diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index 04349221a02..cc3e574694f 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -212,7 +212,7 @@ class CMailFile // 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 // 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') { diff --git a/htdocs/lib/admin.lib.php b/htdocs/lib/admin.lib.php index d9b4523ad01..ac4bd9c4b92 100644 --- a/htdocs/lib/admin.lib.php +++ b/htdocs/lib/admin.lib.php @@ -123,17 +123,17 @@ function run_sql($sqlfile,$silent=1) && versioncompare($versioncommande,$versionarray) <= 0) { // 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.'
'; } } // Ajout ligne si non commentaire - if (! eregi('^--',$buf)) $buffer .= $buf; + if (! preg_match('/^--/i',$buf)) $buffer .= $buf; // print $buf.'
'; - if (eregi(';',$buffer)) + if (preg_match('/;/',$buffer)) { // Found new request $arraysql[$i]=trim($buffer); @@ -155,7 +155,7 @@ function run_sql($sqlfile,$silent=1) $newsql=$sql; // 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]; if (! isset($listofmaxrowid[$table])) @@ -236,10 +236,10 @@ function run_sql($sqlfile,$silent=1) $result=$db->query($newsql); if ($result) { - if (eregi('insert into ([^ ]+)',$newsql,$reg)) + if (preg_match('/insert into ([^\s]+)/i',$newsql,$reg)) { // 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); $listofinsertedrowid[$cursorinsert]=$insertedrowid; dol_syslog('Admin.lib::run_sql Insert nb '.$cursorinsert.', done in table '.$table.', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG); diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index e41995f7ad7..bb057045224 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -131,7 +131,7 @@ function societe_prepare_head($objsoc) { $values=explode(':',$value); 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][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/databases/mssql.lib.php b/htdocs/lib/databases/mssql.lib.php index b0fc2623155..b500eb8a9a7 100644 --- a/htdocs/lib/databases/mssql.lib.php +++ b/htdocs/lib/databases/mssql.lib.php @@ -554,7 +554,7 @@ class DoliDb */ function jdate($string) { - $string=eregi_replace('[^0-9]','',$string); + $string=preg_replace('/([^0-9])/i','',$string); $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)); return $date; diff --git a/htdocs/lib/databases/mysql.lib.php b/htdocs/lib/databases/mysql.lib.php index a4cf143c8ef..6c837ea225c 100644 --- a/htdocs/lib/databases/mysql.lib.php +++ b/htdocs/lib/databases/mysql.lib.php @@ -544,7 +544,7 @@ class DoliDb */ function jdate($string) { - $string=eregi_replace('[^0-9]','',$string); + $string=preg_replace('/([^0-9])/i','',$string); $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)); return $date; diff --git a/htdocs/lib/databases/mysqli.lib.php b/htdocs/lib/databases/mysqli.lib.php index e6e07bbef00..cd0d702e58f 100644 --- a/htdocs/lib/databases/mysqli.lib.php +++ b/htdocs/lib/databases/mysqli.lib.php @@ -559,7 +559,7 @@ class DoliDb */ function jdate($string) { - $string=eregi_replace('[^0-9]','',$string); + $string=preg_replace('/([^0-9])/i','',$string); $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)); return $date; diff --git a/htdocs/lib/databases/pgsql.lib.php b/htdocs/lib/databases/pgsql.lib.php index 9e23d5e05a3..2892e344b2d 100644 --- a/htdocs/lib/databases/pgsql.lib.php +++ b/htdocs/lib/databases/pgsql.lib.php @@ -156,15 +156,15 @@ class DoliDb return ''; } # 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; } if ($create_sql != "") { # we are inside create table statement so lets process datatypes - if (eregi('(ISAM|innodb)',$line)) { # end of create table sequence - $line=eregi_replace('\) *type=(MyISAM|innodb);',');'); - $line=eregi_replace('\) *engine=(MyISAM|innodb);',');'); + if (preg_match('/(ISAM|innodb)/i',$line)) { # end of create table sequence + $line=preg_replace('/\) *type=(MyISAM|innodb);/i',');'); + $line=preg_replace('/\) *engine=(MyISAM|innodb);/i',');'); } # int, auto_increment -> serial @@ -187,21 +187,21 @@ class DoliDb s/\w*int\(\d+\)/$out/g; } */ - $line=eregi_replace('tinyint','smallint'); + $line=str_replace('tinyint','smallint',$line); # 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 - $line=eregi_replace('\w*blob','text'); + $line=preg_replace('/\w*blob/i','text'); # tinytext/mediumtext -> text - $line=eregi_replace('tinytext','text'); - $line=eregi_replace('mediumtext','text'); + $line=preg_replace('/tinytext/i','text'); + $line=preg_replace('/mediumtext/i','text'); # char -> varchar # PostgreSQL would otherwise pad with spaces as opposed @@ -215,8 +215,8 @@ class DoliDb # change not null datetime field to null valid ones # (to support remapping of "zero time" to null - $line=eregi_replace('datetime not null','datetime'); - $line=eregi_replace('datetime','timestamp'); + $line=preg_replace('/datetime not null/i','datetime'); + $line=preg_replace('/datetime/i','timestamp'); # nuke size of timestamp // s/timestamp\([^)]*\)/timestamp/i; @@ -677,7 +677,7 @@ class DoliDb */ function jdate($string) { - $string=eregi_replace('[^0-9]','',$string); + $string=preg_replace('/([^0-9])/i','',$string); $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)); return $date; diff --git a/htdocs/lib/fichinter.lib.php b/htdocs/lib/fichinter.lib.php index 1b51e8330a6..76f71ecb35f 100644 --- a/htdocs/lib/fichinter.lib.php +++ b/htdocs/lib/fichinter.lib.php @@ -78,7 +78,7 @@ function fichinter_prepare_head($fichinter) { $values=explode(':',$value); 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][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php index f83fcfb6195..fe0e41c9674 100644 --- a/htdocs/lib/files.lib.php +++ b/htdocs/lib/files.lib.php @@ -43,7 +43,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil $loadsize=$mode?true:false; // Clean parameters - $path=eregi_replace('[\\/]+$','',$path); + $path=preg_replace('/([\\/]+)$/i','',$path); $newpath=(utf8_check($path)?utf8_decode($path):$path); if (! is_dir($newpath)) return array(); diff --git a/htdocs/lib/fourn.lib.php b/htdocs/lib/fourn.lib.php index ed9217a489f..00a52b5ac95 100644 --- a/htdocs/lib/fourn.lib.php +++ b/htdocs/lib/fourn.lib.php @@ -69,7 +69,7 @@ function facturefourn_prepare_head($fac) { $values=explode(':',$value); 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][2] = 'tab'.$values[1]; $h++; @@ -134,7 +134,7 @@ function ordersupplier_prepare_head($commande) { $values=explode(':',$value); 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][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 50a64ba04be..162a44c889c 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -254,7 +254,7 @@ function dol_syslog($message, $level=LOG_INFO) if (defined("SYSLOG_FILE") && 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+"); 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=eregi_replace('[^0-9]','',$string); + $string=preg_replace('/([^0-9])/i','',$string); $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); return $date; @@ -2282,14 +2282,14 @@ function dol_delete_dir_recursive($dir,$count=0) function vatrate($rate,$addpercent=false,$info_bits=0) { // Test for compatibility - if (eregi('%',$rate)) + if (preg_match('/%/',$rate)) { - $rate=eregi_replace('%','',$rate); + $rate=str_replace('%','',$rate); $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; } @@ -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."-"; - $amount = ereg_replace(',','.',$amount); // should be useless + $amount = str_replace(',','.',$amount); // should be useless //print $amount."-"; $datas = explode('.',$amount); $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."
"; $end=''; @@ -2341,7 +2341,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2) if ($trunc && $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 ... $end='...'; @@ -2351,7 +2351,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2) // Format number if ($html) { - $output=ereg_replace(' ',' ',number_format($amount, $nbdecimal, $dec, $thousand)); + $output=preg_replace('/\s/',' ',number_format($amount, $nbdecimal, $dec, $thousand)); } else { @@ -2572,8 +2572,8 @@ function yn($yesno, $case=1, $color=0) function get_exdir($num,$level=3,$alpha=0) { $path = ''; - if (empty($alpha)) $num = eregi_replace('[^0-9]','',$num); - else $num = eregi_replace('^.*\-','',$num); + if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num); + else $num = preg_replace('/^.*\-/i','',$num); $num = substr("000".$num, -$level); if ($level == 1) $path = 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)) { //$trans = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT); var_dump($trans); - $newstring=eregi_replace('" by "
". It's same and avoid pb with FPDF. - $newstring=eregi_replace('
$','',$newstring); // Replace "
" by "
". It's same and avoid pb with FPDF. + $newstring=preg_replace('/','
',$stringtoencode); // Replace "
" by "
". It's same and avoid pb with FPDF. + $newstring=preg_replace('/
$/i','',$newstring); // Replace "
" by "
". It's same and avoid pb with FPDF. $newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__')); $newstring=@htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding $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; $ret=@html_entity_decode($stringtodecode,ENT_COMPAT,$pagecodeto); - $ret=eregi_replace("\r\n".'",$ret); - $ret=eregi_replace('/i',"
",$ret); + $ret=preg_replace('/'."\r\n".'/i',"\r\n",$ret); + $ret=eregi_replace('/'."\n".'/i',"\n",$ret); + $ret=preg_replace('//i',"\n",$ret); return $ret; } @@ -2747,7 +2747,7 @@ function dol_htmlentitiesbr_decode($stringtodecode,$pagecodeto='UTF-8') */ function dol_htmlcleanlastbr($stringtodecode) { - $ret=eregi_replace('(
|||'."\n".'|'."\r".')+$/i',"",$stringtodecode); return $ret; }