discuz Passport 通行证 整合笔记
太简单了,但时间长了,记不得,浪费我半小时找资料,深刻体会好记性不如烂笔头!!今天把passport文挡贴上,防止以后忘记!!记住,网上找到自己需要的资料也要耗时间的!!!!!!
Passport 通行证 整合
第一篇:整合原理请注意: 整合不成功可能造成的后果-----dz论坛无法登录,无法管理
解决办法:
第一步: 到dz的数据库表cdb_settings 找到下面这几行修改为
第二步: 删除dz安装目录/forumdata/cache/cache_settings.php
第三步: 重新访问论坛
登陆和注册整合流程
用户从登陆或注册表单提交帐号密码信息 ==>
主站程序检验用户登陆或注册,成功(注册需要生成新用户)则 ==>
设置主站自身的cookie或session ==>
url传递 返回地址forward和编码后的用户信息和其他信息 到dz/api/passport.php
整合之前请先仔细阅读官方passport技术文档: http://www.discuz.net/usersguide/advanced_passport.htm
代码:
<font face="新宋体"><?php <BR>//该文档保存为login.php<br>//首先将接口技术文档里的加密解密函数拷贝<br>//为了不让代码太乱,我拷贝到文档的结尾处<br>//假设自己的用户数据库表里用户名字段为UserName, 密码字段为Pwd, Email字段为 Email<br>//注册页实现方法差不多,可自行实现,疑问加我QQ:2666556<br><br>$act=(isset($_GET['act']))?$_GET['act']:"login";<br>if(function_exists($act)) $act();else login(); <br><br>function login()<br>{ <br> $ErrMsg=UserCheck();<br> if($ErrMsg!="")echo $ErrMsg; <br> //后面加上显示你的登陆表单的代码 如<br>?><br><form action="login.php?act=login" method="post">
<br>用户名:<input name="username"><br>密码:<input name="password"><br><input name="submit" type="submit" value="登陆">
</form>
<br><?php <br><br>}//end function<br><br>function logout()//登出<br>{<br> $passportkey="1234567890";//这里换成你论坛通行证设置的passportkey<br> $auth=$_COOKIE['auth'];<br> setcookie("auth", "",time() - 3600);<br> $forward=$_GET['forward'];<br> if($forward=="")$forward="../../index.php";//这里换成你的主页绝对地址或相对地址 <br> $verify = md5('logout'.$auth.$forward.$passportkey);<br> $auth=rawurlencode($auth);<br> $forward=rawurlencode($forward);<br> header("Location: bbs/api/passport.php?action=logout&auth=$auth&forward=$forward&verify=$verify");<br>}<br><br>function UserCheck() <br>{ <br> $passportkey="1234567890";//这里换成你论坛通行证设置的passportkey<br><br> //===========验证输入=====================<br> if(!isset($_POST['submit'])) return; // login表单的按钮需要与此同名<br> $usnm=$_POST['username'];//username换成你登陆表单里的用户名域 <br> $pwd=$_POST['password'];//password换成你登陆表单里的密码域 <br> if($usnm=="") return "请输入用户名!";<br> if($pwd=="") return "请输入密码!";<br><br> //=========数据库处理==========================<br> $db=mysql_connect("localhost", "root", "");<br> mysql_select_db("your_db_name");<br>$sql="Select * from `user` where UserName='".$usnm."' Limit 1"; <br> $rs = mysql_query($sql,$db) ;<br> $row = mysql_fetch_array($rs);<br> if(!$row)return "该用户不存在";<br> if($row["Pwd"]!=md5($pwd))return "密码错误";<br> mysql_free_result($rs); <br><br> //==============header到bbs===================== <br> $member = array<br> (<br> 'time' => time(),<br> 'username' => $row["UserName"],<br> 'password' => $row["Pwd"],<br> 'email' => $row["Email"]<br> );<br> $auth = passport_encrypt(passport_encode($member), $passportkey);<br> setcookie("auth",$auth,($_POST["Cookie"]? time()+(int)$_POST["Cookie"] :0));<br> $forward=$_POST['forward'];<br> if($forward=="")$forward="../../index.php"; <br> $verify = md5('login'.$auth.$forward.$passportkey);<br> $auth=rawurlencode($auth);<br> $forward=rawurlencode($forward);<br> header("Location: bbs/api/passport.php?action=login&auth=$auth&forward=$forward&verify=$verify"); <br><br>}<br><br><br>//=============================================================<br>//=============以下为拷贝过来的函数============================<br>function passport_encrypt($txt, $key) {<br> srand((double)microtime() * 1000000);<br> $encrypt_key = md5(rand(0, 32000)); <br> $ctr = 0;<br> $tmp = '';<br> for($i = 0; $i $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;<br> $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);<br> }<br> return base64_encode(passport_key($tmp, $key));<br>}<br><br>function passport_decrypt($txt, $key) {<br> $txt = passport_key(base64_decode($txt), $key);<br> $tmp = '';<br> for ($i = 0; $i $tmp .= $txt[$i] ^ $txt[++$i];<br> }<br> return $tmp;<br>}<br><br>function passport_key($txt, $encrypt_key) {<br> $encrypt_key = md5($encrypt_key);<br> $ctr = 0;<br> $tmp = '';<br> for($i = 0; $i $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;<br> $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];<br> }<br> return $tmp;<br>}<br><br>function passport_encode($array) {<br> $arrayenc = array();<br> foreach($array as $key => $val) {<br> $arrayenc[] = $key.'='.urlencode($val);<br> }<br> return implode('&', $arrayenc);<br><br>}<br>//=========================================================================<br>//===========================拷贝结束======================================<br>?></font>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to delete Xiaohongshu notes? Notes can be edited in the Xiaohongshu APP. Most users don’t know how to delete Xiaohongshu notes. Next, the editor brings users pictures and texts on how to delete Xiaohongshu notes. Tutorial, interested users come and take a look! Xiaohongshu usage tutorial How to delete Xiaohongshu notes 1. First open the Xiaohongshu APP and enter the main page, select [Me] in the lower right corner to enter the special area; 2. Then in the My area, click on the note page shown in the picture below , select the note you want to delete; 3. Enter the note page, click [three dots] in the upper right corner; 4. Finally, the function bar will expand at the bottom, click [Delete] to complete.

On the Douyin platform, many users are eager to obtain level certification, and the level 10 light sign shows the user's influence and recognition on Douyin. This article will delve into the price of Douyin’s level 10 light boards and the time it takes to reach this level to help users better understand the process. 1. How much does a level 10 Douyin light sign cost? The price of Douyin's 10-level light signs will vary depending on market fluctuations and supply and demand. The general price ranges from a few thousand yuan to ten thousand yuan. This price mainly includes the cost of the light sign itself and possible service fees. Users can purchase level 10 light signs through Douyin’s official channels or third-party service agencies, but they should pay attention to legal channels when purchasing to avoid false or fraudulent transactions. 2. How many days does it take to create a level 10 fan sign? Reach level 10 light sign

As a Xiaohongshu user, we have all encountered the situation where published notes suddenly disappeared, which is undoubtedly confusing and worrying. In this case, what should we do? This article will focus on the topic of "What to do if the notes published by Xiaohongshu are missing" and give you a detailed answer. 1. What should I do if the notes published by Xiaohongshu are missing? First, don't panic. If you find that your notes are missing, staying calm is key and don't panic. This may be caused by platform system failure or operational errors. Checking release records is easy. Just open the Xiaohongshu App and click "Me" → "Publish" → "All Publications" to view your own publishing records. Here you can easily find previously published notes. 3.Repost. If found

How to add product links in notes in Xiaohongshu? In the Xiaohongshu app, users can not only browse various contents but also shop, so there is a lot of content about shopping recommendations and good product sharing in this app. If If you are an expert on this app, you can also share some shopping experiences, find merchants for cooperation, add links in notes, etc. Many people are willing to use this app for shopping, because it is not only convenient, but also has many Experts will make some recommendations. You can browse interesting content and see if there are any clothing products that suit you. Let’s take a look at how to add product links to notes! How to add product links to Xiaohongshu Notes Open the app on the desktop of your mobile phone. Click on the app homepage

Players can experience the main plot of the game and collect game achievements when playing in Elden's Circle. Many players don't know how long it takes to clear Elden's Circle. The player's clearance process is 30 hours. How long does it take to clear the Elden Ring? Answer: 30 hours. 1. Although this 30-hour clearance time does not refer to a master-like speed pass, it also omits a lot of processes. 2. If you want to get a better game experience or experience the complete plot, then you will definitely need to spend more time on the duration. 3. If players collect them all, it will take about 100-120 hours. 4. If you only take the main line to brush BOSS, it will take about 50-60 hours. 5. If you want to experience it all: 150 hours of base time.

Xiaohongshu, a platform full of life and knowledge sharing, allows more and more creators to express their opinions freely. In order to get more attention and likes on Xiaohongshu, in addition to the quality of content, the time of publishing works is also crucial. So, how to set the time for Xiaohongshu to publish works? 1. How to set the time for publishing works on Xiaohongshu? 1. Understand the active time of users. First, it is necessary to clarify the active time of Xiaohongshu users. Generally speaking, 8 pm to 10 pm and weekend afternoons are the times when user activity is high. However, this time period will also vary depending on factors such as audience group and geography. Therefore, in order to better grasp the active period of users, it is recommended to conduct a more detailed analysis of the behavioral habits of different groups. By understanding users’ lives

A must-have for Discuz users! Comprehensive analysis of renaming props! In the Discuz forum, the name change function has always received much attention and demand from users. For some users who need to change their name, name change props can easily modify the user name, and this is also an interesting way of interaction. Let’s take an in-depth look at the renaming props in Discuz, including how to obtain them, how to use them, and solutions to some common problems. 1. Obtain name-changing props in Discuz. Name-changing props are usually purchased through points or the administrator

"Detailed Explanation of Discuz Registration Process: Allowing you to easily modify personal information, specific code examples are required" Discuz is a powerful community forum program that is widely used in various websites. It provides a wealth of user registration and personal information modification. functions and interfaces. This article will introduce you to Discuz's registration process in detail and provide specific code examples to help you easily customize and modify your personal information. 1. User registration process In Discuz, user registration is one of the important functions of the site. The smoothness of the registration process and
