Location: PHPKode > projects > Bcom > bcom-1.99.1/bcom/include/login.inc
<?
//login page

require_once('lib/liblayout.inc');

global $CLIlogin,$CLIpw,$CLIid,$_POST,$CLImagic,$PHP_SELF,$BCOM_ERROR,$BCOM_COUNT;
global $_SESSION,$_BCOM;
$CLImagic = '';
if(isset($_POST['clilogin'])) {
	$password = $_POST['password'];
   	$CLIlogin = $_POST['clilogin'];
	//foreach($GLOBALS as $var => $val) { if(substr($var,0,8) == 'password') { $CLIpw = $val; } }
   	$result = bsql_query('select * from users where u_login = \''.$CLIlogin.'\';') or sdie();
   	if($row = bsql_getrow($result)) {
		if($row['u_password'] == md5($password)) {
			$CLIid = $row['u_id'];
			$CLIpw = md5($password);
			mt_srand(time());
			$CLImagic = md5(uniqid(mt_rand()));
			setuseroption('general','CLImagic',$CLImagic);
			bcom_syslog('Successfull login');
			bcom_commitsyslog();
			//$HTTP_SESSION_VARS['CLIlogin'] = $CLIlogin;
			refreshdisplay(basename($PHP_SELF).'?');
			exit;
		}
	}
}
$message = 'Login Failed!<BR>Please try again.';
if($mode == 'embed') {
	print '<TABLE CELLPADDING="2" CELLSPACING="2" BORDER="0"><FORM METHOD="POST" ACTION="'.$PHP_SELF.'">
   	<TR><TH>Username:</TH><TD CLASS="bar1">'.ui_textbox('clilogin','').'</TD>
   	<TH>Password:</TH><TD CLASS="bar1">'.ui_textbox('clilogin','',10,255,'password').'</TD>
	<TD CLASS="bar2"><INPUT TYPE="submit" VALUE="login"></TD></TR></FORM></TABLE>';
	return;
} else {
	if(basename($PHP_SELF)!='index.php') {
		refreshdisplay(basename($PHP_SELF).'?');
	}
   	iheader('title=Bcom Login');
   	if(isset($BCOM_ERROR)) { print "<BR>$BCOM_ERROR<BR>"; }
   	print '<DIV ALIGN="CENTER"><TABLE BORDER="0" CELLPADDING="8">
	<TD>';	
	if(getoption('company','logo') != 0) {
		print formatobject(getoption('company','logo'));
	}
	else {
		print '<IMG SRC="'.$_BCOM['images'].'/bcomlogin.png">';
	}

	print '</TD>
	<TD><TABLE CELLPADDING="2" CELLSPACING="2" BORDER="0">
	<FORM METHOD="POST" ACTION="'.$_BCOM['secureself'].'index.php">
	<INPUT TYPE="HIDDEN" NAME="U'.session_name().'" VALUE="'.session_id().'">
		
	<TR><TH COLSPAN="2">Welcome to bcom</TH></TR>
    <TR><TH>Username:</TH><TD CLASS="bar1">'.ui_textbox('clilogin','').'</TD></TR>
    <TR><TH>Password:</TH><TD CLASS="bar1">'.ui_textbox('password','',10,255,'password').'</TD>
    <TR><TD CLASS="bar2" COLSPAN="2">'.formbutton('login','login').'</TD></TR>
	</FORM></TABLE>
		
	</TD></TABLE>
	</DIV>';
	ui_end();
}

?>
Return current item: Bcom