Example #1
0
            exit;
        } else {
            $gmtDate = gmdate("D, d M Y H:i:s \\G\\M\\T", $lastModifiedDate);
            header('Last-Modified: ' . $gmtDate);
        }
    }
}
// This function uses a static variable to track the most recent
// last modification time
function lastModificationTime($time = 0)
{
    static $last_mod;
    if (!isset($last_mod) || $time > $last_mod) {
        $last_mod = $time;
    }
    return $last_mod;
}
lastModificationTime(filemtime(__FILE__));
cacheHeaders(lastModificationTime());
header("Content-type: text/javascript; charset: UTF-8");
ob_start("ob_gzhandler");
foreach (explode(",", $_GET['load']) as $value) {
    if (is_file("{$value}.js")) {
        $real_path = mb_strtolower(realpath("{$value}.js"));
        if (strpos($real_path, mb_strtolower(dirname(__FILE__))) !== false || strpos($real_path, mb_strtolower(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR)) !== false) {
            lastModificationTime(filemtime("{$value}.js"));
            include "{$value}.js";
            echo "\n";
        }
    }
}
            }
        }
    }
    if (strpos($file['path'], G_ROOTPATH . 'libraries') !== false && strpos($file['path'], G_ROOTPATH . 'libraries/language') === false && $file['mime_type'] != "application/inc") {
        throw new EfrontFileException(_ILLEGALPATH . ': ' . $file['path'], EfrontFileException::ILLEGAL_PATH);
    }
    if (pathinfo($file['path'], PATHINFO_EXTENSION) == 'php') {
        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 {