Файл: html/admin/new.php
Строк: 35
<?php
require_once '../system/func.php';
require_once '../system/header.php';
if (!$user OR $user['access'] < 3) {
?><script>showContent("/");</script><?php
exit;
}
//сброс флага и счетчика
if($user['news'] == 1){
$mc->query("UPDATE `users` SET `news_all` = '0' WHERE `id` = '".$user['id']."'");
}
?>
<center><div style="width:50">Заголовок</div><input type="text" class="input_real chat_input title" name="title" ><br>
<div style="width:50">Текст</div><input type="text" class="input_real chat_input txt" name="text" ><br>
<button class="button_alt_01" onclick="go()">Создать</button></center>
<script>
var scor = 0;
function go(){
var text = $(".text").val();
if(scor == 0){
scor = 1;
showContent('/admin/new.php?create&title=' + $(".title").val() + '&text=' + $(".txt").val());
}
}
</script>
<?php
if(isset($_GET['create']) && isset($_GET['title']) && isset($_GET['text'])){
if($mc->query("INSERT INTO `news`("
. "`id`,"
. " `title`,"
. " `text`,"
. " `date`"
. ")VALUES("
. "NULL,"
. "'" . $_GET['title'] . "',"
. "'" . $_GET['text'] . "',"
. "'" . date("d.m.20y") . "'"
. ")")){
message("Новость создана");
$mc->query("UPDATE `users` SET `news` = '1',`news_all`=`news_all`+1 ");
}
}
$footval = 'adminindex';
include '../system/foot/foot.php';
?>