<p> <code><?php<br />ob_start();<br />session_start();<br />class CC{<br /> private $REFURL="http://www.abc.com"; //登陆成功后转换页面<br /> private $LoginFLAG=false; //登陆成功标志<br /> private $loginFILE="loginmsg.txt"; //信息文件<br /> function setFlag($flag){<br /> $this->loginFLAG=$flag;<br /> }<br /> function check(){<br /> global $_POST;<br /> if(file_exists($this->loginFILE)&& (time()-filemtime($this->loginFILE))<60){//用户登陆存在而且有效<br /> $info=file($this->loginFILE);<br /> $username=trim($info[0]); //已在线的登陆用户名<br /> $password=trim($info[1]); //已在线密码(可以不保存)<br /> $ip  =trim($info[2]); //已在线IP<br /> $sid  =trim($info[3]); //已在线PORT<br /> if(strcmp($_SESSION[LoginUser],$username)==0){<br /> if(strcmp($_SESSION['LoginPw'],$password)==0){<br /> if(strcmp($_SERVER[REMOTE_ADDR],$ip)==0){<br /> if(strcmp(session_id(),$sid)==0){<br /> $this->setFlag(true);<br /> echo "<h3>您的帐户可以确定是唯一的!</h3>";<br /> $cf=fopen($this->loginFILE,"a+");<br /> fputs($cf,"\r\na");<br /> fclose($cf);<br /> echo "<meta http-equiv=refresh content=\"10;url=t.php\">";<br /> //echo "<iframe src=\"t.php\" frameborder=0 width=0 height=0></iframe>";<br /> }else{<br /> echo "不允许帐户在局网上同时登陆.. ".$_SERVER[REMOTE_PORT];<br /> $this->LoginFLAG=false;<br /> }  <br /> }else{<br /> echo "不允许使用帐户同时登陆..<br>";<br /> $this->LoginFLAG=false;<br /> }<br /> }else{<br /> echo "密码错误..<br>";<br /> $this->LoginFLAG=false;<br /> }<br /> }else{<br /> //这里验证身份如果正确则<br /> echo "帐户登陆时发生错误!用户名错误<br><pre>";<br /> }<br /> }else{<br /> if(isset($_POST[LoginUser])){<br /> $_SESSION[LoginUser]=$_POST[LoginUser];<br /> $_SESSION[LoginPw]=$_POST[LoginPw];<br /> $fp=fopen($this->loginFILE,"w");<br /> $msg=$_POST['LoginUser']."\r\n".$_POST['LoginPw']."\r\n".$_SERVER[REMOTE_ADDR]."\r\n".session_id();;<br /> fputs($fp,$msg);<br /> fclose($fp);<br /> }else{<br /> $outtime=time()-filemtime($this->loginFILE)-60;<br /> echo "登陆不存在或您已经超时(".$outtime."秒)...";<br /> }<br /> }<br /> }<br /> function Wfrom(){<br /> global $_POST;<br /> if(!file_exists($this->loginFILE) ||(time()-filemtime($this->loginFILE))>60){ //登陆失败<br /> echo <<<LOGINFORM<br /> <Form action="$_SERVER[PHP_SELF]" method="post" name="Loginform"><br /> <table cellpadding=0 border=0><br /> <tr><td><br /> 用户名:<td><input type="text" name="LoginUser"></span><br><br /> <tr><td>密码:<td><input type="password" name="LoginPw"></span><br><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;}"><br /> </table><br /> </form><br />LOGINFORM;<br /> }else{<br /> echo "已有用户登陆";<br /> }<br /> }<br />}<br />$D=new CC;<br />$D->check();<br />$D->Wfrom();<br />?></code></p>