Landing interface limited to allow only one machine online
Last Update:2017-02-28
Source: Internet
Author: User
Online <?php
Ob_start ();
Session_Start ();
Class cc{
Private $REFURL = "http://www.abc.com"; Convert page after successful landing
Private $LoginFLAG =false; Landing Success Sign
Private $loginFILE = "Loginmsg.txt"; Information file
function Setflag ($flag) {
$this->loginflag= $flag;
}
function Check () {
Global $_post;
if (file_exists ($this->loginfile) && (Time ()-filemtime ($this->loginfile)) <60) {//user login exists and is valid
$info =file ($this->loginfile);
$username =trim ($info [0]); Logged in User name online
$password =trim ($info [1]); Online password (can not be saved)
$ip =trim ($info [2]); Already online IP
$sid =trim ($info [3]); Already online 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 $CF =fopen ($this->loginfile, "A +");
Fputs ($CF, "\r\na");
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 "does not allow the account to land at the same time on the Bureau web." $_server[remote_port];
$this->loginflag=false;
}
}else{
echo "is not allowed to log in simultaneously with the account. <br> ";
$this->loginflag=false;
}
}else{
echo ' password error. <br> ";
$this->loginflag=false;
}
}else{
This verifies the identity, if correct,
echo "Account Log in Error! User name error <br><pre> ";
}
}else{
if (Isset ($_post[loginuser])) {
$_session[loginuser]=$_post[loginuser];
$_SESSION[LOGINPW]=$_POST[LOGINPW];
$FP =fopen ($this->loginfile, "w");
$msg =$_post[' Loginuser ']. " \ r \ n ". $_post[' LOGINPW ']." \ r \ n ". $_server[remote_addr]." \ r \ n ". session_id ();;
Fputs ($fp, $msg);
Fclose ($FP);
}else{
$outtime =time ()-filemtime ($this->loginfile)-60;
echo "Login does not exist or you have timed out (". $outtime. " seconds) ... ";
}
}
}
function Wfrom () {
Global $_post;
if (!file_exists ($this->loginfile) | | (Time ()-filemtime ($this->loginfile)) >60) {//Login failed
Echo <<<loginform
<form action= "$_server[php_self]" method= "POST" name= "LoginForm" >
<table cellpadding=0 border=0>
<tr><td>
User name: <td><input type= "text" name= "Loginuser" ></span><br>
<tr><td> Password: <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 "Already have user login";
}
}
}
$D =new CC;
$D->check ();
$D->wfrom ();
?>