# HG changeset patch # User Tom Fredrik "BFG" Klaussen # Date 1349909694 -7200 # Node ID 2e6ba72592818882b31a02fb49c6b196e50b0b3d # Parent 3898353ed1d83d8c35c1d3d262faf9296c2bcb9b# Parent 2cfea6e84694c08294b72209e4163a8d9613bab8 Merge diff -r 2cfea6e84694 -r 2e6ba7259281 CacheTimeCheck.inc --- a/CacheTimeCheck.inc Thu Oct 11 00:06:26 2012 +0200 +++ b/CacheTimeCheck.inc Thu Oct 11 00:54:54 2012 +0200 @@ -1,4 +1,12 @@ cache_time("${baseDir}/logger.inc"); +$cache->cache_time("${baseDir}/common-functions.inc"); + /** * CacheTimeCheck provides a set of functions to enable generating a * correct time for the latest update for a given file. @@ -88,7 +96,7 @@ { if (!file_exists($path)) { warn("${path} does not exist"); - errorPage("Resource not available"); + errorPage("Resource is not available"); } array_push($this->files, $path); diff -r 2cfea6e84694 -r 2e6ba7259281 accept-language.inc --- a/accept-language.inc Thu Oct 11 00:06:26 2012 +0200 +++ b/accept-language.inc Thu Oct 11 00:54:54 2012 +0200 @@ -1,4 +1,9 @@ >>>>>> other - if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { - // break up string into pieces (languages and q factors) - preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); + if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + // break up string into pieces (languages and q factors) + preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); - if (count($lang_parse[1])) { + if (count($lang_parse[1])) { // create a list like "en" => 0.8 $langs = array_combine($lang_parse[1], $lang_parse[4]); // set default to 1 for any without q factor foreach ($langs as $lang => $val) { - if ($val === '') $langs[$lang] = 1; + if ($val === '') $langs[$lang] = 1; } // sort list based on value arsort($langs, SORT_NUMERIC); - } - } - return $langs; -} - -function preferLanguage($prefer) -{ - $language = $prefer; - $langs = acceptedLanguages(); - if ($langs) { - foreach ($langs as $l => $val) { - if (file_exists($l)) { - $language = $l; - break; } } + return $langs; } - return $language; + + function preferLanguage($prefer) + { + $language = $prefer; + $langs = acceptedLanguages(); + if ($langs) { + foreach ($langs as $l => $val) { + if (file_exists($l)) { + $language = $l; + break; + } + } + } + return $language; + } } ?> \ No newline at end of file diff -r 2cfea6e84694 -r 2e6ba7259281 common-functions.inc --- a/common-functions.inc Thu Oct 11 00:06:26 2012 +0200 +++ b/common-functions.inc Thu Oct 11 00:54:54 2012 +0200 @@ -5,8 +5,10 @@ */ include_once 'CacheTimeCheck.inc'; +$baseDir = dirname(__FILE__); + $cache = CacheTimeCheck::instance(__FILE__); -$cache->includeOnce('http-response-status-codes.inc', dirname(__FILE__)); +$cache->includeOnce('http-response-status-codes.inc', $baseDir); function repMapString($map) { diff -r 2cfea6e84694 -r 2e6ba7259281 sitemap.php --- a/sitemap.php Thu Oct 11 00:06:26 2012 +0200 +++ b/sitemap.php Thu Oct 11 00:54:54 2012 +0200 @@ -3,18 +3,21 @@ * @file * Generates a sitemap */ -header('Content-type: application/xml'); -print ''; -print "\n"; -?> -includeOnce('common-functions.inc', $baseDir); + + $cache = CacheTimeCheck::instance(__FILE__); $cache->includeOnce('Options.inc', dirname(__FILE__)); @@ -63,10 +66,10 @@ $lastmod = strtotime($lastmod); $lastmod = date(DateTime::W3C, $lastmod); - print "\n"; - print "${location}\n"; - print "${lastmod}\n"; - print "\n"; + $out .= "\n"; + $out .= "${location}\n"; + $out .= "${lastmod}\n"; + $out .= "\n"; } } } @@ -75,5 +78,8 @@ } } -?> - \ No newline at end of file +$out .= ''; + +header('Content-type: application/xml'); +print $out; +?> \ No newline at end of file