Esempio n. 1
0
<?php

error_reporting(0);
function isBuggyIe()
{
    $ua = $_SERVER['HTTP_USER_AGENT'];
    // quick escape for non-IEs
    if (0 !== strpos($ua, 'Mozilla/4.0 (compatible; MSIE ') || false !== strpos($ua, 'Opera')) {
        return false;
    }
    // no regex = faaast
    $version = (double) substr($ua, 30);
    return $version < 6 || $version == 6 && false === strpos($ua, 'SV1');
}
if (!isBuggyIe() && extension_loaded('zlib')) {
    ob_start('ob_gzhandler');
}
header("Content-type: text/css");
$files = scandir(dirname(__FILE__));
foreach ($files as $file) {
    if (end(explode('.', $file)) == 'css') {
        echo "/* {$file} */";
        include dirname(__FILE__) . '/' . $file;
    }
}
if (!isBuggyIe() && extension_loaded('zlib')) {
    ob_end_flush();
}
Esempio n. 2
0
/**
 * Returns client's accepted encoding
 * Code taken from Minify (http://code.google.com/p/minify/)
 *
 * @return void bool If client supports gzip
 */
function getAcceptedEncoding()
{
    // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
    if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) || isBuggyIe()) {
        return array('', '');
    }
    $ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
    // gzip checks (quick)
    if (0 === strpos($ae, 'gzip,') || 0 === strpos($ae, 'deflate, gzip,')) {
        return array('gzip', 'gzip');
    }
    // gzip checks (slow)
    if (preg_match('@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae, $m)) {
        return array('gzip', $m[1]);
    }
}