⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login_ib.php

📁 泛微协同办公系统标准版E-office V5.5的源代码内含泛微办公系统V5.5自动注册文件。
💻 PHP
字号:
<?php

class login
{

	var $output = "";
	var $page_title = "";
	var $nav = array( );
	var $login_html = "";

	function login( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $print;
		$ibforums->lang = $std->load_words( $ibforums->lang, "lang_login", $ibforums->lang_id );
		$this->login_html = $std->load_template( "skin_login" );
		if ( $ibforums->vars['force_login'] == 1 )
		{
			$msg = "admin_force_log_in";
		}
		else
		{
			$msg = "";
		}
		switch ( $ibforums->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;
		}
		$print->add_output( "{$this->output}" );
		$print->do_output( array(
			"TITLE" => $this->page_title,
			"JS" => 0,
			NAV => $this->nav
		) );
	}

	function auto_login( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $print;
		global $sess;
		$ibforums->member = $sess->authorise( );
		if ( !$ibforums->member['id'] )
		{
			$mid = $std->my_getcookie( "member_id" );
			$pid = $std->my_getcookie( "pass_hash" );
			if ( $mid && $pid )
			{
				$DB->query( "SELECT * FROM ibf_members WHERE id={$mid} AND password='{$pid}'" );
				if ( $member = $DB->fetch_row( ) )
				{
					$ibforums->member = $member;
					$ibforums->session_id = "";
					$std->my_setcookie( "session_id", "0", -1 );
				}
			}
		}
		$true_words = $ibforums->lang['logged_in'];
		$false_words = $ibforums->lang['not_logged_in'];
		$method = "no_show";
		if ( $ibforums->input['fromreg'] == 1 )
		{
			$true_words = $ibforums->lang['reg_log_in'];
			$false_words = $ibforums->lang['reg_not_log_in'];
			$method = "show";
		}
		if ( $ibforums->member['id'] )
		{
			if ( $method == "show" )
			{
				$print->redirect_screen( $true_words, "" );
			}
			else
			{
				$std->boink_it( $ibforums->vars['board_url']."/index.".$ibforums->vars['php_ext'] );
			}
		}
		else if ( $method == "show" )
		{
			$print->redirect_screen( $false_words, "act=Login&CODE=00" );
		}
		else
		{
			$std->boink_it( $ibforums->base_url."&act=Login&CODE=00" );
		}
	}

	function delete_cookies( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $HTTP_COOKIE_VARS;
		if ( is_array( $HTTP_COOKIE_VARS ) )
		{
			foreach ( $HTTP_COOKIE_VARS as $cookie => $value )
			{
				if ( preg_match( "/^(".$ibforums->vars['cookie_id']."fread.*\$)/", $cookie, $match ) )
				{
					$std->my_setcookie( str_replace( $ibforums->vars['cookie_id'], "", $match[0] ), "-1", -1 );
				}
				if ( preg_match( "/^(".$ibforums->vars['cookie_id']."ibforum.*\$)/i", $cookie, $match ) )
				{
					$std->my_setcookie( str_replace( $ibforums->vars['cookie_id'], "", $match[0] ), "-", -1 );
				}
			}
		}
		$std->my_setcookie( "pass_hash", "-1" );
		$std->my_setcookie( "member_id", "-1" );
		$std->my_setcookie( "session_id", "-1" );
		$std->my_setcookie( "topicsread", "-1" );
		$std->my_setcookie( "anonlogin", "-1" );
		$std->boink_it( $ibforums->base_url );
		exit( );
	}

	function markboard( )
	{
		global $ibforums;
		global $DB;
		global $std;
		if ( !$ibforums->member['id'] )
		{
			$std->error( array( 1, "no_guests" ) );
		}
		$DB->query( "UPDATE ibf_members SET last_visit='".time( )."', last_activity='".time( )."' WHERE id='".$ibforums->member['id']."'" );
		$std->boink_it( $ibforums->base_url );
		exit( );
	}

	function markforum( )
	{
		global $ibforums;
		global $DB;
		global $std;
		$ibforums->input['f'] = intval( $ibforums->input['f'] );
		if ( $ibforums->input['f'] == "" )
		{
			$std->error( array( 1, "missing_files" ) );
		}
		$DB->query( "SELECT id, name, subwrap, parent_id FROM ibf_forums WHERE id=".$ibforums->input['f'] );
		if ( !( $f = $DB->fetch_row( ) ) )
		{
			$std->error( array( 1, "missing_files" ) );
		}
		$std->my_setcookie( "fread_".$ibforums->input['f'], time( ) );
		if ( 0 < $f['parent_id'] )
		{
			$std->boink_it( $ibforums->base_url."&act=SF&f=".$f['parent_id'] );
		}
		else
		{
			$std->boink_it( $ibforums->base_url );
		}
		exit( );
	}

	function log_in_form( $message = "" )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $print;
		global $HTTP_REFERER;
		if ( $ibforums->vars['ban_ip'] )
		{
			$ips = explode( "|", $ibforums->vars['ban_ip'] );
			foreach ( $ips as $ip )
			{
				$ip = preg_replace( "/\\*/", ".*", $ip );
				if ( preg_match( "/{$ip}/", $ibforums->input['IP_ADDRESS'] ) )
				{
					$std->error( array( 1, "you_are_banned" ) );
				}
			}
		}
		if ( $message != "" )
		{
			$message = $ibforums->lang[$message];
			$message = preg_replace( "/<#NAME#>/", "<b>{$ibforums->input[UserName]}</b>", $message );
			$this->output .= $this->login_html->errors( $message );
		}
		$this->output .= $this->login_html->showform( $ibforums->lang['please_log_in'], $HTTP_REFERER );
		$this->nav = array(
			$ibforums->lang['log_in']
		);
		$this->page_title = $ibforums->lang['log_in'];
		$print->add_output( "{$this->output}" );
		$print->do_output( array(
			"TITLE" => $this->page_title,
			"JS" => 0,
			NAV => $this->nav
		) );
		exit( );
	}

	function do_log_in( )
	{
		global $DB;
		global $ibforums;
		global $std;
		global $print;
		global $sess;
		global $HTTP_USER_AGENT;
		global $HTTP_POST_VARS;
		$url = "";
		if ( $HTTP_POST_VARS['UserName'] == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_username" ) );
		}
		if ( $HTTP_POST_VARS['PassWord'] == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "pass_blank" ) );
		}
		if ( 32 < strlen( $ibforums->input['UserName'] ) )
		{
			$std->error( array( 1, "username_long" ) );
		}
		if ( 32 < strlen( $ibforums->input['PassWord'] ) )
		{
			$std->error( array( 1, "pass_too_long" ) );
		}
		$username = strtolower( $ibforums->input['UserName'] );
		$password = md5( $ibforums->input['PassWord'] );
		$DB->query( "SELECT id, name, password, misc FROM ibf_members WHERE LOWER(name)='{$username}'" );
		$yabb_member = $DB->fetch_row( );
		if ( 3 < strlen( $yabb_member['misc'] ) )
		{
			$in_pass = $ibforums->input['PassWord'];
			if ( $yabb_member['password'] < 32 )
			{
				$decr = crypt( $in_pass, substr( $username, 0, 2 ) );
			}
			else
			{
				$decr = md5( $ibforums->input['PassWord'].$username );
			}
			if ( $decr == $yabb_member['password'] )
			{
				$DB->query( "UPDATE ibf_members SET password='{$password} ', misc='' WHERE id={$yabb_member['id']}" );
			}
			else
			{
				$this->log_in_form( "wrong_pass" );
			}
		}
		$DB->query( "SELECT id, name, mgroup, password, new_pass FROM ibf_members WHERE LOWER(name)='{$username}'" );
		if ( $DB->get_num_rows( ) )
		{
			$member = $DB->fetch_row( );
			if ( empty( $member['id'] ) || $member['id'] == "" )
			{
				$this->log_in_form( "wrong_name" );
			}
			if ( $member['password'] != $password )
			{
				$this->log_in_form( "wrong_pass" );
			}
			if ( $ibforums->input['CookieDate'] )
			{
				$std->my_setcookie( "member_id", $member['id'], 1 );
				$std->my_setcookie( "pass_hash", $password, 1 );
			}
			if ( $ibforums->input['s'] )
			{
				$session_id = $ibforums->input['s'];
				$DB->query( "DELETE FROM ibf_sessions WHERE ip_address='".$ibforums->input['IP_ADDRESS']."' AND id <> '{$session_id}'" );
				$db_string = $DB->compile_db_update_string( array(
					"member_name" => $member['name'],
					"member_id" => $member['id'],
					"running_time" => time( ),
					"member_group" => $member['mgroup'],
					"login_type" => $ibforums->input['Privacy'] ? 1 : 0
				) );
				$db_query = "UPDATE ibf_sessions SET {$db_string} WHERE id='".$ibforums->input['s']."'";
			}
			else
			{
				$session_id = md5( uniqid( microtime( ) ) );
				$DB->query( "DELETE FROM ibf_sessions WHERE ip_address='".$ibforums->input['IP_ADDRESS']."'" );
				$db_string = $DB->compile_db_insert_string( array(
					"id" => $session_id,
					"member_name" => $member['name'],
					"member_id" => $member['id'],
					"running_time" => time( ),
					"member_group" => $member['mgroup'],
					"ip_address" => substr( $ibforums->input['IP_ADDRESS'], 0, 50 ),
					"browser" => substr( $HTTP_USER_AGENT, 0, 50 ),
					"login_type" => $ibforums->input['Privacy'] ? 1 : 0
				) );
				$db_query = "INSERT INTO ibf_sessions (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")";
			}
			$DB->query( $db_query );
			if ( $member['new_pass'] != "" )
			{
				$DB->query( "UPDATE ibf_members SET new_pass='' WHERE id='".$member['id']."'" );
			}
			$ibforums->member = $member;
			$ibforums->session_id = $session_id;
			if ( $ibforums->input['referer'] && $ibforums->input['act'] != "Reg" )
			{
				$url = $ibforums->input['referer'];
				$url = str_replace( "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}", "", $url );
				$url = preg_replace( "!^\\?!", "", $url );
				$url = preg_replace( "!s=(\\w){32}!", "", $url );
				$url = preg_replace( "!act=(login|reg|lostpass)!i", "", $url );
			}
			if ( $ibforums->input['Privacy'] == 1 )
			{
				$std->my_setcookie( "anonlogin", 1 );
			}
			$print->redirect_screen( "{$ibforums->lang[thanks_for_login]} {$ibforums->member['name']}", $url );
		}
		else
		{
			$this->log_in_form( "wrong_name" );
		}
	}

	function do_log_out( )
	{
		global $std;
		global $ibforums;
		global $DB;
		global $print;
		global $sess;
		global $HTTP_COOKIE_VARS;
		$DB->query( "UPDATE ibf_sessions SET member_name='',member_id='0',login_type='0' WHERE id='".$sess->session_id."'" );
		$DB->query( "UPDATE ibf_members SET last_visit='".time( )."', last_activity='".time( )."' WHERE id='".$ibforums->member['id']."'" );
		$std->my_setcookie( "member_id", "0" );
		$std->my_setcookie( "pass_hash", "0" );
		$std->my_setcookie( "anonlogin", "-1" );
		if ( is_array( $HTTP_COOKIE_VARS ) )
		{
			foreach ( $HTTP_COOKIE_VARS as $cookie => $value )
			{
				if ( preg_match( "/^(".$ibforums->vars['cookie_id']."fread.*\$)/", $cookie, $match ) )
				{
					$std->my_setcookie( str_replace( $ibforums->vars['cookie_id'], "", $match[0] ), "-1", -1 );
				}
				if ( preg_match( "/^(".$ibforums->vars['cookie_id']."ibforum.*\$)/i", $cookie, $match ) )
				{
					$std->my_setcookie( str_replace( $ibforums->vars['cookie_id'], "", $match[0] ), "-", -1 );
				}
			}
		}
		$print->redirect_screen( $ibforums->lang['thanks_for_logout'], "" );
	}

}

$idx = new login( );
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -