else {
$header = $this->get_translation_number(0);
- if (eregi("plural-forms: (.*)\n",$header,$regs)) {
+ if (preg_match('/plural-forms: (.*)\n/i',$header,$regs)) {
$expr = $regs[1];
} else {
$expr = "nplurals=2; plural=n == 1 ? 0 : 1;";
(#2796007).
- Removed the shut down DSBL blocklists (#2796734).
- Fixed broken RFC1918 reference in contrib/.htaccess and doc/.htaccess (#2798839).
+ - Stop using deprecated ereg functions. (#2820952)
Version 1.5.1 (branched on 2006-02-12)
--------------------------------------
* TODO: regexp search is supported only in local_file backend.
* Do we check format of regexp or ignore errors?
*/
- // errors on eregi call are suppressed in order to prevent display of regexp compilation errors
- if(@eregi($expr, $line)) {
+ // errors on preg_match call are suppressed in order to prevent display of regexp compilation errors
+ if(@preg_match('/' . $expr . '/i', $line)) {
array_push($res, array('nickname' => $row[0],
'name' => $this->fullname($row[1], $row[2]),
'firstname' => $row[1],
$this->quotevalue((!empty($userdata['label'])?$userdata['label']:''));
/* Strip linefeeds */
- $data = ereg_replace("[\r\n]", ' ', $data);
+ $nl_str = array("\r","\n");
+ $data = str_replace($nl_str, ' ', $data);
/**
* Make sure that entry fits into allocated record space.
function quotevalue($value) {
/* Quote the field if it contains | or ". Double quotes need to
* be replaced with "" */
- if(ereg("[|\"]", $value)) {
+ if(stristr('"', $value) || stristr('|', $value)) {
$value = '"' . str_replace('"', '""', $value) . '"';
}
return $value;
}
/* Blocks use of space, :, |, #, " and ! in nickname */
- if (eregi('[ \\:\\|\\#\\"\\!]', $userdata['nickname'])) {
+ if (preg_match('/[ :|#"!]/', $userdata['nickname'])) {
$this->error = _("Nickname contains illegal characters");
return false;
}
return false;
}
- if (eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) {
+ if (preg_match('/[: |#"!]/', $userdata['nickname'])) {
$this->error = _("Nickname contains illegal characters");
return false;
}
//FIXME: or at least we can move this hook up to the top of this file where $FileExtensionToMimeType is defined. What else is this hook here for? What plugins use it?
do_hook('attachment_common-load_mime_types', $null);
- ereg('\\.([^\\.]+)$', $Args[6], $Regs);
+ preg_match('/\.([^.]+)$/', $Args[7], $Regs);
+
+ $Ext = '';
+ if (is_array($Regs) && isset($Regs[1])) {
+ $Ext = $Regs[1];
+ }
$Ext = strtolower($Regs[1]);
/** lets see if we CAN move folders to the trash.. otherwise,
** just delete them **/
- if ($delete_folder || eregi('^'.$trash_folder.'.+', $folder_name) ) {
+ if ($delete_folder || preg_match('/^' . $trash_folder . '.+/i', $folder_name) ) {
$can_move_to_trash = FALSE;
} else {
/* Otherwise, check if trash folder exits and support sub-folders */
global $imap_asearch_months;
$what = trim($what);
- $what = ereg_replace('[ /\\.,]+', '-', $what);
+ $what = preg_replace('/[ \/\\.,]+/', '-', $what);
if ($what) {
preg_match('/^([0-9]+)-+([^\-]+)-+([0-9]+)$/', $what, $what_parts);
if (count($what_parts) == 4) {
default:
case 'anum':
$what = str_replace(' ', '', $what);
- $what = ereg_replace('[^0-9]+[^KMG]$', '', strtoupper($what));
+ $what = preg_replace('/[^0-9]+[^KMG]$/', '', strtoupper($what));
if ($what != '') {
switch (substr($what, -1)) {
case 'G':
$criteria = $opcode . ' ' . sqimap_asearch_encode_string($what, $charset) . ' ';
break;
case 'asequence':
- $what = ereg_replace('[^0-9:\(\)]+', '', $what);
+ $what = preg_replace('/[^0-9:()]+/', '', $what);
if ($what != '')
$criteria = $opcode . ' ' . $what . ' ';
break;
* TODO: remove this in favour of the information from sqimap_get_namespace()
*/
$read = sqimap_run_command($imap_stream, 'NAMESPACE', true, $a, $b);
- if (eregi('\\* NAMESPACE +(\\( *\\(.+\\) *\\)|NIL) +(\\( *\\(.+\\) *\\)|NIL) +(\\( *\\(.+\\) *\\)|NIL)', $read[0], $data)) {
- if (eregi('^\\( *\\((.*)\\) *\\)', $data[1], $data2)) {
+ if (preg_match('/\* NAMESPACE +(\( *\(.+\) *\)|NIL) +(\( *\(.+\) *\)|NIL) +(\( *\(.+\) *\)|NIL)/i', $read[0], $data)) {
+ if (preg_match('/^\( *\((.*)\) *\)/', $data[1], $data2)) {
$pn = $data2[1];
}
$pna = explode(')(', $pn);
$ns_strings = array(1=>'personal', 2=>'users', 3=>'shared');
$namespace = array();
- if(ereg('NAMESPACE (\(\(.*\)\)|NIL) (\(\(.*\)\)|NIL) (\(\(.*\)\)|NIL)', $input, $regs) !== false) {
+ if (preg_match('/NAMESPACE (\(\(.*\)\)|NIL) (\(\(.*\)\)|NIL) (\(\(.*\)\)|NIL)/', $input, $regs)) {
for($i=1; $i<=3; $i++) {
if($regs[$i] == 'NIL') {
$namespace[$ns_strings[$i]] = array();
*/
function sqimap_encode_mailbox_name($what)
{
- if (ereg("[\"\\\r\n]", $what))
+ if (preg_match('/["\\\r\n]/', $what))
return '{' . strlen($what) . "}\r\n" . $what; /* 4.3 literal form */
return '"' . $what . '"'; /* 4.3 quoted string form */
}
} while($topline && ($topline[0] == '*') && !preg_match('/\* [0-9]+ FETCH.*/i', $topline)) ;
$wholemessage = implode('', $data);
- if (ereg('\\{([^\\}]*)\\}', $topline, $regs)) {
+ if (preg_match('/\{([^\}]*)\}/', $topline, $regs)) {
$ret = substr($wholemessage, 0, $regs[1]);
/* There is some information in the content info header that could be important
* in order to parse html messages. Let's get them here.
// if ($ret{0} == '<') {
// $data = sqimap_run_command ($imap_stream, "FETCH $id BODY[$ent_id.MIME]", true, $response, $message, TRUE);
// }
- } else if (ereg('"([^"]*)"', $topline, $regs)) {
+ } else if (preg_match('/"([^"]*)"/', $topline, $regs)) {
$ret = $regs[1];
} else if ((stristr($topline, 'nil') !== false) && (empty($wholemessage))) {
$ret = $wholemessage;
$filename =
call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_downloadfilename', $filename, $HTTP_USER_AGENT);
} else {
- $filename = ereg_replace('[\\/:\*\?"<>\|;]', '_', str_replace(' ', ' ', $filename));
+ $filename = preg_replace('/[\\\/:*?"<>|;]/', '_', str_replace(' ', ' ', $filename));
}
// A Pox on Microsoft and it's Internet Explorer!
}
}
- ereg("^([\t >]*)([^\t >].*)?$", $line, $regs);
+ preg_match('/^([\t >]*)([^\t >].*)?$/', $line, $regs);
$beginning_spaces = $regs[1];
if (isset($regs[2])) {
$words = explode(' ', $regs[2]);
$addresses = array();
/* Find all the email addresses in the body */
- while(eregi($Email_RegExp_Match, $sbody, $regs)) {
+ while (preg_match('/' . $Email_RegExp_Match . '/i', $sbody, $regs)) {
$addresses[$regs[0]] = strtr($regs[0], array('&' => '&'));
$start = strpos($sbody, $regs[0]) + strlen($regs[0]);
$sbody = substr($sbody, $start);
$url = substr($body, $target_pos, $end-$target_pos);
/* Needed since lines are not passed with \n or \r */
- while ( ereg("[,\.]$", $url) ) {
+ while ( preg_match('/[,.]$/', $url) ) {
$url = substr( $url, 0, -1 );
$end--;
}
$addresses = array();
/* Find all the email addresses in the body */
- while (eregi($Email_RegExp_Match, $string, $regs)) {
+ while (preg_match('/' . $Email_RegExp_Match . '/i', $string, $regs)) {
$addresses[$regs[0]] = strtr($regs[0], array('&' => '&'));
$start = strpos($string, $regs[0]) + strlen($regs[0]);
$string = substr($string, $start);
$SQSPELL_WORDS_FILE =
getHashedFile($username, $data_dir, "$username.words");
-/**
- * Function used for checking words in user's dictionary
- * @global string $SQSPELL_EREG
- * @deprecated It is not used since 1.5.1 (sqspell 0.5)
- */
-$SQSPELL_EREG = 'ereg';
if (!$r) {
/* Remove backend name from error string */
$errstr = $abook->error;
- $errstr = ereg_replace('^\[.*\] *', '', $errstr);
+ $errstr = preg_replace('/^\[.*\] */', '', $errstr);
$formerror = $errstr;
$showaddrlist = false;
for ($i=1; $i < count($read); $i++) {
$line = htmlspecialchars($read[$i]);
switch (true) {
- case (eregi("^>", $line)):
+ case (preg_match('/^>/i', $line)):
$second[$i] = $line;
$first[$i] = ' ';
$cnum++;
break;
- case (eregi("^[ |\t]", $line)):
+// FIXME: is the pipe character below a mistake? I think the original author might have thought it carried special meaning in the character class, which it does not... but then again, I am not currently trying to understand what this code actually does
+ case (preg_match('/^[ |\t]/', $line)):
$second[$i] = $line;
$first[$i] = '';
break;
- case (eregi("^([^:]+):(.+)", $line, $regs)):
+ case (preg_match('/^([^:]+):(.+)/', $line, $regs)):
$first[$i] = $regs[1] . ':';
$second[$i] = $regs[2];
$cnum++;