PHPwind integration of the most soil system user synchronous login method

  • 2020-03-31 21:24:58
  • OfStack

The last successful commercial version upgrade the soil, the next is the integration of the company's community website, to explain my work place is now a local community site, with the foundation of the program is PHPWind, my mission is to make PHPWind login synchronization and the soil, leaders also know that my technical ability is limited, not very high demand, so let me realize, then consider other. Put the ducks on the shelf. Let's go.
Under my immature program thinking ability, to rewrite the program I first repudiated this method, will once again denied PHPWind validation method is introduced into the method of soil, the last to come up with a compromise, will be the same: the only ID two tables set give priority to table PHPWind user table, the soil the users table for an external table, let the user ID and the soil PHPWind user table UID one-to-one correspondence, synchronized user ID to complete the following work.
Say no more, go ahead.
Step 1: user synchronization
New PHPWind user, the most soil synchronization corresponding user, the most soil ID corresponding to PHPWind user ID.
Register. PHP
 
$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 surest login mode to use cookies
Remove the password and change the authenticated user name to the user ID.
ZUser. Class. PHP
 
$field = strpos($email, '@') ? 'email' : 'id';//username 
$zuituuser = DB::GetTableRow('tg_user', array( 
$field => $email, 
//'password' => $password, 

index.php
 
$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 to PHPWind and write the user ID to the Cookie value. Log out of PHPWind and clear the user ID from the Cookie value
The login. PHP/register. PHP
Write a Cookie
SetCookie (" CookieID ", $Winduid);
Remove the Cookie
Setcookie ("CookieID", "", time() -3600);
Step 4: modify the dirt page connection
The header. The HTML
 
<ul class="links"> 
<li class="username"> You are 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']}"> exit </a></li> 
</ul> 
<!--{else}--> 
<ul class="links"> 
<li class="login"><a href="/../login.php"> The login </a></li> 
<li class="signup"><a href="/../register.php"> registered </a></li> 
</ul> 

Synchronous login is successful, all logins and logouts are carried out in PHPWind, and the minimum soil is only responsible for accepting whether to pass a null value to confirm whether to log in.

Related articles: