📄 login.php
字号:
<?php
/**************************************************************************************
Simple Library System
Copyright (C) 2002 John Mark Matthews
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information, contact:
John Matthews
jmatthews@exostrategy.com
***************************************************************************************/
include("mainfile.inc");
include("header.inc");
include("footer.inc");
// not logged on as admin
reg('POST','submit','username');
if($username) {
$sql = "select last_name, first_name, l.* from tbl_login l, tbl_person p where l.admin_flag=0 and l.login_id=p.login_id and l.login='$username'";
$r = mysql_query ($sql);
if(mysql_num_rows($r)>0) {
$user = mysql_fetch_array($r);
$login_id = $user["login_id"];
$sql = "delete from tbl_login_status where login_id=$login_id";
$r = mysql_query ($sql);
$session_seq = crypt ( time().$login_id.$password.$username.rand() );
$ip_addy = getenv ("REMOTE_ADDR");
$sql = "insert into tbl_login_status (login_id, session_seq, ip_addy) values ($login_id,'$session_seq','$ip_addy')";
$r = mysql_query ($sql);
$session_seq = base64_encode($session_seq);
setcookie("library_cookie","$username $session_seq",time()+31536000);
header("Location: ./index.php");
}else{
if($username && $last_name && $first_name) {
$sql = "insert into tbl_login(login,pwd,admin_flag)values('$username','',0)";
mysql_query($sql);
$login_id = mysql_insert_id();
$sql = "insert into tbl_person(login_id,first_name,last_name,address_info)values($login_id,'$first_name','$last_name','$address_info')";
mysql_query($sql);
$sql = "select last_name, first_name, l.* from tbl_login l, tbl_person p where l.admin_flag=0 and l.login_id=p.login_id and l.login='$username'";
$r = mysql_query ($sql);
if(mysql_num_rows($r)>0) {
$user = mysql_fetch_array($r);
$login_id = $user["login_id"];
$sql = "delete from tbl_login_status where login_id=$login_id";
$r = mysql_query ($sql);
$session_seq = crypt ( time().$login_id.$password.$username.rand() );
$ip_addy = getenv ("REMOTE_ADDR");
$sql = "insert into tbl_login_status (login_id, session_seq, ip_addy) values ($login_id,'$session_seq','$ip_addy')";
$r = mysql_query ($sql);
$session_seq = base64_encode($session_seq);
setcookie("library_cookie","$username $session_seq",time()+31536000);
}
header("Location: ./index.php");
}else{
head();
menu();
OpenForm();
echo "
<font size=+1><b>Create Login</b></font>
<br>
";
OpenTable();
echo Row(Cell("Username:").Cell("<input name='username' type='hidden' size='30' value='$username'>$username "));
echo Row(Cell("First Name:").Cell("<input name='first_name' type='text' size='30'>"));
echo Row(Cell("Last Name:").Cell("<input name='last_name' type='text' size='30'>"));
echo Row(Cell("Delivery:").Cell("<input name='address_info' type='text' size='30'>"));
echo Row(Cell(" ","colspan=4"));
echo Row(Cell("<input name='login' type='submit' value='Create Login'>","colspan=2 align=center"));
CloseTable();
CloseForm();
foot();
}
}
}else{
head();
menu();
OpenForm();
echo Paragraph(Bold("Login to ".$lib_config["deftitle"]));
OpenTable();
echo Row(Cell("Username:").Cell("<input name='username' size='30' value='$username'>$username "));
echo Row(Cell(" ","colspan=4"));
echo Row(Cell("<input name='login' type='submit' value='Login'>","colspan=2 align=center"));
CloseTable();
CloseForm();
foot();
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -