PHPBB3跟网站结合,实现登入网站同时登入论坛
因为工作的原因.要用到这个,所以研究了一下.
主要思路是模拟COOKIES ..先往Cookies里面插入用户ID和一个SessionID,然后再往数据库中的sessions表里面插入SessionID,和用户ID,如果打开论坛,系统会验证COOKIES的信息跟数据库中的信息是否一样,如果一样的话就可以实现自动登入..登入部份主要代码如下:
(做为现在的主流开发语言)
//获取32位随机的SESSIONID
//初始化各值
$Session_testId=create_sess_id(32);
$SessionIp=192.168.0.100;
$cookie_path=/;
$cookieName=php(做为现在的主流开发语言)bb3_1w36a;
$userBrowserInfo= $_SERVER["HTTP_USER_AGENT"];
$userIpAdd=$_SERVER["REMOTE_ADDR"];
//获取表单的用户名和密码
$cmd_username=$_POST["username"];
$cmd_password=$_POST["password"];
//先跟CMS系统表验证,如果通过.查询相应用户名BBS用户表中的ID
$link=MySQL(和PHP搭配之最佳组合)_connect("localhost","root","");
MySQL(和PHP搭配之最佳组合)_select_db("cms");
$selectUid="select user_id from bbs_users where username=$cmd_username";
$uidResult=MySQL(和PHP搭配之最佳组合)_query($selectUid);
$userId=null;
while($row1 = MySQL(和PHP搭配之最佳组合)_fetch_array($uidResult, MySQL(和PHP搭配之最佳组合)_NUM))
{
$userId=$row1[0];
}
//echo $userId;
MySQL(和PHP搭配之最佳组合)_close($link);
//往Cookies里插入用户ID信息
setcookie($cookieName._u,$userId,time()+100000000,$cookie_path,$SessionIp,false);
//往Cookies里插入SessionID信息
setcookie($cookieName._sid,$Session_testId,time()+100000000,$cookie_path,$SessionIp,false);
//往php(做为现在的主流开发语言)b_sessions表中插入Session信息
$link=MySQL(和PHP搭配之最佳组合)_connect("localhost","root","");
MySQL(和PHP搭配之最佳组合)_select_db("cms");
$sqlcommand="insert into bbs_sessions(session_id,session_user_id,session_last_visit,session_start,session_time,session_ip,session_browser,session_page)";
$sqlcommand.=" values($Session_testId,$userId,".time().",".time().",".time().",$userIpAdd,$userBrowserInfo,index.php(做为现在的主流开发语言))";
//echo $sqlcommand;
MySQL(和PHP搭配之最佳组合)_query($sqlcommand);
MySQL(和PHP搭配之最佳组合)_close($link);
//生成一个32位随机数
function create_sess_id($len=32)
{
// 获取当前时间的微秒
list($u, $s) = eXPlode( , microtime());
$time = (float)$u + (float)$s;
// 产生一个随机数
$rand_num = rand(100000, 999999);
$rand_num = rand($rand_num, $time);
mt_srand($rand_num);
$rand_num = mt_rand();
// 产生SessionID
$sess_id = md5( md5($time). md5($rand_num) );
// 截取指定需要长度的SessionID
$sess_id = substr($sess_id, 0, $len);
return $sess_id;
}
header("location: http://192.168.0.100/bbs/index.php(做为现在的主流开发语言)");
//print_r($_COOKIE);
?>
这样,就可以实现自动登入了.
当然,只有这些还是不够,还要屏蔽php(做为现在的主流开发语言)BB中的用户修改账户信息和注册新用户.比如要修改注册的,可以修改
php(做为现在的主流开发语言)bb3rc2stylesprosilver emplate这个目录下面的.ucp_register.html模版面.把里面的内容的删了.加上这个
这样,当用户点注册,阅读完条款后点注册,就会跳到网站上的注册页面.修改信息的大体一样..
我的作法并没有统一用户表.而是各有各的用户系统..
当在网站上注册用户时,同时往php(做为现在的主流开发语言)BB数据库的users表和user_group表中插入用户信息.记住,一定要看看分组啊,
权限,插入相应的东西,要不然可能不能登入,不改发信息,不能读版块等问题.这部份比较长简单,代码就省了.主要是登入部份..

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



When connecting a printer to a local area network and starting a print job, some minor problems may occur. For example, the problem "wpsoffice cannot start the print job..." occasionally occurs, resulting in the inability to print out files, etc., delaying our work and study, and causing a bad impact. , let me tell you how to solve the problem that wpsoffice cannot start the print job? Of course, you can upgrade the software or upgrade the driver to solve the problem, but this will take you a long time. Below I will give you a solution that can be solved in minutes. First of all, I noticed that wpsoffice cannot start the print job, resulting in the inability to print. To solve this problem, we need to investigate one by one. Also, make sure the printer is powered on and connected. Generally, abnormal connection will cause

A Comprehensive Guide to PHP 500 Errors: Causes, Diagnosis, and Fixes During PHP development, we often encounter errors with HTTP status code 500. This error is usually called "500InternalServerError", which means that some unknown errors occurred while processing the request on the server side. In this article, we will explore the common causes of PHP500 errors, how to diagnose them, and how to fix them, and provide specific code examples for reference. Common causes of 1.500 errors 1.

How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

Some users may encounter slow charging speeds when using Apple phones. There are many reasons for this problem. It may be caused by low power of the charging device, device failure, problems with the USB interface of the mobile phone, or even battery aging and other factors. Why does Apple mobile phone charge very slowly? Answer: charging equipment problem, mobile phone hardware problem, mobile phone system problem. 1. When users use charging equipment with relatively low power, the charging speed of the mobile phone will be very slow. 2. Using third-party inferior chargers or charging cables will also cause slow charging. 3. It is recommended that users use the official original charger, or replace it with a regular certified high-power charger. 4. There is a problem with the user’s mobile phone hardware. For example, the USB interface of the mobile phone cannot be contacted.

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

Nowadays, in addition to data and wifi, mobile phones have two ways to access the Internet, and OPPO mobile phones are no exception. But what should we do if we can’t turn on the wifi function when using it? Don't worry yet, you might as well read this tutorial, it will help you! What should I do if my phone’s wifi function cannot be turned on? It may be because there is a slight delay when the WLAN switch is turned on. Please wait 2 seconds to see if it is turned on. Do not click continuously. 1. You can try to enter "Settings>WLAN" and try to turn on the WLAN switch again. 2. Please turn on/off airplane mode and try to turn on the WLAN switch again. 3. Restart the phone and try to see if WLAN can be turned on normally. 4. It is recommended to try restoring factory settings after backing up data. If none of the above methods solve your problem, please bring the purchased

Discuz forum permission management: Read the permission setting guide In Discuz forum management, permission setting is a crucial part. Among them, the setting of reading permissions is particularly important, as it determines the scope of content that different users can see in the forum. This article will introduce in detail the reading permission settings of the Discuz forum and how to flexibly configure it for different needs. 1. Basic concepts of reading permissions In the Discuz forum, reading permissions mainly include the following concepts that need to be understood: Default reading permissions: Default after new user registration
