Файл: 4mast/profmas.ru/downloads/archives.php
Строк: 76
<?php
require_once('../includes/Headers.php');
require_once('../includes/PDO_func.php');
$f = DB::$dbs->queryFetch('SELECT * FROM `down_files` WHERE `id` = ? LIMIT 1', array((int) $_GET['id']));
$kats = DB::$dbs->queryFetch('SELECT `mod` FROM `down_kats` WHERE `id`= ? LIMIT 1', array($f['id_kats']));
$pods = DB::$dbs->queryFetch('SELECT `id`,`name` FROM `down_pods` WHERE `id`= ? LIMIT 1', array($f['id_pods']));
$ext = substr($f['filename'], strrpos($f['filename'], '.') + 1);
if(!$f or $f['reit']>$us['reit'] or $ext != 'zip' or !$pods or empty($f['dop']) and $kats['mod']!=$us['id'])
{
header('Location: /');
exit;
}
H($f['name'],'<a href="/downloads" style="color:white;">Обменник</a> / <a href="/downloads/pods'.$pods['id'].'" style="color:white;">'.$pods['name'].'</a> / '.$f['name']);
$f_ext = $ext = substr('../files/down/'.$f['filename'], strrpos('../files/down/'.$f['filename'], '.') + 1);
if(!in_array($f_ext, array('zip','rar','7z'))) echo '<div class="error">Файл не является архивом!</div>';
else
{
$text_exts = array(
'htaccess',
'html',
'wml',
'php',
'txt',
'dat',
'sql',
'asp',
'aspx',
'jsp',
'js',
'pl',
'css'
);
$image_exts = array(
'jpg',
'gif',
'png',
'jpeg',
'bmp'
);
$allow_exts = array_merge($text_exts, $image_exts);
$count_files = 0;
$size = 0;
$files = array();
$archive = zip_open('../files/down/'.$f['filename']);
while($file = zip_read($archive))
{
++$count_files;
$size += zip_entry_filesize($file);
$files[] = array(
'name' => zip_entry_name($file),
'size' => zip_entry_filesize($file),
'content' => zip_entry_read($file, zip_entry_filesize($file))
);
}
if(isset($_GET['i']))
{
$i =(int)$_GET['i'];
$ext = substr($files[$i]['name'], strrpos($files[$i]['name'], '.') + 1);
if(!isset($files[$i]) || empty($files[$i]['name']) or !in_array($ext, $allow_exts))
{
header('Location: /downloads/archives.php?id='.$f['id']);
exit;
}
$name = str_replace('/', '', substr($files[$i]['name'], strrpos($files[$i]['name'], '/')));
echo '
<div class="list1">
Файл: '.$name.'<br/>
Размер: '.sizef($files[$i]['size']).'
</div>
<div class="list1">
';
if(in_array($ext, $text_exts)) echo highlight_string($files [$i]['content']);
elseif(in_array($ext, $image_exts)) echo '
<img src="data:image/'.$ext.';base64, '.base64_encode($files[$i]['content']).'" alt=""/>
';
echo '
</div>
<div class="block"><a href="/downloads/archives.php?id='.$f['id'].'">Вернуться</a></div>';
}
else
{
echo '<div class="list1">
Всего файлов: '.$count_files.'<br/>
Размер: '.sizef($size).'
</div>';
$items_per_page = 11;
$pages = ceil($count_files / $items_per_page);
if($page < 1) $page = 1;
if($page > $pages) $page = $pages;
$start = $page * $items_per_page - $items_per_page;
if($count_files != 0)
{
for($i = $start; $i < $start + $items_per_page; ++$i)
{
if(!empty($files[$i]['name']))
{
echo '<div class="block">';
$ext = substr($files[$i]['name'], strrpos($files[$i]['name'], '.') + 1);
if(!in_array($ext, $allow_exts)) echo '<img src="" alt=""/> '.$files[$i]['name'];
else echo '<img src="" alt=""/> <a href="/downloads/archives.php?id='.$f['id'].'&i='.$i.'">'.str_replace('/', '', substr($files[$i]['name'], strrpos($files[$i]['name'], '/'))).'</a>('.sizef($files[$i]['size']).')';
echo '</div>';
}
}
echo '<div class="list1">'.page('/downloads/archives'.$f['id']).'</div>';
if($file_comm>11) page('/downloads/archives');
}
else echo 'Файлов нет!';
echo '<div class="block"><a href="/downloads/file.php?id='.$f['id'].'"> К файлу</a></div>';
}
}
require_once('../includes/Footers.php');
?>