The most commercial version was successfully upgraded last time. The next step is to integrate the company's community website. First, let us know where I am working is a local community website, and PHPWind is used as the basic program, my task is to synchronize PHPWind with the most common logon. The leaders also know that my technical capabilities are limited and I don't have high requirements. Therefore, let me implement it first and then consider other things. The duck was shelved and started to work.
With my immature program thinking ability, I first denied the method of rewriting the program, and again denied the method of introducing PHPWind's verification method to the most practical method, finally, I came up with a compromise method to make the two tables have the same unique ID: Set the PHPWind User table as the primary table, and the most common user table as the External table, let the most Earth user ID correspond to the PHPWind User table UID one by one, and use the user ID to complete the subsequent synchronization work.
If you don't need to talk about it, go to the previous step.
Step 1: User Synchronization
Create a PHPWind user, synchronize the user with the most soil, and the most soil ID corresponds to the PHPWind user ID.
Register. php
Copy codeThe 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 local logon mode and use Cookie
Remove the password and change the authentication username to the user ID.
ZUser. class. php
Copy codeThe Code is as follows:
$ Field = strpos ($ email ,'@')? 'Email ': 'id'; // username
$ Zuituuser = DB: GetTableRow ('tg _ user', array (
$ Field => $ email,
// 'Password' => $ password,
Index. php
Copy codeThe 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 on to PHPWind and write the user ID to the Cookie value. Exit PHPWind and clear the user ID from the Cookie value.
Login. php/register. php
Write Cookie
SetCookie ("CookieID", $ Winduid );
Clear Cookie
Setcookie ("CookieID", "", time ()-3600 );
Step 4: Modify the most Earth page connection
Header.html
Copy codeThe Code is as follows:
<Ul class = "links">
<Li class = "username"> welcome, {$ login_user ['username']}! </Li>
<Li class = "account"> <a href = "/order/index. php "id =" myaccount "class =" account "> my {$ INI ['system'] ['abbreviation']} </a> </li>
<Li class = "logout"> <a href = "http://www.cnblogs.com/../login.php? Action = quit & verify = {$ _ COOKIE ['setout']} "> quit </a> </li>
</Ul>
<! -- {Else} -->
<Ul class = "links">
<Li class = "login"> <a href = "/../login. php"> logon </a> </li>
<Li class = "signup"> <a href = "/../register. php"> register </a> </li>
</Ul>
Synchronous logon is successful, and all logon and exit operations are performed in PHPWind. The most common logon mode is to accept whether to pass null values to confirm logon.