Файл: modules/news/add.php
Строк: 105
<?php
/* DCMS S (Special)
* Версия файла 0.0.1
* Дата последнего редактирования 14.10.2015
* Модифицировал densnet
*/
require_once '../../sys/inc/start.php';
require_once H . 'sys/inc/compress.php';
require_once H . 'sys/inc/sess.php';
require_once H . 'sys/inc/settings.php';
require_once H . 'sys/inc/db_connect.php';
require_once H . 'sys/inc/ipua.php';
require_once H . 'sys/inc/fnc.php';
require_once H . 'sys/inc/user.php';
user::access('adm_news_add', null, 'index.php?' . SID);
$set['title'] = 'Новости';
require_once H . 'sys/inc/thead.php';
if (isset($_POST['title']) && isset($_POST['msg']) && isset($_POST['link'])) {
$title = text::esc($_POST['title'], 1);
$link = text::esc($_POST['link'], 1);
if ($link != NULL && !preg_match('#^https?://#i', $link) && !preg_match('#^/#', $link)) {
$link = '/' . $link;
}
$msg = text::esc($_POST['msg']);
if (text::utf8_strlen($title) > 250) {
$err = 'Заголовок длинее 250-ти символов';
}
if (text::utf8_strlen($title) < 3) {
$err = 'Заголовок короче 3-х символов';
}
$mat = text::antimat($title);
if ($mat) {
$err[] = 'В заголовке обнаружен мат: ' . $mat;
}
if (text::utf8_strlen($msg) > 10024) {
$err = 'Содержание длинее 10024-х символов';
}
if (text::utf8_strlen($msg) < 5) {
$err = 'Содержание короче 5-ти символов';
}
$mat = text::antimat($msg);
if ($mat) {
$err[] = 'В содержании обнаружен мат: ' . $mat;
}
$mat = mysql_real_escape_string($msg);
if (!isset($err)) {
$ch = intval($_POST['ch']);
$mn = intval($_POST['mn']);
$main_time = time() + $ch * $mn * 60 * 60 * 24;
if ($main_time <= time()) {
$main_time = 0;
}
mysql_query("INSERT INTO `news` (`time`, `msg`, `title`, `main_time`, `link`, `avtor`) values('$time', '" . mysql_real_escape_string($msg) . "', '$title', '$main_time', '$link', '$user[nick]')");
mysql_query("OPTIMIZE TABLE `news`");
if (isset($_POST['mail'])) {
$q = mysql_query("SELECT `ank_mail` FROM `user` WHERE `set_news_to_mail` = '1' AND `ank_mail` <> ''");
while ($ank = mysql_fetch_assoc($q)) {
mysql_query("INSERT INTO `mail_to_send` (`mail`, `them`, `msg`) values('$ank[ank_mail]', 'Новости', '" . text::toOutput($msg) . "')");
}
}
msg('Новость успешно добавлена');
header("Location: index.php");
exit;
}
}
err();
echo "<form class = 'comm' name = 'add' method = 'POST' action = 'add.php'><center>";
echo "<b>Заголовок новости</b><br />";
echo "<input name = 'title' size = '16' maxlength = '250' value = '' type = 'text' /><br/>";
echo '<b>Ссылка | Подробности</b><br/>';
echo "<input name = 'link' size = '16' maxlength = '64' value = '' type = 'text' /><br/>";
echo "<b>Содержание новости</b><br />";
echo text::auto_bb("add", "msg");
echo "<textarea name = 'msg'></textarea><br/>";
echo "<label><input name = 'mail' value = '1' type = 'checkbox' checked = 'checked' /> Рассылка на email (" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `set_news_to_mail` = '1' AND `ank_mail` <> ''"), 0) . ")</label><br/>";
echo '<b>Показывать на главной</b><br/>';
echo "<input type = 'text' name = 'ch' size = '1' value = '1' />";
echo "<select name = 'mn'>n";
echo "<option value = '0' selected = 'selected'>Не показывать</option>";
echo "<option value = '1'>Дней</option>";
echo "<option value = '7'>Недель</option>";
echo "<option value = '31'>Месяцев</option>";
echo "</select><br/>";
echo "<button class = 'flat blue' name = 'ok'>Опубликовать</button>";
echo "</center></form>";
echo "<div class = 'comm'><a href = '/modules/news/'><img src = '/style/icons/lext.png' /> Новости</a></div>";
require_once H . 'sys/inc/tfoot.php';