summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2009-04-22 12:49:48 +0000
committerChristian Schneider2009-04-22 12:49:48 +0000
commit3ef0c43348c8f735bab740e4a9b7bf8df26fbb00 (patch)
tree93c63c624528a013f0efcad223ac3b49cdf0f13f
parent414cc575912785ef15e4a26eb002bef1d0f739bf (diff)
downloaditools-3ef0c43348c8f735bab740e4a9b7bf8df26fbb00.tar.gz
itools-3ef0c43348c8f735bab740e4a9b7bf8df26fbb00.tar.bz2
itools-3ef0c43348c8f735bab740e4a9b7bf8df26fbb00.zip
Get rid of ereg/split, replaced by preg equivalents
-rw-r--r--it.class4
-rw-r--r--it_browser.class6
-rw-r--r--it_debug.class6
-rw-r--r--it_mail.class10
-rw-r--r--it_text.class2
-rw-r--r--it_url.class30
-rw-r--r--it_user.class6
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('^<!doctype', $this->body[IT_MAIL_HTML]))
+ if ($this->body[IT_MAIL_HTML] && !preg_match('/^<!doctype/i', $this->body[IT_MAIL_HTML]))
{
$this->body[IT_MAIL_HTML] = '<!doctype html public "-//w3c//dtd html 4.01 transitional//en">' . "\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 = "<span style='background:#8F8' title='$label (" . it_debug::backtrace(array('levels'=>1, 'skipfiles'=>"text|auto_prepend")) . ")'>" . ($text ? $text : $label) . "</span>";
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('<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";
diff --git a/it_user.class b/it_user.class
index 85c44bd..328819b 100644
--- a/it_user.class
+++ b/it_user.class
@@ -385,7 +385,7 @@ function is_valid_username($name)
{
if ((strlen($name) >= 2) && (strlen($name) <= 32))
{
- if (!ereg('["\'\\&\$+]', $name))
+ if (!preg_match('/["\'\\\\&$+]/', $name))
return true;
}
return false;
@@ -399,7 +399,7 @@ function is_valid_password($word)
{
if ((strlen($word) >= 2) && (strlen($word) <= 32))
{
- if (!ereg('["\'\\&\$+]', $word))
+ if (!preg_match('/["\'\\\\&$+]/', $word))
return true;
}
return false;
@@ -492,7 +492,7 @@ function check_url($withsession = false)
if (!empty($_SERVER['QUERY_STRING']))
{
- $url = ereg_replace("&?$this->urlauthenticationcode=[a-zA-Z0-9]*", '', $_SERVER['REQUEST_URI']);
+ $url = preg_replace("/&?$this->urlauthenticationcode=[a-zA-Z0-9]*/", '', $_SERVER['REQUEST_URI']);
$result = $this->check_signature($url, $GLOBALS[$this->urlauthenticationcode], $withsession);
}