Вход Регистрация
Файл: bloodlands.pw/downloads/zip.php
Строк: 149
<?php

require '../system/sid.php';
require 
'../system/config.php';
include 
'../system/user.php';
include 
'../system/head.php';
include 
'../system/navigator.php';
include 
'pclzip.lib.php';

whorm(0, 'fo');
$onpage = 999999;
$id = my_int($_GET['id']);
$page = my_int($_GET['page']);
$start = my_int($_GET['start']);

$action = (isset($_GET['action']) && $_GET['action'] == 'preview') ? my_check($_GET['action']) : NULL;

$d = mysql_fetch_assoc(mysql_query('SELECT * FROM `fo_files` WHERE `id` = ' . $id));
if (!
file_exists($d['url']))
{
    
err('Файл не найден!');
    include 
'../system/foot.php';
    exit();
}
###############Получаем каталог#############
$filename = pathinfo($d['url']);
$ext = strtolower($filename['extension']);
if (
$ext != 'zip') die('Файл не является ZIP архивом');

$back = mysql_fetch_assoc(mysql_query("SELECT * FROM `fo_files` WHERE `url` = '$dir'"));
###############Заголовок###################
echo '<div class="title">Просмотр архива ' . basename($d['url']) . '</div>';
echo 
'<div class="menu">';
###############Содержимое###################
if (!$action)
{
$zip = new PclZip($d['url']);
if (!
$list = $zip->listContent()) die('Ошибка: '.$zip->errorInfo(true));
for(
$i = 0; $i < sizeof($list); ++$i)
{
for(
reset($list[$i]); $key = key($list[$i]); next($list[$i]))
{
$zfilesize = strstr($listcontent, '--size');
$zfilesize = str_replace('--size:', '', $zfilesize);
$zfilesize = str_replace($zfilesize, $zfilesize . '|', $zfilesize);
$sizelist .= $zfilesize;
$listcontent = "[$i]--$key:" . $list[$i][$key];
$zfile = strstr($listcontent, '--filename');
$zfile = str_replace('--filename:', '', $zfile);
$zfile = str_replace($zfile, $zfile . '|', $zfile);
$savelist .= $zfile;
}
}
$sizefiles2 = explode('|', $sizelist);

$sizelist2 = array_sum($sizefiles2);
$obkb = round($sizelist2 / 1024, 2);
$preview = $savelist;

$preview = explode('|', $preview);

$count = count($preview) - 1;
echo 
'Всего файлов: ' . $count . '<br/>Вес распакованного архива: ' . $obkb . ' kb</div>';
echo 
'<div class="menu">';
if (!isset(
$page)) $page = 1;
$n = 0;
$pages = ceil($count / $onpage);
if (!
$pages) $pages = 1;
if (
$page) $n = ($onpage * $page) - $onpage;
if (
$count == 0) echo 'Пусто...';
$sizefiles = explode('|', $sizelist);
$selectfile = explode('|', $savelist);
//------------------------------------------------------------------------------------------
for ($i = 1; $i <= $onpage; ++$i)
{
if (empty(
$selectfile[$n]))
{
    
$n++;
    continue;
}

$path = $selectfile[$n];
$fname = preg_replace('/.*[/]/', '', $path);

echo 
'<a href="zip.php?action=preview&amp;id='.$id.'&amp;open='.$path.'">' . $fname . '</a>';
if (
$sizefiles[$n] != 0) echo ' [' . round($sizefiles[$n] / 1024, 2) . 'kb]';
echo 
'<br/>';
$n++;
}
//------------------------------------------------------------------------------------------

}

###############Просмотр файла###################
if ($action == 'preview')
{
    
$open = check($_GET['open']);
    if (
strpos($open , '..') !== false or strpos($open , './') !== false)
    {
        
err('В хакэра решил поиграть?');
        include 
'../system/foot.php';
        exit();
    }

$zip = new PclZip($d['url']);
$content = $zip->extract(PCLZIP_OPT_BY_NAME, $open, PCLZIP_OPT_EXTRACT_AS_STRING);
$content = $content[0]['content'];
$preview2 = explode("n", $content);
$count = count($preview2);

echo 
'<b>Файл: ' . $open . '</b><br/>';

$eX = strtolower(strrchr($open, '.'));

$php = array('.php', '.pl', '.js', '.jsp', '.html', '.xhtml', '.xml', '.wml', '.asp', '.aspx');
$txt = array('.txt', '.sql', '.dat', '.css', '.ini', '.function', '.htaccess', '.tpl');
$img = array('.gif', '.jpg', '.jpeg', '.png', '.bmp', '.wbmp', '.ico', '.swf');

if (empty(
$content)) echo 'Файл пуст.<br/>';

        if (isset(
$_GET['img']))
        {
          
$ext = strtolower(substr($open, strrpos($open, '.') + 1));

          
ob_end_clean();
          
ob_clean();

          
header("Content-type: image/$ext");
          
header("Content-Length: " . strlen($content));
          
header('Content-Disposition: inline; filename="' . $open . '"');

          echo 
$content;
          exit();
        }

if (
in_array($eX, $php))
{
    echo  (!empty(
$content) ? 'Строк: ' . $count . '<br/>' : '');
    if (
is_utf($content)) echo highlight($content);
    else echo 
highlight(win_to_utf($content));
}
elseif (
in_array($eX, $txt))
{
    
$content = htmlspecialchars($content);
    echo  (!empty(
$content) ? 'Строк: ' . $count . '<br/>' : '');
    if (
is_utf($content)) echo '<div style="background:#dedede; color:#727272; overflow: auto;"><code>' . wordwrap($content, 75, '<br/>') . '</code></div>';
    else echo 
'<div style="background:#dedede; color:#727272; overflow: auto;"><code>' . win_to_utf(wordwrap($content, 75, '<br/>')) . '</code></div>';
}
elseif (
in_array($eX, $img))
{
    echo 
'<img src="?action=preview&amp;id='.$id.'&amp;open='.$open.'&amp;img" alt=""/><br/>';
}
else
{
    echo 
'Невозможно прочесть файл!<br/>';
}

}
echo 
'</div><div class="menu"><a class="ssyl2" href="info.php?i='.$id.'">К файлу</a></div>';
include 
'../system/foot.php';
?>
Онлайн: 3
Реклама