\n"; echo "\n"; echo "Asda Travel > Destination Guides\n"; echo ""; echo "\n\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; } // otherwise show the XML for the destination else { // if no section has been requested, show the overview if (!(strlen($section_requested)>0)) { $section_requested="Overview"; } // if the file doesn't exist (i.e. they've entered a bogus destination name in their URL bar) // then show an error message and exit nicely. if (!(file_exists("xml/".$xml_filename.".xml"))) { die("There is no travel guide for that destination ($xml_filename)."); } // if it does exist, then load the XML file, add to sections so they are // treated as text and not parsed into XML objects by SimpleXML, then create the SimpleXML object $xml else { $xml_file = str_replace(array("",""),array(""),file_get_contents("xml/".$xml_filename.".xml")); $xml = new SimpleXMLElement($xml_file); if (!($xml)) { die("SimpleXML object creation error!"); } } echo "\n"; echo "\n"; echo "Asda Travel > Destination Guides > $xml_filename\n"; echo ""; echo "\n\n"; echo "\n"; echo "\n"; echo "
"; echo "Asda Travel > \n"; echo "Destination Guides\n\n"; echo "

\n"; echo "
    \n"; // create directory object and set up a counter for the array that will hold the filenames $mydir = dir('/home/sites/webvictim/destguides/xml'); $j=0; $file_array=array(); // while there are files still in the directory while(($file = $mydir->read()) !== false) { // if the extension is .xml if(substr($file,(strpos($file,".")))==".xml") { // add the file into the array (minus its .xml extension) $file = substr($file, 0, strlen($file)-4); $file_array[$j] = "$file
    \n"; } $j++; } // close the directory $mydir->close(); // sort and print the list of destinations asort($file_array); foreach ($file_array as $filename) { echo $filename; } echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; // if a particular section has been requested if (isset($section_requested)) { // go through the file until we get to the appropriate part foreach ($xml->Region->Section as $section) { // and if it exists, create $body with all the information in if (strcasecmp($section->SectionTitle, $section_requested)==0) { $body.="
"; // for each section in the XML file (they vary a lot) add a menu entry into the array $i=0; foreach ($xml->Region->Section as $section) { $menu[$i] = $section->SectionTitle; $i++; } /* sort the menu array so it's in alphabetical order echo "
";
	print_r($menu);
	echo "
"; exit(); asort($menu); */ echo "Asda Travel > \n"; echo "Destination Guides > \n"; echo "$xml_filename\n\n"; echo "

\n"; echo "
    \n"; // print the menu at the left hand side with appropriate links for navigation foreach ($menu as $menuItem) { $self = $_SERVER['PHP_SELF']; $menuItemEncoded = rawurlencode($menuItem); echo "
  • $menuItem
  • \n"; } echo "
\n"; echo "
\n"; $body.="\n"; $body.="\n"; $body.="
".$section->SectionTitle."
".(string)$section->OutputData->DataInfo."
\n"; $body.="

\n\n"; } } // if there is no section with that name if (!(strlen($body)>0)) { // print an error echo "\n"; echo "Sorry, that section does not exist.

\n"; echo "\n"; } // otherwise, print the section information else { echo "\n"; echo $body."

\n"; echo "\n"; // if the body is over 4000 characters (that's approximately one screenful at 1024x768) if (strlen($body)>4000) { // give them a "back to the top" link echo "

Back to the top

\n"; } // also print a "back to the index" link for ease echo "

Back to the index"; } } echo "\n"; echo ""; } ?>