public function output() { if (isset($GET['applylistsubmit']) && 'yes' === $GET['applylistsubmit']) { BigAppAPI::outputOperation(); } else { BigAppAPI::outputList(); } }
function common() { if ($_GET['action'] == 'logout') { BigAppAPI::logout(); } else { if ($_GET['action'] == 'login') { BigAppAPI::login(); } } echo BIGAPPJSON::encode(array('error_code' => 1, 'error_msg' => lang('plugin/bigapp', 'invalid_param'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'invalid_param')))); die(0); }
public function output() { global $_G; $only_count = false; if (isset($_GET["only_count"]) && $_GET["only_count"] == 1) { $only_count = true; } if ($only_count) { $variable = array("count" => $GLOBALS['count']); bigapp_core::result(bigapp_core::variable($variable)); return; } $variable = array("count" => $GLOBALS['count'], "list" => array_values(mobile_core::getvalues($GLOBALS['list'], array('/^.+?$/'), array('fuid', 'fusername', 'note', 'dateline', 'gid')))); $uidarr = array(); foreach ($variable["list"] as &$item) { $uid = $item["fuid"]; $username = $item["fusername"]; unset($item["fuid"]); unset($item["fusername"]); $item["uid"] = $uid; $item["username"] = $username; $item["avatar"] = avatar($uid, 'big', 'true'); $uidarr[] = $uid; } //////////////////////////////// // map group $ugmap = BigAppAPI::get_user_group_map($uidarr); foreach ($variable["list"] as &$item) { $uid = $item["uid"]; $item["groupname"] = "unknown"; if (!isset($ugmap[$uid])) { $item["groupid"] = 0; } else { $gid = $ugmap[$uid]; $item["groupid"] = $gid; if (isset($_G['cache']['usergroups'][$gid]['grouptitle'])) { $item['groupname'] = preg_replace('/<.*?\\>/', '', $_G['cache']['usergroups'][$gid]['grouptitle']); } } } //////////////////////////////// bigapp_core::result(bigapp_core::variable($variable)); }
public static function common() { global $_G; $avatarpath = $_G['setting']['attachdir']; $filetype = null; $imgtype = array(1 => '.gif', 2 => '.jpg', 3 => '.png'); foreach ($imgtype as $_filetype) { if (file_exists($avatarpath . './temp/upload' . $_G['uid'] . $_filetype)) { $filetype = $_filetype; break; } } if (is_null($filetype)) { self::error('api_uploadavatar_unavailable_pic'); } $tmpavatar = $avatarpath . './temp/upload' . $_G['uid'] . $filetype; $tmpavatarbig = './temp/upload' . $_G['uid'] . 'big' . $filetype; $tmpavatarmiddle = './temp/upload' . $_G['uid'] . 'middle' . $filetype; $tmpavatarsmall = './temp/upload' . $_G['uid'] . 'small' . $filetype; self::$tmpavatar = $tmpavatar; self::$tmpavatarbig = $avatarpath . $tmpavatarbig; self::$tmpavatarmiddle = $avatarpath . $tmpavatarmiddle; self::$tmpavatarsmall = $avatarpath . $tmpavatarsmall; }
function _doSearch($variable, $key, &$ret) { if (function_exists('iconv')) { $keyWord = iconv('UTF-8', BIGAPP_CHARSET . '//ignore', $_GET['keyword']); } else { $keyWord = mb_convert_encoding($_GET['keyword'], BIGAPP_CHARSET, 'UTF-8'); } foreach ((array) $variable[$key] as $item) { if ($item['type'] !== 'group' && preg_match('/' . $keyWord . '/', $item['name'])) { $tmp = $item; if (isset($tmp['forums'])) { unset($tmp['forums']); } if (isset($tmp['subs'])) { unset($tmp['subs']); } $ret[] = $tmp; } isset($item['forums']) && BigAppAPI::_doSearch($item, 'forums', $ret); isset($item['subs']) && BigAppAPI::_doSearch($item, 'subs', $ret); } }
protected function _getDetails(&$list) { //check whether thread list image mode is open global $_G; if (isset($_G['setting']['bigapp_settings']) && is_string($_G['setting']['bigapp_settings'])) { $_G['setting']['bigapp_settings'] = unserialize($_G['setting']['bigapp_settings']); } if (isset($_G['setting']['bigapp_settings']['threadlist_image_mode']) && !$_G['setting']['bigapp_settings']['threadlist_image_mode']) { return; } $tids = array(); foreach ($list as $l) { $tids[] = $l['tid']; } if (empty($tids)) { return; } $sql = 'SELECT pid, tid, first FROM ' . DB::table('forum_post') . ' WHERE tid IN (' . implode(', ', $tids) . ')'; $query = DB::query($sql); $threadInfo = array(); $pids = array(); while ($tmp = DB::fetch($query)) { if (!!$tmp['first']) { if (isset($pids[$threadInfo[$tmp['tid']]['pid']])) { unset($pids[$threadInfo[$tmp['tid']]['pid']]); } $threadInfo[$tmp['tid']] = array('pid' => $tmp['pid']); $pids[$tmp['pid']] = $tmp['pid']; } } if (empty($pids)) { return; } $pids = array_values($pids); $sql = 'SELECT pid, tid, message FROM ' . DB::table('forum_post') . ' WHERE pid IN (' . implode(', ', $pids) . ')'; $query = DB::query($sql); while ($tmp = DB::fetch($query)) { $threadInfo[$tmp['tid']]['message'] = $tmp['message']; } $sql = 'SELECT aid, tid, tableid, pid FROM ' . DB::table('forum_attachment') . ' WHERE pid IN (' . implode(', ', $pids) . ')'; $tbIdx = array(); $query = DB::query($sql); while ($tmp = DB::fetch($query)) { if ($tmp['tableid'] < 10) { $threadInfo[$tmp['tid']]['aid'][] = $tmp['aid']; $tbIdx[$tmp['tableid']][] = $tmp['aid']; } } foreach ($tbIdx as $tableId => $aids) { $sql = 'SELECT aid, tid, attachment, description, remote, isimage FROM ' . DB::table('forum_attachment_' . $tableId) . ' WHERE aid IN (' . implode(', ', $aids) . ')'; $query = DB::query($sql); while ($tmp = DB::fetch($query)) { $isImage = $tmp['isimage']; if ($tmp['isimage'] && !$_G['setting']['attachimgpost']) { $isImage = 0; } if ($isImage) { $threadInfo[$tmp['tid']]['attachments'][$tmp['aid']] = array('attachment' => $tmp['attachment'], 'description' => $tmp['description'], 'remote' => $tmp['remote'], 'isimage' => $isImage); } } } BigAppAPI::_getPictures($threadInfo); foreach ($list as &$l) { $l['attachment_urls'] = array(); $l['message_abstract'] = ''; if (isset($threadInfo[$l['tid']]['message'])) { $l['message_abstract'] = $threadInfo[$l['tid']]['message']; } if (isset($threadInfo[$l['tid']]['attachment_urls'])) { $l['attachment_urls'] = $threadInfo[$l['tid']]['attachment_urls']; } if (true === BigAppConf::$enablePicOpt) { foreach ($l['attachment_urls'] as &$_url) { if (ApiUtils::isOptFix($_url)) { $_url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$thumbSize) . '&url=' . urlencode($_url); $_url = str_replace('source/plugin/mobile/', '', $_url); $_url = str_replace('source/plugin/bigapp/', '', $_url); } } unset($_url); } } unset($l); }
* @Brief * @author youzu * @version 1 * @date 2015-04-03 */ define('APPTYPEID', 2); define('CURSCRIPT', 'forum'); require './source/class/class_core.php'; require './source/function/function_forum.php'; $modarray = array('ajax', 'announcement', 'attachment', 'forumdisplay', 'group', 'image', 'index', 'medal', 'misc', 'modcp', 'notice', 'post', 'redirect', 'relatekw', 'relatethread', 'rss', 'topicadmin', 'trade', 'viewthread', 'tag', 'collection', 'guide'); $modcachelist = array('index' => array('announcements', 'onlinelist', 'forumlinks', 'heats', 'historyposts', 'onlinerecord', 'userstats', 'diytemplatenameforum'), 'forumdisplay' => array('smilies', 'announcements_forum', 'globalstick', 'forums', 'onlinelist', 'forumstick', 'threadtable_info', 'threadtableids', 'stamps', 'diytemplatenameforum'), 'viewthread' => array('smilies', 'smileytypes', 'forums', 'usergroups', 'stamps', 'bbcodes', 'smilies', 'custominfo', 'groupicon', 'stamps', 'threadtableids', 'threadtable_info', 'posttable_info', 'diytemplatenameforum'), 'redirect' => array('threadtableids', 'threadtable_info', 'posttable_info'), 'post' => array('bbcodes_display', 'bbcodes', 'smileycodes', 'smilies', 'smileytypes', 'domainwhitelist', 'albumcategory'), 'space' => array('fields_required', 'fields_optional', 'custominfo'), 'group' => array('grouptype', 'diytemplatenamegroup')); $mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod']; define('CURMODULE', $mod); $cachelist = array(); if (isset($modcachelist[CURMODULE])) { $cachelist = $modcachelist[CURMODULE]; $cachelist[] = 'plugin'; $cachelist[] = 'pluginlanguage_system'; } if (C::app()->var['mod'] == 'group') { $_G['basescript'] = 'group'; } C::app()->cachelist = $cachelist; C::app()->init(); loadforum(); set_rssauth(); if (!class_exists('BigAppAPI', false) || !method_exists('BigAppAPI', 'process')) { bigapp_core::result(array('error' => 'module_not_exists')); } BigAppAPI::process();
function _findimg($string) { return preg_replace_callback('/(<img src=\\")(.+?)(\\".*?\\>)/is', function ($matches) { return BigAppAPI::_parseimg($matches[1], $matches[2], $matches[3]); }, $string); }
protected function _getDetails(&$list) { //check whether thread list image mode is open global $_G; if (isset($_G['setting']['bigapp_settings']) && is_string($_G['setting']['bigapp_settings'])) { $_G['setting']['bigapp_settings'] = unserialize($_G['setting']['bigapp_settings']); } if (isset($_G['setting']['bigapp_settings']['threadlist_image_mode']) && !$_G['setting']['bigapp_settings']['threadlist_image_mode']) { return; } $tids = array(); foreach ($list as $l) { $tids[] = $l['tid']; } if (empty($tids)) { return; } $_tids = $tids; $tids = array(); $expire = 5; $threadInfoCache = array(); foreach ($_tids as $tid) { $cacheKey = 'bigapptsum' . $tid; loadcache($cacheKey); if (isset($_G['cache'][$cacheKey]) && TIMESTAMP - $_G['cache'][$cacheKey]['expiration'] <= $expire) { $threadInfoCache[$tid] = $_G['cache'][$cacheKey]['variable']; } else { $tids[] = $tid; } } $threadInfo = array(); if (!empty($tids)) { runlog('bigapp', 'such tids has no cache, get them from database [ tids: ' . json_encode($tids) . ' ]'); $sql = 'SELECT pid, tid, first FROM ' . DB::table('forum_post') . ' WHERE tid IN (' . implode(', ', $tids) . ')'; $query = DB::query($sql); $pids = array(); while ($tmp = DB::fetch($query)) { //if(!isset($threadInfo[$tmp['tid']]) || $threadInfo[$tmp['tid']]['pid'] > $tmp['pid']){ if (!!$tmp['first']) { if (isset($pids[$threadInfo[$tmp['tid']]['pid']])) { unset($pids[$threadInfo[$tmp['tid']]['pid']]); } $threadInfo[$tmp['tid']] = array('pid' => $tmp['pid']); $pids[$tmp['pid']] = $tmp['pid']; } } if (!empty($pids)) { $pids = array_values($pids); $sql = 'SELECT pid, tid, message FROM ' . DB::table('forum_post') . ' WHERE pid IN (' . implode(', ', $pids) . ')'; $query = DB::query($sql); while ($tmp = DB::fetch($query)) { $threadInfo[$tmp['tid']]['message'] = $tmp['message']; } $sql = 'SELECT aid, tid, tableid, pid FROM ' . DB::table('forum_attachment') . ' WHERE pid IN (' . implode(', ', $pids) . ')'; $tbIdx = array(); $query = DB::query($sql); while ($tmp = DB::fetch($query)) { if ($tmp['tableid'] < 10) { $threadInfo[$tmp['tid']]['aid'][] = $tmp['aid']; $tbIdx[$tmp['tableid']][] = $tmp['aid']; } } foreach ($tbIdx as $tableId => $aids) { $sql = 'SELECT aid, tid, attachment, description, remote, isimage FROM ' . DB::table('forum_attachment_' . $tableId) . ' WHERE aid IN (' . implode(', ', $aids) . ')'; $query = DB::query($sql); while ($tmp = DB::fetch($query)) { $isImage = $tmp['isimage']; if ($tmp['isimage'] && !$_G['setting']['attachimgpost']) { $isImage = 0; } if ($isImage) { $threadInfo[$tmp['tid']]['attachments'][$tmp['aid']] = array('attachment' => $tmp['attachment'], 'description' => $tmp['description'], 'remote' => $tmp['remote'], 'isimage' => $isImage); } } } BigAppAPI::_getPictures($threadInfo); foreach ($threadInfo as $tid => $tInfo) { runlog('bigapp', 'save thread sum [ tid: ' . $tid . ' ]'); savecache('bigapptsum' . $tid, array('variable' => $tInfo, 'expiration' => TIMESTAMP)); } } } foreach ($threadInfoCache as $tid => $tInfo) { if (!isset($threadInfo[$tid])) { $threadInfo[$tid] = $tInfo; } } foreach ($list as &$l) { $l['attachment_urls'] = array(); $l['message_abstract'] = ''; if (isset($threadInfo[$l['tid']]['message'])) { $l['message_abstract'] = $threadInfo[$l['tid']]['message']; } if (isset($threadInfo[$l['tid']]['attachment_urls'])) { $l['attachment_urls'] = $threadInfo[$l['tid']]['attachment_urls']; } if (true === BigAppConf::$enablePicOpt) { foreach ($l['attachment_urls'] as &$_url) { if (ApiUtils::isOptFix($_url)) { $_url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$thumbSize) . '&url=' . urlencode($_url); $_url = str_replace('source/plugin/mobile/', '', $_url); $_url = str_replace('source/plugin/bigapp/', '', $_url); } } unset($_url); } } unset($l); }
function process() { global $_G; //1. try to get user mask $authority = array(); if ($_G['uid'] && !empty($_G['member']['accessmasks'])) { loadcache('plugin'); $bucketNum = 100003; $expire = 5; $userBucket = $_G['uid'] % $bucketNum; loadcache('bigapp_authority_' . $userBucket); if (!isset($_G['cache']['bigapp_authority_' . $userBucket]) || TIMESTAMP - $_G['cache']['bigapp_authority_' . $userBucket]['expiration'] > $expire) { $sql = 'SELECT uid, fid, allowview FROM ' . DB::table('forum_access') . ' WHERE uid % ' . $bucketNum . ' = ' . $userBucket; $query = DB::query($sql); $authorities = array(); while ($tmp = DB::fetch($query)) { $authorities[$tmp['uid']][$tmp['fid']] = $tmp['allowview']; } savecache('bigapp_authority_' . $userBucket, array('variable' => $authorities, 'expiration' => TIMESTAMP)); } else { $authorities = $_G['cache']['bigapp_authority_' . $userBucket]['variable']; } if (isset($authorities[$_G['uid']])) { $authority = $authorities[$_G['uid']]; } } //2. try to get all forums $forums = array(); $cacheKey = 'bigapp_forumnav'; if (isset($_G['adminid'])) { $cacheKey = 'bigapp_forumnav_' . $_G['adminid']; } loadcache($cacheKey); $expire = 5; if (!isset($_G['cache'][$cacheKey]) || empty($_G['cache'][$cacheKey]) || TIMESTAMP - $_G['cache'][$cacheKey]['expiration'] > $expire) { //need update all forums from database $sql = "SELECT f.fid, f.type, f.name, f.fup, f.status, f.threads, f.posts, f.todayposts, f.allowpostspecial, f.allowspecialonly, " . "ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts, ff.icon, ff.description, ff.moderators FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff USING(fid) WHERE f.status='1' ORDER BY f.type, f.displayorder"; $query = DB::query($sql); while ($forum = DB::fetch($query)) { if ($forum['redirect'] || $forum['password']) { continue; } if (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm'])) { if ($forum['threadsorts']) { $forum['threadsorts'] = bigapp_core::getvalues(unserialize($forum['threadsorts']), array('required', 'types')); } if ($forum['threadtypes']) { $forum['threadtypes'] = unserialize($forum['threadtypes']); $unsetthreadtype = false; if ($_G['adminid'] == 3 && strpos($forum['moderators'], $_G['username']) === false) { $unsetthreadtype = true; } if ($_G['adminid'] == 0) { $unsetthreadtype = true; } if ($unsetthreadtype) { foreach ($forum['threadtypes']['moderators'] as $k => $v) { if (!empty($v)) { unset($forum['threadtypes']['types'][$k]); } } } $flag = 0; foreach ($forum['threadtypes']['types'] as $k => $v) { if ($k == 0) { $flag = 1; break; } } if ($flag == 1) { krsort($forum['threadtypes']['types']); } $forum['threadtypes'] = bigapp_core::getvalues($forum['threadtypes'], array('required', 'types')); } loadforum($forum['fid'], null); if (!empty($_G['forum']['threadtypes']) || !empty($_GET['debug'])) { $forum['threadtypes_detail'] = $_G['forum']['threadtypes']; unset($forum['threadtypes_detail']['types']); foreach ($_G['forum']['threadtypes']['types'] as $typeId => $typeValue) { $typeValue = preg_replace('/<.*?>/', '', $typeValue); if (isset($_G['forum']['threadtypes']['moderators'][$typeId]) && !empty($_G['forum']['threadtypes']['moderators'][$typeId])) { if (isset($_G['adminid']) && $_G['adminid'] != $_G['forum']['threadtypes']['moderators'][$typeId]) { continue; } } $forum['threadtypes_detail']['types'][] = array('typeid' => $typeId, 'typename' => $typeValue); } unset($forum['threadtypes_detail']['icons']); foreach ($_G['forum']['threadtypes']['icons'] as $typeId => $icon) { $forum['threadtypes_detail']['icons'][] = array('typeid' => $typeId, 'typeicon' => $icon); } } $moderators = explode("\t", $forum['moderators']); if (!is_array($moderators) || 0 === count($moderators)) { $forum['moderators'] = array(); } else { foreach ($moderators as &$_v) { $_v = "'{$_v}'"; } unset($_v); $sql = 'SELECT username, uid FROM ' . DB::table('common_member') . ' WHERE username IN (' . implode(', ', $moderators) . ')'; $subQuery = DB::query($sql); $forum['moderators'] = array(); while ($moderator = DB::fetch($subQuery)) { $forum['moderators'][] = array('uid' => $moderator['uid'], 'username' => $moderator['username']); } } $forums[] = bigapp_core::getvalues($forum, array('fid', 'type', 'name', 'fup', 'viewperm', 'postperm', 'status', 'threadsorts', 'threadtypes', 'threadtypes_detail', 'icon', 'description', 'threads', 'allowpostspecial', 'allowspecialonly', 'posts', 'todayposts', 'moderators')); } } //add result to syscache savecache($cacheKey, array('variable' => $forums, 'expiration' => TIMESTAMP)); } else { $forums = $_G['cache'][$cacheKey]['variable']; } //3. judge which forum should be displayed $retData = array(); if (!empty($authority)) { foreach ($forums as $forum) { if (isset($authority[$forum['fid']]) && -1 == $authority[$forum['fid']]) { continue; } $retData[] = $forum; } } else { $retData = $forums; } //4. AppDegin 论坛视图设置过滤 $res = C::t('common_setting')->fetch("bigapp_view_2", true); if (isset($res['displayid']) && isset($res['forbiddenid'])) { //获取论坛视图配置 $displayArr = array(); $forbiddenArr = array(); if (!empty($res['displayid'])) { $displayArr = explode(',', $res['displayid']); } if (!empty($res['forbiddenid'])) { $forbiddenArr = explode(',', $res['forbiddenid']); } $retData = BigAppAPI::_filterResult($retData, $displayArr, $forbiddenArr); } $activityForum = array(); foreach ($retData as $forum) { if (isset($_G['group']['allowpostactivity']) && $_G['group']['allowpostactivity'] && $forum['allowpostspecial'] & 8) { $activityForum[] = $forum; } } foreach ($retData as &$value) { BigAppAPI::_textDescription($value); } unset($value); $variable['forums'] = array_values(BigAppAPI::_sortResult($retData)); $variable['activity_forums'] = $activityForum; if (isset($_G['setting']['bigapp_settings'])) { $_G['setting']['bigapp_settings'] = unserialize($_G['setting']['bigapp_settings']); } $res = C::t('common_setting')->fetch("bigapp_view_2", true); if (isset($res[0]) && empty($res[0])) { //没有获取论坛视图配置 $variable['display_style'] = strval(isset($_G['setting']['bigapp_settings']['display_style']) ? $_G['setting']['bigapp_settings']['display_style'] : 0); } else { $variable['display_style'] = isset($res["type"]) ? strval(intval($res["type"]) - 1) : '0'; } bigapp_core::result(bigapp_core::variable($variable)); }
* @file forumnav.php * @Brief * @author youzu * @version 1 * @date 2015-04-03 */ if (!defined('IN_MOBILE_API')) { exit('Access Denied'); } require_once dirname(dirname(dirname(__FILE__))) . '/bigappjson.class.php'; $_GET['mod'] = 'logging'; $_GET['action'] = !empty($_GET['action']) ? $_GET['action'] : 'login'; $params = BigAppAPI::parseParam(); $state = time(); if ($params['is_first']) { $_GET['code'] = BigAppAPI::getOauthCode($params['user_name'], $params['password'], $state); $_GET['state'] = $state; $_GET['t'] = 'yz'; } else { $_GET['nickname'] = $params['nickname']; $_GET['code'] = $params['code']; $_GET['t'] = 'yz'; } require_once 'member.php'; class BigAppAPI { function common() { global $_G; if (true === BigAppConf::$debug) { $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
public function output() { global $_G; $tmp = $_G['setting']['bigapp_settings_checkin']; if (isset($_G['setting']['bigapp_settings_checkin']) && is_string($_G['setting']['bigapp_settings_checkin'])) { $tmp = unserialize($_G['setting']['bigapp_settings_checkin']); } $succRet['data'] = $tmp; $uid = $_REQUEST['uid']; $date = date('Ymd'); $last_date = date("Ymd", strtotime("-1 day")); $type = $_REQUEST['check']; if ($uid == "") { $variable = array("status" => strval(1), "checkin_enabled" => strval($succRet['data']['enabled'])); echo BIGAPPJSON::encode(array('Message' => array('messageval' => '1', 'messagestr' => 'success'), 'Variables' => $variable)); die(0); //bigapp_core::result(bigapp_core::variable($variable)); } //获取当前用户的cookie userid $cookie_uid = BigAppAPI::getCookieUserId(); if ($cookie_uid !== $uid) { $variable = array("status" => strval(0), "message" => 'checkin failed'); echo BIGAPPJSON::encode(array('Message' => array('messageval' => '0', 'messagestr' => 'unauthorized user'), 'Variables' => $variable)); die(0); } //合法的用户id $uid = $cookie_uid; try { $value = BigAppAPI::getInfo($uid, $date); $has_checked = empty($value) ? '0' : '1'; if ($type == '1') { if ($succRet['data']['enabled'] == '1' && $has_checked == '1') { $checked = "1"; } else { $checked = "0"; } $variable = array("status" => strval(1), "checkin_enabled" => strval($succRet['data']['enabled']), "checked" => strval($checked)); echo BIGAPPJSON::encode(array('Message' => array('messageval' => '1', 'messagestr' => 'success'), 'Variables' => $variable)); die(0); } else { if ($succRet['data']['enabled'] == '1' && $has_checked == '0') { $value = BigAppAPI::getInfo($uid, $last_date); $has_checked_yesterday = empty($value) ? '0' : '1'; if ($has_checked_yesterday == '1') { //昨天签到过,修正用户签到信息 $value = BigAppAPI::getInfo($uid, $last_date); $days = $value['days'] + 1; $data = array("date" => $date, "days" => $days); $ret = DB::update('bigapp_checkin', $data, array('uid' => $uid, "date" => $last_date)); } else { //昨天未签到,重置用户签到信息 DB::delete('bigapp_checkin', DB::field("uid", $uid)); $data = array("uid" => $uid, "date" => $date, "days" => '1'); DB::insert('bigapp_checkin', $data, $return_insert_id); } $value = BigAppAPI::getInfo($uid, $date); $credit = $succRet['data']['credit_plus']; if ($value['days'] > 0 && $value['days'] % $succRet['data']['bonus_day'] == 0) { //加上连续签到奖励 $credit = $credit + $succRet['data']['bonus_plus']; } $ret = BigAppAPI::updateCredits($uid, $credit, $succRet['data']['credit']); if ($ret) { if (!isset($succRet['data']['credit'])) { $title['title'] = ""; } else { $index = substr($succRet['data']['credit'], -1); $i = 1; foreach ($_G['setting']['extcredits'] as $key => $credits_value) { if ($i++ < $index) { continue; } $title = $_G['setting']['extcredits'][$key]; break; } } $variable = array("status" => strval(1), "days" => $value['days'], "credit" => $credit, "bonus_days" => $succRet['data']['bonus_day'], "bonus_plus" => $succRet['data']['bonus_plus'], "title" => $title['title'], "message" => 'checked in success'); echo BIGAPPJSON::encode(array('Message' => array('messageval' => '1', 'messagestr' => 'checked in success'), 'Variables' => $variable)); die(0); } else { $variable = array("status" => strval(1), "message" => 'credit update failed'); echo BIGAPPJSON::encode(array('Message' => array('messageval' => '1', 'messagestr' => 'credit update failed'), 'Variables' => $variable)); die(0); } } else { if ($succRet['data']['enabled'] == '0') { $variable = array("status" => strval(1), "message" => 'checkin not support'); echo BIGAPPJSON::encode(array('Message' => array('messageval' => '1', 'messagestr' => 'checkin not support'), 'Variables' => $variable)); die(0); } else { $variable = array("status" => strval(1), "message" => 'has checked in'); echo BIGAPPJSON::encode(array('Message' => array('messageval' => '1', 'messagestr' => 'has checked in'), 'Variables' => $variable)); die(0); } } } echo BIGAPPJSON::encode(array('Message' => array('messageval' => '1', 'messagestr' => 'success'), 'Variables' => $variable)); die(0); } catch (Exception $e) { $variable = array("status" => strval(1), "message" => 'checkin not support'); echo BIGAPPJSON::encode(array('Message' => array('messageval' => '0', 'messagestr' => $e->getMessage()), 'Variables' => $variable)); die(0); } //bigapp_core::result(bigapp_core::variable($variable)); }
protected function _getDetails(&$list) { global $_G; $tids = array(); $tbTids = array(); foreach ($list as $l) { $tids[] = $l['tid']; if (0 == $l['posttableid']) { $table = DB::table('forum_post'); } else { $table = DB::table('forum_post') . '_' . $l['posttableid']; } $tbTids[$table][] = $l['tid']; } if (empty($tids)) { return; } ############################################ $sqls = array(); foreach ($tbTids as $table => &$tids) { $tids = array_unique($tids); $sql = 'SELECT pid, tid, message FROM ' . $table . ' WHERE tid IN (' . implode(', ', $tids) . ') AND first = 1'; $sqls[] = $sql; } unset($tids); if (empty($sqls)) { return; } $threadInfo = array(); $pids = array(); foreach ($sqls as $sql) { runlog('bigapp', 'get message from forum_thread, sql: ' . $sql); $query = DB::query($sql); while ($tmp = DB::fetch($query)) { $threadInfo[$tmp['tid']] = array('pid' => $tmp['pid'], 'tid' => $tmp['tid'], 'message' => $tmp['message']); $pids[$tmp['pid']] = $tmp['pid']; } } ############################################ if (empty($pids)) { return; } $pids = array_values($pids); $sql = 'SELECT pid, tid, message FROM ' . DB::table('forum_post') . ' WHERE pid IN (' . implode(', ', $pids) . ')'; $query = DB::query($sql); while ($tmp = DB::fetch($query)) { $threadInfo[$tmp['tid']]['message'] = $tmp['message']; } $sql = 'SELECT aid, tid, tableid, pid FROM ' . DB::table('forum_attachment') . ' WHERE pid IN (' . implode(', ', $pids) . ')'; $tbIdx = array(); $query = DB::query($sql); while ($tmp = DB::fetch($query)) { if ($tmp['tableid'] < 10) { $threadInfo[$tmp['tid']]['aid'][] = $tmp['aid']; $tbIdx[$tmp['tableid']][] = $tmp['aid']; } } foreach ($tbIdx as $tableId => $aids) { $sql = 'SELECT aid, tid, attachment, description, remote, isimage FROM ' . DB::table('forum_attachment_' . $tableId) . ' WHERE aid IN (' . implode(', ', $aids) . ')'; $query = DB::query($sql); while ($tmp = DB::fetch($query)) { $isImage = $tmp['isimage']; if ($tmp['isimage'] && !$_G['setting']['attachimgpost']) { $isImage = 0; } if ($isImage) { $threadInfo[$tmp['tid']]['attachments'][$tmp['aid']] = array('attachment' => $tmp['attachment'], 'description' => $tmp['description'], 'remote' => $tmp['remote'], 'isimage' => $isImage); } } } BigAppAPI::_getPictures($threadInfo); foreach ($list as &$l) { $l['attachment_urls'] = array(); $l['message_abstract'] = ''; if (isset($threadInfo[$l['tid']]['message'])) { $l['message_abstract'] = $threadInfo[$l['tid']]['message']; } if (isset($threadInfo[$l['tid']]['attachment_urls'])) { $l['attachment_urls'] = $threadInfo[$l['tid']]['attachment_urls']; } if (true === BigAppConf::$enablePicOpt) { foreach ($l['attachment_urls'] as &$_url) { if (ApiUtils::isOptFix($_url)) { $_url = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:optpic&mod=__x__&size=' . urlencode(BigAppConf::$thumbSize) . '&url=' . urlencode($_url); $_url = str_replace('source/plugin/mobile/', '', $_url); $_url = str_replace('source/plugin/bigapp/', '', $_url); } } unset($_url); } } unset($l); }
public function misc_bigapp_message($param) { global $_G; if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], 'iyz_index.php') !== false) { if (true === BigAppConf::$debug) { $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__; } if (true === $this->_requireAPI('misc_bigapp_message')) { BigAppAPI::misc_bigapp_message($param); } } }