Размер файла: 8.83Kb
<?php
require_once ( "../includes/start.php" );
require_once ( "../includes/functions.php" );
require_once ( "../includes/header.php" );
include_once ( "../themes/" . $config['themes'] . "/index.php" );
include_once "../includes/pclzip.php";
$dir = check( $_GET['dir'] );
$arch = check( $_GET['arch'] );
$open = check( $_GET['open'] );
if ( isset( $_GET['action'] ) )
$action = check( $_GET['action'] );
if ( isset( $_GET['start'] ) )
$start = ( int )$_GET['start'];
if ( !eregi( "[^a-z0-9_@+-]", $dir ) && ( !eregi( "[^a-z0-9_@+.-]", $arch ) ) )
{
show_title( 'partners.gif', 'Просмотр архива' );
if ( $dir != "" && $arch != "" )
{
if ( !$action )
{
$zip = new PclZip( "$dir/$arch" );
if ( ( $list = $zip->listContent() ) != 0 )
{
sort( $list );
$countlist = count( $list );
$zfilename = array();
$zfilesize = array();
$zfolder = array();
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>' . $arch . '</b><br><br>';
echo 'Всего файлов: ' . $total . '<br>Вес распакованного архива: ' . formatsize( $totalsize ) .
'<hr>';
if ( $start < 0 || $start > $total )
{
$start = 0;
}
if ( $total < $start + $config['ziplist'] )
{
$end = $total;
}
else
{
$end = $start + $config['ziplist'];
}
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="../images/icons/dir.gif" alt=""> <b>Директория ' . $zfilename[$i] .
'</b><br>';
}
else
{
echo '<img src="../images/icons/' . $ico .
'" alt=""> <a href="zip.php?action=preview&dir=' . $dir . '&arch=' . $arch .
'&open=' . $zfilename[$i] . '&start=' . $start . '&' . SID . '">' . $zfilename[$i] .
'</a>';
echo ' (' . formatsize( $zfilesize[$i] ) . ')<br>';
}
}
echo '<hr>';
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 / $config['ziplist'] );
$ba2 = $ba * $config_ziplist - $config['ziplist'];
echo '<br><hr>Страницы:';
$asd = $start - ( $config['ziplist'] * 3 );
$asd2 = $start + ( $config['ziplist'] * 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?action=ob&did=' .
$dir . '&fid=' . $arch . '&' . SID . '">Вернуться</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="zip.php?start=' . $start .
'&dir=' . $dir . '&arch=' . $arch . '&' . SID . '">Вернуться</a><br>';
}
}
else
{
header( "Location: index.php?" . SID );
exit;
}
}
else
{
header( "Location: index.php?" . SID );
exit;
}
echo '<img src="../images/img/dir.gif" alt=""> <a href="down.php?did=' . $dir . '&' .
SID . '">В раздел</a><br>';
echo '<img src="../images/img/panel.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" );
?>