From 8ce50bce4367d520c91fe8ff457f8f71db6c7eac Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Thu, 22 Oct 2009 17:56:57 +0000
Subject: [PATCH] Fix: functions "ereg", "ereg_replace", "eregi",
 "eregi_replace" is deprecated since php 5.3.0

---
 htdocs/install/check.php                       |  2 +-
 htdocs/install/etape0.php                      |  8 ++++----
 htdocs/install/etape1.php                      |  2 +-
 htdocs/install/etape2.php                      | 10 +++++-----
 htdocs/install/etape5.php                      |  8 ++++----
 htdocs/install/fileconf.php                    |  6 +++---
 htdocs/install/inc.php                         |  2 +-
 htdocs/install/mysql/migration/2.1.0-2.2.0.sql | 18 +++++++++---------
 htdocs/install/repair.php                      |  4 ++--
 htdocs/install/upgrade.php                     |  8 ++++----
 htdocs/install/upgrade2.php                    |  2 +-
 11 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index 31a6774366f..68d63ed7060 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -134,7 +134,7 @@ $memmaxorig=@ini_get("memory_limit");
 $memmax=@ini_get("memory_limit");
 if ($memmaxorig != '')
 {
-	eregi('([0-9]+)([a-zA-Z]*)',$memmax,$reg);
+	preg_match('/([0-9]+)([a-zA-Z]*)/i',$memmax,$reg);
 	if ($reg[2])
 	{
 		if (strtoupper($reg[2]) == 'M') $memmax=$reg[1]*1024*1024;
diff --git a/htdocs/install/etape0.php b/htdocs/install/etape0.php
index 783817c062d..784522b3294 100644
--- a/htdocs/install/etape0.php
+++ b/htdocs/install/etape0.php
@@ -59,14 +59,14 @@ dolibarr_install_syslog("etape0: Entering etape0.php page");
 
 pHeader($langs->trans("ConfigurationFile"),"etape1");
 
-// On reporte champ formulaire pr�c�dent pour propagation
+// On reporte champ formulaire precedent pour propagation
 if ($_POST["action"] == "set")
 {
 	umask(0);
 	foreach($_POST as $cle=>$valeur)
 	{
 		echo '<input type="hidden" name="'.$cle.'"  value="'.$valeur.'">';
-		if (! eregi('^db_pass',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur);
+		if (! preg_match('/^db_pass/i',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur);
 	}
 }
 
@@ -255,7 +255,7 @@ if (! $error && $db->connected)
 			{
 				// We keep only utf8 and iso
 				$linedisabled=false;
-				if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! eregi('(utf8|latin1)',$characterSet['charset'])) $linedisabled=true;
+				if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/(utf8|latin1)/i',$characterSet['charset'])) $linedisabled=true;
 
 				if ($defaultCharacterSet == $characterSet['charset'] )
 				{
@@ -298,7 +298,7 @@ if (! $error && $db->connected)
 			{
 				// We keep only utf8 and iso
 				$linedisabled=false;
-				if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! eregi('(utf8_general|latin1_swedish)',$collation['collation'])) $linedisabled=true;
+				if (($_POST["db_type"] == 'mysql' ||$_POST["db_type"] == 'mysqli') && ! preg_match('/(utf8_general|latin1_swedish)/i',$collation['collation'])) $linedisabled=true;
 
 				if ($defaultCollationConnection == $collation['collation'])
 				{
diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php
index 833a4b95303..270c1d7866a 100644
--- a/htdocs/install/etape1.php
+++ b/htdocs/install/etape1.php
@@ -79,7 +79,7 @@ if ($_POST["action"] == "set")
 	umask(0);
 	foreach($_POST as $cle=>$valeur)
 	{
-		if (! eregi('^db_pass',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur);
+		if (! preg_match('/^db_pass/i',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur);
 	}
 
 	// Show title of step
diff --git a/htdocs/install/etape2.php b/htdocs/install/etape2.php
index ebfce29c23a..c216f4c4ab4 100644
--- a/htdocs/install/etape2.php
+++ b/htdocs/install/etape2.php
@@ -126,7 +126,7 @@ if ($_POST["action"] == "set")
         $tablefound = 0;
         while (($file = readdir($handle))!==false)
         {
-            if (eregi('\.sql$',$file) && eregi('^llx_',$file) && ! eregi('\.key\.sql$',$file))
+            if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && ! preg_match('/\.key\.sql$/i',$file))
             {
                 $tablefound++;
 
@@ -225,7 +225,7 @@ if ($_POST["action"] == "set")
         dolibarr_install_syslog("Ouverture repertoire ".$dir." handle=".$handle,LOG_DEBUG);
         while (($file = readdir($handle))!==false)
         {
-            if (eregi('\.sql$',$file) && eregi('^llx_',$file) && eregi('\.key\.sql$',$file))
+            if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && preg_match('/\.key\.sql$/i',$file))
             {
                 $name = substr($file, 0, strlen($file) - 4);
                 //print "<tr><td>Creation de la table $name</td>";
@@ -238,7 +238,7 @@ if ($_POST["action"] == "set")
                         $buf = fgets($fp, 4096);
 
                         // Cas special de lignes autorisees pour certaines versions uniquement
-                        if (eregi('^-- V([0-9\.]+)',$buf,$reg))
+                        if (preg_match('/^--\sV([0-9\.]+)/i',$buf,$reg))
                         {
                             $versioncommande=explode('.',$reg[1]);
 							//print var_dump($versioncommande);
@@ -253,7 +253,7 @@ if ($_POST["action"] == "set")
                         }
 
                         // Ajout ligne si non commentaire
-                        if (! eregi('^--',$buf)) $buffer .= $buf;
+                        if (! preg_match('/^--/i',$buf)) $buffer .= $buf;
                     }
                     fclose($fp);
 
@@ -281,7 +281,7 @@ if ($_POST["action"] == "set")
 	                            if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
 	                                $db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
 	                                $db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
-	                                eregi('duplicate key name',$db->error()))
+	                                preg_match('/duplicate key name/i',$db->error()))
 	                            {
 	                                //print "<td>Deja existante</td></tr>";
 	                                $key_exists = 1;
diff --git a/htdocs/install/etape5.php b/htdocs/install/etape5.php
index f606b8999b4..93636c61b1d 100644
--- a/htdocs/install/etape5.php
+++ b/htdocs/install/etape5.php
@@ -38,7 +38,7 @@ $langs->setDefaultLang($setuplang);
 // Define targetversion used to update MAIN_VERSION_LAST_INSTALL for first install
 // or MAIN_VERSION_LAST_UPGRADE for upgrade.
 $targetversion=DOL_VERSION;		// It it's last upgrade
-if (isset($_POST["action"]) && eregi('upgrade',$_POST["action"]))	// If it's an old upgrade
+if (isset($_POST["action"]) && preg_match('/upgrade/i',$_POST["action"]))	// If it's an old upgrade
 {
 	$tmp=explode('_',$_POST["action"],2);
 	if ($tmp[0]=='upgrade' && ! empty($tmp[1])) $targetversion=$tmp[1];
@@ -102,7 +102,7 @@ if ($_POST["action"] == "set")
 
 pHeader($langs->trans("SetupEnd"),"etape5");
 
-if ($_POST["action"] == "set" || eregi('upgrade',$_POST["action"]))
+if ($_POST["action"] == "set" || preg_match('/upgrade/i',$_POST["action"]))
 {
 	print '<table cellspacing="0" cellpadding="2" width="100%">';
 	$error=0;
@@ -217,7 +217,7 @@ if ($_POST["action"] == "set" || eregi('upgrade',$_POST["action"]))
 		}
 	}
 	// If upgrade
-	elseif (eregi('upgrade',$_POST["action"]))
+	elseif (preg_match('/upgrade/i',$_POST["action"]))
 	{
 		if ($db->connected == 1)
 		{
@@ -312,7 +312,7 @@ if ($_POST["action"] == "set")
 	}
 }
 // If upgrade
-elseif (eregi('upgrade',$_POST["action"]))
+elseif (preg_match('/upgrade/i',$_POST["action"]))
 {
 	if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
 	{
diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php
index c5478a1de6e..6d1acee0143 100644
--- a/htdocs/install/fileconf.php
+++ b/htdocs/install/fileconf.php
@@ -81,11 +81,11 @@ if(! isset($dolibarr_main_url_root) || strlen($dolibarr_main_url_root) == 0)
 
     // Si le php fonctionne en CGI, alors SCRIPT_FILENAME vaut le path du php et
     // ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
-    if (eregi('^php$',$_SERVER["SCRIPT_FILENAME"]) || eregi('[\\\/]php$',$_SERVER["SCRIPT_FILENAME"]) || eregi('php\.exe$',$_SERVER["SCRIPT_FILENAME"]))
+    if (preg_match('/^php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i',$_SERVER["SCRIPT_FILENAME"]))
     {
         $dolibarr_main_document_root=$_SERVER["DOCUMENT_ROOT"];
 
-        if (! eregi('[\/\\]dolibarr[\/\\]htdocs$',$dolibarr_main_document_root))
+        if (! preg_match('/[\\/]dolibarr[\\/]htdocs$/i',$dolibarr_main_document_root))
         {
             $dolibarr_main_document_root.="/dolibarr/htdocs";
         }
@@ -219,7 +219,7 @@ $option='';
 
 while (($file = readdir($handle))!==false)
 {
-    if (is_readable($dir."/".$file) && eregi('^(.*)\.lib\.php',$file,$reg))
+    if (is_readable($dir."/".$file) && preg_match('/^(.*)\.lib\.php/i',$file,$reg))
     {
         $type=$reg[1];
 
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index 0b61bc61d5f..8880a9c66c9 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -171,7 +171,7 @@ function stripslashes_deep($value)
 {
    return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
 }
-//if (! eregi('PHP/6', $_SERVER['SERVER_SOFTWARE']))
+//if (! preg_match('/PHP\/6/i', $_SERVER['SERVER_SOFTWARE']))
 if (function_exists('get_magic_quotes_gpc'))	// magic_quotes_* plus pris en compte dans PHP6
 {
 	if (get_magic_quotes_gpc())
diff --git a/htdocs/install/mysql/migration/2.1.0-2.2.0.sql b/htdocs/install/mysql/migration/2.1.0-2.2.0.sql
index d78075eb57a..66279510024 100644
--- a/htdocs/install/mysql/migration/2.1.0-2.2.0.sql
+++ b/htdocs/install/mysql/migration/2.1.0-2.2.0.sql
@@ -358,16 +358,16 @@ insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titr
 insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1702, 'accountancy', '', 1700, '/compta/clients.php?leftmenu=customers', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 1);
 insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1703, 'accountancy', '', 1700, '/contact/index.php?leftmenu=customers&type=c', 'Contacts', 1, 'companies', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 2);
 insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1704, 'accountancy', '', 1700, '/compta/facture.php?leftmenu=customers_bills', 'BillsCustomers', 1, 'bills', '$user->rights->facture->lire', '', 2, 3);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1705, 'accountancy', 'eregi("customers_bills",$leftmenu)', 1704, '/compta/clients.php?action=facturer&leftmenu=customers_bills', 'NewBill', 2, 'bills', '$user->rights->facture->creer', '', 2, 3);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1706, 'accountancy', 'eregi("customers_bills",$leftmenu)', 1704, '/compta/facture/fiche-rec.php?leftmenu=customers_bills', 'Repeatable', 2, 'bills', '$user->rights->facture->lire', '', 2, 4);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1707, 'accountancy', 'eregi("customers_bills",$leftmenu)', 1704, '/compta/facture/impayees.php?action=facturer&leftmenu=customers_bills', 'Unpaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 5);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1708, 'accountancy', 'eregi("customers_bills",$leftmenu)', 1704, '/compta/paiement/liste.php?leftmenu=customers_bills_payments', 'Payments', 2, 'bills', '$user->rights->facture->lire', '', 2, 6);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1709, 'accountancy', 'eregi("customers_bills_payments",$leftmenu)', 1708, '/compta/paiement/avalider.php?leftmenu=customers_bills_payments', 'MenuToValid', 3, 'bills', '$user->rights->facture->lire', '', 2, 0);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1710, 'accountancy', 'eregi("customers_bills_payments",$leftmenu)', 1708, '/compta/paiement/rapport.php?leftmenu=customers_bills_payments', 'Reportings', 3, 'bills', '$user->rights->facture->lire', '', 2, 1);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1705, 'accountancy', 'preg_match("/customers_bills/i",$leftmenu)', 1704, '/compta/clients.php?action=facturer&leftmenu=customers_bills', 'NewBill', 2, 'bills', '$user->rights->facture->creer', '', 2, 3);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1706, 'accountancy', 'preg_match("/customers_bills/i",$leftmenu)', 1704, '/compta/facture/fiche-rec.php?leftmenu=customers_bills', 'Repeatable', 2, 'bills', '$user->rights->facture->lire', '', 2, 4);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1707, 'accountancy', 'preg_match("/customers_bills/i",$leftmenu)', 1704, '/compta/facture/impayees.php?action=facturer&leftmenu=customers_bills', 'Unpaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 5);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1708, 'accountancy', 'preg_match("/customers_bills/i",$leftmenu)', 1704, '/compta/paiement/liste.php?leftmenu=customers_bills_payments', 'Payments', 2, 'bills', '$user->rights->facture->lire', '', 2, 6);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1709, 'accountancy', 'preg_match("/customers_bills_payments/i",$leftmenu)', 1708, '/compta/paiement/avalider.php?leftmenu=customers_bills_payments', 'MenuToValid', 3, 'bills', '$user->rights->facture->lire', '', 2, 0);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1710, 'accountancy', 'preg_match("/customers_bills_payments/i",$leftmenu)', 1708, '/compta/paiement/rapport.php?leftmenu=customers_bills_payments', 'Reportings', 3, 'bills', '$user->rights->facture->lire', '', 2, 1);
 insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1711, 'accountancy', '', 6, '/compta/paiement/cheque/index.php?leftmenu=checks', 'MenuChequeDeposits', 0, 'bills', '$user->rights->facture->lire', '', 2, 1);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1712, 'accountancy', 'eregi("checks",$leftmenu)', 1711, '/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'bills', '$user->rights->facture->lire', '', 2, 0);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1713, 'accountancy', 'eregi("checks",$leftmenu)', 1711, '/compta/paiement/cheque/liste.php?leftmenu=checks', 'MenuChequesReceipts', 1, 'bills', '$user->rights->facture->lire', '', 2, 1);
-insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1714, 'accountancy', 'eregi("customers_bills",$leftmenu)', 1704, '/compta/facture/stats/index.php?leftmenu=customers_bills', 'Statistics', 2, 'bills', '$user->rights->facture->lire', '', 2, 8);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1712, 'accountancy', 'preg_match("/checks/i",$leftmenu)', 1711, '/compta/paiement/cheque/fiche.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'bills', '$user->rights->facture->lire', '', 2, 0);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1713, 'accountancy', 'preg_match("/checks/i",$leftmenu)', 1711, '/compta/paiement/cheque/liste.php?leftmenu=checks', 'MenuChequesReceipts', 1, 'bills', '$user->rights->facture->lire', '', 2, 1);
+insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1714, 'accountancy', 'preg_match("/customers_bills/i",$leftmenu)', 1704, '/compta/facture/stats/index.php?leftmenu=customers_bills', 'Statistics', 2, 'bills', '$user->rights->facture->lire', '', 2, 8);
 insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1715, 'accountancy', '', 1700, '/compta/paiement/cheque/index.php', 'CheckReceipt', 1, 'bills', '$user->rights->facture->lire', '', 1, 4);
 insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1716, 'accountancy', '', 1704, '/compta/paiement/cheque/fiche.php?action=new', 'New', 2, 'bills', '$user->rights->facture->lire', '', 1, 9);
 insert into `llx_menu` (`rowid`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, `right`, `target`, `user`, `order`) values (1717, 'accountancy', '', 1704, '/compta/paiement/cheque/liste.php', 'List', 2, 'bills', '$user->rights->facture->lire', '', 1, 10);
diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php
index 5a3d3e38c58..f820b280e63 100644
--- a/htdocs/install/repair.php
+++ b/htdocs/install/repair.php
@@ -165,13 +165,13 @@ if ($ok)
 	$handle=opendir($dir);
 	while (($file = readdir($handle))!==false)
 	{
-		if (eregi('\.sql$',$file)) $filesindir[]=$file;
+		if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
 	}
 	sort($filesindir);
 
 	foreach($filesindir as $file)
 	{
-		if (eregi('repair',$file))
+		if (preg_match('/repair/i',$file))
 		{
 			$filelist[]=$file;
 		}
diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php
index ba26e7887bd..a3af3254ff0 100644
--- a/htdocs/install/upgrade.php
+++ b/htdocs/install/upgrade.php
@@ -72,7 +72,7 @@ pHeader('',"upgrade2",$_REQUEST['action']);
 $actiondone=0;
 
 // Action to launch the repair or migrate script
-if (! isset($_GET["action"]) || eregi('upgrade',$_GET["action"]))
+if (! isset($_GET["action"]) || preg_match('/upgrade/i',$_GET["action"]))
 {
 	$actiondone=1;
 
@@ -300,18 +300,18 @@ if (! isset($_GET["action"]) || eregi('upgrade',$_GET["action"]))
 		$handle=opendir($dir);
 		while (($file = readdir($handle))!==false)
 		{
-			if (eregi('\.sql$',$file)) $filesindir[]=$file;
+			if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
 		}
 		sort($filesindir);
 
 		# Define which file to run
 		foreach($filesindir as $file)
 		{
-			if (eregi($from,$file))
+			if (preg_match('/'.$from.'/i',$file))
 			{
 				$filelist[]=$file;
 			}
-			else if (eregi($to,$file))	// First test may be false if we migrate from x.y.* to x.y.*
+			else if (preg_match('/'.$to.'/i',$file))	// First test may be false if we migrate from x.y.* to x.y.*
 			{
 				$filelist[]=$file;
 			}
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 4433883499f..db7d7a42023 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -77,7 +77,7 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial
 pHeader('','etape5',$_REQUEST["action"]);
 
 
-if (isset($_POST['action']) && eregi('upgrade',$_POST["action"]))
+if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"]))
 {
 	print '<h3>'.$langs->trans('DataMigration').'</h3>';
 
-- 
GitLab