PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/source/include/thread/thread_printable.php

https://github.com/jinbo51/DiscuzX
PHP | 77 lines | 61 code | 10 blank | 6 comment | 21 complexity | 6f9b3dc6ef826700853424644f311783 MD5 | raw file
Possible License(s): BSD-3-Clause
  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: thread_printable.php 33149 2013-04-28 01:53:37Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $thisbg = '#FFFFFF';
  12. if(!getstatus($_G['forum_thread']['status'], 2)) {
  13. $posts = C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], $_G['tid'], true, 'ASC', 0, 100, null, 0);
  14. } else {
  15. $posts = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid'], 0);
  16. $posts = array($posts);
  17. }
  18. $userinfo = $uids = $skipaids = array();
  19. foreach($posts as $post) {
  20. if(strpos($post['message'], '[/password]') !== FALSE) {
  21. $post['message'] = '';
  22. }
  23. $post['dateline'] = dgmdate($post['dateline'], 'u');
  24. if(preg_match("/\[hide\]\s*(.+?)\s*\[\/hide\]/is", $post['message'], $hide)) {
  25. if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $hide[1], $matchaids)) {
  26. $skipaids = array_merge($skipaids, $matchaids[1]);
  27. }
  28. $post['message'] = preg_replace("/\[hide\]\s*(.+?)\s*\[\/hide\]/is", '', $post['message']);
  29. }
  30. if(strpos(strtolower($post['message']), '[hide=') !== FALSE) {
  31. $post['message'] = preg_replace("/\[hide=(\d+)\]\s*(.*?)\s*\[\/hide\]/is", "", $post['message']);
  32. }
  33. $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $_G['forum']['allowsmilies'], $_G['forum']['allowbbcode'], $_G['forum']['allowimgcode'], $_G['forum']['allowhtml'], ($_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0));
  34. if(strpos($post['message'], '[page]') !== FALSE) {
  35. $post['message'] = preg_replace("/\s?\[page\]\s?/is", '', $post['message']);
  36. }
  37. if(strpos($post['message'], '[/index]') !== FALSE) {
  38. $post['message'] = preg_replace("/\s?\[index\](.+?)\[\/index\]\s?/is", '', $post['message']);
  39. }
  40. if($post['attachment']) {
  41. $attachment = 1;
  42. }
  43. $post['attachments'] = array();
  44. if($post['attachment'] && ($_G['group']['allowgetattach'] || $_G['group']['allowgetimage'])) {
  45. $_G['forum_attachpids'][] = $post['pid'];
  46. $post['attachment'] = 0;
  47. if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $post['message'], $matchaids)) {
  48. $_G['forum_attachtags'][$post['pid']] = $matchaids[1];
  49. }
  50. }
  51. $uids[] = $post['authorid'];
  52. $postlist[$post['pid']] = $post;
  53. }
  54. unset($posts);
  55. if($uids) {
  56. $uids = array_unique($uids);
  57. $userinfo = C::t('common_member')->fetch_all($uids);
  58. }
  59. if($_G['forum_attachpids'] && !defined('IN_ARCHIVER')) {
  60. require_once libfile('function/attachment');
  61. if(is_array($threadsortshow) && !empty($threadsortshow['sortaids'])) {
  62. $skipaids = array_merge($skipaids, $threadsortshow['sortaids']);
  63. }
  64. parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist, $skipaids);
  65. }
  66. include template('forum/viewthread_printable');
  67. ?>