function avatar_upload($remote, &$userinfo, $avatar_filename, $avatar) { require_once CORE_PATH . 'classes/cpg_file.php'; global $MAIN_CFG, $db, $lang; if ($remote) { if (!preg_match('/^(http:\\/\\/)?([\\w\\-\\.]+)\\:?([0-9]*)\\/(.*)$/', $avatar_filename, $url_ary) || empty($url_ary[4])) { cpg_error('The URL you entered is incomplete'); } $avatar = get_fileinfo($avatar_filename, !$MAIN_CFG['avatar']['animated'], true); if (!isset($avatar['size'])) { cpg_error(_AVATAR_ERR_DATA); } elseif ($avatar['animation'] && !$MAIN_CFG['avatar']['animated']) { cpg_error('Animated avatar not allowed'); } $avatar_filesize = $avatar['size']; $avatar_filetype = $avatar['type']; $imgtype = check_image_type($avatar_filetype); if ($avatar['size'] > 0 && $avatar['size'] < $MAIN_CFG['avatar']['filesize']) { $new_filename = $userinfo['user_id'] . '_' . uniqid(rand()) . $imgtype; $avatar_filename = $MAIN_CFG['avatar']['path'] . "/{$new_filename}"; if (CPG_File::write($avatar_filename, $avatar['data']) != $avatar['size']) { trigger_error('Could not write avatar to local storage', E_USER_ERROR); } } } else { $avatar_filesize = $avatar['size']; $avatar_filetype = $avatar['type']; $imgtype = check_image_type($avatar_filetype); $new_filename = $userinfo['user_id'] . '_' . uniqid(rand()) . $imgtype; $avatar_filename = $MAIN_CFG['avatar']['path'] . "/{$new_filename}"; if (!CPG_File::move_upload($avatar, $avatar_filename)) { trigger_error('Could not copy avatar to local storage', E_USER_ERROR); } if (!$MAIN_CFG['avatar']['animated'] && ($fp = fopen($avatar_filename, 'rb'))) { $data = fread($fp, $avatar_filesize); fclose($fp); $data = preg_split('/\\x00[\\x00-\\xFF]\\x00\\x2C/', $data); // split GIF frames if (count($data) > 2) { unlink($avatar_filename); cpg_error('Animated avatar not allowed'); } unset($data); } } if ($avatar_filesize < 40 || $avatar_filesize > $MAIN_CFG['avatar']['filesize']) { unlink($avatar_filename); cpg_error(sprintf(_AVATAR_FILESIZE, round($MAIN_CFG['avatar']['filesize'] / 1024))); } avatar_size($avatar_filename, true); avatar_delete($userinfo); return "user_avatar='{$new_filename}', user_avatar_type=1"; }
public static function read($url, $items_limit = 10) { /* <language>en-us</language> <pubDate>Sun, 23 Jan 2005 23:03:36 GMT</pubDate> <docs>http://backend.userland.com/rss</docs> */ $channeltags = array('title', 'link', 'description', 'language', 'generator', 'copyright', 'category', 'pubDate', 'managingEditor', 'webMaster', 'lastBuildDate', 'rating', 'docs', 'ttl'); $itemtags = array('title', 'link', 'description', 'author', 'category', 'comments', 'enclosure', 'guid', 'pubDate', 'source'); if (!($data = get_fileinfo($url, false, true))) { return false; } preg_match("#.*?encoding=[\\'\"](.*?)[\\'\"].*#si", $data['data'], $tag); $encoding = isset($tag[1]) ? strtoupper($tag[1]) : 'ISO-8859-1'; // Read CHANNEL info preg_match("'<channel.*?>(.*?)</channel>'si", $data['data'], $channel); // use IE work around for ', thanks to darkgrue $channel = str_replace(''', ''', $channel[1]); foreach ($channeltags as $channeltag) { $tag = CPG_RSS::get_tag($channeltag, $channel, $encoding); if (!empty($tag)) { $rss[$channeltag] = $tag; } } $rss['title'] = strip_tags(urldecode($rss['title'])); $rss['link'] = strip_tags($rss['link']); $rss['desc'] =& $rss['description']; if (isset($rss['ttl'])) { $rss['ttl'] = intval($rss['ttl']); // seconds } preg_match_all('#<item(| .*?)>(.*?)</item>#si', $data['data'], $items); $items = $items[2]; for ($i = 0; $i < $items_limit; $i++) { if (isset($items[$i]) && !empty($items[$i])) { $item = array(); foreach ($itemtags as $itemtag) { $tag = CPG_RSS::get_tag($itemtag, $items[$i], $encoding); if (!empty($tag)) { $item[$itemtag] = $tag; } } if (!empty($item)) { $item['title'] = strip_tags(urldecode($item['title'])); $item['link'] = isset($item['link']) ? strip_tags($item['link']) : ''; $item['desc'] =& $item['description']; $rss['items'][] = $item; } } } return $rss; }
function get_fileinfo($url, $detectAnim = false, $getdata = false, $lastmodified = 0) { $rdf = parse_url($url); if (!isset($rdf['host'])) { return false; } if (!isset($rdf['path'])) { $rdf['path'] = '/'; } if (!isset($rdf['port'])) { $rdf['port'] = 80; } if (!isset($rdf['query'])) { $rdf['query'] = ''; } elseif ($rdf['query'] != '') { $rdf['query'] = '?' . $rdf['query']; } $file = array('size' => 0, 'type' => '', 'date' => 0, 'animation' => false, 'modified' => true); if ($fp = fsockopen($rdf['host'], $rdf['port'], $errno, $errstr, 4)) { fputs($fp, 'GET ' . $rdf['path'] . $rdf['query'] . " HTTP/1.0\r\n"); fputs($fp, 'User-Agent: Dragonfly File Reader (' . URL::index('credits', true, true) . ")\r\n"); if ($lastmodified > 0) { fputs($fp, 'If-Modified-Since: ' . date('D, d M Y H:i:s \\G\\M\\T', $lastmodified) . "\r\n"); } if (GZIPSUPPORT) { fputs($fp, "Accept-Encoding: gzip;q=0.9\r\n"); } fputs($fp, "HOST: {$rdf['host']}\r\n\r\n"); $data = rtrim(fgets($fp, 300)); preg_match('#.* ([0-9]+) (.*)#i', $data, $head); // 301 = Moved Permanently, 302 = Found, 307 = Temporary Redirect if ($head[1] >= 301 && $head[1] <= 303 || $head[1] == 307) { while (!empty($data)) { $data = rtrim(fgets($fp, 300)); // read lines if (false !== stripos($data, 'Location: ')) { $new_location = trim(str_ireplace('Location: ', '', $data)); break; } } $head[2] .= $head[1] == 302 ? ' at' : ' to'; fputs($fp, "Connection: close\r\n\r\n"); fclose($fp); trigger_error("{$url} {$head['2']} <b>{$new_location}</b>", E_USER_WARNING); return get_fileinfo($new_location, $detectAnim, $getdata); } elseif ($lastmodified > 0 && $head[1] == 304) { # file isn't modifed since $lastmodified $file['modified'] = false; fputs($fp, "Connection: close\r\n\r\n"); fclose($fp); return $file; } elseif ($head[1] != 200) { fputs($fp, "Connection: close\r\n\r\n"); fclose($fp); trigger_error($url . "<br />{$data}", E_USER_WARNING); return false; } $file['utf8'] = $GZIP = false; // Read all headers while (!empty($data)) { $data = rtrim(fgets($fp, 300)); // read lines if (false !== stripos($data, 'Content-Length: ')) { $file['size'] = trim(str_ireplace('Content-Length: ', '', $data)); } elseif (false !== stripos($data, 'Content-Type: ')) { $file['type'] = trim(str_ireplace('Content-Type: ', '', $data)); } elseif (false !== stripos($data, 'Last-Modified: ')) { $file['date'] = trim(str_ireplace('Last-Modified: ', '', $data)); } $GZIP = $GZIP || 0 < preg_match('#Content-Encoding: (x-)?gzip#i', $data); $file['utf8'] = $file['utf8'] || false !== stripos($data, 'charset=utf-8'); } $data = ''; if ($getdata || $detectAnim && false !== strpos($file['type'], 'image/')) { while (!feof($fp)) { $data .= fread($fp, 1024); // read binary } if ($GZIP) { $data = gzinflate(substr($data, 10, -4)); } if ($getdata) { $file['data'] = $data; } // Animation detection thanks to PerM if ($detectAnim && false !== strpos($file['type'], 'image/')) { // if (preg_match('/NETSCAPE2.0/', $data)) $data = preg_split('/\\x00[\\x00-\\xFF]\\x00\\x2C/', $data); // split GIF frames $file['animation'] = count($data) > 2; // 1 = header, 2 = first/main frame } } fputs($fp, "Connection: close\r\n\r\n"); fclose($fp); } else { trigger_error($errstr, E_USER_WARNING); return false; } return $file; }
function saveuser(&$userinfo) { global $db, $user_prefix, $MAIN_CFG, $allowusertheme, $CPG_SESS, $SESS; $mode = isset($_POST['save']) ? $_POST['save'] : 'profile'; if ($mode == 'admin' && !defined('ADMIN_PAGES')) { $mode = 'profile'; } if ($mode == 'profile') { $section = 'section=1 OR section=2'; } elseif ($mode == 'private') { $section = 'section=3'; } elseif ($mode == 'prefs') { $section = 'section=5'; } $sql = $pass_change = false; if ($mode == 'reg_details') { global $allowmailchange; $current_password = isset($_POST['current_password']) ? md5($_POST['current_password']) : ''; if (isset($_POST['new_password'])) { $new_password = $_POST['new_password']; $verify_password = isset($_POST['verify_password']) ? $_POST['verify_password'] : ''; if ($new_password != $verify_password) { cpg_error(_PASSDIFFERENT, 'ERROR: Password mismatch'); } elseif ($new_password != '') { if (strlen($new_password) < $MAIN_CFG['member']['minpass']) { cpg_error(_YOUPASSMUSTBE . ' <b>' . $MAIN_CFG['member']['minpass'] . '</b> ' . _CHARLONG, 'ERROR: Password too short'); } $new_password = md5($new_password); if ($new_password != $userinfo['user_password']) { if (!defined('ADMIN_PAGES') && $current_password != $userinfo['user_password']) { cpg_error('Password incorrect'); } $sql = " user_password='******'"; $pass_change = true; } } } $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : $userinfo['user_email']; if (($allowmailchange || defined('ADMIN_PAGES')) && $user_email != $userinfo['user_email']) { if ($current_password != $userinfo['user_password'] && !defined('ADMIN_PAGES')) { cpg_error('Password incorrect'); } if (is_email($user_email) < 1) { cpg_error(_ERRORINVEMAIL); } if ($sql) { $sql .= ', '; } $sql .= "user_email='{$user_email}'"; } if (defined('ADMIN_PAGES') && isset($_POST['username']) && $_POST['username'] != $userinfo['username']) { if (preg_match('#(\\ |\\*|#|\\\\|%|"|\'|`|&|\\^|@)', $_POST['username'])) { cpg_error(_ERRORINVNICK); } if ($db->sql_count($user_prefix . '_users u, ' . $user_prefix . '_users_temp t', "u.username='******'username']}' OR t.username='******'username']}' LIMIT 1") > 0) { cpg_error(_NICKTAKEN); } if ($sql) { $sql .= ', '; } $sql .= "username='******'username']}'"; } } elseif ($mode == 'avatar') { require_once 'modules/' . basename(dirname(__FILE__)) . '/avatars.php'; // Local avatar? $avatar_local = isset($_POST['user_avatar']) ? $_POST['user_avatar'] : ''; // Remote avatar? $avatar_remoteurl = !empty($_POST['avatarremoteurl']) ? htmlprepare($_POST['avatarremoteurl']) : ''; // Upload avatar thru remote or upload? $avatar_upload = !empty($_POST['avatarurl']) ? trim($_POST['avatarurl']) : (!empty($_FILES['avatar']) && $_FILES['avatar']['tmp_name'] != "none" ? $_FILES['avatar']['tmp_name'] : ''); $avatar_name = !empty($_FILES['avatar']['name']) ? $_FILES['avatar']['name'] : ''; // 0 = USER_AVATAR_NONE if (isset($_POST['avatardel']) || $avatar_local == '') { $sql = avatar_delete($userinfo); } // 1 = USER_AVATAR_UPLOAD if ((!empty($avatar_upload) || !empty($avatar_name)) && $MAIN_CFG['avatar']['allow_upload']) { if (!empty($avatar_upload)) { $sql = avatar_upload(empty($avatar_name), $userinfo, $avatar_upload, $_FILES['avatar']); } elseif (!empty($avatar_name)) { cpg_error(sprintf(_AVATAR_FILESIZE, round($MAIN_CFG['avatar']['filesize'] / 1024)), 'ERROR: Filesize'); } } elseif ($avatar_remoteurl != $userinfo['user_avatar'] && $avatar_remoteurl != '' && $MAIN_CFG['avatar']['allow_remote']) { if (!preg_match('#^(http)|(ftp):\\/\\/#i', $avatar_remoteurl)) { $avatar_remoteurl = 'http://' . $avatar_remoteurl; } if (preg_match('#^((http)|(ftp):\\/\\/[\\w\\-]+?\\.([\\w\\-]+\\.)+[\\w]+(:[0-9]+)*\\/.*?\\.(gif|jpg|jpeg|png)$)#is', $avatar_remoteurl)) { if (in_array('getimagesize', explode(',', ini_get('disable_functions'))) || ini_get('disable_functions') == 'getimagesize') { cpg_error('getimagesize is disabled', _AVATAR_ERR_URL); } elseif (!getimagesize($avatar_remoteurl)) { cpg_error('Image has wrong filetype', _AVATAR_ERR_URL); } elseif (!($file_data = get_fileinfo($avatar_remoteurl, !$MAIN_CFG['avatar']['animated']))) { cpg_error(_AVATAR_ERR_URL); } elseif ($file_data['size'] > $MAIN_CFG['avatar']['filesize']) { cpg_error(sprintf(_AVATAR_FILESIZE, round($MAIN_CFG['avatar']['filesize'] / 1024))); } elseif (!$MAIN_CFG['avatar']['animated'] && $file_data['animation']) { cpg_error('Animated avatar not allowed'); } if (avatar_size($avatar_remoteurl)) { avatar_delete($userinfo); $sql = "user_avatar='{$avatar_remoteurl}', user_avatar_type=2"; } } else { cpg_error('Image has wrong filetype', 'ERROR: Image filetype'); } } elseif ($avatar_local != $userinfo['user_avatar'] && $avatar_local != '' && $MAIN_CFG['avatar']['allow_local'] && file_exists($MAIN_CFG['avatar']['gallery_path'] . '/' . $avatar_local)) { avatar_delete($userinfo); $sql = "user_avatar='{$avatar_local}', user_avatar_type=3"; } } elseif ($mode == 'admin') { $sql = 'user_allow_pm=' . intval($_POST['user_allow_pm']) . ', user_allowavatar=' . intval($_POST['user_allowavatar']) . ', user_rank=' . intval($_POST['user_rank']); $suspendreason = isset($_POST['suspendreason']) ? $_POST['suspendreason'] : 'no reason'; if ($_POST['suspendreason'] != $userinfo['susdel_reason']) { $sql .= ', susdel_reason=\'' . Fix_Quotes($suspendreason) . "'"; } if (intval($_POST['user_suspend']) == 0 && $userinfo['user_level'] == 0) { $sql .= ', user_level=1'; } elseif (intval($_POST['user_suspend']) > 0 && $userinfo['user_level'] > 0) { $message = _SORRYTO . ' ' . $MAIN_CFG['global']['sitename'] . ' ' . _HASSUSPEND; if ($suspendreason > '') { $message .= "\n\n" . _SUSPENDREASON . "\n{$suspendreason}"; } $from = 'noreply@' . str_replace('www.', '', $MAIN_CFG['server']['domain']); if (!send_mail($mailer_message, $message, 0, _ACCTSUSPEND, $userinfo['user_email'], $userinfo['username'], $from)) { trigger_error($mailer_message, E_USER_WARNING); } $sql .= ', user_level=0, susdel_reason=\'' . Fix_Quotes($suspendreason) . "'"; } } else { $result = $db->sql_query('SELECT field, type FROM ' . $user_prefix . '_users_fields WHERE ' . $section); if ($db->sql_numrows($result) > 0) { while ($row = $db->sql_fetchrow($result)) { $field = $row['field'] == 'name' ? 'realname' : $row['field']; $value = Fix_Quotes($_POST[$field], 1); if ($row['field'] == 'user_lang' && !$MAIN_CFG['global']['multilingual']) { continue; } if ($row['type'] == 1 || $row['type'] == 4) { $value = intval($value); } else { if ($field == 'user_website') { if (!preg_match('#^http[s]?:\\/\\/#i', $value)) { $value = 'http://' . $value; } if (!preg_match('#^(http[s]?\\:\\/\\/)?([a-z0-9\\-\\.]+)?[a-z0-9\\-]+\\.[a-z]{2,4}$#i', $value)) { $value = ''; } } } if ($row['type'] == 7 && !$allowusertheme) { $value = $MAIN_CFG['global']['Default_Theme']; } if ($row['type'] == 6) { $value = date_raw($value); if (checkdate(substr($value, 4, 2), substr($value, 6, 2), substr($value, 0, 4))) { $sql .= ", {$row['field']}='{$value}'"; } } elseif (array_key_exists($row['field'], $userinfo) && $userinfo[$row['field']] != $value) { $sql .= ", {$row['field']}='{$value}'"; } if ($field == 'user_timezone') { $sql .= ', user_dst=' . intval($_POST['user_dst']); } } if ($sql) { $sql = substr($sql, 2); } } } if ($sql) { $db->sql_query('UPDATE ' . $user_prefix . '_users SET ' . $sql . " WHERE user_id=" . intval($userinfo['user_id'])); $_SESSION['CPG_USER'] = false; unset($_SESSION['CPG_USER']); if (!defined('ADMIN_PAGES')) { if ($pass_change) { global $CLASS; $CLASS['member']->setmemcookie($userinfo['user_id'], $userinfo['username'], $new_password); } if (isset($_POST['theme']) && $allowusertheme) { $CPG_SESS['theme'] = $_POST['theme']; unset($CPG_SESS['prevtheme']); } cpg_error(_TASK_COMPLETED, _TB_INFO, URL::index('&edit=' . $mode)); } else { cpg_error(_TASK_COMPLETED, _TB_INFO, URL::admin('users&mode=edit&edit=' . $mode . '&id=' . $userinfo['user_id'])); } } if (!defined('ADMIN_PAGES')) { URL::redirect(URL::index('&edit=' . $mode)); } else { cpg_error('Nothing changed', 'No update', URL::admin('users&mode=edit&edit=' . $mode . '&id=' . $userinfo['user_id'])); } }
?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $_SERVER['HTTP_HOST']; ?> HLTV Demos</title> </head> <body> <h1>HLTV Demos</h1> <p>You can download HLTV demo by clicking filename link.</p> <p>timestamp | filename | filesize | timelength</p> <ul> <?php foreach (get_fileinfo() as $file) { echo '<li>'; echo date('Y-m-d H:i:s', $file['timestamp']); echo ' | '; echo a($file['name']); echo ' | '; echo $file['size']; echo ' | '; echo get_timelength($file['timestamp'], parse_filename2timestamp($file['name'])); echo '</li>'; echo PHP_EOL; } ?> </ul> <hr /> <center>© 2009 <a href="http://vaduz.tk">vaduz.tk</a></center>
'; require 'header.php'; GraphicAdmin('_AMENU1'); if (!extension_loaded('xml')) { cpg_error('At this stage the XML extension is required but unfortunately your PHP installation does not load the extension.<br /> Read the <a href="http://www.php.net/manual/en/xml.installation.php">PHP Documentation</a> for more infos.'); } echo ' <input type="button" value="Reload Package List" onClick="window.location.reload()"> '; $xmllastmod = 0; $xml = BASEDIR . 'cache/plugins_xml.php'; if (file_exists($xml)) { $xmllastmod = filemtime($xml); } $xml = get_fileinfo('http://dragonflycms.org/plugins.php', false, true, $xmllastmod); if ($xml['modified'] === true) { Cache::array_save('xml', 'plugins', $xml); } else { Cache::array_load('xml', 'plugins', true); } //$xml['data'] = decode_bb_all($xml['data'], 0 , true); $xmlDOM = new DOMDocument(); $xmlDOM->preserveWhiteSpace = false; $xmlDOM->loadXML($xml['data']); $data = array(); $items = $xmlDOM->getElementsByTagname('item'); foreach ($items as $item) { $tmp = array(); $nodes = $item->childNodes; for ($n = 0; $n < $nodes->length; ++$n) {
function add_link($title, $url, $auth_name, $cat, $description, $email) { global $weblinks_config, $linksprefix, $db, $userinfo, $PHPMAILER_LANG; require_once 'header.php'; menu(1); echo '<br />'; OpenTable(); list($numrows) = $db->sql_ufetchrow("SELECT COUNT(*) FROM " . $linksprefix . "_links WHERE url='{$url}'"); if ($numrows > 0) { trigger_error(_LINKALREADYEXT, E_USER_ERROR); } else { if (is_user()) { $submitter = $userinfo['username']; } else { $submitter = decode_ip($userinfo['user_ip']); } // Check if Title exists if ($title == '') { trigger_error(_LINKNOTITLE, E_USER_ERROR); } elseif ($url == '' || $url == 'http://') { trigger_error(_LINKNOURL, E_USER_ERROR); } elseif ($description == '') { trigger_error(_LINKNODESC, E_USER_ERROR); } else { $title = Fix_Quotes($title); /* Check if URL is valid 1/28/2005 1:25PM */ /* $checkweblinks is from modules/Web_Links/l_config.php */ if ($weblinks_config['checkweblinks']) { $url = !empty($url) && get_fileinfo($url) ? Fix_Quotes($url) : trigger_error(sprintf(_ERROR_NO_EXIST, $url), E_USER_ERROR); } $description = Fix_Quotes($description); $auth_name = Fix_Quotes($auth_name); /* Check if email is valid 1/28/2005 1:31PM*/ if (!empty($email)) { $email = is_email($email) ? Fix_Quotes($email) : trigger_error($PHPMAILER_LANG['from_failed'] . $email, E_USER_ERROR); } $db->sql_query("INSERT INTO " . $linksprefix . "_newlink (lid, cid, title, url, description, name, email, submitter) VALUES (NULL, '{$cat}', '{$title}', '{$url}', '{$description}', '{$auth_name}', '{$email}', '{$submitter}')"); echo '<b>' . _LINKRECEIVED . '</b><br />'; echo empty($email) ? _EMAILWHENADD : _CHECKFORIT; } } CloseTable(); }
$git_version = file_get_contents(CORE_PATH . 'nexos_version'); echo 'Git ' . _VERSION . ": {$git_version}"; } echo '</div>'; CloseTable(); echo '<br />'; if (can_admin() && $MAIN_CFG['global']['update_monitor']) { if (!isset($CPG_SESS['update_monitor'])) { $CPG_SESS['update_monitor'] = false; } if ($CPG_SESS['update_monitor']) { $CPG_SESS['update_monitor'] = Cache::array_load('data', 'update_monitor', true); } if (!$CPG_SESS['update_monitor']) { $update_url = 'http://69.57.185.107/update.php?vers=' . CPG_NUKE; $updinfo = get_fileinfo($update_url, false, true); if ($updinfo) { $items = preg_split('#(<item>)#s', $updinfo['data'], -1, PREG_SPLIT_NO_EMPTY); unset($updinfo); $curvers = preg_replace('#^(.*)<version>(.*)</version>(.*)#s', '\\2', $items[0], 1); $upgurl = preg_replace('#^(.*)<url>(.*)</url>(.*)#s', '\\2', $items[0], 1); unset($items[0]); $data = array('current' => $curvers, 'url' => $upgurl, 'num' => count($items), 'msg' => array()); foreach ($items as $item) { if (!empty($item)) { $alrt_vers = preg_replace('#(.*)<version>(.*)</version>(.*)#s', '\\2', $item); $alrt_title = preg_replace('#(.*)<title>(.*)</title>(.*)#s', '\\2', $item); $alrt_desc = preg_replace('#(.*)<description>(.*)</description>(.*)#s', '\\2', $item); $alrt_date = preg_replace('#(.*)<date>(.*)</date>(.*)#s', '\\2', $item); $data['msg'][] = array('vers' => $alrt_vers, 'title' => $alrt_title, 'desc' => $alrt_desc, 'date' => $alrt_date); }
public function Load() { # Check if URL exists if ($this->URL == '') { $this->LastError = self::ERR_NO_URL_SPECIFIED; return false; } if (ereg('://', $this->URL)) { $data = get_fileinfo($this->URL); if (!isset($data['data'])) { $this->LastError = self::ERR_NO_URL_SPECIFIED; return false; } $data = $data['data']; } else { if (ereg('\\.\\.', $this->URL) || preg_match("/[*?\"<>|]/i", $this->URL) || !file_exists($this->URL)) { $this->LastError = self::ERR_NO_URL_SPECIFIED; return false; } $data = file_get_contents($this->URL); } # Read in file (line by line) if (empty($data)) { $this->LastError = self::ERR_READ_FROM_URL_FAILED; return false; } # Remove Byte-Order-Mark (BOM) if existing # (needed to avoid problems on some PHP versions) # UNCOMMENT THIS LINE IF YOU HAVE PROBLEMS WITH PAD FILES WITH A BOM # $data = substr($data, strpos($data, '<')); # Parse the raw XML into Nodes if (!$this->Parse($data)) { $this->LastError = self::ERR_PARSE_ERROR; return false; } # Succeeded $this->LastError = 0; return true; }