diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php
index 735cc8f268a..2b5cdd0e824 100644
--- a/htdocs/admin/agenda_xcal.php
+++ b/htdocs/admin/agenda_xcal.php
@@ -120,9 +120,8 @@ print "
";
// Show message
$message='';
-$slash = '/';
-$backslash = strtr($slash, '/', '\\');
-$urlwithouturlroot=preg_replace('/'.$backslash.DOL_URL_ROOT.'$/i','',$dolibarr_main_url_root);
+$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
+$urlwithouturlroot=preg_replace('/'.$pattern.'$/i','',$dolibarr_main_url_root);
$urlvcal=''.$urlwithouturlroot.DOL_URL_ROOT.'/comm/action/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'';
$message.=$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
$message.='
';
diff --git a/htdocs/admin/paybox.php b/htdocs/admin/paybox.php
index 4d1dbbec0a4..5d69bde5fc8 100644
--- a/htdocs/admin/paybox.php
+++ b/htdocs/admin/paybox.php
@@ -160,9 +160,8 @@ print '
';
print ''.$langs->trans("FollowingUrlAreAvailableToMakePayments").':
';
// Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr'
$firstpart=$dolibarr_main_url_root;
-$slash = '/';
-$backslash = strtr($slash, '/', '\\');
-$regex='/'.$backslash.DOL_URL_ROOT.'$/i';
+$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
+$regex='/'.$pattern.'$/i';
$firstpart=preg_replace($regex,'',$firstpart);
print '
';
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':
';
diff --git a/htdocs/admin/webcalendar.php b/htdocs/admin/webcalendar.php
index 9918a344c18..e1790a6b50e 100644
--- a/htdocs/admin/webcalendar.php
+++ b/htdocs/admin/webcalendar.php
@@ -313,9 +313,8 @@ print "
";
// Show message
$message='';
-$slash = '/';
-$backslash = strtr($slash, '/', '\\');
-$urlwithouturlroot=preg_replace('/'.$backslash.DOL_URL_ROOT.'$/i','',$dolibarr_main_url_root);
+$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
+$urlwithouturlroot=preg_replace('/'.$pattern.'$/i','',$dolibarr_main_url_root);
$urlvcal=''.$urlwithouturlroot.DOL_URL_ROOT.'/webcal/webcalexport.php?format=vcal&exportkey='.$conf->global->PHPWEBCALENDAR_PASSWORD_VCALEXPORT.'';
$message.=$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
$message.='
';
diff --git a/htdocs/admin/webservices.php b/htdocs/admin/webservices.php
index 55795db4524..75734829918 100644
--- a/htdocs/admin/webservices.php
+++ b/htdocs/admin/webservices.php
@@ -92,9 +92,8 @@ print '
';
// Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr'
$firstpart=$dolibarr_main_url_root;
-$slash = '/';
-$backslash = strtr($slash, '/', '\\');
-$regex='/'.$backslash.DOL_URL_ROOT.'$/i';
+$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
+$regex='/'.$pattern.'$/i';
$firstpart=preg_replace($regex,'',$firstpart);
print ''.$langs->trans("WSDLCanBeDownloadedHere").':
';
diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php
index 31744796bfe..a9fd66fa19a 100644
--- a/htdocs/categories/categorie.class.php
+++ b/htdocs/categories/categorie.class.php
@@ -612,7 +612,7 @@ class Categorie
$this->cats[$id_categ]['fulllabel']=$this->cats[$id_categ]['label'];
}
// We count number of _ to have level
- $this->cats[$id_categ]['level']=strlen(eregi_replace('[^_]','',$this->cats[$id_categ]['fullpath']));
+ $this->cats[$id_categ]['level']=strlen(preg_replace('/[^_]/i','',$this->cats[$id_categ]['fullpath']));
// Process all childs on several levels of this category
$protection++;
@@ -1059,9 +1059,9 @@ class Categorie
// On determine nom du fichier vignette
$photo_vignette='';
- if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$photo,$regs))
+ if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$photo,$regs))
{
- $photo_vignette=eregi_replace($regs[0],'',$photo).'_small'.$regs[0];
+ $photo_vignette=preg_replace('/'.$regs[0].'/i','',$photo).'_small'.$regs[0];
}
// Objet
@@ -1091,15 +1091,16 @@ class Categorie
{
$dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
- $filename = eregi_replace($dir,'',$file); // Nom du fichier
+ $dir = str_replace('/','\/',$dir); // Add backslashes for regular expression
+ $filename = preg_replace('/'.$dir.'/i','',$file); // Nom du fichier
// On efface l'image d'origine
dol_delete_file($file,1);
// Si elle existe, on efface la vignette
- if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$filename,$regs))
+ if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$filename,$regs))
{
- $photo_vignette=eregi_replace($regs[0],'',$filename).'_small'.$regs[0];
+ $photo_vignette=preg_replace('/'.$regs[0].'/i','',$filename).'_small'.$regs[0];
if (file_exists($dirthumb.$photo_vignette))
{
dol_delete_file($dirthumb.$photo_vignette,1);