Размер файла: 5.27Kb
<?
include_once("../inc/ini.php");
include_once("../inc/connect.php");
include_once("../inc/function.php");
include_once("../inc/config.php");
include_once("../themes/$config_themes/index.php");
include_once"pclzip.php";
$config_ziplist = 10;
$id_file = $_GET['id_file'];
$OR_ADD_NAME = mysql_query("SELECT * FROM files WHERE id='$id_file'");
$data2 = mysql_fetch_array($OR_ADD_NAME);
$dir=$_GET['dir'];
$arch=$_GET['file'];
$open=$_GET['open'];
$action=$_GET['action'];
echo $div['title'].'<b>Просмотр архива</b>'.$div['title_end'];
echo $div['menu'];
if($dir!="" && $arch!=""){
if (!$action){
$zip=new PclZip("../$dir/$arch");
if (($list = $zip->listContent()) != 0){
sort($list);
$countlist=count($list);
for ($i=0; $i<$countlist; $i++){
$zfilename[]=$list[$i]['filename'];
$zfilesize[]=$list[$i]['size'];
$zfolder[]=$list[$i]['folder'];
}
$totalsize=array_sum($zfilesize);
$total = count($zfilename);
echo '<img src="../images/img/zip.gif" alt=""> <b>'.$data2['name'].'</b><br><br>';
echo 'Всего файлов: '.$total.'<br>Вес распакованного архива: '.size($totalsize).'<br />';
$start = (int)$_GET['start'];
if($start < 0 || $start > $total){$start = 0;}
if ($total < $start + 10){ $end = $total; }
else {$end = $start + 10; }
for ($i = $start; $i < $end; $i++){
$ext=strtolower(strrchr($zfilename[$i], "."));
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($zfolder[$i]=="1"){
$zfilename[$i]=substr($zfilename[$i],0,-1);
echo '<img src="../img/icon/dir.gif" alt=""> <b>Директория '.$zfilename[$i].'</b><br>';
}else{
echo '<img src="../img/icon/'.$ico.'" alt=""> '.$zfilename[$i].'';
echo ' ('.size($zfilesize[$i]).')<br>';
}}
if ($start != 0) {echo '<a href="zip.php?start='.($start - $config_ziplist).'&dir='.$dir.'&arch='.$arch.'&'.SID.'"><-Назад</a> ';}else{echo'<-Назад';}
echo ' | ';
if ($total > $start + $config_ziplist) {echo ' <a href="zip.php?start='.($start + $config_ziplist).'&dir='.$dir.'&arch='.$arch.'&'.SID.'">Далее-></a>';}else{echo'Далее->';}
if($total>0){
$ba=ceil($total/10);
$ba2=$ba*$config_ziplist-$config_ziplist;
echo '<br /><br>Страницы:';
$asd=$start-(10*3);
$asd2=$start+(10*4);
if($asd<$total && $asd>0){echo ' <a href="zip.php?start=0&dir='.$dir.'&arch='.$arch.'&'.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.'&dir='.$dir.'&arch='.$arch.'&'.SID.'">'.$ii.'</a> ';
}}
$i=$i+$config_ziplist;}
if($asd2<$total){echo ' ... <a href="zip.php?start='.$ba2.'&dir='.$dir.'&arch='.$arch.'&'.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?id_file='.$id_file.'">Вернуться</a><br>';
}
////////////////////////////////// Просмотр файла ////////////////////////////////
if($action=="preview"){
$zip=new PclZip("../$dir/$arch");
$content = $zip->extract(PCLZIP_OPT_BY_NAME, $open,PCLZIP_OPT_EXTRACT_AS_STRING);
$content = $content[0]['content'];
$preview = explode("\r\n",$content);
$count = count($preview);
$ext = strtolower(substr($open, strrpos($open, '.') + 1));
echo '<img src="../images/img/zip.gif" alt=""> <b>'.$arch.'</b><br>';
echo '<img src="../images/img/files.gif" alt=""> <b>'.$open.'</b><br>';
if ($ext!="gif" && $ext!="jpg" && $ext!="png"){
//---------------------- Файл ----------------------//
echo 'Всего строчек: '.(int)$count.'<br><hr>';
if(is_utf($content)){echo highlight_code($content);}else{echo highlight_code(win_to_utf($content));}
}else{
//-------------------- Картинка --------------------//
if($create=="image"){
ob_end_clean();
ob_clean();
header('Content-Disposition: attachment; filename="image.'.$ext.'";');
if($ext=="jpg"){$ext="jpeg";}
header("Content-type: image/$ext");
header("Content-Length: ".strlen($content));
echo $content;
exit;
}
echo'<br><img src="zip.php?action=preview&dir='.$dir.'&arch='.$arch.'&open='.$open.'&create=image" alt="">';
//--------------------------------------------------//
}
echo'<hr><br><img src="../images/img/back.gif" alt=""> <a href="down.php?id_file='.$id_file.'">Вернуться</a><br>';
}
}else{header ("Location: index.php"); exit;}
echo $div['menu_end'];
include_once("../themes/$config_themes/foot.php");
?>