Home  >  Article  >  Backend Development  >  BlackBerry passport discuz Passport pass integrated notes

BlackBerry passport discuz Passport pass integrated notes

WBOY
WBOYOriginal
2016-07-29 08:38:221208browse

It's too simple, but after a long time, I couldn't remember it. I wasted half an hour looking for information, and I deeply realized that a good memory is not as good as a bad writing! ! Post the passport document today to prevent it from being forgotten later! ! Remember, it takes time to find the information you need online!!!!!!

Passport integration

Part 1: Integration principles
Please note: Possible consequences of unsuccessful integration---- -dz forum cannot be logged in and cannot be managed
Solution:
Step one: Go to the dz database table cdb_settings and find the following lines and modify them to
 discuz Passport 通行证 整合笔记 discuz Passport 通行证 整合笔记

 discuz Passport 通行证 整合笔记setting.gif (4.3 KB)

2006- 9-30 13:59


Step 2: Delete the dz installation directory/forumdata/cache/cache_settings.php
Step 3: Re-visit the forum

Login and registration integration process
User submits account and password information from the login or registration form ==>
Master The website program checks user login or registration. If successful (registration needs to generate a new user) ==>
Set the cookie or session of the main website itself ==>
url passes the return address forward and encoded user information and other information to dz/api/passport.php

Please read the official passport technical documentation carefully before integrating: http://www.discuz.net/usersguide/advanced_passport.htm

Copy the content to the clipboard

Code:
<font face="新宋体"><?php<BR>//Save this document as login.php<BR>//First copy the encryption and decryption functions in the interface technical document<BR>//In order to prevent the code from being too messy, I copied it to the end of the document <BR>//Assume that the user name field in your user database table is UserName, the password field is Pwd, and the Email field is Email<BR>//The registration page implementation method is similar and can be implemented by yourself. If you have any questions, please add me QQ: 2666556<br>$act=(isset ($_GET['act']))?$_GET['act']:"login";<BR>if(function_exists($act)) $act();else login(); $ErrMsg=UserCheck();<br> if($ErrMsg!="")echo $ErrMsg; =login method=post><br>Username:<input name=username><br>Password:<input name=password><br><input name=submit type=submit value=Login></form><br>< ?php<BR>}//end function<BR>function logout()//Logout<BR>{<BR> $passportkey="1234567890";//Replace the passportkey set by your forum pass here<BR> $auth=$_COOKIE['auth']; <BR>         setcookie("auth", "",time() - 3600); <br>             $forward=$_GET['forward'];                                                 through .php";//Replace here with the absolute address or relative address of your homepage                                                                                    $forward =rawurlencode($forward);<br> header("Location: bbs/api/passport.php?action=logout&auth=$auth&forward=$forward&verify=$verify");<BR>}OnFunction usercheck () {<br> $ passportkey = "1234567890"; // here to replace it with passportkey<BR> // ==================== =============<BR> If(!isset($_POST['submit'])) return; // The button of the login form needs to have the same name<br> $usnm=$_POST['username' ];//username is replaced with the username field in your login form                                                                                                                                                                        ") return "Please enter the username!"; <BR> if ($ pwd == "") Return "Please enter the password!"; <BR> // ======= The database processing ======== ================ <BR> $ db = mysql_connect ("localhost", "root", ""); <BR> mysql_select_db ("you_db_name"); `user' where UserName='".$usnm."' Limit 1"; The user does not exist"; <BR>                                                                                                                                                                           if($row["Pwd"]!=md5($pwd))return ""Password Incorrect"; ====header to bbs======================                                                                                                                                          ​'username' = & gt; $ row ["username"], <br> 'password' = & gt; $ row ["pwd"], <BR> 'email' = & gt; $ row ["email"]; Assport_encode ($member), $passportkey);<BR> setcookie("auth",$auth,($_POST["Cookie"]? time()+(int)$_POST["Cookie"] :0));<BR> $forward =$_POST['forward'];<BR> if($forward=="")$forward="../../index.php"; $verify = md5('login'.$auth.$forward. $passportkey);<BR>                                                                                                                                 $auth=rawurlencode(($auth); "); " ===================<BR>//==============The following is the copied function========= ===================<BR>function passport_encrypt($txt, $key) {<BR> srand((double)microtime() * 1000000);<br> $encrypt_key = md5(rand (0, 32000)); $ctr = 0;<BR> $tmp = '';<BR> $i r = $ctr == strlen($encrypt_key) ? 0 : $ctr;<BR>                                                                        $tmp, $key));<BR>}<BR>function passport_decrypt($txt, $key) {<BR> $txt = passport_key(base64_decode($txt), $key);<BR> $tmp = '';<BR> for ($i = 0; $ i < strlen($txt); $i++) {<BR>                                                                                                                                                                        ​ <br>function passport_key($txt, $encrypt_key) {<BR> $encrypt_key = md5($encrypt_key);<BR> $ctr = 0;<BR> $tmp = '';<BR> for($i = 0; $i < strlen($txt ); $i++) {<BR>                                                              }<BR>           return $tmp ;<BR>}<BR>function passport_encode($array) {<BR> $arrayenc = array();<br> foreach($array as $key => $val) {<br> $arrayenc[] = $key.'='.urlencode($ val);<br>           }                                                                                                                        ’’’ return implode('&', $arrayenc); =============================================<br>//== =========================End of copy======================== ===============<br>?><br><br><br> <br> The above introduces the BlackBerry passport discuz Passport integration notes, including BlackBerry passport content. I hope it will be helpful to friends who are interested in PHP tutorials. <br> </font>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn