Вход Регистрация
Файл: CMS/core/modules/users_files_zip.php
Строк: 137
<?php

if (!defined('CMS')) { die('Access Denied!'); }

include( 
dirname(__FILE__) . '/users_files.inc.php' );

if (
$id < 1) {

    
$inSes->addMessage('Ошибка! Файл не найден или ссылка неверна!');
    
gen_red('files', '', RND);
}

$row = array();
$row = $db->selectRow("SELECT ?_downs.*, ?_downs_category.*
                       FROM ?_downs LEFT JOIN ?_downs_category 
                       ON ?_downs.`downs_user_cat` = ?_downs_category.`cats_id` 
                       WHERE `downs_id` = ? LIMIT 1;"
, $id);


if (empty(
$row) || !is_array($row)) {

    
$inSes->addMessage('Ошибка! Файл не найден или ссылка неверна!');
    
gen_red('files', '', RND);
}

$filepath = ROOTPATH . DS . $config['files_folder'] . DS . $row['downs_id'] . DS;

if (!
is_file($filepath . $row['downs_link'])) {

    
$inSes->addMessage('Ошибка! Файл не найден или ссылка неверна!');
    
gen_red('file', $id, RND);
}

include_once( 
ENGINE . '/classes/pclzip.class.php' );

if (!
$zip = new PclZip($filepath . $row['downs_link'])) {

    
$inSes->addMessage('Ошибка! Невозможно просмотреть данный файл, т.к. он не является архивом!');
    
gen_red('file', $id, RND);
}

if (!empty(
$_GET['img'])) {

    
$img = (abs(intval($_GET['img'])) - 1);

    
$content = $zip -> extract(PCLZIP_OPT_BY_INDEX, $img, PCLZIP_OPT_EXTRACT_AS_STRING);

    if (!empty(
$content)) {

        
$filecontent = $content[0]['content'];
        
$filename = $content[0]['filename'];
        
$ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
        
header("Content-type: image/$ext");
        
header("Content-Length: " . strlen($filecontent));
        
header('Content-Disposition: inline; filename="' . $filename . '";');
        echo 
$filecontent;
        exit;
    }
}

if (!empty(
$_GET['view'])) {

    
$view = (abs(intval($_GET['view'])) - 1);

    
$content = $zip -> extract(PCLZIP_OPT_BY_INDEX, $view, PCLZIP_OPT_EXTRACT_AS_STRING);

    if (!empty(
$content)) {

        
$filecontent = $content[0]['content'];
        
$filename = $content[0]['filename'];
        
$ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
        
show_header('Просмотр файла - ' . $filename);
        echo 
'<div class="b">' . extensions($ext);
        echo 
'<b>' . $filename . '</b> (' . size($content[0]['size']) . ')</div>';

        if (!
preg_match("/.(gif|png|bmp|wbmp|jpg|jpeg)$/", $filename)) {

            if (
$content[0]['size'] > 0) {

                if (
is_utf($filecontent)) {

                    echo 
'<div class="b">' . highlight_string($filecontent, 1) . '</div>';
                }
                else {
                    echo 
'<div class="b">' . highlight_string(iconv('cp1251', 'UTF-8', $filecontent), 1) . '</div>';
                }
            }
            else {
                
show_error('Данный файл пустой!');
            }
        }
        else {

            echo 
'<div class="b"><img src="' . gen_uri('zip', $id, 'img=' . ($view + 1)) . '" alt="" /><br /></div>';
        }
    }
    else {

        
$inSes->addMessage('Ошибка! Не удалось извлечь файл!');
        
gen_red('zip', $id, RND);
    }
}
else {

    
show_header('Просмотр архива - ' . $row['downs_title'], $row['downs_text'], $row['downs_text']);

    if ((
$list = $zip -> listContent()) != 0) {

        
$intotal = $zip -> properties();
        
$total = $intotal['nb'];
        
sort($list);

        if (
$total > 0) {

            echo 
'<div class="b">';
            echo 
'Всего файлов: ' . $total . '</div><div class="b">';

            
$arrext = array('.xml', '.wml', '.asp', '.aspx', '.shtml', '.htm', '.phtml', '.html', '.php', '.htt', '.dat', '.tpl', '.htaccess', '.pl', '.js', '.jsp', '.css', '.txt', '.sql', '.gif', '.png', '.bmp', '.wbmp', '.jpg', '.jpeg');

            
$onpage = 25;

            list(
$start,$stop) = get_page();

            for (
$i = $start; $i < $stop; $i++) {

                if (
$list[$i]['folder'] == 1) {

                    
$filename = substr($list[$i]['filename'], 0, -1);
                    echo 
icon('folder.png', 'icons') . '<b>Директория ' . $filename . '</b><br />';
                }
                else {

                    
$filename = $list[$i]['filename'];
                    
$ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
                    echo 
extensions($ext);

                    if (
in_array('.' . $ext, $arrext)) {

                        echo 
'<a href="' . gen_uri('zip', $id, 'view=' . ($list[$i]['index'] + 1) . '&amp;' . RND) . '">' . $filename . '</a>';
                    }
                    else {

                        echo 
$list[$i]['filename'];
                    }
                    echo 
' (' . size($list[$i]['size']) . ')<br />';
                }
            }

            echo 
'</div>' . show_pages(gen_uri('zip', $id, RND));

        }
        else {
            
show_error('Ошибка! В данном архиве нет файлов!');
        }
    }
    else {
        
show_error('Ошибка! Невозможно открыть архив!');
    }
}

echo 
'<div class="b">' . show_back_link($row['cats_parent_all'] . ',' . $row['cats_id'], $data['users_login']);
echo 
' -&gt; <a href="' . gen_uri('file', $id, RND) . '">' . $row['downs_title'] . '</a>';
echo 
'</div>';

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