if ($dopost == 'loginbyqq') { session_start(); $code = $_REQUEST["code"]; include SLINEINC . '/qq.class.php'; //$appid='100423525'; //$appkey='f833e7f02293ff05dfeb303d71fdf255'; $appid = $cfg_qq_appid; $appkey = $cfg_qq_appkey; $callback_url = "{$GLOBALS['cfg_basehost']}/member/login.php?dopost=loginbyqq"; $qq = new qqPHP($appid, $appkey, $callback_url); if (empty($code)) { $url = $qq->login_url($_SESSION['state']); header("location:{$url}"); exit; } else { $token = $qq->access_token($code); //获取access-toking $openid = $qq->get_openid($token); //获取openid if (!empty($openid)) { $sql = "select * from #@__member where `connectid`='{$openid}' and `from`='qq'"; $r = $dsql->GetOne($sql); if (!empty($r)) { /* $user=!empty($r['mobile']) ? $r['mobile'] : $r['email']; $pass=$r['pwd']; $User=new Member(7*3600); $flag = $User->Login($user, $pass,true); if($flag) {
*/ session_start(); require_once 'config.php'; require_once 'function.php'; $u = './'; $c_log = chklog(); if ($c_log) { $u = './?m=profile&t=sync&n=qq'; } else { $u = './?m=login&t=qq'; } if ($config['is_qq'] > 0 && $config['qq_app_id'] != '' && $config['qq_app_key'] != '') { if (isset($_GET['code']) && trim($_GET['code']) != '') { require_once 'lib/qq.php'; $o = new qqPHP($config['qq_app_id'], $config['qq_app_key']); $result = $o->access_token($config['site_url'] . 'qq_callback.php', $_GET['code']); } if (isset($result['access_token']) && $result['access_token'] != '') { $s_t = $result['access_token']; if ($c_log) { $ar = getainfo($_SESSION[$config['u_hash']], 'id, name'); $s_dby = sprintf('select id from %s where aid=%s and name=%s limit 1', $dbprefix . 'm_sync', $ar['id'], SQLString('qq', 'text')); $q_dby = mysql_query($s_dby) or die(''); $r_dby = mysql_fetch_assoc($q_dby); if (mysql_num_rows($q_dby) > 0) { $u_db = sprintf('update %s set s_t=%s where id=%s', $dbprefix . 'm_sync', SQLString($s_t, 'text'), $r_dby['id']); $result = mysql_query($u_db) or die(''); } else { $i_db = sprintf('insert into %s (aid, name, s_t) values (%s, %s, %s)', $dbprefix . 'm_sync', $ar['id'], SQLString('qq', 'text'), SQLString($s_t, 'text')); $result = mysql_query($i_db) or die(''); }