Home > Article > Backend Development > BlackBerry passport discuz Passport pass integrated notes
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 principlessetting.gif (4.3 KB)
2006- 9-30 13:59
Copy the content to the clipboard
<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>