diff options
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/it_url.class b/it_url.class index 0ee799a..5dcc757 100644 --- a/it_url.class +++ b/it_url.class @@ -60,7 +60,7 @@ function it_url($url, $options = array()) $this->pass = $regs[3]; $url = $regs[4]; } - else if (ereg('^[a-z]:', $url) || ereg('^/', $url)) + else if (preg_match('/^[a-z]:/', $url) || preg_match('#^/#', $url)) { $this->protocol = 'file'; } @@ -83,7 +83,7 @@ function it_url($url, $options = array()) else $pattern = '^([a-z0-9_:\.-]+)/*(.*)$'; - if (eregi($pattern, $url, $regs)) + if (preg_match("#$pattern#i", $url, $regs)) { list($hostname, $port) = explode(':', $regs[1]); @@ -100,7 +100,7 @@ function it_url($url, $options = array()) # Get rid of common index file names $url = preg_replace('#(^|/)(index\.[ps]?html?|index\.php[34]?|default\.aspx?)$#', '', $url); - $this->path = ereg_replace('^/$', '', $url); + $this->path = preg_replace('#^/$#', '', $url); if ($this->port != $protoport) $this->url = "$this->protocol://$this->realhostname:$this->port/$this->path"; @@ -138,23 +138,23 @@ function read_page($timeout = 0) ** If the URL does not contain a dot followed by at least one character, ** it is considered bogus. This prevents 'localhost', 'www', and numerical IP addresses. */ - if (!eregi('\.[a-z]+$', $this->realhostname)) + if (!preg_match('/\.[a-z]+$/i', $this->realhostname)) return 0; $url = $this->rawurl; while ($this->page == '') { - $cmd = 'LANG=C wget 2>&1 -T ' . ((int)$timeout) . ' -q -U "Mozilla/4.0 (Compatible; Relog ITools)" -O - ' . ereg_replace("[ \t]", '\\ ', escapeshellcmd("$url")); + $cmd = 'LANG=C wget 2>&1 -T ' . ((int)$timeout) . ' -q -U "Mozilla/4.0 (Compatible; Relog ITools)" -O - ' . preg_replace("/[ \t]/", '\\ ', escapeshellcmd("$url")); $this->page = `$cmd`; if ($this->page == '') /* An error occurred. Find out what it was. */ { - $cmd = 'LANG=C wget 2>&1 -T' . ((int)$timeout) . ' -v -U "Mozilla/4.0 (Compatible; Relog ITools)" -O - ' . ereg_replace("[ \t]", '\\ ', escapeshellcmd($url)); + $cmd = 'LANG=C wget 2>&1 -T' . ((int)$timeout) . ' -v -U "Mozilla/4.0 (Compatible; Relog ITools)" -O - ' . preg_replace("/[ \t]/", '\\ ', escapeshellcmd($url)); $error = `$cmd`; - if (eregi('Location: ([^ ]*)', $error, $regs)) /* Redirect ? */ + if (preg_match('/Location: ([^ ]*)/i', $error, $regs)) /* Redirect ? */ { $url = $regs[1]; - if (!eregi('^[a-z]+:', $url)) /* Kludge for Miss Kournikova's admirers: grok local redirects (in violation of RFC) */ + if (!preg_match('/^[a-z]+:/i', $url)) /* Kludge for Miss Kournikova's admirers: grok local redirects (in violation of RFC) */ $url = $this->rawurl.'/'.$url; } else @@ -167,10 +167,10 @@ function read_page($timeout = 0) $this->page_read = 1; - if (eregi('<title>([^<]*)</title>', $this->page, $regs)) + if (preg_match('#<title>([^<]*)</title>#i', $this->page, $regs)) $this->title = it_htmlentities_decode($regs[1]); - if (eregi('<meta name="description"[^>]+content="([^"]*)">', $this->page, $regs)) + if (preg_match('/<meta name="description"[^>]+content="([^"]*)">/i', $this->page, $regs)) $this->description = it_htmlentities_decode($regs[1]); return ($this->page != ''); @@ -213,7 +213,7 @@ function is_reachable($timeout = 5) fclose($fp); #debug("it_url::is_reachable($this->rawurl: $line"); - $result = eregi("^$this->protocol/[^ ]+ +[23]", $line); + $result = preg_match("#^$this->protocol/[^ ]+ +[23]#i", $line); } return $result; @@ -515,12 +515,12 @@ function absolute($url=null) if (!isset($url)) $url = $_SERVER['PHP_SELF']; - if (!ereg('^http', $url)) + if (!preg_match('/^http/', $url)) { - if (!ereg('//', $url)) + if (!preg_match('#//#', $url)) { - $dir = ereg_replace('/[^/]*$', '/', $_SERVER['PHP_SELF']); - $url = ereg('^/', $url) ? $url : "$dir$url"; + $dir = preg_replace('#/[^/]*$#', '/', $_SERVER['PHP_SELF']); + $url = preg_match('#^/#', $url) ? $url : "$dir$url"; $url = "//" . $_SERVER['HTTP_HOST'] . $url; } $url = "http" . (isset($_SERVER['HTTPS']) ? 's':'') . ":$url"; |