31 lines
1.0 KiB
PHP
31 lines
1.0 KiB
PHP
|
<?php
|
||
|
|
||
|
ini_set('display_errors', 0);
|
||
|
|
||
|
//Добавление от авторизованного юзера
|
||
|
function add_auth()
|
||
|
{
|
||
|
return \DB::add("INSERT INTO `os` (`txt`, `status`, `t`, `user_id`) VALUES(?, ?, ?, ?)", array($_POST['txt'], 1, time(), $_SESSION['user_id']));
|
||
|
}
|
||
|
|
||
|
function add_no_auth()
|
||
|
{
|
||
|
//Сверяем капчу
|
||
|
if ($_POST['capcha'] != $_SESSION['capcha'] || !$_SESSION['capcha'])
|
||
|
return "err";
|
||
|
else
|
||
|
return \DB::add("INSERT INTO `os` (`txt`, `status`, `t`, `fio`, `email`) VALUES(?, ?, ?, ?, ?)", array($_POST['txt'], 0, time(), $_POST['fio'], $_POST['email']));
|
||
|
}
|
||
|
|
||
|
|
||
|
if ($_POST['ok']) {
|
||
|
$res = ($_SESSION['user_id']) ? add_auth() : add_no_auth();
|
||
|
$smarty->assign('res', $res);
|
||
|
}
|
||
|
|
||
|
$list=\DB::getAll("SELECT * FROM `os` WHERE `status`=1 ORDER BY `id` DESC LIMIT 1000");
|
||
|
for ($i=0; $i<count($list);$i++) if ($list[$i]['user_id'])$list[$i]['fio']=\DB::getValue("SELECT `fio` FROM `users` WHERE `id`=? LIMIT 1", $list[$i]['user_id']);
|
||
|
|
||
|
|
||
|
$smarty->assign('list', $list);
|
||
|
?>
|