function api_header($o, $last_mod = null) { if ($last_mod && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { $t = cond_parse_http_date($_SERVER['HTTP_IF_MODIFIED_SINCE']); if (isset($t) && $t >= $last_mod) { header('HTTP/1.0 304 Not Modified'); header('Last-Modified: ' . date('r', $last_mod)); return true; } } if ($o == 'xml') { $type = 'text/xml'; } elseif ($o == 'php') { $type = 'text/php'; } elseif ($o == 'rabx') { $type = 'application/octet-stream'; } else { $type = 'text/javascript'; } #$type = 'text/plain'; header("Content-Type: {$type}; charset=iso-8859-1"); if ($last_mod > 0) { header('Last-Modified: ' . date('r', $last_mod)); } return false; }
function cond_if_modified_since($time) { $t = cond_parse_http_date($_SERVER['HTTP_IF_MODIFIED_SINCE']); if (isset($t) && $t >= $time) { return true; } return false; }