diff --git a/user/profile/template/profile.htm b/user/profile/template/profile.htm index d54e360..cb629f8 100644 --- a/user/profile/template/profile.htm +++ b/user/profile/template/profile.htm @@ -79,7 +79,7 @@
-
$_G[username]    {lang do_unbind} +
$_G[username]
diff --git a/user/qqlogin/api_qqlogin/class/ErrorCase.class.php b/user/qqlogin/api_qqlogin/class/ErrorCase.class.php deleted file mode 100644 index 273913a..0000000 --- a/user/qqlogin/api_qqlogin/class/ErrorCase.class.php +++ /dev/null @@ -1,48 +0,0 @@ -errorMsg = array( - "20001" => "

配置文件损坏或无法读取,请重新执行intall

", - "30001" => "

The state does not match. You may be a victim of CSRF.

", - "50001" => "

可能是服务器无法请求https协议

可能未开启curl支持,请尝试开启curl支持,重启web服务器,如果问题仍未解决,请联系我们" - ); - } - - /** - * showError - * 显示错误信息 - * @param int $code 错误代码 - * @param string $description 描述信息(可选) - */ - public function showError($code, $description = '$'){ - $recorder = new Recorder(); - if(! $recorder->readInc("errorReport")){ - die();//die quietly - } - - - echo ""; - if($description == "$"){ - die($this->errorMsg[$code]); - }else{ - echo "

error:

$code"; - echo "

msg :

$description"; - exit(); - } - } - public function showTips($code, $description = '$'){ - } -} diff --git a/user/qqlogin/api_qqlogin/class/Oauth.class.php b/user/qqlogin/api_qqlogin/class/Oauth.class.php deleted file mode 100644 index 7980002..0000000 --- a/user/qqlogin/api_qqlogin/class/Oauth.class.php +++ /dev/null @@ -1,120 +0,0 @@ -recorder = new Recorder(); - $this->urlUtils = new URL(); - $this->error = new ErrorCase(); - } - - public function qq_login(){ - $appid = $this->recorder->readInc("appid"); - $callback = $this->recorder->readInc("callback"); - $scope = $this->recorder->readInc("scope"); - - //-------生成唯一随机串防CSRF攻击 - $state = md5(uniqid(rand(), TRUE)); - $this->recorder->write('state',$state); - - //-------构造请求参数列表 - $keysArr = array( - "response_type" => "code", - "client_id" => $appid, - "redirect_uri" => $callback, - "state" => $state, - "scope" => $scope - ); - - $login_url = $this->urlUtils->combineURL(self::GET_AUTH_CODE_URL, $keysArr); - header("Location:$login_url"); - } - - public function qq_callback(){ - $state = $this->recorder->read("state"); - - //--------验证state防止CSRF攻击 - if($_GET['state'] != $state){ - $this->error->showError("30001"); - } - - //-------请求参数列表 - $keysArr = array( - "grant_type" => "authorization_code", - "client_id" => $this->recorder->readInc("appid"), - "redirect_uri" => urlencode($this->recorder->readInc("callback")), - "client_secret" => $this->recorder->readInc("appkey"), - "code" => $_GET['code'] - ); - //------构造请求access_token的url - $token_url = $this->urlUtils->combineURL(self::GET_ACCESS_TOKEN_URL, $keysArr); - $response = $this->urlUtils->get_contents($token_url); - - if(strpos($response, "callback") !== false){ - - $lpos = strpos($response, "("); - $rpos = strrpos($response, ")"); - $response = substr($response, $lpos + 1, $rpos - $lpos -1); - $msg = json_decode($response); - - if(isset($msg->error)){ - $this->error->showError($msg->error, $msg->error_description); - } - } - - $params = array(); - parse_str($response, $params); - - $this->recorder->write("access_token", $params["access_token"]); - return $params["access_token"]; - - } - - public function get_openid(){ - - //-------请求参数列表 - $keysArr = array( - "access_token" => $this->recorder->read("access_token") - ); - - $graph_url = $this->urlUtils->combineURL(self::GET_OPENID_URL, $keysArr); - $response = $this->urlUtils->get_contents($graph_url); - - //--------检测错误是否发生 - if(strpos($response, "callback") !== false){ - - $lpos = strpos($response, "("); - $rpos = strrpos($response, ")"); - $response = substr($response, $lpos + 1, $rpos - $lpos -1); - } - - $user = json_decode($response); - if(isset($user->error)){ - $this->error->showError($user->error, $user->error_description); - } - - //------记录openid - $this->recorder->write("openid", $user->openid); - return $user->openid; - - } -} diff --git a/user/qqlogin/api_qqlogin/class/QC.class.php b/user/qqlogin/api_qqlogin/class/QC.class.php deleted file mode 100644 index 8999ab0..0000000 --- a/user/qqlogin/api_qqlogin/class/QC.class.php +++ /dev/null @@ -1,302 +0,0 @@ -keysArr = array( - "oauth_consumer_key" => (int)$this->recorder->readInc("appid"), - "access_token" => $this->recorder->read("access_token"), - "openid" => $this->recorder->read("openid") - ); - }else{ - $this->keysArr = array( - "oauth_consumer_key" => (int)$this->recorder->readInc("appid"), - "access_token" => $access_token, - "openid" => $openid - ); - } - - //初始化APIMap - /* - * 加#表示非必须,无则不传入url(url中不会出现该参数), "key" => "val" 表示key如果没有定义则使用默认值val - * 规则 array( baseUrl, argListArr, method) - */ - $this->APIMap = array( - - - /* qzone */ - "add_blog" => array( - "https://graph.qq.com/blog/add_one_blog", - array("title", "format" => "json", "content" => null), - "POST" - ), - "add_topic" => array( - "https://graph.qq.com/shuoshuo/add_topic", - array("richtype","richval","con","#lbs_nm","#lbs_x","#lbs_y","format" => "json", "#third_source"), - "POST" - ), - "get_user_info" => array( - "https://graph.qq.com/user/get_user_info", - array("format" => "json"), - "GET" - ), - "add_one_blog" => array( - "https://graph.qq.com/blog/add_one_blog", - array("title", "content", "format" => "json"), - "GET" - ), - "add_album" => array( - "https://graph.qq.com/photo/add_album", - array("albumname", "#albumdesc", "#priv", "format" => "json"), - "POST" - ), - "upload_pic" => array( - "https://graph.qq.com/photo/upload_pic", - array("picture", "#photodesc", "#title", "#albumid", "#mobile", "#x", "#y", "#needfeed", "#successnum", "#picnum", "format" => "json"), - "POST" - ), - "list_album" => array( - "https://graph.qq.com/photo/list_album", - array("format" => "json") - ), - "add_share" => array( - "https://graph.qq.com/share/add_share", - array("title", "url", "#comment","#summary","#images","format" => "json","#type","#playurl","#nswb","site","fromurl"), - "POST" - ), - "check_page_fans" => array( - "https://graph.qq.com/user/check_page_fans", - array("page_id" => "314416946","format" => "json") - ), - /* wblog */ - - "add_t" => array( - "https://graph.qq.com/t/add_t", - array("format" => "json", "content","#clientip","#longitude","#compatibleflag"), - "POST" - ), - "add_pic_t" => array( - "https://graph.qq.com/t/add_pic_t", - array("content", "pic", "format" => "json", "#clientip", "#longitude", "#latitude", "#syncflag", "#compatiblefalg"), - "POST" - ), - "del_t" => array( - "https://graph.qq.com/t/del_t", - array("id", "format" => "json"), - "POST" - ), - "get_repost_list" => array( - "https://graph.qq.com/t/get_repost_list", - array("flag", "rootid", "pageflag", "pagetime", "reqnum", "twitterid", "format" => "json") - ), - "get_info" => array( - "https://graph.qq.com/user/get_info", - array("format" => "json") - ), - "get_other_info" => array( - "https://graph.qq.com/user/get_other_info", - array("format" => "json", "#name", "fopenid") - ), - "get_fanslist" => array( - "https://graph.qq.com/relation/get_fanslist", - array("format" => "json", "reqnum", "startindex", "#mode", "#install", "#sex") - ), - "get_idollist" => array( - "https://graph.qq.com/relation/get_idollist", - array("format" => "json", "reqnum", "startindex", "#mode", "#install") - ), - "add_idol" => array( - "https://graph.qq.com/relation/add_idol", - array("format" => "json", "#name-1", "#fopenids-1"), - "POST" - ), - "del_idol" => array( - "https://graph.qq.com/relation/del_idol", - array("format" => "json", "#name-1", "#fopenid-1"), - "POST" - ), - /* pay */ - - "get_tenpay_addr" => array( - "https://graph.qq.com/cft_info/get_tenpay_addr", - array("ver" => 1,"limit" => 5,"offset" => 0,"format" => "json") - ) - ); - } - - //调用相应api - private function _applyAPI($arr, $argsList, $baseUrl, $method){ - $pre = "#"; - $keysArr = $this->keysArr; - - $optionArgList = array();//一些多项选填参数必选一的情形 - foreach($argsList as $key => $val){ - $tmpKey = $key; - $tmpVal = $val; - - if(!is_string($key)){ - $tmpKey = $val; - - if(strpos($val,$pre) === 0){ - $tmpVal = $pre; - $tmpKey = substr($tmpKey,1); - if(preg_match("/-(\d$)/", $tmpKey, $res)){ - $tmpKey = str_replace($res[0], "", $tmpKey); - $optionArgList[$res[1]][] = $tmpKey; - } - }else{ - $tmpVal = null; - } - } - - //-----如果没有设置相应的参数 - if(!isset($arr[$tmpKey]) || $arr[$tmpKey] === ""){ - - if($tmpVal == $pre){//则使用默认的值 - continue; - }else if($tmpVal){ - $arr[$tmpKey] = $tmpVal; - }else{ - if($v = $_FILES[$tmpKey]){ - - $filename = dirname($v['tmp_name'])."/".$v['name']; - move_uploaded_file($v['tmp_name'], $filename); - $arr[$tmpKey] = "@$filename"; - - }else{ - $this->error->showError("api调用参数错误","未传入参数$tmpKey"); - } - } - } - - $keysArr[$tmpKey] = $arr[$tmpKey]; - } - //检查选填参数必填一的情形 - foreach($optionArgList as $val){ - $n = 0; - foreach($val as $v){ - if(in_array($v, array_keys($keysArr))){ - $n ++; - } - } - - if(! $n){ - $str = implode(",",$val); - $this->error->showError("api调用参数错误",$str."必填一个"); - } - } - - if($method == "POST"){ - if($baseUrl == "https://graph.qq.com/blog/add_one_blog") $response = $this->urlUtils->post($baseUrl, $keysArr, 1); - else $response = $this->urlUtils->post($baseUrl, $keysArr, 0); - }else if($method == "GET"){ - $response = $this->urlUtils->get($baseUrl, $keysArr); - } - - return $response; - - } - - /** - * _call - * 魔术方法,做api调用转发 - * @param string $name 调用的方法名称 - * @param array $arg 参数列表数组 - * @since 5.0 - * @return array 返加调用结果数组 - */ - public function __call($name,$arg){ - //如果APIMap不存在相应的api - if(empty($this->APIMap[$name])){ - $this->error->showError("api调用名称错误","不存在的API: $name"); - } - - //从APIMap获取api相应参数 - $baseUrl = $this->APIMap[$name][0]; - $argsList = $this->APIMap[$name][1]; - $method = isset($this->APIMap[$name][2]) ? $this->APIMap[$name][2] : "GET"; - - if(empty($arg)){ - $arg[0] = null; - } - - //对于get_tenpay_addr,特殊处理,php json_decode对\xA312此类字符支持不好 - if($name != "get_tenpay_addr"){ - $response = json_decode($this->_applyAPI($arg[0], $argsList, $baseUrl, $method)); - $responseArr = $this->objToArr($response); - }else{ - $responseArr = $this->simple_json_parser($this->_applyAPI($arg[0], $argsList, $baseUrl, $method)); - } - - - //检查返回ret判断api是否成功调用 - if($responseArr['ret'] == 0){ - return $responseArr; - }else{ - $this->error->showError($response->ret, $response->msg); - } - - } - - //php 对象到数组转换 - private function objToArr($obj){ - if(!is_object($obj) && !is_array($obj)) { - return $obj; - } - $arr = array(); - foreach($obj as $k => $v){ - $arr[$k] = $this->objToArr($v); - } - return $arr; - } - - - /** - * get_access_token - * 获得access_token - * @param void - * @since 5.0 - * @return string 返加access_token - */ - public function get_access_token(){ - return $this->recorder->read("access_token"); - } - - //简单实现json到php数组转换功能 - private function simple_json_parser($json){ - $json = str_replace("{","",str_replace("}","", $json)); - $jsonValue = explode(",", $json); - $arr = array(); - foreach($jsonValue as $v){ - $jValue = explode(":", $v); - $arr[str_replace('"',"", $jValue[0])] = (str_replace('"', "", $jValue[1])); - } - return $arr; - } -} diff --git a/user/qqlogin/api_qqlogin/class/Recorder.class.php b/user/qqlogin/api_qqlogin/class/Recorder.class.php deleted file mode 100644 index fb623d6..0000000 --- a/user/qqlogin/api_qqlogin/class/Recorder.class.php +++ /dev/null @@ -1,66 +0,0 @@ -error = new ErrorCase(); - - //-------读取配置文件 - $incFileContents = file(ROOT."comm/inc.php"); - $incFileContents = $incFileContents[1]; - $this->inc = json_decode($incFileContents); - if(empty($this->inc)){ - $this->error->showError("20001"); - } - - if(empty($_SESSION['QC_userData'])){ - self::$data = array(); - }else{ - self::$data = $_SESSION['QC_userData']; - } - } - - public function write($name,$value){ - self::$data[$name] = $value; - } - - public function read($name){ - if(empty(self::$data[$name])){ - return null; - }else{ - return self::$data[$name]; - } - } - - public function readInc($name){ - global $_G; - if($name == 'appid'){ - return $_G['setting']['qq_appid']; - }else if($name == 'appkey'){ - return $_G['setting']['qq_appkey']; - }else if($name == 'callback'){ - return $_G['siteurl'].urlencode('user.php?mod=qqlogin&type=callback'); - }else if(empty($this->inc->$name)){ - return $this->inc->$name; - }else{ - return null; - } - } - - public function delete($name){ - unset(self::$data[$name]); - } - - function __destruct(){ - $_SESSION['QC_userData'] = self::$data; - } -} diff --git a/user/qqlogin/api_qqlogin/class/URL.class.php b/user/qqlogin/api_qqlogin/class/URL.class.php deleted file mode 100644 index 6419427..0000000 --- a/user/qqlogin/api_qqlogin/class/URL.class.php +++ /dev/null @@ -1,100 +0,0 @@ -error = new ErrorCase(); - } - - /** - * combineURL - * 拼接url - * @param string $baseURL 基于的url - * @param array $keysArr 参数列表数组 - * @return string 返回拼接的url - */ - public function combineURL($baseURL,$keysArr){ - $combined = $baseURL."?"; - $valueArr = array(); - - foreach($keysArr as $key => $val){ - $valueArr[] = "$key=$val"; - } - - $keyStr = implode("&",$valueArr); - $combined .= ($keyStr); - - return $combined; - } - - /** - * get_contents - * 服务器通过get请求获得内容 - * @param string $url 请求的url,拼接后的 - * @return string 请求返回的内容 - */ - public function get_contents($url){ - if (ini_get("allow_url_fopen") == "1") { - $response = file_get_contents($url); - }else{ - $ch = curl_init(); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($ch, CURLOPT_URL, $url); - $response = curl_exec($ch); - curl_close($ch); - } - - //-------请求为空 - if(empty($response)){ - $this->error->showError("50001"); - } - - return $response; - } - - /** - * get - * get方式请求资源 - * @param string $url 基于的baseUrl - * @param array $keysArr 参数列表数组 - * @return string 返回的资源内容 - */ - public function get($url, $keysArr){ - $combined = $this->combineURL($url, $keysArr); - return $this->get_contents($combined); - } - - /** - * post - * post方式请求资源 - * @param string $url 基于的baseUrl - * @param array $keysArr 请求的参数列表 - * @param int $flag 标志位 - * @return string 返回的资源内容 - */ - public function post($url, $keysArr, $flag = 0){ - - $ch = curl_init(); - if(! $flag) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); - curl_setopt($ch, CURLOPT_POST, TRUE); - curl_setopt($ch, CURLOPT_POSTFIELDS, $keysArr); - curl_setopt($ch, CURLOPT_URL, $url); - $ret = curl_exec($ch); - - curl_close($ch); - return $ret; - } -} diff --git a/user/qqlogin/api_qqlogin/comm/config.php b/user/qqlogin/api_qqlogin/comm/config.php deleted file mode 100644 index 13a0322..0000000 --- a/user/qqlogin/api_qqlogin/comm/config.php +++ /dev/null @@ -1,9 +0,0 @@ - -{"scope":"get_user_info,add_share,list_album,add_album,upload_pic,add_topic,add_one_blog,add_weibo,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idolist,add_idol,del_idol,get_tenpay_addr","errorReport":true,"storageType":"file","host":"localhost","user":"root","password":"root","database":"test"} \ No newline at end of file diff --git a/user/qqlogin/api_qqlogin/comm/utils.php b/user/qqlogin/api_qqlogin/comm/utils.php deleted file mode 100644 index 02a027b..0000000 --- a/user/qqlogin/api_qqlogin/comm/utils.php +++ /dev/null @@ -1,43 +0,0 @@ - diff --git a/user/qqlogin/api_qqlogin/qqConnectAPI.php b/user/qqlogin/api_qqlogin/qqConnectAPI.php deleted file mode 100644 index 25d77f2..0000000 --- a/user/qqlogin/api_qqlogin/qqConnectAPI.php +++ /dev/null @@ -1,10 +0,0 @@ - $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['member']['uid']); - showmessage('login_succeed', $referer ? $referer : './', $param); - $msg = ''; - $msg .= ' '; - $msg .= '
'; - exit($msg); - } - $inurl = $_SERVER["HTTP_REFERER"]; - //来路 - $_SESSION['url_ref'] = $inurl; - $qc = new QC(); - $qc -> qq_login(); - -} elseif ($_GET['type'] == 'callback') { - - if (!$_SESSION['openid'] || $_GET['code']) { - $qc = new QC(); - $access = $qc -> qq_callback(); - $openid = $qc -> get_openid(); - $_SESSION['openid'] = $openid; - $_SESSION['access'] = $access; - $qc = new QC($access, $openid); - $uinfo = $qc -> get_user_info(); - $_SESSION['uinfo'] = $uinfo; - - } else { - $access = $_SESSION['access']; - $openid = $_SESSION['openid']; - $uinfo = $_SESSION['uinfo']; - } - if (!DB::result_first("select COUNT(*) from %t where openid=%d", array('user_qqconnect', $openid))) { - if ($_G['setting']['qq_bind']==1){ - include template('qqcallback'); - exit(); - }else { - dheader("Location: user.php?mod=qqlogin&type=newuser"); - } - } - session_unset(); - $user = C::t('user_qqconnect') -> fetch_by_openid($openid); - if ($user['status'] == -2) { - showmessage('user_stopped_please_admin'); - } elseif ($_G['setting']['bbclosed'] && $user['adminid'] != 1) { - showmessage('site_closed_please_admin'); - } - setloginstatus($user, $_GET['cookietime'] ? 2592000 : 0); - if ($_G['member']['lastip'] && $_G['member']['lastvisit']) { - dsetcookie('lip', $_G['member']['lastip'] . ',' . $_G['member']['lastvisit']); - } - C::t('user_status') -> update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP)); - writelog('loginlog', 'QQ登录成功'); - $param = array( - 'username' => $result['username'], - 'usergroup' => $_G['group']['grouptitle'], - 'uid' => $_G['member']['uid'], - 'groupid' => $_G['groupid'], - 'syn' => 0 - ); - - $extra = array( - 'showdialog' => true, - 'locationtime' => true, - 'extrajs' => '' - ); - - $loginmessage = $_G['groupid'] == 8 ? 'login_succeed_inactive_member' : 'login_succeed'; - $location = $_G['groupid'] == 8 ? 'index.php?open=password' : dreferer(); - if (defined('IN_MOBILE')) { - showmessage('location_login_succeed_mobile', $location, array('username' => $result['username']), array('location' => true)); - } else { - showmessage($loginmessage, $location, $param, $extra); - } - -} elseif ($_GET['type'] == 'newuser') {//不绑定,直接使用时根据QQ登录获取的用户信息来添加用户,用户名,姓名使用QQ昵称,邮箱和密码随机 - $openid = $_SESSION['openid']; - $uinfo = $_SESSION['uinfo']; - if (empty($openid)) { - @header("Location:" . $_G[siteurl] . 'user.php?mod=qqlogin&type=callback'); - exit(); - } elseif (DB::result_first("select COUNT(*) from %t where openid=%d", array('user_qqconnect', $openid))) { - - } - @session_unset(); - $groupinfo = array(); - $addorg = 0; - if ($_G['setting']['regverify']) { - $groupinfo['groupid'] = 8; - } else { - $groupinfo['groupid'] = $_G['setting']['newusergroupid']; - $addorg = 1; - } - $password = random(20); - $email = $password . '@qq.com'; - $result = uc_user_register(addslashes($uinfo['nickname']), $password, $email, '', 0, '', $_G['clientip'], $addorg); - if (is_array($result)) { - $uid = $result['uid']; - $password = $result['password']; - } else { - $uid = $result; - } - if ($uid <= 0) { - if ($uid == -1) { - showmessage('profile_nickname_illegal'); - } elseif ($uid == -2) { - showmessage('profile_nickname_protect'); - } elseif ($uid == -3) { - showmessage('profile_nickname_duplicate'); - } elseif ($uid == -4) { - showmessage('profile_email_illegal'); - } elseif ($uid == -5) { - showmessage('profile_email_domain_illegal'); - } elseif ($uid == -6) { - showmessage('profile_email_duplicate'); - } elseif ($uid == -7) { - showmessage('profile_username_illegal'); - } else { - showmessage('undefined_action'); - } - } else { - C::t('user_qqconnect') -> insert_by_openid($openid, $uid, $uinfo, 1); - } - setloginstatus(array('uid' => $uid, 'username' => $result['username'], 'password' => $password, 'groupid' => $groupinfo['groupid'], ), 0); - showmessage(lang('congratulations') . $result['username'] . ',' . lang('login_success'), $_G['siteurl']); -} elseif ($_GET['type'] == 'olduser') { - $userinfo = $_GET['userinfo']; - if (isemail($userinfo['email'])) { - $user = C::t('user') -> fetch_by_email($userinfo['email']); - } else { - $user = C::t('user') -> fetch_by_username($userinfo['username']); - }; - if (!$user) { - showmessage('username_or_password_error', $_G['siteurl'] . 'user.php?mod=qqlogin&type=callback'); - } - $md5pw = md5(md5($userinfo['pw']) . $user['salt']); - if ($md5pw == $user['password']) { - C::t('user_qqconnect') -> insert_by_openid($_SESSION['openid'], $user['uid'], $_SESSION['uinfo']); - session_unset(); - setloginstatus($user, $_GET['cookietime'] ? 2592000 : 0); - showmessage(lang('congratulations') . $user['username'] . ',' . lang('qq_shortcut_login_binding_success'), $_G['siteurl']); - } else { - showmessage('user_password_not_correct', $_G['siteurl'] . 'user.php?mod=qqlogin&type=callback'); - } -} -?> \ No newline at end of file diff --git a/user/qqlogin/template/qqcallback.htm b/user/qqlogin/template/qqcallback.htm deleted file mode 100644 index d79261f..0000000 --- a/user/qqlogin/template/qqcallback.htm +++ /dev/null @@ -1,85 +0,0 @@ - - - - - -
-
-
-
-

$uinfo['nickname']

-
-
- -
-
- -
-
- -
-
- -
- -
-
-
-
- \ No newline at end of file