View file forum/zip.php

File size: 7Kb
<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"setforum.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/pclzip.php";

echo '<img src="../images/img/partners.gif" alt=""> <b>Просмотр архива</b><br><br>';

if($config_forum_off=="1"){

if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!=""){

if($config_file_post=="1"){
if($udata[36]>$config_file_usball){

$dir=check($dir);
$arch=check($arch);
$open=check($open);

if($dir!="" && $arch!=""){
if (!$action){

$zip=new PclZip("$dir/$arch");
if (($list = $zip->listContent()) != 0){
     
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 = explode("|",$savelist);

$count = count($preview)-1;
echo '<img src="../images/img/zip.gif" alt=""> <b>'.$arch.'</b><br><br>';
echo 'Всего файлов: '.$count.'<br>Вес распакованного архива: '.$obkb.' кб<hr>';

if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($count < $start + $config_ziplist){ $end = $count; }
else {$end = $start + $config_ziplist; }
for ($i = $start; $i < $end; $i++){
	
$sizefiles = explode("|",$sizelist); //вырезаем элементы из массива с размерами файлов
$selectfile = explode("|",$savelist);
$path = $selectfile[$i];
$fname = ereg_replace(".*[\\/]","",$path);
$zdir = ereg_replace("[\\/]?[^\\/]*$","",$path);
$path = str_replace("/","*",$path);

$ext=strtolower(strrchr($fname, "."));

switch($ext){
case 'dir': $ico='dir.gif'; break;
case '.jpg': case '.jpeg': $ico='jpg.gif'; break;
case '.gif': $ico='gif.gif'; break;
case '.mid': $ico='mid.gif'; break;
case '.mp3': $ico='mp3.gif'; break;
case '.wav': case '.amr': $ico='wav.gif'; break;
case '.mmf': $ico='mmf.gif'; break;
case '.jad': $ico='jad.gif'; break;
case '.jar': $ico='jar.gif'; break;
case '.zip': $ico='zip.gif'; break;
case '.txt': $ico='txt.gif'; break;
case '.exe': $ico='exe.gif'; break;
case '.htm': $ico='htm.gif'; break;
case '.html': $ico='htm.gif'; break;
case '.php': $ico='php.gif'; break;
default: $ico='file.gif'; break; }

if(!$fname){
echo '<img src="../images/icons/dir.gif" alt=""> <b>Директория '.$zdir.'</b><br>';
}else{
echo '<img src="../images/icons/'.$ico.'" alt=""> <a href="zip.php?action=preview&amp;dir='.$dir.'&amp;arch='.$arch.'&amp;open='.$path.'&amp;start='.$start.'&amp;'.SID.'">'.$zdir.'/'.$fname.'</a>';
echo ' ('.formatsize($sizefiles[$i]).')<br>'; 

}}

echo '<hr>';
if ($start != 0) {echo '<a href="zip.php?start='.($start - $config_ziplist).'&amp;dir='.$dir.'&amp;arch='.$arch.'&amp;'.SID.'">&lt;-Назад</a> ';}else{echo'&lt;-Назад';}
echo ' | ';
if ($count > $start + $config_ziplist) {echo ' <a href="zip.php?start='.($start + $config_ziplist).'&amp;dir='.$dir.'&amp;arch='.$arch.'&amp;'.SID.'">Далее-&gt;</a>';}else{echo'Далее-&gt;';}


$total=$count;
if($total>0){
$ba=ceil($total/$config_ziplist);
$ba2=$ba*$config_ziplist-$config_ziplist;
echo '<br>';
echo '<hr>Страницы:';
$asd=$start-($config_ziplist*3);
$asd2=$start+($config_ziplist*4);

if($asd<$total && $asd>0){echo ' <a href="zip.php?start=0&amp;dir='.$dir.'&amp;arch='.$arch.'&amp;'.SID.'">1</a> ... ';}
for($i=$asd; $i<$asd2;)
{
if($i<$total && $i>=0){
$ii=floor(1+$i/$config_ziplist);

if ($start==$i) {
echo ' <b>'.$ii.'</b>';
} else {
echo ' <a href="zip.php?start='.$i.'&amp;dir='.$dir.'&amp;arch='.$arch.'&amp;'.SID.'">'.$ii.'</a> ';
}}
$i=$i+$config_ziplist;
}
if($asd2<$total){echo ' ... <a href="zip.php?start='.$ba2.'&amp;dir='.$dir.'&amp;arch='.$arch.'&amp;'.SID.'">'.$ba.'</a>';}
}

}else{
echo '<br><img src="../images/img/error.gif" alt=""> <b>Невозможно открыть архив!</b><br>';
echo 'Ошибка: '.$zip->errorInfo(true);

}
echo'<br><br><img src="../images/img/back.gif" alt=""> <a href="down.php?action=ob&amp;did='.$dir.'&amp;fid='.$arch.'&amp;'.SID.'">Вернуться</a><br>'; 
}
//////////////////////////////////action preview////////////////////////////////
if($action=="preview"){
	
$open = str_replace("*","/",$open);	
	
$zip=new PclZip("$dir/$arch");
$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);

echo '<img src="../images/img/zip.gif" alt=""> <b>'.$arch.'</b><br>';
echo '<img src="../images/img/files.gif" alt=""> <b>'.$open.'</b><br>';
echo 'Всего строчек: '.(int)$count.'<br><hr>';

if($utf=="ok"){echo highlight_code($content);}else{echo highlight_code(win_to_utf($content));}

echo'<hr><br><img src="../images/img/back.gif" alt=""> ';
echo'<a href="zip.php?start='.$start.'&amp;dir='.$dir.'&amp;arch='.$arch.'&amp;'.SID.'">Вернуться</a><br>'; 
}
}else{header ("Location: index.php?".SID); exit;}
echo'<img src="../images/img/dir.gif" alt=""> <a href="down.php?did='.$dir.'&amp;'.SID.'">В раздел</a><br>';	 

}else{
echo'<center><font color="red">У вас недостаточно баллов для просмотра файлов!!!</font></center>'; }}

if($config_file_post=="0"){
echo'<center><font color="red">Добавление и просмотр файлов форума отключено администрацией!!!</font></center>'; }

}else{
echo'<center><font color="red">Вы не авторизованы для просмотра файлов</font></center>';}
}

if($config_forum_off=="0"){
echo'<center><font color="red">Форум сайта отключен!</font></center>';}

echo'<img src="../images/img/barrow.gif" alt=""> <a href="index.php?'.SID.'">На форум</a><br>';	
echo'<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a>';
include_once"../themes/$config_themes/foot.php";
?>