From 3ef0c43348c8f735bab740e4a9b7bf8df26fbb00 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 22 Apr 2009 12:49:48 +0000 Subject: Get rid of ereg/split, replaced by preg equivalents --- it.class | 4 ++-- it_browser.class | 6 +++--- it_debug.class | 6 +++--- it_mail.class | 10 +++++----- it_text.class | 2 +- it_url.class | 30 +++++++++++++++--------------- it_user.class | 6 +++--- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/it.class b/it.class index 13e286a..d8e4098 100644 --- a/it.class +++ b/it.class @@ -599,9 +599,9 @@ function getopt($helplines) if ($result['debug']) { - foreach (split('[.,]', $result['debug']) as $ultrad) + foreach (preg_split('/[.,]/', $result['debug']) as $ultrad) { - $ultravar = split('[-=:]', $ultrad); + $ultravar = preg_split('/[-=:]/', $ultrad); $GLOBALS["debug_$ultravar[0]"] = isset($ultravar[1]) ? $ultravar[1] : 1; } } diff --git a/it_browser.class b/it_browser.class index f46df92..d2d2673 100644 --- a/it_browser.class +++ b/it_browser.class @@ -62,7 +62,7 @@ function it_browser() /* $this->UserAgent = "Mozilla/4.0 [de] (compatible; MSIE 5.0; Windows 95; .NET CRL 2.0.154)"; */ /* Find "Mozilla/4.0" */ - if (ereg("([^/]*)/([^ ]*)", $this->UserAgent, $regs)) + if (preg_match("#([^/]*)/([^ ]*)#", $this->UserAgent, $regs)) { $this->Type = $regs[1]; $this->Version = (double)$regs[2]; @@ -74,7 +74,7 @@ function it_browser() $optattr = preg_split("/;\s+/", $regs[1]); if ($optattr[0] == "compatible") { - if (ereg("([^/]*)[/ ]([^/]*)", $optattr[1], $regs)) + if (preg_match("#([^/]*)[/ ]([^/]*)#", $optattr[1], $regs)) { $this->Type = $regs[1]; $this->Version = (double)$regs[2]; @@ -99,7 +99,7 @@ function it_browser() } /* Find optional "[de]" */ - if (!$this->Language && ereg("\[(.*)\]", $this->UserAgent, $regs)) + if (!$this->Language && preg_match("/\[(.*)\]/", $this->UserAgent, $regs)) $this->Language = $regs[1]; /* Check for Safari/KHTML */ diff --git a/it_debug.class b/it_debug.class index 4b0650a..e1766f3 100644 --- a/it_debug.class +++ b/it_debug.class @@ -80,7 +80,7 @@ function srcline($stackoffs = 0) */ function dump($args) { - if (ereg('(csv|txt|gif|jpg)', $_SERVER['PHP_SELF'])) + if (preg_match('/csv|txt|gif|jpg/', $_SERVER['PHP_SELF'])) $plain = 1; else if ($_SERVER['REMOTE_ADDR']) { @@ -136,7 +136,7 @@ function dump($args) { list (, $head, $classname, $values, $tail) = $regs; $classname = strtolower($classname); - $values = preg_replace("#'(\w+)' =>([^\n]+),#", 'var \$$1 = $2;', $values); + $values = preg_replace("#'(\w+)' =>\s*([^\n]+),#", 'var \$$1 = $2;', $values); $item = $head . "class $classname { $values }$tail"; } @@ -151,7 +151,7 @@ function dump($args) if (isset($_SERVER['REMOTE_ADDR']) && !$plain) $item = htmlspecialchars($item); - if (ereg('^[\'"]', $var)) + if (preg_match('/^[\'"]/', $var)) $r .= "$item "; else { $var = "$blue$var=$noblue"; diff --git a/it_mail.class b/it_mail.class index 9ab04bd..db3d9ea 100644 --- a/it_mail.class +++ b/it_mail.class @@ -197,7 +197,7 @@ function send() /* Automatically add doctype if none given */ - if ($this->body[IT_MAIL_HTML] && !eregi('^body[IT_MAIL_HTML])) + if ($this->body[IT_MAIL_HTML] && !preg_match('/^body[IT_MAIL_HTML])) { $this->body[IT_MAIL_HTML] = '' . "\n" . $this->body[IT_MAIL_HTML]; } @@ -344,7 +344,7 @@ function send_smtp_cmd($fp, $cmd, &$answer, $timeoutok = false, $failcode = 300) if (!$cmd || (!feof($fp) && fwrite($fp, "$cmd\r\n"))) { - while (!feof($fp) && ereg('^(...)(.?)(.*)$', fgets($fp, 1024), $regs)) + while (!feof($fp) && preg_match('/^(...)(.?)(.*)[\r\n]*$/', fgets($fp, 1024), $regs)) { $answer .= $regs[0]; $resultcode = intval($regs[1]); @@ -383,7 +383,7 @@ function check_email($email, $checkmailbox = true) $result = IT_MAIL_CHECKEMAIL_INVALID; /* Check if username starts with www. or not well-formed => reject */ - if (!ereg('^www\.', $email) && eregi('^[a-z0-9&_+.-]+@([a-z0-9.-]+\.[a-z]+)$', $email, $regs)) + if (!preg_match('/^www\./', $email) && preg_match('/^[a-z0-9&_+.-]+@([a-z0-9.-]+\.[a-z]+)$/i', $email, $regs)) { $domain = $regs[1]; @@ -423,7 +423,7 @@ function check_email($email, $checkmailbox = true) } } - if (eregi('@([a-z0-9.-]+\.[a-z]+)$', $from, $regs)) + if (preg_match('/@([a-z0-9.-]+\.[a-z]+)$/i', $from, $regs)) $fromdomain = $regs[1]; else $fromdomain = 'gna.ch'; @@ -452,7 +452,7 @@ function check_email($email, $checkmailbox = true) if (it_mail::send_smtp_cmd($fp, "RCPT TO: <$email>", $answer, $timeoutok, 500)) # 450 is often used for Greylisting $result = IT_MAIL_CHECKEMAIL_OK; - else if (eregi('quota|full|exceeded storage', $answer)) + else if (preg_match('/quota|full|exceeded storage/i', $answer)) $result = IT_MAIL_CHECKEMAIL_MAILBOXFULL; /* Do not try other MX if we got this far */ diff --git a/it_text.class b/it_text.class index cfbfa01..c82c750 100644 --- a/it_text.class +++ b/it_text.class @@ -138,7 +138,7 @@ function text($label, $language = null) } } - if ($GLOBALS['debug_texts'] && !eregi('submit|reset|button|_search$|service|claim', $label)) + if ($GLOBALS['debug_texts'] && !preg_match('/submit|reset|button|_search$|service|claim/i', $label)) $text = "1, 'skipfiles'=>"text|auto_prepend")) . ")'>" . ($text ? $text : $label) . ""; return $text; 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('