The Zuitu business version was successfully upgraded last time. The next step is to integrate the company's community website. First, let me explain that the place where I work now is a local community website. The basic program I use is PHPWind. My task is to synchronize PHPWind with the Zuitu login. , the leader also knew that my technical ability was limited and I was not very demanding, so he asked me to implement it first and then consider other things. The ducks are put on the shelves and work begins.
With my immature programming thinking ability, I first rejected the method of rewriting the program, and then rejected the introduction of PHPWind's verification method to the most rustic method. Finally, I came up with a compromise method to combine the two The unique IDs of the tables are the same: set the PHPWind user table as the main table, and the user table as the external table. Let the user ID and the PHPWind user table UID correspond one to one, and use the user ID to complete the subsequent synchronization work.
Without further ado, let’s take the steps.
Step one: User synchronization
Create a new PHPWind user, synchronize the corresponding user, and the ID corresponds to the PHPWind user ID.
register.php
Copy code The code is as follows:
$db->update("insert into tg_user ( id,email,username,password,city_id,create_time,enable,realname) values ('".$winduid."','".addslashes($regemail)."','".addslashes($regname)."' ,'".$windpwd."','1','".time()."','Y','".addslashes($regname)."')");
Step 2: Modify the most native login mode and use Cookie method
Remove the password and change the verification username to user ID.
ZUser.class.php
Copy code The code is as follows:
$field = strpos($email, '@ ') ? 'email' : 'id';//username
$zuituuser = DB::GetTableRow('tg_user', array(
$field => $email,
//'password' => $password,
index.php
Copy code The code is as follows:
$login_user = ZUser::GetLogin($_COOKIE['CookieID'], $_POST['password']);
Session::Set('user_id', $login_user['id']);
ZLogin ::Remember($login_user);
ZUser::SynLogin($_POST['email'], $_POST['password']);
Step 3: Log in PHPWind writes the user ID into the Cookie value. Exit PHPWind and clear the user ID from the Cookie value
login.php/register.php
Write Cookie
setCookie("CookieID", $Winduid) ;
Clear Cookies
setcookie("CookieID", "", time() - 3600);
Step 4: Modify the most popular page link
header.html
Copy code The code is as follows:
Synchronous login is successful, all logins and logouts are performed within PHPWind, and the most rustic It is only responsible for accepting whether the passed value is a null value to confirm whether to log in.
http://www.bkjia.com/PHPjc/322592.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322592.htmlTechArticleLast time I successfully upgraded the commercial version of Zuitu. The next step is to integrate the company’s community website. Let me first explain what I am doing now. The place I work at is a local community website, and the basic program I use is PHPWind. I...