From 7c45bfe83380abc200dba640ba74a551f28ab2df Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 8 Jan 2018 19:08:39 +0100 Subject: [PATCH] Replace ereg() function call by preg_match() --- .../LSattr_html/LSattr_html_maildir.docbook | 4 ++-- .../conf/LSaddons/config.LSaddons.maildir.php | 6 ++---- .../includes/addons/LSaddons.maildir.php | 2 +- .../class/class.LSattr_html_maildir.php | 2 +- .../class/class.LSformElement_mailQuota.php | 2 +- .../class/class.LSformElement_quota.php | 2 +- .../class.LSformElement_valueWithUnit.php | 2 +- .../includes/class/class.LSsession.php | 6 +++--- public_html/includes/functions.php | 20 +++++++++---------- 9 files changed, 22 insertions(+), 24 deletions(-) diff --git a/doc/conf/LSattribute/LSattr_html/LSattr_html_maildir.docbook b/doc/conf/LSattribute/LSattr_html/LSattr_html_maildir.docbook index 2b8fa322..9beb91c2 100644 --- a/doc/conf/LSattribute/LSattr_html/LSattr_html_maildir.docbook +++ b/doc/conf/LSattribute/LSattr_html/LSattr_html_maildir.docbook @@ -43,7 +43,7 @@ remoteRootPathRegex - Expression régulière facultative dont le but est de + Expression régulière (compatible Perl) facultative dont le but est de matcher dans la valeur complète du chemin distant de la maildir, le chemin de la maildir à créer une fois connecté sur le serveur. @@ -52,7 +52,7 @@ se connecte arrive directement dans /home/vmail, et faut définir le paramètre remoteRootPathRegex de la manière suivante : - ^\/home\/vmail\/([^\/]*)\/+$ + /^\/home\/vmail\/([^\/]*)\/+$/ diff --git a/public_html/conf/LSaddons/config.LSaddons.maildir.php b/public_html/conf/LSaddons/config.LSaddons.maildir.php index aab8ad69..10fa1ab3 100644 --- a/public_html/conf/LSaddons/config.LSaddons.maildir.php +++ b/public_html/conf/LSaddons/config.LSaddons.maildir.php @@ -41,10 +41,8 @@ define('LS_MAILDIR_FTP_PWD','password'); // Serveur FTP - Maildir Path define('LS_MAILDIR_FTP_MAILDIR_PATH','%{mailbox}'); -// Serveur FTP - Maildir Path Regex -define('LS_MAILDIR_FTP_MAILDIR_PATH_REGEX','^\/home\/vmail\/([^\/]+)\/$'); +// Serveur FTP - Maildir Path Regex (Perl compatible) +define('LS_MAILDIR_FTP_MAILDIR_PATH_REGEX','/^\/home\/vmail\/([^\/]+)\/$/'); // Serveur FTP - Maildir CHMOD define('LS_MAILDIR_FTP_MAILDIR_CHMOD','700'); - -?> diff --git a/public_html/includes/addons/LSaddons.maildir.php b/public_html/includes/addons/LSaddons.maildir.php index a4097073..b099c179 100644 --- a/public_html/includes/addons/LSaddons.maildir.php +++ b/public_html/includes/addons/LSaddons.maildir.php @@ -146,7 +146,7 @@ $retval=true; $dir = getFData(LS_MAILDIR_FTP_MAILDIR_PATH,$ldapObject,'getValue'); if (LS_MAILDIR_FTP_MAILDIR_PATH_REGEX != "") { - if (ereg(LS_MAILDIR_FTP_MAILDIR_PATH_REGEX,$dir,$regs)) { + if (preg_match(LS_MAILDIR_FTP_MAILDIR_PATH_REGEX,$dir,$regs)) { $dir = $regs[1]; } else { diff --git a/public_html/includes/class/class.LSattr_html_maildir.php b/public_html/includes/class/class.LSattr_html_maildir.php index 8cc87e83..f8e1d639 100644 --- a/public_html/includes/class/class.LSattr_html_maildir.php +++ b/public_html/includes/class/class.LSattr_html_maildir.php @@ -114,7 +114,7 @@ class LSattr_html_maildir extends LSattr_html { } if ($this -> config['html_options']['remoteRootPathRegex']) { if ( - ereg($this -> config['html_options']['remoteRootPathRegex'],$val,$r) + preg_match($this -> config['html_options']['remoteRootPathRegex'],$val,$r) || empty($val) ) diff --git a/public_html/includes/class/class.LSformElement_mailQuota.php b/public_html/includes/class/class.LSformElement_mailQuota.php index 91ad93a8..c445f4e0 100644 --- a/public_html/includes/class/class.LSformElement_mailQuota.php +++ b/public_html/includes/class/class.LSformElement_mailQuota.php @@ -54,7 +54,7 @@ class LSformElement_mailQuota extends LSformElement { $quotas=array(); foreach ($this -> values as $value) { - if (ereg('([0-9]*)'.$this -> getSuffix(),$value,$regs)) { + if (preg_match('/([0-9]*)/'.$this -> getSuffix(),$value,$regs)) { $infos = array( 'size' => $regs[1] ); diff --git a/public_html/includes/class/class.LSformElement_quota.php b/public_html/includes/class/class.LSformElement_quota.php index ae735928..176a6db7 100644 --- a/public_html/includes/class/class.LSformElement_quota.php +++ b/public_html/includes/class/class.LSformElement_quota.php @@ -54,7 +54,7 @@ class LSformElement_quota extends LSformElement { $quotas=array(); foreach ($this -> values as $value) { - if (ereg('^([0-9]*)$',$value,$regs)) { + if (preg_match('/^([0-9]*)$/',$value,$regs)) { $infos = array( 'size' => ceil($regs[1]/$this -> getFactor()) ); diff --git a/public_html/includes/class/class.LSformElement_valueWithUnit.php b/public_html/includes/class/class.LSformElement_valueWithUnit.php index caa6f94d..c793150e 100644 --- a/public_html/includes/class/class.LSformElement_valueWithUnit.php +++ b/public_html/includes/class/class.LSformElement_valueWithUnit.php @@ -87,7 +87,7 @@ class LSformElement_valueWithUnit extends LSformElement { if ($units) { foreach ($this -> values as $value) { - if (ereg('^([0-9]*)$',$value,$regs)) { + if (preg_match('/^([0-9]*)$/',$value,$regs)) { $infos = array( 'value' => $regs[1] ); diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index d09641db..304e4c48 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -394,15 +394,15 @@ class LSsession { public static function getLangList() { $list=array('en_US'); if (self :: $encoding) { - $regex = '^([a-zA-Z_]*)\.'.self :: $encoding.'$'; + $regex = '/^([a-zA-Z_]*)\.'.self :: $encoding.'$/'; } else { - $regex = '^([a-zA-Z_]*)$'; + $regex = '/^([a-zA-Z_]*)$/'; } if ($handle = opendir(LS_I18N_DIR)) { while (false !== ($file = readdir($handle))) { if(is_dir(LS_I18N_DIR.'/'.$file)) { - if (ereg($regex,$file,$regs)) { + if (preg_match($regex,$file,$regs)) { if (!in_array($regs[1],$list)) { $list[]=$regs[1]; } diff --git a/public_html/includes/functions.php b/public_html/includes/functions.php index 5f3f7f3a..3cd0c01a 100644 --- a/public_html/includes/functions.php +++ b/public_html/includes/functions.php @@ -52,7 +52,7 @@ function getFData($format,$data,$meth=NULL) { * - 7 : ! or _ * - 8 : ~ */ - $expr="%[{(]([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?[})]"; + $expr="/%[{(]([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?[})]/"; if(!is_array($format)) { $format=array($format); $unique=true; @@ -60,7 +60,7 @@ function getFData($format,$data,$meth=NULL) { for($i=0;$i $meth(); if (is_array($value)) { @@ -90,7 +90,7 @@ function getFData($format,$data,$meth=NULL) { } elseif (is_object($data)) { if ($meth==NULL) { - while (ereg($expr,$format[$i],$ch)) { + while (preg_match($expr,$format[$i],$ch)) { $value = $data -> $ch[1]; if (is_array($value)) { $value = $value[0]; @@ -100,7 +100,7 @@ function getFData($format,$data,$meth=NULL) { } } else { - while (ereg($expr,$format[$i],$ch)) { + while (preg_match($expr,$format[$i],$ch)) { if (method_exists($data,$meth)) { $value = $data -> $meth($ch[1]); if (is_array($value)) { @@ -117,7 +117,7 @@ function getFData($format,$data,$meth=NULL) { } } else { - while (ereg($expr,$format[$i],$ch)) { + while (preg_match($expr,$format[$i],$ch)) { $val=_getFData_extractAndModify($data,$ch); $format[$i]=str_replace($ch[0],$val,$format[$i]); } @@ -194,18 +194,18 @@ function _getFData_extractAndModify($data,$ch) { function getFieldInFormat($format) { $fields=array(); - $expr="%[{(]([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?[})]"; - while (ereg($expr,$format,$ch)) { + $expr='/%[{(]([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?[})]/'; + while (preg_match($expr,$format,$ch)) { $fields[]=$ch[1]; $format=str_replace($ch[0],'',$format); } return $fields; } -function loadDir($dir,$regexpr='^.*\.php$') { +function loadDir($dir,$regexpr='/^.*\.php$/') { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { - if (ereg($regexpr,$file)) { + if (preg_match($regexpr,$file)) { require_once($dir.'/'.$file); } }