<% if ($_SERVER['SERVER_NAME'] == "www.dur.ac.uk") { header("Location: http://www.camhsmapping.org.uk/".substr($_SERVER['REQUEST_URI'],15)); die(); } # A generalised index page # if the file home.php exists in this directory then use it and stop # if the file info.php exists in this directory then use it and continue # if a menu exists for this page the list the options sequentially, with help # NB info.php should not have a page top and bottom on it include_once "mhfunctions.php"; $thisFilename=$_SERVER['SCRIPT_FILENAME']; $thisDir=dirname($thisFilename); $thisFile=basename($thisFilename); if(is_readable($thisDir."/home.php")){ include ($thisDir."/home.php"); exit; } $page=new pageInfo(__FILE__,$PHP_SELF,$menuName); $page->top(); if(is_readable($thisDir."/info.php")){ include ($thisDir."/info.php"); $somestuff=1; } $menuDescriptionFile=$thisDir."/menu.xml"; if(!is_readable($menuDescriptionFile)){ if(!$somestuff){ warning ("No menu items available"); } $page->end(); exit; } # some gubbins for the Menu XML parser: the other functions are # defined in pageInfo function menuListEndElement($parser,$name){ global $menuItemURL, $menuItemDisplay; if($name=="ITEM"){ print "
  • $menuItemDisplay
  • \n"; } } $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($xml_parser, "menuStartElement", "menuListEndElement"); xml_set_character_data_handler($xml_parser, "menuCharacterData"); $menuDescription=implode('', file($menuDescriptionFile)); print "
    \n"; print "\n"; print "\n"; print "
    Menu
      \n"; if (!xml_parse($xml_parser, $menuDescription)) { warning(sprintf("Menu XML error: %s at line %d of $menuDescriptionFile\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); $page->end(); xml_parser_free($xml_parser); exit; } print "
    \n"; if($somestuff){ $page->bottom(); } else{ $page->end(); } xml_parser_free($xml_parser); %>