/** * Redirect (mean read from file and output) to CSS-file of current map. * Almost generate header-values. * * @param array $map_cfg map-config array * * @return bool is redirect done */ public static function redirect($map_cfg) { $filename = self::get_valid_css_source($map_cfg, isset($map_cfg['attach'])); if ($filename === false) { return false; } //--------------------------------------------------------------------- $cache_timeout = qpimg_config::get_option('cache_time_expire'); $headers = array(); $headers['Expires'] = gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $cache_timeout); $headers['Last-Modified'] = gmdate('D, d M Y H:i:s \\G\\M\\T', filemtime($filename)); $headers['ETag'] = "\"qpimg-{$map_cfg['id']}-{$map_cfg['hash']}\""; //--------------------------------------------------------------------- $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : false; $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : false; if ($if_none_match && $if_none_match == $headers['ETag']) { $headers[':Response-Code'] = 304; $filename = false; } elseif ($if_modified_since && $if_modified_since == $headers['Last-Modified']) { $headers[':Response-Code'] = 304; $filename = false; } else { $headers['Content-Type'] = 'text/css'; $headers['Cache-Control'] = "max-age={$cache_timeout}, public, must-revalidate"; } qpimg_utils::send_headers($headers); if ($filename !== false) { @readfile($filename); } return true; }