| | 42 | function wp_cache_get_response_headers() { |
| | 43 | if(function_exists('apache_response_headers')) { |
| | 44 | $headers = apache_response_headers(); |
| | 45 | } else if(function_exists('headers_list')) { |
| | 46 | $headers = array(); |
| | 47 | foreach(headers_list() as $hdr) { |
| | 48 | list($header_name, $header_value) = explode(': ', $hdr, 2); |
| | 49 | $headers[$header_name] = $header_value; |
| | 50 | } |
| | 51 | } else |
| | 52 | $headers = null; |
| | 53 | |
| | 54 | return $headers; |
| | 55 | } |
| | 56 | |
| 190 | | /* Preparing... with PHP5 is straightforward, use headers_list() */ |
| 191 | | if(function_exists('apache_response_headers') ) { |
| 192 | | $response = apache_response_headers(); |
| 193 | | $meta_object->headers = array(); |
| 194 | | foreach ($known_headers as $key) { |
| 195 | | if(isset($response{$key})) { |
| 196 | | array_push($meta_object->headers, "$key: " . $response{$key}); |
| 197 | | } |
| | 201 | $meta_object = new CacheMeta; |
| | 202 | $meta_object->uri = $_SERVER["SERVER_NAME"].preg_replace('/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI']); // To avoid XSS attacs |
| | 203 | $meta_object->blog_id=$blog_id; |
| | 204 | $meta_object->post = wp_cache_post_id(); |
| | 205 | |
| | 206 | $response = wp_cache_get_response_headers(); |
| | 207 | $meta_object->headers = array(); |
| | 208 | foreach ($known_headers as $key) { |
| | 209 | if(isset($response{$key})) { |
| | 210 | array_push($meta_object->headers, "$key: " . $response{$key}); |
| 199 | | /* Not use because it gives problems with some |
| 200 | | * PHP installations |
| 201 | | if (!$response{'Content-Length'}) { |
| 202 | | // WP does not set content size |
| 203 | | $content_size = ob_get_length(); |
| 204 | | @header("Content-Length: $content_size"); |
| 205 | | array_push($meta_object->headers, "Content-Length: $content_size"); |
| 206 | | } |
| 207 | | */ |
| 208 | | if (!$response{'Last-Modified'}) { |
| 209 | | $value = gmdate('D, d M Y H:i:s') . ' GMT'; |
| 210 | | /* Dont send this the first time */ |
| 211 | | /* @header('Last-Modified: ' . $value); */ |
| 212 | | array_push($meta_object->headers, "Last-Modified: $value"); |
| 213 | | } |
| 214 | | if (!$response{'Content-Type'}) { |
| 215 | | $value = "text/html; charset=\"" . get_settings('blog_charset') . "\""; |
| 216 | | @header("Content-Type: $value"); |
| 217 | | array_push($meta_object->headers, "Content-Type: $value"); |
| 218 | | } |
| | 213 | /* Not use because it gives problems with some |
| | 214 | * PHP installations |
| | 215 | if (!$response{'Content-Length'}) { |
| | 216 | // WP does not set content size |
| | 217 | $content_size = ob_get_length(); |
| | 218 | @header("Content-Length: $content_size"); |
| | 219 | array_push($meta_object->headers, "Content-Length: $content_size"); |
| | 220 | } |
| | 221 | */ |
| | 222 | if (!$response{'Last-Modified'}) { |
| | 223 | $value = gmdate('D, d M Y H:i:s') . ' GMT'; |
| | 224 | /* Dont send this the first time */ |
| | 225 | /* @header('Last-Modified: ' . $value); */ |
| | 226 | array_push($meta_object->headers, "Last-Modified: $value"); |
| | 227 | } |
| | 228 | if (!$response{'Content-Type'}) { |
| | 229 | $value = "text/html; charset=\"" . get_settings('blog_charset') . "\""; |
| | 230 | @header("Content-Type: $value"); |
| | 231 | array_push($meta_object->headers, "Content-Type: $value"); |
| | 232 | } |
| | 233 | |