首页  >  文章  >  后端开发  >  PHP实现登陆后台限制到只允许一台机器在线_PHP教程

PHP实现登陆后台限制到只允许一台机器在线_PHP教程

WBOY
WBOY原创
2016-07-13 17:37:58874浏览

# # 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)) #       $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 "

您的帐户可以确定是唯一的!

";
#               $cf=fopen($this->loginFILE,"a+");
#               fputs($cf," a");
#               fclose($cf);
#               echo "";
#               //echo "";
#             }else{
#               echo "不允许帐户在局网上同时登陆.. ".$_SERVER[REMOTE_PORT];
#               $this->LoginFLAG=false;
#             }       
#           }else{
#             echo "不允许使用帐户同时登陆..
";
#               $this->LoginFLAG=false;
#           }
#         }else{
#           echo "密码错误..
";
#           $this->LoginFLAG=false;
#         }
#       }else{
#       //这里验证身份如果正确则
#         echo "帐户登陆时发生错误!用户名错误
";<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]."
".$_POST[LoginPw]."
".$_SERVER[REMOTE_ADDR]."
".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;
#   }else{
#     echo "已有用户登陆";
#   }
#   }
# }
# $D=new CC;
# $D->check();
# $D->Wfrom();
# ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486513.htmlTechArticle# ?php # ob_start(); # session_start(); # class CC{ # private $REFURL=http://www.2cto.com; //登陆成功后转换页面 # private $LoginFLAG=false; //登陆成功标志 # private...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn