Paha_W
Full Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору Hryamzik ############################################################# # # # ___ ХАК СКЛЕЙКИ СООБЩЕНИЙ ___ # # # # Name: Stuck Message # # Autor: polo # # VB version: 3.x.x # # Hack version: 1.0 # # This hack is for netadmin memebers only. # # Distribution of this hack at other forums is forbidden. # # # #-----------------------------------------------------------# # # # Хак: Склейка сообщений # # Автор: polo # # Версия VB: 3.x.x # # Версия хака: 1.0 # # Этот хак только для пользователей netadmin. # # Расспостранение данного хака вне страницах сайта # # netadmin.ws запрещено. # # # ############################################################# -------------------------- Описание ------------------------- Данный хак соеденяет сообщения пользователей, которые были помещены одним и тем же пользователем в одну и ту же тему ру- ководствуясь некоторыми параметрами (читай 'особености'). ------------------------- Особености ------------------------ 1. Склейка сообщений помещенных в одну и туже тему которые были опубликованы в период менее двух часов, с условием что пользователь отвечает на сообщение не цитируя другое, сделано для поддержания древовидной структуры отображения. 2. Тема не обновляется, т.е. дата не меняется и соответсвенно тема не подымается вверх в списке тем. 3. Полное обновление параметров сообщений: подписка на тему, смайлы в сообщении, иконка, заголовок (если предыдущее сообще- ние не содержало заголовка), закрытие/открытие (при наличии соответсующих прав)... 4.Добавление аттачментов. 5. Добавление строки в сообщении типа: 'username добавил дата время'. Фраза хранится в в языковой системе VB и легко может быть изменена и переведена на все доступные языки. 6. Практически никакой новой нагрузки не считая один доп. запрос при создании сообщения. ------------------------- Установка ------------------------- ###################################### # ВЫПОЛНИТЬ СЛЕДУЮЩИЙ SQL ЗАПРОС # Замените TABLEPREFIX_ на ваш prefix INSERT INTO TABLEPREFIX_phrase VALUES (NULL, 0, 'user_added_to_post', '<span class="smallfont"><i>{1} has added {2} at <span class="time">{3}</span></i></span>', 42); Перейти в admincp > Languages & Phrases > Language Manager > Rebuild All Languages ##################################### # редактирование 'newreply.php' ****** Найти (примерно 151-152 строка) ****** eval(print_standard_error('error_invalidid')); } ****** Ниже добавить ****** // __START__ Hack stuck messages by polo // this hack is for netadmin memebers only // Distribution of this hack at other forums is forbidden if ($_POST['do'] == 'postreply' AND !$_POST['preview']) { $lastpost=$DB_site->query_first("SELECT post.*, NOT ISNULL(deletionlog.primaryid) AS isdeleted FROM " . TABLE_PREFIX . "post AS post," . TABLE_PREFIX . "thread AS thread LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND type = 'post') WHERE post.threadid=thread.threadid AND thread.threadid='$threadid' AND post.visible=1 AND thread.visible=1 ORDER BY post.dateline DESC LIMIT 1"); $timedifference = TIMENOW - $lastpost['dateline']; if ($bbuserinfo['userid'] != 0 AND $bbuserinfo['userid'] == $lastpost['userid'] AND !$lastpost['isdeleted'] AND $timedifference <= 7200) { if ((empty($_POST['postid']) OR !is_numeric($_POST['postid'])) OR $_POST['postid'] == $lastpost['postid']) { unset($_POST['do']); $_POST['do'] = 'stuckmessagesbypolo'; $edit = array(); $postid = $lastpost['postid']; } } } // ############################### start stuck messages ############################### if ($_POST['do'] == 'stuckmessagesbypolo') { globalize($_POST, array('posthash' => STR_NOHTML, 'poststarttime')); // Make sure the posthash is valid if (md5($poststarttime . $bbuserinfo['userid'] . $bbuserinfo['salt']) != $posthash) { $posthash = 'invalid posthash'; // don't phrase me } // ### PREP INPUT (should eventually all come in array direct from form) ### if ($_POST['WYSIWYG_HTML'] != '') { require_once('./includes/functions_wysiwyg.php'); $edit['message'] = trim(convert_wysiwyg_html_to_bbcode($_POST['WYSIWYG_HTML'], $foruminfo['allowhtml'])); } else { $edit['message'] = trim($_POST['message']); } // remove empty bbcodes $edit['message'] = strip_empty_bbcode($edit['message']); // add # to color tags using hex if it's not there $edit['message'] = preg_replace('#\[color=("|"|\'|)([a-f0-9]{6})\\1]#i', '[color=\1#\2\1]', $edit['message']); // remove /list=x remnants if (stristr($edit['message'], '/list=') != false) { $edit['message'] = preg_replace('#/list=[a-z0-9]+\]#siU', '/list]', $edit['message']); } // remove extra whitespace between [list] and first element $edit['message'] = preg_replace('#(\[list(=("|"|\'|)([^\]]*)\\3)?\])\s+#i', "\\1\n", $edit['message']); if ($_POST['fromquickreply']) { // We only add notifications to threads that don't have one if the user defaults to it, do nothing else! if ($bbuserinfo['autosubscribe'] != -1 AND !$threadinfo['issubscribed']) { $_POST['folderid'] = 0; $_POST['emailupdate'] = $bbuserinfo['autosubscribe']; } else if ($threadinfo['issubscribed']) { // Don't alter current settings $_POST['folderid'] = $threadinfo['folderid']; $_POST['emailupdate'] = $threadinfo['emailupdate']; } else { // Don't don't add! $_POST['emailupdate'] = 9999; } // fetch the quoted post title $_POST['title'] = fetch_quote_title($postinfo['title'], $threadinfo['title']); } if ($lastpost['title'] == '') { $edit['title'] = trim($_POST['title']); } else { $edit['title'] = $lastpost['title']; } if ($lastpost['iconid'] == 0) { $edit['iconid'] = intval($_POST['iconid']); } else { $edit['iconid'] = $lastpost['iconid']; } $edit['parseurl'] = intval($_POST['parseurl']); $edit['signature'] = intval($_POST['signature']); $edit['disablesmilies'] = intval($_POST['disablesmilies']); $edit['enablesmilies'] = $edit['allowsmilie'] = iif($edit['disablesmilies'], 0, 1); $edit['folderid'] = intval($_POST['folderid']); $edit['emailupdate'] = intval($_POST['emailupdate']); $postusername = $bbuserinfo['username']; verify_post_errors('editpost', $edit, $errors); if (sizeof($errors) > 0) { // ### POST HAS ERRORS ### $postpreview = construct_errors($errors); // this will take the preview's place construct_checkboxes($edit); $_REQUEST['do'] = 'newreply'; $newpost['message'] = htmlspecialchars_uni($edit['message']); } else { // ### POST HAS NO ERRORS ### if ((($permissions['genericoptions'] & SHOWEDITEDBY) AND $postinfo['dateline'] < (TIMENOW - ($vboptions['noeditedbytime'] * 60))) OR $edit['reason_exists'] OR !empty($edit['reason'])) { $DB_site->query(" REPLACE INTO " . TABLE_PREFIX . "editlog (postid, userid, username, dateline, reason) VALUES ($postid, $bbuserinfo[userid], '" . addslashes($bbuserinfo['username']) . "', " . TIMENOW . ", '" . addslashes($edit['reason']) . "') "); } if ($edit['parseurl']) { $edit['message'] = convert_url_to_bbcode($edit['message']); } // remove /list=x remnants if (stristr($edit['message'], '/list=') != false) { $edit['message'] = preg_replace('#/list=[a-z0-9]+\]#siU', '/list]', $edit['message']); } $edit['title'] = fetch_censored_text(fetch_no_shouting_text($edit['title'])); require_once('./includes/functions_login.php'); $edit['message'] = fetch_censored_text(fetch_removed_sessionhash($edit['message'])); // initialize thread / forum update clauses $threadupdate = array(); $modlogsql = array(); $forumupdate = false; // find out if first post $getpost = $DB_site->query_first(" SELECT postid FROM " . TABLE_PREFIX . "post WHERE threadid=$threadinfo[threadid] ORDER BY dateline LIMIT 1 "); if ($getpost['postid'] == $postid AND $edit['title'] != '' AND ($postinfo['dateline'] + $vboptions['editthreadtitlelimit'] * 60) > TIMENOW) { // need to update thread title and iconid $threadupdate[] = "title = '" . addslashes(htmlspecialchars_uni($edit['title'])) . "', iconid = $edit[iconid]"; // do we need to update the forum counters? $forumupdate = iif($foruminfo['lastthreadid'] == $threadinfo['threadid'], true, false); } // can this user open/close this thread if they want to? if ($_POST['openclose'] AND (($threadinfo['postuserid'] != 0 AND $threadinfo['postuserid'] == $bbuserinfo['userid'] AND $forumperms & CANOPENCLOSE) OR can_moderate($threadinfo['forumid'], 'canopenclose'))) { if ($threadinfo['open']) { $open = 0; $notes = addslashes(construct_phrase($vbphrase['thread_closed_by_x_on_y_at_z'], $bbuserinfo['username'], $date, $time)); $string = $vbphrase['closed']; } else { $open = 1; $notes = addslashes(construct_phrase($vbphrase['thread_opened_by_x_on_y_at_z'], $bbuserinfo['username'], $date, $time)); $string = $vbphrase['opened']; } $threadupdate[] = "open = $open, notes = CONCAT(notes, ' $notes')"; $modlogsql[] = "($bbuserinfo[userid], " . TIMENOW . ", $threadinfo[forumid], $threadinfo[threadid], '" . addslashes($string) . "')"; } // can this user stick/unstick this thread if they want to? if ($_POST['stickunstick'] AND can_moderate($threadinfo['forumid'], 'canmanagethreads')) { if ($threadinfo['sticky']) { $stick = 0; $notes = addslashes(construct_phrase($vbphrase['thread_unstuck_by_x_on_y_at_z'], $bbuserinfo['username'], $date, $time)); $string = $vbphrase['unstuck']; } else { $stick = 1; $notes = addslashes(construct_phrase($vbphrase['thread_stuck_by_x_on_y_at_z'], $bbuserinfo['username'], $date, $time)); $string = $vbphrase['stuck']; } $threadupdate[] = "sticky = $stick, notes = CONCAT(notes, ' $notes')"; $modlogsql[] = "($bbuserinfo[userid], " . TIMENOW . ", $threadinfo[forumid], $threadinfo[threadid], '" . addslashes($string) . "')"; } require_once('./includes/functions_databuild.php'); if (!empty($threadupdate)) { // do thread update $DB_site->query(" UPDATE " . TABLE_PREFIX . "thread SET " . implode(', ', $threadupdate) . " WHERE threadid = $threadinfo[threadid] "); // moderator log if (!empty($modlogsql)) { $DB_site->query(" INSERT INTO " . TABLE_PREFIX . "moderatorlog(userid, dateline, forumid, threadid, action) VALUES " . implode(', ', $modlogsql) ); } // do forum update if necessary if ($forumupdate) { build_forum_counters($threadinfo['forumid']); } } // Are we editing someone else's post? If so load that users subscription info for this thread. if ($bbuserinfo['userid'] != $lastpost['userid']) { if ($otherthreadinfo = $DB_site->query_first(" SELECT emailupdate, folderid FROM " . TABLE_PREFIX . "subscribethread WHERE threadid = $threadinfo[threadid] AND userid = $lastpost[userid]")) { $threadinfo['issubscribed'] = true; $threadinfo['emailupdate'] = $otherthreadinfo['emailupdate']; $threadinfo['folderid'] = $otherthreadinfo['folderid']; } } // ### DO THREAD SUBSCRIPTION ### // We use $lastpost[userid] so that we update the user who posted this, not the user who is editing this if (!$threadinfo['issubscribed'] AND $edit['emailupdate'] != 9999) { // user is not subscribed to this thread so insert it $DB_site->query(" REPLACE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid) VALUES ($lastpost[userid], $threadinfo[threadid], $edit[emailupdate], $edit[folderid]) "); } else { // User is subscribed, see if they changed the settings for this thread if ($edit['emailupdate'] == 9999) { // Remove this subscription, user chose 'No Subscription' $DB_site->query(" DELETE FROM " . TABLE_PREFIX . "subscribethread WHERE threadid = $threadinfo[threadid] AND userid = $lastpost[userid]"); } else if ($threadinfo['emailupdate'] != $edit['emailupdate'] OR $threadinfo['folderid'] != $edit['folderid']) { // User changed the settings so update the current record $DB_site->query(" REPLACE INTO " . TABLE_PREFIX . "subscribethread (userid, threadid, emailupdate, folderid) VALUES ($lastpost[userid], $threadinfo[threadid], $edit[emailupdate], $edit[folderid]) "); } } $attachments = $DB_site->query_first(" SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "attachment WHERE posthash = '" . addslashes($posthash) . "' ### AND userid = $bbuserinfo[userid] Sep 19, 2003 Change to allow owner to always own any attachment on their post ### "); $newattachments = $attachments['count']; if ($newattachments) { $DB_site->query(" UPDATE " . TABLE_PREFIX . "attachment SET postid = $postid, posthash = '' WHERE posthash = '" . addslashes($posthash) . "' ### AND userid = $bbuserinfo[userid] Sep 19, 2003 Change to allow owner to always own any attachment on their post ### "); $DB_site->query(" UPDATE " . TABLE_PREFIX . "thread SET attach = attach + $newattachments WHERE threadid = $threadinfo[threadid] "); } delete_post_index($postid); $edit['message'] = $lastpost['pagetext'] . "\n\n[ADDED=$postusername]" .TIMENOW. "[/ADDED]\n" .$edit['message']; $DB_site->query(" UPDATE " . TABLE_PREFIX . "post SET title = '" . addslashes(htmlspecialchars_uni($edit['title'])) . "', pagetext = '" . addslashes($edit['message']) . "', allowsmilie = $edit[allowsmilie], showsignature = $edit[signature], iconid = $edit[iconid], attach = attach + $newattachments WHERE postid = $postid "); $DB_site->query("DELETE FROM " . TABLE_PREFIX . "post_parsed WHERE postid = $postid"); build_post_index($postid , $foruminfo); $url = "showthread.php?$session[sessionurl]p=$postid#post$postid"; eval(print_standard_redirect('redirect_postthanks')); } } // __END__ Hack stuck messages by polo ##################################################### # редактирование 'includes/functions_bbcodeparse.php' ****** Ниже (примерно 203-206 строки) ****** // [HIGHLIGHT] $bbcodes['custom']['find']['[highlight]'] = '#\[highlight\](.*)\[/highlight\]#esiU'; $bbcodes['custom']['replace']['[highlight]'] = "handle_bbcode_parameter('\\1', '" . str_replace("'", "\'", '<span class="highlight">\1</span>') . "')"; $bbcodes['custom']['recurse']['highlight'][0] = array('replace_html' => "<span class=\"highlight\">\\7</span>"); ****** Добавить ****** // [ADDED] $bbcodes['custom']['find']['[added='] = '#\[added=("|"|\'|)([^":]*)\\1\](.*)\[/added\]#esiU'; // $bbcodes['custom']['replace']['[added='] = "handle_bbcode_added('\\2', '\\3')"; $bbcodes['custom']['recurse']['added'][0] = array('handler' => 'handle_bbcode_added'); ****** Выше (примерно 969-971 строки) ****** // ###################### Start hasimages ####################### function contains_bbcode_img_tags($bbcode) ****** Добавить функцию ****** // ###################### Start bbcodehandler_added ####################### function handle_bbcode_added($username, $timestamp) { global $vboptions, $vbphrase, $stylevar, $show; // remove empty codes if (trim($timestamp) == '') { return ''; } // remove unnecessary escaped quotes $username = str_replace('\\"', '"', $username); $date = str_replace('\\"', '"', $date); // remove smilies from username $username = strip_smilies($username); $date = vbdate($vboptions['dateformat'], $timestamp, true); $time = vbdate($vboptions['timeformat'], $timestamp); $html = construct_phrase($vbphrase['user_added_to_post'], $username, $date, $time); return $html; } ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ¤ ¤ ¤ ЭТО ВСЕ! ¤ ¤ Единственное что остается это перевести фразу 'user_added_to_post' на нужные языки. ¤ ¤ ¤ ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ------------------ ©Netadmin 2004
---------- Far Far Away У каждого в голове свои тараканы... |
|