xmlFileContents = curl_exec($cu); if (curl_error($cu)) { $this -> error = "Error: ".curl_errno($cu).", ".curl_error($cu); return FALSE; } curl_close ($cu); return $this->xmlFileContents; } if(ini_get("allow_url_fopen")) { $old_timeout = e107_ini_set('default_socket_timeout', $timeout); $remote = @fopen ($address, "r"); e107_ini_set('default_socket_timeout', $old_timeout); if(!$remote) { $this -> error = "Unable to open remote XML file."; return FALSE; } } else { $tmp = parse_url($address); if(!$remote = fsockopen ($tmp['host'], 80 ,$errno, $errstr, $timeout)) { $this -> error = "Unable to open remote XML file."; return FALSE; } else { socket_set_timeout($remote, $timeout); fputs($remote, "GET ".urlencode($address)." HTTP/1.0\r\n\r\n"); } } $this -> xmlFileContents = ""; while (!feof($remote)) { $this->xmlFileContents .= fgets ($remote, 4096); } fclose ($remote); return $this->xmlFileContents; } function parseXml($xml='') { if($xml == '' && $this->xmlFileContents) { $xml = $this->xmlFileContents; } if(!$xml) { return false; } $xml = simplexml_load_string($xml); if(is_object($xml)) { $xml = (array)$xml; } $xml = $this->xml_convert_to_array($xml); return $xml; } function xml_convert_to_array($xml) { if(is_array($xml)) { foreach($xml as $k => $v) { if(is_object($v)) { $v = (array)$v; } $xml[$k] = $this->xml_convert_to_array($v); } if(count($xml) == 1 && isset($xml[0])) { $xml = $xml[0]; } } return $xml; } function loadXMLfile($fname='', $parse = false, $replace_constants = false) { if($fname == '') { return false; } $xml = false; if(strpos($filename, '://') !== false) { $this->getRemoteFile($fname); } else { if($xml = file_get_contents($fname)) { $this->xmlFileContents = $xml; } } if($this->xmlFileContents) { if($replace_constants == true) { global $tp; if(!is_object($tp)) { require_once('e_parse_class.php'); $tp = new e_parse; } $this->xmlFileContents = $tp->replaceConstants($this->xmlFileContents, '', true); } if($parse == true) { return $this->parseXML(); } else { return $this->xmlFileContents; } } return false; } } ?>