Skip to content

Commit

Permalink
Replaced old ereg() uses with preg_match().
Browse files Browse the repository at this point in the history
  • Loading branch information
lux committed Jun 9, 2010
1 parent cd06549 commit 5008583
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion inc/app/siteinvoice/boxes/create/index.php
Expand Up @@ -57,7 +57,7 @@ function WriteHTML($html) {
$tag=strtoupper(array_shift($a2));
$prop=array();
foreach($a2 as $v)
if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3))
if(preg_match('/^([^=]*)=["\']?([^"\']*)["\']?$/',$v,$a3))
$prop[strtoupper($a3[1])]=$a3[2];
$this->OpenTag($tag,$prop);
}
Expand Down
12 changes: 6 additions & 6 deletions inc/app/siteinvoice/lib/PEAR/OS/Guess.php
Expand Up @@ -158,7 +158,7 @@ function parseSignature($uname = null)
case 'Linux' :
$extra = $this->_detectGlibcVersion();
// use only the first two digits from the kernel version
$release = ereg_replace('^([[:digit:]]+\.[[:digit:]]+).*', '\1', $parts[2]);
$release = preg_replace('/^(\d+\.\d+).*/', '\1', $parts[2]);
break;
case 'Mac' :
$sysname = 'darwin';
Expand All @@ -176,10 +176,10 @@ function parseSignature($uname = null)
$cpu = 'powerpc';
}
}
$release = ereg_replace('^([[:digit:]]+\.[[:digit:]]+).*', '\1', $parts[2]);
$release = preg_replace('/^(\d+\.\d+).*/', '\1', $parts[2]);
break;
default:
$release = ereg_replace('-.*', '', $parts[2]);
$release = preg_replace('/-.*/', '', $parts[2]);
break;
}

Expand Down Expand Up @@ -222,7 +222,7 @@ function _detectGlibcVersion()
unlink($tmpfile);
if (!($major && $minor) && is_link('/lib/libc.so.6')) {
// Let's try reading the libc.so.6 symlink
if (ereg('^libc-([.*])\.so$', basename(readlink('/lib/libc.so.6')), $matches)) {
if (preg_match('/^libc-([.*])\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
list($major, $minor) = explode('.', $matches);
}
}
Expand Down Expand Up @@ -292,8 +292,8 @@ function matchSignature($match)
function _matchFragment($fragment, $value)
{
if (strcspn($fragment, '*?') < strlen($fragment)) {
$reg = '^' . str_replace(array('*', '?', '/'), array('.*', '.', '\\/'), $fragment) . '$';
return eregi($reg, $value);
$reg = '/^' . str_replace(array('*', '?', '/'), array('.*', '.', '\\/'), $fragment) . '$/i';
return preg_match($reg, $value);
}
return ($fragment == '*' || !strcasecmp($fragment, $value));
}
Expand Down
2 changes: 1 addition & 1 deletion inc/app/sitellite/boxes/user/change/index.php
Expand Up @@ -78,7 +78,7 @@ function update_user ($username, $email, $company, $position, $website, $jabber_
if (empty($email))
return "No email address";

if (!ereg(".+@.+\..+", $email))
if (!preg_match("/.+@.+\..+/", $email))
return "Invalid email address";

// This probably has structure for being done elsewhere - nasty hard coding
Expand Down
2 changes: 1 addition & 1 deletion inc/app/sitellite/boxes/user/signup/index.php
Expand Up @@ -42,7 +42,7 @@

// Does this function belong in a seperate class or at least in a file in lib/ ?
function create_user ($email, $username, $password, $password_confirm, $firstname, $lastname) {
if (!ereg(".+@.+\..+", $email))
if (!preg_match("/.+@.+\..+/", $email))
return "Invalid email address";

if (empty($username))
Expand Down
1 change: 1 addition & 0 deletions install/changes.txt
Expand Up @@ -103,6 +103,7 @@ Changes in 5.0.3-stable
- Added script to fix existing boxes for Firefox 3.6 compatibility.
- Merged Professional Edition features into the main codebase.
- Merged Enterprise Edition features in the main codebase.
- Replaced old ereg() uses with preg_match().

Changes in 5.0.2-stable

Expand Down
6 changes: 3 additions & 3 deletions saf/lib/CGI/CGI.php
Expand Up @@ -359,7 +359,7 @@ function translateUri ($uri = '', $lose = '') {
// compile array of key.value pairs
foreach (split ('&', $params) as $p) {
if (! empty ($p)) {
array_push ($vars, ereg_replace ('=', '.', $p));
array_push ($vars, str_replace ('=', '.', $p));
}
}

Expand All @@ -368,8 +368,8 @@ function translateUri ($uri = '', $lose = '') {
if (empty ($p)) {
continue;
}
$start = ereg_replace ('/' . $p . '(\.?[^/]*)/', '/', $start);
$start = ereg_replace ('/' . $p . '(\.?[^/]*)/?$', '', $start);
$start = preg_replace ('/' . $p . '(\.?[^/]*)/', '/', $start);
$start = preg_replace ('/' . $p . '(\.?[^/]*)/?$', '', $start);
}
return $start . '/' . join ('/', $vars);
}
Expand Down
2 changes: 1 addition & 1 deletion saf/lib/Cache/Cache.php
Expand Up @@ -324,7 +324,7 @@ function expired ($file = '', $duration = 0) {
//echo "expired, so we generate a new time: $gmt_mtime\n";
if ($GLOBALS['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) {
//echo "send 'em a 304\n";
if (eregi ('^WIN', PHP_OS)) {
if (preg_match ('/^WIN/i', PHP_OS)) {
header ('Status: 304 Not Modified');
} else {
header ('HTTP/1.1 304 Not Modified');
Expand Down
8 changes: 4 additions & 4 deletions saf/lib/Date/Date.php
Expand Up @@ -233,9 +233,9 @@ function timestamp ($timestamp = '', $format = 'M j, Y h:i:s a') {
return intl_get ('Empty');
}
if (is_array ($format)) {
if (ereg ('^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$', $timestamp, $regs)) {
if (preg_match ('/^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$/', $timestamp, $regs)) {
$unix = mktime ($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
} elseif (ereg ('^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$', $timestamp, $regs)) {
} elseif (preg_match ('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/', $timestamp, $regs)) {
$unix = mktime ($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
} else {
return $timestamp;
Expand All @@ -252,9 +252,9 @@ function timestamp ($timestamp = '', $format = 'M j, Y h:i:s a') {
return localdate ($format['other'], $unix);
}
} else {
if (ereg ('^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$', $timestamp, $regs)) {
if (preg_match ('/^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$/', $timestamp, $regs)) {
return localdate ($format, mktime ($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]));
} elseif (ereg ('^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$', $timestamp, $regs)) {
} elseif (preg_match ('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/', $timestamp, $regs)) {
return localdate ($format, mktime ($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]));
} else {
return $timestamp;
Expand Down
4 changes: 2 additions & 2 deletions saf/lib/File/File.php
Expand Up @@ -253,10 +253,10 @@ function File ($abs_file_path = '', $www_file_path = '') {
$this->absolute = $abs_file_path;
if (@is_dir ($abs_file_path)) {
$this->extension = 'folder';
} elseif (ereg ("\.([^\.]+)$", $abs_file_path, $regs)) {
} elseif (preg_match ("/\.([^\.]+)$/", $abs_file_path, $regs)) {
$this->extension = $regs[1];
}
if (ereg ("([^\\/]+)$", $abs_file_path, $regs)) {
if (preg_match ("/([^\\/]+)$/", $abs_file_path, $regs)) {
$this->name = $regs[1];
}

Expand Down
4 changes: 2 additions & 2 deletions saf/lib/MailForm/Rule.php
Expand Up @@ -272,7 +272,7 @@ function _validate ($value, $form, $cgi) {
return false;
}
} elseif ($this->type == 'regex') {
if (! ereg ($this->value, $value)) {
if (! preg_match ($this->value, $value)) {
return false;
}
} elseif ($this->type == 'preg') {
Expand Down Expand Up @@ -380,7 +380,7 @@ function _validateNegated ($value, $form, $cgi) {
return false;
}
} elseif ($this->type == 'regex') {
if (ereg ($this->value, $value)) {
if (preg_match ($this->value, $value)) {
return false;
}
} elseif ($this->type == 'preg') {
Expand Down
2 changes: 1 addition & 1 deletion saf/lib/MailForm/Widget/Allow.php
Expand Up @@ -133,7 +133,7 @@ function getMods () {
$dir = new Dir (getcwd () . '/mod');
$files = $dir->read_all ();
foreach ($files as $file) {
if (ereg ("^\.+$", $file)) {
if (preg_match ("/^\.+$/", $file)) {
continue;
}
$module = new Module ($file);
Expand Down
8 changes: 4 additions & 4 deletions saf/lib/MailForm/Widget/Dirlist.php
Expand Up @@ -206,8 +206,8 @@ function display ($generate_html = 0) {
$dir->close ();
foreach ($list as $file) {
if (
(! eregi ('^\.ht', $file)) &&
(eregi ('\.(' . join ('|', $this->extensions) . ')$', $file) || count ($this->extensions) == 0) &&
(! preg_match ('/^\.ht/i', $file)) &&
(preg_match ('/\.(' . join ('|', $this->extensions) . ')$/i', $file) || count ($this->extensions) == 0) &&
($file != '.') &&
($file != '..')
) {
Expand All @@ -221,8 +221,8 @@ function display ($generate_html = 0) {
for ($i = 0; $i < count ($list); $i++) {
if (
(! @is_dir ($list[$i])) &&
(! eregi ('^\.ht', $list[$i])) &&
(eregi ('\.(' . join ('|', $this->extensions) . ')$', $list[$i]) || count ($this->extensions) == 0) &&
(! preg_match ('/^\.ht/i', $list[$i])) &&
(preg_match ('/\.(' . join ('|', $this->extensions) . ')$/i', $list[$i]) || count ($this->extensions) == 0) &&
($list[$i] != '.') &&
($list[$i] != '..')
) {
Expand Down
14 changes: 7 additions & 7 deletions saf/lib/Misc/Search.php
Expand Up @@ -112,31 +112,31 @@ function get_searchengine_keywords ($referer) {
$url = urldecode($referer);

// Google
if (eregi("www\.google",$url)) {
if (preg_match("/www\.google/i",$url)) {
preg_match("'(\?|&)q=(.*?)(&|$)'si", " $url ", $keywords);
}
// AllTheWeb
if (eregi("www\.alltheweb",$url)) {
if (preg_match("/www\.alltheweb/i",$url)) {
preg_match("'(\?|&)q=(.*?)(&|$)'si", " $url ", $keywords);
}
// MSN
if (eregi("search\.msn",$url)) {
if (preg_match("/search\.msn/i",$url)) {
preg_match("'(\?|&)q=(.*?)(&|$)'si", " $url ", $keywords);
}
// Yahoo
if ((eregi("yahoo\.com",$url)) or (eregi("search\.yahoo",$url))) {
if ((preg_match("/yahoo\.com/i",$url)) or (preg_match("search\.yahoo",$url))) {
preg_match("'(\?|&)p=(.*?)(&|$)'si", " $url ", $keywords);
}
// Looksmart
if (eregi("looksmart\.com",$url)) {
if (preg_match("/looksmart\.com/i",$url)) {
preg_match("'(\?|&)qt=(.*?)(&|$)'si", " $url ", $keywords);
}
// Ilse.nl
if (eregi("ilse\.nl",$url)) {
if (preg_match("/ilse\.nl/i",$url)) {
preg_match("'(\?|&)search_for=(.*?)(&|$)'si", " $url ", $keywords);
}
// Vinden.nl or zoeken.nl
if (eregi("(vinden\.nl|zoeken\.nl)",$url)) {
if (preg_match("/(vinden\.nl|zoeken\.nl)/i",$url)) {
preg_match("'(\?|&)query=(.*?)(&|$)'si", " $url ", $keywords);
}

Expand Down

0 comments on commit 5008583

Please sign in to comment.