www.gusucode.com > 搜一次CMS电影程序 PHP 1.5源码程序 > users/login.php

    <?php
include "../include/label.php";
//'**************************************************************************************************
//' 软件名称: 搜一次 Content Management System
//' 版本编号: V4.0.0版
//' 官方网站: http://www.syccms.com
//' 官方论坛:http://bbs.syccms.com
//' 软件编写: 无痕(QQ:512591),暮寒,新手℡鼠标
//' 郑重声明:
//'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息;
//'    2、搜一次网络有限公司保留此软件的法律追究权利
//'**************************************************************************************************
global $db;
$UserIP = getenv('REMOTE_ADDR');
$sqlse="select * from s_users where S_Group=1 and S_StartIP='".$UserIP."'";
$resultse=$db->query($sqlse);
if($resultse){
$rowse=$db->fetch_array($resultse);
	if($rowse){
	setcookie("S_Name",$rowse["S_Name"],time()+3600);
	setcookie("S_PWD",$rowse["S_PassWord"],time()+3600);
	}
}



$action=SafeRequest("action","get");
switch($action){
	case "checklog" :
		CheckLog();
		break;
	case "showlog" :
		ShowLog();
		break;
	case "showinfo" :
		ShowInfo();
		break;
	case "delcook" :
		DelCook();
		break;
	case "checkcookies" :
		CheckCookies();
		break;
	default:
		CheckCookies();
		break;
}


function CheckLog(){
	global $db;
	$S_Name=SafeRequest("S_Name","post");
	$S_PassWord=SafeRequest("S_PassWord","post");
	$Code=SafeRequest("codes","post");
	if(($S_Name=="")||($S_PassWord=="")){
		echo("<script>alert('请输入帐号密码!');window.history.go(-1);</script>");
	}
	else{
		if($_SESSION["codes"]!=$Code){
			echo("<script>alert('验证码错误,请重新输入!');window.history.go(-1);</script>");
		}
		else{
			$S_PassWord=Md5($S_PassWord);
			$sql="select * from s_users where S_Name='".$S_Name."'";
			$result=$db->query($sql);
			if($row=$db->fetch_array($result)){
				if($row["S_PassWord"]==$S_PassWord){
					setcookie('S_Name',$S_Name,time()+3600,S_SitePath);
					setcookie('S_PWD',$S_PassWord,time()+3600);
					if($row["S_Group"]==1){
						setcookie("S_LogName",$S_Name,time()+3600);
					}
					$S_LogIP=$row["S_LogIP"];
					if($S_LogIP==""){
					}
					else{
						setcookie("S_LogIP",$S_LogIP,time()+3600);
					}
					$S_LogNum=$row["S_LogNum"]+1;
					$S_LogTime=date("Y-m-d");
					$S_LogIP = getenv('REMOTE_ADDR');
					$update="update s_users set S_LogNum='".$S_LogNum."',S_LogTime='".$S_LogTime."',S_LogIP='".$S_LogIP."' where S_Name='".$S_Name."'";
					$db->query($update);
					echo("<script>window.location='?action=showinfo'</script>");
				}
				else{
					echo("<script>alert('密码错误,请重新输入!');window.history.go(-1);</script>");
				}
			}
			else{
				echo("<script>alert('帐号不存在,请重新输入!');window.history.go(-1);</script>");
			}
		}
	}
}

function DelCook(){
	setcookie("S_Name","",time()-3600);
	setcookie("S_PWD","",time()-3600);
	setcookie("S_LogName","",time()-3600);
	echo "<script>window.location='login.php';</script>";
}

function CheckCookies(){
	global $db;
	if((empty($_COOKIE["S_Name"]))||(empty($_COOKIE["S_PWD"]))){
		ShowLog();
	}
	else{
		$sql="select * from s_users where S_Name='".$_COOKIE["S_Name"]."'";
		$result=$db->query($sql);
		if($result){
			$row=$db->fetch_array($result);
			if($row["S_PassWord"]!=$_COOKIE["S_PWD"]){
				ShowLog();
			}
			else{
				ShowInfo();
			}
		}
		else{
			ShowLog();
		}
	}
}

function ShowInfo(){
	global $db;
	$S_Name=$_COOKIE["S_Name"];
	$sqlv="select * from s_users where S_Name='".$S_Name."'";
	$resultv=$db->query($sqlv);
	$rowv=$db->fetch_array($resultv);
	$sqlvg="select * from s_usersgroup where S_ID=".$rowv["S_Type"];
	$resultvg=$db->query($sqlvg);
	$rowvg=$db->fetch_array($resultvg);
	if($rowv["S_UseType"]==0){$s_usertype="剩余点数:";}else{$s_usertype="到期时间:";}
	if($rowv["S_UseType"]==0){$s_userpoints=$rowv["S_Coin"];}else{$s_userpoints=$rowv["S_UseDate"];}
	$str=file_get_contents("../".S_Templateurl."/logininfo.html");
	$str=str_replace('{s_username}',$_COOKIE["S_Name"],$str);
	$str=str_replace('{s_usergroup}',$rowvg["S_Name"],$str);
	$str=str_replace('{s_usertype}',$s_usertype,$str);
	$str=str_replace('{s_userpoints}',$s_userpoints,$str);
	$str=str_replace('{s_userlogout}','?action=delcook',$str);
	$str=str_replace('{s_userboard}','index.php',$str);
	echo($str);
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员登录</title>
<script language="javascript">
function checklg(){
	var S_Name=form1.S_Name.value;
	var S_PWD=form1.S_PassWord.value;
	var codes=form1.codes.value;
	form1.S_Name.style.borderColor='#666 #ccc #ccc #666';
	form1.S_PassWord.style.borderColor='#666 #ccc #ccc #666';
	form1.codes.style.border='1px #eaeaea solid';
	if(S_Name==""){
		form1.S_Name.style.border='1px solid red';
		return false;
		};
	else if(len(S_Name)>16){
		form1.S_Name.style.border='1px solid red';
		return false;
		};
	else if(S_PWD==""){
		form1.S_PassWord.style.border='1px solid red';
		return false;
		};
	else if(len(S_PWD)>18){
		form1.S_PassWord.style.border='1px solid red';
		return false;
		};
	else if(codes==""){
		form1.codes.style.border='1px solid red';
		return false;
		};
	else if(codes.length!=4){
		form1.codes.style.border='1px solid red';
		return false;
		};
	};
function len(s) {
	var l = 0;
	var a = s.split("");
	for (var i=0;i<a.length;i++) {
	if (a[i].charCodeAt(0)<299) {
		l++;
		}
	else{
   l+=2;
		}
	}
	return l;
}
</script>

</head>
<body>
<?php

function ShowLog(){
?>
<form method="post" action="?action=checklog" name="form1" id="form1">
<?php
$str=file_get_contents("../".S_Templateurl."/loginuser.html");
$str=str_replace('{s_usercode}',"<img src='../include/code.php' name='imgcode' id='imgcode'>",$str);
$str=str_replace('{s_userreg}',"userreg.php",$str);
$str=str_replace('{s_userfin}',"userfin.php",$str);
echo(Common_Mark($str,0));
}
?>
</form>



</body>
</html>