PHP supports logging on to the background to allow only one machine to go online.

Source: Internet
Author: User
? Php (); session_start (); CC {private $ REFURL = http://www.cncms.com.cn; // after successful login, convert the page private $ LoginFLAG = false; // Login success sign private?loginfile=loginmsg.txt;

# # Ob_start ();
# Session_start ();
# Class CC {
# Private $ REFURL = "http://www.php100.com"; // The conversion page after successful login
# Private $ LoginFLAG = false; // logon success flag
# 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) {// The user login exists and is valid
# $ Info = file ($ this-> loginFILE );
# $ Username = trim ($ info [0]); // online login username
# $ Password = trim ($ info [1]); // online password (optional)
# $ Ip = trim ($ info [2]); // An online IP address
# $ Sid = trim ($ info [3]); // 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 "your account is unique! ";
# $ Cf = fopen ($ this-> loginFILE, "a + ");
# Fputs ($ cf, "\ r \ na ");
# Fclose ($ cf );
# Echo" ";
# // Echo "";
#} Else {
# Echo "you are not allowed to log on to your account online at the same time...". $ _ SERVER [REMOTE_PORT];
# $ This-> LoginFLAG = false;
#}
#} Else {
# Echo "the account cannot be used to log on simultaneously ..
";
# $ This-> LoginFLAG = false;
#}
#} Else {
# Echo "incorrect password ..
";
# $ This-> LoginFLAG = false;
#}
#} Else {
# // If the authentication is correct
# Echo "an error occurred when logging on to the account! Incorrect user name

";
#}
#} 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 "the 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;
#} Else {
# Echo "existing 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.