Вход Регистрация
Файл: sman/set/show_zip.php
Строк: 72
<?php

include_once '../../sman/includs/configurations.php';

$file_opt 'true';

//include_once '../../sman/includs/head.php';

if(!empty($_GET['path']))

   
$arh ROOT.htmlspecialchars($_GET['path']);




if(!empty(
$_GET['act']))

   
$act $_GET['act'];

else

   
$act 'main';


$zip = new ZipArchive;

if(
$zip->open($arh) === TRUE){

   switch(
$act){

   case(
'main'):

    echo
'Обьектов: '.$zip->numFiles.'<br/>';

    if(
$zip->comment != NULL)

       echo
'Комментарий: '.$zip->comment.'<br/>';

    for (
$i 0$i $zip->numFiles$i++) {

           
$t $zip->statIndex($i);

           if(
preg_match('//$/',$t['name']))

               echo 
'Каталог <strong>'.$t['name'].'</strong>';

           else

               echo 
'<a href="?act=pre&path='.$_GET['path'].'&index='.$t['index'].'">'.$t['name'].            '</a>';


           echo
'<br/>';

        }

        break;


   case(
'pre'):

        if(
$info $zip->statIndex(abs((int)$_GET['index']))){

           echo 
'Файл '.$info['name'].'<br/>

           <a href="?act=down&path='
.$_GET['path'].'&index='.$info['index'].'">Скачать файл</a>

           <br/>'
;




           
$highlight=array('php','html','htm');

           
$astext=array('txt','css','ini','htaccess');

           
$type=substr($info['name'],strrpos($info['name'],'.')+1);

echo 
'<div class = "code_show">';
           if(
in_array($type$highlight)){

$code $zip->getFromIndex($info['index']);


  
$code =            highlight_string($codetrue);
echo 
'<code>'.$code.'</code>';

           }elseif(
in_array($type$astext)){

              echo 
nl2br(htmlspecialchars($zip->getFromIndex($info['index'])));

           }

echo 
'</div>';
        }else

           echo 
'Ошибка извлечения файла!';

    break;


   case(
'down'):

        
$index abs((int)$_GET['index']);

        if(
$name $zip->getNameIndex($index)){

           
header('Content-Type: application/octet-stream'true);

           
header('Content-Disposition: attachment; filename="'.urlencode(basename($name)).'";');

           echo 
$zip->getFromIndex($index);

        }else

           echo 
'Ошибка извлечения файла!';

    break;


   default:

        echo
'Не известное действие';

        break;


}


$zip->close();

}else

   echo
'Ошибка открытия архива!';

?>
Онлайн: 0
Реклама