<?php include 'functions.php'; setXMLLocation(); $header = "loadURL: "; $url = $_GET['url']; logMessage("{$header} url={$url}"); $displayResults = ""; $fileExtension = pathinfo($url, PATHINFO_EXTENSION); if ($fileExtension == "xml") { logMessage("{$header} Determined that url: '{$url}' is attempting to " . "point to an xml file."); logMessage("{$header} Try to get local path from url: '{$url}'"); //$localPath = getLocalPathFromURL($url); $localPath = getPathToXMLFile($url); if (!file_exists($localPath)) { logMessage("{$header} Determined the desired file: '{$localPath}' " . "does not exist"); $displayResults = "File does not exist. Please check your path " . "and try again."; } else { logMessage("{$header} Attempt to load '{$localPath}' as xml"); $fileXML = simplexml_load_file($localPath); if ($fileXML != false) { $displayResults = getInnerContent($fileXML); } else { $displayResults = "Error found in the xml file that's " . "intending to be loaded. This can very " . "likely be due to syntax errors. (Remember " . "that the '&' character should be " . "represented as '&amp;')."; } } } else { $url = getSubstringOfAAfterOccuranceOfB(getLocalPathFromURL($url), "/www"); // Redirect to the url that was passed in logMessage("{$header} Since file extension was not xml, redirect to the " . "url that was passed in"); header("HTTP/1.1 307 Temporary Redirect");
/** * parses the config file * * @author Andrew Darwin <*****@*****.**> * @author Delvison Castillo */ function parseConfig() { global $configFileName; global $configXML; global $user; global $aclDict; global $restrictedDirectoriesDict; global $startPage; global $mainContentFilePath; global $defaultSecurityValue; global $ldapAddress; global $ldapPort; global $organizationalUnit1, $organizationalUnit2; global $organization, $countryNaming, $attr; global $useLDAP; global $defaultSecurityInLDAPAbsence; global $domainName; $logHeader = "parseConfig()"; //$pathToXMLFiles = getPathToXMLFiles(); $configFilePath = getPathToXMLFile($configFileName); logMessage("{$logHeader} configFilePath = {$configFilePath}"); $configXML = simplexml_load_file($configFilePath); logMessage("parseConfig() loaded config file and will now begin parsing"); //parse access_config $accessConfigXML = $configXML->access_config[0]; foreach ($accessConfigXML as $xmlElement) { $elementName = $xmlElement->getName(); if ($elementName == "acl") { $aclName = (string) $xmlElement->name; $groups = $xmlElement->group; $groupsArray = array(); foreach ($groups as $groupItem) { array_push($groupsArray, (string) $groupItem); } logMessage("{$logHeader} Encountered acl element with name = " . "{$aclName} and groups = " . getArrayString($groupsArray)); $tempArray = array((string) $aclName => $groupsArray); /*Had to cast $aclName to string here to avoid an illegal offset type warning*/ $aclDict = array_merge($aclDict, $tempArray); /* Had to use array_merge instead of array_push */ } else { if ($elementName == "restricted_directory") { $path = (string) $xmlElement->path; $acl_name = (string) $xmlElement->acl_name; logMessage("{$logHeader} Encountered restricted_directory element " . "with path = {$path} and acl_name = {$acl_name}"); $restrictedDirectoriesDict[$path] = $acl_name; } } } $siteConfigXML = $configXML->site_config[0]; foreach ($siteConfigXML as $xmlElement) { $elementName = $xmlElement->getName(); $stringValue = (string) $xmlElement; switch ($elementName) { case "start_page": $startPage = $stringValue; break; case "main_content": $mainContentFilePath = $stringValue; break; case "default_security": $defaultSecurityValue = $stringValue; break; case "domain_name": $domainName = $stringValue; break; } } $ldapConfigXML = $configXML->ldap_config[0]; foreach ($ldapConfigXML as $xmlElement) { $elementName = $xmlElement->getName(); $stringValue = getTrimmed((string) $xmlElement); switch ($elementName) { case "address": $ldapAddress = $stringValue; break; case "port": $ldapPort = $stringValue; break; case "organizational_unit1": $organizationalUnit1 = $stringValue; break; case "organizational_unit2": $organizationalUnit2 = $stringValue; break; case "organization": $organization = $stringValue; break; case "country_naming": $countryNaming = $stringValue; break; case "attribute": $attr = $stringValue; break; case "use_ldap": $useLDAP = $stringValue == "true"; break; case "default_security_in_ldap_absence": $defaultSecurityInLDAPAbsence = $stringValue; break; } } if (!$useLDAP) { $defaultSecurityValue = $defaultSecurityInLDAPAbsence; } logMessage("{$logHeader} finished parsing and produced aclDict = '" . getArrayString($aclDict) . "' and restrictedDirectoriesDict = '" . getArrayString($restrictedDirectoriesDict) . "'"); }