Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- function fetchXML($params = false) {
- // Are we overriding the default XML path calculation?
- if ($params !== false) {
- $address = $params;
- }
- // No? Didn't think so
- else {
- $address = substr($_SERVER['SCRIPT_NAME'], +1, -4);
- if (isset($_GET['category'])) {
- $address .= "/" . $_GET['category'];
- if (isset($_GET['subcategory'])) {
- $address .= "/" . $_GET['subcategory'];
- }
- if (isset($_GET['page'])) {
- $address .= "/" . $_GET['page'];
- }
- else {
- $address .= "/" . (isset($_GET['subcategory']) ? $_GET['subcategory'] : $_GET['category']) . "_index";
- }
- }
- else if (isset($_GET['page'])) {
- $address .= "/" . $_GET['page'];
- }
- else {
- $address .= "/" . $address . "_index";
- }
- }
- $address = "xml/" . $address . ".xml";
- //echo $address; //testing porpoises
- if (file_exists($address)) {
- $output = simplexml_load_file($address) or die("Error loading XML");
- }
- else {
- $output = false;
- }
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement