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); }
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); }
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); }