PhpcmsV9 use of the QQ landing is still OAuth1.0, but now Tencent has not audited the use of OAuth1.0 's website. This is a huge pit for the webmaster who uses the PC. After the Phpcms forum of a classmate to do the plug-in to modify, now perfect QQ landing, no bug found.
Implementation steps:
① Open \phpcms\modules\member\index.php file, the following code to find a place to plug in (can be directly in the PC default QQ landing below).
-
-
QQ Landing oAuth2.0
-
-
ublic function public_qq_login2 () {
-
-
$appid = pc_base::load_config (' System ', ' qq_appid ');
-
-
$appkey = pc_base::load_config (' System ', ' Qq_appkey ');
-
-
$callback = pc_base::load_config (' System ', ' qq_callback ');
-
-
Pc_base::load_app_class (' qqOAuth2 ', ', ', 0);
-
-
$info = new QqOAuth2 ($appid, $appkey, $callback);
-
-
$this->_session_start ();
-
-
if (!isset ($_get[' code ')) {
-
-
$info->redirect_to_login ();
-
-
}else{
-
-
$code = $_get[' code '];
-
-
$_session[' OpenID ' = $info->get_openid ($code);//To fetch the QQ OpenID value
-
-
if (!emptyempty ($_session[' OpenID ')) {
-
-
$r = $this->db->get_one (' Connectid ' =>$_session[' OpenID '), ' from ' => ' QQ ');
-
-
if (!emptyempty ($r)) {
-
-
QQ already exists in the database, then direct to the landing operation
-
-
$password = $r [' Password '];
-
-
$this->_init_phpsso ();
-
-
$synloginstr = $this->client->ps_member_synlogin ($r [' phpssouid ']);
-
-
$userid = $r [' userid '];
-
-
$groupid = $r [' GroupID '];
-
-
$username = $r [' username '];
-
-
$nickname = Emptyempty ($r [' nickname '])? $username: $r [' nickname '];
-
-
$this->db->update (Array (' Lastip ' =>ip (), ' lastdate ' =>sys_time, ' nickname ' => $me [' name ']), Array (' UserID ' => $userid));
-
-
if (! $cookietime) $get _cookietime = Param::get_cookie (' cookietime ');
-
-
$_cookietime = $cookietime? Intval ($cookietime): ($get _cookietime $get _cookietime:0);
-
-
$cookietime = $_cookietime? Time + $_cookietime:0;
-
-
$phpcms _auth_key = MD5 (pc_base::load_config (' System ', ' Auth_key '). $this->http_user_agent);
-
-
$phpcms _auth = Sys_auth ($userid.) \ t ". $password, ' ENCODE ', $phpcms _auth_key);
-
-
Param::set_cookie (' auth ', $phpcms _auth, $cookietime);
-
-
Param::set_cookie (' _userid ', $userid, $cookietime);
-
-
Param::set_cookie (' _username ', $username, $cookietime);
-
-
Param::set_cookie (' _groupid ', $groupid, $cookietime);
-
-
Param::set_cookie (' Cookietime ', $_cookietime, $cookietime);
-
-
Param::set_cookie (' _nickname ', $nickname, $cookietime);
-
-
$forward = Isset ($_get[' forward ']) &&!emptyempty ($_get[' forward '])? $_get[' forward ']: ' Index.php?m=member&c=index ';
-
-
ShowMessage (L (' login_success '). $synloginstr, $forward);
-
-
}else{
-
-
Does not exist in the database, skip to refine the data page. Page preset username (QQ return is UTF8 code, if necessary for transcoding)
-
-
$user = $info->get_user_info ();
-
-
$_session[' connectid '] = $_session[' OpenID '];
-
-
$_session[' from '] = ' QQ ';
-
-
if (CHARSET!= ' utf-8 ') {//transcoding
-
-
$connect _username = iconv (' Utf-8 ', CHARSET, $user [' nickname ']);
-
-
}
-
-
Include template (' member ', ' Connect ');
-
-
}
-
-
}
-
-
}
-
-
}
② put the attached qqOAuth2.class.php file in the \phpcms\modules\member\classes\ folder.
③ in the background to find connect settings, the QQ number landing callback address changed to Http://php100.com/index.php?m=member&c=index&a=public_qq_login2 (Change my domain name to your own)
④ fill in the app ID and app key, and then update the cache.
⑤ Login phpMyAdmin, locate the Connectid field (or custom field) of the V9_member table and change the type to "char (255)" Because the PHPCMS default is 15-bit. So we directly and completely modified into 255, this is no matter Tencent's other third party website accounts (such as Taobao, Alipay, Baidu, and other third party accounts), can complete data binding. (This article added on July 27, by the Netizen liuyang814 sends the mail to remind)
Later, the code of Sina Weibo and Tencent Weibo will be put up. Phpcms's peripheral code is too few to find on the Internet.