Файл: modules/domens/file.php
Строк: 60
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.ru *
**********************************/
$locate = 'in_share';
if(!isset($_GET['id'])) { go('/domens/'); }
$id = abs(intval($_GET['id']));
if($db->query("SELECT * FROM `share_files` WHERE `id` = '". $id ."'")->rowCount() == 0) {
$title = $lang->word('share');
require_once(SYS.'/view/header.php');
$tpl->div('menu', $lang->word('file_not_exists'));
$tpl->div('block', NAV.' <a href="/domens/">'. $lang->word('share') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
exit;
}
$file_a = $db->query("SELECT * FROM `share_files` WHERE `id` = '". $id ."'")->fetch();
$file_ra = $db->query("SELECT * FROM `share_rating` WHERE `file_id` = '". $id ."' ORDER BY rating DESC")->fetch();
$file_ar = $db->query("SELECT * FROM `share_rating` WHERE `file_id` = '". $id ."'")->rowCount();
if(isset($_GET['act']) && $_GET['act'] == 'rate') {
$rates = abs(intval($_POST['rate']));
$rate = ($rates < 1 ? 1 : ($rates > 5 ? 5 : $rates));
$db->query("INSERT INTO `share_rating` SET `rating` = '". ($file_ra['rating']+$rate)."', `rated` = '". ($file_ra['rated']+1) ."', `user_id` = '". $user['id'] ."', `file_id` = '". $id."'");
header('location: /domens/file/'.$file_a['id'].'/');
exit;
}
if(isset($_GET['delete_screen']) && file_exists(ROOT.'/files/preview/'.$file_a['path_name'].'.png') && ($user['id'] == $file_a['user_id'] || $user['level'] >= 4))
{
unlink(ROOT.'/files/preview/'.$file_a['path_name'].'.png');
header('location: /domens/file/'.$file_a['id']);
exit;
}
$title = $file_a['name'] .' | '. $lang->word('share');
require_once(SYS .'/view/header.php');
$tpl->div('title', $file_a['name']);
$file_q = $db->query("SELECT * FROM `share_files` WHERE `id` = '". $id ."'");
while($file = $file_q->fetch()) {
if($file_ra['rating'] != 0) {
$rating = ($file_ra['rating']/$file_ra['rated']);
}
else {
$rating = 0;
}
echo '<div class="menu">
Адрес: <b>'. $file_a['name'] .' </b></br>
Регистратор: <b>'. $file_a['reg'] .' </b></br>
Панель: <b>'. $file_a['panel'] .' </b></br>
Дата регистрации: <b>'. $file_a['data'] .' </b></br>
Оплачен до: <b>'. $file_a['do'] .' </b></br>
Цена: <b>'. $file_a['cena'] .' руб. </b></br>
Описание: <b>'. output($file['text']) .'</b>
</div>
<div class="menu">
Добавил: <a href="/user/'.$file['user_id'].'">'. tnick($file['user_id']) .'</a> ('.rtime($file['time']).')
</div>
<div class="menu">
<a href="/user/'.$file['user_id'].'">Контактные данные продавца</a>
</div>
<div class="post">
'.($user['id'] == $file['user_id'] || $user['level'] == 4 || $user['level'] >=6 ? img('delete.png') .' <a href="/domens/delete_file/?file_id='. $file['id'] .'">'. $lang->word('delete').'</a><br/>
'.img('edit.png').' <a href="/domens/edit_file/'. $file['id'].'/">'. $lang->word('edit') .'</a><br/>' : NULL).'
</div>
</div>
';
}
$tpl->div('block', NAV.'<a href="/domens/folder/'. $file_a['cat_id'] .'/">'. $db->query("SELECT name FROM `share_c` WHERE `id` = '". $file_a['cat_id'] ."'")->fetchColumn() .'</a><br/>' . HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS .'/view/footer.php');
?>