login.php

来自「flashget43的源代码 一个比较常用的下载程序」· PHP 代码 · 共 46 行

PHP
46
字号
<?php

include_once('init.php');

$error = '';

function doLogin($userid) {
	global $smarty;
	$_SESSION['userid'] = $userid;
	include('index.php');
	exit;
}

if(($userid = ChatServer::isLoggedIn()) && ChatServer::userInRole($userid, ROLE_ADMIN)) 
{
	doLogin($userid);
} else {
	$_SESSION['userid'] = null;
}	

if(isset($_REQUEST['do'])) {
	if(($userid = ChatServer::login($_REQUEST['login'], $_REQUEST['password'])) && ChatServer::userInRole($userid, ROLE_ADMIN)) {
		doLogin($userid);
	} else {
		$_SESSION['userid'] = null;
		$error = 'Could not grant admin role for this login and password.';
	}
} else {
	$_SESSION['userid'] = null;
	$_REQUEST['login'] = '';
	$_REQUEST['password'] = '';
}

$installed = isInstalled();
if( !$installed ) 
{
	$_SESSION['userid'] = null;
	$error = 'FlashChat is not installed.';
}
 
//Assign Smarty variables and load the admin template
$smarty->assign('error',$error);
$smarty->assign('installed',$installed);
$smarty->display('login.tpl');

?>

⌨️ 快捷键说明

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