<?php

$cssFiles = array(
  "background.css",
        "jqueryui.css",
        "jquery.fancybox.css",
         "normalize.min.css",
         "carousel.css",
         "main.css",
         "color.css",
         'font.css',
         'input.css',
         'effects.css',
         'semplicita.css',
         'calendarMedula.css',
         'responsive.css',
         'superslide.css',
         "formcontatti.css"
        
         

);



$buffer = "";
foreach ($cssFiles as $cssFile) {
  $buffer .="/* ".$cssFile."*/\n". file_get_contents($_SERVER["DOCUMENT_ROOT"]."oldcss/".$cssFile)."\n";
}

$buffer=str_replace("https://contents.vroomerz.com/","https://cdn-vroomerz.medula.co.uk/",$buffer);
  

$bb=$buffer;

$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
//
$buffer = str_replace(': ', ':', $buffer);
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
//
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
// Enable GZip encoding.
//ob_start("ob_gzhandler");
//ob_start();
// Enable caching

function minify_css($str){

    # remove comments first (simplifies the other regex)
    $re1 = <<<'EOS'
(?sx)
  # quotes
  (
    "(?:[^"\\]++|\\.)*+"
  | '(?:[^'\\]++|\\.)*+'
  )
|
  # comments
  /\* (?> .*? \*/ )
EOS;

    $re2 = <<<'EOS'
(?six)
  # quotes
  (
    "(?:[^"\\]++|\\.)*+"
  | '(?:[^'\\]++|\\.)*+'
  )
|
  # ; before } (and the spaces after it while we're here)
  \s*+ ; \s*+ ( } ) \s*+
|
  # all spaces around meta chars/operators
  \s*+ ( [*$~^|]?+= | [{};,>~+-] | !important\b ) \s*+
|
  # spaces right of ( [ :
  ( [[(:] ) \s++
|
  # spaces left of ) ]
  \s++ ( [])] )
|
  # spaces left (and right) of :
  \s++ ( : ) \s*+
  # but not in selectors: not followed by a {
  (?!
    (?>
      [^{}"']++
    | "(?:[^"\\]++|\\.)*+"
    | '(?:[^'\\]++|\\.)*+' 
    )*+
    {
  )
|
  # spaces at beginning/end of string
  ^ \s++ | \s++ \z
|
  # double spaces to single
  (\s)\s+
EOS;

    $str = preg_replace("%$re1%", '$1', $str);
    return preg_replace("%$re2%", '$1$2$3$4$5$6$7', $str);
}
//if (!$_GET["_"])$buffer=minify_css($buffer);
header('Cache-Control: cache');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 864000) . ' GMT');
header("Cache-Control: max-age=2592000");
header("Last-Modified: ".gmdate("D, d M Y H:i:s", time()-864000)." GMT");
$etagFile = md5_file(__FILE__);
header("Etag: $etagFile");
header("Content-type: text/css");

echo(trim($buffer));
?>