discuz 登录,怎么调试出$ucsynlogin,tp如何和discuz同步登录
/home/wwwroot/default/old_sqfoto/source/class/class_member.php----
1.on_login函数中调试------把跳转时间延长,在3000的地方,改为999999999;这样就不用跳转了;
2.$this->setting['allowsynlogin'] = true;//added 添加这个字段~~~因为缓存,或其他配置,这个变量没有被复制;相当于cache中的app.php是否开启同步登录一样~~~
//~~~~因为这个回调,对discuz不了解,起码多出4 5天的时间;不断的删除重建discuz环境~~~~~
或者参考: http://www.cnblogs.com/coxsoft/archive/2013/12/27/3494794.html
同步信息,多增salt,email信息,salt是为了处理photos那边密码同步用的;
/home/wwwroot/default/old_sqfoto/uc_server/control/user.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /**added by zhubin 新增了邮箱和salt字段*/ function onsynlogin() { $ this ->init_input(); $uid = $ this ->input( 'uid' ); if ($ this ->app[ 'synlogin' ]) { if ($ this ->user = $_ENV[ 'user' ]->get_user_by_uid($uid)) { $synstr = '' ; foreach ($ this ->cache[ 'apps' ] as $appid => $app) { if ($app[ 'synlogin' ]) { if ($app[ 'appid' ] != $ this ->app[ 'appid' ]) { $synstr .= '<script type="text/javascript" src="' .$app[ 'url' ]. '/api/' .$app[ 'apifilename' ]. '?time=' .$ this ->time. '&code=' .urlencode($ this ->authcode( 'action=synlogin&username=' .$ this ->user[ 'username' ]. '&uid=' .$ this ->user[ 'uid' ]. '&email=' .$ this ->user[ 'email' ] . '&password=' .$ this ->user[ 'password' ]. '&salt=' .$ this ->user[ 'salt' ]."&time= ".$this->time,'ENCODE', $app['authkey'])).'" reload= "1" ></script>'; } if (is_array($app[ 'extra' ][ 'extraurl' ])) foreach ($app[ 'extra' ][ 'extraurl' ] as $extraurl) { $synstr .= '<script type="text/javascript" src="' .$extraurl. '/api/' .$app[ 'apifilename' ]. '?time=' .$ this ->time. '&code=' .urlencode($ this ->authcode( 'action=synlogin&username=' .$ this ->user[ 'username' ]. '&uid=' .$ this ->user[ 'uid' ]. '&email=' .$ this ->user[ 'email' ]. '&password=' .$ this ->user[ 'password' ]. '&salt=' .$ this ->user[ 'salt' ]."&time= ".$this->time,'ENCODE', $app['authkey'])).'" reload= "1" ></script>'; } } } return $synstr; } } return '' ; } // function onsynlogin() { // $this->init_input(); // $uid = $this->input('uid'); // if($this->app['synlogin']) { // if($this->user = $_ENV['user']->get_user_by_uid($uid)) { // $synstr = ''; // foreach($this->cache['apps'] as $appid => $app) { // if($app['synlogin']) { // if($app['appid'] != $this->app['appid']) { // $synstr .= '<script type="text/javascript" src="'.$app['url'].'/api/'.$app['apifilename'].'?time='.$this->time.'&code='.urlencode($this->authcode('action=synlogin&username='.$this->user['username'].'&uid='.$this->user['uid'].'&password='.$this->user['password']."&time=".$this->time, 'ENCODE', $app['authkey'])).'" reload="1"></script>'; // } // if(is_array($app['extra']['extraurl'])) foreach($app['extra']['extraurl'] as $extraurl) { // $synstr .= '<script type="text/javascript" src="'.$extraurl.'/api/'.$app['apifilename'].'?time='.$this->time.'&code='.urlencode($this->authcode('action=synlogin&username='.$this->user['username'].'&uid='.$this->user['uid'].'&password='.$this->user['password']."&time=".$this->time, 'ENCODE', $app['authkey'])).'" reload="1"></script>'; // } // } // } // return $synstr; // } // } // return ''; // } |
discuz同步过来的信息,到tp中中文用不了;
1.中文解析过来就乱码
在uc.php头部加:
header("Content-type:text/html;charset=gb2312");//~~~added 否则线上乱码;
2.sql语句处理不了中文,非中文用户同步,中文用户不好同步
在uc/include/config.inc.php 中的编码格式调试:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /*discuz表格 前缀 photos登录discuz从ucenter用户表中抓取插入用户信息~~*/ define( 'DISCUZ_DANAME' , 'x3gbk' ); define( 'DISCUZ_DBRRE' , 'pre_' ); //同步登录 Cookie 设置 $cookiedomain = 'local.photos.caomall.net' ; // cookie 作用域, 这里前面不能加http://,否则区域无效~~~ $cookiepath = '/' ; // cookie 作用路径 $dbhost = 'localhost' ; // 数据库服务器 $dbuser = 'root' ; // 数据库用户名 $dbpw = '123456' ; // 数据库密码 $dbname = 'photos' ; // 数据库名 $pconnect = 0; // 数据库持久连接 0=关闭, 1=打开 $tablepre = 'tf_' ; // 表名前缀, 同一数据库安装多个论坛请修改此处 $dbcharset = 'gbk' ; //线上字段为gbk,这个字段关系discuz同步过来中文在这里sql处理的编码格式,sql语句是否可以用来处理乱码,在这设定; // MySQL 字符集, 可选 'gbk', 'big5', 'utf8', 'latin1', 留空为按照论坛字符集设定 |
3. uc只是设定setcookie登录方法,tp中用的是session,如何处理?
先设定cookie,因为cookie用了好有个作用域,在融入tp系统的session中,否则即使设定了session,也融入不了tp的系统中;
相信坚持的力量,日复一日的习惯.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)