Ejemplo n.º 1
0
        throw new EfrontFileException(_ILLEGALPATH . ': ' . $file['path'], EfrontFileException::ILLEGAL_PATH);
    }
    if (strpos($file['path'], G_ROOTPATH . 'backups') !== false && $_SESSION['s_type'] != 'administrator') {
        throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
    }
    if (isset($_GET['action']) && $_GET['action'] == 'download') {
        $file->sendFile(true);
    } else {
        cacheHeaders(lastModificationTime(filemtime($file['path'])));
        $file->sendFile(false);
    }
} catch (EfrontFileException $e) {
    if ($e->getCode() == EfrontFileException::FILE_NOT_EXIST) {
        header("HTTP/1.0 404");
    }
    echo EfrontSystem::printErrorMessage($e->getMessage());
}
function cacheHeaders($lastModifiedDate)
{
    if ($lastModifiedDate) {
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModifiedDate) {
            if (php_sapi_name() == 'CGI') {
                Header("Status: 304 Not Modified");
            } else {
                Header("HTTP/1.0 304 Not Modified");
            }
            exit;
        } else {
            $gmtDate = gmdate("D, d M Y H:i:s \\G\\M\\T", $lastModifiedDate);
            header('Last-Modified: ' . $gmtDate);
        }
Ejemplo n.º 2
0
/**
 * Shutdown function
 * This function gets executed whenever the script ends, normally or unexpectedly.
 * We implement this in order to catch fatal errors (E_ERROR) level and display
 * an appropriate message
 *
 * @since 3.6.6
 */
function shutDownFunction()
{
    session_write_close();
    if (function_exists('error_get_last')) {
        $error = error_get_last();
        if ($error['type'] == E_ERROR || $error['type'] == E_COMPILE_ERROR || $error['type'] == E_CORE_ERROR) {
            echo EfrontSystem::printErrorMessage($error['message'] . ' in ' . $error['file'] . ' line ' . $error['line']);
        }
    }
}