Файл: soc-set/moduls/loads/rating.php
Строк: 25
<?php
require_once('../../core/start.php');
require_once('func.php');
require_once('../../core/class/id.php');
check_auth();
$folder = DB::$dbs->queryFetch("SELECT * FROM ".LOADS." WHERE `id` = ? ", array(abs(num($_GET['folder']))));
if (empty($folder)) {
head('Каталог не найден');
echo DIV_TITLE . 'Каталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/loads/">Загрузки</a> / <b>Каталог не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$folderc = DB::$dbs->queryFetch("SELECT * FROM ".LOADS_CAT." WHERE `id` = ? ", array(abs(num($_GET['folderc']))));
if (empty($folderc)) {
head('Подкаталог не найден');
echo DIV_TITLE . 'Подкаталог не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/loads/">Загрузки</a> / <b>Подкаталог не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$file = DB::$dbs->queryFetch("SELECT * FROM ".LOADS_FILE." WHERE `id` = ? ", array(abs(num($_GET['file']))));
if (empty($file)) {
head('Файл не найден');
echo DIV_TITLE . 'Файл не найден' . CLOSE_DIV;
echo DIV_ERROR . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/loads/">Загрузки</a> / <b>Файл не найден</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
/* **** */
head('Рейтинг файла: ' . $file['name']);
echo DIV_TITLE . 'Рейтинг файла: ' . $file['name'] . CLOSE_DIV;
if (DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LOADS_RATING." WHERE `file_id` = ? && `user_id` = ? ", array($file['id'], $user['user_id'])) == TRUE) {
head('Загрузки: Вы уже голосовали');
echo DIV_TITLE . 'Вы уже голосовали' . CLOSE_DIV;
echo DIV_BLOCK . 'Ошибка!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">На главную</a> / <a href="'.HOME.'/loads/">Загрузки</a> / <b>Вы уже голосовали</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
if ($_GET['type'] == 'plus') {
DB::$dbs->query("INSERT INTO ".LOADS_RATING." (`file_id`, `user_id`, `type`) VALUES (?, ?, ?)", array($file['id'], $user['user_id'], 'plus'));
DB::$dbs->query("UPDATE ".LOADS_FILE." SET `rating` = ? WHERE `id` = ? ", array(($file['rating'] + 1), $file['id']));
} else {
DB::$dbs->query("INSERT INTO ".LOADS_RATING." (`file_id`, `user_id`, `type`) VALUES (?, ?, ?)", array($file['id'], $user['user_id'], 'minus'));
DB::$dbs->query("UPDATE ".LOADS_FILE." SET `rating` = ? WHERE `id` = ? ", array(($file['rating'] - 1), $file['id']));
}
header("Location: ".HOME."/loads/".$folder['id']."/".$folderc['id']."/".$file['id']."/");
echo DIV_GO . '<a href="'.HOME.'/">Главная</a> / <a href="'.HOME.'/loads/">Загрузки</a> / <a href="'.HOME.'/loads/'.$folder['id'].'/">'.$folder['name'].'</a> / <a href="'.HOME.'/loads/'.$folder['id'].'/'.$folderc['id'].'/">'.$folderc['name'].'</a> / <a href="'.HOME.'/loads/'.$folder['id'].'/'.$folderc['id'].'/'.$file['id'].'/">'.$file['name'].'</a> / <b>Рейтинг файла</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
?>