forum_viewthread.php 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  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: forum_viewthread.php 36348 2017-01-13 06:36:44Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('function/forumlist');
  12. require_once libfile('function/discuzcode');
  13. require_once libfile('function/post');
  14. $thread = & $_G['forum_thread'];
  15. $forum = & $_G['forum'];
  16. if(!empty($_GET['checkrush']) && preg_match('/[^0-9_]/', $_GET['checkrush'])) {
  17. $_GET['checkrush'] = '';
  18. }
  19. if(!$_G['forum_thread'] || !$_G['forum']) {
  20. showmessage('thread_nonexistence');
  21. }
  22. $page = max(1, $_G['page']);
  23. $_GET['stand'] = isset($_GET['stand']) && in_array($_GET['stand'], array('0', '1', '2')) ? $_GET['stand'] : null;
  24. if($page === 1 && !empty($_G['setting']['antitheft']['allow']) && empty($_G['setting']['antitheft']['disable']['thread']) && empty($_G['forum']['noantitheft'])) {
  25. helper_antitheft::check($_G['forum_thread']['tid'], 'tid');
  26. }
  27. if($_G['setting']['cachethreadlife'] && $_G['forum']['threadcaches'] && !$_G['uid'] && $page == 1 && !$_G['forum']['special'] && empty($_GET['do']) && !defined('IN_ARCHIVER') && !defined('IN_MOBILE')) {
  28. viewthread_loadcache();
  29. }
  30. $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
  31. $threadtable_info = !empty($_G['cache']['threadtable_info']) ? $_G['cache']['threadtable_info'] : array();
  32. $archiveid = $thread['threadtableid'];
  33. $thread['is_archived'] = $archiveid ? true : false;
  34. $thread['archiveid'] = $archiveid;
  35. $forum['threadtableid'] = $archiveid;
  36. $threadtable = $thread['threadtable'];
  37. $posttableid = $thread['posttableid'];
  38. $posttable = $thread['posttable'];
  39. $_G['action']['fid'] = $_G['fid'];
  40. $_G['action']['tid'] = $_G['tid'];
  41. if($_G['fid'] == $_G['setting']['followforumid'] && $_G['adminid'] != 1) {
  42. dheader("Location: home.php?mod=follow");
  43. }
  44. $st_p = $_G['uid'].'|'.TIMESTAMP;
  45. dsetcookie('st_p', $st_p.'|'.md5($st_p.$_G['config']['security']['authkey']));
  46. $close_leftinfo = intval($_G['setting']['close_leftinfo']);
  47. if($_G['setting']['close_leftinfo_userctrl']) {
  48. if($_G['cookie']['close_leftinfo'] == 1) {
  49. $close_leftinfo = 1;
  50. } elseif($_G['cookie']['close_leftinfo'] == 2) {
  51. $close_leftinfo = 0;
  52. }
  53. }
  54. $_GET['authorid'] = !empty($_GET['authorid']) ? intval($_GET['authorid']) : 0;
  55. $_GET['ordertype'] = !empty($_GET['ordertype']) ? intval($_GET['ordertype']) : 0;
  56. $_GET['from'] = in_array($_GET['from'], array('preview', 'portal', 'album')) ? $_GET['from'] : '';
  57. if($_GET['from'] == 'portal' && !$_G['setting']['portalstatus']) {
  58. $_GET['from'] = '';
  59. } elseif($_GET['from'] == 'preview' && !$_G['inajax']) {
  60. $_GET['from'] = '';
  61. } elseif($_GET['from'] == 'album' && ($_G['setting']['guestviewthumb']['flag'] && !$_G['uid'] && IN_MOBILE != 2 || !$_G['group']['allowgetimage'])) {
  62. $_GET['from'] = '';
  63. }
  64. $fromuid = $_G['setting']['creditspolicy']['promotion_visit'] && $_G['uid'] ? '&amp;fromuid='.$_G['uid'] : '';
  65. $feeduid = $_G['forum_thread']['authorid'] ? $_G['forum_thread']['authorid'] : 0;
  66. $feedpostnum = $_G['forum_thread']['replies'] > $_G['ppp'] ? $_G['ppp'] : ($_G['forum_thread']['replies'] ? $_G['forum_thread']['replies'] : 1);
  67. if(!empty($_GET['extra'])) {
  68. parse_str($_GET['extra'], $extra);
  69. $_GET['extra'] = array();
  70. foreach($extra as $_k => $_v) {
  71. if(preg_match('/^\w+$/', $_k)) {
  72. if(!is_array($_v)) {
  73. $_GET['extra'][] = $_k.'='.rawurlencode($_v);
  74. } else {
  75. $_GET['extra'][] = http_build_query(array($_k => $_v));
  76. }
  77. }
  78. }
  79. $_GET['extra'] = implode('&', $_GET['extra']);
  80. }
  81. $_G['forum_threadindex'] = '';
  82. $skipaids = $aimgs = $_G['forum_posthtml'] = array();
  83. $thread['subjectenc'] = rawurlencode($_G['forum_thread']['subject']);
  84. $thread['short_subject'] = cutstr($_G['forum_thread']['subject'], 52);
  85. $navigation = '';
  86. if($_GET['from'] == 'portal') {
  87. if($_G['forum']['status'] == 3) {
  88. _checkviewgroup();
  89. }
  90. $_G['setting']['ratelogon'] = 1;
  91. $navigation = ' <em>&rsaquo;</em> <a href="portal.php">'.lang('core', 'portal').'</a>';
  92. $navsubject = $_G['forum_thread']['subject'];
  93. $navtitle = $_G['forum_thread']['subject'];
  94. }elseif($_GET['from'] == 'preview') {
  95. $_G['setting']['ratelogon'] = 1;
  96. } elseif($_G['forum']['status'] == 3) {
  97. _checkviewgroup();
  98. $nav = get_groupnav($_G['forum']);
  99. $navigation = ' <em>&rsaquo;</em> <a href="group.php">'.$_G['setting']['navs'][3]['navname'].'</a> '.$nav['nav'];
  100. $upnavlink = 'forum.php?mod=forumdisplay&amp;fid='.$_G['fid'].($_GET['extra'] && !IS_ROBOT ? '&amp;'.$_GET['extra'] : '');
  101. $_G['grouptypeid'] = $_G['forum']['fup'];
  102. } else {
  103. $navigation = '';
  104. $upnavlink = 'forum.php?mod=forumdisplay&amp;fid='.$_G['fid'].($_GET['extra'] && !IS_ROBOT ? '&amp;'.$_GET['extra'] : '');
  105. if($_G['forum']['type'] == 'sub') {
  106. $fup = $_G['cache']['forums'][$_G['forum']['fup']]['fup'];
  107. $t_link = $_G['cache']['forums'][$fup]['type'] == 'group' ? 'forum.php?gid='.$fup : 'forum.php?mod=forumdisplay&fid='.$fup;
  108. $navigation .= ' <em>&rsaquo;</em> <a href="'.$t_link.'">'.($_G['cache']['forums'][$fup]['name']).'</a>';
  109. }
  110. if($_G['forum']['fup']) {
  111. $fup = $_G['forum']['fup'];
  112. $t_link = $_G['cache']['forums'][$fup]['type'] == 'group' ? 'forum.php?gid='.$fup : 'forum.php?mod=forumdisplay&fid='.$fup;
  113. $navigation .= ' <em>&rsaquo;</em> <a href="'.$t_link.'">'.($_G['cache']['forums'][$fup]['name']).'</a>';
  114. }
  115. $t_link = 'forum.php?mod=forumdisplay&amp;fid='.$_G['fid'].($_GET['extra'] && !IS_ROBOT ? '&amp;'.$_GET['extra'] : '');
  116. $navigation .= ' <em>&rsaquo;</em> <a href="'.$t_link.'">'.($_G['forum']['name']).'</a>';
  117. if($archiveid) {
  118. if($threadtable_info[$archiveid]['displayname']) {
  119. $t_name = dhtmlspecialchars($threadtable_info[$archiveid]['displayname']);
  120. } else {
  121. $t_name = lang('core', 'archive').' '.$archiveid;
  122. }
  123. $navigation .= ' <em>&rsaquo;</em> <a href="forum.php?mod=forumdisplay&fid='.$_G['fid'].'&archiveid='.$archiveid.'">'.$t_name.'</a>';
  124. }
  125. unset($t_link, $t_name);
  126. }
  127. $_GET['extra'] = $_GET['extra'] ? rawurlencode($_GET['extra']) : '';
  128. if(@in_array('forum_viewthread', $_G['setting']['rewritestatus'])) {
  129. $canonical = rewriteoutput('forum_viewthread', 1, '', $_G['tid'], 1, '', '');
  130. } else {
  131. $canonical = 'forum.php?mod=viewthread&tid='.$_G['tid'];
  132. }
  133. $_G['setting']['seohead'] .= '<link href="'.$_G['siteurl'].$canonical.'" rel="canonical" />';
  134. $_G['forum_tagscript'] = '';
  135. $threadsort = $thread['sortid'] && isset($_G['forum']['threadsorts']['types'][$thread['sortid']]) ? 1 : 0;
  136. if($threadsort) {
  137. require_once libfile('function/threadsort');
  138. $threadsortshow = threadsortshow($thread['sortid'], $_G['tid']);
  139. }
  140. if(empty($_G['forum']['allowview'])) {
  141. if(!$_G['forum']['viewperm'] && !$_G['group']['readaccess']) {
  142. showmessage('group_nopermission', NULL, array('grouptitle' => $_G['group']['grouptitle']), array('login' => 1));
  143. } elseif($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm'])) {
  144. showmessagenoperm('viewperm', $_G['fid']);
  145. }
  146. } elseif($_G['forum']['allowview'] == -1) {
  147. showmessage('forum_access_view_disallow');
  148. }
  149. if($_G['forum']['formulaperm']) {
  150. formulaperm($_G['forum']['formulaperm']);
  151. }
  152. if($_G['forum']['password'] && $_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) {
  153. dheader("Location: $_G[siteurl]forum.php?mod=forumdisplay&fid=$_G[fid]");
  154. }
  155. if($_G['forum']['price'] && !$_G['forum']['ismoderator']) {
  156. $membercredits = C::t('common_member_forum_buylog')->get_credits($_G['uid'], $_G['fid']);
  157. $paycredits = $_G['forum']['price'] - $membercredits;
  158. if($paycredits > 0) {
  159. dheader("Location: $_G[siteurl]forum.php?mod=forumdisplay&fid=$_G[fid]");
  160. }
  161. }
  162. if($_G['forum_thread']['readperm'] && $_G['forum_thread']['readperm'] > $_G['group']['readaccess'] && !$_G['forum']['ismoderator'] && $_G['forum_thread']['authorid'] != $_G['uid']) {
  163. showmessage('thread_nopermission', NULL, array('readperm' => $_G['forum_thread']['readperm']), array('login' => 1));
  164. }
  165. $usemagic = array('user' => array(), 'thread' => array());
  166. $replynotice = getstatus($_G['forum_thread']['status'], 6);
  167. $hiddenreplies = getstatus($_G['forum_thread']['status'], 2);
  168. $rushreply = getstatus($_G['forum_thread']['status'], 3);
  169. $savepostposition = getstatus($_G['forum_thread']['status'], 1);
  170. $incollection = getstatus($_G['forum_thread']['status'], 9);
  171. $_G['forum_threadpay'] = FALSE;
  172. if($_G['forum_thread']['price'] > 0 && $_G['forum_thread']['special'] == 0) {
  173. if($_G['setting']['maxchargespan'] && TIMESTAMP - $_G['forum_thread']['dateline'] >= $_G['setting']['maxchargespan'] * 3600) {
  174. C::t('forum_thread')->update($_G['tid'], array('price' => 0), false, false, $archiveid);
  175. $_G['forum_thread']['price'] = 0;
  176. } else {
  177. $exemptvalue = $_G['forum']['ismoderator'] ? 128 : 16;
  178. if(!($_G['group']['exempt'] & $exemptvalue) && $_G['forum_thread']['authorid'] != $_G['uid']) {
  179. if(!(C::t('common_credit_log')->count_by_uid_operation_relatedid($_G['uid'], 'BTC', $_G['tid']))) {
  180. require_once libfile('thread/pay', 'include');
  181. $_G['forum_threadpay'] = TRUE;
  182. }
  183. }
  184. }
  185. }
  186. if($rushreply) {
  187. $rewardfloor = '';
  188. $rushresult = $rewardfloorarr = $rewardfloorarray = array();
  189. $rushresult = C::t('forum_threadrush')->fetch($_G['tid']);
  190. if($rushresult['creditlimit'] == -996) {
  191. $rushresult['creditlimit'] = '';
  192. }
  193. if((TIMESTAMP < $rushresult['starttimefrom'] || ($rushresult['starttimeto'] && TIMESTAMP > $rushresult['starttimeto']) || ($rushresult['stopfloor'] && $_G['forum_thread']['replies'] + 1 >= $rushresult['stopfloor'])) && $_G['forum_thread']['closed'] == 0) {
  194. C::t('forum_thread')->update($_G['tid'], array('closed'=>1));
  195. } elseif(($rushresult['starttimefrom'] && TIMESTAMP > $rushresult['starttimefrom']) && $_G['forum_thread']['closed'] == 1) {
  196. if(($rushresult['starttimeto'] && TIMESTAMP < $rushresult['starttimeto'] || !$rushresult['starttimeto']) && ($rushresult['stopfloor'] && $_G['forum_thread']['replies'] + 1 < $rushresult['stopfloor'] || !$rushresult['stopfloor'])) {
  197. C::t('forum_thread')->update($_G['tid'], array('closed'=>0));
  198. }
  199. }
  200. if($rushresult['starttimefrom'] > TIMESTAMP) {
  201. $rushresult['timer'] = $rushresult['starttimefrom'] - TIMESTAMP;
  202. $rushresult['timertype'] = 'start';
  203. } elseif($rushresult['starttimeto'] > TIMESTAMP) {
  204. $rushresult['timer'] = $rushresult['starttimeto'] - TIMESTAMP;
  205. $rushresult['timertype'] = 'end';
  206. }
  207. $rushresult['starttimefrom'] = $rushresult['starttimefrom'] ? dgmdate($rushresult['starttimefrom']) : '';
  208. $rushresult['starttimeto'] = $rushresult['starttimeto'] ? dgmdate($rushresult['starttimeto']) : '';
  209. $rushresult['creditlimit_title'] = $_G['setting']['creditstransextra'][11] ? $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][11]]['title'] : lang('forum/misc', 'credit_total');
  210. }
  211. if($_G['forum_thread']['replycredit'] > 0) {
  212. $_G['forum_thread']['replycredit_rule'] = C::t('forum_replycredit')->fetch($thread['tid']);
  213. $_G['forum_thread']['replycredit_rule']['remaining'] = $_G['forum_thread']['replycredit'] / $_G['forum_thread']['replycredit_rule']['extcredits'];
  214. $_G['forum_thread']['replycredit_rule']['extcreditstype'] = $_G['forum_thread']['replycredit_rule']['extcreditstype'] ? $_G['forum_thread']['replycredit_rule']['extcreditstype'] : $_G['setting']['creditstransextra'][10] ;
  215. }
  216. $_G['group']['raterange'] = $_G['setting']['modratelimit'] && $adminid == 3 && !$_G['forum']['ismoderator'] ? array() : $_G['group']['raterange'];
  217. $_G['group']['allowgetattach'] = !empty($_G['forum']['allowgetattach']) || ($_G['group']['allowgetattach'] && !$_G['forum']['getattachperm']) || forumperm($_G['forum']['getattachperm']);
  218. $_G['group']['allowgetimage'] = !empty($_G['forum']['allowgetimage']) || ($_G['group']['allowgetimage'] && !$_G['forum']['getattachperm']) || forumperm($_G['forum']['getattachperm']);
  219. $_G['getattachcredits'] = '';
  220. if($_G['forum_thread']['attachment']) {
  221. $exemptvalue = $_G['forum']['ismoderator'] ? 32 : 4;
  222. if(!($_G['group']['exempt'] & $exemptvalue)) {
  223. $creditlog = updatecreditbyaction('getattach', $_G['uid'], array(), '', 1, 0, $_G['forum_thread']['fid']);
  224. $p = '';
  225. if($creditlog['updatecredit']) for($i = 1;$i <= 8;$i++) {
  226. if($policy = $creditlog['extcredits'.$i]) {
  227. $_G['getattachcredits'] .= $p.$_G['setting']['extcredits'][$i]['title'].' '.$policy.' '.$_G['setting']['extcredits'][$i]['unit'];
  228. $p = ', ';
  229. }
  230. }
  231. }
  232. }
  233. $exemptvalue = $_G['forum']['ismoderator'] ? 64 : 8;
  234. $_G['forum_attachmentdown'] = $_G['group']['exempt'] & $exemptvalue;
  235. list($seccodecheck, $secqaacheck) = seccheck('post', 'reply');
  236. $usesigcheck = $_G['uid'] && $_G['group']['maxsigsize'];
  237. $postlist = $_G['forum_attachtags'] = $attachlist = $_G['forum_threadstamp'] = array();
  238. $aimgcount = 0;
  239. $_G['forum_attachpids'] = array();
  240. if(!empty($_GET['action']) && $_GET['action'] == 'printable' && $_G['tid']) {
  241. require_once libfile('thread/printable', 'include');
  242. dexit();
  243. }
  244. if($_G['forum_thread']['stamp'] >= 0) {
  245. $_G['forum_threadstamp'] = $_G['cache']['stamps'][$_G['forum_thread']['stamp']];
  246. }
  247. $lastmod = viewthread_lastmod($_G['forum_thread']);
  248. $showsettings = str_pad(decbin($_G['setting']['showsettings']), 3, '0', STR_PAD_LEFT);
  249. $showsignatures = $showsettings{0};
  250. $showavatars = $showsettings{1};
  251. $_G['setting']['showimages'] = $showsettings{2};
  252. $highlightstatus = isset($_GET['highlight']) && str_replace('+', '', $_GET['highlight']) ? 1 : 0;
  253. $_G['forum']['allowreply'] = isset($_G['forum']['allowreply']) ? $_G['forum']['allowreply'] : '';
  254. $_G['forum']['allowpost'] = isset($_G['forum']['allowpost']) ? $_G['forum']['allowpost'] : '';
  255. $allowpostreply = ($_G['forum']['allowreply'] != -1) && (($_G['forum_thread']['isgroup'] || (!$_G['forum_thread']['closed'] && !checkautoclose($_G['forum_thread']))) || $_G['forum']['ismoderator']) && ((!$_G['forum']['replyperm'] && $_G['group']['allowreply']) || ($_G['forum']['replyperm'] && forumperm($_G['forum']['replyperm'])) || $_G['forum']['allowreply']);
  256. $fastpost = $_G['setting']['fastpost'] && !$_G['forum_thread']['archiveid'] && ($_G['forum']['status'] != 3 || $_G['isgroupuser']);
  257. $allowfastpost = $_G['setting']['fastpost'] && $allowpostreply;
  258. if(!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum']) || !$_G['adminid'] && (!cknewuser(1) || $_G['setting']['newbiespan'] && (!getuserprofile('lastpost') || TIMESTAMP - getuserprofile('lastpost') < $_G['setting']['newbiespan'] * 60) && TIMESTAMP - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60)) {
  259. $allowfastpost = false;
  260. }
  261. $_G['group']['allowpost'] = $_G['forum']['allowpost'] != -1 && ((!$_G['forum']['postperm'] && $_G['group']['allowpost']) || ($_G['forum']['postperm'] && forumperm($_G['forum']['postperm'])) || $_G['forum']['allowpost']);
  262. $_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
  263. $allowpostattach = $allowpostreply && ($_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || (!$_G['forum']['postattachperm'] && $_G['group']['allowpostattach']) || ($_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm']))));
  264. if($_G['group']['allowpost']) {
  265. $_G['group']['allowpostpoll'] = $_G['group']['allowpostpoll'] && ($_G['forum']['allowpostspecial'] & 1);
  266. $_G['group']['allowposttrade'] = $_G['group']['allowposttrade'] && ($_G['forum']['allowpostspecial'] & 2);
  267. $_G['group']['allowpostreward'] = $_G['group']['allowpostreward'] && ($_G['forum']['allowpostspecial'] & 4) && isset($_G['setting']['extcredits'][$_G['setting']['creditstrans']]);
  268. $_G['group']['allowpostactivity'] = $_G['group']['allowpostactivity'] && ($_G['forum']['allowpostspecial'] & 8);
  269. $_G['group']['allowpostdebate'] = $_G['group']['allowpostdebate'] && ($_G['forum']['allowpostspecial'] & 16);
  270. } else {
  271. $_G['group']['allowpostpoll'] = $_G['group']['allowposttrade'] = $_G['group']['allowpostreward'] = $_G['group']['allowpostactivity'] = $_G['group']['allowpostdebate'] = FALSE;
  272. }
  273. $_G['forum']['threadplugin'] = $_G['group']['allowpost'] && $_G['setting']['threadplugins'] ? is_array($_G['forum']['threadplugin']) ? $_G['forum']['threadplugin'] : dunserialize($_G['forum']['threadplugin']) : array();
  274. $_G['setting']['visitedforums'] = $_G['setting']['visitedforums'] && $_G['forum']['status'] != 3 ? visitedforums() : '';
  275. $relatedthreadlist = array();
  276. $relatedthreadupdate = $tagupdate = FALSE;
  277. $relatedkeywords = $tradekeywords = $_G['forum_firstpid'] = '';
  278. if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], 'modarea_c') === FALSE) {
  279. $collapseimg['modarea_c'] = 'collapsed_no';
  280. $collapse['modarea_c'] = '';
  281. } else {
  282. $collapseimg['modarea_c'] = 'collapsed_yes';
  283. $collapse['modarea_c'] = 'display: none';
  284. }
  285. $threadtag = array();
  286. viewthread_updateviews($archiveid);
  287. $_G['setting']['infosidestatus']['posts'] = $_G['setting']['infosidestatus'][1] && isset($_G['setting']['infosidestatus']['f'.$_G['fid']]['posts']) ? $_G['setting']['infosidestatus']['f'.$_G['fid']]['posts'] : $_G['setting']['infosidestatus']['posts'];
  288. $postfieldsadd = $specialadd1 = $specialadd2 = $specialextra = '';
  289. $tpids = array();
  290. if($_G['forum_thread']['special'] == 2) {
  291. if(!empty($_GET['do']) && $_GET['do'] == 'tradeinfo') {
  292. require_once libfile('thread/trade', 'include');
  293. }
  294. $query = C::t('forum_trade')->fetch_all_thread_goods($_G['tid']);
  295. foreach($query as $trade) {
  296. $tpids[] = $trade['pid'];
  297. }
  298. $specialadd2 = 1;
  299. } elseif($_G['forum_thread']['special'] == 5) {
  300. if(isset($_GET['stand'])) {
  301. $specialadd2 = 1;
  302. $specialextra = "&amp;stand=$_GET[stand]";
  303. }
  304. }
  305. $onlyauthoradd = $threadplughtml = '';
  306. $maxposition = 0;
  307. if(empty($_GET['viewpid'])) {
  308. if(!in_array($_G['forum_thread']['special'], array(2,3,5))) {
  309. $disablepos = !$rushreply && C::t('forum_threaddisablepos')->fetch($_G['tid']) ? 1 : 0;
  310. if(!$disablepos) {
  311. if($_G['forum_thread']['maxposition']) {
  312. $maxposition = $_G['forum_thread']['maxposition'];
  313. } else {
  314. $maxposition = C::t('forum_post')->fetch_maxposition_by_tid($posttableid, $_G['tid']);
  315. C::t('forum_thread')->update($_G['tid'], array('maxposition' => $maxposition));
  316. }
  317. }
  318. }
  319. $ordertype = empty($_GET['ordertype']) && getstatus($_G['forum_thread']['status'], 4) ? 1 : $_GET['ordertype'];
  320. if($_GET['from'] == 'album') {
  321. $ordertype = 1;
  322. }
  323. $sticklist = array();
  324. if($_G['page'] === 1 && $_G['forum_thread']['stickreply'] && empty($_GET['authorid'])) {
  325. $poststick = C::t('forum_poststick')->fetch_all_by_tid($_G['tid']);
  326. foreach(C::t('forum_post')->fetch_all($posttableid, array_keys($poststick)) as $post) {
  327. $post['position'] = $poststick[$post['pid']]['position'];
  328. $post['avatar'] = avatar($post['authorid'], 'small');
  329. $post['isstick'] = true;
  330. $sticklist[$post['pid']] = $post;
  331. }
  332. $stickcount = count($sticklist);
  333. }
  334. if($rushreply) {
  335. $rushids = $rushpids = $rushpositionlist = $preg = $arr = array();
  336. $str = ',,';
  337. $preg_str = rushreply_rule($rushresult);
  338. if($_GET['checkrush']) {
  339. $maxposition = 0;
  340. for($i = 1; $i <= $_G['forum_thread']['replies'] + 1; $i++) {
  341. $str = $str.$i.',,';
  342. }
  343. preg_match_all($preg_str, $str, $arr);
  344. $arr = $arr[0];
  345. foreach($arr as $var) {
  346. $var = str_replace(',', '', $var);
  347. $rushids[$var] = $var;
  348. }
  349. $temp_reply = $_G['forum_thread']['replies'];
  350. $_G['forum_thread']['replies'] = $countrushpost = max(0, count($rushids) - 1);
  351. $rushids = array_slice($rushids, ($page - 1) * $_G['ppp'], $_G['ppp']);
  352. foreach(C::t('forum_post')->fetch_all_by_tid_position($posttableid, $_G['tid'], $rushids) as $post) {
  353. $postarr[$post['position']] = $post;
  354. }
  355. } else {
  356. for($i = ($page - 1) * $_G['ppp'] + 1; $i <= $page * $_G['ppp']; $i++) {
  357. $str = $str.$i.',,';
  358. }
  359. preg_match_all($preg_str, $str, $arr);
  360. $arr = $arr[0];
  361. foreach($arr as $var) {
  362. $var = str_replace(',', '', $var);
  363. $rushids[$var] = $var;
  364. }
  365. $_G['forum_thread']['replies'] = $_G['forum_thread']['replies'] - 1;
  366. }
  367. }
  368. if(!empty($_GET['authorid'])) {
  369. $maxposition = 0;
  370. $_G['forum_thread']['replies'] = C::t('forum_post')->count_by_tid_invisible_authorid($_G['tid'], $_GET['authorid']);
  371. $_G['forum_thread']['replies']--;
  372. if($_G['forum_thread']['replies'] < 0) {
  373. showmessage('undefined_action');
  374. }
  375. $onlyauthoradd = 1;
  376. } elseif($_G['forum_thread']['special'] == 5) {
  377. if(isset($_GET['stand']) && $_GET['stand'] >= 0 && $_GET['stand'] < 3) {
  378. $_G['forum_thread']['replies'] = C::t('forum_debatepost')->count_by_tid_stand($_G['tid'], $_GET['stand']);
  379. } else {
  380. $_G['forum_thread']['replies'] = C::t('forum_post')->count_visiblepost_by_tid($_G['tid']);
  381. $_G['forum_thread']['replies'] > 0 && $_G['forum_thread']['replies']--;
  382. }
  383. } elseif($_G['forum_thread']['special'] == 2) {
  384. $tradenum = C::t('forum_trade')->fetch_counter_thread_goods($_G['tid']);
  385. $_G['forum_thread']['replies'] -= $tradenum;
  386. }
  387. if($maxposition) {
  388. $_G['forum_thread']['replies'] = $maxposition - 1;
  389. }
  390. $_G['ppp'] = $_G['forum']['threadcaches'] && !$_G['uid'] ? $_G['setting']['postperpage'] : $_G['ppp'];
  391. $totalpage = ceil(($_G['forum_thread']['replies'] + 1) / $_G['ppp']);
  392. $page > $totalpage && $page = $totalpage;
  393. $_G['forum_pagebydesc'] = !$maxposition && $page > 2 && $page > ($totalpage / 2) ? TRUE : FALSE;
  394. if($_G['forum_pagebydesc']) {
  395. $firstpagesize = ($_G['forum_thread']['replies'] + 1) % $_G['ppp'];
  396. $_G['forum_ppp3'] = $_G['forum_ppp2'] = $page == $totalpage && $firstpagesize ? $firstpagesize : $_G['ppp'];
  397. $realpage = $totalpage - $page + 1;
  398. if($firstpagesize == 0) {
  399. $firstpagesize = $_G['ppp'];
  400. }
  401. $start_limit = max(0, ($realpage - 2) * $_G['ppp'] + $firstpagesize);
  402. $_G['forum_numpost'] = ($page - 1) * $_G['ppp'];
  403. if($ordertype != 1) {
  404. } else {
  405. $_G['forum_numpost'] = $_G['forum_thread']['replies'] + 2 - $_G['forum_numpost'] + ($page > 1 ? 1 : 0);
  406. }
  407. } else {
  408. $start_limit = $_G['forum_numpost'] = max(0, ($page - 1) * $_G['ppp']);
  409. if($start_limit > $_G['forum_thread']['replies']) {
  410. $start_limit = $_G['forum_numpost'] = 0;
  411. $page = 1;
  412. }
  413. if($ordertype != 1) {
  414. } else {
  415. $_G['forum_numpost'] = $_G['forum_thread']['replies'] + 2 - $_G['forum_numpost'] + ($page > 1 ? 1 : 0);
  416. }
  417. }
  418. $multipage = multi($_G['forum_thread']['replies'] + 1, $_G['ppp'], $page, 'forum.php?mod=viewthread&tid='.$_G['tid'].
  419. ($_G['forum_thread']['is_archived'] ? '&archive='.$_G['forum_thread']['archiveid'] : '').
  420. '&amp;extra='.$_GET['extra'].
  421. ($ordertype && $ordertype != getstatus($_G['forum_thread']['status'], 4) ? '&amp;ordertype='.$ordertype : '').
  422. (isset($_GET['highlight']) ? '&amp;highlight='.rawurlencode($_GET['highlight']) : '').
  423. (!empty($_GET['authorid']) ? '&amp;authorid='.$_GET['authorid'] : '').
  424. (!empty($_GET['from']) ? '&amp;from='.$_GET['from'] : '').
  425. (!empty($_GET['checkrush']) ? '&amp;checkrush='.$_GET['checkrush'] : '').
  426. (!empty($_GET['modthreadkey']) ? '&amp;modthreadkey='.rawurlencode($_GET['modthreadkey']) : '').
  427. $specialextra);
  428. } else {
  429. $_GET['viewpid'] = intval($_GET['viewpid']);
  430. $pageadd = "AND p.pid='$_GET[viewpid]'";
  431. }
  432. $_G['forum_newpostanchor'] = $_G['forum_postcount'] = 0;
  433. $_G['forum_onlineauthors'] = $_G['forum_cachepid'] = $_G['blockedpids'] = array();
  434. $isdel_post = $cachepids = $postusers = $skipaids = array();
  435. if($_G['forum_auditstatuson'] || in_array($_G['forum_thread']['displayorder'], array(-2, -3, -4)) && $_G['forum_thread']['authorid'] == $_G['uid']) {
  436. $visibleallflag = 1;
  437. }
  438. if($maxposition) {
  439. $start = ($page - 1) * $_G['ppp'] + 1;
  440. $end = $start + $_G['ppp'];
  441. if($ordertype == 1) {
  442. $end = $maxposition - ($page - 1) * $_G['ppp'] + ($page > 1 ? 2 : 1);
  443. $start = $end - $_G['ppp'] + ($page > 1 ? 0 : 1);
  444. $start = max(array(1,$start));
  445. }
  446. $have_badpost = $realpost = $lastposition = 0;
  447. foreach(C::t('forum_post')->fetch_all_by_tid_range_position($posttableid, $_G['tid'], $start, $end, $maxposition, $ordertype) as $post) {
  448. if($post['invisible'] != 0) {
  449. $have_badpost = 1;
  450. }
  451. $cachepids[$post[position]] = $post['pid'];
  452. $postarr[$post[position]] = $post;
  453. $lastposition = $post['position'];
  454. }
  455. $realpost = count($postarr);
  456. if($realpost != $_G['ppp'] || $have_badpost) {
  457. $k = 0;
  458. for($i = $start; $i < $end; $i ++) {
  459. if(!empty($cachepids[$i])) {
  460. $k = $cachepids[$i];
  461. $isdel_post[$i] = array('deleted' => 1, 'pid' => $k, 'message' => '', 'position' => $i);
  462. } elseif($i < $maxposition || ($lastposition && $i < $lastposition)) {
  463. $isdel_post[$i] = array('deleted' => 1, 'pid' => $k, 'message' => '', 'position' => $i);
  464. }
  465. $k ++;
  466. }
  467. }
  468. $pagebydesc = false;
  469. }
  470. if($_GET['checkrush'] && $rushreply) {
  471. $_G['forum_thread']['replies'] = $temp_reply;
  472. }
  473. if(!$maxposition && empty($postarr)) {
  474. if(empty($_GET['viewpid'])) {
  475. if($_G['forum_thread']['special'] == 2) {
  476. $postarr = C::t('forum_post')->fetch_all_tradepost_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $tpids, $_G['forum_pagebydesc'], $ordertype, $start_limit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $_G['ppp']));
  477. } elseif($_G['forum_thread']['special'] == 5) {
  478. $postarr = C::t('forum_post')->fetch_all_debatepost_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $_GET['stand'], $_G['forum_pagebydesc'], $ordertype, $start_limit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $_G['ppp']));
  479. } else {
  480. $postarr = C::t('forum_post')->fetch_all_common_viewthread_by_tid($_G['tid'], $visibleallflag, $_GET['authorid'], $_G['forum_pagebydesc'], $ordertype, $_G['forum_thread']['replies'] + 1, $start_limit, ($_G['forum_pagebydesc'] ? $_G['forum_ppp2'] : $_G['ppp']));
  481. }
  482. } else {
  483. $post = array();
  484. if($_G['forum_thread']['special'] == 2) {
  485. if(!in_array($_GET['viewpid'], $tpids)) {
  486. $post = C::t('forum_post')->fetch('tid:'.$_G['tid'],$_GET['viewpid']);
  487. }
  488. } elseif($_G['forum_thread']['special'] == 5) {
  489. $post = C::t('forum_post')->fetch('tid:'.$_G['tid'], $_GET['viewpid']);
  490. $debatpost = C::t('forum_debatepost')->fetch($_GET['viewpid']);
  491. if(!isset($_GET['stand']) || (isset($_GET['stand']) && ($post['first'] == 1 || $debatpost['stand'] == $_GET['stand']))) {
  492. $post = array_merge($post, $debatpost);
  493. } else {
  494. $post = array();
  495. }
  496. unset($debatpost);
  497. } else {
  498. $post = C::t('forum_post')->fetch('tid:'.$_G['tid'], $_GET['viewpid']);
  499. }
  500. if($post['tid'] != $_G['tid']) {
  501. $post = array();
  502. }
  503. if($post) {
  504. if($visibleallflag || (!$visibleallflag && !$post['invisible'])) {
  505. $postarr[0] = $post;
  506. }
  507. }
  508. }
  509. }
  510. if(!empty($isdel_post)) {
  511. $updatedisablepos = false;
  512. foreach($isdel_post as $id => $post) {
  513. if(isset($postarr[$id]['invisible']) && ($postarr[$id]['invisible'] == 0 || $postarr[$id]['invisible'] == -3 || $visibleallflag)) {
  514. continue;
  515. }
  516. $postarr[$id] = $post;
  517. $updatedisablepos = true;
  518. }
  519. if($updatedisablepos && !$rushreply) {
  520. C::t('forum_threaddisablepos')->insert(array('tid' => $_G['tid']), false, true);
  521. dheader("Location:forum.php?mod=viewthread&tid=$_G[tid]");
  522. }
  523. $ordertype != 1 ? ksort($postarr) : krsort($postarr);
  524. }
  525. $summary = '';
  526. if($page == 1 && $ordertype == 1) {
  527. $firstpost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid']);
  528. if($firstpost['invisible'] == 0 || $visibleallflag == 1) {
  529. $postarr = array_merge(array($firstpost), $postarr);
  530. unset($firstpost);
  531. }
  532. }
  533. $tagnames = $locationpids = $hotpostarr = $hotpids = $member_blackList = array();
  534. $remainhots = ($_G['page'] == 1 && !$rushreply && !$hiddenreplies && !$_G['forum_thread']['special'] && !$_G['forum']['noforumrecommend'] && empty($_GET['authorid'])) ? $_G['setting']['threadhotreplies'] : 0;
  535. if($remainhots) {
  536. $hotpids = array_keys(C::t('forum_hotreply_number')->fetch_all_by_tid_total($_G['tid'], 10));
  537. $remainhots = $remainhots - count($hotpids);
  538. }
  539. if($_G['setting']['nofilteredpost'] && $_G['forum_thread']['replies'] > $_G['setting']['postperpage'] && $remainhots) {
  540. $hotpids = array_merge($hotpids, array_keys(C::t('forum_filter_post')->fetch_all_by_tid_postlength_limit($_G['tid'], $remainhots)));
  541. }
  542. if($hotpids) {
  543. $hotposts = C::t('forum_post')->fetch_all_by_pid($posttableid, $hotpids);
  544. foreach($hotpids as $hotpid) {
  545. if($hotposts[$hotpid]) {
  546. $hotpostarr[$hotpid] = $hotposts[$hotpid];
  547. $hotpostarr[$hotpid]['hotrecommended'] = true;
  548. }
  549. }
  550. unset($hotposts);
  551. }
  552. if($hotpostarr || $sticklist) {
  553. $_newpostarr_first = array_shift($postarr);
  554. $postarr = (array)$sticklist + (array)$hotpostarr + $postarr;
  555. array_unshift($postarr, $_newpostarr_first);
  556. unset($_newpostarr_first, $sticklist);
  557. }
  558. foreach($postarr as $post) {
  559. if(($onlyauthoradd && empty($post['anonymous']) || !$onlyauthoradd) && !isset($postlist[$post['pid']])) {
  560. if(isset($hotpostarr[$post['pid']])) {
  561. $post['existinfirstpage'] = true;
  562. }
  563. $postusers[$post['authorid']] = array();
  564. if($post['first']) {
  565. if($ordertype == 1 && $page != 1) {
  566. continue;
  567. }
  568. $_G['forum_firstpid'] = $post['pid'];
  569. if(!$_G['forum_thread']['price'] && (IS_ROBOT || $_G['adminid'] == 1)) $summary = str_replace(array("\r", "\n"), '', messagecutstr(strip_tags($post['message']), 160));
  570. $tagarray_all = $posttag_array = array();
  571. $tagarray_all = explode("\t", $post['tags']);
  572. if($tagarray_all) {
  573. foreach($tagarray_all as $var) {
  574. if($var) {
  575. $tag = explode(',', $var);
  576. $posttag_array[] = $tag;
  577. $tagnames[] = $tag[1];
  578. }
  579. }
  580. }
  581. $post['tags'] = $posttag_array;
  582. if($post['tags']) {
  583. $post['relateitem'] = getrelateitem($post['tags'], $post['tid'], $_G['setting']['relatenum'], $_G['setting']['relatetime']);
  584. }
  585. if(!$_G['forum']['disablecollect']) {
  586. if($incollection) {
  587. $post['relatecollection'] = getrelatecollection($post['tid'], false, $post['releatcollectionnum'], $post['releatcollectionmore']);
  588. if($_G['group']['allowcommentcollection'] && $_GET['ctid']) {
  589. $ctid = dintval($_GET['ctid']);
  590. $post['sourcecollection'] = C::t('forum_collection')->fetch($ctid);
  591. }
  592. } else {
  593. $post['releatcollectionnum'] = 0;
  594. }
  595. }
  596. }
  597. $postlist[$post['pid']] = $post;
  598. }
  599. }
  600. unset($hotpostarr);
  601. $seodata = array('forum' => $_G['forum']['name'], 'fup' => $_G['cache']['forums'][$fup]['name'], 'subject' => $_G['forum_thread']['subject'], 'summary' => $summary, 'tags' => @implode(',', $tagnames), 'page' => intval($_GET['page']));
  602. if($_G['forum']['status'] != 3) {
  603. $seotype = 'viewthread';
  604. } else {
  605. $seotype = 'viewthread_group';
  606. $seodata['first'] = $nav['first']['name'];
  607. $seodata['second'] = $nav['second']['name'];
  608. }
  609. list($navtitle, $metadescription, $metakeywords) = get_seosetting($seotype, $seodata);
  610. if(!$navtitle) {
  611. $navtitle = helper_seo::get_title_page($_G['forum_thread']['subject'], $_G['page']).' - '.strip_tags($_G['forum']['name']);
  612. $nobbname = false;
  613. } else {
  614. $nobbname = true;
  615. }
  616. if(!$metakeywords) {
  617. $metakeywords = strip_tags($thread['subject']);
  618. }
  619. if(!$metadescription) {
  620. $metadescription = $summary.' '.strip_tags($_G['forum_thread']['subject']);
  621. }
  622. $_G['allblocked'] = true;
  623. $postno = & $_G['cache']['custominfo']['postno'];
  624. $postnostick = str_replace(array('<sup>', '</sup>'), '', $postno[0]);
  625. if($postusers) {
  626. $member_verify = $member_field_forum = $member_status = $member_count = $member_profile = $member_field_home = array();
  627. $uids = array_keys($postusers);
  628. $uids = array_filter($uids);
  629. $selfuids = $uids;
  630. if($_G['setting']['threadblacklist'] && $_G['uid'] && !in_array($_G['uid'], $selfuids)) {
  631. $selfuids[] = $_G['uid'];
  632. }
  633. if(!($_G['setting']['threadguestlite'] && !$_G['uid'])) {
  634. if($_G['setting']['verify']['enabled']) {
  635. $member_verify = C::t('common_member_verify')->fetch_all($uids);
  636. foreach($member_verify as $uid => $data) {
  637. foreach($_G['setting']['verify'] as $vid => $verify) {
  638. if($verify['available'] && $verify['showicon']) {
  639. if($data['verify'.$vid] == 1) {
  640. $member_verify[$uid]['verifyicon'][] = $vid;
  641. } elseif (!empty($verify['unverifyicon'])) {
  642. $member_verify[$uid]['unverifyicon'][] = $vid;
  643. }
  644. }
  645. }
  646. }
  647. }
  648. $member_count = C::t('common_member_count')->fetch_all($selfuids);
  649. $member_status = C::t('common_member_status')->fetch_all($uids);
  650. $member_field_forum = C::t('common_member_field_forum')->fetch_all($uids);
  651. $member_profile = C::t('common_member_profile')->fetch_all($uids);
  652. $member_field_home = C::t('common_member_field_home')->fetch_all($uids);
  653. }
  654. if($_G['setting']['threadblacklist'] && $_G['uid'] && $member_count[$_G['uid']]['blacklist']) {
  655. $member_blackList = C::t('home_blacklist')->fetch_all_by_uid_buid($_G['uid'], $uids);
  656. }
  657. foreach(C::t('common_member')->fetch_all($uids) as $uid => $postuser) {
  658. $member_field_home[$uid]['privacy'] = empty($member_field_home[$uid]['privacy']) ? array() : dunserialize($member_field_home[$uid]['privacy']);
  659. $postuser['memberstatus'] = $postuser['status'];
  660. $postuser['authorinvisible'] = $member_status[$uid]['invisible'];
  661. $postuser['signature'] = $member_field_forum[$uid]['sightml'];
  662. unset($member_field_home[$uid]['privacy']['feed'], $member_field_home[$uid]['privacy']['view'], $postuser['status'], $member_status[$uid]['invisible'], $member_field_forum[$uid]['sightml']);
  663. $postusers[$uid] = array_merge((array)$member_verify[$uid], (array)$member_field_home[$uid], (array)$member_profile[$uid], (array)$member_count[$uid], (array)$member_status[$uid], (array)$member_field_forum[$uid], $postuser);
  664. if($postusers[$uid]['regdate'] + $postusers[$uid]['oltime'] * 3600 > TIMESTAMP) {
  665. $postusers[$uid]['oltime'] = 0;
  666. }
  667. $postusers[$uid]['office'] = $postusers[$uid]['position'];
  668. $postusers[$uid]['inblacklist'] = $member_blackList[$uid] ? true : false;
  669. $postusers[$uid]['groupcolor'] = $_G['cache']['usergroups'][$postuser['groupid']]['color'];
  670. unset($postusers[$uid]['position']);
  671. }
  672. unset($member_field_forum, $member_status, $member_count, $member_profile, $member_field_home, $member_blackList);
  673. $_G['medal_list'] = array();
  674. foreach($postlist as $pid => $post) {
  675. if(getstatus($post['status'], 6)) {
  676. $locationpids[] = $pid;
  677. }
  678. $post = array_merge($postlist[$pid], (array)$postusers[$post['authorid']]);
  679. $postlist[$pid] = viewthread_procpost($post, $_G['member']['lastvisit'], $ordertype, $maxposition);
  680. }
  681. }
  682. if($_G['allblocked']) {
  683. $_G['blockedpids'] = array();
  684. }
  685. if($locationpids) {
  686. $locations = C::t('forum_post_location')->fetch_all($locationpids);
  687. }
  688. if($postlist && $rushids) {
  689. foreach($postlist as $pid => $post) {
  690. $post['number'] = $post['position'];
  691. $postlist[$pid] = checkrushreply($post);
  692. }
  693. }
  694. if($_G['setting']['repliesrank'] && $postlist) {
  695. if($postlist) {
  696. foreach(C::t('forum_hotreply_number')->fetch_all_by_pids(array_keys($postlist)) as $pid => $post) {
  697. $postlist[$pid]['postreview']['support'] = dintval($post['support']);
  698. $postlist[$pid]['postreview']['against'] = dintval($post['against']);
  699. }
  700. }
  701. }
  702. if($_G['forum_thread']['special'] > 0 && (empty($_GET['viewpid']) || $_GET['viewpid'] == $_G['forum_firstpid'])) {
  703. $_G['forum_thread']['starttime'] = gmdate($_G['forum_thread']['dateline']);
  704. $_G['forum_thread']['remaintime'] = '';
  705. switch($_G['forum_thread']['special']) {
  706. case 1: require_once libfile('thread/poll', 'include'); break;
  707. case 2: require_once libfile('thread/trade', 'include'); break;
  708. case 3: require_once libfile('thread/reward', 'include'); break;
  709. case 4: require_once libfile('thread/activity', 'include'); break;
  710. case 5: require_once libfile('thread/debate', 'include'); break;
  711. case 127:
  712. if($_G['forum_firstpid']) {
  713. $sppos = strpos($postlist[$_G['forum_firstpid']]['message'], chr(0).chr(0).chr(0));
  714. $specialextra = substr($postlist[$_G['forum_firstpid']]['message'], $sppos + 3);
  715. $postlist[$_G['forum_firstpid']]['message'] = substr($postlist[$_G['forum_firstpid']]['message'], 0, $sppos);
  716. if($specialextra) {
  717. if(array_key_exists($specialextra, $_G['setting']['threadplugins'])) {
  718. @include_once DISCUZ_ROOT.'./source/plugin/'.$_G['setting']['threadplugins'][$specialextra]['module'].'.class.php';
  719. $classname = 'threadplugin_'.$specialextra;
  720. if(class_exists($classname) && method_exists($threadpluginclass = new $classname, 'viewthread')) {
  721. $threadplughtml = $threadpluginclass->viewthread($_G['tid']);
  722. }
  723. }
  724. }
  725. }
  726. break;
  727. }
  728. }
  729. if(empty($_GET['authorid']) && empty($postlist)) {
  730. if($rushreply) {
  731. dheader("Location: forum.php?mod=redirect&tid=$_G[tid]&goto=lastpost");
  732. } else {
  733. $replies = C::t('forum_post')->count_visiblepost_by_tid($_G['tid']);
  734. $replies = intval($replies) - 1;
  735. if($_G['forum_thread']['replies'] != $replies && $replies > 0) {
  736. C::t('forum_thread')->update($_G['tid'], array('replies' => $replies), false, false, $archiveid);
  737. dheader("Location: forum.php?mod=redirect&tid=$_G[tid]&goto=lastpost");
  738. }
  739. }
  740. }
  741. if($_G['forum_pagebydesc'] && (!$savepostposition || $_GET['ordertype'] == 1)) {
  742. $postlist = array_reverse($postlist, TRUE);
  743. }
  744. if(!empty($_G['setting']['sessionclose'])) {
  745. $_G['setting']['vtonlinestatus'] = 1;
  746. }
  747. if($_G['setting']['vtonlinestatus'] == 2 && $_G['forum_onlineauthors']) {
  748. foreach(C::app()->session->fetch_all_by_uid(array_keys($_G['forum_onlineauthors'])) as $author) {
  749. if(!$author['invisible']) {
  750. $_G['forum_onlineauthors'][$author['uid']] = 1;
  751. }
  752. }
  753. } else {
  754. $_G['forum_onlineauthors'] = array();
  755. }
  756. $ratelogs = $comments = $commentcount = $totalcomment = array();
  757. if($_G['forum_cachepid']) {
  758. foreach(C::t('forum_postcache')->fetch_all($_G['forum_cachepid']) as $postcache) {
  759. if($postcache['rate']) {
  760. $postcache['rate'] = dunserialize($postcache['rate']);
  761. $postlist[$postcache['pid']]['ratelog'] = $postcache['rate']['ratelogs'];
  762. $postlist[$postcache['pid']]['ratelogextcredits'] = $postcache['rate']['extcredits'];
  763. $postlist[$postcache['pid']]['totalrate'] = $postcache['rate']['totalrate'];
  764. }
  765. if($postcache['comment']) {
  766. $postcache['comment'] = dunserialize($postcache['comment']);
  767. $commentcount[$postcache['pid']] = $postcache['comment']['count'];
  768. $comments[$postcache['pid']] = $postcache['comment']['data'];
  769. $totalcomment[$postcache['pid']] = $postcache['comment']['totalcomment'];
  770. }
  771. unset($_G['forum_cachepid'][$postcache['pid']]);
  772. }
  773. $postcache = $ratelogs = array();
  774. if($_G['forum_cachepid']) {
  775. list($ratelogs, $postlist, $postcache) = C::t('forum_ratelog')->fetch_postrate_by_pid($_G['forum_cachepid'], $postlist, $postcache, $_G['setting']['ratelogrecord']);
  776. }
  777. foreach($postlist as $key => $val) {
  778. if(!empty($val['ratelogextcredits'])) {
  779. ksort($postlist[$key]['ratelogextcredits']);
  780. }
  781. }
  782. if($_G['forum_cachepid'] && $_G['setting']['commentnumber']) {
  783. list($comments, $postcache, $commentcount, $totalcomment) = C::t('forum_postcomment')->fetch_postcomment_by_pid($_G['forum_cachepid'], $postcache, $commentcount, $totalcomment, $_G['setting']['commentnumber']);
  784. }
  785. foreach($postcache as $pid => $data) {
  786. C::t('forum_postcache')->insert(array('pid' => $pid, 'rate' => serialize($data['rate']), 'comment' => serialize($data['comment']), 'dateline' => TIMESTAMP), false, true);
  787. }
  788. }
  789. if($_G['forum_attachpids'] && !defined('IN_ARCHIVER')) {
  790. require_once libfile('function/attachment');
  791. if(is_array($threadsortshow) && !empty($threadsortshow['sortaids'])) {
  792. $skipaids = $threadsortshow['sortaids'];
  793. }
  794. parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist, $skipaids);
  795. }
  796. if(empty($postlist)) {
  797. showmessage('post_not_found');
  798. } elseif(!defined('IN_MOBILE_API')) {
  799. foreach($postlist as $pid => $post) {
  800. $postlist[$pid]['message'] = preg_replace("/\[attach\]\d+\[\/attach\]/i", '', $postlist[$pid]['message']);
  801. }
  802. }
  803. if(defined('IN_ARCHIVER')) {
  804. include loadarchiver('forum/viewthread');
  805. exit();
  806. }
  807. $_G['forum_thread']['heatlevel'] = $_G['forum_thread']['recommendlevel'] = 0;
  808. if($_G['setting']['heatthread']['iconlevels']) {
  809. foreach($_G['setting']['heatthread']['iconlevels'] as $k => $i) {
  810. if($_G['forum_thread']['heats'] > $i) {
  811. $_G['forum_thread']['heatlevel'] = $k + 1;
  812. break;
  813. }
  814. }
  815. }
  816. if(!empty($_G['setting']['recommendthread']['status']) && $_G['forum_thread']['recommends']) {
  817. foreach($_G['setting']['recommendthread']['iconlevels'] as $k => $i) {
  818. if($_G['forum_thread']['recommends'] > $i) {
  819. $_G['forum_thread']['recommendlevel'] = $k+1;
  820. break;
  821. }
  822. }
  823. }
  824. $allowblockrecommend = $_G['group']['allowdiy'] || getstatus($_G['member']['allowadmincp'], 4) || getstatus($_G['member']['allowadmincp'], 5) || getstatus($_G['member']['allowadmincp'], 6);
  825. if($_G['setting']['portalstatus']) {
  826. $allowpostarticle = $_G['group']['allowmanagearticle'] || $_G['group']['allowpostarticle'] || getstatus($_G['member']['allowadmincp'], 2) || getstatus($_G['member']['allowadmincp'], 3);
  827. $allowpusharticle = empty($_G['forum_thread']['special']) && empty($_G['forum_thread']['sortid']) && !$_G['forum_thread']['pushedaid'];
  828. } else {
  829. $allowpostarticle = $allowpusharticle = false;
  830. }
  831. if($_G['forum_thread']['displayorder'] != -4) {
  832. $modmenu = array(
  833. 'thread' => $_G['forum']['ismoderator'] || $allowblockrecommend || $allowpusharticle && $allowpostarticle,
  834. 'post' => $_G['forum']['ismoderator'] && ($_G['group']['allowwarnpost'] || $_G['group']['allowbanpost'] || $_G['group']['allowdelpost'] || $_G['group']['allowstickreply']) || $_G['forum_thread']['pushedaid'] && $allowpostarticle || $_G['forum_thread']['authorid'] == $_G['uid']
  835. );
  836. } else {
  837. $modmenu = array();
  838. }
  839. if($_G['forum']['alloweditpost'] && $_G['uid']) {
  840. $alloweditpost_status = getstatus($_G['setting']['alloweditpost'], $_G['forum_thread']['special'] + 1);
  841. if(!$alloweditpost_status) {
  842. $edittimelimit = $_G['group']['edittimelimit'] * 60;
  843. }
  844. }
  845. if($_G['forum_thread']['replies'] > $_G['forum_thread']['views']) {
  846. $_G['forum_thread']['views'] = $_G['forum_thread']['replies'];
  847. }
  848. require_once libfile('function/upload');
  849. $swfconfig = getuploadconfig($_G['uid'], $_G['fid']);
  850. $_G['forum_thread']['relay'] = 0;
  851. if(getstatus($_G['forum_thread']['status'], 10)) {
  852. $preview = C::t('forum_threadpreview')->fetch($_G['tid']);
  853. $_G['forum_thread']['relay'] = $preview['relay'];
  854. }
  855. if(empty($_GET['viewpid'])) {
  856. $sufix = '';
  857. if($_GET['from'] == 'portal') {
  858. $_G['disabledwidthauto'] = 1;
  859. $_G['widthauto'] = 0;
  860. $sufix = '_portal';
  861. $post = &$postlist[$_G['forum_firstpid']];
  862. } elseif($_GET['from'] == 'preview') {
  863. $_G['disabledwidthauto'] = 1;
  864. $_G['widthauto'] = 0;
  865. $sufix = '_preview';
  866. } elseif($_GET['from'] == 'album') {
  867. $_G['disabledwidthauto'] = 1;
  868. $_G['widthauto'] = 0;
  869. $sufix = '_album';
  870. $post = &$postlist[$_G['forum_firstpid']];
  871. $post['message'] = cutstr(strip_tags(preg_replace('/(<ignore_js_op>.*<\/ignore_js_op>)/is', '', $post['message'])), 200);
  872. require_once libfile('thread/album', 'include');
  873. }
  874. include template('diy:forum/viewthread'.$sufix.':'.$_G['fid']);
  875. } else {
  876. $_G['setting']['admode'] = 0;
  877. $post = $postlist[$_GET['viewpid']];
  878. if($maxposition) {
  879. $post['number'] = $post['position'];
  880. } else {
  881. $post['number'] = C::t('forum_post')->count_by_tid_dateline($posttableid, $post['tid'], $post['dbdateline']);
  882. }
  883. if($rushreply) {
  884. $post['number'] = $post['position'];
  885. $preg_str = rushreply_rule($rewardfloorarr);
  886. preg_match_all($preg_str, ",,".$post['number'].",,", $arr);
  887. if($post['number'] == str_replace(",", '', $arr['0']['0'])) {
  888. $post['rewardfloor'] = 1;
  889. }
  890. }
  891. include template('common/header_ajax');
  892. hookscriptoutput('viewthread');
  893. $postcount = 0;
  894. if($_GET['from']) {
  895. include template($_GET['from'] == 'preview' ? 'forum/viewthread_preview_node' : 'forum/viewthread_from_node');
  896. } else {
  897. include template('forum/viewthread_node');
  898. }
  899. include template('common/footer_ajax');
  900. }
  901. function viewthread_updateviews($tableid) {
  902. global $_G;
  903. if(!$_G['setting']['preventrefresh'] || $_G['cookie']['viewid'] != 'tid_'.$_G['tid']) {
  904. if(!$tableid && $_G['setting']['optimizeviews']) {
  905. if(isset($_G['forum_thread']['addviews'])) {
  906. if($_G['forum_thread']['addviews'] < 100) {
  907. C::t('forum_threadaddviews')->update_by_tid($_G['tid']);
  908. } else {
  909. if(!discuz_process::islocked('update_thread_view')) {
  910. $row = C::t('forum_threadaddviews')->fetch($_G['tid']);
  911. C::t('forum_threadaddviews')->update($_G['tid'], array('addviews' => 0));
  912. C::t('forum_thread')->increase($_G['tid'], array('views' => $row['addviews']+1), true);
  913. discuz_process::unlock('update_thread_view');
  914. }
  915. }
  916. } else {
  917. C::t('forum_threadaddviews')->insert(array('tid' => $_G['tid'], 'addviews' => 1), false, true);
  918. }
  919. } else {
  920. C::t('forum_thread')->increase($_G['tid'], array('views' => 1), true, $tableid);
  921. }
  922. }
  923. dsetcookie('viewid', 'tid_'.$_G['tid']);
  924. }
  925. function viewthread_procpost($post, $lastvisit, $ordertype, $maxposition = 0) {
  926. global $_G, $rushreply;
  927. if(!$_G['forum_newpostanchor'] && $post['dateline'] > $lastvisit) {
  928. $post['newpostanchor'] = '<a name="newpost"></a>';
  929. $_G['forum_newpostanchor'] = 1;
  930. } else {
  931. $post['newpostanchor'] = '';
  932. }
  933. $post['lastpostanchor'] = ($ordertype != 1 && $_G['forum_numpost'] == $_G['forum_thread']['replies']) || ($ordertype == 1 && $_G['forum_numpost'] == $_G['forum_thread']['replies'] + 2) ? '<a name="lastpost"></a>' : '';
  934. if(!$post['hotrecommended']) {
  935. if($_G['forum_pagebydesc']) {
  936. if($ordertype != 1) {
  937. $post['number'] = $_G['forum_numpost'] + $_G['forum_ppp2']--;
  938. } else {
  939. $post['number'] = $post['first'] == 1 ? 1 : ($_G['forum_numpost'] - 1) - $_G['forum_ppp2']--;
  940. }
  941. } else {
  942. if($ordertype != 1) {
  943. $post['number'] = ++$_G['forum_numpost'];
  944. } else {
  945. $post['number'] = $post['first'] == 1 ? 1 : --$_G['forum_numpost'];
  946. $post['number'] = $post['number'] - 1;
  947. }
  948. }
  949. }
  950. if($post['existinfirstpage']) {
  951. if($_G['forum_pagebydesc']) {
  952. $_G['forum_ppp2']--;
  953. } else {
  954. if($ordertype != 1) {
  955. ++$_G['forum_numpost'];
  956. } else {
  957. --$_G['forum_numpost'];
  958. }
  959. }
  960. }
  961. if($maxposition) {
  962. $post['number'] = $post['position'];
  963. }
  964. if($post['hotrecommended']) {
  965. $post['number'] = -1;
  966. }
  967. if(!$_G['forum_thread']['special'] && !$rushreply && !$hiddenreplies && $_G['setting']['threadfilternum'] && getstatus($post['status'], 11)) {
  968. $post['isWater'] = true;
  969. if($_G['setting']['hidefilteredpost'] && !$_G['forum']['noforumhidewater']) {
  970. $post['inblacklist'] = true;
  971. }
  972. } else {
  973. $_G['allblocked'] = false;
  974. }
  975. if($post['inblacklist']) {
  976. $_G['blockedpids'][] = $post['pid'];
  977. }
  978. $_G['forum_postcount']++;
  979. $post['dbdateline'] = $post['dateline'];
  980. $post['dateline'] = dgmdate($post['dateline'], 'u', '9999', getglobal('setting/dateformat').' H:i:s');
  981. $post['groupid'] = $_G['cache']['usergroups'][$post['groupid']] ? $post['groupid'] : 7;
  982. if($post['username']) {
  983. $_G['forum_onlineauthors'][$post['authorid']] = 0;
  984. $post['usernameenc'] = rawurlencode($post['username']);
  985. $post['readaccess'] = $_G['cache']['usergroups'][$post['groupid']]['readaccess'];
  986. if($_G['cache']['usergroups'][$post['groupid']]['userstatusby'] == 1) {
  987. $post['authortitle'] = $_G['cache']['usergroups'][$post['groupid']]['grouptitle'];
  988. $post['stars'] = $_G['cache']['usergroups'][$post['groupid']]['stars'];
  989. }
  990. $post['upgradecredit'] = false;
  991. if($_G['cache']['usergroups'][$post['groupid']]['type'] == 'member' && $_G['cache']['usergroups'][$post['groupid']]['creditslower'] != 999999999) {
  992. $post['upgradecredit'] = $_G['cache']['usergroups'][$post['groupid']]['creditslower'] - $post['credits'];
  993. $post['upgradeprogress'] = 100 - ceil($post['upgradecredit'] / ($_G['cache']['usergroups'][$post['groupid']]['creditslower'] - $_G['cache']['usergroups'][$post['groupid']]['creditshigher']) * 100);
  994. $post['upgradeprogress'] = min(max($post['upgradeprogress'], 2), 100);
  995. }
  996. $post['taobaoas'] = addslashes($post['taobao']);
  997. $post['regdate'] = dgmdate($post['regdate'], 'd');
  998. $post['lastdate'] = dgmdate($post['lastvisit'], 'd');
  999. $post['authoras'] = !$post['anonymous'] ? ' '.addslashes($post['author']) : '';
  1000. if($post['medals']) {
  1001. loadcache('medals');
  1002. foreach($post['medals'] = explode("\t", $post['medals']) as $key => $medalid) {
  1003. list($medalid, $medalexpiration) = explode("|", $medalid);
  1004. if(isset($_G['cache']['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > TIMESTAMP)) {
  1005. $post['medals'][$key] = $_G['cache']['medals'][$medalid];
  1006. $post['medals'][$key]['medalid'] = $medalid;
  1007. $_G['medal_list'][$medalid] = $_G['cache']['medals'][$medalid];
  1008. } else {
  1009. unset($post['medals'][$key]);
  1010. }
  1011. }
  1012. }
  1013. $post['avatar'] = avatar($post['authorid']);
  1014. $post['groupicon'] = $post['avatar'] ? g_icon($post['groupid'], 1) : '';
  1015. $post['banned'] = $post['status'] & 1;
  1016. $post['warned'] = ($post['status'] & 2) >> 1;
  1017. } else {
  1018. if(!$post['authorid']) {
  1019. $post['useip'] = substr($post['useip'], 0, strrpos($post['useip'], '.')).'.x';
  1020. }
  1021. }
  1022. $post['attachments'] = array();
  1023. $post['imagelist'] = $post['attachlist'] = array();
  1024. if($post['attachment']) {
  1025. if((!empty($_G['setting']['guestviewthumb']['flag']) && !$_G['uid']) || $_G['group']['allowgetattach'] || $_G['group']['allowgetimage']) {
  1026. $_G['forum_attachpids'][] = $post['pid'];
  1027. $post['attachment'] = 0;
  1028. if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $post['message'], $matchaids)) {
  1029. $_G['forum_attachtags'][$post['pid']] = $matchaids[1];
  1030. }
  1031. } else {
  1032. $post['message'] = preg_replace("/\[attach\](\d+)\[\/attach\]/i", '', $post['message']);
  1033. }
  1034. }
  1035. if($_G['setting']['ratelogrecord'] && $post['ratetimes']) {
  1036. $_G['forum_cachepid'][$post['pid']] = $post['pid'];
  1037. }
  1038. if($_G['setting']['commentnumber'] && ($post['first'] && $_G['setting']['commentfirstpost'] || !$post['first']) && $post['comment']) {
  1039. $_G['forum_cachepid'][$post['pid']] = $post['pid'];
  1040. }
  1041. $post['allowcomment'] = $_G['setting']['commentnumber'] && in_array(1, $_G['setting']['allowpostcomment']) && ($_G['setting']['commentpostself'] || $post['authorid'] != $_G['uid']) &&
  1042. ($post['first'] && $_G['setting']['commentfirstpost'] && in_array($_G['group']['allowcommentpost'], array(1, 3)) ||
  1043. (!$post['first'] && in_array($_G['group']['allowcommentpost'], array(2, 3))));
  1044. $forum_allowbbcode = $_G['forum']['allowbbcode'] ? -$post['groupid'] : 0;
  1045. $post['signature'] = $post['usesig'] ? ($_G['setting']['sigviewcond'] ? (strlen($post['message']) > $_G['setting']['sigviewcond'] ? $post['signature'] : '') : $post['signature']) : '';
  1046. $imgcontent = $post['first'] ? getstatus($_G['forum_thread']['status'], 15) : 0;
  1047. if(!defined('IN_ARCHIVER')) {
  1048. if($post['first']) {
  1049. if(!defined('IN_MOBILE')) {
  1050. $messageindex = false;
  1051. if(strpos($post['message'], '[/index]') !== FALSE) {
  1052. $post['message'] = preg_replace_callback("/\s?\[index\](.+?)\[\/index\]\s?/is", create_function('$matches', 'return parseindex($matches[1], '.intval($post['pid']).');'), $post['message']);
  1053. $messageindex = true;
  1054. unset($_GET['threadindex']);
  1055. }
  1056. if(strpos($post['message'], '[page]') !== FALSE) {
  1057. if($_GET['cp'] != 'all') {
  1058. $postbg = '';
  1059. if(strpos($post['message'], '[/postbg]') !== FALSE) {
  1060. preg_match("/\s?\[postbg\]\s*([^\[\<\r\n;'\"\?\(\)]+?)\s*\[\/postbg\]\s?/is", $post['message'], $r);
  1061. $postbg = $r[0];
  1062. }
  1063. $messagearray = explode('[page]', $post['message']);
  1064. $cp = max(intval($_GET['cp']), 1);
  1065. $post['message'] = $messagearray[$cp - 1];
  1066. if($postbg && strpos($post['message'], '[/postbg]') === FALSE) {
  1067. $post['message'] = $postbg.$post['message'];
  1068. }
  1069. unset($postbg);
  1070. } else {
  1071. $cp = 0;
  1072. $post['message'] = preg_replace("/\s?\[page\]\s?/is", '', $post['message']);
  1073. }
  1074. if($_GET['cp'] != 'all' && strpos($post['message'], '[/index]') === FALSE && empty($_GET['threadindex']) && !$messageindex) {
  1075. $_G['forum_posthtml']['footer'][$post['pid']] .= '<div id="threadpage"></div><script type="text/javascript" reload="1">show_threadpage('.$post['pid'].', '.$cp.', '.count($messagearray).', '.($_GET['from'] == 'preview' ? '1' : '0').');</script>';
  1076. }
  1077. }
  1078. }
  1079. }
  1080. if(!empty($_GET['threadindex'])) {
  1081. $_G['forum_posthtml']['header'][$post['pid']] .= '<div id="threadindex"></div><script type="text/javascript" reload="1">show_threadindex(0, '.($_GET['from'] == 'preview' ? '1' : '0').');</script>';
  1082. }
  1083. if(!$imgcontent) {
  1084. $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $forum_allowbbcode, ($_G['forum']['allowimgcode'] && $_G['setting']['showimages'] ? 1 : 0), $_G['forum']['allowhtml'], ($_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0), 0, $post['authorid'], $_G['cache']['usergroups'][$post['groupid']]['allowmediacode'] && $_G['forum']['allowmediacode'], $post['pid'], $_G['setting']['lazyload'], $post['dbdateline'], $post['first']);
  1085. if($post['first']) {
  1086. $_G['relatedlinks'] = '';
  1087. $relatedtype = !$_G['forum_thread']['isgroup'] ? 'forum' : 'group';
  1088. if(!$_G['setting']['relatedlinkstatus']) {
  1089. $_G['relatedlinks'] = get_related_link($relatedtype);
  1090. } else {
  1091. $post['message'] = parse_related_link($post['message'], $relatedtype);
  1092. }
  1093. if(strpos($post['message'], '[/begin]') !== FALSE) {
  1094. $post['message'] = preg_replace_callback("/\[begin(=\s*([^\[\<\r\n]*?)\s*,(\d*),(\d*),(\d*),(\d*))?\]\s*([^\[\<\r\n]+?)\s*\[\/begin\]/is", create_function('$matches', 'return '.intval($_G['cache']['usergroups'][$post['groupid']]['allowbegincode']).' ? parsebegin($matches[2], $matches[7], $matches[3], $matches[4], $matches[5], $matches[6]) : \'\';'), $post['message']);
  1095. }
  1096. }
  1097. }
  1098. }
  1099. if(defined('IN_ARCHIVER') || defined('IN_MOBILE') || !$post['first']) {
  1100. if(strpos($post['message'], '[page]') !== FALSE) {
  1101. $post['message'] = preg_replace("/\s?\[page\]\s?/is", '', $post['message']);
  1102. }
  1103. if(strpos($post['message'], '[/index]') !== FALSE) {
  1104. $post['message'] = preg_replace("/\s?\[index\](.+?)\[\/index\]\s?/is", '', $post['message']);
  1105. }
  1106. if(strpos($post['message'], '[/begin]') !== FALSE) {
  1107. $post['message'] = preg_replace("/\[begin(=\s*([^\[\<\r\n]*?)\s*,(\d*),(\d*),(\d*),(\d*))?\]\s*([^\[\<\r\n]+?)\s*\[\/begin\]/is", '', $post['message']);
  1108. }
  1109. }
  1110. if($imgcontent) {
  1111. $post['message'] = '<img id="threadimgcontent" src="./'.stringtopic('', $post['tid']).'">';
  1112. }
  1113. $_G['forum_firstpid'] = intval($_G['forum_firstpid']);
  1114. $post['numbercard'] = viewthread_numbercard($post);
  1115. $post['mobiletype'] = getstatus($post['status'], 4) ? base_convert(getstatus($post['status'], 10).getstatus($post['status'], 9).getstatus($post['status'], 8), 2, 10) : 0;
  1116. return $post;
  1117. }
  1118. function viewthread_loadcache() {
  1119. global $_G;
  1120. $_G['forum']['livedays'] = ceil((TIMESTAMP - $_G['forum']['dateline']) / 86400);
  1121. $_G['forum']['lastpostdays'] = ceil((TIMESTAMP - $_G['forum']['lastthreadpost']) / 86400);
  1122. $threadcachemark = 100 - (
  1123. $_G['forum']['displayorder'] * 15 +
  1124. $_G['thread']['digest'] * 10 +
  1125. min($_G['thread']['views'] / max($_G['forum']['livedays'], 10) * 2, 50) +
  1126. max(-10, (15 - $_G['forum']['lastpostdays'])) +
  1127. min($_G['thread']['replies'] / $_G['setting']['postperpage'] * 1.5, 15));
  1128. if($threadcachemark < $_G['forum']['threadcaches']) {
  1129. $threadcache = getcacheinfo($_G['tid']);
  1130. if(TIMESTAMP - $threadcache['filemtime'] > $_G['setting']['cachethreadlife']) {
  1131. @unlink($threadcache['filename']);
  1132. define('CACHE_FILE', $threadcache['filename']);
  1133. } else {
  1134. readfile($threadcache['filename']);
  1135. viewthread_updateviews($_G['forum_thread']['threadtableid']);
  1136. $_G['setting']['debug'] && debuginfo();
  1137. $_G['setting']['debug'] ? die('<script type="text/javascript">document.getElementById("debuginfo").innerHTML = " '.($_G['setting']['debug'] ? 'Updated at '.gmdate("H:i:s", $threadcache['filemtime'] + 3600 * 8).', Processed in '.$debuginfo['time'].' second(s), '.$debuginfo['queries'].' Queries'.($_G['gzipcompress'] ? ', Gzip enabled' : '') : '').'";</script>') : die();
  1138. }
  1139. }
  1140. }
  1141. function viewthread_lastmod(&$thread) {
  1142. global $_G;
  1143. if(!$thread['moderated']) {
  1144. return array();
  1145. }
  1146. $lastmod = array();
  1147. $lastlog = C::t('forum_threadmod')->fetch_by_tid($thread['tid']);
  1148. if($lastlog) {
  1149. $lastmod = array(
  1150. 'moduid' => $lastlog['uid'],
  1151. 'modusername' => $lastlog['username'],
  1152. 'moddateline' => $lastlog['dateline'],
  1153. 'modaction' => $lastlog['action'],
  1154. 'magicid' => $lastlog['magicid'],
  1155. 'stamp' => $lastlog['stamp'],
  1156. 'reason' => $lastlog['reason']
  1157. );
  1158. }
  1159. if($lastmod) {
  1160. $modactioncode = lang('forum/modaction');
  1161. $lastmod['modusername'] = $lastmod['modusername'] ? $lastmod['modusername'] : 'System';
  1162. $lastmod['moddateline'] = dgmdate($lastmod['moddateline'], 'u');
  1163. $lastmod['modactiontype'] = $lastmod['modaction'];
  1164. if($modactioncode[$lastmod['modaction']]) {
  1165. $lastmod['modaction'] = $modactioncode[$lastmod['modaction']].($lastmod['modaction'] != 'SPA' ? '' : ' '.$_G['cache']['stamps'][$lastmod['stamp']]['text']);
  1166. } elseif(substr($lastmod['modaction'], 0, 1) == 'L' && preg_match('/L(\d\d)/', $lastmod['modaction'], $a)) {
  1167. $lastmod['modaction'] = $modactioncode['SLA'].' '.$_G['cache']['stamps'][intval($a[1])]['text'];
  1168. } else {
  1169. $lastmod['modaction'] = '';
  1170. }
  1171. if($lastmod['magicid']) {
  1172. loadcache('magics');
  1173. $lastmod['magicname'] = $_G['cache']['magics'][$lastmod['magicid']]['name'];
  1174. }
  1175. } else {
  1176. C::t('forum_thread')->update($thread['tid'], array('moderated' => 0), false, false, $thread['threadtableid']);
  1177. $thread['moderated'] = 0;
  1178. }
  1179. return $lastmod;
  1180. }
  1181. function viewthread_baseinfo($post, $extra) {
  1182. global $_G;
  1183. list($key, $type) = $extra;
  1184. $v = '';
  1185. if(substr($key, 0, 10) == 'extcredits') {
  1186. $i = substr($key, 10);
  1187. $extcredit = $_G['setting']['extcredits'][$i];
  1188. if($extcredit) {
  1189. $v = $type ? ($extcredit['img'] ? $extcredit['img'].' ' : '').$extcredit['title'] : $post['extcredits'.$i].' '.$extcredit['unit'];
  1190. }
  1191. } elseif(substr($key, 0, 6) == 'field_') {
  1192. $field = substr($key, 6);
  1193. if(!empty($post['privacy']['profile'][$field])) {
  1194. return '';
  1195. }
  1196. require_once libfile('function/profile');
  1197. if($field != 'qq') {
  1198. $v = profile_show($field, $post);
  1199. } elseif(!empty($post['qq'])) {
  1200. $v = '<a href="http://wpa.qq.com/msgrd?v=3&uin='.$post['qq'].'&site='.$_G['setting']['bbname'].'&menu=yes&from=discuz" target="_blank" title="'.lang('spacecp', 'qq_dialog').'"><img src="'.STATICURL.'/image/common/qq_big.gif" alt="QQ" style="margin:0px;"/></a>';
  1201. }
  1202. if($v) {
  1203. if(!isset($_G['cache']['profilesetting'])) {
  1204. loadcache('profilesetting');
  1205. }
  1206. $v = $type ? $_G['cache']['profilesetting'][$field]['title'] : $v;
  1207. }
  1208. } elseif($key == 'eccredit_seller') {
  1209. $v = $type ? lang('space', 'viewthread_userinfo_sellercredit') : '<a href="home.php?mod=space&uid='.$post['uid'].'&do=trade&view=eccredit#buyercredit" target="_blank" class="vm"><img src="'.STATICURL.'image/traderank/seller/'.countlevel($post['buyercredit']).'.gif" /></a>';
  1210. } elseif($key == 'eccredit_buyer') {
  1211. $v = $type ? lang('space', 'viewthread_userinfo_buyercredit') : '<a href="home.php?mod=space&uid='.$post['uid'].'&do=trade&view=eccredit#sellercredit" target="_blank" class="vm"><img src="'.STATICURL.'image/traderank/seller/'.countlevel($post['sellercredit']).'.gif" /></a>';
  1212. } else {
  1213. $v = getLinkByKey($key, $post);
  1214. if($v !== '') {
  1215. $v = $type ? lang('space', 'viewthread_userinfo_'.$key) : $v;
  1216. }
  1217. }
  1218. return $v;
  1219. }
  1220. function viewthread_profile_nodeparse($param) {
  1221. list($name, $s, $e, $extra, $post) = $param;
  1222. if(strpos($name, ':') === false) {
  1223. if(function_exists('profile_node_'.$name)) {
  1224. return call_user_func('profile_node_'.$name, $post, $s, $e, explode(',', $extra));
  1225. } else {
  1226. return '';
  1227. }
  1228. } else {
  1229. list($plugin, $pluginid) = explode(':', $name);
  1230. if($plugin == 'plugin') {
  1231. global $_G;
  1232. static $pluginclasses;
  1233. if(isset($_G['setting']['plugins']['profile_node'][$pluginid])) {
  1234. @include_once DISCUZ_ROOT.'./source/plugin/'.$_G['setting']['plugins']['profile_node'][$pluginid].'.class.php';
  1235. $classkey = 'plugin_'.$pluginid;
  1236. if(!class_exists($classkey, false)) {
  1237. return '';
  1238. }
  1239. if(!isset($pluginclasses[$classkey])) {
  1240. $pluginclasses[$classkey] = new $classkey;
  1241. }
  1242. return call_user_func(array($pluginclasses[$classkey], 'profile_node'), $post, $s, $e, explode(',', $extra));
  1243. }
  1244. }
  1245. }
  1246. }
  1247. function viewthread_profile_node($type, $post) {
  1248. global $_G;
  1249. $tpid = false;
  1250. if($post['verifyicon']) {
  1251. $tpid = isset($_G['setting']['profilenode']['groupid'][-$post['verifyicon'][0]]) ? $_G['setting']['profilenode']['groupid'][-$post['verifyicon'][0]] : false;
  1252. }
  1253. if($tpid === false) {
  1254. $tpid = isset($_G['setting']['profilenode']['groupid'][$post['groupid']]) ? $_G['setting']['profilenode']['groupid'][$post['groupid']] : 0;
  1255. }
  1256. $template = $_G['setting']['profilenode']['template'][$tpid][$type];
  1257. $code = $_G['setting']['profilenode']['code'][$tpid][$type];
  1258. include_once template('forum/viewthread_profile_node');
  1259. foreach($code as $k => $p) {
  1260. $p[] = $post;
  1261. $template = str_replace($k, call_user_func('viewthread_profile_nodeparse', $p), $template);
  1262. }
  1263. echo $template;
  1264. }
  1265. function viewthread_numbercard($post) {
  1266. global $_G;
  1267. if(!is_array($_G['setting']['numbercard'])) {
  1268. $_G['setting']['numbercard'] = dunserialize($_G['setting']['numbercard']);
  1269. }
  1270. $numbercard = array();
  1271. foreach($_G['setting']['numbercard']['row'] as $key) {
  1272. if(substr($key, 0, 10) == 'extcredits') {
  1273. $numbercard[] = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=profile', 'value' => $post[$key], 'lang' => $_G['setting']['extcredits'][substr($key, 10)]['title']);
  1274. } else {
  1275. $getLink = getLinkByKey($key, $post, 1);
  1276. $numbercard[] = array('link' => $getLink['link'], 'value' => $getLink['value'], 'lang' => lang('space', 'viewthread_userinfo_'.$key));
  1277. }
  1278. }
  1279. return $numbercard;
  1280. }
  1281. function getLinkByKey($key, $post, $returnarray = 0) {
  1282. switch($key) {
  1283. case 'uid': $v = array('link' => '?'.$post['uid'], 'value' => $post['uid']);break;
  1284. case 'posts': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=thread&type=reply&view=me&from=space', 'value' => $post['posts']);break;
  1285. case 'threads': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=thread&type=thread&view=me&from=space', 'value' => $post['threads']);break;
  1286. case 'digestposts': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=thread&type=thread&view=me&from=space', 'value' => $post['digestposts']);break;
  1287. case 'feeds': $v = array('link' => 'home.php?mod=follow&uid='.$post['uid'].'&do=view', 'value' => $post['feeds']);break;
  1288. case 'doings': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=doing&view=me&from=space', 'value' => $post['doings']);break;
  1289. case 'blogs': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=blog&view=me&from=space', 'value' => $post['blogs']);break;
  1290. case 'albums': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=album&view=me&from=space', 'value' => $post['albums']);break;
  1291. case 'sharings': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=share&view=me&from=space', 'value' => $post['sharings']);break;
  1292. case 'friends': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=friend&view=me&from=space', 'value' => $post['friends']);break;
  1293. case 'follower': $v = array('link' => 'home.php?mod=follow&do=follower&uid='.$post['uid'], 'value' => $post['follower']);break;
  1294. case 'following': $v = array('link' => 'home.php?mod=follow&do=following&uid='.$post['uid'], 'value' => $post['following']);break;
  1295. case 'credits': $v = array('link' => 'home.php?mod=space&uid='.$post['uid'].'&do=profile', 'value' => $post['credits']);break;
  1296. case 'digest': $v = array('value' => $post['digestposts']);break;
  1297. case 'readperm': $v = array('value' => $post['readaccess']);break;
  1298. case 'regtime': $v = array('value' => $post['regdate']);break;
  1299. case 'lastdate': $v = array('value' => $post['lastdate']);break;
  1300. case 'oltime': $v = array('value' => $post['oltime'].' '.lang('space', 'viewthread_userinfo_hour'));break;
  1301. }
  1302. if(!$returnarray) {
  1303. if($v['link']) {
  1304. $v = '<a href="'.$v['link'].'" target="_blank" class="xi2">'.$v['value'].'</a>';
  1305. } else {
  1306. $v = $v['value'];
  1307. }
  1308. }
  1309. return $v;
  1310. }
  1311. function countlevel($usercredit) {
  1312. global $_G;
  1313. $rank = 0;
  1314. if($usercredit){
  1315. foreach($_G['setting']['ec_credit']['rank'] AS $level => $credit) {
  1316. if($usercredit <= $credit) {
  1317. $rank = $level;
  1318. break;
  1319. }
  1320. }
  1321. }
  1322. return $rank;
  1323. }
  1324. function remaintime($time) {
  1325. $days = intval($time / 86400);
  1326. $time -= $days * 86400;
  1327. $hours = intval($time / 3600);
  1328. $time -= $hours * 3600;
  1329. $minutes = intval($time / 60);
  1330. $time -= $minutes * 60;
  1331. $seconds = $time;
  1332. return array((int)$days, (int)$hours, (int)$minutes, (int)$seconds);
  1333. }
  1334. function getrelateitem($tagarray, $tid, $relatenum, $relatetime, $relatecache = '', $type = 'tid') {
  1335. $tagidarray = $relatearray = $relateitem = array();
  1336. $updatecache = 0;
  1337. $limit = $relatenum;
  1338. if(!$limit) {
  1339. return '';
  1340. }
  1341. foreach($tagarray as $var) {
  1342. $tagidarray[] = $var['0'];
  1343. }
  1344. if(!$tagidarray) {
  1345. return '';
  1346. }
  1347. if(empty($relatecache)) {
  1348. $thread = C::t('forum_thread')->fetch($tid);
  1349. $relatecache = $thread['relatebytag'];
  1350. }
  1351. if($relatecache) {
  1352. $relatecache = explode("\t", $relatecache);
  1353. if(TIMESTAMP > $relatecache[0] + $relatetime * 60) {
  1354. $updatecache = 1;
  1355. } else {
  1356. if(!empty($relatecache[1])) {
  1357. $relatearray = explode(',', $relatecache[1]);
  1358. }
  1359. }
  1360. } else {
  1361. $updatecache = 1;
  1362. }
  1363. if($updatecache) {
  1364. $query = C::t('common_tagitem')->select($tagidarray, $tid, $type, 'itemid', 'DESC', $limit, 0, '<>');
  1365. foreach($query as $result) {
  1366. if($result['itemid']) {
  1367. $relatearray[] = $result['itemid'];
  1368. }
  1369. }
  1370. if($relatearray) {
  1371. $relatebytag = implode(',', $relatearray);
  1372. }
  1373. C::t('forum_thread')->update($tid, array('relatebytag'=>TIMESTAMP."\t".$relatebytag));
  1374. }
  1375. if(!empty($relatearray)) {
  1376. rsort($relatearray);
  1377. foreach(C::t('forum_thread')->fetch_all_by_tid($relatearray) as $result) {
  1378. if($result['displayorder'] >= 0) {
  1379. $relateitem[] = $result;
  1380. }
  1381. }
  1382. }
  1383. return $relateitem;
  1384. }
  1385. function rushreply_rule () {
  1386. global $rushresult;
  1387. if(!empty($rushresult['rewardfloor'])) {
  1388. $rushresult['rewardfloor'] = preg_replace('/\*+/', '*', $rushresult['rewardfloor']);
  1389. $rewardfloorarr = explode(',', $rushresult['rewardfloor']);
  1390. if($rewardfloorarr) {
  1391. foreach($rewardfloorarr as $var) {
  1392. $var = trim($var);
  1393. if(strlen($var) > 1) {
  1394. $var = str_replace('*', '[^,]?[\d]*', $var);
  1395. } else {
  1396. $var = str_replace('*', '\d+', $var);
  1397. }
  1398. $preg[] = "(,$var,)";
  1399. }
  1400. $preg_str = "/".implode('|', $preg)."/";
  1401. }
  1402. }
  1403. return $preg_str;
  1404. }
  1405. function checkrushreply($post) {
  1406. global $_G, $rushids;
  1407. if($_GET['authorid']) {
  1408. return $post;
  1409. }
  1410. if(in_array($post['number'], $rushids)) {
  1411. $post['rewardfloor'] = 1;
  1412. }
  1413. return $post;
  1414. }
  1415. function parseindex($nodes, $pid) {
  1416. global $_G;
  1417. $nodes = dhtmlspecialchars($nodes);
  1418. $nodes = preg_replace('/(\**?)\[#(\d+)\](.+?)[\r\n]/', "<a page=\"\\2\" sub=\"\\1\">\\3</a>", $nodes);
  1419. $nodes = preg_replace('/(\**?)\[#(\d+),(\d+)\](.+?)[\r\n]/', "<a tid=\"\\2\" pid=\"\\3\" sub=\"\\1\">\\4</a>", $nodes);
  1420. $_G['forum_posthtml']['header'][$pid] .= '<div id="threadindex">'.$nodes.'</div><script type="text/javascript" reload="1">show_threadindex('.$pid.', '.($_GET['from'] == 'preview' ? '1' : '0').')</script>';
  1421. return '';
  1422. }
  1423. function parsebegin($linkaddr, $imgflashurl, $w = 0, $h = 0, $type = 0, $s = 0) {
  1424. static $begincontent;
  1425. if($begincontent || $_GET['from'] == 'preview') {
  1426. return '';
  1427. }
  1428. preg_match("/((https?){1}:\/\/|www\.)[^\[\"']+/i", $imgflashurl, $matches);
  1429. $imgflashurl = $matches[0];
  1430. $fileext = fileext($imgflashurl);
  1431. preg_match("/((https?){1}:\/\/|www\.)[^\[\"']+/i", $linkaddr, $matches);
  1432. $linkaddr = $matches[0];
  1433. $randomid = 'swf_'.random(3);
  1434. $w = ($w >=400 && $w <=1024) ? $w : 900;
  1435. $h = ($h >=300 && $h <=640) ? $h : 500;
  1436. $s = $s ? $s*1000 : 5000;
  1437. switch($fileext) {
  1438. case 'jpg':
  1439. case 'jpeg':
  1440. case 'gif':
  1441. case 'png':
  1442. $content = '<img style="position:absolute;width:'.$w.'px;height:'.$h.'px;" src="'.$imgflashurl.'" />';
  1443. break;
  1444. case 'flv':
  1445. $content = '<span id="'.$randomid.'" style="position:absolute;"></span>'.
  1446. '<script type="text/javascript" reload="1">$(\''.$randomid.'\').innerHTML='.
  1447. 'AC_FL_RunContent(\'width\', \''.$w.'\', \'height\', \''.$h.'\', '.
  1448. '\'allowNetworking\', \'internal\', \'allowScriptAccess\', \'never\', '.
  1449. '\'src\', \''.STATICURL.'image/common/flvplayer.swf\', '.
  1450. '\'flashvars\', \'file='.rawurlencode($imgflashurl).'\', \'quality\', \'high\', '.
  1451. '\'wmode\', \'transparent\', \'allowfullscreen\', \'true\');</script>';
  1452. break;
  1453. case 'swf':
  1454. $content = '<span id="'.$randomid.'" style="position:absolute;"></span>'.
  1455. '<script type="text/javascript" reload="1">$(\''.$randomid.'\').innerHTML='.
  1456. 'AC_FL_RunContent(\'width\', \''.$w.'\', \'height\', \''.$h.'\', '.
  1457. '\'allowNetworking\', \'internal\', \'allowScriptAccess\', \'never\', '.
  1458. '\'src\', encodeURI(\''.$imgflashurl.'\'), \'quality\', \'high\', \'bgcolor\', \'#ffffff\', '.
  1459. '\'wmode\', \'transparent\', \'allowfullscreen\', \'true\');</script>';
  1460. break;
  1461. default:
  1462. $content = '';
  1463. }
  1464. if($content) {
  1465. if($type == 1) {
  1466. $content = '<div id="threadbeginid" style="display:none;">'.
  1467. '<div class="flb beginidin"><span><div id="begincloseid" class="flbc" title="'.lang('core', 'close').'">'.lang('core', 'close').'</div></span></div>'.
  1468. $content.'<div class="beginidimg" style=" width:'.$w.'px;height:'.$h.'px;">'.
  1469. '<a href="'.$linkaddr.'" target="_blank" style="display: block; width:'.$w.'px; height:'.$h.'px;"></a></div></div>'.
  1470. '<script type="text/javascript">threadbegindisplay(1, '.$w.', '.$h.', '.$s.');</script>';
  1471. } else {
  1472. $content = '<div id="threadbeginid">'.
  1473. '<div class="flb beginidin">
  1474. <span><div id="begincloseid" class="flbc" title="'.lang('core', 'close').'">'.lang('core', 'close').'</div></span>
  1475. </div>'.
  1476. $content.'<div class="beginidimg" style=" width:'.$w.'px; height:'.$h.'px;">'.
  1477. '<a href="'.$linkaddr.'" target="_blank" style="display: block; width:'.$w.'px; height:'.$h.'px;"></a></div>
  1478. </div>'.
  1479. '<script type="text/javascript">threadbegindisplay('.$type.', '.$w.', '.$h.', '.$s.');</script>';
  1480. }
  1481. }
  1482. $begincontent = $content;
  1483. return $content;
  1484. }
  1485. function _checkviewgroup() {
  1486. global $_G;
  1487. $_G['action']['action'] = 3;
  1488. require_once libfile('function/group');
  1489. $status = groupperm($_G['forum'], $_G['uid']);
  1490. if($status == 1) {
  1491. showmessage('forum_group_status_off');
  1492. } elseif($status == 2) {
  1493. showmessage('forum_group_noallowed', 'forum.php?mod=group&fid='.$_G['fid']);
  1494. } elseif($status == 3) {
  1495. showmessage('forum_group_moderated', 'forum.php?mod=group&fid='.$_G['fid']);
  1496. }
  1497. }
  1498. ?>