All pastes #1274393 Raw Edit

Magento JS Speed Fix

public php v1 · immutable
#1274393 ·published 2008-12-02 23:59 UTC
rendered paste body
<?php/** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category    Mage * @package     Mage_Core * @copyright   Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0) *//** * Proxy script to combine and compress one or few files for JS and CSS * * Restricts access only to files under current script's folder * * @category    Mage * @package     Mage_Core * @author      Magento Core Team <core@magentocommerce.com> */// no files specified return 404if (empty($_GET['f'])) {    header('404 Not found');    echo "SYNTAX: index.php/x.js?f=dir1/file1.js,dir2/file2.js";    exit;}if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {    header("HTTP/1.1 304 Not Modified");    exit;} $files = is_array($_GET['f']) ? $_GET['f'] : explode(',', $_GET['f']); header('Cache-Control: must-revalidate');header('Last-modified: ' . gmdate('r'));header('Content-type: text/javascript'); $time = time()+(365*86400);header('Expires: '.gmdate('r', $time));    foreach($files as $file){    $p = trim(str_replace('/', DIRECTORY_SEPARATOR, $file), DIRECTORY_SEPARATOR);    // validate file path    if (empty($p) || strpos($p, '..')!==false || strpos($p, '//')!==false || !file_exists($p)) {        continue;    }    // append file contents    print file_get_contents($p);	    flush();}exit;