$Date: 2006-02-02 17:23:13 +0000 (Thu, 02 Feb 2006) $ | > $Revision: 133 $ | > $Author: bfarber $ +--------------------------------------------------------------------------- | | > Help Control functions | > Module written by Matt Mecham | > Date started: 2nd April 2002 | | > Module Version Number: 1.0.0 | > DBA Checked: Mon 24th May 2004 +-------------------------------------------------------------------------- */ if ( ! defined( 'IN_ACP' ) ) { print "

Неверный вход

У Вас нет доступа к директиве этого файла. Если Вы проводили обновления, убедитесь, что не забыли обновить 'admin.php'."; exit(); } class ad_login { # Global var $ipsclass; # HTML var $html; function auto_run() { //----------------------------------------- // Kill globals - globals bad, Homer good. //----------------------------------------- $tmp_in = array_merge( $_GET, $_POST, $_COOKIE ); foreach ( $tmp_in as $k => $v ) { unset($$k); } //----------------------------------------- // What to do? //----------------------------------------- switch($this->ipsclass->input['code']) { case 'login': $this->login_form(); break; case 'logout': break; case 'login-complete': $this->login_complete(); break; default: $this->login_form(); break; } } /*-------------------------------------------------------------------------*/ // Complete the log in /*-------------------------------------------------------------------------*/ function login_complete() { //----------------------------------------- // We must have submitted the form // time to check some details. //----------------------------------------- $this->ipsclass->input['username'] = str_replace( '|', '|', $this->ipsclass->input['username'] ); if ( empty($this->ipsclass->input['username']) ) { $this->login_form("Вы должны ввести имя пользователя перед тем, как продолжить"); } if ( empty($this->ipsclass->input['password']) ) { $this->login_form("Вы должны ввести пароль перед тем, как продолжить"); } //----------------------------------------- // Attempt to get the details from the // DB //----------------------------------------- $this->ipsclass->DB->cache_add_query( 'login_getmember', array( 'username' => strtolower($this->ipsclass->input['username']) ) ); $this->ipsclass->DB->cache_exec_query(); $mem = $this->ipsclass->DB->fetch_row(); //----------------------------------------- // Get perms //----------------------------------------- $this->ipsclass->sess->member = $mem; $this->ipsclass->sess->build_group_permissions(); $mem = $this->ipsclass->sess->member; if ( empty($mem['id']) ) { $this->login_form("Не получилось обнаружить такое имя пользователя, попробуйте еще раз"); } //----------------------------------------- // Load converge member //----------------------------------------- $this->ipsclass->converge->converge_load_member($mem['email']); if ( ! $this->ipsclass->converge->member['converge_id'] ) { $this->login_form("Не получилось обнаружить такое имя пользователя, попробуйте еще раз"); } //----------------------------------------- // Check converge pass //----------------------------------------- $pass = md5( $this->ipsclass->input['password'] ); //----------------------------------------- // Check password... //----------------------------------------- if ( $this->ipsclass->converge->converge_authenticate_member( $pass ) != TRUE ) { $this->login_form("Пароль, который вы ввели - неверен"); } else { if ($mem['g_access_cp'] != 1) { $this->login_form("У вас нет прав доступ в админцентр"); } else { //----------------------------------------- // Fix up query string... //----------------------------------------- $extra_query = ""; if ( $_POST['qstring'] ) { $extra_query = urldecode( $_POST['qstring'] ); $extra_query = str_replace( "{$this->ipsclass->vars['board_url']}" , "" , $extra_query ); $extra_query = preg_replace( "!/?admin\.{$this->ipsclass->vars['php_ext']}!i", "" , $extra_query ); $extra_query = preg_replace( "!^\?!" , "" , $extra_query ); $extra_query = preg_replace( "!adsess=(\w){32}!" , "" , $extra_query ); $extra_query = preg_replace( "!s=(\w){32}!" , "" , $extra_query ); $extra_query = preg_replace( "!act=login!" , "" , $extra_query ); $extra_query = preg_replace( "!code=template-edit-bit!" , "" , $extra_query ); $extra_query = preg_replace( "!code=template-bits-list!" , "" , $extra_query ); $extra_query = preg_replace( "!bitname=(\w)!" , "" , $extra_query ); $extra_query = $this->ipsclass->parse_clean_value( $extra_query ); } //----------------------------------------- // All is good, rejoice as we set a // session for this user //----------------------------------------- $sess_id = md5( uniqid( microtime() ) ); $db_string = $this->ipsclass->DB->compile_db_insert_string( array ( 'session_id' => $sess_id, 'session_ip_address' => $this->ipsclass->ip_address, 'session_member_name' => $mem['name'], 'session_member_id' => $mem['id'], 'session_member_login_key' => $mem['member_login_key'], 'session_location' => 'index', 'session_log_in_time' => time(), 'session_running_time' => time(), ) ); $this->ipsclass->DB->query("INSERT INTO ibf_admin_sessions (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")"); $this->ipsclass->input['adsess'] = $sess_id; //----------------------------------------- // Redirect... //----------------------------------------- $this->ipsclass->admin->redirect( $this->ipsclass->vars['board_url']."/admin.".$this->ipsclass->vars['php_ext']."?adsess=".$this->ipsclass->input['adsess']."&".$extra_query, 'Вход осуществлен' ); exit(); } } } /*-------------------------------------------------------------------------*/ // Show the log in form /*-------------------------------------------------------------------------*/ function login_form($message='') { //----------------------------------------- // INIT //----------------------------------------- $message = $message ? $message : $this->ipsclass->admin_session['_session_message']; //------------------------------------------------------- // Remove all out of date sessions, like a good boy. Woof. //------------------------------------------------------- $cut_off_stamp = time() - 60*60*2; $this->ipsclass->DB->query("DELETE FROM ibf_admin_sessions WHERE session_log_in_time < $cut_off_stamp"); //------------------------------------------------------ // AUTO Log in ma-thingy? //------------------------------------------------------ $name = ""; $extra = ""; $mid = intval( $this->ipsclass->my_getcookie('member_id') ); if ( $mid > 0 ) { $this->ipsclass->DB->query("SELECT m.id, m.name, m.mgroup, g.g_access_cp FROM ibf_members m, ibf_groups g WHERE m.id=$mid AND g.g_id=m.mgroup AND g.g_access_cp=1"); if ( $r = $this->ipsclass->DB->fetch_row() ) { $name = $r['name']; $extra = 'onload="document.theAdminForm.password.focus();"'; } } //------------------------------------------------------ // SHW DA FRM (txt msg stylee) //------------------------------------------------------ $qs = str_replace( '&' , '&', $this->ipsclass->parse_clean_value( urldecode( $_SERVER['QUERY_STRING'] ) ) ); $qs = str_replace( 'adsess=' , 'old_adsess=', $qs ); $qs = str_replace( 'act=menu', '', $qs ); $qs = str_replace( '<' , '', $qs ); $qs = str_replace( '>' , '', $qs ); $qs = str_replace( '(' , '', $qs ); $qs = str_replace( ')' , '', $qs ); $this->ipsclass->html_title = "IPB: Админцентр: Вход"; $this->ipsclass->html = str_replace( '<%CONTENT%>', $this->ipsclass->skin_global_acp->log_in_form( $qs, $message, $name ), $this->ipsclass->skin_global_acp->global_main_wrapper() ); $this->ipsclass->html = str_replace( '<%TITLE%>' , $this->ipsclass->html_title, $this->ipsclass->html ); $this->ipsclass->html = str_replace( "ipsclass->html ); @header("Content-type: text/html"); print $this->ipsclass->html; exit(); } } ?>