1<?php 2class FetchedDataURL extends FetchedDataHTML { 3 var $content; 4 var $headers; 5 var $url; 6 7 function detect_encoding() { 8 // First, try to get encoding from META http-equiv tag 9 // 10 $encoding = $this->_detect_encoding_using_meta($this->content); 11 12 // If no META encoding specified, try to use encoding from HTTP response 13 // 14 if (is_null($encoding)) { 15 foreach ($this->headers as $header) { 16 if (preg_match("/Content-Type: .*charset=\s*([^\s;]+)/i", $header, $matches)) { 17 $encoding = strtolower($matches[1]); 18 }; 19 }; 20 } 21 22 // At last, fall back to default encoding 23 // 24 if (is_null($encoding)) { $encoding = "iso-8859-1"; } 25 26 return $encoding; 27 } 28 29 function FetchedDataURL($content, $headers, $url) { 30 $this->content = $content; 31 $this->headers = $headers; 32 $this->url = $url; 33 } 34 35 function get_additional_data($key) { 36 switch ($key) { 37 case 'Content-Type': 38 foreach ($this->headers as $header) { 39 if (preg_match("/Content-Type: (.*)/", $header, $matches)) { 40 return $matches[1]; 41 }; 42 }; 43 return null; 44 }; 45 } 46 47 function get_uri() { 48 return $this->url; 49 } 50 51 function get_content() { 52 return $this->content; 53 } 54 55 function set_content($data) { 56 $this->content = $data; 57 } 58} 59?>