关于DISCUZ不用通行证登陆得内容介绍第1/2页_php实例
关于DISCUZ不用通行证登陆得内容介绍
DISCUZ是中国最常用的论坛,虽然他本身有通行证给大家连接,但实际上用户的统一还是很不好,经常要建立两个用户表,第一不利于注册和管理,第二浪费数据库。
最近做一个项目也是使用的DISCUZ,所以研究了一下DISCUZ的登陆,基本完成了同步登陆。大家如果有兴趣可以研究一下。
别的不废话了,如果你自己写的系统,可以直接用DISCUZ的公用文件,直接引用include/common.inc.php就好了,这样最简单了,只要引用这个文件,$discuz_uid就是你的用户ID了,$discuz_user就是你的用户名,
如果你用的自己的公用文件,就要提取两个函数,在global.func.php中,有两个函数
Dsetcookie,和authcode,如果你不懒的话在复制一个函数clearcookies,第一个就是DISCUZ自己的建造COOKIE的函数,第二个是DISCUZ的可逆加密函数,第三个是清除COOKIE函数,我是放到我自己的FUNC.PHP文件中了
好了,咱们开始写建立和识别COOKIE的方法了
function lgoin($array)
{
$username = $array['username'];
$password = $array['password'];
$sql = "SELECT `uid`,`password`,`secques` FROM `cdb_members` WHERE
`username`='$username' and `password`=md5('$password')";
try {
$rs = $this -> _db -> query($sql);
}catch (Exception $e){
exit("查询出错,出错信息:".$e->getMessage());
return 0;
}
$row = $this -> _db -> fetch($rs); //查询登陆的用户名和密码是否正确
if($row){
dsetcookie('sid','',-2423234234); // 注销掉sid
$secques = $row['secques'];
$uid = $row['uid'];
$formPassword = $row['password'];
dsetcookie('auth', authcode("$formPassword\t$secques\t$uid", 'ENCODE','123'), '0');
return 1;
}else{
return 2;
}
}
这是一个登陆函数,废话不说了,直接说关键部分吧,在查询之后,当获得到信息后,(用户名和密码正确的话)我们获得3个信息,UID,PASSWORD,和SECQUES,这三个是DISCUZ建立COOKIE需要用的,第一个是用户ID,第二个是加密后的密码,第三个是加密后的回答问题答案(即使没有设置也要用),DISCUZ是需要提示问题和答案的,而我们登陆就不需要了,所以我这里直接把他查出来了。dsetcookie('auth', authcode("$formPassword\t$secques\t$uid", 'ENCODE','123'), '0');
这句就是建立用户的COOKIE,别的不用说了,请注意这句'123',这个地方一定要注意,这个是加密时设置的KEY,就是你这里需要和你DISCUZ的一样,所以有三个地方一定要统一,一个是global.func.php,一个是你自己复制出来的那个authcode函数,还有就是你在使用authcode的时候。这时候论坛应该可以登陆了,如果不能登陆,请看下面

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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 change the page that opens the Microsoft Edge browser to 360 navigation? It is actually very simple, so now I will share with you the method of changing the page that opens the Microsoft Edge browser to 360 navigation. Friends in need can take a look. I hope Can help everyone. Open the Microsoft Edge browser. We see a page like the one below. Click the three-dot icon in the upper right corner. Click "Settings." Click "On startup" in the left column of the settings page. Click on the three points shown in the picture in the right column (do not click "Open New Tab"), then click Edit and change the URL to "0" (or other meaningless numbers). Then click "Save". Next, select "

"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

"Exploring Discuz: Definition, Functions and Code Examples" With the rapid development of the Internet, community forums have become an important platform for people to obtain information and exchange opinions. Among the many community forum systems, Discuz, as a well-known open source forum software in China, is favored by the majority of website developers and administrators. So, what is Discuz? What functions does it have, and how can it help our website? This article will introduce Discuz in detail and attach specific code examples to help readers learn more about it.

CheatEngine is a game editor that can edit and modify the game's memory. However, its default language is non-Chinese, which is inconvenient for many friends. So how to set Chinese in CheatEngine? Today, the editor will give you a detailed introduction to how to set up Chinese in CheatEngine. I hope it can help you. Setting method one: 1. Double-click to open the software and click "edit" in the upper left corner. 2. Then click “settings” in the option list below. 3. In the opened window interface, click "languages" in the left column

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

Title: To solve the problem that Discuz WeChat shares cannot be displayed, specific code examples are needed. With the development of the mobile Internet, WeChat has become an indispensable part of people's daily lives. In website development, in order to improve user experience and expand website exposure, many websites will integrate WeChat sharing functions, allowing users to easily share website content to Moments or WeChat groups. However, sometimes when using open source forum systems such as Discuz, you will encounter the problem that WeChat shares cannot be displayed, which brings certain difficulties to the user experience.

Discuz Editor: A powerful web page editing tool that requires specific code examples. With the development of the Internet, website construction and content editing have become more and more important. As a common web page editing tool, Discuz editor plays an important role in website construction. It not only provides a wealth of functions and tools, but also helps users edit and publish content more conveniently. In this article, we will introduce the features and usage of the Discuz editor, and provide some specific code examples to help readers better understand and use

Title: Discuz background account login exception, how to deal with it? When you use the backend management of the Discuz forum system, you may sometimes encounter abnormal account login. This could be due to a variety of reasons, including a wrong password, account being blocked, network connection issues, etc. When encountering this situation, we need to solve the problem through simple troubleshooting and processing. Check whether the account number and password are correct: First, confirm whether the account number and password you entered are correct. When logging in, make sure the capitalization is correct and the password is
