view index.php @ 32:7b19be62ea94

Remove yet another global, replace by CacheTimeCheck class.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Thu, 04 Oct 2012 19:46:11 +0200
parents ca75a735651e
children 511b6514823f
line wrap: on
line source

<?php
define(DEBUG,0);
define(MAX_RECURSE,50);
define(CACHING,1);

/*
var_dump($_SERVER);
exit;
*/

if (DEBUG) {
  error_reporting(E_ALL);
  ini_set("display_errors", 1);
}

$cacheable = true;

include_once 'php/cache_check.inc';

$cache = new CacheTimeCheck(filemtime(__FILE__));
$cache->includeOnce('php/Options.inc');
$cache->includeOnce('php/accept-language.inc');
$cache->includeOnce('php/common-functions.inc');
$cache->includeOnce('php/filters.inc');
$cache->includeOnce('php/inputParser.inc');

$URL_PARAMS = array('name', 'lang');

$master = new DOMDocument();
$master->load("master.xml");

$options = new Options($master);
$options->setCache($cache);

$lang = $_GET['lang'];
if($lang) {
  $options->setLang($lang);
}
else {
  $options->setLang($options->getDefaultLang());
}

$name = $_GET['name'];
if($name) {
  $options->setName($name);
}

$params = $master->getElementsByTagName("param");

foreach ($params as $param) {
  if ($param->getAttribute("type") == "input") {
    $doc = getInput($master, $param, $options);

    $parent = $param->parentNode;
    foreach ($doc->firstChild->childNodes as $child) {
      $clonedChild = $master->importNode($child, true);
      $parent->insertBefore($clonedChild, $param);
    }
    $parent->removeChild($param);
  }
}

if (CACHING && $cacheable)
  $options->getCache()->CheckHttpModified($newest);

print $master->saveXml($master);

?>