# <?php
# ob_start();
# session_start();
# class CC{
# private $REFURL="http://www.BkJia.com"; //登陸成功後轉換頁面
# private $LoginFLAG=false; //登陸成功標志
# private $loginFILE="loginmsg.txt"; //信息文件
# function setFlag($flag){
# $this->loginFLAG=$flag;
# }
# function check(){
# global $_POST;
# if(file_exists($this->loginFILE)&& (time()-filemtime($this->loginFILE))<60){//用戶登陸存在而且有效
# $info=file($this->loginFILE);
# $username=trim($info[0]); //已在線的登陸用戶名
# $password=trim($info[1]); //已在線密碼(可以不保存)
# $ip =trim($info[2]); //已在線IP
# $sid =trim($info[3]); //已在線PORT
# if(strcmp($_SESSION[LoginUser],$username)==0){
# if(strcmp($_SESSION[LoginPw],$password)==0){
# if(strcmp($_SERVER[REMOTE_ADDR],$ip)==0){
# if(strcmp(session_id(),$sid)==0){
# $this->setFlag(true);
# echo "<h3>您的帳戶可以確定是唯一的!</h3>";
# $cf=fopen($this->loginFILE,"a+");
# fputs($cf,"
a");
# fclose($cf);
# echo "<meta http-equiv=refresh content="10;url=t.php">";
# //echo "<iframe src="t.php" frameborder=0 width=0 height=0></iframe>";
# }else{
# echo "不允許帳戶在局網上同時登陸.. ".$_SERVER[REMOTE_PORT];
# $this->LoginFLAG=false;
# }
# }else{
# echo "不允許使用帳戶同時登陸..<br>";
# $this->LoginFLAG=false;
# }
# }else{
# echo "密碼錯誤..<br>";
# $this->LoginFLAG=false;
# }
# }else{
# //這裡驗證身份如果正確則
# echo "帳戶登陸時發生錯誤!用戶名錯誤<br><pre>";
# }
# }else{
# if(isset($_POST[LoginUser])){
# $_SESSION[LoginUser]=$_POST[LoginUser];
# $_SESSION[LoginPw]=$_POST[LoginPw];
# $fp=fopen($this->loginFILE,"w");
# $msg=$_POST[LoginUser]."
".$_POST[LoginPw]."
".$_SERVER[REMOTE_ADDR]."
".session_id();;
# fputs($fp,$msg);
# fclose($fp);
# }else{
# $outtime=time()-filemtime($this->loginFILE)-60;
# echo "登陸不存在或您已經超時(".$outtime."秒)...";
# }
# }
# }
# function Wfrom(){
# global $_POST;
# if(!file_exists($this->loginFILE) ||(time()-filemtime($this->loginFILE))>60){ //登陸失敗
# echo <<<LOGINFORM
# <Form action="$_SERVER[PHP_SELF]" method="post" name="Loginform">
# <table cellpadding=0 border=0>
# <tr><td>
# 用戶名:<td><input type="text" name="LoginUser"></span><br>
# <tr><td>密碼:<td><input type="password" name="LoginPw"></span><br>
# <tr><td> <td><input type="button" value=" Login " onclick="if(this.form.LoginUser.length*this.form.LoginPw.length!=0){this.form.submit();}else{return false;}">
# </table>
# </form>
# LOGINFORM;
# }else{
# echo "已有用戶登陸";
# }
# }
# }
# $D=new CC;
# $D->check();
# $D->Wfrom();
# ?>