Пример #1
0
 private static function _show($messagekey, $key, $expire = 0)
 {
     global $_G;
     if (!$_G['wechat']['setting']['wsq_allow']) {
         return;
     }
     $expire = $expire ? $expire : self::$expire;
     $key = authcode($key, 'ENCODE', $_G['config']['security']['authkey'], $expire);
     $url = $_G['siteurl'] . 'plugin.php?mobile=2&id=wechat&op=' . $messagekey . '&key=' . urlencode(base64_encode($key));
     $param = array('bbname' => $_G['wechat']['setting']['wsq_sitename'], 'date' => dgmdate(TIMESTAMP + $expire, 'Y-m-d'));
     loadcache('wechat_response');
     $desc = !empty($_G['cache']['wechat_response'][$messagekey]) ? $_G['cache']['wechat_response'][$messagekey] : 'wechat_response_text_' . $messagekey;
     $list = array(array('title' => lang('plugin/wechat', 'wechat_response_text_title', $param), 'desc' => lang('plugin/wechat', $desc, $param), 'url' => $url));
     echo WeChatServer::getXml4RichMsgByArray($list);
     exit;
 }
Пример #2
0
 private static function _custom($type, $keyword = '')
 {
     global $_G;
     loadcache('wechat_response');
     $response =& $_G['cache']['wechat_response'];
     $query = $type == 'text' ? $response['query']['text'][$keyword] : $response['query']['subscribe'];
     if ($query) {
         if ($query == self::$keyword) {
             return 1;
         }
         if (preg_match("/^\\[resource=(\\d+)\\]/", $query, $r)) {
             $resource = C::t('#wechat#mobile_wechat_resource')->fetch($r[1]);
             if (!$resource['type']) {
                 $list = array(array('title' => $resource['data']['title'], 'desc' => $resource['data']['desc'], 'pic' => $resource['data']['pic'], 'url' => $resource['data']['url']));
             } else {
                 $mergeids = array_keys($resource['data']['mergeids']);
                 $sresource = C::t('#wechat#mobile_wechat_resource')->fetch_all($mergeids);
                 $list = array();
                 foreach ($resource['data']['mergeids'] as $id => $order) {
                     $list[] = array('title' => $sresource[$id]['data']['title'], 'desc' => $sresource[$id]['data']['desc'], 'pic' => $sresource[$id]['data']['pic'], 'url' => $sresource[$id]['data']['url']);
                 }
             }
             echo WeChatServer::getXml4RichMsgByArray($list);
             exit;
         } else {
             echo WeChatServer::getXml4Txt($query);
         }
         exit;
     }
     return 0;
 }