exit('Access Denied'); } $config = $_G['cache']['plugin']['aljwsq']; require_once DISCUZ_ROOT . './source/plugin/wechat/wechat.lib.class.php'; require_once libfile('function/member'); $wechatuser = C::t('#wechat#common_member_wechat')->fetch_by_openid($postObj->FromUserName); $user = C::t('#aljwsq#aljwsq_user')->fetch($postObj->FromUserName); echo $this->responsetext(123); exit; if (empty($wechatuser) && empty($user)) { loaducenter(); $username = '******' . random(5); $return = register($username); WeChatHook::bindOpenId($return['uid'], $postObj->FromUserName, 1); require_once 'source/plugin/aljwsq/function_core.php'; $wuser = getwuserinfo($postObj, $config['appid'], $config['appsecret']); $user = C::t('#aljwsq#aljwsq_user')->fetch($postObj->FromUserName); if (!$user) { C::t('#aljwsq#aljwsq_user')->insert(array('nickname' => u2g($wuser['nickname']), 'username' => $username, 'openid' => $postObj->FromUserName, 'bindtime' => TIMESTAMP, 'sex' => $wuser['sex'], 'city' => u2g($wuser['city']), 'country' => u2g($wuser['country']), 'province' => u2g($wuser['province']), 'language' => $wuser['language'], 'headimgurl' => $wuser['headimgurl'], 'subscribe_time' => $wuser['subscribe_time'])); } else { C::t('#aljwsq#aljwsq_user')->update($postObj->FromUserName, array('nickname' => u2g($wuser['nickname']), 'username' => $username, 'bindtime' => TIMESTAMP, 'sex' => $wuser['sex'], 'city' => u2g($wuser['city']), 'country' => u2g($wuser['country']), 'province' => u2g($wuser['province']), 'language' => $wuser['language'], 'headimgurl' => $wuser['headimgurl'], 'subscribe_time' => $wuser['subscribe_time'])); } echo $this->responsetext($postObj, '您已成功注册本站帐号,用户名' . $return['username'] . ',密码' . $return['password'] . '.此帐户已与微信帐户成功绑定,并支持微信扫码登录.'); } else { if (empty($user)) { $user = getuserbyuid($wechatuser['uid']); } echo $this->responsetext($postObj, '您已成功注册过帐号,用户名' . $user['username']); } function g2u($a) {
public function responsemsg() { global $_G; $config = $_G['cache']['plugin']['aljwsq']; define("TOKEN", $config['token']); if ($_G['wechat']['setting']['wechat_token']) { $config['token'] = $_G['wechat']['setting']['wechat_token']; } $postStr = file_get_contents("php://input"); if (!empty($postStr)) { $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $textTpl = "<xml>\n\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t<MsgType><![CDATA[text]]></MsgType>\n\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t</xml>"; if ($postObj->MsgType == 'event' && $postObj->Event == 'CLICK') { $contentStr = trim($postObj->EventKey); $contentStr = $this->u2g($contentStr); } else { if ($postObj->MsgType == 'event' && $postObj->Event == 'SCAN') { $check = C::t('#aljwsq#aljwsq_wxqrcode_record')->count_by_openid_dateline($this->u2g($postObj->FromUserName), TIMESTAMP); if (empty($check)) { DB::query('update %t set num = num+1 where scene_id=%d', array('aljwsq_wxqrcode', $this->u2g($postObj->EventKey))); $scene_id = $postObj->EventKey; C::t('#aljwsq#aljwsq_wxqrcode_record')->insert(array('openid' => $this->u2g($postObj->FromUserName), 'scene_id' => $this->u2g($scene_id), 'dateline' => TIMESTAMP)); } $scan = C::t('#aljwsq#aljwsq_wxqrcode')->fetch_by_scene_id($scene_id); //echo $this->responsetext($postObj, $scene_id);exit; } else { if ($postObj->MsgType == 'voice') { C::t('#aljwsq#aljwsq_voice')->insert(array('toUser' => $this->u2g($postObj->ToUserName), 'fromUser' => $this->u2g($postObj->FromUserName), 'CreateTime' => $this->u2g($postObj->CreateTime), 'MsgType' => $this->u2g($postObj->MsgType), 'MediaId' => $this->u2g($postObj->MediaId), 'Format' => $this->u2g($postObj->Format), 'Recognition' => $this->u2g($postObj->Recognition), 'MsgId' => $this->u2g($postObj->MsgId))); exit; } else { if ($postObj->MsgType == 'event' && $postObj->Event == 'subscribe') { $config = $_G['cache']['plugin']['aljwsq']; require_once 'source/plugin/aljwsq/function_core.php'; if ($config['appid'] && $config['appsecret']) { $wuser = getwuserinfo($postObj, $config['appid'], $config['appsecret']); } $openid = (string) $this->u2g($postObj->FromUserName); $user = C::t('#aljwsq#aljwsq_user')->fetch($openid); if ($openid) { if (!$user && $openid) { C::t('#aljwsq#aljwsq_user')->insert(array('openid' => $openid, 'nickname' => $this->u2g($wuser['nickname']), 'sex' => $wuser['sex'], 'city' => $this->u2g($wuser['city']), 'country' => $this->u2g($wuser['country']), 'province' => $this->u2g($wuser['province']), 'language' => $wuser['language'], 'headimgurl' => $wuser['headimgurl'], 'subscribe_time' => TIMESTAMP)); } else { C::t('#aljwsq#aljwsq_user')->update($this->u2g($postObj->FromUserName), array('nickname' => $this->u2g($wuser['nickname']), 'sex' => $wuser['sex'], 'city' => $this->u2g($wuser['city']), 'country' => $this->u2g($wuser['country']), 'province' => $this->u2g($wuser['province']), 'language' => $wuser['language'], 'headimgurl' => $wuser['headimgurl'])); } } $subscribe = C::t('#aljwsq#aljwsq_autoreply')->fetch_by_msgtype('subscribe'); } else { if ($postObj->MsgType == 'event' && strtolower($postObj->Event) == 'location') { $location = C::t('#aljwsq#aljwsq_autoreply')->fetch_by_msgtype('location'); } else { $contentStr = $this->u2g(trim($postObj->Content)); } } } } } if ($contentStr || $subscribe || $location || $scan) { if ($subscribe) { if (file_exists('source/plugin/aljwsq/com/subscribe.php')) { include 'source/plugin/aljwsq/com/subscribe.php'; } } else { if ($location) { if (file_exists('source/plugin/aljwsq/com/location.php')) { include 'source/plugin/aljwsq/com/location.php'; } } else { if ($scan) { if (file_exists('source/plugin/aljwsq/com/scan.php')) { include 'source/plugin/aljwsq/com/scan.php'; } } else { C::t('#aljwsq#aljwsq_keywordlog')->insert(array('keyword' => $contentStr, 'openid' => $this->u2g($postObj->FromUserName), 'nickname' => $this->u2g($wuser['nickname']), 'dateline' => TIMESTAMP)); if (strpos($contentStr, lang('plugin/aljwsq', 'w1')) !== false) { $str = mb_substr($contentStr, -2, 2, CHARSET); $str_key = mb_substr($contentStr, 0, -2, CHARSET); if ($str == lang('plugin/aljwsq', 'w1') && !empty($str_key)) { $data = $this->weather($str_key); if (empty($data[weatherinfo])) { $contentStr = lang('plugin/aljwsq', 'w2') . $str_key . lang('plugin/aljwsq', 'w3'); } else { $info = $data['weatherinfo']; $contentStr = $str_key . lang('plugin/aljwsq', 'w4') . $info['temp'] . lang('plugin/aljwsq', 'w5') . $info['SD'] . lang('plugin/aljwsq', 'w6') . $this->u2g($info['WD']) . $info['WSE'] . lang('plugin/aljwsq', 'w7'); } echo $this->responsetext($postObj, $contentStr); } exit; } $news = C::t('#aljwsq#aljwsq_autoreply')->fetch_by_mykeyword($contentStr); $user = DB::fetch_first('select * from %t where openid=%s and bindtime!=0', array('aljwsq_user', $this->u2g($postObj->FromUserName))); if (!$user && $config['isnot'] && $news['msgtype'] != 'bind' && $news['msgtype'] != 'register') { echo $this->responsetext($postObj, $config['btips']); exit; } if ($news['msgtype'] == 'bindkeyword') { if (file_exists('source/plugin/aljwsq/com/bindkeyword.php')) { include 'source/plugin/aljwsq/com/bindkeyword.php'; } } } } } if ($news['msgtype'] == 'text') { if (file_exists('source/plugin/aljwsq/com/text.php')) { include 'source/plugin/aljwsq/com/text.php'; } } else { if ($news['msgtype'] == 'register') { if (file_exists('source/plugin/aljwsq/com/register.php')) { include 'source/plugin/aljwsq/com/register.php'; } } else { if ($news['msgtype'] == 'index' || $news['msgtype'] == 'ggk' || $news['msgtype'] == 'mes' || $news['msgtype'] == 'brandindex' || $news['msgtype'] == 'wsq') { echo $this->responsenews($postObj, $news); } else { if ($news['msgtype'] == 'bind') { if (file_exists('source/plugin/aljwsq/com/bind.php')) { include 'source/plugin/aljwsq/com/bind.php'; } } else { if ($news['msgtype'] == 'unbind') { if (file_exists('source/plugin/aljwsq/com/unbind.php')) { include 'source/plugin/aljwsq/com/unbind.php'; } } else { if ($news['msgtype'] == 'url') { if (file_exists('source/plugin/aljwsq/com/url.php')) { include 'source/plugin/aljwsq/com/url.php'; } } else { if ($news['msgtype'] == 'singlenews') { if (file_exists('source/plugin/aljwsq/com/singlenews.php')) { include 'source/plugin/aljwsq/com/singlenews.php'; } } else { if ($news['msgtype'] == 'multinews') { if (file_exists('source/plugin/aljwsq/com/multinews.php')) { include 'source/plugin/aljwsq/com/multinews.php'; } } else { if ($news['msgtype'] == 'thread') { if (file_exists('source/plugin/aljwsq/com/thread.php')) { include 'source/plugin/aljwsq/com/thread.php'; } } else { if ($news['msgtype'] == 'forum') { if (file_exists('source/plugin/aljwsq/com/forum.php')) { include 'source/plugin/aljwsq/com/forum.php'; } } else { if ($news['msgtype'] == 'forumlist') { if (file_exists('source/plugin/aljwsq/com/forumlist.php')) { include 'source/plugin/aljwsq/com/forumlist.php'; } } else { if ($news['msgtype'] == 'post') { if (file_exists('source/plugin/aljwsq/com/post.php')) { include 'source/plugin/aljwsq/com/post.php'; } } else { if ($news['msgtype'] == 'hotthread') { if (file_exists('source/plugin/aljwsq/com/hotthread.php')) { include 'source/plugin/aljwsq/com/hotthread.php'; } } else { if ($news['msgtype'] == 'digesthread') { if (file_exists('source/plugin/aljwsq/com/digesthread.php')) { include 'source/plugin/aljwsq/com/digesthread.php'; } } else { if ($news['msgtype'] == 'comb') { if (file_exists('source/plugin/aljwsq/com/comb.php')) { include 'source/plugin/aljwsq/com/comb.php'; } } else { if ($news['msgtype'] == 'newthread') { if (file_exists('source/plugin/aljwsq/com/newthread.php')) { include 'source/plugin/aljwsq/com/newthread.php'; } } else { if ($news['msgtype'] == 'newarticle') { if (file_exists('source/plugin/aljwsq/com/newarticle.php')) { include 'source/plugin/aljwsq/com/newarticle.php'; } } else { if ($news['msgtype'] == 'invite') { if (file_exists('source/plugin/aljwsq/com/invite.php')) { include 'source/plugin/aljwsq/com/invite.php'; } } else { if ($news['msgtype'] == 'sign') { if (file_exists('source/plugin/aljwsq/com/sign.php')) { include 'source/plugin/aljwsq/com/sign.php'; } } else { if ($news['msgtype'] == 'orderlist') { if (file_exists('source/plugin/aljwsq/com/orderlist.php')) { include 'source/plugin/aljwsq/com/orderlist.php'; } } else { if ($news['msgtype'] == 'music') { if (file_exists('source/plugin/aljwsq/com/music.php')) { include 'source/plugin/aljwsq/com/music.php'; } } else { if ($news['msgtype'] == 'voice') { if (file_exists('source/plugin/aljwsq/com/voice.php')) { include 'source/plugin/aljwsq/com/voice.php'; } } else { if ($news['msgtype'] == 'aljbd') { if (file_exists('source/plugin/aljwsq/com/aljbd.php')) { include 'source/plugin/aljwsq/com/aljbd.php'; } } else { global $_G; $config = $_G['cache']['plugin']['aljwsq']; $form = C::t('#aljwsq#aljwsq_autoreply_advanced')->fetch_by_mykeyword($contentStr); if ($form) { $form['url'] = 'plugin.php?id=aljwsq:form&fid=' . $form['id']; echo $this->responsenews($postObj, $form); exit; } $tid = intval($contentStr); if ($config['isthread'] && $tid && is_int($tid)) { $thread = C::t('forum_thread')->fetch($tid); if ($thread) { $news = $this->getnews($contentStr); echo $this->responsenews($postObj, $news); exit; } } $keyword = stripsearchkey($contentStr); if ($config['isservice']) { if ($config['skeywords']) { $config['skeywords'] = str_replace('\\r', '\\n', $config['skeywords']); $skeywords = explode("\n", $config['skeywords']); foreach ($skeywords as $wd) { $wd = trim($wd); if ($wd == $keyword) { echo $this->responseservice($postObj); exit; } } } else { echo $this->responseservice($postObj); exit; } } if (file_exists('source/plugin/aljwsq/com/so.php')) { if ($config['isso']) { $threads = C::t('forum_thread')->fetch_all_by_authorid_displayorder('', 'tid', '>=', '', $keyword, 0, $config['sonum']); } } $keyword = '%' . $keyword . '%'; if ($config['sobrand']) { $brands = DB::fetch_all('select * from %t where name like %s order by id desc limit 0,9', array('aljbd', $keyword)); } if ($threads) { if (file_exists('source/plugin/aljwsq/com/so.php')) { include 'source/plugin/aljwsq/com/so.php'; } } else { if ($brands) { $i = 0; foreach ($brands as $brand) { $tmp = $this->getbrands($brand['id'], $news); if (empty($i)) { if (empty($tmp['picurl'])) { $tmp['picurl'] = $config['default']; } } $items[] = $tmp; $i++; } echo $this->reponsemultinews($postObj, $items); } else { if (preg_match('/(http:\\/\\/)?(.*?)\\.(.*?)\\.(.*?)/is', $contentStr)) { if (file_exists('source/plugin/aljwsq/com/seo.php')) { include 'source/plugin/aljwsq/com/seo.php'; } } else { $config = $_G['cache']['plugin']['aljwsq']; if (file_exists('source/plugin/aljwsq/com/third.php')) { include 'source/plugin/aljwsq/com/third.php'; } if ($return && $return != 'Request Failed') { echo $return; } else { if ($config['so']) { echo $this->responsetext($postObj, $config['so']); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } }
$access_token = getaccesstoken($plugin['hjbox_appid'], $plugin['hjbox_appsecret']); if($access_token){ $uptokendata = array( 'access_token' => addslashes($access_token), 'cj_time'=>time(), ); $uptoken = C::t('#hejin_box#hjbox_token')->update_by_id(1,$uptokendata); $returnaccess = $access_token; } }else{ $returnaccess = $token['access_token']; } } if($returnaccess){ $wxuser = getwuserinfo($openid, $returnaccess); if($wxuser['nickname']){ $upuserdata = array(); $upuserdata['nickname']= addslashes(u2g($wxuser['nickname'])); $upuserdata['sex']= intval($wxuser['sex']); $upuserdata['city']= addslashes(u2g($wxuser['city'])); $upuserdata['country']= addslashes(u2g($wxuser['country'])); $upuserdata['province']= addslashes(u2g($wxuser['province'])); $upuserdata['headimgurl']= addslashes(u2g($wxuser['headimgurl'])); $upuser = C::t('#hejin_box#hjbox_users')->update_by_id($userinfo['id'],$upuserdata); if($upuser){ $url = 'action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=hejin_toupiao&pmod=toupiao&model=tpjles&zid='.$zid.'&page='.$page; cpmsg(lang('plugin/hejin_box', 'getcg'), $url, 'succeed'); exit; }else{ $url = 'action=plugins&operation=config&do=' . $_GET['do'] . '&identifier=hejin_toupiao&pmod=toupiao&model=tpjles&zid='.$zid.'&page='.$page;