示例#1
0
 public function testCreatePosts()
 {
     $p1 = $this->createPost(ApiUtils::makePost('title1', 'content1'));
     $p2 = $this->createPost(ApiUtils::makePost('title2', 'content2'));
     $this->assertNotEquals($p1->id, $p2->id, 'Two created posts should not have the same ID');
     return [$p1, $p2];
 }
示例#2
0
 protected function sendClarificationEmail(Request $r, $time)
 {
     if (!OMEGAUP_EMAIL_SEND_EMAILS || !is_null($r['clarification']->answer) || !$r['problem']->email_clarifications) {
         return;
     }
     try {
         $emails = ProblemsDAO::getExplicitAdminEmails($r['problem']);
         $mail = new PHPMailer();
         $mail->IsSMTP();
         $mail->Host = OMEGAUP_EMAIL_SMTP_HOST;
         $mail->SMTPAuth = true;
         $mail->Password = OMEGAUP_EMAIL_SMTP_PASSWORD;
         $mail->From = OMEGAUP_EMAIL_SMTP_FROM;
         $mail->Port = 465;
         $mail->SMTPSecure = 'ssl';
         $mail->Username = OMEGAUP_EMAIL_SMTP_FROM;
         $mail->FromName = OMEGAUP_EMAIL_SMTP_FROM;
         foreach ($emails as $email) {
             $mail->AddAddress($email);
         }
         $mail->isHTML(true);
         global $smarty;
         $email_params = array('clarification_id' => $r['clarification']->clarification_id, 'clarification_body' => htmlspecialchars($r['clarification']->message), 'problem_alias' => $r['problem']->alias, 'problem_name' => htmlspecialchars($r['problem']->title), 'url' => is_null($r['contest']) ? 'https://omegaup.com/arena/problem/' . $r['problem']->alias . '#clarifications' : 'https://omegaup.com/arena/' . $r['contest']->alias . '#clarifications', 'user_name' => $r['user']->username);
         $mail->Subject = ApiUtils::FormatString($smarty->getConfigVars('clarificationEmailSubject'), $email_params);
         $mail->Body = ApiUtils::FormatString($smarty->getConfigVars('clarificationEmailBody'), $email_params);
         if (!$mail->Send()) {
             $this->log->error('Failed to send mail: ' . $mail->ErrorInfo);
         }
     } catch (Exception $e) {
         $this->log->error('Failed to send clarification email ' . $e->getMessage());
     }
 }
示例#3
0
 public static function normalize($name)
 {
     $name = ApiUtils::RemoveAccents(trim($name));
     $name = preg_replace('/[^a-z0-9]/', '-', strtolower($name));
     $name = preg_replace('/--+/', '-', $name);
     return $name;
 }
示例#4
0
 /**
  * Get an array of maps from an array of database's rows.
  * 
  * @param Array $rows An array of database rows.
  */
 public static function rowsToMaps($rows)
 {
     $res = array();
     // Validate parameters.
     if (!is_array($rows)) {
         $rows = array($rows);
     }
     // Iterate over each row.
     foreach ($rows as $entry) {
         $map = ApiUtils::rowToMap($entry);
         if ($map != null) {
             array_push($res, $map);
         }
     }
     return $res;
 }
示例#5
0
 function uploadmsg($statusid)
 {
     global $_G;
     $errorMap = array(0 => '上传成功', 10 => '非法提交', 2 => '上传失败', 6 => '附件个数超限制', 1 => '非法附件后缀', 2 => '上传失败', 3 => '附件超最大限制', 4 => '附件超最大限制', 5 => '附件超最大限制', 11 => '今日附件总大小超限制', 8 => '保存图片失败', 9 => '保存附件失败', 7 => '文件格式不一致');
     $msg = '附件提交失败';
     if (isset($errorMap[$statusid])) {
         $msg = $errorMap[$statusid];
     }
     if (function_exists('iconv')) {
         $msg = iconv('UTF-8', CHARSET . '//ignore', $msg);
     } else {
         $msg = mb_convert_encoding($msg, CHARSET, 'UTF-8');
     }
     $variable = array('code' => $statusid, 'message' => $msg, 'ret' => array('aId' => $this->aid, 'relative_url' => $this->attach['attachment'], 'abs_url' => ApiUtils::getDzRoot() . $_G['setting']['attachurl'] . 'forum/' . $this->attach['attachment'], 'image' => $this->attach['isimage'] ? -1 : 2));
     bigapp_core::result(bigapp_core::variable($variable));
 }
 public function testShouldRefuseMultipleRequestsInShortInterval()
 {
     $user_data = UserFactory::generateUser();
     $r = new Request(array('email' => $user_data['email']));
     $response = ResetController::apiCreate($r);
     try {
         ResetController::apiCreate($r);
     } catch (InvalidParameterException $expected) {
         $message = $expected->getMessage();
     }
     $this->assertEquals('passwordResetMinWait', $message);
     // time travel
     $reset_sent_at = ApiUtils::GetStringTime(time() - PASSWORD_RESET_MIN_WAIT - 1);
     $user = UsersDAO::FindByEmail($user_data['email']);
     $user->setResetSentAt($reset_sent_at);
     UsersDAO::save($user);
     ResetController::apiCreate($r);
 }
 public function testShouldRefuseExpiredReset()
 {
     $user_data = UserFactory::generateUser();
     $r = new Request(array('email' => $user_data['email']));
     $response = ResetController::apiCreate($r);
     $user_data['password_confirmation'] = $user_data['password'];
     $user_data['reset_token'] = $response['token'];
     // Time travel
     $reset_sent_at = ApiUtils::GetStringTime(time() - PASSWORD_RESET_TIMEOUT - 1);
     $user = UsersDAO::FindByEmail($user_data['email']);
     $user->setResetSentAt($reset_sent_at);
     UsersDAO::save($user);
     try {
         $r = new Request($user_data);
         $response = ResetController::apiUpdate($r);
     } catch (InvalidParameterException $expected) {
         $message = $expected->getMessage();
     }
     $this->assertEquals('passwordResetResetExpired', $message);
 }
 /**
  * Creates a reset operation, the first of two steps needed to reset a
  * password. The first step consist of sending an email to the user with
  * instructions to reset he's password, if and only if the email is valid.
  * @param Request $r
  * @return array
  * @throws InvalidParameterException
  */
 public static function apiCreate(Request $r)
 {
     self::ValidateCreateRequest($r);
     $email = $r['email'];
     $token = ApiUtils::GetRandomString();
     $reset_digest = hash('sha1', $token);
     $reset_sent_at = ApiUtils::GetStringTime();
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->Host = OMEGAUP_EMAIL_SMTP_HOST;
     $mail->SMTPAuth = true;
     $mail->Password = OMEGAUP_EMAIL_SMTP_PASSWORD;
     $mail->From = OMEGAUP_EMAIL_SMTP_FROM;
     $mail->Port = 465;
     $mail->SMTPSecure = 'ssl';
     $mail->Username = OMEGAUP_EMAIL_SMTP_FROM;
     $mail->FromName = OMEGAUP_EMAIL_SMTP_FROM;
     $mail->AddAddress($email);
     $mail->isHTML(true);
     $user = UsersDAO::FindByEmail($email);
     $user->setResetDigest($reset_digest);
     $user->setResetSentAt($reset_sent_at);
     UsersDAO::save($user);
     if (IS_TEST) {
         return array('status' => 'ok', 'token' => $token);
     }
     global $smarty;
     $mail->Subject = $smarty->getConfigVariable('wordsReset');
     $link = OMEGAUP_URL . '/login/password/reset/?';
     $link .= 'email=' . rawurlencode($email) . '&reset_token=' . $token;
     $message = $smarty->getConfigVariable('wordsResetMessage');
     $mail->Body = str_replace('[link]', $link, $message);
     if (!$mail->Send()) {
         self::$log->error('Failed to send mail:' . $mail->ErrorInfo);
         $user->setResetDigest(null);
         $user->setResetSentAt(null);
         UsersDAO::save($user);
     }
     return array('status' => 'ok', 'message' => $smarty->getConfigVariable('passwordResetRequestSuccess'));
 }
示例#9
0
 protected function _sortResult($forums)
 {
     $group = array();
     $forum = array();
     $sub = array();
     foreach ((array) $forums as $v) {
         $v['name'] = preg_replace('/<.*?\\>/', '', $v['name']);
         $v['icon'] = ApiUtils::getAttachPath($v['icon']);
         if (empty($v['icon'])) {
             $v['icon'] = '';
         }
         if ('group' === $v['type']) {
             $group[$v['fid']] = $v;
             continue;
         }
         if ('forum' === $v['type']) {
             $forum[$v['fid']] = $v;
             continue;
         }
         $sub[$v['fid']] = $v;
     }
     foreach ($sub as $v) {
         if (isset($forum[$v['fup']])) {
             $forum[$v['fup']]['subs'][] = $v;
             if (!isset($forum[$v['fup']]['posts'])) {
                 $forum[$v['fup']]['posts'] = 0;
             }
             if (!isset($forum[$v['fup']]['threads'])) {
                 $forum[$v['fup']]['threads'] = 0;
             }
             $forum[$v['fup']]['posts'] += $v['posts'];
             $forum[$v['fup']]['threads'] += $v['threads'];
         }
     }
     foreach ($forum as $v) {
         if (isset($group[$v['fup']])) {
             $group[$v['fup']]['forums'][] = $v;
         }
     }
     foreach ($group as $fid => $v) {
         if (isset($v['forums']) && !empty($v['forums'])) {
             continue;
         }
         unset($group[$fid]);
     }
     return $group;
 }
示例#10
0
 protected function _sortResult($forums)
 {
     $group = array();
     $forum = array();
     $sub = array();
     foreach ((array) $forums as $v) {
         $v['icon'] = ApiUtils::getAttachPath($v['icon']);
         if (empty($v['icon'])) {
             $v['icon'] = '';
         }
         if ('group' === $v['type']) {
             $group[$v['fid']] = $v;
             continue;
         }
         if ('forum' === $v['type']) {
             $forum[$v['fid']] = $v;
             continue;
         }
         $sub[$v['fid']] = $v;
     }
     foreach ($sub as $v) {
         if (isset($forum[$v['fup']])) {
             $forum[$v['fup']]['subs'][] = $v;
         }
     }
     foreach ($forum as $v) {
         if (isset($group[$v['fup']])) {
             $group[$v['fup']]['forums'][] = $v;
         }
     }
     return $group;
 }
示例#11
0
 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);
 }
示例#12
0
 function output()
 {
     global $_G, $thread;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     if ($GLOBALS['hiddenreplies']) {
         foreach ($GLOBALS['postlist'] as $k => $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']['lastpost'] = dgmdate($_G['thread']['lastpost']);
     $_G['thread']['ordertype'] = $GLOBALS['ordertype'];
     if (!empty($_GET['viewpid'])) {
         $GLOBALS['postlist'][$_GET['viewpid']] = $GLOBALS['post'];
     }
     if (!$_G['thread']['maxposition']) {
         $_G['thread']['maxposition'] = "1";
     }
     if ($GLOBALS['rushreply']) {
         $_G['thread']['rushreply'] = $GLOBALS['rushreply'];
         $_G['thread']['rushresult'] = $GLOBALS['rushresult'];
     }
     foreach ($GLOBALS['comments'] as $pid => $comments) {
         $comments = bigapp_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(bigapp_core::getvalues($GLOBALS['postlist'], array('/^\\d+$/'), array('uid', 'pid', 'tid', 'author', 'first', 'dbdateline', 'dateline', 'username', 'adminid', 'memberstatus', 'authorid', 'username', 'groupid', 'memberstatus', 'status', 'message', 'number', 'memberstatus', 'groupid', 'attachment', 'attachments', 'attachlist', 'imagelist', 'anonymous', 'extcredits2', 'posts', 'threads', 'authortitle', 'position', 'postreview', 'isWater'))), 'allowpostcomment' => $_G['setting']['allowpostcomment'], 'comments' => $GLOBALS['comments'], 'commentcount' => $GLOBALS['commentcount'], 'imagelist' => array(), 'ppp' => $_G['ppp'], 'totalpage' => $GLOBALS['totalpage'], 'setting_rewriterule' => $_G['setting']['rewriterule'], 'setting_rewritestatus' => $_G['setting']['rewritestatus'], 'forum_threadpay' => $_G['forum_threadpay'], 'cache_custominfo_postno' => $_G['cache']['custominfo']['postno']);
     //帖子举报
     $variable['report']['enable'] = '1';
     $variable['report']['handlekey'] = 'miscreport' . $variable['postlist'][0]['tid'];
     $language_file = 'source/language/lang_template.php';
     if (file_exists($language_file)) {
         require_once $language_file;
     }
     $report_msg = explode(",", $lang['report_reason_message']);
     foreach ($report_msg as $key => $msg) {
         #$report_msg[$key] = preg_replace('/[|\'/', '', $msg);
         $msg = str_replace('[', '', $msg);
         $msg = str_replace(']', '', $msg);
         $msg = str_replace("'", "", $msg);
         $report_msg[$key] = $msg;
     }
     if (empty($report_msg[0])) {
         $variable['report']['content'] = array();
     } else {
         $variable['report']['content'] = $report_msg;
     }
     foreach ($variable['postlist'] as &$_item) {
         $_item['dateline'] = preg_replace('/<.*?\\>/', '', $_item['dateline']);
     }
     unset($_item);
     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 = bigapp_core::getvalues($GLOBALS['threadsortshow'], array('/^(?!typetemplate).*$/'));
     if (!empty($threadsortshow)) {
         $variable['threadsortshow'] = $threadsortshow;
     }
     foreach ($variable['postlist'] as $k => &$post) {
         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($_G['uid'] != $variable['postlist'][$k]['authorid']) {
         				$variable['postlist'][$k]['report']['enable'] = '1';
         				$variable['postlist'][$k]['report']['handlekey']='miscreport'.$variable['postlist'][$k]['pid'];
         				$variable['postlist'][$k]['report']['content'] = lang('plugin/bigapp', 'report_reason_message');
         		} else {
         				$variable['postlist'][$k]['report']['enable'] = '0';
         		}*/
         ##############################
         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("/<a\\shref=\"([^\"]+?)\"\\starget=\"_blank\">\\[viewimg\\]<\\/a>/is", "<img src=\"\\1\" />", $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = BigAppAPI::_findimg($variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = str_replace('!post_hide_reply_hidden!', lang('plugin/bigapp', 'post_hide_reply_hide'), $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = str_replace('post_hide_reply_hidden', lang('plugin/bigapp', 'post_hide_reply_hide'), $variable['postlist'][$k]['message']);
         if ($GLOBALS['aimgs'][$post['pid']]) {
             $imagelist = array();
             foreach ($GLOBALS['aimgs'][$post['pid']] as $aid) {
                 $extra = '';
                 $url = BigAppAPI::_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]', '<div class="img"><img src="' . $url . '" ' . $extra . '/></div>', $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('/(&nbsp;){2,}/', '', $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['dateline'] = strip_tags($post['dateline']);
         $variable['postlist'][$k]['groupiconid'] = bigapp_core::usergroupIconId($post['groupid']);
         if ($post['first']) {
             $post['recommends'] = $_G['thread']['recommends'];
             $post['recommend_add'] = $_G['thread']['recommend_add'];
             $post['recommend_sub'] = $_G['thread']['recommend_sub'];
             $post['enable_recommend'] = 0;
             if (($_G['group']['allowrecommend'] || !$_G['uid']) && $_G['setting']['recommendthread']['status']) {
                 $post['enable_recommend'] = 1;
                 $post['click2login'] = 0;
                 if (!$_G['uid']) {
                     $post['click2login'] = 1;
                 }
             }
             $post['addtext'] = $_G['setting']['recommendthread']['addtext'];
             $post['subtext'] = $_G['setting']['recommendthread']['subtracttext'];
             $post['recommend_value'] = $_G['group']['allowrecommend'];
             $post['recommended'] = 0;
             if (C::t('forum_memberrecommend')->fetch_by_recommenduid_tid($_G['uid'], $post['tid'])) {
                 $post['recommended'] = 1;
             }
         } else {
             $post['enable_support'] = 0;
             @preg_match('/^x([0-9\\.]+)/i', $_G['setting']['version'], $matches);
             $num = 0;
             if (isset($matches[1])) {
                 $num = $matches[1];
             }
             if ($num >= 3.1 && !$_G['forum_thread']['special'] && !$rushreply && !$hiddenreplies && $_G['setting']['repliesrank'] && !$post['first'] && !($post['isWater'] && $_G['setting']['filterednovote'])) {
                 $post['enable_support'] = 1;
                 $post['click2login'] = 0;
                 if (!$_G['uid']) {
                     $post['click2login'] = 1;
                 }
             }
             if (function_exists('iconv')) {
                 $post['supporttext'] = iconv('UTF-8', CHARSET . '//ignore', '支持');
                 $post['opposetext'] = iconv('UTF-8', CHARSET . '//ignore', '反对');
             } else {
                 $post['supporttext'] = mb_convert_encoding('支持', CHARSET, 'UTF-8');
                 $post['opposetext'] = mb_convert_encoding('反对', CHARSET, 'UTF-8');
             }
             $post['support'] = 0;
             $post['oppose'] = 0;
             if (isset($post['postreview']['support'])) {
                 $post['support'] = $post['postreview']['support'];
             }
             if (isset($post['postreview']['against'])) {
                 $post['oppose'] = $post['postreview']['against'];
             }
             unset($post['isWater']);
             unset($post['postreview']);
         }
     }
     unset($post);
     foreach ($GLOBALS['aimgs'] as $pid => $aids) {
         foreach ($aids as $aid) {
             $variable['imagelist'][] = $GLOBALS['postlist'][$pid]['attachments'][$aid]['url'] . $GLOBALS['postlist'][$pid]['attachments'][$aid]['attachment'];
         }
     }
     $variable['special_poll'] = BigAppAPI::getPollInfo();
     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'] = bigapp_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'] = bigapp_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';
     BigAppAPI::modifyPost2($variable['postlist']);
     if (isset($variable['thread']['tid'])) {
         $variable['thread']['share_url'] = rtrim(ApiUtils::getDzRoot(), '/') . '/forum.php?mod=viewthread&tid=' . $variable['thread']['tid'];
     } else {
         $variable['thread']['share_url'] = '';
     }
     $variable['jump#pid'] = isset($_G['jump#pid']) ? $_G['jump#pid'] : "0";
     $variable['page'] = isset($_G['page']) ? $_G['page'] : "1";
     bigapp_core::result(bigapp_core::variable($variable));
 }
示例#13
0
function getPictures(&$threadInfo)
{
    global $_G, $collect;
    foreach ($threadInfo as $tid => &$info) {
        $collect = array();
        $message = str_replace("\r", '', $info['message']);
        $message = str_replace("\n", '', $message);
        $message = str_replace('\\r', '', $message);
        $message = str_replace('\\n', '', $message);
        if (function_exists('iconv')) {
            $message = iconv(CHARSET, 'UTF-8//ignore', $message);
            foreach ($info['attachments'] as &$att) {
                $att['description'] = '__DONT_DICONV_TO_UTF8___' . iconv(CHARSET, 'UTF-8//ignore', $att['description']);
            }
            unset($att);
        } else {
            $message = mb_convert_encoding($message, 'UTF-8', CHARSET);
            foreach ($info['attachments'] as &$att) {
                $att['description'] = '__DONT_DICONV_TO_UTF8___' . mb_convert_encoding($att['description'], 'UTF-8', CHARSET);
            }
            unset($att);
        }
        $message = preg_replace_callback('/\\[img.*?\\](.*?)\\[\\/img\\]|\\[attach\\]([0-9]+)\\[\\/attach\\]|\\[hide\\](.*?)\\[\\/hide\\]|\\[i.*\\](.*)' . '\\[\\/i\\]|\\[.*?\\]|\\n|\\r/', 'imgCallback', $message);
        $oldMessage = $message;
        if (function_exists('mb_substr')) {
            $message = mb_substr($message, 0, 30, 'UTF-8');
        } else {
            $message = substr($message, 0, 60);
        }
        if ($oldMessage !== $message) {
            $message .= '...';
        }
        loadcache(array('smilies', 'smileytypes'));
        foreach ($_G['cache']['smilies']['replacearray'] as $id => $img) {
            $pattern = $_G['cache']['smilies']['searcharray'][$id];
            $message = preg_replace($pattern, '[表情]', $message);
        }
        $info['message'] = '__DONT_DICONV_TO_UTF8___' . $message;
        $infoAttrs = $info['attachments'];
        foreach ($collect as $attach) {
            true === BIGAPP_DEV && runlog('bigapp', 'process attach collect [ ' . $attach . ' ]');
            if (is_numeric($attach)) {
                if (isset($infoAttrs[$attach])) {
                    $url = ($infoAttrs[$attach]['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
                    $url .= $infoAttrs[$attach]['attachment'];
                    $tmp = parse_url($url);
                    if (!isset($tmp['scheme'])) {
                        $url = ApiUtils::getDzRoot() . $url;
                    }
                    $info['attachment_urls'][] = $url;
                    unset($infoAttrs[$attach]);
                }
                continue;
            }
            $tmp = parse_url($attach);
            if (!isset($tmp['scheme'])) {
                $url = ApiUtils::getDzRoot() . $attach;
            } else {
                $url = str_replace('source/plugin/mobile/', '', $attach);
                $url = str_replace('source/plugin/mobile/', '', $url);
            }
            $info['attachment_urls'][] = $url;
        }
        foreach ($infoAttrs as $aid => $aInfo) {
            $url = ($aInfo['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/';
            $url .= $aInfo['attachment'];
            $tmp = parse_url($url);
            if (!isset($tmp['scheme'])) {
                $url = ApiUtils::getDzRoot() . $url;
            }
            $info['attachment_urls'][] = $url;
        }
    }
    unset($info);
}
示例#14
0
<?php

// ---- Initialize logging ---- //
require_once 'libs/KLogger.php';
ApiUtils::$logger = new KLogger(ApiConfig::$LOG_FILEPATH, KLogger::DEBUG);
// ---- Initialize Slim Framework ---- //
require 'libs/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
// ---- Initialize ActiveRecord ---- //
require_once 'libs/ActiveRecord/ActiveRecord.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('libs/models');
    $cfg->set_connections(array('development' => ApiConfig::$CONN_STRING));
});
// ---- Other initializations ---- //
// Initialize session.
session_start();
示例#15
0
 function output()
 {
     global $_G;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     $variable['data'] = "";
     $formatRec = array('aid', 'catid', 'title', 'summary', 'pic', 'dateline', 'catname', 'content', 'url', 'contents');
     if ('list' == $_GET['mod']) {
         $variable['data'] = array();
         $_G['catid'] = $catid = max(0, intval($_GET['catid']));
         $page = max(1, intval($_GET['page']));
         $cat = category_remake($catid);
         if (!empty($cat)) {
             $wheresql = category_get_wheresql($cat);
             $list = category_get_list($cat, $wheresql, $page);
             if (!empty($list)) {
                 $articleList = array();
                 foreach ($list['list'] as $key => $value) {
                     if (!empty($value['pic'])) {
                         $tmp = parse_url($value['pic']);
                         if (!isset($tmp['scheme'])) {
                             $url = ApiUtils::getDzRoot() . $value['pic'];
                         } else {
                             $url = str_replace('source/plugin/mobile/', '', $attach);
                             $url = str_replace('source/plugin/mobile/', '', $url);
                         }
                         $list['list'][$key]['pic'] = $url;
                     }
                     //暂时不支持存在url 跳转的文章
                     if (isset($value['url']) && !empty($value['url'])) {
                         unset($list['list'][$key]);
                         continue;
                     }
                     foreach ($value as $k => $v) {
                         if (!in_array($k, $formatRec)) {
                             unset($list['list'][$key][$k]);
                         }
                     }
                     $articleList[] = $list['list'][$key];
                 }
                 $variable['data'] = $articleList;
                 $variable['perpage'] = $cat['perpage'];
                 $variable['needmore'] = count($articleList) < $cat['perpage'] ? '0' : '1';
             }
         }
     } else {
         $aid = empty($_GET['aid']) ? 0 : intval($_GET['aid']);
         $article = C::t('portal_article_title')->fetch($aid);
         if (!empty($article)) {
             $content = C::t('portal_article_content')->fetch_all($aid);
             if (is_array($content)) {
                 foreach ($content as $i => $c) {
                     if ($i != 0) {
                         $content[0]['content'] .= $c['content'];
                     }
                 }
             }
             $article = array_merge($content[0], $article);
             foreach ($article as $k => $v) {
                 if (!in_array($k, $formatRec)) {
                     unset($article[$k]);
                 }
             }
             $article['content'] = self::filterContent($article['content']);
             $article['dateline'] = date('Y-m-d H:i', $article['dateline']);
             $article['share_url'] = rtrim(ApiUtils::getDzRoot(), '/') . '/portal.php?mod=view&aid=' . $aid;
             $variable['data'] = $article;
         }
     }
     bigapp_core::result(bigapp_core::variable($variable));
 }
示例#16
0
 protected function getErrorMessage()
 {
     // Obtener el texto final (ya localizado) de smarty.
     global $smarty;
     $localizedText = $smarty->getConfigVars($this->message);
     if (empty($localizedText)) {
         self::$log->error("Untranslated error message: {$this->message}");
         return "{untranslated:{$this->message}}";
     }
     $localizedText = ApiUtils::FormatString($localizedText, $this->additional_parameters);
     if ($this->parameter == null) {
         return $localizedText;
     } else {
         return "{$localizedText}: {$this->parameter}";
     }
 }
示例#17
0
});
// Service for update the values of an assistance list.
$app->put('/assistanceList', function () use($app) {
    try {
        // Verify that the user is logged.
        if (ApiUtils::isLogged()) {
            // Get input.
            $request = $app->request();
            $input = json_decode($request->getBody());
            $rows = is_object($input) ? get_object_vars($input) : $input;
            // Update all rows.
            for ($i = 0; $i < count($rows); $i++) {
                $entry = Assistance::find($rows[$i]->id);
                $attributes = is_object($rows[$i]) ? get_object_vars($rows[$i]) : $rows[$i];
                $creation = is_object($rows[$i]->creation) ? get_object_vars($rows[$i]->creation) : $rows[$i]->creation;
                $attributes['creation'] = $creation['date'];
                if ($entry != null) {
                    $entry->update_attributes($attributes);
                }
            }
            // Return result.
            echo json_encode(array("error" => null));
        } else {
            // Return error message.
            ApiUtils::returnError($app, 'UserNotAdmin');
        }
    } catch (Exception $e) {
        // An exception ocurred. Return an error message.
        ApiUtils::handleException($app, $e);
    }
});
示例#18
0
文件: index.php 项目: benjaminovak/ep
        }
        break;
    case "narocilo":
        session_start();
        if ($http_method == "GET" && $param == null) {
            ApiUtils::saveOrder();
        } else {
            if ($http_method == "GET" && $param == "oddani") {
                ApiUtils::orders();
            } else {
                if ($http_method == "GET" && $param == "potrjeni") {
                    ApiUtils::ordersProven();
                } else {
                    if ($http_method == "GET" && $param == "stornirani") {
                        ApiUtils::ordersCancelled();
                    } else {
                        if ($http_method == "GET" && $param != null) {
                            ApiUtils::getOrderProducts($param);
                        } else {
                            // error
                            echo returnError(404, "Unknown request: [{$http_method} {$resource}]");
                        }
                    }
                }
            }
        }
        break;
    default:
        returnError(404, "Invalid resource: " . $resource);
        break;
}
示例#19
0
 public function output()
 {
     global $_G;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     if (isset($GLOBALS['list']) && is_array($GLOBALS['list'])) {
         foreach ($GLOBALS['list'] as &$v) {
             $v['icon'] = ApiUtils::getImgPath($v['icon']);
             loadcache(array('bigapp_favforum_' . $v['id'], 'plugin'));
             $expire = 5;
             if (!$_G['cache']['bigapp_favforum_' . $v['id']] || TIMESTAMP - $_G['cache']['bigapp_favforum_' . $v['id']]['expiration'] > $expire) {
                 $sql = 'SELECT description, icon FROM ' . DB::table('forum_forumfield') . ' WHERE fid = ' . $v['id'];
                 $query = DB::query($sql);
                 $description = '';
                 $icon = ApiUtils::getImgPath($v['icon']);
                 while ($fInfo = DB::fetch($query)) {
                     $description = $fInfo['description'];
                     $icon = ApiUtils::getDzRoot() . $_G['setting']['attachurl'] . 'common/' . $fInfo['icon'];
                     break;
                 }
                 $sql = 'SELECT threads, posts, todayposts FROM ' . DB::table('forum_forum') . ' WHERE fid = ' . $v['id'];
                 $query = DB::query($sql);
                 $nums = array('threads' => 0, 'posts' => 0, 'todayposts' => 0, 'yesterdayposts' => 0);
                 while ($tmp = DB::fetch($query)) {
                     $nums = $tmp;
                     break;
                 }
                 $fInfo = array_merge($fInfo, $nums);
                 savecache('bigapp_favforum_' . $v['id'], array('variable' => $fInfo, 'expiration' => TIMESTAMP));
             } else {
                 $fInfo = $_G['cache']['bigapp_favforum_' . $v['id']]['variable'];
                 $description = $fInfo['description'];
                 $icon = ApiUtils::getDzRoot() . $_G['setting']['attachurl'] . 'common/' . $fInfo['icon'];
             }
             $v['icon'] = $icon;
             $v['description'] = preg_replace('/<.*?>/', '', $description);
             $v['name'] = $v['title'];
             $v['threads'] = $fInfo['threads'];
             $v['posts'] = $fInfo['posts'];
             $v['todayposts'] = $fInfo['todayposts'];
             $v['yesterdayposts'] = isset($fInfo['yesterdayposts']) ? $fInfo['yesterdayposts'] : 0;
             unset($v['title']);
         }
     }
     if (!isset($_GET['page']) || !is_numeric($_GET['page']) || $_GET['page'] <= 0) {
         $_GET['page'] = 1;
     }
     $start = $GLOBALS['perpage'] * ($_GET['page'] - 1);
     $end = count($GLOBALS['list']) + $start;
     loadcache('forum');
     if ($end >= $GLOBALS['count']) {
         $GLOBALS['need_more'] = 0;
     } else {
         $GLOBALS['need_more'] = 1;
     }
     $list = array_values($GLOBALS['list']);
     $newList = array();
     if (is_array($list) && !empty($list)) {
         foreach ($list as $fav) {
             if (!empty($fav['threads'])) {
                 $newList[] = $fav;
             }
         }
     } else {
         $newList = $list;
     }
     $variable = array('list' => $newList, 'perpage' => $GLOBALS['perpage'], 'need_more' => $GLOBALS['need_more'], 'count' => $GLOBALS['count']);
     bigapp_core::result(bigapp_core::variable($variable));
 }
示例#20
0
 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);
 }
示例#21
0
 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);
 }