<?php
include_once "../config.php";
include_once "../inc/inc.php";
include_once "../inc/func.php";
include_once "../inc/user.php";
include_once "../inc/gzip.php";
include_once "../inc/online.php";
include_once "../themes/$theme/index.php";
include_once"../inc/pclzip.php";
echo '<center>Просмотр архива</center><hr>';
if (!$action) {
$d = str_replace("../", "", $d);
$d = str_replace(" ", "", $d);
$d = str_replace("'", "", $d);
$d = str_replace("\"", "", $d);
$d = str_replace("%00", "", $d);
$d = str_replace("|", "/", $d);
$zip = new PclZip($d);
if (($list = $zip->listContent()) == 0) {
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 = ereg_replace("--size:", "", $zfilesize);
$zfilesize = @ereg_replace("$zfilesize", "$zfilesize|", $zfilesize);
$sizelist .= "$zfilesize";
$listcontent = "[$i]--$key:" . $list[$i][$key] . "";
$zfile = strstr($listcontent, "--filename");
$zfile = ereg_replace("--filename:", "", $zfile);
$zfile = @ereg_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 '<b>' . $arch . '</b><br>Всего файлов: ' . $count . '<br>Вес распакованного архива: ' . $obkb . ' кб<hr>';
$vsego = $count;
$pagevsego = $vsego / 10;
$pagevsego = (int)$pagevsego;
$bbb = $vsego - ($pagevsego * 10);
if ($bbb > 0) {
$pagevsego++;
}
$page = (int)$page;
if ($page >= $pagevsego) {
$page = $pagevsego;
}
if ((!isset($page)) || ($page <= 0) || ($page == '')) {
$page = 1;
$start = 0;
} else {
$start = ($page * 10)-10;
}
$end = $start + $indown;
for ($i = $start; $i < $end; $i++) {
// if($path==''){break;}
// $vsego =$count;
// for ($i = 0; $i < $count; $i++){
$sizefiles = explode("|", $sizelist); //вырезаем элементы из массива с размерами файлов
$selectfile = explode("|", $savelist);
$path = $selectfile[$i];
$fname = ereg_replace(".*[\\/]", "", $path);
$zdir = ereg_replace("[\\/]?[^\\/]*$", "", $path);
$path = str_replace("/", "*", $path);
if ($path == '') {
break;
}
echo $zdir . '/';
$d = str_replace('/', '|', $d);
echo '<a href="zip.php?action=preview&d=' . $d . '&open=' . $path . '&page=' . $page . '&' . SID . '">' . $fname . '</a>';
if ($sizefiles[$i] != "0") {
$sizekb = round($sizefiles[$i] / 1024, 2);
echo ' (' . $sizekb . ' кб)';
}
echo'<br>';
}
$d = str_replace('/', '|', $d);
echo '<hr>Страницы:<br>';
if ($page == '1') {
echo'<-Назад';
} else {
$ggg = $page-1;
echo '<a href="zip.php?d=' . $d . '&page=' . $ggg . '"><-Назад</a>';
}
echo ' [' . $page . ' из ' . $pagevsego . '] ';
if (($page == $pagevsego) || ($pagevsego == 0)) {
echo 'Вперёд-><br>';
} else {
$ggg = $page + 1;
echo '<a href="zip.php?d=' . $d . '&page=' . $ggg . '">Вперёд-></a><br>';
}
echo '<form action="zip.php" method="get">';
echo '<input name="d" type="hidden" value="' . $d . '">';
echo '<input name="page" type="text" value=""><input type="submit" value=">>">';
echo '</form>';
echo'<hr>';
}
if ($action == "preview") {
$open = str_replace("*", "/", $open);
$d = str_replace('|', '/', $d);
$zip = new PclZip($d);
$content = $zip->extract(PCLZIP_OPT_BY_NAME, $open, PCLZIP_OPT_EXTRACT_AS_STRING);
$content = $content[0]['content'];
$letters = array("а", "б", "в", "г", "д", "е", "ё", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я", "А", "Б", "В", "Г", "Д", "Е", "Ё", "Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ч", "Ш", "Щ", "Ъ", "Ы", "Ь", "Э", "Ю", "Я");
for ($b = 0; $b < 66; $b++) {
if (strstr($content, $letters[$b]) !== false) {
$utf = "ok";
}
}
$preview2 = explode("\r\n", $content);
$count = count($preview2);
function highlight_code($code)
{
$code = trim($code);
return highlight_string($code, true);
}
echo '<b>Файл: ' . $open . '</b><br>строчек: ' . $count . '<br><hr>';
if ($utf == "ok") {
echo highlight_code($content);
} else {
echo highlight_code(win_to_utf($content));
}
echo'<hr>';
$d = str_replace('/', '|', $d);
echo'<br><a href="zip.php?page=' . $page . '&d=' . $d . '">Назад</a><br>';
}
include_once "../themes/$theme/foot.php";
?>