Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.88 KB | None | 0 0
  1. <?php
  2.  
  3. switch ($livetopichook) {
  4. case 'template_edits':
  5. /*
  6. * Template Replacements
  7. */
  8. switch (THIS_SCRIPT) {
  9. case 'showthread':
  10. $vbulletin->templatecache['headinclude'] .= '
  11. <link rel=\"stylesheet\" type=\"text/css\" href=\"clientscript/vbulletin_css/livetopic.css\" id=\"livetopic\" />';
  12. $vbulletin->templatecache['footer'] .= '<div id=\"presence-container\"><div class=\"presence-contents\">no new posts</div></div>';
  13. $vbulletin->templatecache['footer'] .= '<script src=\"".$stylevar[yuipath]."/animation/animation-min.js\" type=\"text/javascript\"></script>
  14. <script type=\"text/javascript\" src=\"clientscript/livetopic.js\"></script>
  15. <script type=\"text/javascript\">
  16. var threadid = $threadinfo[threadid];
  17. var ajax_last_edit = $threadinfo[lastedit];
  18. livetopic.old_topic = ' . $vbulletin->options['livetopic_threadtime'] . ';
  19. livetopic.interval_time = ' . $vbulletin->options['livetopic_requestinterval'] . ';
  20. livetopic.ajax_max_visibleposts = ' . $vbulletin->options['livetopic_maxvisibleposts'] . ';
  21.  
  22. vbphrase[\"livetopic_maxpostnotice\"] = \"' . addslashes($vbphrase['livetopic_maxpostnotice']) . '\";
  23. vbphrase[\"livetopic_edit_message\"] = \"' . addslashes($vbphrase['livetopic_edit_message']) . '\";
  24. vbphrase[\"livetopic_newresponses\"] = \"' . addslashes($vbphrase['livetopic_newresponses']) . '\";
  25. </script>
  26. ';
  27. break;
  28. case 'search':
  29. case 'forumdisplay':
  30. $vbulletin->templatecache['FORUMDISPLAY'] = preg_replace('#<!-- controls below thread list -->#i','<!-- controls below thread list --><div style=\"height: 0px !important; overflow: hidden !important;\">90353748e6549cd1148d01dde3b3bc75</div>', $vbulletin->templatecache['FORUMDISPLAY']);
  31. if (preg_match('#<!--livetopic_icon-->#i', $vbulletin->templatecache['threadbit'])) {
  32. $vbulletin->templatecache['threadbit'] = preg_replace('#<!--livetopic_icon-->#i','".(($livetopic === true) ? ("<img src=\"$stylevar[imgdir_statusicon]/thread_livetopic.gif\" alt=\"live topic\" />") : (""))."', $vbulletin->templatecache['threadbit']);
  33. } else {
  34. $vbulletin->templatecache['threadbit'] = preg_replace('#\[last_page\]</a>"\) \: \(""\)\)\."\)</span>"\)\ \: \(""\)\)\."#i','[last_page]</a>") : ("")).")</span>") : (""))." ".(($livetopic === true) ? ("<img src=\"$stylevar[imgdir_statusicon]/thread_livetopic.gif\" alt=\"live topic\" />") : (""))."', $vbulletin->templatecache['threadbit']);
  35. }
  36. break;
  37. }
  38. break;
  39.  
  40. /*
  41. * Ajax Logic
  42. */
  43. case 'ajax_start':
  44. if (
  45. $_GET['do'] == 'shownewresponses' &&
  46. isset($_POST['threadid'], $_POST['ajax_lastpost'], $_POST['ajax_lastedit'])
  47. ) {
  48.  
  49. $vbulletin->input->clean_array_gpc('p', array(
  50. 'threadid' => TYPE_INT,
  51. 'ajax_lastpost' => TYPE_INT,
  52. 'ajax_lastedit' => TYPE_INT
  53. ));
  54.  
  55. $_POST['threadid'] = $vbulletin->db->escape_string($vbulletin->GPC['threadid']);
  56. $_POST['ajax_lastpost'] = $vbulletin->db->escape_string($vbulletin->GPC['ajax_lastpost']);
  57. $_POST['ajax_lastedit'] = $vbulletin->db->escape_string($vbulletin->GPC['ajax_lastedit']);
  58.  
  59. $change_query = $db->query_first("
  60. SELECT COUNT(*) AS count
  61. FROM " . TABLE_PREFIX . "post AS post
  62. WHERE
  63. " . iif (trim($vbulletin->userinfo['ignorelist']), "userid NOT IN (0," . str_replace(' ', ',', $vbulletin->userinfo['ignorelist']) . ") AND ") ."
  64. (threadid = {$_POST[threadid]}
  65. AND visible = 1
  66. AND dateline > {$_POST[ajax_lastpost]}
  67. AND userid != " . $vbulletin->userinfo['userid'] . ")
  68. OR (threadid = {$_POST[threadid]}
  69. AND visible = 1
  70. AND lastedit > {$_POST[ajax_lastedit]})"
  71. );
  72.  
  73. if ($change_query['count'] > 0) {
  74.  
  75. define('NOPMPOPUP', 1);
  76. define('NOSHUTDOWNFUNC', 1);
  77. define('LOCATION_BYPASS', 1);
  78.  
  79. require_once(DIR . '/includes/class_postbit.php');
  80. require_once(DIR . '/includes/functions_bigthree.php');
  81. require_once(DIR . '/includes/class_xml.php');
  82.  
  83. $postcount = 0;
  84. $thread =& $threadinfo;
  85. $forum =& $foruminfo;
  86.  
  87. $show['quickreply'] = true;
  88.  
  89. if (!$forum['allowposting'])
  90. {
  91. $show['quickreply'] = false;
  92. }
  93.  
  94. $show['managepost'] = iif(can_moderate($threadinfo['forumid'], 'candeleteposts') OR can_moderate($threadinfo['forumid'], 'canremoveposts'), true, false);
  95. $show['approvepost'] = (can_moderate($threadinfo['forumid'], 'canmoderateposts')) ? true : false;
  96. $show['managethread'] = can_moderate($threadinfo['forumid'], 'canmanagethreads') ? true : false;
  97. $show['inlinemod'] = ($show['managethread'] OR $show['managepost'] OR $show['approvepost']) ? true : false;
  98.  
  99. $show['multiquote_global'] = ($vbulletin->options['multiquote'] AND $vbulletin->userinfo['userid']);
  100. if ($show['multiquote_global'])
  101. {
  102. $vbulletin->input->clean_array_gpc('c', array(
  103. 'vbulletin_multiquote' => TYPE_STR
  104. ));
  105. $vbulletin->GPC['vbulletin_multiquote'] = explode(',', $vbulletin->GPC['vbulletin_multiquote']);
  106. }
  107.  
  108. $hook_query_fields = $hook_query_joins = $hook_query_where = '';
  109. ($hook = vBulletinHook::fetch_hook('newreply_post_ajax')) ? eval($hook) : false;
  110.  
  111. $posts = $db->query_read("
  112. SELECT
  113. post.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,
  114. user.*, userfield.*, usertextfield.*,
  115. " . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "
  116. " . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "
  117. " . iif($deljoin, 'deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,') . "
  118. editlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,
  119. editlog.reason AS edit_reason, editlog.hashistory,
  120. postparsed.pagetext_html, postparsed.hasimages,
  121. sigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,
  122. sigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,
  123. IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
  124. " . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefiled['hidden']) . "
  125. $hook_query_fields
  126. FROM " . TABLE_PREFIX . "post AS post
  127. LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)
  128. LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
  129. LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
  130. " . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "
  131. " . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "
  132. $deljoin
  133. LEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)
  134. LEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")
  135. LEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")
  136. LEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)
  137. $hook_query_joins
  138. WHERE post.threadid = $_POST[threadid] AND
  139. post.visible = 1 AND
  140. ((post.dateline > $_POST[ajax_lastpost] AND
  141. post.userid != " . $vbulletin->userinfo['userid'] . ")
  142. OR
  143. post.lastedit > $_POST[ajax_lastedit])
  144. " . iif (trim($vbulletin->userinfo['ignorelist']), "AND post.userid NOT IN (0," . str_replace(' ', ',', $vbulletin->userinfo['ignorelist']) . ")") . "
  145. $hook_query_where
  146. ORDER BY dateline
  147. ");
  148.  
  149. $postcount_query = $db->query_first("
  150. SELECT COUNT(*) AS count
  151. FROM " . TABLE_PREFIX . "post AS post
  152. WHERE threadid = {$_POST[threadid]}
  153. AND visible = 1"
  154. );
  155.  
  156. $postcount = $postcount_query['count']-1;
  157.  
  158. $postbit_factory =& new vB_Postbit_Factory();
  159. $postbit_factory->registry =& $vbulletin;
  160. $postbit_factory->forum =& $foruminfo;
  161. $postbit_factory->thread =& $thread;
  162. $postbit_factory->cache = array();
  163. $postbit_factory->bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
  164.  
  165. $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
  166. $xml->add_group('root');
  167.  
  168. while ($post = $db->fetch_array($posts))
  169. {
  170. if ($tachyuser = in_coventry($post['userid']) AND !can_moderate($thread['forumid']))
  171. {
  172. continue;
  173. }
  174.  
  175. if ($tachyuser)
  176. {
  177. $fetchtype = 'post_global_ignore';
  178. }
  179. else if ($ignore["$post[userid]"])
  180. {
  181. $fetchtype = 'post_ignore';
  182. }
  183. else if ($post['visible'] == 2)
  184. {
  185. if (!$see_deleted)
  186. {
  187. continue;
  188. }
  189. $fetchtype = 'post_deleted';
  190. }
  191. else if ($post['visible'] == 0 AND !can_moderate($thread['forumid'], 'canmoderateposts'))
  192. {
  193. $fetchtype = 'auto_moderated';
  194. }
  195. else
  196. {
  197. $fetchtype = 'post';
  198. }
  199.  
  200. if ($postorder)
  201. {
  202. $post['postcount'] = --$postcount;
  203. }
  204. else
  205. {
  206. $post['postcount'] = ++$postcount;
  207. }
  208.  
  209. if ($post['attach'])
  210. {
  211. $attachments = $db->query_read_slave("
  212. SELECT dateline, thumbnail_dateline, filename, filesize, visible, attachmentid, counter,
  213. postid, IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail, thumbnail_filesize,
  214. attachmenttype.thumbnail AS build_thumbnail, attachmenttype.newwindow
  215. FROM " . TABLE_PREFIX . "attachment
  216. LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype USING (extension)
  217. WHERE postid = $post[postid]
  218. ORDER BY attachmentid
  219. ");
  220. while ($attachment = $db->fetch_array($attachments))
  221. {
  222. if (!$attachment['build_thumbnail'])
  223. {
  224. $attachment['hasthumbnail'] = false;
  225. }
  226. $post['attachments']["$attachment[attachmentid]"] = $attachment;
  227. }
  228. }
  229.  
  230. // address padding issues in postbit_legacy. These 2 lines will place only
  231. // top padding before each postbit created this way.
  232. $post['islastshown'] = true;
  233. $post['toppadding'] = true;
  234.  
  235. if ($post['lastedit'] > $_POST['ajax_lastedit']) {
  236. $post['postcount'] = '___postcount_placeholder___';
  237. }
  238.  
  239. ($hook = vBulletinHook::fetch_hook('showthread_postbit_create')) ? eval($hook) : false;
  240.  
  241. $postbit_obj =& $postbit_factory->fetch_postbit($fetchtype);
  242.  
  243. $xml->add_tag('postbit', process_replacement_vars($postbit_obj->construct_postbit($post)), array('postid' => $post['postid'], 'dateline' => $post['dateline'], 'lastedit' => $post['lastedit'] ));
  244.  
  245. $dateline = $post['dateline'];
  246. }
  247.  
  248. // ajax posts always mark the thread as read because any missed posts are retrieved as well
  249. mark_thread_read($threadinfo, $foruminfo, $vbulletin->userinfo['userid'], TIMENOW);
  250.  
  251. $xml->add_tag('posttype', $dateline);
  252. $xml->add_tag('db_ajax_last_post', $dateline);
  253. $xml->add_tag('db_ajax_last_edit', $thread['lastedit']);
  254. $xml->close_group();
  255. $xml->print_xml(true);
  256. } else {
  257. header('Content-Type: text/xml');
  258. echo '<?xml version="1.0" encoding="windows-1252"?><root><db_ajax_last_post></db_ajax_last_post><db_ajax_last_edit></db_ajax_last_edit></root>';
  259. }
  260. } else if (
  261. $_GET['do'] == 'shownewnotifications' &&
  262. isset($_POST['threadid'], $_POST['ajax_lastpost'])
  263. ) {
  264.  
  265. $vbulletin->input->clean_array_gpc('p', array(
  266. 'threadid' => TYPE_INT,
  267. 'ajax_lastpost' => TYPE_INT
  268. ));
  269.  
  270. $_POST['threadid'] = $vbulletin->db->escape_string($vbulletin->GPC['threadid']);
  271. $_POST['ajax_lastpost'] = $vbulletin->db->escape_string($vbulletin->GPC['ajax_lastpost']);
  272.  
  273. $postcount_query = $db->query_first("
  274. SELECT COUNT(*) AS count
  275. FROM " . TABLE_PREFIX . "post AS post
  276. WHERE threadid = $_POST[threadid]
  277. AND visible = 1
  278. AND dateline > " . ($_POST['ajax_lastpost'])
  279. );
  280.  
  281. header('Content-Type: text/xml');
  282. echo '<?xml version="1.0" encoding="windows-1252"?><postbits><new>'.$postcount_query['count'].'</new></postbits>';
  283. }
  284. break;
  285. default:
  286. break;
  287. }
  288. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement