<?php
    
    
// This function retrieves the config file to be used by the modules.
    
    
function getConfig() {
        
        
// The xml string by default is our own config XML.
        
        
$xml 'wdlconfig.xml'$default $xml;
        
        
// If the user has an active session, set the xml variable to the url they have provided.
        
        
if(isset($_SESSION['xml'])) $xml $_SESSION['xml'];
        
        
// If a config xml url has been passed as a GET variable use that, (this is used in the KML module purely for the benefit of Google Maps).
        
        
if(isset($_GET['xml'])) $xml $_GET['xml'];
        
        
// This if statement checks if the file was successfully retrieved and that the last 3 characters of its url is 'xml'. Error reporting is disabled on the file_get_contents function.
        // If this statement returns false, the default xml config is used and an error is set as the xml session value.
        
        
if(substr($xml, -3) != 'xml' || !$data = @file_get_contents($xml)) {
            
$data file_get_contents($default);        // read the configuration file from the current directory
            
$_SESSION['xml'] = 'Error: Invalid Config XML Submitted.';
        }
        
        
// Returns the config file as an object.
        
        
return new simpleXMLElement($data);
    }

?>