Файл: moduls/loads/rating.php
Строк: 29
<?php
/**
* @package Prime Social
* @link http://primesocial.ru
* @copyright Copyright (C) 2016 Prime Social
* @author BoB | http://primesocial.ru/about
*/
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('Bo`lim topilmadi');
echo DIV_ERROR . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/loads/">Yuklamalar</a> / <b>Bo`lim topilmadi</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('Ichki bo`lim topilmadi');
echo DIV_ERROR . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/loads/">Yuklamalar</a> / <b>Ichki bo`lim topilmadi</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('Fayl topilmadi');
echo DIV_ERROR . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/loads/">Yuklamalar</a> / <b>Fayl topilmadi</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
/* **** */
head('Fayl reytingi: ' . $file['name']);
if (DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LOADS_RATING." WHERE `file_id` = ? && `user_id` = ? ", array($file['id'], $user['user_id'])) == TRUE) {
head('Yuklamalar: Siz ovoz bergansiz');
echo DIV_BLOCK . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/loads/">Yuklamalar</a> / <b>Siz ovoz bergansiz</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.'/">Bosh sahifa</a> / <a href="'.HOME.'/loads/">Yuklamalar</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>Fayl reytingi/b>' . CLOSE_DIV;
require_once('../../core/stop.php');
?>