Файл: moduls/loads/comm.php
Строк: 32
<?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('Sharhlash: ' . $file['name']);
if ($_POST) {
$comm = html($_POST['comm']);
if (empty($comm)) {
$err = 'Sharh bo`sh';
}
if (!empty($err)) {
echo DIV_ERROR . $err . CLOSE_DIV;
} else {
DB::$dbs->query("INSERT INTO ".LOADS_COMM." (`file_id`, `user_id`, `comm`, `time`) VALUES (?, ?, ?, ?)", array($file['id'], $user['user_id'], $comm, time()));
balls_operation(2);
echo DIV_MSG . 'Sharh kiritildi' . CLOSE_DIV;
}
}
$comm = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LOADS_COMM." WHERE `file_id` = ?", array($file['id']));
if (!empty($_GET['del_comm'])) {
DB::$dbs->query("DELETE FROM ".LOADS_COMM." WHERE `id` = ? ", array(num($_GET['del_comm'])));
header("Location: ".HOME."/moduls/loads/comm.php?folder=".$folder['id']."&folderc=".$folderc['id']."&file=".$file['id']."&".(int)$_GET['p']);
}
if (empty($comm)) {
echo DIV_BLOCK . 'Sharhlar yo`q' . CLOSE_DIV;
} else {
$n = new Navigator($comm,$config['write']['loads_comm'],'folder='.$folder['id'].'&folderc='.$folderc['id'].'&file='.$file['id']);
$sql = DB::$dbs->query("SELECT * FROM ".LOADS_COMM." WHERE `file_id` = ? ORDER BY `id` DESC LIMIT {$n->start()}, ".$config['write']['loads_comm']."", array($file['id']));
while($comm = $sql -> fetch()) {
echo DIV_LI . userLink($comm['user_id']) . ' [' . vrem($comm['time']) . ']' . (privilegy('zc_moder') ? ' <a href="'.HOME.'/moduls/loads/comm.php?folder='.$folder['id'].'&folderc='.$folderc['id'].'&file='.$file['id'].'&del_comm='.$comm['id'].'&p='.(int)$_GET['p'].'">[O`chr.]</a>' : NULL) . CLOSE_DIV;
echo DIV_BLOCK . text($comm['comm']) . CLOSE_DIV;
}
echo $n->navi();
}
echo DIV_AUT;
echo '<form action="#" method="POST">';
echo '<textarea name="comm"></textarea><br />';
echo '<input type="submit" value="Sharh kiritish" /></form>';
echo CLOSE_DIV;
bbsmile();
echo DIV_LI . '<a href="'.HOME.'/loads/'.$folder['id'].'/'.$folderc['id'].'/'.$file['id'].'/">Orqaga qaytish</a>' . CLOSE_DIV;
$array = array('Yuklamalar');
nav($array);
require_once('../../core/stop.php');
?>