------------------ SQL -------------------- CREATE TABLE IF NOT EXISTS `bb_post_rate` ( `post_id` INT( 11 ) NOT NULL default '0', `user_id` INT( 11 ) NOT NULL default '0', PRIMARY KEY (`post_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; ALTER TABLE `bb_posts` ADD `rate_post` INT( 11 ) NOT NULL DEFAULT '0'; -------------------------------------------- ------------ init_bb.php ------------ Найти: define('BB_WORDS', 'bb_words'); После добавить: define('BB_POST_RATE', 'bb_post_rate'); -------------------------------------------- --------- ajax.php -------------- Найти: 'user_todey' => array('user'), После добавить: 'rate_post' => array('user'), Перед последней скобкой добавить: function rate_post() { global $userdata; $mode = (string) $this->request['mode']; $pid = (int) $this->request['post_id']; $rate_sum = (int) $this->request['rate_sum']; $user_id = (int) $userdata['user_id']; $rate_user = DB()->fetch_row("SELECT user_id FROM ". BB_POST_RATE ." WHERE post_id = $pid AND user_id = $user_id"); if($mode == 'plus' && $rate_user != $user_id) { $rate_sum = $rate_sum + 1; if($rate_sum > 0) $pl_mn = '+'; elseif($rate_sum > 0) $pl_mn = '-'; else { $pl_mn = ''; } $rate_post = 'rate_post + 1'; } elseif($mode == 'minus' && $rate_user != $user_id) { $rate_sum = $rate_sum - 1; if($rate_sum > 0) $pl_mn = '+'; elseif($rate_sum > 0) $pl_mn = '-'; else { $pl_mn = ''; } $rate_post = 'rate_post - 1'; } else { $this->ajax_die('Вы уже голосовали за этот пост'); } DB()->query("UPDATE ". BB_POSTS ." SET rate_post = $rate_post WHERE post_id = ".$pid); DB()->query("INSERT INTO ". BB_POST_RATE ." SET post_id = ".$pid.", user_id = ".$user_id); $this->response['post_id'] = $pid; $this->response['rate_sum'] = $rate_sum; $this->response['rate_sum_str'] = (string) $pl_mn.$rate_sum; } -------------------------------------------- --------------- viewtopic.php ------------------ Найти: p.*, В эту же строчку добавить: pr.*, Найти: LEFT JOIN ". BB_GROUPS ." g ON(g.group_id = p.poster_rg_id) После добавить: LEFT JOIN ". BB_POST_RATE ." AS pr ON(pr.post_id = p.post_id AND pr.user_id = ". $userdata['user_id'] .") Найти: $newest = $next_topic_id = 0; $start = isset($_GET['start']) ? abs(intval($_GET['start'])) : 0; Выше добавить: $pl_mn = ($postrow[$i]['rate_post'] > 0) ? '+' : ($postrow[$i]['rate_post'] < 0) ?'-' : ''; Найти: 'RG_SIG' => $rg_signature, 'RG_SIG_ATTACH' => $postrow[$i]['attach_rg_sig'], Ниже добавить: 'POST_RATE' => ($postrow[$i]['rate_post']) ? $pl_mn.$postrow[$i]['rate_post'] : 0, -------------------------------------------- --------------- viewtopic.tpl ------------------ Найти: Ниже добавить: Найти: {MOD_POST_IMG}{POST_BTN_SPACER}
Ниже добавить: