login.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 859 行 · 第 1/2 页
PHP
859 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.5| =============================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services, Inc.| | =============================================| Web: | Time: Wed, 01 Mar 2006 19:11:27 GMT| Release: | Licence Info: +---------------------------------------------------------------------------| > $Date: 2006-01-31 22:47:20 +0000 (Tue, 31 Jan 2006) $| > $Revision: 131 $| > $Author: bfarber $+---------------------------------------------------------------------------|| > Log in / log out module| > Module written by Matt Mecham| > Date started: 14th February 2002|| > Module Version Number: 1.0.0| > DBA Checked: Wed 19 May 2004| > Quality Checked: Wed 15 Sept. 2004+--------------------------------------------------------------------------*/if ( ! defined( 'IN_IPB' ) ){ print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files."; exit();}class login{ # Classes var $ipsclass; # Others var $output = ""; var $page_title = ""; var $nav = array(); var $login_html = ""; var $modules = ""; var $han_login = ""; function auto_run() { $this->ipsclass->load_language('lang_login'); $this->ipsclass->load_template('skin_login'); if ( USE_MODULES == 1 ) { require ROOT_PATH."modules/ipb_member_sync.php"; $this->modules = new ipb_member_sync(); $this->modules->ipsclass =& $this->ipsclass; } //----------------------------------------- // Are we enforcing log ins? //----------------------------------------- if ( $this->ipsclass->vars['force_login'] == 1 ) { $msg = 'admin_force_log_in'; } else { $msg = ""; } //----------------------------------------- // What to do? //----------------------------------------- switch( $this->ipsclass->input['CODE'] ) { case '01': $this->do_log_in(); break; case '02': $this->log_in_form(); break; case '03': $this->do_log_out(); break; case '04': $this->markforum(); break; case '05': $this->markboard(); break; case '06': $this->delete_cookies(); break; case 'autologin': $this->auto_login(); break; default: $this->log_in_form($msg); break; } //----------------------------------------- // If we have any HTML to print, do so... //----------------------------------------- $this->ipsclass->print->add_output("$this->output"); $this->ipsclass->print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) ); } /*-------------------------------------------------------------------------*/ // AUTO LOG IN /*-------------------------------------------------------------------------*/ function auto_login() { //----------------------------------------- // Universal routine. // If we have cookies / session created, simply return to the index screen // If not, return to the log in form //----------------------------------------- $this->ipsclass->member = $this->ipsclass->sess->authorise(); //----------------------------------------- // If there isn't a member ID set, do a quick check ourselves. // It's not that important to do the full session check as it'll // occur when they next click a link. //----------------------------------------- if ( ! $this->ipsclass->member['id'] ) { $mid = intval( $this->ipsclass->my_getcookie('member_id') ); $pid = substr( $this->ipsclass->my_getcookie('pass_hash'), 0, 32 ); If ( $mid and $pid ) { $this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'members', 'where' => "id=$mid and member_login_key='$pid'" ) ); $this->ipsclass->DB->simple_exec(); if ( $member = $this->ipsclass->DB->fetch_row() ) { $this->ipsclass->member = $member; $this->ipsclass->session_id = ""; $this->ipsclass->my_setcookie('session_id', '0', -1 ); } } } $true_words = $this->ipsclass->lang['logged_in']; $false_words = $this->ipsclass->lang['not_logged_in']; $method = 'no_show'; if ($this->ipsclass->input['fromreg'] == 1) { $true_words = $this->ipsclass->lang['reg_log_in']; $false_words = $this->ipsclass->lang['reg_not_log_in']; $method = 'show'; } else if ($this->ipsclass->input['fromemail'] == 1) { $true_words = $this->ipsclass->lang['email_log_in']; $false_words = $this->ipsclass->lang['email_not_log_in']; $method = 'show'; } else if ($this->ipsclass->input['frompass'] == 1) { $true_words = $this->ipsclass->lang['pass_log_in']; $false_words = $this->ipsclass->lang['pass_not_log_in']; $method = 'show'; } if ($this->ipsclass->member['id']) { if ($method == 'show') { $this->ipsclass->print->redirect_screen( $true_words, "" ); } else { $this->ipsclass->boink_it($this->ipsclass->vars['board_url'].'/index.'.$this->ipsclass->vars['php_ext']); } } else { if ($method == 'show') { $this->ipsclass->print->redirect_screen( $false_words, 'act=Login&CODE=00' ); } else { $this->ipsclass->boink_it($this->ipsclass->base_url.'&act=Login&CODE=00'); } } } /*-------------------------------------------------------------------------*/ // DELETE IPB COOKIES /*-------------------------------------------------------------------------*/ function delete_cookies() { if (is_array($_COOKIE)) { foreach( $_COOKIE as $cookie => $value) { if (preg_match( "/^(".$this->ipsclass->vars['cookie_id']."ibforum.*$)/i", $cookie, $match)) { $this->ipsclass->my_setcookie( str_replace( $this->ipsclass->vars['cookie_id'], "", $match[0] ) , '-', -1 ); } } } $this->ipsclass->my_setcookie('pass_hash' , '-1'); $this->ipsclass->my_setcookie('member_id' , '-1'); $this->ipsclass->my_setcookie('session_id', '-1'); $this->ipsclass->my_setcookie('topicsread', '-1'); $this->ipsclass->my_setcookie('anonlogin' , '-1'); $this->ipsclass->my_setcookie('forum_read', '-1'); $this->ipsclass->boink_it($this->ipsclass->base_url); exit(); } /*-------------------------------------------------------------------------*/ // MARK ALL AS READ /*-------------------------------------------------------------------------*/ function markboard() { //----------------------------------------- // Reset board marker //----------------------------------------- if ( $this->ipsclass->member['id'] ) { $this->ipsclass->member['members_markers']['board'] = time(); $this->ipsclass->DB->do_update( 'members', array( 'members_markers' => serialize( $this->ipsclass->member['members_markers'] ) ), 'id='.$this->ipsclass->member['id'] ); //----------------------------------------- // Update forum marker rows //----------------------------------------- $this->ipsclass->DB->do_update( 'topic_markers', array( 'marker_unread' => 0, 'marker_last_update' => time(), 'marker_last_cleared' => time(), 'marker_topics_read' => serialize(array()) ), 'marker_member_id='.$this->ipsclass->member['id'] ); } else { $this->ipsclass->forum_read[ 0 ] = time(); $this->ipsclass->hdl_forum_read_cookie('set'); } $this->ipsclass->boink_it($this->ipsclass->base_url.'act=idx'); } /*-------------------------------------------------------------------------*/ // MARK FORUM AS READ /*-------------------------------------------------------------------------*/ function markforum() { //----------------------------------------- // INIT //----------------------------------------- $forum_id = intval($this->ipsclass->input['f']); $from_forum_id = intval($this->ipsclass->input['fromforum']); $forum_data = $this->ipsclass->forums->forum_by_id[ $forum_id ]; $children = $this->ipsclass->forums->forums_get_children( $forum_data['id'] ); $save = array(); $delete = array(); //----------------------------------------- // Check //----------------------------------------- if ( ! $forum_data['id'] ) { $this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files' ) ); } //----------------------------------------- // Come from the index? Add kids //----------------------------------------- if ( $this->ipsclass->input['i'] ) { if ( is_array( $children ) and count($children) ) { foreach( $children as $id ) { $this->ipsclass->forum_read[ $id ] = time(); $delete[] = $id; $save[ $id ] = array( 'marker_forum_id' => $id, 'marker_member_id' => $this->ipsclass->member['id'], 'marker_last_update' => time(), 'marker_unread' => 0, 'marker_last_cleared' => time() ); } } } //----------------------------------------- // Add in the current forum... //----------------------------------------- $this->ipsclass->forum_read[ $forum_data['id'] ] = time(); $delete[] = $forum_data['id']; $save[ $forum_data['id'] ] = array( 'marker_forum_id' => $forum_data['id'], 'marker_member_id' => $this->ipsclass->member['id'], 'marker_last_update' => time(), 'marker_unread' => 0, 'marker_last_cleared' => time() ); //----------------------------------------- // Reset topic markers //----------------------------------------- if ( $this->ipsclass->vars['db_topic_read_cutoff'] and $this->ipsclass->member['id'] ) { if ( count( $delete ) ) { $this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'topic_markers', 'where' => 'marker_member_id='.$this->ipsclass->member['id'].' AND marker_forum_id IN ('.implode(',',$delete ).')' ) ); foreach( $save as $id => $data ) { $this->ipsclass->DB->do_insert( 'topic_markers', $data ); } } } //----------------------------------------- // Reset cookie //----------------------------------------- $this->ipsclass->hdl_forum_read_cookie('set'); //----------------------------------------- // Where are we going back to? //----------------------------------------- if ( $from_forum_id ) { //----------------------------------------- // Its a sub forum, lets go redirect to parent forum //----------------------------------------- $this->ipsclass->boink_it($this->ipsclass->base_url."showforum=".$from_forum_id); } else { $this->ipsclass->boink_it($this->ipsclass->base_url.'act=idx'); } } /*-------------------------------------------------------------------------*/ // LOG IN FORM /*-------------------------------------------------------------------------*/ function log_in_form($message="") { //----------------------------------------- // INIT //----------------------------------------- $extra_form = ""; $show_form = 1; //----------------------------------------- // Load handler... //----------------------------------------- require_once( ROOT_PATH.'sources/handlers/han_login.php' ); $this->han_login = new han_login(); $this->han_login->ipsclass =& $this->ipsclass; $this->han_login->init(); //----------------------------------------- // Are they banned? //----------------------------------------- if ( is_array( $this->ipsclass->cache['banfilters'] ) and count( $this->ipsclass->cache['banfilters'] ) ) { foreach ($this->ipsclass->cache['banfilters'] as $ip) { $ip = str_replace( '\*', '.*', preg_quote($ip, "/") ); if ( preg_match( "/^$ip$/", $this->ipsclass->ip_address ) ) { $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'you_are_banned', 'INIT' => 1 ) ); } } } if ( $message != "" ) { $message = $this->ipsclass->lang[ $message ]; $message = preg_replace( "/<#NAME#>/", "<b>{$this->ipsclass->input[UserName]}</b>", $message ); $this->output .= $this->ipsclass->compiled_templates['skin_login']->errors($message); } //----------------------------------------- // Extra HTML? //----------------------------------------- if ( $this->han_login->login_method['login_alt_login_html'] ) { if ( ! $this->han_login->login_method['login_replace_form'] )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?