Файл: modules/share/file.php
Строк: 116
<?php
if(isset($user)) {
$locate = 'in_share';
if(!isset($_GET['id'])) { go('/share/'); }
$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('title', $lang->word('share'));
$tpl->div('menu', $lang->word('file_not_exists'));
$tpl->div('block', img('share.png').' <a href="/share/">'. $lang->word('share') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
exit;
}
$file = $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_plus = $db->query("SELECT * FROM `share_rating` WHERE `file_id` = '". $id ."' AND `type` = 'plus'")->rowCount();
$file_minus = $db->query("SELECT * FROM `share_rating` WHERE `file_id` = '". $id ."' AND `type` = 'minus'")->rowCount();
if(isset($_GET['plus']) && isset($user) && $db->query("SELECT * FROM `share_rating` WHERE `file_id` = '". $id ."' AND `user_id` = '". $user['id'] ."' ")->rowCount() == 0) {
$db->query("INSERT INTO `share_rating` SET `rating` = '1', `type` = 'plus', `user_id` = '". $user['id'] ."', `file_id` = '". $id."'");
header('location: /share/file/'.$file['id'].'/');
exit;
}
if(isset($_GET['minus']) && isset($user) && $db->query("SELECT * FROM `share_rating` WHERE `file_id` = '". $id ."' AND `user_id` = '". $user['id'] ."' ")->rowCount() == 0) {
$db->query("INSERT INTO `share_rating` SET `rating` = '1', `type` = 'minus', `user_id` = '". $user['id'] ."', `file_id` = '". $id."'");
header('location: /share/file/'.$file['id'].'/');
exit;
}
if(isset($_GET['delete_screen']) && file_exists(ROOT.'/files/preview/'.$file['path_name'].'.png') && ($user['id'] == $file['user_id'] || $user['level'] >= 4))
{
unlink(ROOT.'/files/preview/'.$file['path_name'].'.png');
header('location: /share/file/'.$file['id']);
exit;
}
$title = $file['name'] .' | '. $lang->word('share');
require_once(SYS .'/view/header.php');
$tpl->div('title', $file['name']);
echo '<div class="menu">
'.(preg_match('/jpeg|jpg|gif|png|bmp/i', $file['ext']) ? '<img style="border: 1px solid #000;" weight="80" height="60" src="/files/share/'. $file['path_name'] .'" alt="Screen" /><br/>'."n" : (file_exists(ROOT.'/files/preview/'.$file['path_name'].'.png') ? '<a href="/files/preview/'.$file['path_name'].'.png"><img style="border: 1px solid #000;" weight="100" height="80" src="/files/preview/'.$file['path_name'].'.png" alt="Screen" /></a><br/>'."n" : NULL)) .' </div><div class="menu"><b>Описание</b>:
'. output($file['text']) .'<br/>
<b>Добавил</b>: <a href="/user/'.$file['user_id'].'">'. tnick($file['user_id']) .'</a> ['.rtime($file['time']).']<br/>
<b>Размер</b>: '.size($file['size']).'<br/>
<b>Импортировать</b>: <br/>
<input type="text" name="imp" value="http://mostop.net/files/share/'. $file['path_name'] .'" />
</div>
<div class="post">
<b>Рейтинг</b>: (<font color="green">'. $file_plus .'</font>/<font color="red">'. $file_minus .'</font>)
'.($db->query("SELECT * FROM `share_rating` WHERE `user_id` = '". $user['id'] ."' AND `file_id` = '". $file['id'] ."'")->rowCount() == 0 ?
'<a href="/share/file/'.$file['id'].'/?plus">[<font color="green">+1</a></font> | <a href="/share/file/'.$file['id'].'/?minus"><font color="red">-1</a></font>]' : NULL).'
</div>
<div class="title">Навигация</div>
<div class="post">'.img('download.png').' <a href="/share/download/'. $file['id'] .'/">'. $lang->word('download') .'</a> ['.$file['dload_times'].'] <br/>
'.($user['id'] == $file['user_id'] || $user['level'] == 4 || $user['level'] >=6 ? img('delete.png') .' <a href="/share/delete_file/?file_id='. $file['id'] .'">'. $lang->word('delete').'</a><br/>
'.img('edit.png').' <a href="/share/edit_file/'. $file['id'].'/">'. $lang->word('edit') .'</a><br/>' : NULL).'
'.($user['id'] == $file['user_id'] || $user['level'] == 4 || $user['level'] >=6 ? (file_exists(ROOT.'/files/preview/'.$file['path_name'].'.png') ? img('image.png').' <a href="/share/file/'.$file['id'].'?delete_screen">'. $lang->word('screenshot_delete').'</a><br/>' : img('image.png').' <a href="/share/add_screen?file_id='.$file['id'].'">'. $lang->word('screenshot_add').'</a><br/>') : NULL) .'
</div>
';
$tpl->div('block', img('reply_11.png') .' <a href="/share/'. $file['id'] .'/comments/">'. $lang->word('comments') .'</a> ['. $db->query("SELECT * FROM `share_comms` WHERE `share_id` = '". $file['id'] ."'")->rowCount().']<br/>' . img('folder.png').'<a href="/share/folder/'. $file['cat_id'] .'/">'. $db->query("SELECT name FROM `share_c` WHERE `id` = '". $file['cat_id'] ."'")->fetchColumn() .'</a><br/>' . img('share.png') .'<a href="/share/">'. $lang->word('share') .'</a><br/>' . HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS .'/view/footer.php');
} else {
$title = 'Загруз-центр';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Загруз-центр');
$tpl->div('menu', '<center>Загруз-центр доступен только зарегистрированным пользователям!</center>');
$tpl->div('block',HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
}
?>