Exemplo n.º 1
1
 public static function scan($param)
 {
     list($data) = $param;
     self::_init();
     global $_G;
     if (!$_G['wechat']['setting']['wsq_allow']) {
         return;
     }
     $authcode = C::t('#wechat#mobile_wechat_authcode')->fetch_by_code($data['key']);
     if (!$authcode || $authcode['status']) {
         //			echo WeChatServer::getXml4Txt(lang('plugin/wechat', 'wechat_response_text_codeerror'));
     } else {
         if ($authcode['uid']) {
             $member = getuserbyuid($authcode['uid'], 1);
             if ($member['adminid'] == 0 && !$_G['wechat']['setting']['wechat_confirmtype']) {
                 C::t('#wechat#mobile_wechat_authcode')->update($authcode['sid'], array('uid' => $member['uid'], 'status' => 1));
                 $authcode['sid'] = '';
             }
         } else {
             $wechatuser = C::t('#wechat#common_member_wechat')->fetch_by_openid($data['from']);
             if ($wechatuser) {
                 $member = getuserbyuid($wechatuser['uid'], 1);
                 if ($member['adminid'] == 0 && !$_G['wechat']['setting']['wechat_confirmtype']) {
                     C::t('#wechat#mobile_wechat_authcode')->update($authcode['sid'], array('uid' => $member['uid'], 'status' => 1));
                     $authcode['sid'] = '';
                 }
             } elseif ($_G['wechat']['setting']['wechat_allowregister'] && $_G['wechat']['setting']['wechat_allowfastregister'] && $_G['wechat']['setting']['wechat_mtype'] == 2) {
                 require_once DISCUZ_ROOT . './source/plugin/wechat/wechat.class.php';
                 require_once libfile('function/member');
                 $uid = WeChat::register(WeChat::getnewname($data['from']), 1);
                 if ($uid) {
                     WeChatHook::bindOpenId($uid, $data['from'], 1);
                     C::t('#wechat#mobile_wechat_authcode')->update($authcode['sid'], array('uid' => $uid, 'status' => 1));
                 }
                 wsq::report('register');
                 $authcode['sid'] = '';
             }
         }
         wsq::report('scanqr');
         self::_show('scan', $data['from'] . "\t" . $authcode['sid']);
     }
 }
Exemplo n.º 2
0
 private static function _setting()
 {
     global $_G;
     if (!self::$SETTING) {
         self::$SETTING = unserialize($_G['setting']['mobilewechat']);
     }
 }
Exemplo n.º 3
0
 function common()
 {
     global $_G;
     if (!in_array('wechat', $_G['setting']['plugins']['available'])) {
         mobile_core::result(mobile_core::variable(array()));
     }
     require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
     mobile_core::result(mobile_core::variable(wsq::siteinfo()));
 }
Exemplo n.º 4
0
 function output()
 {
     global $_G;
     include_once 'source/plugin/mobile/api/4/sub_threadlist.php';
     loadcache('mobile_stats');
     if (!$_G['cache']['mobile_stats'] || TIMESTAMP - $_G['cache']['mobile_stats']['expiration'] > 3600) {
         $forums = C::t('forum_forum')->fetch_all_by_status(1);
         foreach ($forums as $forum) {
             $posts += $forum['posts'];
         }
         loadcache('userstats');
         $_G['cache']['mobile_stats']['variable'] = array('totalposts' => $posts, 'totalmembers' => $_G['cache']['userstats']['totalmembers']);
         savecache('mobile_stats', array('variable' => $_G['cache']['mobile_stats']['variable'], 'expiration' => TIMESTAMP));
     }
     $variable['stats'] = $_G['cache']['mobile_stats']['variable'];
     require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
     $variable['wsqsiteinfo'] = wsq::siteinfo();
     mobile_core::result(mobile_core::variable($variable));
 }
Exemplo n.º 5
0
 function output()
 {
     global $_G;
     parse_str($_G['messageparam'][1], $p);
     $variable = array('auth' => $p['auth']);
     if ($_G['uid']) {
         require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
         if (method_exists('wsq', 'userloginUrl')) {
             $_source = isset($_GET['_source']) ? $_GET['_source'] : '';
             if (!$_source && !empty($_GET['openid']) && !empty($_GET['openidsign'])) {
                 $variable['loginUrl'] = wsq::userloginUrl($_G['uid'], $_GET['openid'], $_GET['openidsign']);
                 if (!C::t('#wechat#common_member_wechatmp')->fetch($_G['uid'])) {
                     C::t('#wechat#common_member_wechatmp')->insert(array('uid' => $_G['uid'], 'openid' => $_GET['openid'], 'status' => 1), false, true);
                 }
             } else {
                 $variable['loginUrl'] = wsq::userloginUrl2($_G['uid']);
             }
         }
     }
     mobile_core::result(mobile_core::variable($variable));
 }
     $_GET['setting']['wsq_sitelogo'] = ($parsev['host'] ? '' : $_G['siteurl']) . $_G['setting']['attachurl'] . 'common/' . $upload->attach['attachment'];
 } else {
     $_GET['setting']['wsq_sitelogo'] = $setting['wsq_sitelogo'];
 }
 if (!$_GET['setting']['wsq_fid']) {
     cpmsg(lang('plugin/wechat', 'wsq_fid_empty'), '', 'error');
 }
 if (!$setting['wsq_sitetoken']) {
     $siteinfo = wsq::register($_GET['setting']['wsq_sitename'], $_GET['setting']['wsq_siteurl'], $_GET['setting']['wsq_sitelogo'], $_GET['setting']['wsq_sitesummary'], $setting['wechat_mtype'], $setting['wechat_qrtype']);
     if (!$siteinfo || $siteinfo->code) {
         cpmsg(lang('plugin/wechat', 'wsq_api_register_error'), '', 'error');
     }
     $_GET['setting']['wsq_siteid'] = $siteinfo->res->siteid;
     $_GET['setting']['wsq_sitetoken'] = $siteinfo->res->token;
 } else {
     $siteinfo = wsq::edit($_GET['setting']['wsq_sitename'], $_GET['setting']['wsq_siteurl'], $_GET['setting']['wsq_sitelogo'], $_GET['setting']['wsq_sitesummary'], $setting['wechat_mtype'], $setting['wechat_qrtype']);
     if (!$siteinfo || $siteinfo->code) {
         cpmsg(lang('plugin/wechat', 'wsq_api_edit_error'), '', 'error');
     }
 }
 if (function_exists('domain_create')) {
     if (preg_match('/^((http|https|ftp):\\/\\/|\\.)|(\\/|\\.)$/i', $_GET['setting']['wsq_domain'])) {
         cpmsg('setting_domain_http_error', '', 'error');
     }
 }
 $_GET['setting']['wsq_status'] = $siteinfo->res->status;
 $_GET['setting']['wsq_lastrequest'] = $siteinfo->res->lasttime;
 $settings = array('mobilewechat' => serialize($_GET['setting'] + $setting));
 C::t('common_setting')->update_batch($settings);
 updatecache('setting');
 if ($_GET['setting']['wsq_allow']) {
Exemplo n.º 7
0
        showmessage('profile_passwd_notmatch');
    }
    if (!$_GET['newpassword1'] || $_GET['newpassword1'] != addslashes($_GET['newpassword1'])) {
        showmessage('profile_passwd_illegal');
    }
    loaducenter();
    uc_user_edit(addslashes($_G['member']['username']), null, $_GET['newpassword1'], null, 1);
    C::t('common_member')->update($_G['uid'], array('password' => md5(random(10))));
    if ($_G['wechat']['setting']['wechat_qrtype']) {
        C::t('#wechat#common_member_wechatmp')->update($_G['uid'], array('status' => 1));
    } else {
        C::t('#wechat#common_member_wechat')->update($_G['uid'], array('isregister' => 0));
    }
    showmessage('wechat:wsq_password_reset', dreferer());
} elseif (submitcheck('unbindsubmit')) {
    require_once libfile('function/member');
    if ($_G['wechat']['setting']['wechat_qrtype']) {
        require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
        $member = C::t('#wechat#common_member_wechatmp')->fetch($_G['uid']);
        if (!$member || !wsq::userunbind($_G['uid'], $member['openid'])) {
            showmessage('wechat:wechat_message_unbind_fail');
        }
        C::t('#wechat#common_member_wechatmp')->delete($_G['uid']);
    } else {
        C::t('#wechat#common_member_wechat')->delete($_G['uid']);
        require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
        wsq::report('unbind');
    }
    clearcookies();
    showmessage('wechat:wechat_message_unbinded', $_G['siteurl']);
}
Exemplo n.º 8
0
     }
 } else {
     C::t('#qqconnect#common_member_connect')->delete($connect_member['uid']);
     unset($connect_member);
 }
 $connect_is_unbind = $params['is_unbind'] == 1 ? 1 : 0;
 require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
 if (method_exists('wsq', 'userloginUrl')) {
     $_source = isset($refererarray['_source']) ? $refererarray['_source'] : '';
     if (!$_source && !empty($refererarray['openid']) && !empty($refererarray['openidsign'])) {
         $loginUrl = wsq::userloginUrl($connect_member['uid'], $refererarray['openid'], $refererarray['openidsign']);
         if (!C::t('#wechat#common_member_wechatmp')->fetch($connect_member['uid'])) {
             C::t('#wechat#common_member_wechatmp')->insert(array('uid' => $connect_member['uid'], 'openid' => $refererarray['openid'], 'status' => 1), false, true);
         }
     } else {
         $loginUrl = wsq::userloginUrl2($_G['uid']);
     }
     $referer .= '&loginUrl=' . urlencode($loginUrl);
 }
 C::t('#qqconnect#common_member_connect')->update($connect_member['uid'], !$_G['setting']['connect']['oauth2'] ? array('conuin' => $conuin, 'conuinsecret' => $conuinsecret, 'conopenid' => $conopenid, 'conisfeed' => 1) : array('conuintoken' => $conuintoken, 'conopenid' => $conopenid, 'conisfeed' => 1));
 $params['mod'] = 'login';
 connect_login($connect_member);
 loadcache('usergroups');
 $usergroups = $_G['cache']['usergroups'][$_G['groupid']]['grouptitle'];
 $param = array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle']);
 C::t('common_member_status')->update($connect_member['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP));
 $ucsynlogin = '';
 if ($_G['setting']['allowsynlogin']) {
     loaducenter();
     $ucsynlogin = uc_user_synlogin($_G['uid']);
 }
Exemplo n.º 9
0
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: checkinfo.php 34424 2014-04-24 05:17:08Z nemohou $
 */
if (!defined('IN_MOBILE_API')) {
    exit('Access Denied');
}
require './source/class/class_core.php';
$discuz = C::app();
$cachelist = array();
$discuz->cachelist = $cachelist;
$discuz->init();
$_G['wechat']['setting'] = unserialize($_G['setting']['mobilewechat']);
require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
$result = wsq::check($_GET);
if ($result) {
    $setting = C::t('common_setting')->fetch_all(array('mobilewechat'));
    $setting = unserialize($setting['mobilewechat']);
    $setting['wsq_status'] = 1;
    $settings = array('mobilewechat' => serialize($setting));
    C::t('common_setting')->update_batch($settings);
}
echo $result;
exit;
Exemplo n.º 10
0
        showmessage('wechat:wechat_member_register_faild');
    }
    $groupid = $_G['wechat']['setting']['wechat_newusergroupid'] ? $_G['wechat']['setting']['wechat_newusergroupid'] : $_G['setting']['newusergroupid'];
    C::t('common_member')->update($_G['uid'], array('groupid' => $groupid));
    dheader('location: ' . ($_G['referer'] ? $_GET['referer'] : $_G['siteurl']));
} elseif ($ac == 'wxlogin') {
    unset($_GET['mapifrom'], $_GET['charset']);
    if (wsq::checksign($_GET)) {
        $member = getuserbyuid($_GET['siteuid'], 1);
        if ($member) {
            require_once libfile('function/member');
            setloginstatus($member, 1296000);
        }
    }
} elseif ($ac == 'wxregverify') {
    if (!wsq::checksign($_GET)) {
        showmessage('wechat:wechat_member_auth_fail');
    }
    $member = getuserbyuid($_GET['siteuid'], 1);
    if ($member) {
        require_once libfile('function/member');
        setloginstatus($member, 1296000);
    }
    if ($_G['cookie']['wxnewuser']) {
        $groupid = $_G['wechat']['setting']['wechat_newusergroupid'] ? $_G['wechat']['setting']['wechat_newusergroupid'] : $_G['setting']['newusergroupid'];
        C::t('common_member')->update($_G['uid'], array('groupid' => $groupid));
        dsetcookie('wxnewuser', '', -1);
    }
    dheader('location: ' . ($_GET['referer'] ? $_GET['referer'] : $_G['siteurl']));
} else {
    showmessage('undefined_action');
Exemplo n.º 11
0
        $activity['class'] = $_GET['activityclass'];
        $activity['starttimefrom'] = @strtotime($_GET['starttimefrom']);
        $activity['starttimeto'] = $_GET['starttimeto'] ? @strtotime($_GET['starttimeto']) : 0;
        $activity['place'] = $_GET['activityplace'];
        $activity['expiration'] = @strtotime($_GET['activityexpiration']);
        $newthread = array('fid' => $_GET['fid'], 'posttableid' => 0, 'readperm' => 0, 'price' => 0, 'typeid' => 0, 'sortid' => 0, 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $_GET['subject'], 'dateline' => TIMESTAMP, 'lastpost' => TIMESTAMP, 'lastposter' => $_G['username'], 'displayorder' => 1, 'digest' => 0, 'special' => 4, 'attachment' => 0, 'moderated' => 0, 'status' => 0, 'isgroup' => 0, 'replycredit' => 0, 'closed' => 0);
        $tid = C::t('forum_thread')->insert($newthread, true);
        $pid = insertpost(array('fid' => $_GET['fid'], 'tid' => $tid, 'first' => '1', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $_GET['subject'], 'dateline' => TIMESTAMP, 'message' => $_GET['message'], 'useip' => '', 'invisible' => 0, 'anonymous' => 0, 'usesig' => 0, 'htmlon' => 0, 'bbcodeoff' => 0, 'smileyoff' => 0, 'parseurloff' => 0, 'attachment' => '0', 'tags' => '', 'replycredit' => 0, 'status' => 0));
        $data = array('tid' => $tid, 'uid' => $_G['uid'], 'cost' => 0, 'starttimefrom' => $activity['starttimefrom'], 'starttimeto' => $activity['starttimeto'], 'place' => $activity['place'], 'class' => $activity['class'], 'expiration' => $activity['expiration']);
        C::t('forum_activity')->insert($data);
        $setting['showactivity']['tids'][$tid] = $tid;
        $settings = array('mobilewechat' => serialize($setting));
        C::t('common_setting')->update_batch($settings);
        updatecache(array('plugin', 'setting'));
        require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
        wsq::report('pubshowactivity');
        cpmsg(lang('plugin/wechat', 'show_addthread_succeed'), 'action=plugins&operation=config&do=' . $pluginid . '&identifier=wechat&pmod=showactivity_setting', 'succeed');
    }
} elseif ($ac == 'export') {
    if (!isset($setting['showactivity']['tids'][$_GET['tid']])) {
        cpmsg(lang('plugin/wechat', 'show_thread_not_found'));
    }
    $thread = get_thread_by_tid($_GET['tid']);
    if (!$thread) {
        cpmsg(lang('plugin/wechat', 'show_thread_not_found'));
    }
    $posttableid = $thread['posttableid'];
    $posts = DB::fetch_all("SELECT * FROM %t WHERE tid=%d", array('forum_debatepost', $_GET['tid']), 'pid');
    foreach (C::t('forum_post')->fetch_all($posttableid, array_keys($posts), false) as $post) {
        $array[$posts[$post['pid']]['voters'] . '.' . $post['position']] = $post['author'] . ',' . $posts[$post['pid']]['voters'] . ',' . $post['position'];
    }
Exemplo n.º 12
0
 function common()
 {
     global $_G;
     if (!defined('IN_MOBILE_API')) {
         return;
     }
     if (!$_G['setting']['mobile']['allowmobile']) {
         mobile_core::result(array('error' => 'mobile_is_closed'));
     }
     if (!empty($_GET['tpp'])) {
         $_G['tpp'] = intval($_GET['tpp']);
     }
     if (!empty($_GET['ppp'])) {
         $_G['ppp'] = intval($_GET['ppp']);
     }
     $_G['pluginrunlist'] = array('mobile', 'qqconnect', 'wechat');
     $_G['siteurl'] = preg_replace('/api\\/mobile\\/$/', '', $_G['siteurl']);
     $_G['setting']['msgforward'] = '';
     $_G['setting']['cacheindexlife'] = $_G['setting']['cachethreadlife'] = false;
     if (!$_G['setting']['mobile']['nomobileurl'] && function_exists('diconv') && !empty($_GET['charset'])) {
         $_GET = mobile_core::diconv_array($_GET, $_GET['charset'], $_G['charset']);
     }
     if ($_GET['_auth']) {
         require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
         $uid = wsq::decodeauth($_GET['_auth']);
         $disablesec = false;
         if ($uid) {
             require_once libfile('function/member');
             $member = getuserbyuid($uid, 1);
             if ($_GET['module'] != 'login') {
                 setloginstatus($member, 1296000);
                 $disablesec = true;
             } else {
                 $disablesec = logincheck($member['username']);
             }
         } elseif ($_GET['module'] == 'login') {
             $disablesec = logincheck($_GET['username']);
         }
         if ($disablesec) {
             $_G['setting']['seccodedata'] = array();
             $_G['setting']['seccodestatus'] = 0;
             $_G['setting']['secqaa'] = array();
             unset($_GET['force']);
             define('IN_MOBILE_AUTH', $uid);
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $_GET['formhash'] = $_G['formhash'];
             }
         }
     }
     if (class_exists('mobile_api', false) && method_exists('mobile_api', 'common')) {
         mobile_api::common();
     }
 }
Exemplo n.º 13
0
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: wsq_stat.inc.php 35168 2014-12-25 02:29:36Z nemohou $
 */
if (!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
    exit('Access Denied');
}
require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
require_once DISCUZ_ROOT . './source/plugin/wechat/setting.class.php';
WeChatSetting::menu();
showtips(lang('plugin/wechat', 'discuzqr_tips'));
$data = wsq::stat();
$d = date('Ymd', TIMESTAMP);
if (!$data || $data->code != 0) {
    cpmsg_error('wechat:stat_failed');
}
$xa = $uv = $pv = $newthread = $reply = $share = $reflow = array();
foreach ($data->res as $d) {
    $xa[$d->ftime] = substr($d->ftime, 4, 2) . '<br/>' . substr($d->ftime, 6, 2);
    $uv[$d->ftime] = intval($uv[$d->ftime]) + intval($d->uv);
    $pv[$d->ftime] = intval($pv[$d->ftime]) + intval($d->pv);
    $newthread[$d->ftime] = intval($newthread[$d->ftime]) + intval($d->newthread_num);
    $reply[$d->ftime] = intval($reply[$d->ftime]) + intval($d->reply_num);
    $share[$d->ftime] = intval($share[$d->ftime]) + intval($d->share_num);
    $reflow[$d->ftime] = intval($reflow[$d->ftime]) + intval($d->reflow_num);
}
$xas = "'" . implode('\',\'', $xa) . "'";
Exemplo n.º 14
0
 }
 if (!$_GET['setting']['wsq_fid']) {
     cpmsg(lang('plugin/wechat', 'wsq_fid_empty'), '', 'error');
 }
 if (!$setting['wsq_sitetoken']) {
     $siteinfo = wsq::register($_GET['setting']['wsq_sitename'], $_GET['setting']['wsq_siteurl'], $_GET['setting']['wsq_sitelogo'], $_GET['setting']['wsq_sitesummary'], $setting['wechat_mtype'], $setting['wechat_qrtype'], $_GET['setting']['wsq_siteip'], $setting['wechat_followurl'], $setting['wechat_appId'], $setting['wechat_appsecret'], $_GET['setting']['wsq_global_banner'], $_GET['setting'] + $setting);
     if (!$siteinfo || $siteinfo->code) {
         if ($siteinfo->code == 14) {
             cpmsg(lang('plugin/wechat', 'wsq_api_servertime_error', '', 'error'));
         }
         cpmsg(lang('plugin/wechat', 'wsq_api_register_error'), '', 'error');
     }
     $_GET['setting']['wsq_siteid'] = $siteinfo->res->siteid;
     $_GET['setting']['wsq_sitetoken'] = $siteinfo->res->token;
 } else {
     $siteinfo = wsq::edit($_GET['setting']['wsq_sitename'], $_GET['setting']['wsq_siteurl'], $_GET['setting']['wsq_sitelogo'], $_GET['setting']['wsq_sitesummary'], $setting['wechat_mtype'], $setting['wechat_qrtype'], $_GET['setting']['wsq_siteip'], $setting['wechat_followurl'], $setting['wechat_appId'], $setting['wechat_appsecret'], $_GET['setting']['wsq_global_banner'], $_GET['setting'] + $setting);
     if (!$siteinfo || $siteinfo->code) {
         if ($siteinfo->code == 14) {
             cpmsg(lang('plugin/wechat', 'wsq_api_servertime_error', '', 'error'));
         }
         cpmsg(lang('plugin/wechat', 'wsq_api_edit_error'), '', 'error');
     }
 }
 if (function_exists('domain_create')) {
     if (preg_match('/^((http|https|ftp):\\/\\/|\\.)|(\\/|\\.)$/i', $_GET['setting']['wsq_domain'])) {
         cpmsg('setting_domain_http_error', '', 'error');
     }
 }
 $_GET['setting']['wsq_status'] = $siteinfo->res->status;
 $_GET['setting']['wsq_lastrequest'] = $siteinfo->res->lasttime;
 $settings = array('mobilewechat' => serialize($_GET['setting'] + $setting));
Exemplo n.º 15
0
            setloginstatus($member, 1296000);
            dsetcookie('wechat_ticket', '', -1);
            $echostr = 'done';
        } else {
            $echostr = '1';
            //json_encode($authcode);
        }
    } else {
        $echostr = '-1';
    }
    if (!ob_start($_G['gzipcompress'] ? 'ob_gzhandler' : null)) {
        ob_start();
    }
    if ($echostr === 'done') {
        C::t('#wechat#mobile_wechat_authcode')->delete($authcode['sid']);
    }
    include template('common/header_ajax');
    echo $echostr;
    include template('common/footer_ajax');
    exit;
}
if ($_G['cookie']['qrauth']) {
    $qrauth = authcode(base64_decode($_G['cookie']['qrauth']), 'DECODE', $_G['config']['security']['authkey']);
}
if (!$_G['wechat']['setting']['wechat_qrtype']) {
    require_once DISCUZ_ROOT . './source/plugin/wechat/wechat.lib.class.php';
    require_once DISCUZ_ROOT . './source/plugin/wechat/wsq.class.php';
    list($isqrapi, $qrcodeurl, $codeenc, $code) = WeChat::getqrcode();
    wsq::report('siteqrshow');
}
include_once template('wechat:wechat_qrcode');