redirect("index.php"); } break; ############################################################################################ ## Добавление сообщения ## ############################################################################################ ############################################################################################ ## Добавление сообщения ## ############################################################################################ case 'add': $uid = !empty($_GET['uid']) ? check($_GET['uid']) : 0; $msg = isset($_POST['msg']) ? check($_POST['msg']) : ''; if (is_user()) { $topics = DB::run()->queryFetch("SELECT `topics`.*, `forums`.`forums_parent` FROM `topics` LEFT JOIN `forums` ON `topics`.`topics_forums_id`=`forums`.`forums_id` WHERE `topics`.`topics_id`=? LIMIT 1;", array($tid)); $validation = new Validation(); $validation->addRule('equal', array($uid, $_SESSION['token']), 'Неверный идентификатор сессии, повторите действие!')->addRule('not_empty', $topics, 'Выбранная вами тема не существует, возможно она была удалена!')->addRule('empty', $topics['topics_closed'], 'Запрещено писать в закрытую тему!')->addRule('equal', array(is_quarantine($log), true), 'Карантин! Вы не можете писать в течении ' . round($config['karantin'] / 3600) . ' часов!')->addRule('equal', array(is_flood($log), true), 'Антифлуд! Разрешается отправлять сообщения раз в ' . flood_period() . ' сек!')->addRule('string', $msg, 'Слишком длинное или короткое сообщение!', true, 5, $config['forumtextlength']); // Проверка сообщения на схожесть $post = DB::run()->queryFetch("SELECT * FROM `posts` WHERE `posts_topics_id`=? ORDER BY `posts_id` DESC LIMIT 1;", array($tid)); $validation->addRule('not_equal', array($msg, $post['posts_text']), 'Ваше сообщение повторяет предыдущий пост!'); if ($validation->run()) { $msg = antimat($msg); if ($log == $post['posts_user'] && $post['posts_time'] + 600 > SITETIME && utf_strlen($msg) + utf_strlen($post['posts_text']) <= $config['forumtextlength']) { $newpost = $post['posts_text'] . "\n\n" . '[i][size=1]Добавлено через ' . maketime(SITETIME - $post['posts_time']) . ' сек.[/size][/i]' . "\n" . $msg; DB::run()->query("UPDATE `posts` SET `posts_text`=? WHERE `posts_id`=? LIMIT 1;", array($newpost, $post['posts_id'])); $lastid = $post['posts_id']; } else { DB::run()->query("INSERT INTO `posts` (`posts_topics_id`, `posts_forums_id`, `posts_user`, `posts_text`, `posts_time`, `posts_ip`, `posts_brow`) VALUES (?, ?, ?, ?, ?, ?, ?);", array($tid, $topics['topics_forums_id'], $log, $msg, SITETIME, $ip, $brow)); $lastid = DB::run()->lastInsertId(); DB::run()->query("UPDATE `users` SET `users_allforum`=`users_allforum`+1, `users_point`=`users_point`+1, `users_money`=`users_money`+5 WHERE `users_login`=? LIMIT 1;", array($log)); DB::run()->query("UPDATE `topics` SET `topics_posts`=`topics_posts`+1, `topics_last_user`=?, `topics_last_time`=? WHERE `topics_id`=?;", array($log, SITETIME, $tid)); DB::run()->query("UPDATE `forums` SET `forums_posts`=`forums_posts`+1, `forums_last_id`=?, `forums_last_themes`=?, `forums_last_user`=?, `forums_last_time`=? WHERE `forums_id`=?;", array($tid, $topics['topics_title'], $log, SITETIME, $topics['topics_forums_id']));
############################################################################################ ## Добавление сообщения ## ############################################################################################ ############################################################################################ ## Добавление сообщения ## ############################################################################################ case 'add': $uid = check($_GET['uid']); $msg = check($_POST['msg']); if (is_user()) { if ($uz == $log || is_admin() || is_contact($uz, $log)) { if ($uid == $_SESSION['token']) { if (utf_strlen($msg) >= 5 && utf_strlen($msg) < 1000) { $ignorstr = DB::run()->querySingle("SELECT `ignore_id` FROM `ignore` WHERE `ignore_user`=? AND `ignore_name`=? LIMIT 1;", array($uz, $log)); if (empty($ignorstr)) { if (is_quarantine($log)) { if (is_flood($log)) { $msg = antimat($msg); if ($uz != $log) { DB::run()->query("UPDATE `users` SET `users_newwall`=`users_newwall`+1 WHERE `users_login`=?", array($uz)); } DB::run()->query("INSERT INTO `wall` (`wall_user`, `wall_login`, `wall_text`, `wall_time`) VALUES (?, ?, ?, ?);", array($uz, $log, $msg, SITETIME)); DB::run()->query("DELETE FROM `wall` WHERE `wall_user`=? AND `wall_time` < (SELECT MIN(`wall_time`) FROM (SELECT `wall_time` FROM `wall` WHERE `wall_user`=? ORDER BY `wall_time` DESC LIMIT " . $config['wallmaxpost'] . ") AS del);", array($uz, $uz)); $_SESSION['note'] = 'Запись успешно добавлена!'; redirect("wall.php?uz={$uz}"); } else { show_error('Антифлуд! Разрешается отправлять сообщения раз в ' . flood_period() . ' секунд!'); } } else { show_error('Карантин! Вы не можете писать в течении ' . round($config['karantin'] / 3600) . ' часов!'); }
$posts = DBM::run()->select('guest', null, $config['bookpost'], $start, array('guest_time' => 'DESC')); render('book/index', array('posts' => $posts, 'start' => $start, 'total' => $total)); break; /** * Добавление сообщения */ /** * Добавление сообщения */ case 'add': $msg = check($_POST['msg']); $uid = check($_GET['uid']); if (is_user()) { if ($uid == $_SESSION['token']) { if (utf_strlen($msg) >= 5 && utf_strlen($msg) < $config['guesttextlength']) { if (is_quarantine($log) || $config['bookadds'] == 1) { if (is_flood($log)) { $msg = antimat($msg); $bookscores = $config['bookscores'] ? 1 : 0; $user = DBM::run()->update('users', array('users_allguest' => array('+', 1), 'users_point' => array('+', $bookscores), 'users_money' => array('+', 5)), array('users_login' => $log)); $guest = DBM::run()->insert('guest', array('guest_user' => $log, 'guest_text' => $msg, 'guest_ip' => $ip, 'guest_brow' => $brow, 'guest_time' => SITETIME)); DBM::run()->execute("DELETE FROM `guest` WHERE `guest_time` < (SELECT MIN(`guest_time`) FROM (SELECT `guest_time` FROM `guest` ORDER BY `guest_time` DESC LIMIT :limit) AS del);", array('limit' => intval($config['maxpostbook']))); notice('Сообщение успешно добавлено!'); redirect("index.php"); } else { show_error('Антифлуд! Разрешается отправлять сообщения раз в ' . flood_period() . ' секунд!'); } } else { show_error('Карантин! Вы не можете писать в течении ' . round($config['karantin'] / 3600) . ' часов!'); } } else {
break; ############################################################################################ ## Cоздание темы ## ############################################################################################ ############################################################################################ ## Cоздание темы ## ############################################################################################ case 'add': $uid = !empty($_GET['uid']) ? check($_GET['uid']) : 0; $fid = isset($_POST['fid']) ? abs(intval($_POST['fid'])) : 0; $title = isset($_POST['title']) ? check($_POST['title']) : ''; $msg = isset($_POST['msg']) ? check($_POST['msg']) : ''; if (is_user()) { $forums = DB::run()->queryFetch("SELECT * FROM `forums` WHERE `forums_id`=? LIMIT 1;", array($fid)); $validation = new Validation(); $validation->addRule('equal', array($uid, $_SESSION['token']), 'Неверный идентификатор сессии, повторите действие!')->addRule('not_empty', $forums, 'Раздела для новой темы не существует!')->addRule('empty', $forums['forums_closed'], 'В данном разделе запрещено создавать темы!')->addRule('equal', array(is_quarantine($log), true), 'Карантин! Вы не можете писать в течении ' . round($config['karantin'] / 3600) . ' часов!')->addRule('equal', array(is_flood($log), true), 'Антифлуд! Разрешается отправлять сообщения раз в ' . flood_period() . ' сек!')->addRule('string', $title, 'Слишком длинный или короткий заголовок темы!', true, 5, 50)->addRule('string', $msg, 'Слишком длинное или короткое сообщение!', true, 5, $config['forumtextlength']); /* Сделать проверку поиска похожей темы */ if ($validation->run()) { $title = antimat($title); $msg = antimat($msg); DB::run()->query("UPDATE `users` SET `users_allforum`=`users_allforum`+1, `users_point`=`users_point`+1, `users_money`=`users_money`+5 WHERE `users_login`=?", array($log)); DB::run()->query("INSERT INTO `topics` (`topics_forums_id`, `topics_title`, `topics_author`, `topics_posts`, `topics_last_user`, `topics_last_time`) VALUES (?, ?, ?, ?, ?, ?);", array($fid, $title, $log, 1, $log, SITETIME)); $lastid = DB::run()->lastInsertId(); DB::run()->query("INSERT INTO `posts` (`posts_topics_id`, `posts_forums_id`, `posts_user`, `posts_text`, `posts_time`, `posts_ip`, `posts_brow`) VALUES (?, ?, ?, ?, ?, ?, ?);", array($lastid, $fid, $log, $msg, SITETIME, $ip, $brow)); DB::run()->query("UPDATE `forums` SET `forums_topics`=`forums_topics`+1, `forums_posts`=`forums_posts`+1, `forums_last_id`=?, `forums_last_themes`=?, `forums_last_user`=?, `forums_last_time`=? WHERE `forums_id`=?", array($lastid, $title, $log, SITETIME, $fid)); // Обновление родительского форума if ($forums['forums_parent'] > 0) { DB::run()->query("UPDATE `forums` SET `forums_last_id`=?, `forums_last_themes`=?, `forums_last_user`=?, `forums_last_time`=? WHERE `forums_id`=?", array($lastid, $title, $log, SITETIME, $forums['forums_parent'])); } notice('Новая тема успешно создана!'); redirect("topic.php?tid={$lastid}");
} echo '<img src="/images/img/back.gif" alt="image" /> <a href="index.php">К новостям</a><br />'; break; ############################################################################################ ## Добавление комментариев ## ############################################################################################ ############################################################################################ ## Добавление комментариев ## ############################################################################################ case 'add': $uid = !empty($_GET['uid']) ? check($_GET['uid']) : 0; $msg = isset($_POST['msg']) ? check($_POST['msg']) : ''; if (is_user()) { $data = DB::run()->queryFetch("SELECT * FROM `news` WHERE `news_id`=? LIMIT 1;", array($id)); $validation = new Validation(); $validation->addRule('equal', array($uid, $_SESSION['token']), 'Неверный идентификатор сессии, повторите действие!')->addRule('equal', array(is_quarantine($log), true), 'Карантин! Вы не можете писать в течении ' . round($config['karantin'] / 3600) . ' часов!')->addRule('equal', array(is_flood($log), true), 'Антифлуд! Разрешается комментировать раз в ' . flood_period() . ' сек!')->addRule('not_empty', $data, 'Выбранной новости не существует, возможно она было удалена!')->addRule('string', $msg, 'Слишком длинный или короткий комментарий!', true, 5, 1000)->addRule('empty', $data['news_closed'], 'Комментирование данной новости запрещено!'); if ($validation->run()) { $msg = antimat($msg); DB::run()->query("INSERT INTO `commnews` (`commnews_news_id`, `commnews_text`, `commnews_author`, `commnews_time`, `commnews_ip`, `commnews_brow`) VALUES (?, ?, ?, ?, ?, ?);", array($id, $msg, $log, SITETIME, $ip, $brow)); DB::run()->query("DELETE FROM `commnews` WHERE `commnews_news_id`=? AND `commnews_time` < (SELECT MIN(`commnews_time`) FROM (SELECT `commnews_time` FROM `commnews` WHERE `commnews_news_id`=? ORDER BY `commnews_time` DESC LIMIT " . $config['maxkommnews'] . ") AS del);", array($id, $id)); DB::run()->query("UPDATE `news` SET `news_comments`=`news_comments`+1 WHERE `news_id`=?;", array($id)); DB::run()->query("UPDATE `users` SET `users_allcomments`=`users_allcomments`+1, `users_point`=`users_point`+1, `users_money`=`users_money`+5 WHERE `users_login`=?", array($log)); notice('Комментарий успешно добавлен!'); if (isset($_GET['read'])) { redirect("index.php?act=read&id={$id}"); } redirect("index.php?act=end&id={$id}"); } else { show_error($validation->getErrors()); } } else {