Qeephp调整ucenter实现单点登陆之个人PHP项目与Ucenter整合
Qeephp整合ucenter实现单点登陆之个人PHP项目与Ucenter整合
前言
要实现使用ucenter单点登陆,则首先需要部署一个ucenter项目
一、下载ucenter程序
去Discuz官网下载一个ucenter程序
http://www.comsenz.com/downloads/install/ucenter
我下载的是下面这个版本的。
UCenter_1.6.0_SC_UTF8.zip
二、安装程序
php的安装环境我就不说了,将下载下来的ucenter程序部署完成。
我顺便部署了一下我的qeephp程序,这个和个人项目都是一样的,先保证运行正常。
我的配置:
ucenter域名:http://ucenter.webplus3.com
我的项目域名:http://www.nj-jz.com
三、开始整合
1、UCenter_1.6.0_SC_UTF8.zip解压
2、将advanced\examples\api文件夹下的uc.php文件拷贝到你网站的根目录下的api文件夹中,若没有api则新建一个api文件夹(api文件夹一定要在网站的根目录中)
3、将advanced\examples文件夹下的include文件夹拷贝到你项目的根目录。文件夹内包含一个文件叫db_mysql.class.php,这是连接数据库的类。
4、将uc_client文件夹整个复制到你网站根目录,uc_client之前说了是接口代码,现在根目录已经有include和uc_client两个文件夹了。
5、复制advanced\examples文件夹内的config.inc.php到你网站的根目录,这是配置UCenter的配置文件。
6、在ucenter后台中添加新应用,截图如下:
其他属性默认,点击“提交”,保存应用!
此时返回应用列表,通信状态应该是失败的!
别急,我们再修改一下配置文件。
四、修改ucenter配置
1.编辑应用,在应用提交按钮的下方会有一段配置
将这段配置信息拷贝到第(三)2步提到的uc.php文件的最上方。
添加后的文件前20行(其中2-15行是拷贝过来的配置)如下:
<?php define('UC_CONNECT', 'mysql'); define('UC_DBHOST', 'localhost'); define('UC_DBUSER', 'root'); define('UC_DBPW', '12344'); define('UC_DBNAME', 'web3_ucenter'); define('UC_DBCHARSET', 'utf8'); define('UC_DBTABLEPRE', '`web3_ucenter`.uc_'); define('UC_DBCONNECT', '0'); define('UC_KEY', '123456'); define('UC_API', 'http://ucenter.webplus3.com'); define('UC_CHARSET', 'utf-8'); define('UC_IP', ''); define('UC_APPID', '2'); define('UC_PPP', '20'); define('IN_DISCUZ', TRUE); define('UC_CLIENT_VERSION', '1.5.0'); //note UCenter 版本标识 define('UC_CLIENT_RELEASE', '20081031');
同时按照这段配置信息更改第5步中说的config.inc.php文件里面相应的参数,使其与ucenter生成的配置信息保持一致。
<pre name="code" class="php"><?php define('UC_CONNECT', 'mysql');// 连接 UCenter 的方式: mysql/NULL, 默认为空时为 fscoketopen() // mysql 是直接连接的数据库, 为了效率, 建议采用 mysql //数据库相关 (mysql 连接时, 并且没有设置 UC_DBLINK 时, 需要配置以下变量) define('UC_DBHOST', 'localhost');// UCenter 数据库主机 define('UC_DBUSER', 'root');// UCenter 数据库用户名 define('UC_DBPW', '12344');// UCenter 数据库密码 define('UC_DBNAME', 'web3_ucenter');// UCenter 数据库名称 define('UC_DBCHARSET', 'utf8'); // UCenter 数据库字符集 define('UC_DBTABLEPRE', 'web3_ucenter.uc_'); // UCenter 数据库表前缀 //通信相关 define('UC_KEY', '123456');// 与 UCenter 的通信密钥, 要与 UCenter 保持一致 define('UC_API', 'http://ucenter.webplus3.com');// UCenter 的 URL 地址, 在调用头像时依赖此常量 define('UC_CHARSET', 'utf-8'); // UCenter 的字符集 define('UC_IP', ''); // UCenter 的 IP //当 UC_CONNECT 为非 mysql 方式时, 并且当前应用服务器解析域名有问题时, 请设置此值 define('UC_APPID', 2); // 当前应用的 ID define('UC_PPP', '20'); //同步登录 Cookie 设置 $cookiedomain = ''; // cookie 作用域 $cookiepath = '/'; // cookie 作用路径

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











MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Methods for configuring character sets and collations in MySQL include: 1. Setting the character sets and collations at the server level: SETNAMES'utf8'; SETCHARACTERSETutf8; SETCOLLATION_CONNECTION='utf8_general_ci'; 2. Create a database that uses specific character sets and collations: CREATEDATABASEexample_dbCHARACTERSETutf8COLLATEutf8_general_ci; 3. Specify character sets and collations when creating a table: CREATETABLEexample_table(idINT
