Fix: functions "ereg", "ereg_replace", "eregi", "eregi_replace" is deprecated since php 5.3.0

This commit is contained in:
Regis Houssin
2009-10-21 16:50:15 +00:00
parent c226de4f00
commit 47670f5f97
11 changed files with 47 additions and 47 deletions

View File

@@ -212,7 +212,7 @@ class CMailFile
// On nettoie le header pour qu'il ne se termine pas par un retour chariot. // On nettoie le header pour qu'il ne se termine pas par un retour chariot.
// Ceci evite aussi les lignes vides en fin qui peuvent etre interpretees // Ceci evite aussi les lignes vides en fin qui peuvent etre interpretees
// comme des injections mail par les serveurs de messagerie. // comme des injections mail par les serveurs de messagerie.
$this->headers = eregi_replace("[\r\n]+$","",$this->headers); $this->headers = preg_replace("/([\r\n]+)$/i","",$this->headers);
} }
else if ($conf->global->MAIN_MAIL_SENDMODE == 'simplemail') else if ($conf->global->MAIN_MAIL_SENDMODE == 'simplemail')
{ {

View File

@@ -123,17 +123,17 @@ function run_sql($sqlfile,$silent=1)
&& versioncompare($versioncommande,$versionarray) <= 0) && versioncompare($versioncommande,$versionarray) <= 0)
{ {
// Version qualified, delete SQL comments // Version qualified, delete SQL comments
$buf=eregi_replace('^-- V([0-9\.]+)','',$buf); $buf=preg_replace('/^-- V([0-9\.]+)/i','',$buf);
//print "Ligne $i qualifi?e par version: ".$buf.'<br>'; //print "Ligne $i qualifi?e par version: ".$buf.'<br>';
} }
} }
// Ajout ligne si non commentaire // Ajout ligne si non commentaire
if (! eregi('^--',$buf)) $buffer .= $buf; if (! preg_match('/^--/i',$buf)) $buffer .= $buf;
// print $buf.'<br>'; // print $buf.'<br>';
if (eregi(';',$buffer)) if (preg_match('/;/',$buffer))
{ {
// Found new request // Found new request
$arraysql[$i]=trim($buffer); $arraysql[$i]=trim($buffer);
@@ -155,7 +155,7 @@ function run_sql($sqlfile,$silent=1)
$newsql=$sql; $newsql=$sql;
// Replace __+MAX_table__ with max of table // Replace __+MAX_table__ with max of table
while (eregi('__\+MAX_([A-Za-z_]+)__',$newsql,$reg)) while (preg_match('/__\+MAX_([A-Za-z_]+)__/i',$newsql,$reg))
{ {
$table=$reg[1]; $table=$reg[1];
if (! isset($listofmaxrowid[$table])) if (! isset($listofmaxrowid[$table]))
@@ -236,10 +236,10 @@ function run_sql($sqlfile,$silent=1)
$result=$db->query($newsql); $result=$db->query($newsql);
if ($result) if ($result)
{ {
if (eregi('insert into ([^ ]+)',$newsql,$reg)) if (preg_match('/insert into ([^\s]+)/i',$newsql,$reg))
{ {
// It's an insert // It's an insert
$table=eregi_replace('[^a-zA-Z_]+','',$reg[1]); $table=preg_replace('/([^a-zA-Z_]+)/i','',$reg[1]);
$insertedrowid=$db->last_insert_id($table); $insertedrowid=$db->last_insert_id($table);
$listofinsertedrowid[$cursorinsert]=$insertedrowid; $listofinsertedrowid[$cursorinsert]=$insertedrowid;
dol_syslog('Admin.lib::run_sql Insert nb '.$cursorinsert.', done in table '.$table.', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG); dol_syslog('Admin.lib::run_sql Insert nb '.$cursorinsert.', done in table '.$table.', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);

View File

@@ -131,7 +131,7 @@ function societe_prepare_head($objsoc)
{ {
$values=explode(':',$value); $values=explode(':',$value);
if ($values[2]) $langs->load($values[2]); if ($values[2]) $langs->load($values[2]);
$head[$h][0] = eregi_replace('__ID__',$objsoc->id,$values[3]); $head[$h][0] = preg_replace('/__ID__/i',$objsoc->id,$values[3]);
$head[$h][1] = $langs->trans($values[1]); $head[$h][1] = $langs->trans($values[1]);
$head[$h][2] = 'tab'.$values[1]; $head[$h][2] = 'tab'.$values[1];
$h++; $h++;

View File

@@ -554,7 +554,7 @@ class DoliDb
*/ */
function jdate($string) function jdate($string)
{ {
$string=eregi_replace('[^0-9]','',$string); $string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000'; $tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4)); $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4));
return $date; return $date;

View File

@@ -544,7 +544,7 @@ class DoliDb
*/ */
function jdate($string) function jdate($string)
{ {
$string=eregi_replace('[^0-9]','',$string); $string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000'; $tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4)); $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4));
return $date; return $date;

View File

@@ -559,7 +559,7 @@ class DoliDb
*/ */
function jdate($string) function jdate($string)
{ {
$string=eregi_replace('[^0-9]','',$string); $string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000'; $tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4)); $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4));
return $date; return $date;

View File

@@ -156,15 +156,15 @@ class DoliDb
return ''; return '';
} }
# comments or empty lines # comments or empty lines
if (eregi('^#',$line) || eregi('^$',$line) || eregi('^--',$line)) if (preg_match('/^#/i',$line) || preg_match('/^$/i',$line) || preg_match('/^--/i',$line))
{ {
return $line; return $line;
} }
if ($create_sql != "") if ($create_sql != "")
{ # we are inside create table statement so lets process datatypes { # we are inside create table statement so lets process datatypes
if (eregi('(ISAM|innodb)',$line)) { # end of create table sequence if (preg_match('/(ISAM|innodb)/i',$line)) { # end of create table sequence
$line=eregi_replace('\) *type=(MyISAM|innodb);',');'); $line=preg_replace('/\) *type=(MyISAM|innodb);/i',');');
$line=eregi_replace('\) *engine=(MyISAM|innodb);',');'); $line=preg_replace('/\) *engine=(MyISAM|innodb);/i',');');
} }
# int, auto_increment -> serial # int, auto_increment -> serial
@@ -187,21 +187,21 @@ class DoliDb
s/\w*int\(\d+\)/$out/g; s/\w*int\(\d+\)/$out/g;
} }
*/ */
$line=eregi_replace('tinyint','smallint'); $line=str_replace('tinyint','smallint',$line);
# nuke unsigned # nuke unsigned
if (eregi_replace('(int\w+|smallint)\s+unsigned','smallint',$reg)) if (preg_replace('/(int\w+|smallint)\s+unsigned/i','smallint',$reg))
{ {
$line=eregi_replace('(int\w+|smallint)\s+unsigned',$reg[1]); $line=preg_replace('/(int\w+|smallint)\s+unsigned/i',$reg[1]);
} }
# blob -> text # blob -> text
$line=eregi_replace('\w*blob','text'); $line=preg_replace('/\w*blob/i','text');
# tinytext/mediumtext -> text # tinytext/mediumtext -> text
$line=eregi_replace('tinytext','text'); $line=preg_replace('/tinytext/i','text');
$line=eregi_replace('mediumtext','text'); $line=preg_replace('/mediumtext/i','text');
# char -> varchar # char -> varchar
# PostgreSQL would otherwise pad with spaces as opposed # PostgreSQL would otherwise pad with spaces as opposed
@@ -215,8 +215,8 @@ class DoliDb
# change not null datetime field to null valid ones # change not null datetime field to null valid ones
# (to support remapping of "zero time" to null # (to support remapping of "zero time" to null
$line=eregi_replace('datetime not null','datetime'); $line=preg_replace('/datetime not null/i','datetime');
$line=eregi_replace('datetime','timestamp'); $line=preg_replace('/datetime/i','timestamp');
# nuke size of timestamp # nuke size of timestamp
// s/timestamp\([^)]*\)/timestamp/i; // s/timestamp\([^)]*\)/timestamp/i;
@@ -677,7 +677,7 @@ class DoliDb
*/ */
function jdate($string) function jdate($string)
{ {
$string=eregi_replace('[^0-9]','',$string); $string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000'; $tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4)); $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4));
return $date; return $date;

View File

@@ -78,7 +78,7 @@ function fichinter_prepare_head($fichinter)
{ {
$values=explode(':',$value); $values=explode(':',$value);
if ($values[2]) $langs->load($values[2]); if ($values[2]) $langs->load($values[2]);
$head[$h][0] = eregi_replace('__ID__',$fichinter->id,$values[3]); $head[$h][0] = preg_replace('/__ID__/i',$fichinter->id,$values[3]);
$head[$h][1] = $langs->trans($values[1]); $head[$h][1] = $langs->trans($values[1]);
$head[$h][2] = 'tab'.$values[1]; $head[$h][2] = 'tab'.$values[1];
$h++; $h++;

View File

@@ -43,7 +43,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
$loadsize=$mode?true:false; $loadsize=$mode?true:false;
// Clean parameters // Clean parameters
$path=eregi_replace('[\\/]+$','',$path); $path=preg_replace('/([\\/]+)$/i','',$path);
$newpath=(utf8_check($path)?utf8_decode($path):$path); $newpath=(utf8_check($path)?utf8_decode($path):$path);
if (! is_dir($newpath)) return array(); if (! is_dir($newpath)) return array();

View File

@@ -69,7 +69,7 @@ function facturefourn_prepare_head($fac)
{ {
$values=explode(':',$value); $values=explode(':',$value);
if ($values[2]) $langs->load($values[2]); if ($values[2]) $langs->load($values[2]);
$head[$h][0] = eregi_replace('__ID__',$fac->id,$values[3]); $head[$h][0] = preg_replace('/__ID__/i',$fac->id,$values[3]);
$head[$h][1] = $langs->trans($values[1]); $head[$h][1] = $langs->trans($values[1]);
$head[$h][2] = 'tab'.$values[1]; $head[$h][2] = 'tab'.$values[1];
$h++; $h++;
@@ -134,7 +134,7 @@ function ordersupplier_prepare_head($commande)
{ {
$values=explode(':',$value); $values=explode(':',$value);
if ($values[2]) $langs->load($values[2]); if ($values[2]) $langs->load($values[2]);
$head[$h][0] = eregi_replace('__ID__',$commande->id,$values[3]); $head[$h][0] = preg_replace('/__ID__/i',$commande->id,$values[3]);
$head[$h][1] = $langs->trans($values[1]); $head[$h][1] = $langs->trans($values[1]);
$head[$h][2] = 'tab'.$values[1]; $head[$h][2] = 'tab'.$values[1];
$h++; $h++;

View File

@@ -254,7 +254,7 @@ function dol_syslog($message, $level=LOG_INFO)
if (defined("SYSLOG_FILE") && SYSLOG_FILE) if (defined("SYSLOG_FILE") && SYSLOG_FILE)
{ {
$filelog=SYSLOG_FILE; $filelog=SYSLOG_FILE;
$filelog=eregi_replace('DOL_DATA_ROOT',DOL_DATA_ROOT,$filelog); $filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog);
if (defined("SYSLOG_FILE_NO_ERROR")) $file=@fopen($filelog,"a+"); if (defined("SYSLOG_FILE_NO_ERROR")) $file=@fopen($filelog,"a+");
else $file=fopen($filelog,"a+"); else $file=fopen($filelog,"a+");
@@ -542,7 +542,7 @@ function dol_stringtotime($string)
$string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec); $string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
} }
$string=eregi_replace('[^0-9]','',$string); $string=preg_replace('/([^0-9])/i','',$string);
$tmp=$string.'000000'; $tmp=$string.'000000';
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),1); $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),1);
return $date; return $date;
@@ -2282,14 +2282,14 @@ function dol_delete_dir_recursive($dir,$count=0)
function vatrate($rate,$addpercent=false,$info_bits=0) function vatrate($rate,$addpercent=false,$info_bits=0)
{ {
// Test for compatibility // Test for compatibility
if (eregi('%',$rate)) if (preg_match('/%/',$rate))
{ {
$rate=eregi_replace('%','',$rate); $rate=str_replace('%','',$rate);
$addpercent=true; $addpercent=true;
} }
if (eregi('\*',$rate) || eregi(MAIN_LABEL_MENTION_NPR,$rate)) if (preg_match('/\*/',$rate) || preg_match('/'.MAIN_LABEL_MENTION_NPR.'/i',$rate))
{ {
$rate=eregi_replace('\*','',$rate); $rate=str_replace('*','',$rate);
$info_bits |= 1; $info_bits |= 1;
} }
@@ -2327,11 +2327,11 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2)
//print "amount=".$amount." html=".$html." trunc=".$trunc." nbdecimal=".$nbdecimal." dec=".$dec." thousand=".$thousand; //print "amount=".$amount." html=".$html." trunc=".$trunc." nbdecimal=".$nbdecimal." dec=".$dec." thousand=".$thousand;
//print "amount=".$amount."-"; //print "amount=".$amount."-";
$amount = ereg_replace(',','.',$amount); // should be useless $amount = str_replace(',','.',$amount); // should be useless
//print $amount."-"; //print $amount."-";
$datas = explode('.',$amount); $datas = explode('.',$amount);
$decpart = isset($datas[1])?$datas[1]:''; $decpart = isset($datas[1])?$datas[1]:'';
$decpart = eregi_replace('0+$','',$decpart); // Supprime les 0 de fin de partie decimale $decpart = preg_replace('/0+$/i','',$decpart); // Supprime les 0 de fin de partie decimale
//print "decpart=".$decpart."<br>"; //print "decpart=".$decpart."<br>";
$end=''; $end='';
@@ -2341,7 +2341,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2)
if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN)
{ {
$nbdecimal=$conf->global->MAIN_MAX_DECIMALS_SHOWN; $nbdecimal=$conf->global->MAIN_MAX_DECIMALS_SHOWN;
if (eregi('\.\.\.',$conf->global->MAIN_MAX_DECIMALS_SHOWN)) if (preg_match('/\.\.\./i',$conf->global->MAIN_MAX_DECIMALS_SHOWN))
{ {
// Si un affichage est tronque, on montre des ... // Si un affichage est tronque, on montre des ...
$end='...'; $end='...';
@@ -2351,7 +2351,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2)
// Format number // Format number
if ($html) if ($html)
{ {
$output=ereg_replace(' ','&nbsp;',number_format($amount, $nbdecimal, $dec, $thousand)); $output=preg_replace('/\s/','&nbsp;',number_format($amount, $nbdecimal, $dec, $thousand));
} }
else else
{ {
@@ -2572,8 +2572,8 @@ function yn($yesno, $case=1, $color=0)
function get_exdir($num,$level=3,$alpha=0) function get_exdir($num,$level=3,$alpha=0)
{ {
$path = ''; $path = '';
if (empty($alpha)) $num = eregi_replace('[^0-9]','',$num); if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num);
else $num = eregi_replace('^.*\-','',$num); else $num = preg_replace('/^.*\-/i','',$num);
$num = substr("000".$num, -$level); $num = substr("000".$num, -$level);
if ($level == 1) $path = substr($num,0,1).'/'; if ($level == 1) $path = substr($num,0,1).'/';
if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1).'/'; if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1).'/';
@@ -2710,8 +2710,8 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8')
if (dol_textishtml($stringtoencode)) if (dol_textishtml($stringtoencode))
{ {
//$trans = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT); var_dump($trans); //$trans = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT); var_dump($trans);
$newstring=eregi_replace('<br( [ a-zA-Z_="]*)?/?>','<br>',$stringtoencode); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF. $newstring=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?/i>','<br>',$stringtoencode); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
$newstring=eregi_replace('<br>$','',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF. $newstring=preg_replace('/<br>$/i','',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
$newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__')); $newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__'));
$newstring=@htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding $newstring=@htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding
$newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"')); $newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"'));
@@ -2734,10 +2734,10 @@ function dol_htmlentitiesbr_decode($stringtodecode,$pagecodeto='UTF-8')
{ {
// We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8;
$ret=@html_entity_decode($stringtodecode,ENT_COMPAT,$pagecodeto); $ret=@html_entity_decode($stringtodecode,ENT_COMPAT,$pagecodeto);
$ret=eregi_replace("\r\n".'<br( [ a-zA-Z_="]*)?/?>',"<br>",$ret); $ret=preg_replace('/'."\r\n".'<br(\s[\sa-zA-Z_="]*)?\/?>/i',"<br>",$ret);
$ret=eregi_replace('<br( [ a-zA-Z_="]*)?/?>'."\r\n","\r\n",$ret); $ret=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>'."\r\n".'/i',"\r\n",$ret);
$ret=eregi_replace('<br( [ a-zA-Z_="]*)?/?>'."\n","\n",$ret); $ret=eregi_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>'."\n".'/i',"\n",$ret);
$ret=eregi_replace('<br( [ a-zA-Z_="]*)?/?>',"\n",$ret); $ret=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i',"\n",$ret);
return $ret; return $ret;
} }
@@ -2747,7 +2747,7 @@ function dol_htmlentitiesbr_decode($stringtodecode,$pagecodeto='UTF-8')
*/ */
function dol_htmlcleanlastbr($stringtodecode) function dol_htmlcleanlastbr($stringtodecode)
{ {
$ret=eregi_replace('(<br>|<br( [ a-zA-Z_="]*)?/?>|'."\n".'|'."\r".')+$',"",$stringtodecode); $ret=preg_replace('/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'."\n".'|'."\r".')+$/i',"",$stringtodecode);
return $ret; return $ret;
} }