Landing interface limited to allow only one machine online

Source: Internet
Author: User
Tags interface log strcmp trim
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 ();
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.