Файл: public_html/modules/downloads/file.php
Строк: 319
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.net *
* ------------------------------- *
* @package: PerfCMS Ultra *
* @year: 2013 *
* @author: wanya26ua & Tesla *
* @link: http://perfclub.ru *
**********************************/
$locate = 'in_downloads';
$file_id = abs(intval($_GET['id']));
if($db->query("SELECT * FROM `downloads_files` WHERE `id` = '". $file_id ."'")->rowCount() == 0)
{
header('location: /downloads/');
exit;
}
$file = $db->query("SELECT * FROM `downloads_files` WHERE `id` = '". $file_id ."'")->fetch();
$file_ra = $db->query("SELECT * FROM `downloads_rating` WHERE `file_id` = '". $file_id ."'")->fetch();
if(isset($_GET['act']) && $_GET['act'] == 'rate') {
$rates = abs(intval($_POST['rate']));
$rate = ($rates < 1 ? 1 : ($rates > 5 ? 5 : $rates));
$db->query("INSERT INTO `downloads_rating` SET `rating` = '". ($file_ra['rating']+$rate)."', `rated` = '". ($file_ra['rated']+1) ."', `user_id` = '". $user['id'] ."', `file_id` = '". $file_id."'");
header('location: /downloads/file/'.$file['id']);
exit;
}
$root_dir = $db->query("SELECT server_path FROM `downloads` WHERE `id` = '". abs(intval($file['ref_id'])) ."'")->fetchColumn();
$title = $file['name'].' | '.$lang->word('downloads');
require_once(SYS.'/view/header.php');
$tpl->div('title', $file['name']);
echo '<div class="post">';
if(preg_match('/png|jpg|gif|jpeg/i', $file['ext']))
{
if(file_exists(ROOT.'/cache/downloads_images/cache_'.$file['server_name']).'.png')
{
echo '<img src="/cache/downloads_images/cache_'.$file['server_name'].'.png" alt="Screen" /><br/>';
}
else
{
echo '<img src="/files/downloads/'.$root_dir.'/'.$file['server_dir'].'/'.$file['server_name'].'" alt="Image" weight="200" width="250"/><br/>';
}
$dl_image_info = getimagesize(ROOT.'/files/downloads/'.$root_dir.'/'.$file['server_dir'].'/'.$file['server_name']);
$type = $dl_image_info['mime'];
$width = $dl_image_info[0];
$height = $dl_image_info[1];
echo '<b>'.$lang->word('dl_image_size').'</b>: '.$width.'x'.$height.'<br/>';
}
elseif(preg_match('/mp3/i', $file['ext']))
{
import_lib('audio.class');
$mp3Info = new AudioFile;
$mp3Info->loadFile(ROOT.'/files/downloads/'.$root_dir.'/'.$file['server_dir'].'/'.$file['server_name']);
$mp3Info->printSampleInfo();
}
elseif(!preg_match('/png|jpg|gif|jpeg|mp3|avi|3gp|mp4/i', $file['ext']))
{
if (file_exists(ROOT.'/files/downloads_screens/screen_1_'.$file['server_name'].'.png') && !isset($_GET['screen'])) {
echo '<a href="/files/downloads_screens/screen_1_'.$file['server_name'].'.png"><img src="/files/downloads_screens/screen_1_'.$file['server_name'].'.png" alt="Screen" /></a><br />[1]'
. (file_exists(ROOT.'/files/downloads_screens/screen_2_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=2">2</a>' : NULL)
. (file_exists(ROOT.'/files/downloads_screens/screen_3_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=3">3</a>' : NULL)
. (file_exists(ROOT.'/files/downloads_screens/screen_4_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=4">4</a>' : NULL)
. (file_exists(ROOT.'/files/downloads_screens/screen_5_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=5">5</a><br />' : NULL);
}
elseif (isset($_GET['screen']) && $_GET['screen'] == 2 && file_exists(ROOT.'/files/downloads_screens/screen_2_'.$file['server_name'].'.png')) {
echo '<a href="/files/downloads_screens/screen_2_'.$file['server_name'].'.png"><img src="/files/downloads_screens/screen_2_'.$file['server_name'].'.png" alt="" /></a><br />
<a href="/downloads/file/'. $file['id'] .'">1</a><br/>, [2]'
. (file_exists(ROOT.'/files/downloads_screens/screen_3_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=3">3</a>' : NULL)
. (file_exists(ROOT.'/files/downloads_screens/screen_4_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=4">4</a>' : NULL)
. (file_exists(ROOT.'/files/downloads_screens/screen_5_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=5">5</a><br />' : NULL);
}
elseif (isset($_GET['screen']) && $_GET['screen'] == 3 && (file_exists(ROOT.'/files/downloads_screens/screen_3_'.$file['server_name'].'.png'))) {
echo '<a href="/files/downloads_screens/screen_3_'.$file['server_name'].'.png"><img src="/files/downloads_screens/screen_3_'.$file['server_name'].'.png" alt="" /></a><br />
<a href="/downloads/file/'. $file['id'] .'">1</a>, <a href="/downloads/file/'. $file['id'] .'?screen=2">2</a>, [3]'
. (file_exists(ROOT.'/files/downloads_screens/screen_4_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=4">4</a>' : NULL)
. (file_exists(ROOT.'/files/downloads_screens/screen_5_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=5">5</a><br />' : NULL);
}
elseif (isset($_GET['screen']) && $_GET['screen'] == 4 && (file_exists(ROOT.'/files/downloads_screens/screen_4_'.$file['server_name'].'.png'))) {
echo '<a href="/files/downloads_screens/screen_4_'.$file['server_name'].'.png"><img src="/files/downloads_screens/screen_4_'.$file['server_name'].'.png" alt="" /></a><br />
<a href="/downloads/file/'. $file['id'] .'">1</a>, <a href="/downloads/file/'. $file['id'] .'?screen=2">2</a>, <a href="/downloads/file/'. $file['id'] .'?screen=3">3</a> [4]'
. (file_exists(ROOT.'/files/downloads_screens/screen_5_'.$file['server_name'].'.png') ? ', <a href="/downloads/file/'. $file['id'] .'?screen=5">5</a><br />' : NULL);
}
elseif (isset($_GET['screen']) && $_GET['screen'] == 5 && (file_exists(ROOT.'/files/downloads_screens/screen_5_'.$file['server_name'].'.png'))) {
echo '<a href="/files/downloads_screens/screen_5_'.$file['server_name'].'.png"><img src="/files/downloads_screens/screen_5_'.$file['server_name'].'.png" alt="" /></a><br />
<a href="/downloads/file/'. $file['id'] .'">1</a>, <a href="/downloads/file/'. $file['id'] .'?screen=2">2</a>, <a href="/downloads/file/'. $file['id'] .'?screen=3">3</a>, <a href="/downloads/file/'. $file['id'] .'?screen=4">4</a> [5]<br />';
}
}
if($file_ra['rating'] != 0) {
$rating = ($file_ra['rating']/$file_ra['rated']);
}
else {
$rating = 0;
}
echo '<br/><b>'.$lang->word('dl_description').'</b>:
'.output($file['description']).'<br/>
<b>'.$lang->word('rating').': </b>'. round($rating, 1) .'<br/>
'.(isset($user) && $db->query("SELECT * FROM `downloads_rating` WHERE `user_id` = '". $user['id'] ."' AND `file_id` = '". $file['id'] ."'")->rowCount() == 0 ?
'<form action="/downloads/file/'.$file['id'].'/?act=rate" method="post">
<select name="rate">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<input type="submit" value="'.$lang->word('vote').'" />
</form>' : NULL).'
</div>';
echo '<div class="post">
'.img('globe.png').' <b>'.$lang->word('dl_file_user').'</b>: '.rtime($file['time']).' (<a href="/user/'.$file['user_id'].'">'.tnick($file['user_id']).'</a>)<br/>
'.img('info.png').' <b>'.$lang->word('dl_file_downloaded').'</b>: '.$file['dl_times'].'<br/>
'.dlext($file['ext']).' <a href="/downloads/get_file/'.$file['id'].'">'.(preg_match('/jar|sis|apk|exe|zip|ipa|sisx/i', $file['ext']) ? $file['name'] : $lang->word('dl_download_file')).' ('.strtoupper($file['ext']).')</a> ['.size($file['size']).'] '.($file['ext'] == 'jar' ? '[<a href="/downloads/jad/'.$file['id'].'">jad</a>]' : NULL).'<br/>';
if($db->query("SELECT * FROM `downloads_archive` WHERE `file_id` = '". $file['id'] ."'")->rowCount() != 0)
{
$farch_q = $db->query("SELECT * FROM `downloads_archive` WHERE `file_id` = '". $file['id'] ."'");
while($farch = $farch_q->fetch())
{
echo dlext($farch['ext']).' <a href="/downloads/get_file/attachment/'.$farch['id'].'">'.$farch['name'].' ('.strtoupper($farch['ext']).')</a> ('.size($farch['size']).') [<a href="/downloads/delete_attachment/'.$farch['id'].'">x</a>] '.($farch['ext'] == 'jar' ? '[<a href="/downloads/jad/attachment/'.$farch['id'].'">jad</a>]' : NULL).'<br/>';
}
}
echo '</div>';
echo '
'.($user['level'] >= 4 ? '<div class="menu">'.
img('edit.png') .' <a href="/downloads/file_edit/'.$file['id'].'">'. $lang->word('dl_edit_file') .'</a><br/>'.
img('delete.png') .' <a href="/downloads/delete_file/'.$file['id'].'">'. $lang->word('dl_delete_file') .'</a><br/>'.
(!preg_match('/png|jpg|gif|jpeg|mp3|avi|3gp|mp4/i', $file['ext']) ? img('plus.png') .' <a href="/downloads/attach_files/'.$file['id'].'">'. $lang->word('dl_attach_files') .'</a><br/>'.
img('image.png') .' <a href="/downloads/attach_screen/'.$file['id'].'">'. $lang->word('dl_attach_screenshot') .'</a><br/>' : NULL).'</div>' : NULL);
$tpl->div('block', img('nav.png').' <a href="/downloads/'.$file['id'].'/comments?">'.$lang->word('comments').'</a> ('.$db->query("SELECT * FROM `downloads_comms` WHERE `downloads_id` = '". $file['id'] ."'")->rowCount().')<br/>' .($file['ref_id'] != 0 ? img('folder.png') .' <a href="/downloads/dir/'. $file['ref_id'].'">'.$db->query("SELECT name FROM `downloads` WHERE `id` = '". abs(intval($file['ref_id'])) ."'")->fetchColumn().'</a><br/>' : img('folder.png') . ' <a href="/downloads/">'. $lang->word('back') .'</a><br/>').' '
. img('download.png') . ' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
. HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
?>