/** * load and parse a CSS file * * @param string $file * @param int $origin */ function load_css_file($file, $origin = self::ORIG_AUTHOR) { if ($origin) { $this->_current_origin = $origin; } // Prevent circular references if (isset($this->_loaded_files[$file])) { return; } $this->_loaded_files[$file] = true; if (strpos($file, "data:") === 0) { $parsed = parse_data_uri($file); $css = $parsed["data"]; } else { $parsed_url = explode_url($file); list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = $parsed_url; // Fix submitted by Nick Oostveen for aliased directory support: if ($this->_protocol == "") { $file = $this->_base_path . $filename; } else { $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename); } set_error_handler("record_warnings"); $css = qsot_remote_file::get_contents($file, null, $this->_dompdf->get_http_context()); restore_error_handler(); $good_mime_type = true; $headers = qsot_remote_file::get_headers(); if (is_array($headers) && !empty($headers)) { foreach ($headers as $_header) { if (preg_match('#Content-Type:\\s*([\\w/]+)#i', $_header, $matches) && $matches[1] !== 'text/css') { $good_mime_type = false; } } } // See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/ /* LOUSHOU replaced ******************** if ( isset($http_response_header) && !$this->_dompdf->get_quirksmode() ) { foreach($http_response_header as $_header) { if ( preg_match("@Content-Type:\s*([\w/]+)@i", $_header, $matches) && ($matches[1] !== "text/css") ) { $good_mime_type = false; } } } */ if (!$good_mime_type || $css == "") { record_warnings(E_USER_WARNING, "Unable to load css file {$file}", __FILE__, __LINE__); return; } } $this->_parse_css($css); }