Phpcms V9最新版整合DX3.2教程详解

来源:互联网 发布:视频后期制作软件电脑 编辑:程序博客网 时间:2024/05/01 18:33
phpcms v9 discuz x3.2 通信 同步登陆 退出 discuz免激活

第一步:
1.使用新的uc_client文件,打开phpsso_server\api\ 目录修改原uc_client目录名称为uc_client_backup,然后将ucenter下面文件uc_client覆盖到该目录下。
第二步:
1.登录Discuz! X3.2后台,进入“UCenter”,点击“应用管理”后点击“添加新应用”进入应用添加界面,设置如下:
1、安装方式选择“自定义安装”
  2、应用类型选择“其他”
  3、应用名称填“phpsso”
  4、应用的主 URL, 即phpsso_server的路径,视实际情况而定,注意最后不要带斜杠。如本教程填写为http://127.0.0.1/phpsso_server
  5、通信密钥,任意填写64字节以内的英文字母及数字,不过要记住,因为phpcms 的通信密钥必须与此设置保持一致,否则 phpsso 将无法与 UCenter 正常通信。如本教程设置通信密钥为:chinaz
  6、应用IP、应用的物理路径、查看个人资料页面地址默认留空即可,而应用接口文件名称默认uc.php即可。
  7、标签单条显示模板、标签模板标记说明两项默认留空即可。
  8、是否开启同步登录:是。只有开启后,两款程序才能实现同步登录。
  9、完成后提交,将生成新的应用ID。(记住这个应用ID,在”第三步“中将用到它。)
  10、进入后台“站长”,“UCenter 设置”选项。"是否允许直接激活"一项,选择“是”。
  下面去Phpcms v9中配置phpsso。

第三步:配置phpsso
  登录Phpcms v9后台,进入“phpsso”,点击“系统设置”,进入“UCenter配置”设置界面,设置如下:
 
       1、是否启用:是
  2、Ucenter api 地址,即uc_server的路径,根据你的安装情况而定,注意最后不要带斜杠。如本教程填写为:http://localhost/bbs/uc_server
  3、Ucenter 数据库信息:根据自己情况填写数据库的信息。其中数据库表前缀的格式为“`数据库名`.数据库前缀”,注意数据库名的不是单引号。
  4、应用id(APP ID),即第二步创建的 phpsso 应用时自动生成的应用ID。
  5、Ucenter 通信密钥,即第二步中设置的“通信密钥”,这两个值一定要确保一致,否则会导致无法通信。

第四步:查看通信状态
  登录Discuz! X3.2后台,进入“UCenter”,点击“应用管理”查看第二步中创建的 phpsso 应用与 UCenter 通信是否成功。如果  通信失败,请检查“第二步”与“第三步”中的各项参数配置是否正确。
 

第五步:修改 Discuz!  X3.2会员登录相关。
  若不修改此处则在Phpcms v9登录后可以同步登录到Discuz!  X3.2,但是在Discuz!  X3.2登录却无法同步登录到Phpcms v9。修改步骤如下:
  1、找到discuz目录下 template\default\member\login.htm,删除(如一样可不做处理)

  1. onsubmit="{if $this->setting['pwdsafety']}pwmd5('password3_$loginhash');{/if}pwdclear = 1;ajaxpost('loginform_$loginhash', 'returnmessage_$loginhash', 'returnmessage_$loginhash', 'onerror');return false;" 
  2、找到discuz目录下 template\default\member\login_s imple.htm ,删除(如一样可不做处理)

  1. onsubmit="{if $_G['setting']['pwdsafety']}pwmd5('ls_password');{/if}return lsSubmit();" 


  3、找到discuz目录下 /source/function/function_message.php ,查找(如一样可不做处理)

  1. $param['header'] = true
  
替换为
  1. $param['header'] = false

第六步:
       1.(注册提示错误:“验证码错误”)修改如下:
文件位置:/phpcms/modules/member/index.php
 
       2.(phpcmsv9登陆,“discuz不同步登陆错误”)修改如下:
文件位置:/phpsso_server/api/uc_client/client.php
 

第七步: 
找到discuz目录网站:

分析其主要原因是phpsso与ucenter通信成功后,XXX_ucenter_member表中的用户已经同步成功但是在XXX_common_member中并没有此用户,所以只要在xxx_common_member中插入此用户就可以了,所以修改discuz/api/uc.php下找到function synlogin($get, $post)整段,修改为下面的内容:

  1. function synlogin($get, $post) { 
  2.         global $_G; 
  3.  
  4.         if(!API_SYNLOGIN) { 
  5.             return API_RETURN_FORBIDDEN; 
  6.         } 
  7.  
  8.         header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"'); 
  9.  
  10.         $cookietime = 31536000; 
  11.         $uid = intval($get['uid']); 
  12.         $query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'"); 
  13.         if ($member = DB::fetch($query)) 
  14.         { 
  15.             dsetcookie('auth', authcode("$member[password]\t$member[uid]"'ENCODE'), $cookietime); 
  16.         }else 
  17.         { 
  18.             $username = $get['username']; 
  19.             $query = DB::query("SELECT uid, username, password, email FROM ".DB::table('ucenter_members')." WHERE username='$username'"); 
  20.             $member = DB::fetch($query); 
  21.             $password = $member['password']; 
  22.             $email = $member['email']; 
  23.             $ip = $_SERVER['REMOTE_ADDR']; 
  24.             $time = time(); 
  25.             $userdata = array( 
  26.                 'uid'=>$uid, 
  27.                 'username'=>$username, 
  28.                 'password'=>$password, 
  29.                 'email'=>$email, 
  30.                 'adminid'=>0, 
  31.                 'groupid'=>10, 
  32.                 'regdate'=>$time, 
  33.                 'credits'=>0, 
  34.                 'timeoffset'=>9999 
  35.             ); 
  36.             DB::insert('common_member', $userdata); 
  37.  
  38.             $status_data = array( 
  39.                 'uid' => $uid, 
  40.                 'regip' => $ip, 
  41.                 'lastip' => $ip, 
  42.                 'lastvisit' => $time, 
  43.                 'lastactivity' => $time, 
  44.                 'lastpost' => 0, 
  45.                 'lastsendmail' => 0 
  46.             ); 
  47.             DB::insert('common_member_status', $status_data); 
  48.             DB::insert('common_member_profile', array('uid' => $uid)); 
  49.             DB::insert('common_member_field_forum', array('uid' => $uid)); 
  50.             DB::insert('common_member_field_home', array('uid' => $uid)); 
  51.             DB::insert('common_member_count', array('uid' => $uid)); 
  52.             DB::query('UPDATE '.DB::table('common_setting')." SET svalue='$username' WHERE skey='lastmember'"); 
  53.             $query = DB::query("SELECT uid, username, password FROM ".DB::table('common_member')." WHERE uid='$uid'"); 
  54.             if ($member = DB::fetch($query)) 
  55.             { 
  56.                 dsetcookie('auth', authcode("$member[password]\t$member[uid]"'ENCODE'), $cookietime); 
  57.             } 
  58.         } 
  59.     } 

Phpcms V9最新版与dx3.2整合失败是什么原因,Phpcms V9最新版与dx3.2整合失败如何解决

注意UC的表名前缀(UC数据库表前缀的格式为“ `数据库名`.数据库前缀 ”,注意数据库名的不是单引号。是数字键1左边的`号)

对于第7步,对discuz/api/uc.php 里function synlogin($get, $post)函数的修改,如下示例。

如果同步不登陆,请尝试下面的方法。 
A. 如果UC的表前缀和DZ的表前缀不一致,可根据实际情况使用下面一行代码,替换下面函数里红色代码部分。(UC表名: 为你的UC的会员表名。要根据情况替换为你自己的UC会员表名)
$query = DB::query("SELECT uid, username, password, email FROM UC表名WHERE username='$username'");


如我的UC表为cdb_uc_members , 则修改成$query = DB::query("SELECT uid, username, password, email FROM cdb_uc_members WHERE username='$username'");   如图所示:

原文地址:http://www.abcde.cn/info/show-23-903-1.html

以下是我个人开发过程中遇到的问题

①装上论坛后登陆不了Uc
打开\uc_server\model\admin.php
搜索:
$this->cookie_status = 0;修改为:$this->cookie_status = isset($_COOKIE['sid']) ? 1 : 0;
②<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;">v9可以和dz同步登陆但是不同步退出
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;">找到member_server\phpcms\modules\phpsso\classes\phpsso.class.php
<strong style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><pre name="code" class="php" style="display: inline !important;">第36行 注释掉<span style="font-size: 14px;"> </span>
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;"><div style="display: inline !important;"><pre name="code" class="php" style="display: inline !important;">exit('0');
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;"><span style="white-space:pre"></span>if(isset($_POST['data'])) {<span style="white-space:pre"></span>parse_str(sys_auth($_POST['data'], 'DECODE', $this->applist[$this->appid]['authkey']), $this->data);<span style="white-space:pre"></span><span style="white-space:pre"></span>if(empty($this->data) || !is_array($this->data)) {<span style="white-space:pre"></span><span style="color:#cc0000;">//exit('0');   这里第36行</span><span style="white-space:pre"></span>}<span style="white-space:pre"></span>} else {<span style="white-space:pre"></span>exit('0');<span style="white-space:pre"></span>}
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;">③论坛登陆 v9登陆不了
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;">找了一上午问题发现 
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;"><span style="white-space:pre"></span>1、论坛的uc缓存apps.php 里面没有 v9的应用 也不知道这个文件从哪生成的最后我把v9里的uc缓存apps.php 复制一份放到了论坛里 
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;"><span style="white-space:pre"></span>2、把v9里的member_server\caches\caches_admin\caches_data\applist.cache.php  里面的url地址设置为当前访问的url
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;"><span style="white-space:pre"></span>  1 =>   array (    'appid' => '1',    'type' => 'phpcms_v9',    'name' => 'phpcms v9',    'url' => 'http://localhost/phpcms/',   <span style="color:#ff6666;">//注意这个地址是否正确</span>    'authkey' => 'WruhF79DAwNhuWWo8',    'ip' => '',    'apifilename' => 'api.php?op=phpsso',    'charset' => 'utf-8',    'synlogin' => '1',  ),);<span style="white-space:pre"></span> 
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;">问题解决了 但是还是有些疑问不知道  bbs\uc_client\data\cache\apps.php 和 member_server\api\uc_client\data\cache\<strong></strong><pre name="code" class="php" style="font-size:14px;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></span>
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;"><div style="display: inline !important;"><pre name="code" class="php" style="display: inline !important;">apps.php 这两个缓存文件从哪生成的后来我手动把他们改成一致的了分别是论坛的应用配置信息和v9的应用配置信息
<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><strong></strong><div style="display: inline !important;"><pre name="code" class="php" style="font-size:14px; display: inline !important;"><strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;"><div style="display: inline !important;"><pre name="code" class="php" style="display: inline !important;"><pre name="code" class="php"><?php$_CACHE['apps'] = array (  1 =>   array (    'appid' => '1',    'type' => 'DISCUZX',    'name' => 'Discuz! Board',    'url' => 'http://localhost/<strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><pre name="code" class="php" style="font-size:14px; display: inline !important;"><strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><strong></strong><div style="display: inline !important;"><pre name="code" class="php" style="font-size:14px; display: inline !important;"><strong style="font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"></strong><div style="display: inline !important;"><span style="font-size:14px;"></span><pre name="code" class="php" style="display: inline !important;"><div style="display: inline !important;"><pre name="code" class="php" style="display: inline !important;"><div style="display: inline !important;"><div style="display: inline !important;"><pre name="code" class="php" style="display: inline !important;"><div style="display: inline !important;"><pre name="code" class="php" style="display: inline !important;"><div style="display: inline !important;"><pre name="code" class="php" style="display: inline !important;">phpcms
/bbs', 'ip' => '', 'viewprourl' => '', 'apifilename' => 'uc.php', 'charset' => '', 'dbcharset' => '', 'synlogin' => '1', 'recvnote' => '1', 'extra' => false, 'tagtemplates' => '', 'allowips' => '', ), 2 => array ( 'appid' => '2', 'type' => 'OTHER', 'name' => 'phpsso', 'url' => 'http://localhost/phpcms/phpcms_server', 'ip' => '', 'viewprourl' => '', 'apifilename' => 'uc.php', 'charset' => '', 'dbcharset' => '', 'synlogin' => '1', 'recvnote' => '0', 'extra' => false, 'tagtemplates' => '<?xml version="1.0" encoding="ISO-8859-1"?><root><item id="template"><![CDATA[]]></item></root>', 'allowips' => '', ),);?>



0 0
原创粉丝点击