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
/**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 中的编码格式调试:
/*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的系统中;
相信坚持的力量,日复一日的习惯.