diff --git a/README.md b/README.md
index d5e1af0..669ca33 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,21 @@
-# Discuz-Api
-DiscuzAPI,适用于Discuz app 小程序
+## 使用方法
+
+- 修改配置文件,config_minapp.php, 将申请好的小程序 appkey appsecret 修改好
+- 增加新表,SQL如下
+- 把mobile目录覆盖discuz source/plugin/mobile目录
+- 修改小程序配置文件,将域名换成您网站域名
+- 上传小程序测试
+- 该接口也适用于App调用
+
+## 增加小程序登录绑定表
+```
+CREATE TABLE `pre_weixin_minapp_user` (
+ `uid` int(11) unsigned NOT NULL,
+ `openid` char(35) NOT NULL DEFAULT '',
+ `status` tinyint(1) NOT NULL DEFAULT '0',
+ `session_key` char(255) NOT NULL DEFAULT '',
+ `unionid` char(255) NOT NULL DEFAULT '',
+ PRIMARY KEY (`openid`),
+ KEY `uid` (`uid`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+```
\ No newline at end of file
diff --git a/mobile/api/5/activityapplies.php b/mobile/api/5/activityapplies.php
new file mode 100644
index 0000000..f1cfb7a
--- /dev/null
+++ b/mobile/api/5/activityapplies.php
@@ -0,0 +1,30 @@
+
diff --git a/mobile/api/5/check.php b/mobile/api/5/check.php
new file mode 100644
index 0000000..6b18c11
--- /dev/null
+++ b/mobile/api/5/check.php
@@ -0,0 +1,67 @@
+init();
+
+if(!defined('DISCUZ_VERSION')) {
+ require './source/discuz_version.php';
+}
+
+if(in_array('mobile', $_G['setting']['plugins']['available'])) {
+ loadcache('api_checkinfo');
+ if (!$_G['cache']['api_checkinfo'] || TIMESTAMP - $_G['cache']['api_checkinfo']['expiration'] > 600) {
+ $_G['wechat']['setting'] = unserialize($_G['setting']['mobilewechat']);
+ $forums = C::t('forum_forum')->fetch_all_for_grouplist('', array(), 0);
+ $countforums = $posts = $threads = 0;
+ foreach ($forums as $forum) {
+ $posts += $forum['posts'];
+ $threads += $forum['threads'];
+ $countforums++;
+ }
+ loadcache('userstats');
+ $array = array(
+ 'discuzversion' => DISCUZ_VERSION,
+ 'charset' => CHARSET,
+ 'version' => MOBILE_PLUGIN_VERSION,
+ 'pluginversion' => $_G['setting']['plugins']['version']['mobile'],
+ 'regname' => $_G['setting']['regname'],
+ 'sitename' => $_G['setting']['bbname'],
+ 'ucenterurl' => $_G['setting']['ucenterurl'],
+ 'totalthreads' => $threads,
+ 'totalposts' => $posts,
+ 'totalforums' => $countforums,
+ 'totalmembers' => $_G['cache']['userstats']['totalmembers'],
+ );
+ savecache('api_checkinfo', array('variable' => $array, 'expiration' => TIMESTAMP));
+ } else {
+ $array = $_G['cache']['api_checkinfo']['variable'];
+ }
+} else {
+ $array = array();
+}
+
+$array['formhash'] = formhash();
+$array['setting'] = array(
+ 'repliesrank' => $_G['setting']['repliesrank'],
+ 'allowpostcomment' => $_G['setting']['allowpostcomment'],
+);
+
+$data = mobile_core::json($array);
+mobile_core::make_cors($_SERVER['REQUEST_METHOD'], REQUEST_METHOD_DOMAIN);
+
+echo $data;
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/code2session.php b/mobile/api/5/code2session.php
new file mode 100644
index 0000000..4e80a24
--- /dev/null
+++ b/mobile/api/5/code2session.php
@@ -0,0 +1,151 @@
+init();
+
+$_G['config'] = array_merge($_G['config'], require './source/plugin/mobile/config_minapp.php');
+
+$appid = $_G['config']['minapp']['appid'];
+$secret = $_G['config']['minapp']['secret'];
+$code = isset($_GET['code']) ? trim($_GET['code']) : '';
+
+if(!$code || !$appid || !$secret) {
+ $result['code'] = -1;
+ $result['message'] = 'param_error';
+ outjson($result);
+}
+
+$wxApiurl = sprintf('https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code', $appid, $secret, $code);
+
+$response = dfsockopen($wxApiurl);
+$wxinfo = json_decode($response);
+if(isset($wxinfo->errcode)) {
+ $result['code'] = -2;
+ $result['message'] = 'weixin_api_error';
+ outjson($result);
+}
+
+
+$userinfo = C::t('#mobile#weixin_minapp_user')->fetch_by_openid($wxinfo->openid);
+if(!empty($userinfo)) {
+ C::t('#mobile#weixin_minapp_user')->update($openid, array('session_key' => $wxinfo->session_key));
+ $member = getuserbyuid($userinfo['uid']);
+ setloginstatus($member, 1296000);
+} else {
+ // $username = 'minapp_'.strtolower(random(8));
+ // $uid = register($username);
+
+ $result['code'] = -3;
+ $result['openid'] = $wxinfo->openid;
+ $result['message'] = 'no_user';
+ outjson($result);
+
+
+ // C::t('#mobile#weixin_minapp_user')->insert(array('uid' => $uid, 'openid' => $wxinfo->openid, 'session_key' => $wxinfo->session_key, 'unionid' => $wxinfo->unionid));
+
+ // if(C::memory()->enable && strtolower(C::memory()->type) === 'redis') {
+
+ // $redis = new memory_driver_redis();
+ // $redis = $redis->instance();
+
+ // $data = json_encode(array(
+ // 'type' => 'newuser',
+ // 'username' => $username,
+ // 'uid' => $uid
+ // ));
+ // $redis->obj->publish('sitefeed', $data);
+ // }
+
+}
+
+$result['code'] = 0;
+$result['data'] = array(
+ 'auth' => $_G['cookie']['auth'],
+ 'saltkey' => $_G['cookie']['saltkey'],
+ 'formhash' => FORMHASH,
+ 'uid' => $_G['member']['uid']
+);
+$result['message'] = 'login_success';
+outjson($result);
+
+
+function outjson($result) {
+ echo json_encode($result);
+ exit;
+}
+
+function register($username, $groupid = 0) {
+ global $_G;
+ if(!$username) {
+ return false;
+ }
+
+ loaducenter();
+ $groupid = !$groupid ? $_G['setting']['newusergroupid'] : $groupid;
+
+ $password = md5(random(10));
+ $email = 'minapp_'.strtolower(random(10)).'@null.null';
+ $uid = uc_user_register(addslashes($username), $password, $email, '', '', $_G['clientip']);
+ if($uid <= 0) {
+ if($uid == -3) {
+ $username = 'minapp_'.strtolower(random(5));
+ register($username);
+ }
+ return false;
+ }
+
+ $init_arr = array('credits' => explode(',', $_G['setting']['initcredits']));
+ C::t('common_member')->insert($uid, $username, $password, $email, $_G['clientip'], $groupid, $init_arr);
+
+ if($_G['setting']['regctrl'] || $_G['setting']['regfloodctrl']) {
+ C::t('common_regip')->delete_by_dateline($_G['timestamp']-($_G['setting']['regctrl'] > 72 ? $_G['setting']['regctrl'] : 72)*3600);
+ if($_G['setting']['regctrl']) {
+ C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp']));
+ }
+ }
+
+ if($_G['setting']['regverify'] == 2) {
+ C::t('common_member_validate')->insert(array(
+ 'uid' => $uid,
+ 'submitdate' => $_G['timestamp'],
+ 'moddate' => 0,
+ 'admin' => '',
+ 'submittimes' => 1,
+ 'status' => 0,
+ 'message' => '',
+ 'remark' => '',
+ ), false, true);
+ manage_addnotify('verifyuser');
+ }
+
+ setloginstatus(array(
+ 'uid' => $uid,
+ 'username' => $username,
+ 'password' => $password,
+ 'groupid' => $groupid,
+ ), 1296000);
+
+ include_once libfile('function/stat');
+ updatestat('register');
+
+
+ require_once libfile('cache/userstats', 'function');
+ build_cache_userstats();
+ return $uid;
+}
+?>
\ No newline at end of file
diff --git a/mobile/api/5/favorite.php b/mobile/api/5/favorite.php
new file mode 100644
index 0000000..1fd6b20
--- /dev/null
+++ b/mobile/api/5/favorite.php
@@ -0,0 +1,43 @@
+fetch_by_id_idtype(intval($_GET['id']), $_GET['type'], $_G['uid']);
+ unset($_GET['id'], $_GET['type']);
+ $_GET['favid'] = $fav['favid'];
+ }
+ }
+
+ function output() {
+ $variable = array();
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/forum.php b/mobile/api/5/forum.php
new file mode 100644
index 0000000..c0ee040
--- /dev/null
+++ b/mobile/api/5/forum.php
@@ -0,0 +1,59 @@
+ $value) {
+ $value['avatar'] = avatar($value['uid'], 'middle', true);
+ $uids[] = $value['uid'];
+ $GLOBALS['checkusers'][$key] = $value;
+ }
+
+ $usernicknames = array();
+ foreach(C::t('common_member_profile')->fetch_all($uids) as $user) {
+ $usernicknames[$user['uid']] = $user['realname'];
+ }
+ $variable['checkusers'] = $GLOBALS['checkusers'];
+ $variable['usernicknames'] = $usernicknames;
+ }
+
+
+ $_G['forum']['icon'] = $_G['siteurl'].$_G['forum']['icon'];
+
+ $variable['forum'] = mobile_core::getvalues($_G['forum'], array('fid', 'fup', 'name', 'description', 'icon', 'jointype', 'gviewperm'));
+
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/forumdisplay.php b/mobile/api/5/forumdisplay.php
new file mode 100644
index 0000000..5850107
--- /dev/null
+++ b/mobile/api/5/forumdisplay.php
@@ -0,0 +1,38 @@
+ array('fid' => $_G['fid'], 'redirect' => $_G['forum']['redirect']))));
+ }
+ }
+
+ function output() {
+ global $_G;
+ include_once 'source/plugin/mobile/api/5/sub_threadlist.php';
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/forumguide.php b/mobile/api/5/forumguide.php
new file mode 100644
index 0000000..90ff30c
--- /dev/null
+++ b/mobile/api/5/forumguide.php
@@ -0,0 +1,71 @@
+$thread) {
+
+
+ //获取message和附件
+ $post = array_pop(C::t('forum_post')->fetch_all_by_tid('tid:'.$thread['tid'], $thread['tid'], true, '', 0, 0, 1));
+ $attachlist = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$thread['tid'], 'pid', $post['pid']);
+
+ foreach($attachlist as $aid => $attach) {
+
+ if($attach['remote']) {
+ $attach['attachment'] = $_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment'];
+ } else {
+ $attach['attachment'] = strpos($_G['setting']['attachurl'], 'http') !== false ? $_G['setting']['attachurl'].'forum/'.$attach['attachment'] : $_G['siteurl'].$_G['setting']['attachurl'].'forum/'.$attach['attachment'];
+ }
+
+ $attach['thumb'] = mobile_core::thumb($attach['aid'], '0', '268', '380');
+ $type = '';
+ $fileext = addslashes(strtolower(substr(strrchr($attach['filename'], '.'), 1, 10)));
+ if(in_array($fileext, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
+ $type = 'image';
+ } elseif($fileext === 'mp3') {
+ $type = 'audio';
+ } elseif($fileext === 'mp4') {
+ $type = 'video';
+ }
+ $attach['type'] = $type;
+ $attachlist[$aid] = $attach;
+ }
+
+ $GLOBALS['data'][$_GET['view']]['threadlist'][$tid]['attachlist'] = array_values($attachlist);
+
+ $GLOBALS['data'][$_GET['view']]['threadlist'][$tid]['avatar'] = avatar($thread['authorid'], 'middle', true);
+ }
+
+ $GLOBALS['data'][$_GET['view']]['threadlist'] = $GLOBALS['data'][$_GET['view']]['threadlist'] ? $GLOBALS['data'][$_GET['view']]['threadlist'] : array();
+
+ $variable = array(
+ 'data' => array_values($GLOBALS['data'][$_GET['view']]['threadlist']),
+ 'perpage' => $GLOBALS['perpage'],
+ );
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/forumimage.php b/mobile/api/5/forumimage.php
new file mode 100644
index 0000000..af6eeae
--- /dev/null
+++ b/mobile/api/5/forumimage.php
@@ -0,0 +1,79 @@
+fetch('aid:'.$daid, $daid, array(1, -1))) {
+ if(!$dw && !$dh && $attach['tid'] != $id) {
+ header('location: '.$_G['siteurl'].'static/image/common/none.gif');
+ }
+ header("HTTP/1.1 301 Moved Permanently");
+ header("Last-Modified:".date('r'));
+ header('Expires: '.gmdate('D, d M Y H:i:s', TIMESTAMP + 3600).' GMT');
+ if($attach['remote']) {
+ $filename = $_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment'];
+ } else {
+ $filename = $_G['setting']['attachdir'].'forum/'.$attach['attachment'];
+ }
+ require_once libfile('class/image');
+ $img = new image;
+ if($img->Thumb($filename, $thumbfile, $w, $h, $type)) {
+ if($nocache) {
+ header('Content-Type: image');
+ @readfile($_G['setting']['attachdir'].$thumbfile);
+ @unlink($_G['setting']['attachdir'].$thumbfile);
+ } else {
+ header('Location: '.$attachurl.$thumbfile);
+ }
+ } else {
+ header('Content-Type: image');
+ @readfile($filename);
+ }
+ }
+ exit;
+ }
+}
+?>
\ No newline at end of file
diff --git a/mobile/api/5/forummisc.php b/mobile/api/5/forummisc.php
new file mode 100644
index 0000000..bca289d
--- /dev/null
+++ b/mobile/api/5/forummisc.php
@@ -0,0 +1,69 @@
+ $user) {
+ $user['avatar'] = avatar($user['uid'], 'small', true);
+ $data['voterlist'][$uid] = $user;
+ }
+ $data['voterlist'] = array_values($data['voterlist']);
+ unset($data['polloptions']);
+ }
+ } elseif($action == 'activityapplylist') {
+ if(!empty($GLOBALS['query'])) {
+ foreach($GLOBALS['query'] as $key => $value) {
+ $value['dateline'] = date('Y-m-d H:i', $value['dateline']);
+ $dbufielddata = dunserialize($value['ufielddata']);
+ if(!empty($dbufielddata['userfield'])) {
+ foreach ($dbufielddata['userfield'] as $ukey => $uvalue) {
+ $value['dbufielddata'][$ukey] = array('title' => $_G['cache']['profilesetting'][$ukey]['title'], 'value' => $uvalue);
+ }
+ }
+
+ $value['ufielddata'] = $GLOBALS['applylist'][$key]['ufielddata'];
+ $data['applylist'][] = $value;
+ }
+ }
+
+ $data['activityinfo'] = array();
+ $data['activityinfo']['subject'] = $GLOBALS['thread']['subject'];
+ $data['activityinfo']['applynumber'] = $GLOBALS['activity']['applynumber'];
+ $data['activityinfo']['number'] = $GLOBALS['activity']['number'];
+ $data['activityinfo']['days'] = $GLOBALS['activity']['starttimeto'];
+
+ }
+
+ $variable[$action] = $data;
+
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
diff --git a/mobile/api/5/forumupload.php b/mobile/api/5/forumupload.php
new file mode 100644
index 0000000..3346f23
--- /dev/null
+++ b/mobile/api/5/forumupload.php
@@ -0,0 +1,32 @@
+
\ No newline at end of file
diff --git a/mobile/api/5/group.php b/mobile/api/5/group.php
new file mode 100644
index 0000000..bd1642a
--- /dev/null
+++ b/mobile/api/5/group.php
@@ -0,0 +1,239 @@
+fetch_count_by_fid($fid, 1);
+ $realnames = array();
+ foreach(C::t('common_member_profile')->fetch_all($variable['groupinfo']['uids']) as $user) {
+ $realnames[$user['uid']] = $user['realname'];
+ }
+
+ foreach($variable['groupinfo']['userlist'] as $uid => $user) {
+ $user['realname'] = $realnames[$uid];
+ $user['avatar'] = avatar($user['uid'], 'middle', true);
+ $variable['groupinfo']['userlist'][$uid] = $user;
+ }
+
+ $founderinfo = C::t('common_member_profile')->fetch($_G['forum']['founderuid']);
+ $variable['groupinfo']['founderuid'] = $_G['forum']['founderuid'];
+ if($groupusernicknames[$_G['forum']['founderuid']]) {
+ $variable['groupinfo']['foundername'] = $groupusernicknames[$_G['forum']['founderuid']];
+ } elseif($founderinfo['realname']) {
+ $variable['groupinfo']['foundername'] = $founderinfo['realname'];
+ } else {
+ $variable['groupinfo']['foundername'] = $_G['forum']['foundername'];
+ }
+ $variable['groupinfo']['founderavatar'] = avatar($_G['forum']['founderuid'], 'middle', true);
+ $variable['groupinfo']['moduser'] = $count;
+
+ unset($variable['groupinfo']['uids']);
+ } else {
+ $variable['grouplist'] = $grouplist;
+ }
+
+ $variable['total'] = $grouplistcount;
+ $variable['tpp'] = $tpp;
+ mobile_core::result(mobile_core::variable($variable));
+
+ }
+
+ function output() {
+ }
+
+
+ function _gotuserlist($grouplist) {
+ global $_G;
+ if(!empty($grouplist)) {
+ $fids = array();
+ foreach($grouplist as $key => $value) {
+ $fids[] = $value['fid'];
+ }
+ $groupusers = C::t('#mobile#forum_groupuser_ext')->fetch_all_by_fids($fids);
+ foreach($grouplist as $key => $value) {
+ $ingroup = 0;
+ $value['iconnew'] = 1;
+ $value['icons'] = array();
+ if(strpos($value['icon'], 'groupicon.gif') !== false) {
+ $value['iconnew'] = 0;
+ }
+ $value['userlist'] = $groupusers[$value['fid']];
+ $value['users'] = count($groupusers[$value['fid']]);
+ $index = 0;
+ foreach($groupusers[$value['fid']] as $user) {
+ if($index < 9 && $value['iconnew'] == 0) {
+ $value['icons'][] = avatar($user['uid'], 'small', 1);
+ }
+ if($_G['uid'] == $user['uid']) {
+ $ingroup = 1;
+ }
+ $value['uids'][] = $user['uid'];
+ }
+ $value['ingroup'] = $ingroup;
+ $grouplist[$key] = $value;
+ }
+ }
+
+ return $grouplist;
+ }
+
+ function _grouplist($orderby = 'dateline', $fieldarray = array(), $num = 1, $fids = array(), $sort = 0, $getcount = 0, $grouplevel = array()) {
+ global $_G;
+ if(isset($_GET['kw']) && empty($fids)) {
+ return array();
+ }
+
+ $fups = self::_getfups();
+ $query = C::t('#mobile#forum_forum_ext')->fetch_all_for_fup_grouplist($orderby, $fieldarray, $num, $fids, $sort, $getcount, $fups);
+ if($getcount) {
+ return $query;
+ }
+
+ $firstgroup = $_G['cache']['grouptype']['first'];
+ $secondgroup = $_G['cache']['grouptype']['second'];
+
+ $grouplist = array();
+ foreach($query as $group) {
+ $fup = $group['fup'];
+
+ $secondid = $secondgroup[$fup]['fup'];
+ $grouptype = array('first' => $firstgroup[$secondid], 'second' => $secondgroup[$fup]);
+
+ $group['iconstatus'] = $group['icon'] ? 1 : 0;
+ $group['grouptype'] = $grouptype;
+ isset($group['icon']) && $group['icon'] = $_G['siteurl'].get_groupimg($group['icon'], 'icon');
+ isset($group['banner']) && $group['banner'] = get_groupimg($group['banner']);
+ $group['orderid'] = $orderid ? intval($orderid) : '';
+ isset($group['dateline']) && $group['dateline'] = $group['dateline'] ? dgmdate($group['dateline'], 'd') : '';
+ isset($group['lastupdate']) && $group['lastupdate'] = $group['lastupdate'] ? dgmdate($group['lastupdate'], 'd') : '';
+ $group['level'] = !empty($grouplevel) ? intval($grouplevel[$group['fid']]) : 0;
+ isset($group['description']) && $group['description'] = cutstr($group['description'], 130);
+ $grouplist[] = $group;
+ $orderid ++;
+ }
+
+ return $grouplist;
+ }
+
+
+ function _withfids() {
+ global $_G;
+ $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0;
+ $mod = isset($_GET['mod']) ? trim($_GET['mod']) : '';
+ $keyword = isset($_GET['kw']) ? rawurldecode(dhtmlspecialchars(trim($_GET['kw']))) : '';
+
+ $fids = array();
+
+ if($fid) {
+ $fids = array($fid);
+ } elseif($keyword) {
+ require_once libfile('function/search');
+ $keyword = str_replace('+', ' ', $keyword);
+ list($srchtxt, $srchtxtsql) = searchkey($keyword, "name LIKE '%{text}%'", true);
+
+ $fups = self::_getfups();
+ $query = C::t('forum_forum')->fetch_all_search_group($fups, $srchtxtsql, 0, $_G['setting']['search']['group']['maxsearchresults']);
+
+ foreach($query as $group) {
+ $fids[] = $group['fid'];
+ }
+
+ } elseif($mod == 'my') {
+ $fids = array(0);
+ if($_G['uid']) {
+ $usergroup = C::t('forum_groupuser')->fetch_all_group_for_user($_G['uid'], 0, 0, 0, 0);
+ if($usergroup) {
+ foreach($usergroup as $group) {
+ if($group['level'] > 0) {
+ $fids[] = $group['fid'];
+ }
+ }
+ }
+ }
+ }
+
+ return $fids;
+ }
+
+ function _getfups() {
+ global $_G;
+ $groupid = isset($_GET['groupid']) ? intval($_GET['groupid']) : 0;
+ $forumid = isset($_GET['forumid']) ? intval($_GET['forumid']) : 0;
+ $subid = isset($_GET['subid']) ? intval($_GET['subid']) : 0;
+
+ $fups = array();
+
+ if($groupid) {
+ $sendlist = $_G['cache']['grouptype']['first'][$groupid]['secondlist'];
+ foreach($sendlist as $k => $v) {
+ foreach($_G['cache']['grouptype']['second'][$v]['threelist'] as $value) {
+ $fups[] = $value;
+ }
+ }
+ }
+
+ if($forumid && in_array($forumid, $sendlist)) {
+ $fups = array();
+ foreach($_G['cache']['grouptype']['second'][$forumid]['threelist'] as $value) {
+ $fups[] = $value;
+ }
+ }
+
+ if($subid && in_array($subid, $_G['cache']['grouptype']['second'][$forumid]['threelist'])) {
+ $fups = array();
+ $fups[] = $subid;
+ }
+
+ if(empty($fups) && ($groupid || $forumid || $subid)) {
+ $fups = array(0);
+ }
+
+ return $fups;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/groupuser.php b/mobile/api/5/groupuser.php
new file mode 100644
index 0000000..aa872f0
--- /dev/null
+++ b/mobile/api/5/groupuser.php
@@ -0,0 +1,57 @@
+fetch_userinfo($_G['uid'], $fid);
+ $level = isset($groupuserinfo['level']) ? $groupuserinfo['level'] : '';
+ if($level == 1 || $level == 2) { //管理员
+ C::t('forum_groupuser')->update_for_user($uid, $fid, null, null, null, $nickname, $mobile);
+ } else {
+ $_G['messageparam'] = array('update_userinfo_righterror');
+ mobile_core::result(mobile_core::variable($variable));
+ }
+ }
+
+ if(submitcheck('groupusersubmit')) {
+ C::t('forum_groupuser')->update_for_user($_G['uid'], $fid, null, null, null, $nickname, $mobile);
+ }
+
+ $_G['messageparam'] = array('update_userinfo_success');
+
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/login.php b/mobile/api/5/login.php
new file mode 100644
index 0000000..e82e85b
--- /dev/null
+++ b/mobile/api/5/login.php
@@ -0,0 +1,39 @@
+fetch($_G['uid'])) {
+ C::t('#mobile#weixin_minapp_user')->insert(array('uid' => $_G['uid'], 'openid' => $_GET['openid'], 'status' => 1), false, true);
+ }
+ }
+
+ $variable = array();
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/mypm.php b/mobile/api/5/mypm.php
new file mode 100644
index 0000000..0f23783
--- /dev/null
+++ b/mobile/api/5/mypm.php
@@ -0,0 +1,62 @@
+ $_v) {
+ if($_v['lastdateline']) {
+ $GLOBALS['list'][$_k]['vdateline'] = dgmdate($_v['lastdateline'], 'u');
+ } elseif($_v['dateline']) {
+ $GLOBALS['list'][$_k]['vdateline'] = dgmdate($_v['dateline'], 'u');
+ }
+
+ //新加客户端表情解析
+ $smiley = in_array($_GET['smiley'], array('yes', 'no')) ? $_GET['smiley'] : 'yes';
+ if($smiley == 'no') {
+ $GLOBALS['list'][$_k]['message'] = mobile_core::smiley($GLOBALS['list'][$_k]['message']);
+ }
+
+ if($_GET['mapifrom'] == 'ios') {
+ $GLOBALS['list'][$_k]['fromavatar'] = avatar($_v['msgfromid'], 'small', true);
+ $GLOBALS['list'][$_k]['toavatar'] = avatar($_v['touid'], 'small', true);
+ $GLOBALS['list'][$_k]['message'] = preg_replace('/<([a-zA-Z]+)[^>]*>/', '', $GLOBALS['list'][$_k]['message']);
+ $GLOBALS['list'][$_k]['message'] = preg_replace('/<\/([a-zA-Z]+)>/', '', $GLOBALS['list'][$_k]['message']);
+ } elseif($_GET['mapifrom'] == 'android') {
+ $GLOBALS['list'][$_k]['fromavatar'] = avatar($_v['msgfromid'], 'small', true);
+ $GLOBALS['list'][$_k]['toavatar'] = avatar($_v['touid'], 'small', true);
+ }
+ }
+ $variable = array(
+ 'list' => mobile_core::getvalues($GLOBALS['list'], array('/^\d+$/'), array('plid', 'isnew', 'vdateline', 'subject', 'pmid', 'msgfromid', 'msgfrom', 'message', 'touid', 'tousername', 'fromavatar', 'toavatar', 'id', 'authorid', 'author', 'dateline', 'numbers')),
+ 'count' => $GLOBALS['count'],
+ 'perpage' => $GLOBALS['perpage'],
+ 'page' => intval($GLOBALS['page']),
+ );
+ if($_GET['subop']) {
+ $variable = array_merge($variable, array('pmid' => $GLOBALS['pmid']));
+ }
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/newthread.php b/mobile/api/5/newthread.php
new file mode 100644
index 0000000..c99a9c2
--- /dev/null
+++ b/mobile/api/5/newthread.php
@@ -0,0 +1,115 @@
+ $bit) {
+ $threadstatus = setstatus(13 - $i, $bit, $threadstatus);
+ }
+ C::t('forum_thread')->update($values['tid'], array('status' => $threadstatus));
+
+ $poststatus = DB::result_first("SELECT status FROM ".DB::table('forum_post')." WHERE pid='$values[pid]'");
+ $poststatus = setstatus(4, 1, $poststatus);
+ if(!empty($_POST['allowlocal'])) {
+ $poststatus = setstatus(6, 1, $poststatus);
+ }
+ if(!empty($_POST['allowsound'])) {
+ $poststatus = setstatus(7, 1, $poststatus);
+ }
+ if(!empty($_POST['mobiletype'])) {
+ $mobiletype = base_convert($_POST['mobiletype'], 10, 2);
+ $mobiletype = sprintf('%03d', $mobiletype);
+ for($i = 0;$i < 3;$i++) {
+ $poststatus = setstatus(10 - $i, $mobiletype{$i}, $poststatus);
+ }
+ }
+ C::t('forum_post')->update(0, $values['pid'], array('status' => $poststatus));
+
+ if($_POST['location']) {
+ list($mapx, $mapy, $location) = explode('|', dhtmlspecialchars($_POST['location']));
+ C::t('forum_post_location')->insert(array(
+ 'pid' => $values['pid'],
+ 'tid' => $values['tid'],
+ 'uid' => $_G['uid'],
+ 'mapx' => $mapx,
+ 'mapy' => $mapy,
+ 'location' => $location,
+ ));
+ }
+ }
+ }
+
+ function output() {
+ global $_G;
+ $variable = array(
+ 'tid' => $GLOBALS['tid'],
+ 'pid' => $GLOBALS['pid'],
+ );
+ if(!empty($_G['forum']['threadtypes'])) {
+ foreach($_G['forum']['threadtypes']['types'] as $typeid => $typename) {
+ $_G['forum']['threadtypes']['types'][$typeid] = strip_tags($typename);
+ }
+ $variable['threadtypes'] = $_G['forum']['threadtypes'];
+ }
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/portalcomment.php b/mobile/api/5/portalcomment.php
new file mode 100644
index 0000000..883c217
--- /dev/null
+++ b/mobile/api/5/portalcomment.php
@@ -0,0 +1,39 @@
+
+';
+ // print_r($GLOBALS['commentlist']);exit;
+ $variable = array(
+ 'commentlist' => $GLOBALS['commentlist']
+ );
+
+ header("Content-type: application/json");
+ echo json_encode($variable);
+ exit;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/profile.php b/mobile/api/5/profile.php
new file mode 100644
index 0000000..9a3bb93
--- /dev/null
+++ b/mobile/api/5/profile.php
@@ -0,0 +1,45 @@
+ $data,
+ 'extcredits' => $_G['setting']['extcredits'],
+ 'wsq' => array('wsq_apicredit' => getuserprofile('extcredits'.$_G['wechat']['setting']['wsq_apicredit'])),
+ );
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/register.php b/mobile/api/5/register.php
new file mode 100644
index 0000000..e1220dc
--- /dev/null
+++ b/mobile/api/5/register.php
@@ -0,0 +1,54 @@
+setting = $_G['setting'];
+ $ctl_obj->setting['regstatus'] = $ctl_obj->setting['regstatus'] ? $ctl_obj->setting['regstatus'] : 1;
+ $ctl_obj->setting['secqaa']['status'] = 0;
+ $ctl_obj->setting['sendregisterurl'] = FALSE;
+
+ $ctl_obj->template = 'member/register';
+ $ctl_obj->extrafile = dirname(__FILE__).'/register_bind.php';
+ $ctl_obj->on_register();
+ } else {
+ global $_G;
+
+ $variable = array(
+ 'reginput' => $_G['setting']['reginput'],
+ );
+ mobile_core::result(mobile_core::variable($variable));
+ }
+ }
+
+ function output() {
+ global $_G;
+
+ $variable = array();
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
\ No newline at end of file
diff --git a/mobile/api/5/register_bind.php b/mobile/api/5/register_bind.php
new file mode 100644
index 0000000..5d4b45a
--- /dev/null
+++ b/mobile/api/5/register_bind.php
@@ -0,0 +1,9 @@
+insert(array('uid' => $uid, 'openid' => $_GET['openid'], 'status' => 1), false, true);
+}
\ No newline at end of file
diff --git a/mobile/api/5/report.php b/mobile/api/5/report.php
new file mode 100644
index 0000000..4a8fa26
--- /dev/null
+++ b/mobile/api/5/report.php
@@ -0,0 +1,31 @@
+
\ No newline at end of file
diff --git a/mobile/api/5/search.php b/mobile/api/5/search.php
new file mode 100644
index 0000000..5a4b5f6
--- /dev/null
+++ b/mobile/api/5/search.php
@@ -0,0 +1,388 @@
+';
+ foreach($_G['cache']['posttable_info'] as $posttableid => $data) {
+ $posttableselect .= '';
+ }
+ $posttableselect .= '';
+ }
+
+ $srchmod = 2;
+
+ $cachelife_time = 300; // Life span for cache of searching in specified range of time
+ $cachelife_text = 3600; // Life span for cache of text searching
+
+ $srchtype = empty($_GET['srchtype']) ? '' : trim($_GET['srchtype']);
+ $searchid = isset($_GET['searchid']) ? intval($_GET['searchid']) : 0;
+ $seltableid = intval($_GET['seltableid']);
+
+ if($srchtype != 'title' && $srchtype != 'fulltext') {
+ $srchtype = '';
+ }
+
+ $srchtxt = trim($_GET['srchtxt']);
+ $srchuid = intval($_GET['srchuid']);
+ $srchuname = isset($_GET['srchuname']) ? trim(str_replace('|', '', $_GET['srchuname'])) : '';;
+ $srchfrom = intval($_GET['srchfrom']);
+ $before = intval($_GET['before']);
+ $srchfid = 'all';
+ $srhfid = intval($_GET['srhfid']);
+
+ $keyword = isset($srchtxt) ? dhtmlspecialchars(trim($srchtxt)) : '';
+
+ $orderby = in_array($_GET['orderby'], array('dateline', 'replies', 'views')) ? $_GET['orderby'] : 'lastpost';
+ $ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc';
+
+
+ //search
+ if($_G['group']['allowsearch'] & 32 && $srchtype == 'fulltext') {
+ periodscheck('searchbanperiods');
+ } elseif($srchtype != 'title') {
+ $srchtype = 'title';
+ }
+
+ $forumsarray = array();
+ if(!empty($srchfid)) {
+ foreach((is_array($srchfid) ? $srchfid : explode('_', $srchfid)) as $forum) {
+ if($forum = intval(trim($forum))) {
+ $forumsarray[] = $forum;
+ }
+ }
+ }
+
+ $fids = $comma = '';
+ foreach($_G['cache']['forums'] as $fid => $forum) {
+ if($forum['type'] != 'group' && (!$forum['viewperm'] && $_G['group']['readaccess']) || ($forum['viewperm'] && forumperm($forum['viewperm']))) {
+ if(!$forumsarray || in_array($fid, $forumsarray)) {
+ $fids .= "$comma'$fid'";
+ $comma = ',';
+ }
+ }
+ }
+
+ if($_G['setting']['threadplugins'] && $specialplugin) {
+ $specialpluginstr = implode("','", $specialplugin);
+ $special[] = 127;
+ } else {
+ $specialpluginstr = '';
+ }
+ $special = $_GET['special'];
+ $specials = $special ? implode(',', $special) : '';
+ $srchfilter = in_array($_GET['srchfilter'], array('all', 'digest', 'top')) ? $_GET['srchfilter'] : 'all';
+
+ $searchstring = 'forum|'.$srchtype.'|'.base64_encode($srchtxt).'|'.intval($srchuid).'|'.$srchuname.'|'.addslashes($fids).'|'.intval($srchfrom).'|'.intval($before).'|'.$srchfilter.'|'.$specials.'|'.$specialpluginstr.'|'.$seltableid;
+ $searchindex = array('id' => 0, 'dateline' => '0');
+
+ foreach(C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['forum']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
+ if($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
+ $searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
+ break;
+ } elseif($_G['adminid'] != '1' && $index['flood']) {
+ $_G['messageparam'][0] = 'search_ctrl';
+ mobile_core::result(mobile_core::variable($variable));
+ }
+ }
+
+ $searchid = $searchindex['id'];
+
+ if(!$searchindex['id']) {
+ !($_G['group']['exempt'] & 2) && checklowerlimit('search');
+
+ if(!$srchtxt && !$srchuid && !$srchuname && !$srchfrom && !in_array($srchfilter, array('digest', 'top')) && !is_array($special)) {
+ $_G['messageparam'][0] = 'undefined_action';
+ mobile_core::result(mobile_core::variable($variable));
+ } elseif(isset($srchfid) && !empty($srchfid) && $srchfid != 'all' && !(is_array($srchfid) && in_array('all', $srchfid)) && empty($forumsarray)) {
+ $_G['messageparam'][0] = 'search_forum_invalid';
+ mobile_core::result(mobile_core::variable($variable));
+ } elseif(!$fids) {
+ $_G['messageparam'][0] = 'group_nopermffission';
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+ if($_G['adminid'] != '1' && $_G['setting']['search']['forum']['maxspm']) {
+ if(C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['forum']['maxspm']) {
+ $_G['messageparam'][0] = 'search_toomany';
+ mobile_core::result(mobile_core::variable($variable));
+ }
+ }
+
+ if($srchtype == 'fulltext' && $_G['setting']['sphinxon']) {
+ require_once libfile('class/sphinx');
+
+ $s = new SphinxClient();
+ $s->setServer($_G['setting']['sphinxhost'], intval($_G['setting']['sphinxport']));
+ $s->setMaxQueryTime(intval($_G['setting']['sphinxmaxquerytime']));
+ $s->SetRankingMode($_G['setting']['sphinxrank']);
+ $s->setLimits(0, intval($_G['setting']['sphinxlimit']), intval($_G['setting']['sphinxlimit']));
+ $s->setGroupBy('tid', SPH_GROUPBY_ATTR);
+
+ if($srchfilter == 'digest') {
+ $s->setFilterRange('digest', 1, 3, false);
+ }
+ if($srchfilter == 'top') {
+ $s->setFilterRange('displayorder', 1, 2, false);
+ } else {
+ $s->setFilterRange('displayorder', 0, 2, false);
+ }
+
+ if(!empty($srchfrom) && empty($srchtxt) && empty($srchuid) && empty($srchuname)) {
+ $expiration = TIMESTAMP + $cachelife_time;
+ $keywords = '';
+ if($before) {
+ $spx_timemix = 0;
+ $spx_timemax = TIMESTAMP - $srchfrom;
+ } else {
+ $spx_timemix = TIMESTAMP - $srchfrom;
+ $spx_timemax = TIMESTAMP;
+ }
+ } else {
+ $uids = array();
+ if($srchuname) {
+ $uids = array_keys(C::t('common_member')->fetch_all_by_like_username($srchuname, 0, 50));
+ if(count($uids) == 0) {
+ $uids = array(0);
+ }
+ } elseif($srchuid) {
+ $uids = array($srchuid);
+ }
+ if(is_array($uids) && count($uids) > 0) {
+ $s->setFilter('authorid', $uids, false);
+ }
+
+ if($srchtxt) {
+ if(preg_match("/\".*\"/", $srchtxt)) {
+ $spx_matchmode = "PHRASE";
+ $s->setMatchMode(SPH_MATCH_PHRASE);
+ } elseif(preg_match("(AND|\+|&|\s)", $srchtxt) && !preg_match("(OR|\|)", $srchtxt)) {
+ $srchtxt = preg_replace("/( AND |&| )/is", "+", $srchtxt);
+ $spx_matchmode = "ALL";
+ $s->setMatchMode(SPH_MATCH_ALL);
+ } else {
+ $srchtxt = preg_replace("/( OR |\|)/is", "+", $srchtxt);
+ $spx_matchmode = 'ANY';
+ $s->setMatchMode(SPH_MATCH_ANY);
+ }
+ $srchtxt = str_replace('*', '%', addcslashes($srchtxt, '%_'));
+ foreach(explode('+', $srchtxt) as $text) {
+ $text = trim(daddslashes($text));
+ if($text) {
+ $sqltxtsrch .= $andor;
+ $sqltxtsrch .= $srchtype == 'fulltext' ? "(p.message LIKE '%".str_replace('_', '\_', $text)."%' OR p.subject LIKE '%$text%')" : "t.subject LIKE '%$text%'";
+ }
+ }
+ $sqlsrch .= " AND ($sqltxtsrch)";
+ }
+
+ if(!empty($srchfrom)) {
+ if($before) {
+ $spx_timemix = 0;
+ $spx_timemax = TIMESTAMP - $srchfrom;
+ } else {
+ $spx_timemix = TIMESTAMP - $srchfrom;
+ $spx_timemax = TIMESTAMP;
+ }
+ $s->setFilterRange('lastpost', $spx_timemix, $spx_timemax, false);
+ }
+ if(!empty($specials)) {
+ $s->setFilter('special', explode(",", $special), false);
+ }
+
+ $keywords = str_replace('%', '+', $srchtxt).(trim($srchuname) ? '+'.str_replace('%', '+', $srchuname) : '');
+ $expiration = TIMESTAMP + $cachelife_text;
+
+ }
+ if($srchtype == "fulltext") {
+ $result = $s->query("'".$srchtxt."'", $_G['setting']['sphinxmsgindex']);
+ } else {
+ $result = $s->query($srchtxt, $_G['setting']['sphinxsubindex']);
+ }
+ $tids = array();
+ if($result) {
+ if(is_array($result['matches'])) {
+ foreach($result['matches'] as $value) {
+ if($value['attrs']['tid']) {
+ $tids[$value['attrs']['tid']] = $value['attrs']['tid'];
+ }
+ }
+ }
+ }
+ if(count($tids) == 0) {
+ $ids = 0;
+ $num = 0;
+ } else {
+ $ids = implode(",", $tids);
+ $num = $result['total_found'];
+ }
+ } else {
+ $digestltd = $srchfilter == 'digest' ? "t.digest>'0' AND" : '';
+ $topltd = $srchfilter == 'top' ? "AND t.displayorder>'0'" : "AND t.displayorder>='0'";
+
+ if(!empty($srchfrom) && empty($srchtxt) && empty($srchuid) && empty($srchuname)) {
+
+ $searchfrom = $before ? '<=' : '>=';
+ $searchfrom .= TIMESTAMP - $srchfrom;
+ $sqlsrch = "FROM ".DB::table('forum_thread')." t WHERE $digestltd t.fid IN ($fids) $topltd AND t.lastpost$searchfrom";
+ $expiration = TIMESTAMP + $cachelife_time;
+ $keywords = '';
+
+ } else {
+ $sqlsrch = $srchtype == 'fulltext' ?
+ "FROM ".DB::table(getposttable($seltableid))." p, ".DB::table('forum_thread')." t WHERE $digestltd t.fid IN ($fids) $topltd AND p.tid=t.tid AND p.invisible='0'" :
+ "FROM ".DB::table('forum_thread')." t WHERE $digestltd t.fid IN ($fids) $topltd";
+ if($srchuname) {
+ $srchuid = array_keys(C::t('common_member')->fetch_all_by_like_username($srchuname, 0, 50));
+ if(!$srchuid) {
+ $sqlsrch .= ' AND 0';
+ }
+ }/* elseif($srchuid) {
+ $srchuid = "'$srchuid'";
+ }*/
+
+ if($srchtxt) {
+ $srcharr = $srchtype == 'fulltext' ? searchkey($keyword, "(p.message LIKE '%{text}%' OR p.subject LIKE '%{text}%')", true) : searchkey($keyword,"t.subject LIKE '%{text}%'", true);
+ $srchtxt = $srcharr[0];
+ $sqlsrch .= $srcharr[1];
+ }
+
+ if($srchuid) {
+ $sqlsrch .= ' AND '.($srchtype == 'fulltext' ? 'p' : 't').'.authorid IN ('.dimplode((array)$srchuid).')';
+ }
+
+ if(!empty($srchfrom)) {
+ $searchfrom = ($before ? '<=' : '>=').(TIMESTAMP - $srchfrom);
+ $sqlsrch .= " AND t.lastpost$searchfrom";
+ }
+
+ if(!empty($specials)) {
+ $sqlsrch .= " AND special IN (".dimplode($special).")";
+ }
+
+ $keywords = str_replace('%', '+', $srchtxt);
+ $expiration = TIMESTAMP + $cachelife_text;
+
+ }
+
+ $num = $ids = 0;
+ $_G['setting']['search']['forum']['maxsearchresults'] = $_G['setting']['search']['forum']['maxsearchresults'] ? intval($_G['setting']['search']['forum']['maxsearchresults']) : 500;
+ $query = DB::query("SELECT ".($srchtype == 'fulltext' ? 'DISTINCT' : '')." t.tid, t.closed, t.author, t.authorid $sqlsrch ORDER BY tid DESC LIMIT ".$_G['setting']['search']['forum']['maxsearchresults']);
+ while($thread = DB::fetch($query)) {
+ $ids .= ','.$thread['tid'];
+ $num++;
+ }
+ DB::free_result($query);
+ }
+
+ $searchid = C::t('common_searchindex')->insert(array(
+ 'srchmod' => $srchmod,
+ 'keywords' => $keywords,
+ 'searchstring' => $searchstring,
+ 'useip' => $_G['clientip'],
+ 'uid' => $_G['uid'],
+ 'dateline' => $_G['timestamp'],
+ 'expiration' => $expiration,
+ 'num' => $num,
+ 'ids' => $ids
+ ), true);
+
+ !($_G['group']['exempt'] & 2) && updatecreditbyaction('search');
+ }
+
+ require_once libfile('function/misc');
+
+ $page = max(1, intval($_GET['page']));
+ $start_limit = ($page - 1) * $_G['tpp'];
+
+ $index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
+ if(!$index) {
+ $_G['messageparam'][0] = 'search_id_invalid';
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+ $keyword = dhtmlspecialchars($index['keywords']);
+ $keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
+
+ $index['keywords'] = rawurlencode($index['keywords']);
+ $searchstring = explode('|', $index['searchstring']);
+ $index['searchtype'] = $searchstring[0];//preg_replace("/^([a-z]+)\|.*/", "\\1", $index['searchstring']);
+ $searchstring[2] = base64_decode($searchstring[2]);
+ $srchuname = $searchstring[3];
+ $modfid = 0;
+ if($keyword) {
+ $modkeyword = str_replace(' ', ',', $keyword);
+ $fids = explode(',', str_replace('\'', '', $searchstring[5]));
+ if(count($fids) == 1 && in_array($_G['adminid'], array(1,2,3))) {
+ $modfid = $fids[0];
+ if($_G['adminid'] == 3 && !C::t('forum_moderator')->fetch_uid_by_fid_uid($modfid, $_G['uid'])) {
+ $modfid = 0;
+ }
+ }
+ }
+ $threadlist = $posttables = array();
+ foreach(C::t('forum_thread')->fetch_all_by_tid_fid_displayorder(explode(',',$index['ids']), null, 0, $orderby, $start_limit, $_G['tpp'], '>=', $ascdesc) as $thread) {
+ $thread['subject'] = strip_tags($thread['subject'], $keyword);
+ $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
+ $threadlist[$thread['tid']] = procthread($thread, 'dt');
+ $posttables[$thread['posttableid']][] = $thread['tid'];
+ }
+ if($threadlist) {
+ foreach($posttables as $tableid => $tids) {
+ foreach(C::t('forum_post')->fetch_all_by_tid($tableid, $tids, true, '', 0, 0, 1) as $post) {
+ $threadlist[$post['tid']]['message'] = strip_tags(messagecutstr($post['message'], 200), $keyword);
+ }
+ }
+
+ }
+
+
+ $variable['threadlist'] = array_values($threadlist);
+ $variable['total'] = $index['num'];
+ $variable['tpp'] = $_G['tpp'];
+
+ mobile_core::result(mobile_core::variable($variable));
+
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/seccode.php b/mobile/api/5/seccode.php
new file mode 100644
index 0000000..a3e7557
--- /dev/null
+++ b/mobile/api/5/seccode.php
@@ -0,0 +1,60 @@
+code = $seccode;
+ $code->type = $type;
+ $code->width = $_G['setting']['seccodedata']['width'];
+ $code->height = $_G['setting']['seccodedata']['height'];
+ $code->background = $_G['setting']['seccodedata']['background'];
+ $code->adulterate = $_G['setting']['seccodedata']['adulterate'];
+ $code->ttf = $_G['setting']['seccodedata']['ttf'];
+ $code->angle = $_G['setting']['seccodedata']['angle'];
+ $code->warping = $_G['setting']['seccodedata']['warping'];
+ $code->scatter = $_G['setting']['seccodedata']['scatter'];
+ $code->color = $_G['setting']['seccodedata']['color'];
+ $code->size = $_G['setting']['seccodedata']['size'];
+ $code->shadow = $_G['setting']['seccodedata']['shadow'];
+ $code->animator = 0;
+ $code->fontpath = DISCUZ_ROOT.'./static/image/seccode/font/';
+ $code->datapath = DISCUZ_ROOT.'./static/image/seccode/';
+ $code->includepath = DISCUZ_ROOT.'./source/class/';
+
+ $code->display();
+
+ }
+
+ function output() {}
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/secure.php b/mobile/api/5/secure.php
new file mode 100644
index 0000000..81caec1
--- /dev/null
+++ b/mobile/api/5/secure.php
@@ -0,0 +1,44 @@
+
\ No newline at end of file
diff --git a/mobile/api/5/sendpm.php b/mobile/api/5/sendpm.php
new file mode 100644
index 0000000..9bc69e9
--- /dev/null
+++ b/mobile/api/5/sendpm.php
@@ -0,0 +1,49 @@
+ $GLOBALS['return']
+ );
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/sendreply.php b/mobile/api/5/sendreply.php
new file mode 100644
index 0000000..7595dd3
--- /dev/null
+++ b/mobile/api/5/sendreply.php
@@ -0,0 +1,119 @@
+ $bit) {
+ $threadstatus = setstatus(13 - $i, $bit, $threadstatus);
+ }
+ C::t('forum_thread')->update($values['tid'], array('status' => $threadstatus));
+ }
+
+ $posttable = getposttablebytid($values['tid']);
+ $poststatus = DB::result_first("SELECT status FROM " . DB::table($posttable) . " WHERE pid='$values[pid]'");
+ $poststatus = setstatus(4, 1, $poststatus);
+ if (!empty($_POST['allowlocal'])) {
+ $poststatus = setstatus(6, 1, $poststatus);
+ }
+ if (!empty($_POST['allowsound'])) {
+ $poststatus = setstatus(7, 1, $poststatus);
+ }
+ if (!empty($_POST['mobiletype']) && $_POST['mobiletype'] < 8) {
+ $mobiletype = base_convert($_POST['mobiletype'], 10, 2);
+ $mobiletype = sprintf('%03d', $mobiletype);
+ for ($i = 0; $i < 3; $i++) {
+ $poststatus = setstatus(10 - $i, $mobiletype{$i}, $poststatus);
+ }
+ }
+ C::t('forum_post')->update('tid:' . $values['tid'], $values['pid'], array('status' => $poststatus));
+
+ if($_POST['location']) {
+ list($mapx, $mapy, $location) = explode('|', dhtmlspecialchars($_POST['location']));
+ C::t('forum_post_location')->insert(array(
+ 'pid' => $values['pid'],
+ 'tid' => $values['tid'],
+ 'uid' => $_G['uid'],
+ 'mapx' => $mapx,
+ 'mapy' => $mapy,
+ 'location' => $location,
+ ));
+ }
+ }
+ }
+
+ function output() {
+ global $_G;
+ $variable = array(
+ 'tid' => $_G['tid'],
+ 'pid' => $GLOBALS['pid'],
+ );
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/sub_checkpost.php b/mobile/api/5/sub_checkpost.php
new file mode 100644
index 0000000..2f75002
--- /dev/null
+++ b/mobile/api/5/sub_checkpost.php
@@ -0,0 +1,111 @@
+ getuserprofile('todayattachs'));
+ $attachremain = array();
+ if($allowupload) {
+ $attachextensions = !$_G['group']['attachextensions'] ? $mobile_attachextensions : array_map('trim', explode(',', $_G['group']['attachextensions']));
+ $allowupload = $forummaxattachsize = array();
+ loadcache('attachtype');
+ if(isset($_G['cache']['attachtype'][$_G['forum']['fid']])) {
+ $attachtype = $_G['cache']['attachtype'][$_G['forum']['fid']];
+ } elseif(isset($_G['cache']['attachtype'][0])) {
+ $attachtype = $_G['cache']['attachtype'][0];
+ } else {
+ $attachtype = array();
+ }
+ if($attachtype) {
+ foreach($attachtype as $extension => $maxsize) {
+ $forummaxattachsize[$extension] = $maxsize;
+ }
+ }
+ foreach($mobile_attachextensions as $ext) {
+ if(in_array($ext, $attachextensions)) {
+ if(isset($forummaxattachsize[$ext])) {
+ if($forummaxattachsize[$ext] > 0) {
+ $allowupload[$ext] = $forummaxattachsize[$ext] ? $forummaxattachsize[$ext] : $_G['group']['maxattachsize'];
+ } else {
+ $allowupload[$ext] = 0;
+ }
+ } else {
+ $allowupload[$ext] = -1;
+ }
+ } else {
+ $allowupload[$ext] = 0;
+ }
+ }
+ $attachremain = array(
+ 'size' => $_G['group']['maxsizeperday'] ? $_G['group']['maxsizeperday'] - getuserprofile('todayattachsize') : -1,
+ 'count' => $_G['group']['maxattachnum'] ? $_G['group']['maxattachnum'] - getuserprofile('todayattachs') : -1,
+ );
+ } else {
+ $allowupload = array();
+ }
+ $uploadhash = md5(substr(md5($_G['config']['security']['authkey']), 8).$_G['uid']);
+ $allowperm = array();
+ $allowperm['allowperm'] = array();
+ $allowkey = array('allowpost', 'allowreply', 'allowupload', 'attachremain', 'uploadhash');
+ foreach($allowkey as $key) {
+ if((!empty(${$key}) || ${$key} === 0) || !empty($_GET['debug'])) {
+ $allowperm['allowperm'][$key] = ${$key};
+ }
+ }
+ return $allowperm;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/sub_threadlist.php b/mobile/api/5/sub_threadlist.php
new file mode 100644
index 0000000..da011e0
--- /dev/null
+++ b/mobile/api/5/sub_threadlist.php
@@ -0,0 +1,134 @@
+ $thread) {
+ $tids[] = $_G['forum_threadlist'][$k]['tid'] = $thread['icontid'];
+
+
+ //获取message和附件
+ $post = array_pop(C::t('forum_post')->fetch_all_by_tid('tid:'.$thread['tid'], $thread['tid'], true, '', 0, 0, 1));
+ $attachlist = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$thread['tid'], 'pid', $post['pid']);
+
+ foreach($attachlist as $aid => $attach) {
+ if($attach['remote']) {
+ $attach['attachment'] = $_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment'];
+ } else {
+ $attach['attachment'] = strpos($_G['setting']['attachurl'], 'http') !== false ? $_G['setting']['attachurl'].'forum/'.$attach['attachment'] : $_G['siteurl'].$_G['setting']['attachurl'].'forum/'.$attach['attachment'];
+ }
+
+ $attach['thumb'] = mobile_core::thumb($attach['aid'], '0', '268', '380');
+ $type = '';
+ $fileext = addslashes(strtolower(substr(strrchr($attach['filename'], '.'), 1, 10)));
+ if(in_array($fileext, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
+ $type = 'image';
+ } elseif($fileext === 'mp3') {
+ $type = 'audio';
+ } elseif($fileext === 'mp4') {
+ $type = 'video';
+ }
+ $attach['type'] = $type;
+ $attachlist[$aid] = $attach;
+ }
+
+ $_G['forum_threadlist'][$k]['attachlist'] = array_values($attachlist);
+
+
+ $_G['forum_threadlist'][$k]['cover'] = array();
+ if ($thread['cover']) {
+ $_G['forum_threadlist'][$k]['cover'] = array('w' => 200, 'h' => 200);
+ }
+
+ $_G['forum_threadlist'][$k]['reply'] = array();
+ if(!isset($_G['wechat']['setting']['wechat_forumdisplay_reply']) || $_G['wechat']['setting']['wechat_forumdisplay_reply']) {
+ $key = C::t('#mobile#mobile_wsq_threadlist')->fetch($thread['tid']);
+ if ($key['svalue']) {
+ $_G['forum_threadlist'][$k]['reply'] = dunserialize($key['svalue']);
+ }
+ }
+ $_G['forum_threadlist'][$k]['dateline'] = strip_tags($thread['dateline']);
+ $_G['forum_threadlist'][$k]['lastpost'] = strip_tags($thread['lastpost']);
+ if(!$thread['authorid'] || !$thread['author']) {
+ $_G['forum_threadlist'][$k]['author'] = $_G['setting']['anonymoustext'];
+ $_G['forum_threadlist'][$k]['authorid'] = 0;
+ }
+
+ //avatar
+ $_G['forum_threadlist'][$k]['avatar'] = avatar($thread['authorid'], 'small', true);
+
+ $userids[] = $thread['authorid'];
+}
+
+foreach(C::t('common_member')->fetch_all($userids) as $user) {
+ $groupiconIds[$user['uid']] = mobile_core::usergroupIconId($user['groupid']);
+}
+
+if($_G['uid']) {
+ $memberrecommends = array();
+ $query = DB::query('SELECT * FROM %t WHERE recommenduid=%d AND tid IN (%n)', array('forum_memberrecommend', $_G['uid'], $tids));
+ while ($memberrecommend = DB::fetch($query)) {
+ $memberrecommends[$memberrecommend['tid']] = 1;
+ }
+ foreach ($_G['forum_threadlist'] as $k => $thread) {
+ $_G['forum_threadlist'][$k]['recommend'] = isset($memberrecommends[$thread['icontid']]) ? 1 : 0;
+ }
+}
+
+foreach ($GLOBALS['sublist'] as $k => $sublist) {
+ if ($sublist['icon']) {
+ $icon = preg_match('/src="(.+?)"/', $sublist['icon'], $r) ? $r[1] : '';
+ if (!preg_match('/^http:\//', $icon)) {
+ $icon = $_G['siteurl'] . $icon;
+ }
+ $GLOBALS['sublist'][$k]['icon'] = $icon;
+ }
+}
+
+if($_G['forum']['icon']) {
+ require_once libfile('function/forumlist');
+ if(strncasecmp($_G['forum']['icon'], 'http://', 7) !== 0) {
+ $_G['forum']['icon'] = get_forumimg($_G['forum']['icon']);
+ if(strncasecmp($_G['forum']['icon'], 'http://', 7) !== 0) {
+ $_G['forum']['icon'] = $_G['siteurl'] . $_G['forum']['icon'];
+ }
+ }
+}
+
+$_G['forum']['threadcount'] = $_G['forum_threadcount'];
+$_G['forum']['favorited'] = $_G['uid'] && C::t('home_favorite')->fetch_by_id_idtype($_G['forum']['fid'], 'fid', $_G['uid']) ? 1 : 0;
+
+$variable = array(
+ 'forum' => mobile_core::getvalues($_G['forum'], array('fid', 'fup', 'name', 'threads', 'posts', 'rules', 'autoclose', 'password', 'icon', 'threadcount', 'picstyle', 'description', 'livetid', 'rank', 'allowspecialonly', 'favorited', 'price', 'paycredits', 'threadmodcount', 'todayposts')),
+ 'group' => mobile_core::getvalues($_G['group'], array('groupid', 'grouptitle', 'allowpostpoll', 'allowpostactivity', 'allowpostdebate')),
+ 'forum_threadlist' => mobile_core::getvalues(array_values($_G['forum_threadlist']), array('/^\d+$/'), array('tid', 'fid', 'author', 'special', 'authorid', 'subject', 'subject', 'dbdateline', 'dateline', 'dblastpost', 'lastpost', 'lastposter', 'attachment', 'replies', 'readperm', 'views', 'digest', 'cover', 'recommend', 'recommend_add', 'reply', 'avatar', 'displayorder', 'coverpath', 'typeid', 'rushreply', 'replycredit', 'price', 'attachlist')),
+ 'groupiconid' => $groupiconIds,
+ 'sublist' => mobile_core::getvalues($GLOBALS['sublist'], array('/^\d+$/'), array('fid', 'name', 'threads', 'todayposts', 'posts', 'icon')),
+ 'tpp' => $_G['tpp'],
+ 'page' => $GLOBALS['page'],
+ 'reward_unit' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]['unit'].$_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]['title'],
+ 'activity_setting' => array(
+ 'activityfield' => unserialize($_G['setting']['activityfield']),
+ 'activitytype' => explode("\r\n", $_G['setting']['activitytype'])
+ )
+);
+if (!empty($_G['forum']['threadtypes']) || !empty($_GET['debug'])) {
+ $variable['threadtypes'] = $_G['forum']['threadtypes'];
+}
+if (!empty($_G['forum']['threadsorts']) || !empty($_GET['debug'])) {
+ $variable['threadsorts'] = $_G['forum']['threadsorts'];
+}
+$variable['forum']['password'] = $variable['forum']['password'] ? '1' : '0';
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/support.php b/mobile/api/5/support.php
new file mode 100644
index 0000000..32f9729
--- /dev/null
+++ b/mobile/api/5/support.php
@@ -0,0 +1,33 @@
+
\ No newline at end of file
diff --git a/mobile/api/5/threadclass.php b/mobile/api/5/threadclass.php
new file mode 100644
index 0000000..d1bf2e3
--- /dev/null
+++ b/mobile/api/5/threadclass.php
@@ -0,0 +1,112 @@
+ 0) {
+ $newenable = array_fill(0, $count, 1);
+ if (!empty($_POST['newdisplayorder'])) {
+ foreach ($newname as $key_order => $value_order) {
+ if (isset($_POST['newdisplayorder'][$key_order])) {
+ $newdisplayorder[$key_order] = $_POST['newdisplayorder'][$key_order];
+ } else {
+ $newdisplayorder[$key_order] = 0;
+ }
+ }
+ } else {
+ $newdisplayorder = array_fill(0, $count, 0);
+ }
+
+ }
+ $temp['newenable'] = $newenable;
+ $temp['newdisplayorder'] = $newdisplayorder;
+ $temp['newname'] = $newname;
+ }
+ $enable = isset($_POST['enable']) && is_array($_POST['enable']) ? $_POST['enable'] : '';
+ $displayorder = isset($_POST['displayorder']) && is_array($_POST['displayorder']) ? $_POST['displayorder'] : '';
+ $name = isset($_POST['name']) && is_array($_POST['name']) ? $_POST['name'] : '';
+ $delete = isset($_POST['delete']) && is_array($_POST['delete']) ? $_POST['delete'] : '';
+
+ if (!empty($enable) || !empty($displayorder) || !empty($name) || !empty($delete)) {
+ $temp['groupthreadtype'] = 1;
+ $temp['threadtypesnew'] = array();
+ $temp['threadtypesnew']['status'] = 1;
+ $temp['threadtypesnew']['options'] = array();
+ }
+ // if (!empty($enable)) {
+ // $temp['threadtypesnew']['options']['enable'] = $enable;
+ // }
+ // if (!empty($displayorder)) {
+ // $temp['threadtypesnew']['options']['displayorder'] = $displayorder;
+ // }
+ if (!empty($name)) {
+ $temp['threadtypesnew']['options']['name'] = $name;
+ $temp['threadtypesnew']['options']['enable'] = array();
+ $temp['threadtypesnew']['options']['displayorder'] = array();
+ foreach ($name as $key_name => $value_name) {
+ if (isset($_POST['displayorder'][$key_name])) {
+ $temp['threadtypesnew']['options']['displayorder'][$key_name] = $_POST['displayorder'][$key_name];
+ } else {
+ $temp['threadtypesnew']['options']['displayorder'][$key_name] = 0;
+ }
+ $temp['threadtypesnew']['options']['enable'][$key_name] = 1;
+ }
+ }
+ if (!empty($delete)) {
+ $temp['threadtypesnew']['options']['delete'] = $delete;
+ }
+ $_GET = $temp;
+ }
+ }
+
+ function output() {
+ global $_G;
+ $variable = array();
+ $threadtypes = $checkeds = array();
+ if(empty($_G['forum']['threadtypes'])) {
+ $checkeds['status'][0] = 'checked';
+ $display = 'none';
+ } else {
+ $display = '';
+ $_G['forum']['threadtypes']['status'] = 1;
+ foreach($_G['forum']['threadtypes'] as $key => $val) {
+ $val = intval($val);
+ $checkeds[$key][$val] = 'checked';
+ }
+ }
+ foreach(C::t('forum_threadclass')->fetch_all_by_fid($_G['fid']) as $type) {
+ $type['enablechecked'] = isset($_G['forum']['threadtypes']['types'][$type['typeid']]) ? ' checked="checked"' : '';
+ $type['name'] = dhtmlspecialchars($type['name']);
+ $threadtypes[] = $type;
+ }
+ $variable['threadtypes'] = $threadtypes;
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/api/5/viewthread.php b/mobile/api/5/viewthread.php
new file mode 100644
index 0000000..08799f6
--- /dev/null
+++ b/mobile/api/5/viewthread.php
@@ -0,0 +1,236 @@
+ $post) {
+ if (!$post['first'] && $_G['uid'] != $post['authorid'] && $_G['uid'] != $_G['forum_thread']['authorid'] && !$_G['forum']['ismoderator']) {
+ $GLOBALS['postlist'][$k]['message'] = lang('plugin/mobile', 'mobile_post_author_visible');
+ $GLOBALS['postlist'][$k]['attachments'] = array();
+ }
+ }
+ }
+
+ $_G['thread']['forumnames'] = $_G['cache']['forums'][$_G['thread']['fid']]['name'];
+ $_G['thread']['lastpost'] = dgmdate($_G['thread']['lastpost']);
+ $_G['thread']['ordertype'] = $GLOBALS['ordertype'];
+ $_G['thread']['favorited'] = $_G['uid'] && C::t('home_favorite')->fetch_by_id_idtype($_G['tid'], 'tid', $_G['uid']) ? 1 : 0;
+ $_G['thread']['recommend'] = $_G['uid'] && C::t('forum_memberrecommend')->fetch_by_recommenduid_tid($_G['uid'], $_G['tid']) ? 1 : 0;
+ if (!empty($_GET['viewpid'])) {
+ $GLOBALS['postlist'][$_GET['viewpid']] = $GLOBALS['post'];
+ }
+ if ($GLOBALS['rushreply']) {
+ $_G['thread']['rushreply'] = $GLOBALS['rushreply'];
+ $_G['thread']['rushresult'] = $GLOBALS['rushresult'];
+ }
+ foreach ($GLOBALS['comments'] as $pid => $comments) {
+ $comments = mobile_core::getvalues($comments, array('/^\d+$/'), array('id', 'tid', 'pid', 'author', 'authorid', 'dateline', 'comment', 'avatar'));
+ foreach ($comments as $k => $c) {
+ $comments[$k]['avatar'] = avatar($c['authorid'], 'small', true);
+ $comments[$k]['dateline'] = dgmdate($c['dateline'], 'u');
+ }
+ $GLOBALS['comments'][$pid] = $comments;
+ }
+
+ $variable = array(
+ 'thread' => $_G['thread'],
+ 'fid' => $_G['fid'],
+ 'postlist' => array_values(mobile_core::getvalues($GLOBALS['postlist'], array('/^\d+$/'), array('pid', 'tid', 'author', 'first', 'dbdateline', 'dateline', 'username', 'adminid', 'memberstatus', 'authorid', 'username', 'groupid', 'memberstatus', 'status', 'message', 'number', 'memberstatus', 'groupid', 'attachment', 'attachments', 'attachlist', 'imagelist', 'anonymous', 'position', 'rewardfloor', 'replycredit', 'postreview'))),
+ 'allowpostcomment' => $_G['setting']['allowpostcomment'],
+ 'comments' => $GLOBALS['comments'],
+ 'commentcount' => $GLOBALS['commentcount'],
+ 'ppp' => $_G['ppp'],
+ 'setting_rewriterule' => $_G['setting']['rewriterule'],
+ 'setting_rewritestatus' => $_G['setting']['rewritestatus'],
+ 'forum_threadpay' => $_G['forum_threadpay'],
+ 'cache_custominfo_postno' => $_G['cache']['custominfo']['postno'],
+ );
+
+ if (!empty($GLOBALS['threadsortshow'])) {
+ $optionlist = array();
+ foreach ($GLOBALS['threadsortshow']['optionlist'] AS $key => $val) {
+ $val['optionid'] = $key;
+ $optionlist[] = $val;
+ }
+ if (!empty($optionlist)) {
+ $GLOBALS['threadsortshow']['optionlist'] = $optionlist;
+ $GLOBALS['threadsortshow']['threadsortname'] = $_G['forum']['threadsorts']['types'][$thread['sortid']];
+ }
+ }
+ $threadsortshow = mobile_core::getvalues($GLOBALS['threadsortshow'], array('/^(?!typetemplate).*$/'));
+ if (!empty($threadsortshow)) {
+ $variable['threadsortshow'] = $threadsortshow;
+ }
+ foreach ($variable['postlist'] as $k => $post) {
+
+ //附件处理
+ foreach($post['attachments'] as $aid => $attach) {
+ if($attach['remote']) {
+ $attach['attachmenturl'] = $_G['setting']['ftp']['attachurl'].'forum/'.$attach['attachment'];
+ } else {
+ $attach['attachmenturl'] = strpos($_G['setting']['attachurl'], 'http') !== false ? $_G['setting']['attachurl'].'forum/'.$attach['attachment'] : $_G['siteurl'].$_G['setting']['attachurl'].'forum/'.$attach['attachment'];
+ }
+ $variable['postlist'][$k]['attachments'][$aid] = $attach;
+ }
+
+ if (!$_G['forum']['ismoderator'] && $_G['setting']['bannedmessages'] & 1 && (($post['authorid'] && !$post['username']) || ($_G['thread']['digest'] == 0 && ($post['groupid'] == 4 || $post['groupid'] == 5 || $post['memberstatus'] == '-1')))) {
+ $message = lang('forum/template', 'message_banned');
+ } elseif (!$_G['forum']['ismoderator'] && $post['status'] & 1) {
+ $message = lang('forum/template', 'message_single_banned');
+ } elseif ($GLOBALS['needhiddenreply']) {
+ $message = lang('forum/template', 'message_ishidden_hiddenreplies');
+ } elseif ($post['first'] && $_G['forum_threadpay']) {
+ $message = lang('forum/template', 'pay_threads') . ' ' . $GLOBALS['thread']['price'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'];
+ } elseif ($_G['forum_discuzcode']['passwordlock']) {
+ $message = lang('forum/template', 'message_password_exists');
+ } else {
+ $message = '';
+ }
+ if ($message) {
+ $variable['postlist'][$k]['message'] = $message;
+ }
+ if ($post['anonymous'] && !$_G['forum']['ismoderator']) {
+ $variable['postlist'][$k]['username'] = $variable['postlist'][$k]['author'] = $_G['setting']['anonymoustext'];
+ $variable['postlist'][$k]['adminid'] = $variable['postlist'][$k]['groupid'] = $variable['postlist'][$k]['authorid'] = 0;
+ if ($post['first']) {
+ $variable['thread']['authorid'] = 0;
+ }
+ }
+ if (strpos($variable['postlist'][$k]['message'], '[/tthread]') !== FALSE) {
+ $matches = array();
+ preg_match('/\[tthread=(.+?),(.+?)\](.*?)\[\/tthread\]/', $variable['postlist'][$k]['message'], $matches);
+ $variable['postlist'][$k]['message'] = preg_replace('/\[tthread=(.+?)\](.*?)\[\/tthread\]/', lang('plugin/qqconnect', 'connect_tthread_message', array('username' => $matches[1], 'nick' => $matches[2])), $variable['postlist'][$k]['message']);
+ }
+ $variable['postlist'][$k]['message'] = preg_replace("/\[viewimg\]<\/a>/is", "", $variable['postlist'][$k]['message']);
+ $variable['postlist'][$k]['message'] = mobile_api::_findimg($variable['postlist'][$k]['message']);
+ if ($GLOBALS['aimgs'][$post['pid']]) {
+ $imagelist = array();
+ foreach ($GLOBALS['aimgs'][$post['pid']] as $aid) {
+ $extra = '';
+ $url = mobile_api::_parseimg('', $GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['url'] . $GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['attachment'], '');
+ if ($GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['thumb']) {
+ $extra = 'file="' . $url . '" ';
+ $url .= '.thumb.jpg';
+ }
+ $extra .= 'attach="' . $post['pid'] . '" ';
+ if (strexists($variable['postlist'][$k]['message'], '[attach]' . $aid . '[/attach]')) {
+ $variable['postlist'][$k]['message'] = str_replace('[attach]' . $aid . '[/attach]', "", $variable['postlist'][$k]['message']);
+ unset($variable['postlist'][$k]['attachments'][$aid]);
+ } elseif (!in_array($aid, $_G['forum_attachtags'][$post['pid']])) {
+ $imagelist[] = $aid;
+ }
+ }
+ $variable['postlist'][$k]['imagelist'] = $imagelist;
+ }
+ $variable['postlist'][$k]['message'] = preg_replace("/\[attach\]\d+\[\/attach\]/i", '', $variable['postlist'][$k]['message']);
+ $variable['postlist'][$k]['message'] = preg_replace('/( ){2,}/', '', $variable['postlist'][$k]['message']);
+ $variable['postlist'][$k]['dateline'] = strip_tags($post['dateline']);
+ $variable['postlist'][$k]['groupiconid'] = mobile_core::usergroupIconId($post['groupid']);
+
+ //avatar
+ $variable['postlist'][$k]['avatar'] = avatar($post['authorid'], 'small', true);
+ }
+
+ if (!empty($GLOBALS['polloptions'])) {
+ $variable['special_poll']['polloptions'] = $GLOBALS['polloptions'];
+ $variable['special_poll']['expirations'] = $GLOBALS['expirations'];
+ $variable['special_poll']['multiple'] = $GLOBALS['multiple'];
+ $variable['special_poll']['maxchoices'] = $GLOBALS['maxchoices'];
+ $variable['special_poll']['voterscount'] = $GLOBALS['voterscount'];
+ $variable['special_poll']['visiblepoll'] = $GLOBALS['visiblepoll'];
+ $variable['special_poll']['allowvote'] = $_G['group']['allowvote'];
+ $variable['special_poll']['remaintime'] = $thread['remaintime'];
+ }
+ if (!empty($GLOBALS['rewardprice'])) {
+ $variable['special_reward']['rewardprice'] = $GLOBALS['rewardprice'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]['title'];
+ $variable['special_reward']['bestpost'] = $GLOBALS['bestpost'];
+ }
+ if (!empty($GLOBALS['trades'])) {
+ $variable['special_trade'] = $GLOBALS['trades'];
+ }
+ if (!empty($GLOBALS['debate'])) {
+ $variable['special_debate'] = $GLOBALS['debate'];
+ }
+ if (!empty($GLOBALS['activity'])) {
+ $variable['special_activity'] = $GLOBALS['activity'];
+ $variable['special_activity']['allapplynum'] = $GLOBALS['allapplynum'];
+ if ($_G['setting']['activitycredit'] && $GLOBALS['activity']['credit'] && !$GLOBALS['applied']) {
+ $variable['special_activity']['creditcost'] = $GLOBALS['activity']['credit'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['activitycredit']]['title'];
+ }
+ $setting = array();
+ foreach ($GLOBALS['activity']['ufield']['userfield'] as $field) {
+ $setting[$field] = $_G['cache']['profilesetting'][$field];
+ }
+ $variable['special_activity']['joinfield'] = mobile_core::getvalues($setting, array('/./'), array('fieldid', 'formtype', 'available', 'title', 'formtype', 'choices'));
+ $variable['special_activity']['userfield'] = $GLOBALS['ufielddata']['userfield'];
+ $variable['special_activity']['extfield'] = $GLOBALS['ufielddata']['extfield'];
+ $variable['special_activity']['basefield'] = mobile_core::getvalues($GLOBALS['applyinfo'], array('message', 'payment'));
+ $variable['special_activity']['closed'] = $GLOBALS['activityclose'];
+ if ($GLOBALS['applied'] && $GLOBALS['isverified'] < 2) {
+ if (!$GLOBALS['isverified']) {
+ $variable['special_activity']['status'] = 'wait';
+ } else {
+ $variable['special_activity']['status'] = 'joined';
+ }
+ if (!$GLOBALS['activityclose']) {
+ $variable['special_activity']['button'] = 'cancel';
+ }
+ } elseif (!$GLOBALS['activityclose']) {
+ if ($GLOBALS['isverified'] != 2) {
+ $variable['special_activity']['status'] = 'join';
+ } else {
+ $variable['special_activity']['status'] = 'complete';
+ }
+ $variable['special_activity']['button'] = 'join';
+ }
+ }
+
+ $variable['forum']['password'] = $variable['forum']['password'] ? '1' : '0';
+ foreach($GLOBALS['forum']['threadtypes']['types'] as $typeid => $typename) {
+ $GLOBALS['forum']['threadtypes']['types'][$typeid] = strip_tags($typename);
+ $GLOBALS['forum']['threadtypes']['dbtypes'][$typeid] = $typename;
+ }
+ $variable['forum']['threadtypes'] = $GLOBALS['forum']['threadtypes'];
+ mobile_core::result(mobile_core::variable($variable));
+ }
+
+ function _findimg($string) {
+ return preg_replace_callback('/()/is', array(__CLASS__, 'findimg_callback_parseimg_123'), $string);
+ }
+
+ static function findimg_callback_parseimg_123($matches) {
+ return mobile_api::_parseimg($matches[1], $matches[2], $matches[3]);
+ }
+
+ function _parseimg($before, $img, $after) {
+ $before = stripslashes($before);
+ $after = stripslashes($after);
+ if (!in_array(strtolower(substr($img, 0, 6)), array('http:/', 'https:', 'ftp://'))) {
+ global $_G;
+ $img = $_G['siteurl'] . $img;
+ }
+ return $before . $img . $after;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/config_minapp.php b/mobile/config_minapp.php
new file mode 100644
index 0000000..10c7105
--- /dev/null
+++ b/mobile/config_minapp.php
@@ -0,0 +1,9 @@
+
+ array(
+ 'appid' => 'xxx',
+ 'secret' => 'xxxx'
+ )
+);
diff --git a/mobile/mobile.class.php b/mobile/mobile.class.php
new file mode 100644
index 0000000..436ac7e
--- /dev/null
+++ b/mobile/mobile.class.php
@@ -0,0 +1,524 @@
+ $_v) {
+ $result[$_k] = mobile_core::format($_v);
+ }
+ break;
+ case 'boolean':
+ case 'integer':
+ case 'double':
+ case 'float':
+ $result = (string)$result;
+ break;
+ }
+ return $result;
+ }
+
+ public static function json($encode) {
+ if(!empty($_GET['debug']) && defined('DISCUZ_DEBUG') && DISCUZ_DEBUG) {
+ return debug($encode);
+ }
+ require_once 'source/plugin/mobile/json.class.php';
+ return CJSON::encode($encode);
+ }
+
+ public static function getvalues($variables, $keys, $subkeys = array()) {
+ $return = array();
+ foreach($variables as $key => $value) {
+ foreach($keys as $k) {
+ if($k{0} == '/' && preg_match($k, $key) || $key == $k) {
+ if($subkeys) {
+ $return[$key] = mobile_core::getvalues($value, $subkeys);
+ } else {
+ if(!empty($value) || !empty($_GET['debug']) || (is_numeric($value) && intval($value) === 0 )) {
+ $return[$key] = is_array($value) ? mobile_core::arraystring($value) : (string)$value;
+ }
+ }
+ }
+ }
+ }
+ return $return;
+ }
+
+ static function arraystring($array) {
+ foreach($array as $k => $v) {
+ $array[$k] = is_array($v) ? mobile_core::arraystring($v) : (string)$v;
+ }
+ return $array;
+ }
+
+ //解析客户端表情
+ static function smiley($message) {
+ preg_match_all('/]*\>/', $message, $match);
+ if($match) {
+ foreach($match[0] as $img) {
+ preg_match('/';
+ }
+ $message = str_replace($img, $code, $message);
+ }
+ }
+ return $message;
+ }
+
+ static function variable($variables = array()) {
+ global $_G;
+ if(in_array('mobileoem', $_G['setting']['plugins']['available'])) {
+ $check = C::t('#mobileoem#mobileoem_member')->fetch($_G['uid']);
+ }
+ $globals = array(
+ 'cookiepre' => $_G['config']['cookie']['cookiepre'],
+ 'auth' => $_G['cookie']['auth'],
+ 'saltkey' => $_G['cookie']['saltkey'],
+ 'member_uid' => $_G['member']['uid'],
+ 'member_username' => $_G['member']['username'],
+ 'member_avatar' => avatar($_G['member']['uid'], 'small', true),
+ 'groupid' => $_G['groupid'],
+ 'formhash' => formhash(),
+ 'ismoderator' => $_G['forum']['ismoderator'],
+ 'readaccess' => $_G['group']['readaccess'],
+ 'notice' => array(
+ 'newpush' => $check['newpush'] ? 1 : 0,
+ 'newpm' => dintval($_G['member']['newpm']),
+ 'newprompt' => dintval(($_G['member']['newprompt'] - $_G['member']['category_num']['mypost']) >= 0 ? ($_G['member']['newprompt'] - $_G['member']['category_num']['mypost']) : 0),
+ 'newmypost' => dintval($_G['member']['category_num']['mypost']),
+ )
+ );
+ if(!empty($_GET['submodule']) == 'checkpost') {
+ $apifile = 'source/plugin/mobile/api/'.$_GET['version'].'/sub_checkpost.php';
+ if(file_exists($apifile)) {
+ require_once $apifile;
+ $globals = $globals + mobile_api_sub::getvariable();
+ }
+ }
+ $pluginvariables = array();
+ if(!empty($_G['setting']['mobileapihook'])) {
+ $mobileapihook = unserialize($_G['setting']['mobileapihook']);
+ if(!empty($mobileapihook[$_GET['module']])) {
+ if(!empty($mobileapihook[$_GET['module']]['variables'])) {
+ mobile_core::activeHook($_GET['module'], $mobileapihook, $variables, true);
+ unset($mobileapihook[$_GET['module']]['variables']);
+ }
+ if(!empty($mobileapihook[$_GET['module']])) {
+ $param = array();
+ $pluginvariables = mobile_core::activeHook($_GET['module'], $mobileapihook, $param);
+ }
+ }
+ }
+ $xml = array(
+ 'Version' => $_GET['version'],
+ 'Charset' => strtoupper($_G['charset']),
+ 'Variables' => array_merge($globals, $variables),
+ );
+ if($pluginvariables) {
+ $xml['pluginVariables'] = $pluginvariables;
+ }
+ if(!empty($_G['messageparam'])) {
+ $message_result = lang('plugin/mobile', $_G['messageparam'][0], $_G['messageparam'][2]);
+ if($message_result == $_G['messageparam'][0]) {
+ $vars = explode(':', $_G['messageparam'][0]);
+ if (count($vars) == 2) {
+ $message_result = lang('plugin/' . $vars[0], $vars[1], $_G['messageparam'][2]);
+ $_G['messageparam'][0] = $vars[1];
+ } else {
+ $message_result = lang('message', $_G['messageparam'][0], $_G['messageparam'][2]);
+ }
+ }
+ $message_result = strip_tags($message_result);
+
+ if(defined('IS_WEBVIEW') && IS_WEBVIEW && in_array('mobileoem', $_G['setting']['plugins']['available'])) {
+ include_once DISCUZ_ROOT.'./source/plugin/mobileoem/discuzcode.func.php';
+ include mobileoem_template('common/showmessage');
+ if(!empty($_GET['debug'])) {
+ exit;
+ }
+ $content = ob_get_contents();
+ ob_end_clean();
+ $xml['Variables']['datatype'] = -1;
+ $xml['Variables']['webview_page'] = $content;
+ return $xml;
+ }
+
+ if($_G['messageparam'][4]) {
+ $_G['messageparam'][0] = "custom";
+ }
+ if ($_G['messageparam'][3]['login'] && !$_G['uid']) {
+ $_G['messageparam'][0] .= '//' . $_G['messageparam'][3]['login'];
+ }
+ $xml['Message'] = array("messageval" => $_G['messageparam'][0], "messagestr" => $message_result);
+ if($_GET['mobilemessage']) {
+ $return = mobile_core::json($xml);
+ header("HTTP/1.1 301 Moved Permanently");
+ header("Location:discuz://" . rawurlencode($_G['messageparam'][0]) . "//" . rawurlencode(diconv($message_result, $_G['charset'], "utf-8")) . ($return ? "//" . rawurlencode($return) : '' ));
+ exit;
+ }
+ }
+ return $xml;
+ }
+
+ public static function diconv_array($variables, $in_charset, $out_charset) {
+ foreach($variables as $_k => $_v) {
+ if(is_array($_v)) {
+ $variables[$_k] = mobile_core::diconv_array($_v, $in_charset, $out_charset);
+ } elseif(is_string($_v)) {
+ $variables[$_k] = diconv($_v, $in_charset, $out_charset);
+ }
+ }
+ return $variables;
+ }
+
+ public static function make_cors($request_method, $origin = '') {
+
+ $origin = $origin ? $origin : REQUEST_METHOD_DOMAIN;
+
+ if ($request_method === 'OPTIONS') {
+ header('Access-Control-Allow-Origin:'.$origin);
+
+ header('Access-Control-Allow-Credentials:true');
+ header('Access-Control-Allow-Methods:GET, POST, OPTIONS');
+
+
+ header('Access-Control-Max-Age:1728000');
+ header('Content-Type:text/plain charset=UTF-8');
+ header("status: 204");
+ header('HTTP/1.0 204 No Content');
+ header('Content-Length: 0',true);
+ flush();
+ }
+
+ if ($request_method === 'POST') {
+
+ header('Access-Control-Allow-Origin:'.$origin);
+ header('Access-Control-Allow-Credentials:true');
+ header('Access-Control-Allow-Methods:GET, POST, OPTIONS');
+ }
+
+ if ($request_method === 'GET') {
+
+ header('Access-Control-Allow-Origin:'.$origin);
+ header('Access-Control-Allow-Credentials:true');
+ header('Access-Control-Allow-Methods:GET, POST, OPTIONS');
+ }
+
+ }
+
+ public static function usergroupIconId($groupid) {
+ global $_G;
+ if($_G['cache']['usergroupIconId']) {
+ return $_G['cache']['usergroupIconId']['variable'][$groupid];
+ }
+ loadcache('usergroupIconId');
+ if(!$_G['cache']['usergroupIconId'] || TIMESTAMP - $_G['cache']['usergroupIconId']['expiration'] > 3600) {
+ loadcache('usergroups');
+ $memberi = 0;
+ $return = array();
+ foreach($_G['cache']['usergroups'] as $groupid => $data) {
+ if($data['type'] == 'member') {
+ if(!$memberi && $groupid == $_G['setting']['newusergroupid']) {
+ $memberi = 1;
+ }
+ if($memberi > 0) {
+ $return[$groupid] = $memberi++;
+ }
+ } elseif($data['type'] == 'system' && $groupid < 4) {
+ $return[$groupid] = 'admin';
+ } elseif($data['type'] == 'special') {
+ $return[$groupid] = 'special';
+ }
+ }
+ savecache('usergroupIconId', array('variable' => $return, 'expiration' => TIMESTAMP));
+ return $return[$groupid];
+ } else {
+ return $_G['cache']['usergroupIconId']['variable'][$groupid];
+ }
+ }
+
+ public static function activeHook($module, $mobileapihook, &$param, $isavariables = false) {
+ global $_G;
+ if($isavariables) {
+ $mobileapihook[$module] = array(
+ 'variables' => $mobileapihook[$module]['variables']
+ );
+ }
+ foreach($mobileapihook[$module] as $hookname => $hooks) {
+ foreach($hooks as $plugin => $hook) {
+ if(!$hook['allow'] || !in_array($plugin, $_G['setting']['plugins']['available'])) {
+ continue;
+ }
+ if(!preg_match('/^[\w\_\.]+\.php$/i', $hook['include'])) {
+ continue;
+ }
+ include_once DISCUZ_ROOT . 'source/plugin/' . $plugin . '/' . $hook['include'];
+ if(!class_exists($hook['class'], false)) {
+ continue;
+ }
+ if(!isset($pluginclasses[$hook['class']])) {
+ $pluginclasses[$hook['class']] = new $hook['class'];
+ }
+ if(!method_exists($pluginclasses[$hook['class']], $hook['method'])) {
+ continue;
+ }
+ if(!$isavariables) {
+ $value[$module.'_'.$hookname][$plugin] = call_user_func(array($pluginclasses[$hook['class']], $hook['method']), $param);
+ } else {
+ call_user_func(array($pluginclasses[$hook['class']], $hook['method']), $param);
+ }
+ }
+ }
+ if(!$isavariables) {
+ return $value;
+ }
+ }
+
+ function thumb($aid, $nocache = 0, $w = 140, $h = 140, $type = '') {
+ global $_G;
+ $key = dsign($aid.'|'.$w.'|'.$h);
+ return $_G['siteurl'].'api/mobile/?module=forumimage&aid='.$aid.'&size='.$w.'x'.$h.'&key='.rawurlencode($key).($nocache ? '&nocache=yes' : '').($type ? '&type='.$type : '').'&version=5';
+ }
+}
+
+class base_plugin_mobile {
+
+ 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();
+ }
+ }
+
+ function discuzcode($param) {
+ if(!defined('IN_MOBILE_API') || $param['caller'] != 'discuzcode') {
+ return;
+ }
+ global $_G;
+ if(defined('IS_WEBVIEW') && IS_WEBVIEW && in_array('mobileoem', $_G['setting']['plugins']['available'])) {
+ include_once DISCUZ_ROOT.'./source/plugin/mobileoem/discuzcode.func.php';
+ include_once mobileoem_template('forum/discuzcode');
+ $_G['discuzcodemessage'] = mobileoem_discuzcode($param['param']);
+ } elseif($_GET['version'] == 4) {
+ include_once 'discuzcode.func.php';
+ $_G['discuzcodemessage'] = mobile_discuzcode($param['param']);
+ } else {
+ $_G['discuzcodemessage'] = preg_replace(array(
+ "/\[size=(\d{1,2}?)\]/i",
+ "/\[size=(\d{1,2}(\.\d{1,2}+)?(px|pt)+?)\]/i",
+ "/\[\/size]/i",
+ ), '', $_G['discuzcodemessage']);
+ }
+ if(in_array('soso_smilies', $_G['setting']['plugins']['available'])) {
+ $sosoclass = DISCUZ_ROOT.'./source/plugin/soso_smilies/soso.class.php';
+ if(file_exists($sosoclass)) {
+ include_once $sosoclass;
+ $soso_class = new plugin_soso_smilies;
+ $soso_class->discuzcode($param);
+ }
+ }
+ }
+
+ function global_mobile() {
+ if(!defined('IN_MOBILE_API')) {
+ return;
+ }
+ if(class_exists('mobile_api', false) && method_exists('mobile_api', 'output')) {
+ mobile_api::output();
+ }
+ }
+
+}
+
+class base_plugin_mobile_forum extends base_plugin_mobile {
+
+ function post_mobile_message($param) {
+ if(!defined('IN_MOBILE_API')) {
+ return;
+ }
+ if(class_exists('mobile_api', false) && method_exists('mobile_api', 'post_mobile_message')) {
+ list($message, $url_forward, $values, $extraparam, $custom) = $param['param'];
+ mobile_api::post_mobile_message($message, $url_forward, $values, $extraparam, $custom);
+ }
+ }
+
+ function misc_mobile_message($param) {
+ if(!defined('IN_MOBILE_API')) {
+ return;
+ }
+ if(class_exists('mobile_api', false) && method_exists('mobile_api', 'misc_mobile_message')) {
+ list($message, $url_forward, $values, $extraparam, $custom) = $param['param'];
+ mobile_api::misc_mobile_message($message, $url_forward, $values, $extraparam, $custom);
+ }
+ }
+
+ function viewthread_postbottom_output() {
+ global $_G, $postlist;
+ foreach($postlist as $k => $post) {
+ if($post['mobiletype'] == 1) {
+ $post['message'] .= lang('plugin/mobile', 'mobile_fromtype_ios');
+ } elseif($post['mobiletype'] == 2) {
+ $post['message'] .= lang('plugin/mobile', 'mobile_fromtype_android');
+ } elseif($post['mobiletype'] == 3) {
+ $post['message'] .= lang('plugin/mobile', 'mobile_fromtype_windowsphone');
+ } elseif($post['mobiletype'] == 5) {
+ $threadmessage = $_G['setting']['wechatviewpluginid'] ? lang('plugin/'.$_G['setting']['wechatviewpluginid'], 'lang_wechat_threadmessage', array('tid' => $_G['tid'], 'pid' => $post['pid'])) : array();
+ $post['message'] .= $threadmessage ? $threadmessage : '';
+ }
+ $postlist[$k] = $post;
+ }
+ return array();
+ }
+
+}
+
+class base_plugin_mobile_misc extends base_plugin_mobile {
+
+
+}
+
+class plugin_mobile extends base_plugin_mobile {}
+class plugin_mobile_forum extends base_plugin_mobile_forum {
+ function post_mobile_message($param) {
+ parent::post_mobile_message($param);
+ list($message) = $param['param'];
+ if(in_array($message, array('post_reply_succeed', 'post_reply_mod_succeed'))) {
+ include_once 'source/plugin/mobile/api/4/sub_sendreply.php';
+ }
+ }
+}
+
+class plugin_mobile_misc extends base_plugin_mobile_misc {}
+class mobileplugin_mobile extends base_plugin_mobile {
+ function global_header_mobile() {
+ global $_G;
+ if(in_array('mobileoem', $_G['setting']['plugins']['available'])) {
+ loadcache('mobileoem_data');
+ if($_G['cache']['mobileoem_data']['iframeUrl']) {
+ return;
+ }
+ }
+ if(IN_MOBILE === '1' || IN_MOBILE === 'yes' || IN_MOBILE === true) {
+ return;
+ }
+ }
+}
+class mobileplugin_mobile_forum extends base_plugin_mobile_forum {
+ function post_mobile_message($param) {
+ parent::post_mobile_message($param);
+ list($message) = $param['param'];
+ if(in_array($message, array('post_reply_succeed', 'post_reply_mod_succeed'))) {
+ include_once 'source/plugin/mobile/api/4/sub_sendreply.php';
+ }
+ }
+}
+class mobileplugin_mobile_misc extends base_plugin_mobile_misc {}
+
+class plugin_mobile_connect extends plugin_mobile {
+
+ function login_mobile_message($param) {
+ global $_G;
+ if(substr($_GET['referer'], 0, 7) == 'Mobile_') {
+ if($_GET['referer'] == 'Mobile_iOS' || $_GET['referer'] == 'Mobile_Android') {
+ $_GET['mobilemessage'] = 1;
+ }
+ $param = array('con_auth_hash' => $_G['cookie']['con_auth_hash']);
+ mobile_core::result(mobile_core::variable($param));
+ }
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/mobile.php b/mobile/mobile.php
new file mode 100644
index 0000000..666f716
--- /dev/null
+++ b/mobile/mobile.php
@@ -0,0 +1,77 @@
+ 4,
+);
+
+if(!isset($_GET['module']) || !in_array($_GET['module'], $modules)) {
+ mobile_core::result(array('error' => 'module_not_exists'));
+}
+$_GET['version'] = !empty($_GET['version']) ? intval($_GET['version']) : (!$defaultversions[$_GET['module']] ? 1 : $defaultversions[$_GET['module']]);
+$_GET['version'] = $_GET['version'] > MOBILE_PLUGIN_VERSION ? MOBILE_PLUGIN_VERSION : $_GET['version'];
+
+if(empty($_GET['module']) || empty($_GET['version']) || !preg_match('/^[\w\.]+$/', $_GET['module']) || !preg_match('/^[\d\.]+$/', $_GET['version'])) {
+ mobile_core::result(array('error' => 'param_error'));
+}
+
+if($_GET['module'] == 'extends') {
+ require_once 'source/plugin/mobile/mobile_extends.php';
+ return;
+}
+
+if(!empty($_GET['_auth'])) {
+ unset($_GET['formhash'], $_POST['formhash']);
+}
+
+$apifile = 'source/plugin/mobile/api/'.$_GET['version'].'/'.$_GET['module'].'.php';
+
+if(file_exists($apifile)) {
+ require_once $apifile;
+} else {
+ if($_GET['version'] > 1) {
+ for($i = $_GET['version']; $i >= 1; $i--) {
+ $apifile = 'source/plugin/mobile/api/'.$i.'/'.$_GET['module'].'.php';
+ if(file_exists($apifile)) {
+ $_GET['version'] = $i;
+ require_once $apifile;
+ break;
+ } elseif($i==1 && !file_exists($apifile)) {
+ mobile_core::result(array('error' => 'module_not_exists'));
+ }
+ }
+ } else {
+ mobile_core::result(array('error' => 'module_not_exists'));
+ }
+}
+
+?>
diff --git a/mobile/table/table_forum_forum_ext.php b/mobile/table/table_forum_forum_ext.php
new file mode 100644
index 0000000..00574f0
--- /dev/null
+++ b/mobile/table/table_forum_forum_ext.php
@@ -0,0 +1,76 @@
+_table = 'forum_forum';
+ $this->_pk = 'fid';
+ $this->_pre_cache_key = 'forum_forum_';
+
+ parent::__construct();
+ }
+
+ public function fetch_all_for_fup_grouplist($orderby = 'displayorder', $fieldarray = array(), $num = 1, $fids = array(), $sort = 0, $getcount = 0, $fups = array()) {
+ if($fieldarray && is_array($fieldarray)) {
+ $fieldadd = '';
+ foreach($fieldarray as $field) {
+ $fieldadd .= $field.', ';
+ }
+ } else {
+ $fieldadd = 'ff.*, ';
+ }
+ $start = 0;
+ if(is_array($num)) {
+ list($start, $snum) = $num;
+ } else {
+ $snum = $num;
+ }
+
+ $addsql = '';
+ if(!empty($fups)) {
+ $addsql = 'AND '.DB::field('fup', $fups);
+ }
+
+ $orderbyarray = array('displayorder' => 'f.displayorder DESC', 'dateline' => 'ff.dateline DESC', 'lastupdate' => 'ff.lastupdate DESC', 'membernum' => 'ff.membernum DESC', 'thread' => 'f.threads DESC', 'activity' => 'f.commoncredits DESC');
+ $useindex = $orderby == 'displayorder' ? 'USE INDEX(fup_type)' : '';
+ $orderby = !empty($orderby) && $orderbyarray[$orderby] ? "ORDER BY ".$orderbyarray[$orderby] : '';
+ $limitsql = $num ? "LIMIT $start, $snum " : '';
+ $field = $sort ? 'fup' : 'fid';
+ $fids = $fids && is_array($fids) ? 'f.'.$field.' IN ('.dimplode($fids).')' : '';
+ if(empty($fids)) {
+ $levelsql = " AND f.level>'-1'";
+ }
+
+ $fieldsql = $fieldadd.' f.fid, f.name, f.threads, f.posts, f.todayposts, f.level as flevel ';
+ if($getcount) {
+ return DB::result_first("SELECT count(*) FROM ".DB::table($this->_table)." f $useindex WHERE".($fids ? " $fids AND " : '')." f.type='sub' " .$addsql. " AND f.status=3 $levelsql");
+ }
+ return DB::fetch_all("SELECT $fieldsql FROM ".DB::table($this->_table)." f $useindex LEFT JOIN ".DB::table("forum_forumfield")." ff ON ff.fid=f.fid WHERE".($fids ? " $fids AND " : '')." f.type='sub' " .$addsql. " AND f.status=3 $levelsql $orderby $limitsql");
+ }
+
+ public function fetch_all_search_group($fups, $conditions, $start = 0, $limit = 50) {
+ if(!empty($conditions) && !is_string($conditions)) {
+ return array();
+ }
+ $typesql = 'type=\'sub\'';
+ $addsql = '';
+ if(!empty($fups)) {
+ $addsql = 'AND '.DB::field('fup', $fups);
+ }
+ return DB::fetch_all("SELECT fid FROM ".DB::table($this->_table)." WHERE status='3' ".$addsql." AND $typesql %i ".DB::limit($start, $limit), array($conditions));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/table/table_forum_groupuser_ext.php b/mobile/table/table_forum_groupuser_ext.php
new file mode 100644
index 0000000..fb345f6
--- /dev/null
+++ b/mobile/table/table_forum_groupuser_ext.php
@@ -0,0 +1,65 @@
+_table = 'forum_groupuser';
+ $this->_pk = '';
+
+ parent::__construct();
+ }
+
+ public function update_for_user($uid, $fid, $threads = null, $replies = null, $level = null, $nickname = null, $mobile = null) {
+ if(empty($uid) || empty($fid)) {
+ return array();
+ }
+ $sqladd = $threads !== null ? 'threads='.intval($threads) : '';
+ if($replies !== null) {
+ $sqladd .= ($sqladd ? ', ' : '').'replies='.intval($replies);
+ }
+ if($level !== null) {
+ $sqladd .= ($sqladd ? ', ' : '').'level='.intval($level);
+ }
+
+ if($nickname !== null) {
+ $sqladd .= ($sqladd ? ', ' : '').DB::field('nickname', $nickname);
+ }
+ if($mobile !== null) {
+ $sqladd .= ($sqladd ? ', ' : '').DB::field('mobile', $mobile);
+ }
+ DB::query("UPDATE %t SET $sqladd WHERE fid=%d AND ".DB::field('uid', $uid), array($this->_table, $fid));
+ }
+
+ public function fetch_all_by_fids($fids, $usekey = true) {
+ if(empty($fids)) {
+ return array();
+ }
+
+ $query = DB::query("SELECT * FROM %t WHERE fid IN(%n) AND level IN(1,2,3,4)", array($this->_table, $fids));
+
+ $groupuserlist = array();
+ while($groupuser = DB::fetch($query)) {
+ if($usekey) {
+ $groupuserlist[$groupuser['fid']][$groupuser['uid']] = $groupuser;
+ } else {
+ $groupuserlist[$groupuser['fid']][] = $groupuser;
+ }
+ }
+
+ return $groupuserlist;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/mobile/table/table_weixin_minapp_user.php b/mobile/table/table_weixin_minapp_user.php
new file mode 100644
index 0000000..9940009
--- /dev/null
+++ b/mobile/table/table_weixin_minapp_user.php
@@ -0,0 +1,28 @@
+_table = 'weixin_minapp_user';
+ $this->_pk = 'uid';
+ $this->_pre_cache_key = 'weixin_minapp_user_';
+ $this->_cache_ttl = 0;
+
+ parent::__construct();
+ }
+
+ public function fetch_by_openid($openid) {
+ return DB::fetch_first("SELECT * FROM ".DB::table($this->_table)." WHERE ".DB::field('openid', $openid));
+ }
+}
\ No newline at end of file