modcp_moderate.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: modcp_moderate.php 32077 2012-11-07 04:38:04Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
  9. exit('Access Denied');
  10. }
  11. $modact = empty($_GET['modact']) || !in_array($_GET['modact'] , array('delete', 'ignore', 'validate')) ? 'ignore' : $_GET['modact'];
  12. if($op == 'members') {
  13. $filter = isset($_GET['filter']) ? intval($_GET['filter']) : 0;
  14. $filtercheck = array('', '', '');
  15. $filtercheck[$filter] = 'selected';
  16. if(submitcheck('dosubmit', 1) || submitcheck('modsubmit')) {
  17. if(empty($modact) || !in_array($modact, array('ignore', 'validate', 'delete'))) {
  18. showmessage('modcp_noaction');
  19. }
  20. $list = array();
  21. if($_GET['moderate'] && is_array($_GET['moderate'])) {
  22. foreach($_GET['moderate'] as $val) {
  23. if(is_numeric($val) && $val) {
  24. $list[] = $val;
  25. }
  26. }
  27. }
  28. if(submitcheck('dosubmit', 1)) {
  29. $_GET['handlekey'] = 'mods';
  30. include template('forum/modcp_moderate_float');
  31. dexit();
  32. } elseif ($uids = $list) {
  33. $members = $uidarray = array();
  34. $member_validate = C::t('common_member_validate')->fetch_all($uids);
  35. foreach(C::t('common_member')->fetch_all($uids, false, 0) as $uid => $member) {
  36. if($member['groupid'] == 8 && $member['status'] == $filter) {
  37. $members[$uid] = array_merge((array)$member_validate[$uid], $member);
  38. }
  39. }
  40. if(($uids = array_keys($members))) {
  41. $reason = dhtmlspecialchars(trim($_GET['reason']));
  42. if($_GET['modact'] == 'delete') {
  43. C::t('common_member')->delete_no_validate($uids);
  44. }
  45. if($_GET['modact'] == 'validate') {
  46. C::t('common_member')->update($uids, array('adminid' => '0', 'groupid' => $_G['setting']['newusergroupid']));
  47. C::t('common_member_validate')->delete($uids);
  48. }
  49. if($_GET['modact'] == 'ignore') {
  50. C::t('common_member_validate')->update($uids, array('moddate' => $_G['timestamp'], 'admin' => $_G['username'], 'status' => '1', 'remark' => $reason));
  51. }
  52. if($sendemail) {
  53. if(!function_exists('sendmail')) {
  54. include libfile('function/mail');
  55. }
  56. foreach($members as $uid => $member) {
  57. $member['regdate'] = dgmdate($member['regdate']);
  58. $member['submitdate'] = dgmdate($member['submitdate']);
  59. $member['moddate'] = dgmdate(TIMESTAMP);
  60. $member['operation'] = $_GET['modact'];
  61. $member['remark'] = $reason ? $reason : 'N/A';
  62. $moderate_member_message = lang('email', 'moderate_member_message', array(
  63. 'username' => $member['username'],
  64. 'bbname' => $_G['setting']['bbname'],
  65. 'regdate' => $member['regdate'],
  66. 'submitdate' => $member['submitdate'],
  67. 'submittimes' => $member['submittimes'],
  68. 'message' => $member['message'],
  69. 'modresult' => lang('email', 'moderate_member_'.$member['operation']),
  70. 'moddate' => $member['moddate'],
  71. 'adminusername' => $_G['member']['username'],
  72. 'remark' => $member['remark'],
  73. 'siteurl' => $_G['siteurl'],
  74. ));
  75. if(!sendmail("$member[username] <$member[email]>", lang('email', 'moderate_member_subject'), $moderate_member_message)) {
  76. runlog('sendmail', "$member[email] sendmail failed.");
  77. }
  78. }
  79. }
  80. }
  81. showmessage('modcp_mod_succeed', "{$cpscript}?mod=modcp&action=$_GET[action]&op=$op&filter=$filter");
  82. } else {
  83. showmessage('modcp_moduser_invalid');
  84. }
  85. } else {
  86. $count = C::t('common_member_validate')->fetch_all_status_by_count();
  87. $page = max(1, intval($_G['page']));
  88. $_G['setting']['memberperpage'] = 20;
  89. $start_limit = ($page - 1) * $_G['setting']['memberperpage'];
  90. $multipage = multi(C::t('common_member_validate')->count_by_status(0), $_G['setting']['memberperpage'], $page, "{$cpscript}?mod=modcp&action=$_GET[action]&op=$op&fid=$_G[fid]&filter=$filter");
  91. $vuids = array();
  92. $memberlist = $member_validate = $common_member = $member_status = array();
  93. if(($member_validate = C::t('common_member_validate')->fetch_all_by_status($filter, $start_limit, $_G['setting']['memberperpage']))) {
  94. $uids = array_keys($member_validate);
  95. $common_member = C::t('common_member')->fetch_all($uids, false, 0);
  96. $member_status = C::t('common_member_status')->fetch_all($uids, false, 0);
  97. }
  98. foreach($member_validate as $uid => $member) {
  99. $member = array_merge($member, $common_member[$uid], $member_status[$uid]);
  100. if($member['groupid'] != 8) {
  101. $vuids[] = $member['uid'];
  102. continue;
  103. }
  104. $member['regdate'] = dgmdate($member['regdate']);
  105. $member['submitdate'] = dgmdate($member['submitdate']);
  106. $member['moddate'] = $member['moddate'] ? dgmdate($member['moddate']) : $lang['none'];
  107. $member['message'] = dhtmlspecialchars($member['message']);
  108. $member['admin'] = $member['admin'] ? "<a href=\"home.php?mod=space&username=".rawurlencode($member['admin'])."\" target=\"_blank\">$member[admin]</a>" : $lang['none'];
  109. $memberlist[] = $member;
  110. }
  111. if($vuids) {
  112. C::t('common_member_validate')->delete($vuids, 'UNBUFFERED');
  113. }
  114. return true;
  115. }
  116. }
  117. if(empty($modforums['fids'])) {
  118. return false;
  119. } elseif($_G['fid'] && ($_G['forum']['type'] == 'group' || !$_G['forum']['ismoderator'])) {
  120. return false;
  121. } else {
  122. $modfids = "";
  123. if($_G['fid']) {
  124. $modfids = $_G['fid'];
  125. $modfidsadd = "fid='$_G[fid]'";
  126. } elseif($_G['adminid'] == 1) {
  127. $modfidsadd = "";
  128. } else {
  129. $modfids = $modforums['fids'];
  130. $modfidsadd = "fid in ($modforums[fids])";
  131. }
  132. }
  133. $updatestat = false;
  134. $op = !in_array($op , array('replies', 'threads')) ? 'threads' : $op;
  135. $filter = !empty($_GET['filter']) ? -3 : 0;
  136. $filtercheck = array(0 => '', '-3' => '');
  137. $filtercheck[$filter] = 'selected="selected"';
  138. $pstat = $filter == -3 ? -3 : -2;
  139. $moderatestatus = $filter == -3 ? 1 : 0;
  140. $tpp = 10;
  141. $page = max(1, intval($_G['page']));
  142. $start_limit = ($page - 1) * $tpp;
  143. $postlist = array();
  144. $posttableselect = '';
  145. $modpost = array('validate' => 0, 'delete' => 0, 'ignore' => 0);
  146. $moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
  147. require_once libfile('function/post');
  148. if(submitcheck('dosubmit', 1) || submitcheck('modsubmit')) {
  149. $list = array();
  150. if($_GET['moderate'] && is_array($_GET['moderate'])) {
  151. foreach($_GET['moderate'] as $val) {
  152. if(is_numeric($val) && $val) {
  153. $moderation[$modact][] = $val;
  154. }
  155. }
  156. }
  157. if(submitcheck('modsubmit')) {
  158. $updatestat = $op == 'replies' ? 1 : 2;
  159. $modpost = array(
  160. 'ignore' => count($moderation['ignore']),
  161. 'delete' => count($moderation['delete']),
  162. 'validate' => count($moderation['validate'])
  163. );
  164. } elseif(submitcheck('dosubmit', 1)) {
  165. $_GET['handlekey'] = 'mods';
  166. $list = $moderation[$modact];
  167. include template('forum/modcp_moderate_float');
  168. dexit();
  169. }
  170. }
  171. if($op == 'replies') {
  172. $posttableid = intval($_GET['posttableid']);
  173. $posttable = getposttable($posttableid);
  174. $posttableselect = getposttableselect();
  175. if(submitcheck('modsubmit')) {
  176. $pmlist = array();
  177. if($ignorepids = dimplode($moderation['ignore'])) {
  178. C::t('forum_post')->update($posttableid, $moderation['ignore'], array('invisible' => -3), true, false, 0, -2, ($modfids ? explode(',', $modfids) : null));
  179. updatemoderate('pid', $moderation['ignore'], 1);
  180. }
  181. if($deletepids = dimplode($moderation['delete'])) {
  182. $recyclebinpids = array();
  183. $pids = array();
  184. foreach(C::t('forum_post')->fetch_all($posttableid, $moderation['delete']) as $post) {
  185. if($post['invisible'] != $pstat || $post['first'] != 0 || ($modfids ? !in_array($post['fid'], explode(',', $modfids)) : 0)) {
  186. continue;
  187. }
  188. if($modforums['recyclebins'][$post['fid']]) {
  189. $recyclebinpids[] = $post['pid'];
  190. } else {
  191. $pids[] = $post['pid'];
  192. }
  193. if($post['authorid'] && $post['authorid'] != $_G['uid']) {
  194. $pmlist[] = array(
  195. 'act' => 'modreplies_delete',
  196. 'notevar' => array('reason' => dhtmlspecialchars($_GET['reason']), 'post' => messagecutstr($post['message'], 30)),
  197. 'authorid' => $post['authorid'],
  198. );
  199. }
  200. }
  201. if($recyclebinpids) {
  202. C::t('forum_post')->update($posttableid, $recyclebinpids, array('invisible' => '-5'), true);
  203. }
  204. if($pids) {
  205. require_once libfile('function/delete');
  206. deletepost($pids, 'pid', false, $posttableid);
  207. }
  208. updatemodworks('DLP', count($moderation['delete']));
  209. updatemoderate('pid', $moderation['delete'], 2);
  210. }
  211. $repliesmod = 0;
  212. if($validatepids = dimplode($moderation['validate'])) {
  213. $threads = $lastpost = $attachments = $pidarray = array();
  214. $postlist = $tids = array();
  215. foreach(C::t('forum_post')->fetch_all($posttableid, $moderation['validate']) as $post) {
  216. if($post['invisible'] != $pstat || $post['first'] != '0' || ($modfids ? !in_array($post['fid'], explode(',', $modfids)) : 0)) {
  217. continue;
  218. }
  219. $tids[$post['tid']] = $post['tid'];
  220. $postlist[] = $post;
  221. }
  222. $threadlist = C::t('forum_thread')->fetch_all($tids);
  223. foreach($postlist as $post) {
  224. $post['lastpost'] = $threadlist[$post['tid']]['lastpost'];
  225. $repliesmod ++;
  226. $pidarray[] = $post['pid'];
  227. if(getstatus($post['status'], 3) == 0) {
  228. updatepostcredits('+', $post['authorid'], 'reply', $post['fid']);
  229. $attachcount = C::t('forum_attachment_n')->count_by_id('tid:'.$post['tid'], 'pid', $post['pid']);
  230. updatecreditbyaction('postattach', $post['authorid'], array(), '', $attachcount, 1, $post['fid']);
  231. }
  232. $threads[$post['tid']]['posts']++;
  233. if($post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']]) {
  234. $threads[$post['tid']]['lastpost'] = $post['dateline'];
  235. $threads[$post['tid']]['lastposter'] = $post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author]);
  236. }
  237. if($threads[$post['tid']]['attachadd'] || $post['attachment']) {
  238. $threads[$post['tid']]['attachment'] = 1;
  239. }
  240. $pm = 'pm_'.$post['pid'];
  241. if($post['authorid'] && $post['authorid'] != $_G['uid']) {
  242. $pmlist[] = array(
  243. 'act' => 'modreplies_validate',
  244. 'notevar' => array('reason' => dhtmlspecialchars($_GET['reason']), 'pid' => $post['pid'], 'tid' => $post['tid'], 'post' => messagecutstr($post['message'], 30), 'from_id' => 0, 'from_idtype' => 'modreplies'),
  245. 'authorid' => $post['authorid'],
  246. );
  247. }
  248. }
  249. unset($postlist, $tids, $threadlist);
  250. foreach($threads as $tid => $thread) {
  251. $updatedata = array('replies'=>$thread['posts']);
  252. if(isset($thread['lastpost'])) {
  253. $updatedata['lastpost'] = array($thread['lastpost']);
  254. $updatedata['lastposter'] = array($thread['lastposter']);
  255. }
  256. if(isset($thread['attachment'])) {
  257. $updatedata['attachment'] = $thread['attachment'];
  258. }
  259. C::t('forum_thread')->increase($tid, $updatedata);
  260. }
  261. if($_G['fid']) {
  262. updateforumcount($_G['fid']);
  263. } else {
  264. $fids = array_keys($modforums['list']);
  265. foreach($fids as $f) {
  266. updateforumcount($f);
  267. }
  268. }
  269. if(!empty($pidarray)) {
  270. $pidarray[] = 0;
  271. $repliesmod = C::t('forum_post')->update($posttableid, $pidarray, array('invisible' => '0'), true);
  272. updatemodworks('MOD', $repliesmod);
  273. updatemoderate('pid', $pidarray, 2);
  274. } else {
  275. updatemodworks('MOD', 1);
  276. }
  277. }
  278. if($pmlist) {
  279. foreach($pmlist as $pm) {
  280. $post = $pm['post'];
  281. $_G['tid'] = intval($pm['tid']);
  282. notification_add($pm['authorid'], 'system', $pm['act'], $pm['notevar'], 1);
  283. }
  284. }
  285. showmessage('modcp_mod_succeed', "{$cpscript}?mod=modcp&action=$_GET[action]&op=$op&filter=$filter&fid=$_G[fid]");
  286. }
  287. $attachlist = array();
  288. require_once libfile('function/discuzcode');
  289. require_once libfile('function/attachment');
  290. $ppp = 10;
  291. $page = max(1, intval($_G['page']));
  292. $start_limit = ($page - 1) * $ppp;
  293. $modcount = C::t('common_moderate')->count_by_search_for_post($posttable, $moderatestatus, 0, ($modfids ? explode(',', $modfids) : null));
  294. $multipage = multi($modcount, $ppp, $page, "{$cpscript}?mod=modcp&action=$_GET[action]&op=$op&filter=$filter&fid=$_G[fid]");
  295. if($modcount) {
  296. $attachtablearr = array();
  297. $_fids = array();
  298. foreach(C::t('common_moderate')->fetch_all_by_search_for_post($posttable, $moderatestatus, 0, ($modfids ? explode(',', $modfids) : null), null, null, null, $start_limit, $ppp) as $post) {
  299. $_fids[$post['fid']] = $post['fid'];
  300. $_tids[$post['tid']] = $post['tid'];
  301. $post['id'] = $post['pid'];
  302. $post['dateline'] = dgmdate($post['dateline']);
  303. $post['subject'] = $post['subject'] ? '<b>'.$post['subject'].'</b>' : '';
  304. $post['message'] = nl2br(dhtmlspecialchars($post['message']));
  305. if($post['attachment']) {
  306. $attachtable = getattachtableid($post['tid']);
  307. $attachtablearr[$attachtable][$post['pid']] = $post['pid'];
  308. }
  309. $postlist[$post['pid']] = $post;
  310. }
  311. $_threads = $_forums = array();
  312. if($_fids) {
  313. $_forums = C::t('forum_forum')->fetch_all($_fids);
  314. foreach($postlist as &$_post) {
  315. $_forum = $_forums[$_post['fid']];
  316. $_arr = array(
  317. 'forumname' => $_forum['name'],
  318. 'allowsmilies' => $_forum['allowsmilies'],
  319. 'allowhtml' => $_forum['allowhtml'],
  320. 'allowbbcode' => $_forum['allowbbcode'],
  321. 'allowimgcode' => $_forum['allowimgcode'],
  322. );
  323. $_post = array_merge($_post, $_arr);
  324. }
  325. }
  326. if($_tids) {
  327. $_threads = C::t('forum_thread')->fetch_all($_tids);
  328. foreach($postlist as &$_post) {
  329. $_post['tsubject'] = $_threads[$_post['tid']]['subject'];
  330. }
  331. }
  332. if(!empty($attachtablearr)) {
  333. foreach($attachtablearr as $attachtable => $pids) {
  334. foreach(C::t('forum_attachment_n')->fetch_all_by_id($attachtable, 'pid', $pids) as $attach) {
  335. $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
  336. $attach['url'] = $attach['isimage']
  337. ? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"{$_G[setting][attachurl]}forum/$attach[attachment]\" onload=\"if(this.width > 100) {this.resized=true; this.width=100;}\">"
  338. : "<a href=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
  339. $postlist[$attach['pid']]['message'] .= "<br /><br />File: ".attachtype(fileext($attach['filename'])."\t").$attach['url'];
  340. }
  341. }
  342. }
  343. }
  344. } else {
  345. if(submitcheck('modsubmit')) {
  346. if(!empty($moderation['ignore'])) {
  347. C::t('forum_thread')->update_by_tid_displayorder($moderation['ignore'], -2, array('displayorder'=>-3), $modfids);
  348. updatemoderate('tid', $moderation['ignore'], 1);
  349. }
  350. $threadsmod = 0;
  351. $pmlist = array();
  352. $reason = trim($_GET['reason']);
  353. if(!empty($moderation['delete'])) {
  354. $deletetids = array();
  355. $recyclebintids = '0';
  356. foreach(C::t('forum_thread')->fetch_all_by_tid_displayorder($moderation['delete'], $pstat, '=', $modfids) as $thread) {
  357. if($modforums['recyclebins'][$thread['fid']]) {
  358. $recyclebintids .= ','.$thread['tid'];
  359. } else {
  360. $deletetids[] = $thread['tid'];
  361. }
  362. if($thread['authorid'] && $thread['authorid'] != $_G['uid']) {
  363. $pmlist[] = array(
  364. 'act' => 'modthreads_delete',
  365. 'notevar' => array('reason' => dhtmlspecialchars($_GET['reason']), 'threadsubject' => $thread['subject']),
  366. 'authorid' => $thread['authorid'],
  367. );
  368. }
  369. }
  370. if($recyclebintids) {
  371. $rows = C::t('forum_thread')->update(explode(',', $recyclebintids), array('displayorder' => -1, 'moderated' => 1));
  372. updatemodworks('MOD', $rows);
  373. C::t('forum_post')->update_by_tid(0, explode(',', $recyclebintids), array('invisible' => -1), true);
  374. updatemodlog($recyclebintids, 'DEL');
  375. }
  376. require_once libfile('function/delete');
  377. deletethread($deletetids);
  378. updatemoderate('tid', $moderation['delete'], 2);
  379. }
  380. if($validatetids = dimplode($moderation['validate'])) {
  381. $tids = $moderatedthread = array();
  382. foreach(C::t('forum_thread')->fetch_all_by_tid_displayorder($moderation['validate'], $pstat, '=', ($modfids ? explode(',', $modfids) : null)) as $thread) {
  383. $tids[] = $thread['tid'];
  384. $poststatus = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
  385. $poststatus = $poststatus['status'];
  386. if(getstatus($poststatus, 3) == 0) {
  387. updatepostcredits('+', $thread['authorid'], 'post', $thread['fid']);
  388. $attachcount = C::t('forum_attachment_n')->count_by_id('tid:'.$thread['tid'], 'tid', $thread['tid']);
  389. updatecreditbyaction('postattach', $thread['authorid'], array(), '', $attachcount, 1, $thread['fid']);
  390. }
  391. $validatedthreads[] = $thread;
  392. if($thread['authorid'] && $thread['authorid'] != $_G['uid']) {
  393. $pmlist[] = array(
  394. 'act' => 'modthreads_validate',
  395. 'notevar' => array('reason' => dhtmlspecialchars($_GET['reason']), 'tid' => $thread['tid'], 'threadsubject' => $thread['subject'], 'from_id' => 0, 'from_idtype' => 'modthreads'),
  396. 'authorid' => $thread['authorid'],
  397. );
  398. }
  399. }
  400. if($tids) {
  401. $tidstr = dimplode($tids);
  402. C::t('forum_post')->update_by_tid(0, $tids, array('invisible' => 0), true, false, 1);
  403. C::t('forum_thread')->update($tids, array('displayorder'=>0, 'moderated'=>1));
  404. $threadsmod = DB::affected_rows();
  405. if($_G['fid']) {
  406. updateforumcount($_G['fid']);
  407. } else {
  408. $fids = array_keys($modforums['list']);
  409. foreach($fids as $f) {
  410. updateforumcount($f);
  411. }
  412. }
  413. updatemodworks('MOD', $threadsmod);
  414. updatemodlog($tidstr, 'MOD');
  415. updatemoderate('tid', $tids, 2);
  416. }
  417. }
  418. if($pmlist) {
  419. foreach($pmlist as $pm) {
  420. $threadsubject = $pm['thread'];
  421. $_G['tid'] = intval($pm['tid']);
  422. notification_add($pm['authorid'], 'system', $pm['act'], $pm['notevar'], 1);
  423. }
  424. }
  425. showmessage('modcp_mod_succeed', "{$cpscript}?mod=modcp&action=$_GET[action]&op=$op&filter=$filter&fid=$_G[fid]");
  426. }
  427. $modcount = C::t('common_moderate')->count_by_seach_for_thread($moderatestatus, ($modfids ? explode(',', $modfids) : null));
  428. $multipage = multi($modcount, $_G['tpp'], $page, "{$cpscript}?mod=modcp&action=$_GET[action]&op=$op&filter=$filter&fid=$_G[fid]");
  429. if($modcount) {
  430. $posttablearr = array();
  431. foreach(C::t('common_moderate')->fetch_all_by_search_for_thread($moderatestatus, ($modfids ? explode(',', $modfids) : null), $start_limit, $_G['tpp']) as $thread) {
  432. $thread['id'] = $thread['tid'];
  433. if($thread['authorid'] && $thread['author'] != '') {
  434. $thread['author'] = "<a href=\"home.php?mod=space&uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a>";
  435. } elseif($thread['authorid']) {
  436. $thread['author'] = "<a href=\"home.php?mod=space&uid=$thread[authorid]\" target=\"_blank\">UID $thread[uid]</a>";
  437. } else {
  438. $thread['author'] = 'guest';
  439. }
  440. $thread['dateline'] = dgmdate($thread['dateline']);
  441. $posttable = $thread['posttableid'] ? (string)$thread['posttableid'] : '0';
  442. $posttablearr[$posttable][$thread['tid']] = $thread['tid'];
  443. $postlist[$thread['tid']] = $thread;
  444. }
  445. $attachtablearr = array();
  446. foreach($posttablearr as $posttable => $tids) {
  447. foreach(C::t('forum_post')->fetch_all_by_tid($posttable, $tids, true, '', 0, 0, 1) as $post) {
  448. $thread = $postlist[$post['tid']] + $post;
  449. $thread['message'] = nl2br(dhtmlspecialchars($thread['message']));
  450. if($thread['attachment']) {
  451. $attachtable = getattachtableid($thread['tid']);
  452. $attachtablearr[$attachtable][$thread['tid']] = $thread['tid'];
  453. } else {
  454. $thread['attach'] = '';
  455. }
  456. if($thread['sortid']) {
  457. require_once libfile('function/threadsort');
  458. $threadsortshow = threadsortshow($thread['sortid'], $thread['tid']);
  459. foreach($threadsortshow['optionlist'] as $option) {
  460. $thread['sortinfo'] .= $option['title'].' '.$option['value']."<br />";
  461. }
  462. } else {
  463. $thread['sortinfo'] = '';
  464. }
  465. $postlist[$post['tid']] = $thread;
  466. }
  467. }
  468. if(!empty($attachtablearr)) {
  469. require_once libfile('function/attachment');
  470. foreach($attachtablearr as $attachtable => $tids) {
  471. foreach(C::t('forum_attachment_n')->fetch_all_by_id($attachtable, 'tid', $tids) as $attach) {
  472. $tid = $attach['tid'];
  473. $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl'];
  474. $attach['url'] = $attach['isimage']
  475. ? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" onload=\"if(this.width > 100) {this.resized=true; this.width=100;}\">"
  476. : "<a href=\"".$_G['setting']['attachurl']."forum/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
  477. $postlist[$tid]['attach'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($attach['filename'])."\t").$attach['url'];
  478. }
  479. }
  480. }
  481. }
  482. }
  483. ?>