<?php
#-----------------------------------------------------#
# ============ЗАГРУЗ-ЦЕНТР============= #
# Автор : Sea #
# E-mail : [email protected] #
# ICQ : 355152215 #
# Вы не имеете права распространять данный скрипт. #
# По всем вопросам пишите в ICQ. #
#-----------------------------------------------------#
include 'moduls/ini.php';
include 'moduls/head.php';
include "moduls/connect.php";
include "moduls/fun.php";
include "moduls/win.php";
include 'moduls/pclzip.lib.php';
include 'moduls/header.php';
###############Если zip выключен##########
if($setup['zip_change']==0) die("Not found");
###############Проверка переменных###############
$onpage = get2ses('onpage');
is_num($id,'id');
is_num($page,'page');
if(!isset($start)) $start = 0;
if(!isset($onpage) or $onpage <= 0 ) $onpage = $setting['onpage'];
$d = mysql_fetch_array(mysql_query("SELECT * FROM `files` WHERE `id` = '".$id."'"));
if(!file_exists($d['path'])) die("Такой файл не существует");
###############Получаем каталог#############
$filename = pathinfo($d['path']);
$ext = $filename['extension'];
if($ext!='zip') die('Файл не является архивом zip');
$dir = $filename['dirname']."/";
$back = mysql_fetch_array(mysql_query("SELECT * FROM `files` WHERE `path` = '".$dir."'"));
###############Заголовок###################
echo"<div class=\"mblock\"><img src='dis/in.png' alt=''><b>Просмотр архива ".basename($d['path'])."</b></div><div class=\"iblock\">";
###############Содержимое###################
if (!$action)
{
$zip=new PclZip($d['path']);
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 "Всего файлов: $count<br>Вес распакованного архива: $obkb кб</div><div class=\"row\">";
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 = ereg_replace(".*[\\/]","",$path);
$zdir = ereg_replace("[\\/]?[^\\/]*$","",$path);
echo "".$zdir.'/<a href="'.$PHP_SELF.'?action=preview&id='.$id.'&open='.$path.'">'.$fname.'</a>';
if($sizefiles[$n]!="0") echo " [".round($sizefiles[$n]/1024,2)."кб]";
echo'<br>';
$n++;
}
//------------------------------------------------------------------------------------------
echo "</div><div class=iblock>Страницы: ";
$asd= $page - 2;
$asd2= $page + 3;
if($asd<$count && $asd>0 && $page>3) echo "<a href=\"zip.php?id=$id&page=1\">1</a> ... ";
for($i=$asd; $i<$asd2;$i++)
{
if($i<$count && $i>0)
{
if ($i > $pages ) break;
if ($page==$i) echo "<b>[$i]</b> ";
else echo "<a href=\"zip.php?id=$id&page=$i\">$i</a> ";
}
}
if ($i <= $pages)
{
if($asd2<$count) echo " ... <a href=\"zip.php?id=$id&page=$pages\">$pages</a>";
}
echo "<br/>";
}
###############Просмотр файла###################
if($action=="preview")
{
if(strpos($open , "..") !== false or strpos($open , "./") !== false) die($hackmess);
$open = clean(del($open));
$zip = new PclZip($d['path']);
$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</div><div class='row'>";
if($utf=="ok") echo highlight_code($content); else echo highlight_code(win_to_utf($content));
echo'</div><div class=iblock>';
}
echo "
- <a href='view.php?id=$id'>Описание</a><br>
- <a href='index.php?id=$back[id]'>В категорию</a><br>
- <a href=\"index.php\">Загрузки</a><br/>
- <a href=\"$setup[site_url]\">На главную</a></div>";
include 'moduls/foot.php';
?>