PHP 8.1.33
Preview: DownloadFile.php Size: 3.15 KB
/home/jambtst2015/public_html/ckfinder/core/connector/php/php4/CommandHandler/DownloadFile.php

<?php

/*

 * CKFinder

 * ========

 * http://ckfinder.com

 * Copyright (C) 2007-2011, CKSource - Frederico Knabben. All rights reserved.

 *

 * The software, this file and its contents are subject to the CKFinder

 * License. Please read the license.txt file before using, installing, copying,

 * modifying or distribute this file or part of its contents. The contents of

 * this file is part of the Source Code of CKFinder.

 */

if (!defined('IN_CKFINDER')) exit;



/**

 * @package CKFinder

 * @subpackage CommandHandlers

 * @copyright CKSource - Frederico Knabben

 */



/**

 * Handle DownloadFile command

 *

 * @package CKFinder

 * @subpackage CommandHandlers

 * @copyright CKSource - Frederico Knabben

 */

class CKFinder_Connector_CommandHandler_DownloadFile extends CKFinder_Connector_CommandHandler_CommandHandlerBase

{

    /**

     * Command name

     *

     * @access private

     * @var string

     */

    var $command = "DownloadFile";



    /**

     * send response (file)

     * @access public

     *

     */

    function sendResponse()

    {

        if (!function_exists('ob_list_handlers') || ob_list_handlers()) {

            @ob_end_clean();

        }

        header("Content-Encoding: none");



        $this->checkConnector();

        $this->checkRequest();



        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {

            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);

        }



        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["FileName"]);

        $_resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();



        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) {

            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);

        }



        if (!$_resourceTypeInfo->checkExtension($fileName, false)) {

            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);

        }



        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);

        if ($_resourceTypeInfo->checkIsHiddenFile($fileName) || !file_exists($filePath) || !is_file($filePath)) {

            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);

        }



        $fileName = CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName);



        header("Cache-Control: cache, must-revalidate");

        header("Pragma: public");

        header("Expires: 0");

        if (!empty($_GET['format']) && $_GET['format'] == 'text') {

            header("Content-Type: text/plain; charset=utf-8");

        }

        else {

            header("Content-type: application/octet-stream; name=\"" . $fileName . "\"");

            header("Content-Disposition: attachment; filename=\"" . str_replace("\"", "\\\"", $fileName). "\"");

        }

        header("Content-Length: " . filesize($filePath));

        CKFinder_Connector_Utils_FileSystem::readfileChunked($filePath);

        exit;

    }

}

Directory Contents

Dirs: 0 × Files: 16

Name Size Perms Modified Actions
4.01 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
11.12 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.55 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.28 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
2.38 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.15 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
8.56 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
4.85 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.69 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.74 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
11.93 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
1.36 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
5.00 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
4.48 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
12.38 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download
3.40 KB lrw-r--r-- 2024-11-22 17:53:11
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).