# HG changeset patch # User Tom Fredrik "BFG" Klaussen # Date 1348062618 -7200 # Node ID ee2c31392ea30c5e4473e514cc4575b6736d278d # Parent d5068ced2ad1eda871ecf2e297b7e1b57fd136c1# Parent a20bb1b51aadfc7b1918a50e810c8e7efe1d25ef Merge Regression, fast cache-checking has been removed. diff -r a20bb1b51aad -r ee2c31392ea3 cache_check.inc --- a/cache_check.inc Tue May 29 21:08:23 2012 +0200 +++ b/cache_check.inc Wed Sep 19 15:50:18 2012 +0200 @@ -1,17 +1,33 @@ $newest) { + $newest = $mtime; + } +} + +function include_with_mtime($path) { + cache_time($path); + include($path); +} + +cache_time('php/cache_check.inc'); ?> \ No newline at end of file diff -r a20bb1b51aad -r ee2c31392ea3 common-functions.inc --- a/common-functions.inc Tue May 29 21:08:23 2012 +0200 +++ b/common-functions.inc Wed Sep 19 15:50:18 2012 +0200 @@ -43,10 +43,10 @@ $new_params[$param]=$val; } foreach($new_params as $param => $val) { - if($first) + if($first) $first=0; - else - $out.="&"; + else + $out.="&"; $out.=urlencode($param).'='.urlencode($val); } return $out; diff -r a20bb1b51aad -r ee2c31392ea3 filters.inc --- a/filters.inc Tue May 29 21:08:23 2012 +0200 +++ b/filters.inc Wed Sep 19 15:50:18 2012 +0200 @@ -9,11 +9,11 @@ $pattern = '/
  • ]*)>(.*?)<\/li>/is'; $replacement = "
  • \$3
  • "; - $output=preg_replace_callback($pattern, + $output=preg_replace_callback($pattern, create_function( - '$matches', + '$matches', 'return "
  • $matches[1]))."\">$matches[3]
  • ";' - ), + ), $output); return $output; @@ -29,12 +29,12 @@ $active=($l == $lang)?0:1; $langbar.= "
  • "; - if ($active) + if ($active) $langbar.=''; $langbar.= " \"Norsk"; - if ($active) + if ($active) $langbar.=""; $langbar.= " diff -r a20bb1b51aad -r ee2c31392ea3 http-response-status-codes.inc --- a/http-response-status-codes.inc Tue May 29 21:08:23 2012 +0200 +++ b/http-response-status-codes.inc Wed Sep 19 15:50:18 2012 +0200 @@ -114,7 +114,7 @@ const HTTP_VERSION_NOT_SUPPORTED = 505; - + private static $messages = array( @@ -212,7 +212,7 @@ ); - + public static function httpHeaderFor($code) { @@ -225,14 +225,14 @@ return self::$messages[$code]; } - + public static function isError($code) { return is_numeric($code) && $code >= self::HTTP_BAD_REQUEST; } - + public static function canHaveBody($code) { @@ -253,4 +253,4 @@ } } -?> +?> \ No newline at end of file diff -r a20bb1b51aad -r ee2c31392ea3 index.php --- a/index.php Tue May 29 21:08:23 2012 +0200 +++ b/index.php Wed Sep 19 15:50:18 2012 +0200 @@ -8,20 +8,39 @@ exit; */ +function include_with_mtime($file) { + global $newest; + $mtime = filemtime($file); + if ($mtime > $newest) { + $newest = $mtime; + } + include $file; +} + if (DEBUG) { error_reporting(E_ALL); ini_set("display_errors", 1); } +$SCRIPT_FILENAME=$_SERVER['SCRIPT_FILENAME']; +$newest = filemtime($SCRIPT_FILENAME); +$cachable = true; +<<<<<<< local +include_with_mtime('php/cache_check.inc'); +include_with_mtime('php/accept-language.inc'); +include_with_mtime('php/filters.inc'); +include_with_mtime('php/common-functions.inc'); +======= if(CACHING) { include 'php/cache_check.inc'; } include 'php/accept-language.inc'; include 'php/filters.inc'; include 'php/common-functions.inc'; +>>>>>>> other -$URL_PARAMS=array('name','lang'); +$URL_PARAMS=array('name', 'lang'); #Globals $name = $_GET['name']; @@ -44,6 +63,78 @@ } } +<<<<<<< local +$title="Dummy title"; + +$config=loadFile("${lang}/${name}.xml"); + +$confFile="${lang}/${name}.xml"; +if (!file_exists($confFile)) { + errorPage("Resource not available"); +} +$doc = new DOMDocument(); +$doc->load($confFile); + +$includes=$doc->getElementsByTagName("include"); +$recurse=0; + +while($includes->length > 0) { + if(++$recurse > MAX_RECURSE) { + errorPage('Recursion limit exceeded', 500); + } + foreach ($includes as $include) { + $src=$include->getAttribute("src"); + $subdoc = new DOMDocument(); + $fname = "${lang}/${src}"; + $subdoc->load($fname); + $mtime = filemtime($fname); + if ($mtime > $newest) { + $newest = $mtime; + } + $parent=$include->parentNode; + $xml=getElementByTagName($subdoc,"xml"); + foreach($xml->childNodes as $child) { + $text=$subdoc->saveXml($child); + $clonedChild=$doc->importNode($child,true); + $parent->insertBefore($clonedChild,$include); + } + $parent->removeChild($include); + } + $includes=$doc->getElementsByTagName("include"); +} + +$head=getElementByTagName($doc,"head"); +$title=$head->getAttribute("title"); + +$css=getElementByTagName($head,"css"); +$css=$doc->saveXML($css); +$css=preg_replace('/\s*<\/?\s*css\s*>\s*/s', '', $css); + +$body=getElementByTagName($doc,"body"); +$files=$body->getElementsByTagName("file"); + + +$out= ''; + +$out.= ' + + + '; + +$out.= "$title"; +$out.= ' + +'; +$out.= "$css"; +$out.= ' + + +
    +'; + +======= +>>>>>>> other function getParam($param) { $param_type=$param->getAttribute("type"); $param_value; @@ -159,10 +250,28 @@ $files=$body->getElementsByTagName("file"); foreach ($files as $file) { - $script=$file->getAttribute("script"); + if ($file->getAttribute("script")) { + $cachable = false; + break; + } + else { + $src = $file->getAttribute("src"); + $fname = "${lang}/${src}"; + if (!file_exists($fname)) { + errorPage("Resource not found '${fname}'"); + } + cache_time($fname); + } +} + +if ($cachable) + cache_check($newest); + +foreach ($files as $file) { + $script = $file->getAttribute("script"); if ($script) { - $src=""; - $cwd=getcwd(); + $src = ""; + $cwd = getcwd(); $matches=array(); preg_match('/(.*\/)/', $script, $matches); @@ -175,10 +284,11 @@ chdir("${cwd}"); } else { - $src=$file->getAttribute("src"); - $file_content=loadFile("${lang}/${src}"); + $src = $file->getAttribute("src"); + $fname = "${lang}/${src}"; + $file_content = loadFile($fname); } - if(floatval($file_content)<0) { + if(floatval($file_content) < 0) { errorPage("Resource not found '${lang}/${src}'"); } @@ -203,8 +313,18 @@ $out.= $file_content; } +<<<<<<< local + + +$out.=' +
    + + +'; +======= $doc = new DOMDocument(); $doc->loadXml("${out}"); +>>>>>>> other return $doc; }