forked from Wavyzz/dolibarr
Fix: useing "preg_quote" is more simpler
This commit is contained in:
@@ -120,8 +120,7 @@ print "<br>";
|
||||
|
||||
// Show message
|
||||
$message='';
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
$urlwithouturlroot=preg_replace('/'.$pattern.'$/i','',$dolibarr_main_url_root);
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root);
|
||||
$urlvcal='<a href="'.DOL_URL_ROOT.'/comm/action/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$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').'</a>';
|
||||
$message.=$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
|
||||
$message.='<br>';
|
||||
|
||||
@@ -160,9 +160,7 @@ print '<br><br>';
|
||||
print '<u>'.$langs->trans("FollowingUrlAreAvailableToMakePayments").':</u><br>';
|
||||
// Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr'
|
||||
$firstpart=$dolibarr_main_url_root;
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
$regex='/'.$pattern.'$/i';
|
||||
$firstpart=preg_replace($regex,'',$firstpart);
|
||||
$firstpart=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$firstpart);
|
||||
print '<br>';
|
||||
print img_picto('','puce.png').' '.$langs->trans("ToOfferALinkForOnlinePaymentOnFreeAmount",$servicename).':<br>';
|
||||
print '<b>'.$firstpart.DOL_URL_ROOT.'/public/paybox/newpayment.php?amount=<i>9.99</i>&tag=<i>your_free_tag</i></b>'."<br>\n";
|
||||
|
||||
@@ -313,8 +313,7 @@ print "<br>";
|
||||
|
||||
// Show message
|
||||
$message='';
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
$urlwithouturlroot=preg_replace('/'.$pattern.'$/i','',$dolibarr_main_url_root);
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$dolibarr_main_url_root);
|
||||
$urlvcal='<a href="'.DOL_URL_ROOT.'/webcal/webcalexport.php?format=vcal&exportkey='.$conf->global->PHPWEBCALENDAR_PASSWORD_VCALEXPORT.'" target="_blank">'.$urlwithouturlroot.DOL_URL_ROOT.'/webcal/webcalexport.php?format=vcal&exportkey='.$conf->global->PHPWEBCALENDAR_PASSWORD_VCALEXPORT.'</a>';
|
||||
$message.=$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
|
||||
$message.='<br>';
|
||||
|
||||
@@ -92,9 +92,7 @@ print '<br><br>';
|
||||
|
||||
// Should work with DOL_URL_ROOT='' or DOL_URL_ROOT='/dolibarr'
|
||||
$firstpart=$dolibarr_main_url_root;
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
$regex='/'.$pattern.'$/i';
|
||||
$firstpart=preg_replace($regex,'',$firstpart);
|
||||
$firstpart=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',$firstpart);
|
||||
|
||||
print '<u>'.$langs->trans("WSDLCanBeDownloadedHere").':</u><br>';
|
||||
$url=$firstpart.DOL_URL_ROOT.'/webservices/server.php?wsdl';
|
||||
|
||||
@@ -1091,8 +1091,7 @@ class Categorie
|
||||
{
|
||||
$dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
|
||||
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
|
||||
$dir = str_replace('/','\/',$dir); // Add backslashes for regular expression
|
||||
$filename = preg_replace('/'.$dir.'/i','',$file); // Nom du fichier
|
||||
$filename = preg_replace('/'.preg_quote($dir,'/').'/i','',$file); // Nom du fichier
|
||||
|
||||
// On efface l'image d'origine
|
||||
dol_delete_file($file,1);
|
||||
|
||||
@@ -292,8 +292,8 @@ class MenuTop {
|
||||
if (! empty($conf->telephonie->enabled) && $user->rights->telephonie->lire)
|
||||
{
|
||||
$class="";
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
if (preg_match("/^".$pattern."\/telephonie\//",$_SERVER["PHP_SELF"]))
|
||||
$path = DOL_URL_ROOT.'/telephonie/';
|
||||
if (preg_match("/^".preg_quote($path,'/')."/i",$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
@@ -313,8 +313,8 @@ class MenuTop {
|
||||
{
|
||||
$langs->load("energy");
|
||||
$class="";
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
if (preg_match("/^".$pattern."\/energie\//",$_SERVER["PHP_SELF"]))
|
||||
$path = DOL_URL_ROOT.'/energie/';
|
||||
if (preg_match('/^'.preg_quote($path,'/').'/i',$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
|
||||
@@ -292,8 +292,8 @@ class MenuTop {
|
||||
if (! empty($conf->telephonie->enabled) && $user->rights->telephonie->lire)
|
||||
{
|
||||
$class="";
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
if (preg_match("/^".$pattern."\/telephonie\//",$_SERVER["PHP_SELF"]))
|
||||
$path = DOL_URL_ROOT.'/telephonie/';
|
||||
if (preg_match('/^'.preg_quote($path,'/').'/i',$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
@@ -313,8 +313,8 @@ class MenuTop {
|
||||
{
|
||||
$langs->load("energy");
|
||||
$class="";
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
if (preg_match("/^".$pattern."\/energie\//",$_SERVER["PHP_SELF"]))
|
||||
$path = DOL_URL_ROOT.'/energie/';
|
||||
if (preg_match('/^'.preg_quote($path,'/').'/i',$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
|
||||
@@ -249,8 +249,8 @@ class MenuTop {
|
||||
if ($conf->telephonie->enabled && $user->rights->telephonie->lire)
|
||||
{
|
||||
$class="";
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
if (preg_match("/^".$pattern."\/telephonie\//",$_SERVER["PHP_SELF"]))
|
||||
$path = DOL_URL_ROOT.'/telephonie/';
|
||||
if (preg_match('/^'.preg_quote($path,'/').'/i',$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
@@ -268,8 +268,8 @@ class MenuTop {
|
||||
{
|
||||
$langs->load("energy");
|
||||
$class="";
|
||||
$pattern = str_replace('/','\/',DOL_URL_ROOT); // Add backslashes for regular expression
|
||||
if (preg_match("/^".$pattern."\/energie\//",$_SERVER["PHP_SELF"]))
|
||||
$path = DOL_URL_ROOT.'/energie/';
|
||||
if (preg_match('/^'.preg_quote($path,'/').'/i',$_SERVER["PHP_SELF"]))
|
||||
{
|
||||
$class='class="tmenusel"'; $_SESSION['idmenu']='';
|
||||
}
|
||||
|
||||
@@ -301,11 +301,8 @@ function clean_url($url,$http=1)
|
||||
}
|
||||
}
|
||||
|
||||
// Add backslashes for regular expression
|
||||
$proto = str_replace('/','\/',$proto);
|
||||
|
||||
// On passe le nom de domaine en minuscule
|
||||
$CleanUrl = preg_replace('/^'.$proto.$domain.'/i', $newproto.strtolower($domain), $url);
|
||||
$CleanUrl = preg_replace('/^'.preg_quote($proto.$domain,'/').'/i', $newproto.strtolower($domain), $url);
|
||||
|
||||
return $CleanUrl;
|
||||
}
|
||||
|
||||
@@ -2546,8 +2546,7 @@ class Product extends CommonObject
|
||||
{
|
||||
$dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
|
||||
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
|
||||
$pattern = str_replace('/','\/',$dir); // Add backslashes for regular expression
|
||||
$filename = preg_replace('/'.$pattern.'/i','',$file); // Nom du fichier
|
||||
$filename = preg_replace('/'.preg_quote($dir,'/').'/i','',$file); // Nom du fichier
|
||||
|
||||
// On efface l'image d'origine
|
||||
dol_delete_file($file);
|
||||
|
||||
Reference in New Issue
Block a user