Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- switch ($livetopichook) {
- case 'template_edits':
- /*
- * Template Replacements
- */
- switch (THIS_SCRIPT) {
- case 'showthread':
- $vbulletin->templatecache['headinclude'] .= '
- <link rel=\"stylesheet\" type=\"text/css\" href=\"clientscript/vbulletin_css/livetopic.css\" id=\"livetopic\" />';
- $vbulletin->templatecache['footer'] .= '<div id=\"presence-container\"><div class=\"presence-contents\">no new posts</div></div>';
- $vbulletin->templatecache['footer'] .= '<script src=\"".$stylevar[yuipath]."/animation/animation-min.js\" type=\"text/javascript\"></script>
- <script type=\"text/javascript\" src=\"clientscript/livetopic.js\"></script>
- <script type=\"text/javascript\">
- var threadid = $threadinfo[threadid];
- var ajax_last_edit = $threadinfo[lastedit];
- livetopic.old_topic = ' . $vbulletin->options['livetopic_threadtime'] . ';
- livetopic.interval_time = ' . $vbulletin->options['livetopic_requestinterval'] . ';
- livetopic.ajax_max_visibleposts = ' . $vbulletin->options['livetopic_maxvisibleposts'] . ';
- vbphrase[\"livetopic_maxpostnotice\"] = \"' . addslashes($vbphrase['livetopic_maxpostnotice']) . '\";
- vbphrase[\"livetopic_edit_message\"] = \"' . addslashes($vbphrase['livetopic_edit_message']) . '\";
- vbphrase[\"livetopic_newresponses\"] = \"' . addslashes($vbphrase['livetopic_newresponses']) . '\";
- </script>
- ';
- break;
- case 'search':
- case 'forumdisplay':
- $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']);
- if (preg_match('#<!--livetopic_icon-->#i', $vbulletin->templatecache['threadbit'])) {
- $vbulletin->templatecache['threadbit'] = preg_replace('#<!--livetopic_icon-->#i','".(($livetopic === true) ? ("<img src=\"$stylevar[imgdir_statusicon]/thread_livetopic.gif\" alt=\"live topic\" />") : (""))."', $vbulletin->templatecache['threadbit']);
- } else {
- $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']);
- }
- break;
- }
- break;
- /*
- * Ajax Logic
- */
- case 'ajax_start':
- if (
- $_GET['do'] == 'shownewresponses' &&
- isset($_POST['threadid'], $_POST['ajax_lastpost'], $_POST['ajax_lastedit'])
- ) {
- $vbulletin->input->clean_array_gpc('p', array(
- 'threadid' => TYPE_INT,
- 'ajax_lastpost' => TYPE_INT,
- 'ajax_lastedit' => TYPE_INT
- ));
- $_POST['threadid'] = $vbulletin->db->escape_string($vbulletin->GPC['threadid']);
- $_POST['ajax_lastpost'] = $vbulletin->db->escape_string($vbulletin->GPC['ajax_lastpost']);
- $_POST['ajax_lastedit'] = $vbulletin->db->escape_string($vbulletin->GPC['ajax_lastedit']);
- $change_query = $db->query_first("
- SELECT COUNT(*) AS count
- FROM " . TABLE_PREFIX . "post AS post
- WHERE
- " . iif (trim($vbulletin->userinfo['ignorelist']), "userid NOT IN (0," . str_replace(' ', ',', $vbulletin->userinfo['ignorelist']) . ") AND ") ."
- (threadid = {$_POST[threadid]}
- AND visible = 1
- AND dateline > {$_POST[ajax_lastpost]}
- AND userid != " . $vbulletin->userinfo['userid'] . ")
- OR (threadid = {$_POST[threadid]}
- AND visible = 1
- AND lastedit > {$_POST[ajax_lastedit]})"
- );
- if ($change_query['count'] > 0) {
- define('NOPMPOPUP', 1);
- define('NOSHUTDOWNFUNC', 1);
- define('LOCATION_BYPASS', 1);
- require_once(DIR . '/includes/class_postbit.php');
- require_once(DIR . '/includes/functions_bigthree.php');
- require_once(DIR . '/includes/class_xml.php');
- $postcount = 0;
- $thread =& $threadinfo;
- $forum =& $foruminfo;
- $show['quickreply'] = true;
- if (!$forum['allowposting'])
- {
- $show['quickreply'] = false;
- }
- $show['managepost'] = iif(can_moderate($threadinfo['forumid'], 'candeleteposts') OR can_moderate($threadinfo['forumid'], 'canremoveposts'), true, false);
- $show['approvepost'] = (can_moderate($threadinfo['forumid'], 'canmoderateposts')) ? true : false;
- $show['managethread'] = can_moderate($threadinfo['forumid'], 'canmanagethreads') ? true : false;
- $show['inlinemod'] = ($show['managethread'] OR $show['managepost'] OR $show['approvepost']) ? true : false;
- $show['multiquote_global'] = ($vbulletin->options['multiquote'] AND $vbulletin->userinfo['userid']);
- if ($show['multiquote_global'])
- {
- $vbulletin->input->clean_array_gpc('c', array(
- 'vbulletin_multiquote' => TYPE_STR
- ));
- $vbulletin->GPC['vbulletin_multiquote'] = explode(',', $vbulletin->GPC['vbulletin_multiquote']);
- }
- $hook_query_fields = $hook_query_joins = $hook_query_where = '';
- ($hook = vBulletinHook::fetch_hook('newreply_post_ajax')) ? eval($hook) : false;
- $posts = $db->query_read("
- SELECT
- post.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,
- user.*, userfield.*, usertextfield.*,
- " . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "
- " . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "
- " . iif($deljoin, 'deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,') . "
- editlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,
- editlog.reason AS edit_reason, editlog.hashistory,
- postparsed.pagetext_html, postparsed.hasimages,
- sigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,
- sigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,
- IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
- " . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefiled['hidden']) . "
- $hook_query_fields
- FROM " . TABLE_PREFIX . "post AS post
- LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)
- LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
- LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
- " . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "
- " . 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)") . "
- $deljoin
- LEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)
- LEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")
- LEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")
- LEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)
- $hook_query_joins
- WHERE post.threadid = $_POST[threadid] AND
- post.visible = 1 AND
- ((post.dateline > $_POST[ajax_lastpost] AND
- post.userid != " . $vbulletin->userinfo['userid'] . ")
- OR
- post.lastedit > $_POST[ajax_lastedit])
- " . iif (trim($vbulletin->userinfo['ignorelist']), "AND post.userid NOT IN (0," . str_replace(' ', ',', $vbulletin->userinfo['ignorelist']) . ")") . "
- $hook_query_where
- ORDER BY dateline
- ");
- $postcount_query = $db->query_first("
- SELECT COUNT(*) AS count
- FROM " . TABLE_PREFIX . "post AS post
- WHERE threadid = {$_POST[threadid]}
- AND visible = 1"
- );
- $postcount = $postcount_query['count']-1;
- $postbit_factory =& new vB_Postbit_Factory();
- $postbit_factory->registry =& $vbulletin;
- $postbit_factory->forum =& $foruminfo;
- $postbit_factory->thread =& $thread;
- $postbit_factory->cache = array();
- $postbit_factory->bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
- $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
- $xml->add_group('root');
- while ($post = $db->fetch_array($posts))
- {
- if ($tachyuser = in_coventry($post['userid']) AND !can_moderate($thread['forumid']))
- {
- continue;
- }
- if ($tachyuser)
- {
- $fetchtype = 'post_global_ignore';
- }
- else if ($ignore["$post[userid]"])
- {
- $fetchtype = 'post_ignore';
- }
- else if ($post['visible'] == 2)
- {
- if (!$see_deleted)
- {
- continue;
- }
- $fetchtype = 'post_deleted';
- }
- else if ($post['visible'] == 0 AND !can_moderate($thread['forumid'], 'canmoderateposts'))
- {
- $fetchtype = 'auto_moderated';
- }
- else
- {
- $fetchtype = 'post';
- }
- if ($postorder)
- {
- $post['postcount'] = --$postcount;
- }
- else
- {
- $post['postcount'] = ++$postcount;
- }
- if ($post['attach'])
- {
- $attachments = $db->query_read_slave("
- SELECT dateline, thumbnail_dateline, filename, filesize, visible, attachmentid, counter,
- postid, IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail, thumbnail_filesize,
- attachmenttype.thumbnail AS build_thumbnail, attachmenttype.newwindow
- FROM " . TABLE_PREFIX . "attachment
- LEFT JOIN " . TABLE_PREFIX . "attachmenttype AS attachmenttype USING (extension)
- WHERE postid = $post[postid]
- ORDER BY attachmentid
- ");
- while ($attachment = $db->fetch_array($attachments))
- {
- if (!$attachment['build_thumbnail'])
- {
- $attachment['hasthumbnail'] = false;
- }
- $post['attachments']["$attachment[attachmentid]"] = $attachment;
- }
- }
- // address padding issues in postbit_legacy. These 2 lines will place only
- // top padding before each postbit created this way.
- $post['islastshown'] = true;
- $post['toppadding'] = true;
- if ($post['lastedit'] > $_POST['ajax_lastedit']) {
- $post['postcount'] = '___postcount_placeholder___';
- }
- ($hook = vBulletinHook::fetch_hook('showthread_postbit_create')) ? eval($hook) : false;
- $postbit_obj =& $postbit_factory->fetch_postbit($fetchtype);
- $xml->add_tag('postbit', process_replacement_vars($postbit_obj->construct_postbit($post)), array('postid' => $post['postid'], 'dateline' => $post['dateline'], 'lastedit' => $post['lastedit'] ));
- $dateline = $post['dateline'];
- }
- // ajax posts always mark the thread as read because any missed posts are retrieved as well
- mark_thread_read($threadinfo, $foruminfo, $vbulletin->userinfo['userid'], TIMENOW);
- $xml->add_tag('posttype', $dateline);
- $xml->add_tag('db_ajax_last_post', $dateline);
- $xml->add_tag('db_ajax_last_edit', $thread['lastedit']);
- $xml->close_group();
- $xml->print_xml(true);
- } else {
- header('Content-Type: text/xml');
- 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>';
- }
- } else if (
- $_GET['do'] == 'shownewnotifications' &&
- isset($_POST['threadid'], $_POST['ajax_lastpost'])
- ) {
- $vbulletin->input->clean_array_gpc('p', array(
- 'threadid' => TYPE_INT,
- 'ajax_lastpost' => TYPE_INT
- ));
- $_POST['threadid'] = $vbulletin->db->escape_string($vbulletin->GPC['threadid']);
- $_POST['ajax_lastpost'] = $vbulletin->db->escape_string($vbulletin->GPC['ajax_lastpost']);
- $postcount_query = $db->query_first("
- SELECT COUNT(*) AS count
- FROM " . TABLE_PREFIX . "post AS post
- WHERE threadid = $_POST[threadid]
- AND visible = 1
- AND dateline > " . ($_POST['ajax_lastpost'])
- );
- header('Content-Type: text/xml');
- echo '<?xml version="1.0" encoding="windows-1252"?><postbits><new>'.$postcount_query['count'].'</new></postbits>';
- }
- break;
- default:
- break;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement