i need help to edit this PHP script. Currently it looks for the most recent XML file on the local server, but I wish to make it load a specific XML file from another server.
define('XML_LOCATION', "../"); //relative to this file
…
…
function load_xpath($dir=XML_LOCATION) {
if ($_REQUEST[SORTORDER] == DEFAULTSORT) {
//$dom = new DOMDocument;
//$dom->load($this->latest_xml_file($dir));
$dom = $this->load_xslt($this->latest_xml_file($dir), $this->xslprops[LENGTHDESC][XSL], $this->xslprops[LENGTHDESC][SORT]);
}
else {
$dom = $this->load_xslt($this->latest_xml_file($dir), $this->xslprops[$_REQUEST[SORTORDER]][XSL], $this->xslprops[$_REQUEST[SORTORDER]][SORT]);
}
$xp = new DOMXPath($dom);
$xp->registerNamespace(NS, "http://www.starstandard.org/STAR/5");
return($xp);
}
function load_xslt($xml, $xsl="", $sort_order="ascending") {
$domxml = new DOMDocument;
$domxsl = new DOMDocument;
if ($domxml->load($xml) && $domxsl->load($xsl)) {
//if ($domxml->loadXML($xml) & $domxsl->loadXML($xsl)) {
$proc = new XSLTProcessor();
$proc->importStylesheet($domxsl);
$proc->setParameter(NS, 'sortorder', $sort_order);
return $proc->transformToDoc($domxml);
}
else {
//TODO: decide on error out method
}
}
function latest_xml_file ($dir=XML_LOCATION) {
$xml_list = array();
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (preg_match('/.*\.xml$/i', $file)) {
array_push ($xml_list, $dir.$file);
}
}
closedir($dh);
}
}
rsort($xml_list);
return $xml_list[0];
}
Im sure a whole lot of that code is not needed, as I dont need it to work out the most recent file, just load in an external file.
For example: https://services.boatwizard.com/bridge/events/ae0324ff-e1a5-4a77-9783-f41248bfa975/boats would be the external XML.
I dont really know php or xml… but im sure if someone can help me change the code it would all work fine !!
Thanks
Something like this:
}