<?
$message = "";
if(isset($_POST['cfms'])) {
$message = system :: check($_POST['message']);
$msg_str = system :: utf_strlen($message);
if($msg_str >= 3) {
if($msg_str <= 10000) {
$m_db = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `blog` WHERE `id_user` = ? AND `time` > ?;", array($user['id'], (time() - 60)));
if($m_db == 0) {
$time_m = time();
$who_look = (isset($_POST['who_look']) && intval($_POST['who_look']) == 1 ? 1 : 0);
if(DB :: $pdo -> query("INSERT INTO `blog` (`id_user`, `time`, `text`, `who_look`) VALUES (?, ?, ?, ?);", [$user['id'], $time_m, $message, $who_look])) {
$last_id = DB :: $pdo -> lastInsertId();
if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `blog_files` WHERE `id_user` = '".$user['id']."' AND `time` = '0'") > 0)
{
DB :: $pdo -> query("UPDATE `blog_files` SET `time` = '".time()."', `id_blog` = '".$last_id."' WHERE `id_user` = '".$user['id']."' AND `time` = '0'");
}
system :: redirect("Запись успешно создана.", $thisLink."?note={$last_id}");
} else {
$errMsg = "Неизвестная ошибка. Запись не создана.";
}
} else { $errMsg = "Запись можно писать раз в 10 секунд."; }
} else { $errMsg = "Сообщение превышает 10000 знаков."; }
} else { $errMsg = "Пустое сообщение."; }
}
system :: show($errMsg);