BIG PATCH : removing all ereg eregi and ereg_replace, replacing them by str_replace or preg_match as required, xals > y'a moyen de backporter celui-là (qui risque d'être galere, désolé...) ?

This commit is contained in:
Benjamin Sonntag 2011-06-17 09:10:52 +00:00
parent d7680db003
commit d8e3410281
6 changed files with 20 additions and 20 deletions

View File

@ -84,7 +84,7 @@ $classes=array();
/* CLASSES PHP : automatic include : */ /* CLASSES PHP : automatic include : */
$c=opendir($root."class/"); $c=opendir($root."class/");
while ($di=readdir($c)) { while ($di=readdir($c)) {
if (ereg("^m_(.*)\\.php$",$di,$match)) { // $ if (preg_match("#^m_(.*)\\.php$#",$di,$match)) { // $
$name1="m_".$match[1]; $name1="m_".$match[1];
$name2=$match[1]; $name2=$match[1];
$classes[]=$name2; $classes[]=$name2;

View File

@ -190,7 +190,7 @@ function checkfqdn($fqdn) {
// Note: a.foo.net is a valid domain // Note: a.foo.net is a valid domain
// Note: RFC1035 tells us that a domain should not start by a digit, but every registrar allows such a domain to be created ... too bad. // Note: RFC1035 tells us that a domain should not start by a digit, but every registrar allows such a domain to be created ... too bad.
if (!eregi("^[a-z0-9]([a-z0-9-]*[a-z0-9])?$",$val)) { if (!preg_match("#^[a-z0-9]([a-z0-9-]*[a-z0-9])?$#i",$val)) {
return 3; return 3;
} }
} }

View File

@ -328,7 +328,7 @@ class m_admin {
} }
// Vérification de la conformité du login // Vérification de la conformité du login
$login=strtolower($login); $login=strtolower($login);
if (!ereg("^[a-z0-9]*$",$login)) { //$ if (!preg_match("#^[a-z0-9]*$#",$login)) { //$
$err->raise("admin", "Login can only contains characters a-z and 0-9"); $err->raise("admin", "Login can only contains characters a-z and 0-9");
return false; return false;
} }

View File

@ -453,7 +453,7 @@ class m_dom {
$err->log("dom","whois",$domain); $err->log("dom","whois",$domain);
// pour ajouter un nouveau TLD, utiliser le code ci-dessous. // pour ajouter un nouveau TLD, utiliser le code ci-dessous.
// echo "whois : $domain<br />"; // echo "whois : $domain<br />";
ereg(".*\.([^\.]*)",$domain,$out); preg_match("#.*\.([^\.]*)#",$domain,$out);
$ext=$out[1]; $ext=$out[1];
// pour ajouter un nouveau TLD, utiliser le code ci-dessous. // pour ajouter un nouveau TLD, utiliser le code ci-dessous.
// echo "ext: $ext<br />"; // echo "ext: $ext<br />";
@ -464,7 +464,7 @@ class m_dom {
$state=0; $state=0;
while (!feof($fp)) { while (!feof($fp)) {
$ligne = fgets($fp,128); $ligne = fgets($fp,128);
if (ereg('^whois:[[:space:]]+.*$', $ligne)) { $serveur=preg_replace('/whois:\ */','',$ligne,1); } if (preg_match('#^whois:#', $ligne)) { $serveur=preg_replace('/whois:\ */','',$ligne,1); }
} }
} }
@ -495,15 +495,15 @@ class m_dom {
case "biz": case "biz":
case "name": case "name":
case "cc": case "cc":
if (ereg("Name Server:", $ligne)) { if (preg_match("#Name Server:#", $ligne)) {
$found = true; $found = true;
$tmp=strtolower(ereg_replace(chr(10), "",ereg_replace(chr(13),"",ereg_replace(" ","", ereg_replace("Name Server:","", $ligne))))); $tmp=strtolower(str_replace(chr(10), "",str_replace(chr(13),"",str_replace(" ","", str_replace("Name Server:","", $ligne)))));
if ($tmp) if ($tmp)
$server[]=$tmp; $server[]=$tmp;
} }
break; break;
case "cx": case "cx":
$ligne = ereg_replace(chr(10), "",ereg_replace(chr(13),"",ereg_replace(" ","", $ligne))); $ligne = str_replace(chr(10), "",str_replace(chr(13),"",str_replace(" ","", $ligne)));
if ($ligne=="" && $state==1) if ($ligne=="" && $state==1)
$state=2; $state=2;
if ($state==1) if ($state==1)
@ -536,7 +536,7 @@ class m_dom {
} }
break; break;
case "it": case "it":
if (ereg("nserver:", $ligne)) { if (preg_match("#nserver:#", $ligne)) {
$found=true; $found=true;
$tmp=strtolower(preg_replace("/nserver:\s*[^ ]*\s*([^\s]*)$/","\\1", $ligne)); $tmp=strtolower(preg_replace("/nserver:\s*[^ ]*\s*([^\s]*)$/","\\1", $ligne));
if ($tmp) if ($tmp)
@ -545,20 +545,20 @@ class m_dom {
break; break;
case "fr": case "fr":
case "re": case "re":
if (ereg("nserver:", $ligne)) { if (preg_match("#nserver:#", $ligne)) {
$found=true; $found=true;
$tmp=strtolower(preg_replace("/nserver:\s*([^\s]*)\s*.*$/","\\1", $ligne)); $tmp=strtolower(preg_replace("#nserver:\s*([^\s]*)\s*.*$#","\\1", $ligne));
if ($tmp) if ($tmp)
$server[]=$tmp; $server[]=$tmp;
} }
break; break;
case "ca": case "ca":
case "ws"; case "ws";
if (ereg('^[[:space:]]*Name servers:[[:space:]]*$', $ligne)) { if (preg_match('#Name servers#', $ligne)) {
// found the server // found the server
$state = 1; $state = 1;
} elseif ($state) { } elseif ($state) {
if (ereg('^[^%]', $ligne) && $ligne = ereg_replace('[[:space:]]', "", $ligne)) { if (preg_match('#^[^%]#', $ligne) && $ligne = preg_replace('#[[:space:]]#', "", $ligne)) {
// first non-whitespace line is considered to be the nameservers themselves // first non-whitespace line is considered to be the nameservers themselves
$found = true; $found = true;
$server[] = $ligne; $server[] = $ligne;
@ -566,7 +566,7 @@ class m_dom {
} }
break; break;
case "coop": case "coop":
if (preg_match('/Host Name:\s*([^\s]+)/', $ligne, $matches)) { if (preg_match('#Host Name:\s*([^\s]+)#', $ligne, $matches)) {
$found = true; $found = true;
$server[] = $matches[1]; $server[] = $matches[1];
} }

View File

@ -492,8 +492,8 @@ Cordialement.
if ($this->user["show_help"] || $force) { if ($this->user["show_help"] || $force) {
$hlp=_("hlp_$file"); $hlp=_("hlp_$file");
if ($hlp!="hlp_$file") { if ($hlp!="hlp_$file") {
$hlp=ereg_replace( $hlp=preg_replace(
"HELPID_([0-9]*)", "#HELPID_([0-9]*)#",
"<a href=\"javascript:help(\\1);\"><img src=\"/admin/aide/help.png\" width=\"17\" height=\"17\" style=\"vertical-align: middle;\" alt=\""._("Help")."\" /></a>",$hlp); "<a href=\"javascript:help(\\1);\"><img src=\"/admin/aide/help.png\" width=\"17\" height=\"17\" style=\"vertical-align: middle;\" alt=\""._("Help")."\" /></a>",$hlp);
echo "<p class=\"hlp\">".$hlp."</p>"; echo "<p class=\"hlp\">".$hlp."</p>";
return true; return true;

View File

@ -135,7 +135,7 @@ class m_mysql {
$err->raise("mysql",1); $err->raise("mysql",1);
return false; return false;
} }
if (!ereg("^[0-9a-z]*$",$dbn)) { if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
$err->raise("mysql",2); $err->raise("mysql",2);
return false; return false;
} }
@ -218,7 +218,7 @@ class m_mysql {
function put_mysql_backup($dbn,$bck_mode,$bck_history,$bck_gzip,$bck_dir) { function put_mysql_backup($dbn,$bck_mode,$bck_history,$bck_gzip,$bck_dir) {
global $db,$err,$mem,$bro,$cuid; global $db,$err,$mem,$bro,$cuid;
$err->log("mysql","put_mysql_backup"); $err->log("mysql","put_mysql_backup");
if (!ereg("^[0-9a-z]*$",$dbn)) { if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
$err->raise("mysql",2); $err->raise("mysql",2);
return false; return false;
} }
@ -443,7 +443,7 @@ class m_mysql {
$err->raise("mysql",13); $err->raise("mysql",13);
return false; return false;
} }
if (!ereg("^[0-9a-z]",$usern)) { if (!preg_match("#^[0-9a-z]#",$usern)) {
$err->raise("mysql",14); $err->raise("mysql",14);
return false; return false;
} }
@ -519,7 +519,7 @@ class m_mysql {
function del_user($user) { function del_user($user) {
global $db,$err,$mem,$cuid,$L_MYSQL_DATABASE; global $db,$err,$mem,$cuid,$L_MYSQL_DATABASE;
$err->log("mysql","del_user",$user); $err->log("mysql","del_user",$user);
if (!ereg("^[0-9a-z]",$user)) { if (!preg_match("#^[0-9a-z]#",$user)) {
$err->raise("mysql",14); $err->raise("mysql",14);
return false; return false;
} }