Файл: moduls/files/comm.php
Строк: 46
<?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();
$id = abs(num($_GET['user']));
$ank = DB::$dbs->queryFetch("SELECT * FROM ".USERS." WHERE `user_id` = ? ", array($id));
if (empty($ank)) {
head('Foydalanuvchi topilmadi');
echo DIV_TITLE . 'Foydalanuvchi topilmadi' . CLOSE_DIV;
echo DIV_BLOCK . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <b>Foydalanuvchi topilmadi</b>' . CLOSE_DIV;
exit();
}
$folder = DB::$dbs->queryFetch("SELECT * FROM ".FILES." WHERE `id` = ? ", array(abs(num($_GET['folder']))));
if (empty($folder)) {
head('Bo`lim topilmadi');
echo DIV_TITLE . 'Bo`lim topilmadi' . CLOSE_DIV;
echo DIV_ERROR . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <b>Bo`lim topilmadi</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
$file = DB::$dbs->queryFetch("SELECT * FROM ".FILES_FILE." WHERE `id` = ? ", array(abs(num($_GET['file']))));
if (empty($file)) {
head('Fayl topilmadi');
echo DIV_TITLE . 'Fayl topilmadi' . CLOSE_DIV;
echo DIV_ERROR . 'Xatolik!' . CLOSE_DIV;
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <b>Fayl topilmadi</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
exit();
}
/* **** */
head('Faylga sharhlar: ' . $file['name']);
if ($_POST) {
$comm = html($_POST['comm']);
if (empty($comm)) {
$err = 'Bo`sh sharh';
}
if (!empty($err)) {
echo DIV_ERROR . $err . CLOSE_DIV;
} else {
DB::$dbs->query("INSERT INTO ".FILES_COMM." (`file_id`, `user_id`, `comm`, `time`) VALUES (?, ?, ?, ?)", array($file['id'], $user['user_id'], $comm, time()));
echo DIV_MSG . 'Sharh joylandi' . CLOSE_DIV;
}
}
$comm = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FILES_COMM." WHERE `file_id` = ?", array($file['id']));
if (!empty($_GET['del_comm'])) {
DB::$dbs->query("DELETE FROM ".FILES_COMM." WHERE `id` = ? ", array(num($_GET['del_comm'])));
header("Location: ".HOME."/moduls/files/comm.php?folder=".$folder['id']."&user=".$ank['user_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']['files_comm'],'folder='.$folder['id'].'&file='.$file['id']);
$sql = DB::$dbs->query("SELECT * FROM ".FILES_COMM." WHERE `file_id` = ? ORDER BY `id` DESC LIMIT {$n->start()}, ".$config['write']['files_comm']."", array($file['id']));
while($comm = $sql -> fetch()) {
echo DIV_LI . userLink($comm['user_id']) . ' [' . vrem($comm['time']) . ']' . ($ank['user_id'] == $user['user_id'] ? ' <a href="'.HOME.'/moduls/files/comm.php?folder='.$folder['id'].'&user='.$ank['user_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 'Sharh yozish:<br /><textarea name="comm"></textarea><br />';
echo '<input type="submit" value="Kiritish" /></form>';
echo CLOSE_DIV;
bbsmile();
echo DIV_GO . '<a href="'.HOME.'/">Bosh sahifa</a> / <a href="'.HOME.'/id'.$ank['user_id'].'">'.$ank['nick'].'</a> / <a href="'.HOME.'/files/'.$ank['user_id'].'/">Shahsiy fayllar</a> / <a href="'.HOME.'/files/'.$ank['user_id'].'/'.$folder['id'].'/">'.$folder['name'].'</a> / <a href="'.HOME.'/files/'.$ank['user_id'].'/'.$folder['id'].'/'.$file['id'].'/">'.$file['name'].'</a> / <b>Faylga sharh</b>' . CLOSE_DIV;
require_once('../../core/stop.php');
?>