From f8599fe188f3203b00793d9e4d2562b817716b37 Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Wed, 21 Feb 2007 21:41:45 +0000 Subject: [PATCH] "suite et fin de #329 sur les ereg, eregi et eregi_replace" --- ecrire/action/editer_site.php | 10 ++++----- ecrire/action/virtualiser.php | 2 +- ecrire/balise/login_public.php | 2 +- ecrire/inc/boutons.php | 2 +- ecrire/inc/chercher_rubrique.php | 2 +- ecrire/inc/distant.php | 4 ++-- ecrire/inc/filtres.php | 4 ++-- ecrire/inc/headers.php | 2 +- ecrire/inc/lang.php | 2 +- ecrire/inc/layer.php | 18 +++++++-------- ecrire/inc/presentation.php | 2 +- ecrire/inc/statistiques.php | 21 +++++++++--------- ecrire/inc/texte.php | 6 ++--- ecrire/inc/traduire.php | 2 +- ecrire/install/etape_1.php | 6 ++--- ecrire/install/etape_ldap1.php | 2 +- ecrire/public/balises.php | 8 +++---- ecrire/public/compiler.php | 8 +++---- ecrire/public/criteres.php | 10 ++++----- ecrire/public/debug.php | 8 +++---- ecrire/public/phraser_html.php | 38 ++++++++++++++++---------------- ecrire/public/references.php | 2 +- 22 files changed, 81 insertions(+), 80 deletions(-) diff --git a/ecrire/action/editer_site.php b/ecrire/action/editer_site.php index 65df21cb63..5951036acf 100644 --- a/ecrire/action/editer_site.php +++ b/ecrire/action/editer_site.php @@ -299,13 +299,13 @@ function analyser_site($url) { else { $result['syndication'] = 'non'; $result['url_site'] = $url; - if (eregi('<head>(.*)', $texte, $regs)) - $head = filtrer_entites(eregi_replace('</head>.*', '', $regs[1])); + if (preg_match(',<head>(.*),i', $texte, $regs)) + $head = filtrer_entites(preg_replace(',</head>.*,i', '', $regs[1])); else $head = $texte; - if (eregi('<title[^>]*>(.*)', $head, $regs)) - $result['nom_site'] = filtrer_entites(supprimer_tags(eregi_replace('</title>.*', '', $regs[1]))); - if (eregi('<meta[[:space:]]+(name|http\-equiv)[[:space:]]*=[[:space:]]*[\'"]?description[\'"]?[[:space:]]+(content|value)[[:space:]]*=[[:space:]]*[\'"]([^>]+)[\'"]>', $head, $regs)) + if (preg_match(',<title[^>]*>(.*),i', $head, $regs)) + $result['nom_site'] = filtrer_entites(supprimer_tags(preg_replace(',</title>.*,i', '', $regs[1]))); + if (preg_match(',<meta[[:space:]]+(name|http\-equiv)[[:space:]]*=[[:space:]]*[\'"]?description[\'"]?[[:space:]]+(content|value)[[:space:]]*=[[:space:]]*[\'"]([^>]+)[\'"]>,i', $head, $regs)) $result['descriptif'] = filtrer_entites(supprimer_tags($regs[3])); // Cherchons quand meme un backend diff --git a/ecrire/action/virtualiser.php b/ecrire/action/virtualiser.php index 1b116f1b5c..dd9710562f 100644 --- a/ecrire/action/virtualiser.php +++ b/ecrire/action/virtualiser.php @@ -29,7 +29,7 @@ function action_virtualiser_dist() { // http://doc.spip.org/@action_virtualiser_post function action_virtualiser_post($r, $url) { - $url = eregi_replace("^ *https?://$", "", rtrim($url)); + $url = preg_replace(",^ *https?://$,i", "", rtrim($url)); if ($url) $url = corriger_caracteres("=$url"); spip_query("UPDATE spip_articles SET chapo=" . _q($url) . ", date_modif=NOW() WHERE id_article=" . $r[1]); } diff --git a/ecrire/balise/login_public.php b/ecrire/balise/login_public.php index 72c47d13fd..eb2f93b54f 100644 --- a/ecrire/balise/login_public.php +++ b/ecrire/balise/login_public.php @@ -102,7 +102,7 @@ function login_pour_tous($login, $cible, $action) { $auth_http = ''; if ($echec_cookie AND !$ignore_auth_http) { if (($GLOBALS['flag_sapi_name'] - AND eregi("apache", @php_sapi_name())) + AND preg_match(",apache,i", @php_sapi_name())) OR preg_match(",^Apache.* PHP,", $_SERVER['SERVER_SOFTWARE'])) $auth_http = $pose_cookie; } diff --git a/ecrire/inc/boutons.php b/ecrire/inc/boutons.php index a97561f618..4c8499217d 100644 --- a/ecrire/inc/boutons.php +++ b/ecrire/inc/boutons.php @@ -387,7 +387,7 @@ function icone_bandeau_principal($texte, $lien, $fond, $rubrique_icone = "vide", $class_select = ($sous_rubrique_icone == $sous_rubrique) ? " class='selection'" : ''; - if (eregi("^javascript:",$lien)) { + if (strcasecmp("javascript:",$lien,11)==0) { $a_href = "\nonclick=\"$lien; return false;\" href='$lien_noscript' "; } else { diff --git a/ecrire/inc/chercher_rubrique.php b/ecrire/inc/chercher_rubrique.php index cd2ee7ac13..72745f1444 100644 --- a/ecrire/inc/chercher_rubrique.php +++ b/ecrire/inc/chercher_rubrique.php @@ -47,7 +47,7 @@ function style_menu_rubriques($i) { global $couleur_claire, $spip_lang_left; $espace = ''; - if (eregi("mozilla", $browser_name)) { + if (preg_match(",mozilla,i", $browser_name)) { $style = "padding-$spip_lang_left: 16px; " . "margin-$spip_lang_left: ".(($i-1)*16)."px;"; } else { diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php index bfb4bdc946..2b96fc796b 100644 --- a/ecrire/inc/distant.php +++ b/ecrire/inc/distant.php @@ -195,7 +195,7 @@ function recuperer_page($url, $munge_charset=false, $get_headers=false, $headers = ''; while ($s = trim(fgets($f, 16384))) { $headers .= $s."\n"; - if (eregi('^Location: (.*)', $s, $r)) { + if (preg_match(',^Location: (.*),i', $s, $r)) { include_spip('inc/filtres'); $location = suivre_lien($url, $r[1]); spip_log("Location: $location"); @@ -380,7 +380,7 @@ function recuperer_infos_distantes($source, $max=0) { function init_http($get, $url, $refuse_gz=false, $uri_referer = '') { $via_proxy = ''; $proxy_user = ''; $fopen = false; $http_proxy = $GLOBALS['meta']["http_proxy"]; - if (!eregi("^http://", $http_proxy)) + if (strncmp("http://", $http_proxy,7)!=0) $http_proxy = ''; else $via_proxy = " (proxy $http_proxy)"; diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index 1f33182fed..505b87857b 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -1420,9 +1420,9 @@ function email_valide($adresses) { foreach (explode(',', $adresses) as $v) { // nettoyer certains formats // "Marie Toto <Marie@toto.com>" - $adresse = trim(eregi_replace("^[^<>\"]*<([^<>\"]+)>$", "\\1", $v)); + $adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v)); // RFC 822 - if (!eregi('^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$', $adresse)) + if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) return false; } return $adresse; diff --git a/ecrire/inc/headers.php b/ecrire/inc/headers.php index d84267ee7f..b4e977c08a 100644 --- a/ecrire/inc/headers.php +++ b/ecrire/inc/headers.php @@ -70,7 +70,7 @@ function http_status($status) { if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return; - $php_cgi = ($flag_sapi_name AND eregi("cgi", @php_sapi_name())); + $php_cgi = ($flag_sapi_name AND preg_match(",cgi,i", @php_sapi_name())); if ($php_cgi) header("Status: ".$status_string[$status]); else diff --git a/ecrire/inc/lang.php b/ecrire/inc/lang.php index 1e017329ce..5bb6819266 100644 --- a/ecrire/inc/lang.php +++ b/ecrire/inc/lang.php @@ -291,7 +291,7 @@ function utiliser_langue_visiteur() { return $l; foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) { - if (eregi('^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$', trim($s), $r)) { + if (preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#', trim($s), $r)) { if (changer_langue($l=strtolower($r[1]))) return $l; } } diff --git a/ecrire/inc/layer.php b/ecrire/inc/layer.php index b6f304967d..b5924c7ce9 100644 --- a/ecrire/inc/layer.php +++ b/ecrire/inc/layer.php @@ -175,34 +175,34 @@ function verif_butineur() { $browser_layer = ''; $browser_barre = ''; - if (!eregi("opera", $browser_description)&&eregi("opera", $browser_name)) { + if (!preg_match(",opera,i", $browser_description)&&preg_match(",opera,i", $browser_name)) { $browser_name = "Opera"; $browser_version = $match[2]; $browser_layer = (($browser_version < 7) ? '' : http_script('', _DIR_JAVASCRIPT . 'layer.js','')); $browser_barre = ($browser_version >= 8.5); } - else if (eregi("opera", $browser_description)) { - eregi("Opera ([^\ ]*)", $browser_description, $match); + else if (preg_match(",opera,i", $browser_description)) { + preg_match(",Opera ([^\ ]*),i", $browser_description, $match); $browser_name = "Opera"; $browser_version = $match[1]; $browser_layer = (($browser_version < 7) ? '' : http_script('', _DIR_JAVASCRIPT . 'layer.js','')); $browser_barre = ($browser_version >= 8.5); } - else if (eregi("msie", $browser_description)) { - eregi("MSIE ([^;]*)", $browser_description, $match); + else if (preg_match(",msie,i", $browser_description)) { + preg_match(",MSIE ([^;]*),i", $browser_description, $match); $browser_name = "MSIE"; $browser_version = $match[1]; $browser_layer = (($browser_version < 5) ? '' : http_script('', _DIR_JAVASCRIPT . 'layer.js','')); $browser_barre = ($browser_version >= 5.5); } - else if (eregi("KHTML", $browser_description) && - eregi("Safari/([^;]*)", $browser_description, $match)) { + else if (preg_match(",KHTML,i", $browser_description) && + preg_match(",Safari/([^;]*),", $browser_description, $match)) { $browser_name = "Safari"; $browser_version = $match[1]; $browser_layer = http_script('', _DIR_JAVASCRIPT . 'layer.js',''); $browser_barre = ($browser_version >= 5.0); } - else if (eregi("mozilla", $browser_name) AND $browser_version >= 5) { + else if (preg_match(",mozilla,i", $browser_name) AND $browser_version >= 5) { $browser_layer = http_script('', _DIR_JAVASCRIPT . 'layer.js',''); // Numero de version pour Mozilla "authentique" if (preg_match(",rv:([0-9]+\.[0-9]+),", $browser_description, $match)) @@ -257,7 +257,7 @@ ondblclick='storeCaret(this);'"); // Hack pour forcer largeur des formo/forml sous Mozilla >= 1.7 // meme principe que le behavior win_width.htc pour MSIE -$GLOBALS['browser_verifForm'] = (eregi("mozilla", $GLOBALS["browser_name"]) AND $GLOBALS["browser_rev"] >= 1.7) ? "verifForm();" : ""; +$GLOBALS['browser_verifForm'] = (preg_match(",mozilla,i", $GLOBALS["browser_name"]) AND $GLOBALS["browser_rev"] >= 1.7) ? "verifForm();" : ""; // http://doc.spip.org/@http_script function http_script($script, $src='', $noscript='') { diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php index 73e9aa83ce..de4371a18e 100644 --- a/ecrire/inc/presentation.php +++ b/ecrire/inc/presentation.php @@ -337,7 +337,7 @@ function afficher_liste_display_neq4($largeurs, $t, $styles = '') { global $spip_lang_left,$browser_name; - $evt = (eregi("msie", $browser_name) ? " onmouseover=\"changeclass(this,'tr_liste_over');\" onmouseout=\"changeclass(this,'tr_liste');\"" :''); + $evt = (preg_match(",msie,i", $browser_name) ? " onmouseover=\"changeclass(this,'tr_liste_over');\" onmouseout=\"changeclass(this,'tr_liste');\"" :''); reset($largeurs); if ($styles) reset($styles); diff --git a/ecrire/inc/statistiques.php b/ecrire/inc/statistiques.php index f44b87e3d5..c4d2769e2c 100644 --- a/ecrire/inc/statistiques.php +++ b/ecrire/inc/statistiques.php @@ -28,9 +28,9 @@ function stats_load_engines() { { $data = trim(chop($data)); - if (!ereg('^#', $data) && $data != '') + if (strncmp('#',$data,1)==0 && $data != '') { - if (ereg('^\[(.*)\]$', $data, $engines)) + if (preg_match(',^\[(.*)\]$,', $data, $engines)) { // engine $engine = $engines[1]; @@ -65,7 +65,7 @@ function stats_show_keywords($kw_referer, $kw_referer_host) { // initialiser la recherche interne $url_site = $GLOBALS['meta']['adresse_site']; - $url_site = strtolower(eregi_replace("^((https?|ftp)://)?(www\.)?", "", $url_site)); + $url_site = preg_replace(",^((https?|ftp)://)?(www\.)?,", "", strtolower($url_site)); } $url = @parse_url( $kw_referer ); @@ -80,8 +80,8 @@ function stats_show_keywords($kw_referer, $kw_referer_host) { $found = false; - if (strpos('-'.$kw_referer, eregi_replace("^(https?:?/?/?)?(www\.)?", "",$url_site))) { - if (eregi("(s|search|r|recherche)=([^&]+)", $kw_referer, $regs)) + if (strpos('-'.$kw_referer, preg_replace(",^(https?:?/?/?)?(www\.)?,", "",$url_site))!==false) { + if (preg_match(",(s|search|r|recherche)=([^&]+),i", $kw_referer, $regs)) $keywords = urldecode($regs[2]); @@ -90,18 +90,19 @@ function stats_show_keywords($kw_referer, $kw_referer_host) { } else for ($cnt = 0; $cnt < sizeof($arr_engines) && !$found; $cnt++) { - if ($found = (ereg($arr_engines[$cnt][2], $host)) OR $found = (ereg($arr_engines[$cnt][2], $path))) + if ( $found = (strpos($host,$arr_engines[$cnt][2])!==false) + OR $found = (strpos($path,$arr_engines[$cnt][2])!==false)) { $kw_referer_host = $arr_engines[$cnt][0]; - if (ereg('=', $arr_engines[$cnt][1])) { + if (strpos($arr_engines[$cnt][1],'=')!==false) { // Fonctionnement simple: la variable existe $keywords = ${str_replace('=', '', $arr_engines[$cnt][1])}; // Si on a defini le nom de la variable en expression reguliere, chercher la bonne variable if (! strlen($keywords) > 0) { - if (ereg($arr_engines[$cnt][1]."([^\&]*)", $query, $vals)) { + if (preg_match(",".preg_quote($arr_engines[$cnt][1],',')."([^\&]*),", $query, $vals)) { $keywords = urldecode($vals[2]); } } @@ -110,7 +111,7 @@ function stats_show_keywords($kw_referer, $kw_referer_host) { } if (( ($kw_referer_host == "Google") - || ($kw_referer_host == "AOL" && !ereg('enc=iso', $query)) + || ($kw_referer_host == "AOL" && strpos($query,'enc=iso')===false) || ($kw_referer_host == "MSN") )) { include_spip('inc/charsets'); @@ -220,7 +221,7 @@ function aff_referers ($result, $limit, $plus) { } else { $aff .= $ret; $lien = $lesreferers[$numero][0]; - if (eregi("^(<a [^>]+>)([^ ]*)( \([0-9]+\))?", $lien, $regs)) { + if (preg_match(",^(<a [^>]+>)([^ ]*)( \([0-9]+\))?,i", $lien, $regs)) { $lien = quote_amp($regs[1]).$lesdomaines[$numero].$regs[2]; if (!strpos($lien, '</a>')) $lien .= '</a>'; } else diff --git a/ecrire/inc/texte.php b/ecrire/inc/texte.php index ca84fe2be4..214c2d6b2e 100644 --- a/ecrire/inc/texte.php +++ b/ecrire/inc/texte.php @@ -331,7 +331,7 @@ function couper($texte, $taille=50) { // prendre <intro>...</intro> sinon couper a la longueur demandee // http://doc.spip.org/@couper_intro function couper_intro($texte, $long) { - $texte = extraire_multi(eregi_replace("(</?)intro>", "\\1intro>", $texte)); // minuscules + $texte = extraire_multi(preg_replace(",(</?)intro>,i", "\\1intro>", $texte)); // minuscules $intro = ''; while ($fin = strpos($texte, "</intro>")) { $zone = substr($texte, 0, $fin); @@ -861,7 +861,7 @@ function traiter_tableau($bloc) { // Sinon ligne normale if ($l) { // Gerer les listes a puce dans les cellules - if (ereg("\n-[*#]", $ligne)) + if (strpos($ligne,"\n-*")!==false OR strpos($ligne,"\n-#")!==false) $ligne = traiter_listes($ligne); // Pas de paragraphes dans les cellules @@ -1416,7 +1416,7 @@ function traiter_raccourcis($letexte) { $letexte = "\n".trim($letexte); // les listes - if (ereg("\n-[*#]", $letexte)) + if (strpos($letexte,"\n-*")!==false OR strpos($letexte,"\n-#")!==false) $letexte = traiter_listes($letexte); // Puce diff --git a/ecrire/inc/traduire.php b/ecrire/inc/traduire.php index d09ce59cae..d4d248ab95 100644 --- a/ecrire/inc/traduire.php +++ b/ecrire/inc/traduire.php @@ -112,7 +112,7 @@ function inc_traduire_dist($ori, $lang) { } // filet pour traduction pas finies - if (($lang<>'fr') AND ereg("^<(NEW|MODIF)>", $text)) + if (($lang<>'fr') AND preg_match(",^<(NEW|MODIF)>,", $text)) $text = inc_traduire_dist($ori, 'fr'); $deja_vu[$lang][$code] = $text; diff --git a/ecrire/install/etape_1.php b/ecrire/install/etape_1.php index 869c09d6cf..43ae8af409 100644 --- a/ecrire/install/etape_1.php +++ b/ecrire/install/etape_1.php @@ -29,11 +29,11 @@ function install_etape_1_dist() // Recuperer les anciennes donnees pour plus de facilite (si presentes) if (@file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php')) { $s = @join('', @file(_FILE_CONNECT_INS . _FILE_TMP . '.php')); - if (ereg("mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)", $s, $regs)) { + if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { $adresse_db = $regs[1]; $login_db = $regs[2]; } - else if (ereg("spip_connect_db\('(.*)','(.*)','(.*)','(.*)','(.*)'\)", $s, $regs)) { + else if (preg_match("#spip_connect_db\('(.*)','(.*)','(.*)','(.*)','(.*)'\)#", $s, $regs)) { $adresse_db = $regs[1]; if ($port_db = $regs[2]) $adresse_db .= ':'.$port_db; $login_db = $regs[3]; @@ -41,7 +41,7 @@ function install_etape_1_dist() } if(@file_exists(_FILE_CHMOD_INS . _FILE_TMP . '.php')){ $s = @join('', @file(_FILE_CHMOD_INS . _FILE_TMP . '.php')); - if(ereg("define\('_SPIP_CHMOD', (.*)\)", $s, $regs)) { + if(preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { $chmod = $regs[1]; } } diff --git a/ecrire/install/etape_ldap1.php b/ecrire/install/etape_ldap1.php index fd27b836b4..978580929b 100644 --- a/ecrire/install/etape_ldap1.php +++ b/ecrire/install/etape_ldap1.php @@ -22,7 +22,7 @@ function install_etape_ldap1_dist() // Recuperer les anciennes donnees (si presentes) if (@file_exists(_FILE_CONNECT_INS . _FILE_TMP . '.php')) { $s = @join('', @file(_FILE_CONNECT_INS . _FILE_TMP . '.php')); - if (ereg('ldap_connect\("(.*)","(.*)"\)', $s, $regs)) { + if (preg_match('#ldap_connect\("(.*)","(.*)"\)#', $s, $regs)) { $adresse_ldap = $regs[1]; $port_ldap = $regs[2]; } diff --git a/ecrire/public/balises.php b/ecrire/public/balises.php index bb38020c36..e9f14252ae 100644 --- a/ecrire/public/balises.php +++ b/ecrire/public/balises.php @@ -401,7 +401,7 @@ function balise_EXPOSER_dist($p) if ($a = ($p->fonctions)) { // Gerer la notation [(#EXPOSER|on,off)] $onoff = array_shift($a); - ereg("([^,]*)(,(.*))?", $onoff[0], $regs); + preg_match("#([^,]*)(,(.*))?#", $onoff[0], $regs); $on = "" . _q($regs[1]); $off = "" . _q($regs[3]) ; // autres filtres @@ -698,12 +698,12 @@ function balise_GRAND_TOTAL_dist($p) { // http://doc.spip.org/@calculer_balise_logo_dist function calculer_balise_logo_dist ($p) { - eregi("^LOGO_([A-Z]+)(_.*)?$", $p->nom_champ, $regs); + preg_match(",^LOGO_([A-Z]+)(_.*)?$,i", $p->nom_champ, $regs); $type_objet = $regs[1]; $suite_logo = $regs[2]; // cas de #LOGO_SITE_SPIP - if (ereg("^_SPIP(.*)$", $suite_logo, $regs)) { + if (preg_match(",^_SPIP(.*)$,", $suite_logo, $regs)) { $type_objet = 'SITE'; $suite_logo = $regs[1]; $_id_objet = "\"'0'\""; @@ -773,7 +773,7 @@ function calculer_balise_logo_dist ($p) { // 2. lien indique en clair (avec des balises : imprimer#ID_ARTICLE.html) else if ($lien) { $code_lien = "'".texte_script(trim($lien))."'"; - while (ereg("^([^#]*)#([A-Za-z_]+)(.*)$", $code_lien, $match)) { + while (preg_match(",^([^#]*)#([A-Za-z_]+)(.*)$,", $code_lien, $match)) { $c = new Champ(); $c->nom_champ = $match[2]; $c->id_boucle = $p->id_boucle; diff --git a/ecrire/public/compiler.php b/ecrire/public/compiler.php index 3165e7dc10..42475bdc44 100644 --- a/ecrire/public/compiler.php +++ b/ecrire/public/compiler.php @@ -18,7 +18,7 @@ if (!defined("_ECRIRE_INC_VERSION")) return; // reperer un code ne calculant rien, meme avec commentaire -define('CODE_MONOTONE', "^(\n//[^\n]*\n)?\(?'([^'])*'\)?$"); +define('CODE_MONOTONE', ",^(\n//[^\n]*\n)?\(?'([^'])*'\)?$,"); // Definition de la structure $p, et fonctions de recherche et de reservation // dans l'arborescence des boucles @@ -152,7 +152,7 @@ function calculer_boucle_nonrec($id_boucle, &$boucles) { $return = $boucle->return; $type_boucle = $boucle->type_requete; $primary = $boucle->primary; - $constant = ereg(CODE_MONOTONE,$return); + $constant = preg_match(CODE_MONOTONE,$return); // Cas {1/3} {1,4} {n-2,1}... @@ -233,7 +233,7 @@ function calculer_boucle_nonrec($id_boucle, &$boucles) { // si le corps est une constante, ne pas appeler le serveur N fois! - if (ereg(CODE_MONOTONE,$corps, $r)) { + if (preg_match(CODE_MONOTONE,$corps, $r)) { if (!$r[2]) { if (!$boucle->numrows) return 'return "";'; @@ -371,7 +371,7 @@ function calculer_parties($boucles, $id_boucle) { $boucle->sql_serveur . '");'; - ereg("([+-/p])([+-/])?", $mode_partie, $regs); + preg_match(",([+-/p])([+-/])?,", $mode_partie, $regs); list(,$op1,$op2) = $regs; // {1/3} diff --git a/ecrire/public/criteres.php b/ecrire/public/criteres.php index d9866c2a14..8ce3ff0e1f 100644 --- a/ecrire/public/criteres.php +++ b/ecrire/public/criteres.php @@ -327,12 +327,12 @@ function critere_parinverse($idb, &$boucles, $crit, $sens) { $par = array_shift($tri); $par = $par->texte; // par multi champ - if (ereg("^multi[[:space:]]*(.*)$",$par, $m)) { + if (preg_match(",^multi[\s]*(.*)$,",$par, $m)) { $texte = $boucle->id_table . '.' . trim($m[1]); $boucle->select[] = " \".creer_objet_multi('".$texte."', \$GLOBALS['spip_lang']).\"" ; $order = "multi"; // par num champ(, suite) - } else if (ereg("^num[[:space:]]*(.*)$",$par, $m)) { + } else if (preg_match(",^num[\s]*(.*)$,",$par, $m)) { $texte = '0+' . $boucle->id_table . '.' . trim($m[1]); $suite = calculer_liste($tri, array(), $boucles, $boucle->id_parent); if ($suite !== "''") @@ -552,10 +552,10 @@ function calculer_critere_parties_aux($idb, &$boucles, $param) { if ($param[0]->type != 'texte') { $a1 = calculer_liste(array($param[0]), array('id_mere' => $idb), $boucles, $boucles[$idb]->id_parent); - ereg('^ *(-([0-9]+))? *$', $param[1]->texte, $m); + preg_match(',^ *(-([0-9]+))? *$,', $param[1]->texte, $m); return array("intval($a1)", ($m[2] ? $m[2] : 0)); } else { - ereg('^ *(([0-9]+)|n) *(- *([0-9]+)? *)?$', $param[0]->texte, $m); + preg_match(',^ *(([0-9]+)|n) *(- *([0-9]+)? *)?$,', $param[0]->texte, $m); $a1 = $m[1]; if (!$m[3]) return array($a1, 0); @@ -1168,7 +1168,7 @@ function calculer_critere_infixe_date($idb, &$boucles, $regs) // http://doc.spip.org/@calculer_param_date function calculer_param_date($date_compare, $date_orig) { - if (ereg("'\" *\.(.*)\. *\"'", $date_compare, $r)) { + if (preg_match(",'\" *\.(.*)\. *\"',", $date_compare, $r)) { $init = "'\" . (\$x = $r[1]) . \"'"; $date_compare = '\'$x\''; } diff --git a/ecrire/public/debug.php b/ecrire/public/debug.php index 6c155fa55d..76b2285429 100644 --- a/ecrire/public/debug.php +++ b/ecrire/public/debug.php @@ -75,10 +75,10 @@ function erreur_requete_boucle($query, $id_boucle, $type, $errno, $erreur) { $GLOBALS['bouton_admin_debug'] = true; - if (eregi('err(no|code):?[[:space:]]*([0-9]+)', $erreur, $regs)) + if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $erreur, $regs)) $errno = $regs[2]; else if (($errno == 1030 OR $errno <= 1026) - AND ereg('[^[:alnum:]]([0-9]+)[^[:alnum:]]', $erreur, $regs)) + AND preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $erreur, $regs)) $errno = $regs[1]; // Erreur systeme @@ -278,7 +278,7 @@ function trouve_squelette_inclus($script) $incl = $reg[1] . '.html$'; foreach($debug_objets['sourcefile'] as $k => $v) { - if (ereg($incl,$v)) return $k; + if (preg_match(",$incl,",$v)) return $k; } return ""; } @@ -527,7 +527,7 @@ function emboite_texte($texte, $fonc='',$self='') if (!$texte) return array(ancre_texte($texte, array('','')), false); - elseif (!ereg("^[[:space:]]*([^<][^0-9]*)([0-9]*)(.*[^0-9])([0-9]*)$", + elseif (!preg_match(",^[[:space:]]*([^<][^0-9]*)([0-9]*)(.*[^0-9])([0-9]*)$,", $GLOBALS['xhtml_error'], $eregs)) diff --git a/ecrire/public/phraser_html.php b/ecrire/public/phraser_html.php index 0d3c85ec1a..18982749a7 100644 --- a/ecrire/public/phraser_html.php +++ b/ecrire/public/phraser_html.php @@ -29,9 +29,9 @@ define('SPEC_BOUCLE','/\s*\(\s*([^\s)]+)(\s*[^)]*)\)/'); define('NOM_DE_BOUCLE', "[0-9]+|[-_][-_.a-zA-Z0-9]*"); # ecriture alambiquee pour rester compatible avec les hexadecimaux des vieux squelettes define('NOM_DE_CHAMP', "#((" . NOM_DE_BOUCLE . "):)?(([A-F]*[G-Z_][A-Z_0-9]*)|[A-Z_]+)(\*{0,2})"); -define('CHAMP_ETENDU', '\[([^]\[]*)\(' . NOM_DE_CHAMP . '([^[)]*\)[^]\[]*)\]'); +define('CHAMP_ETENDU', '/\[([^]\[]*)\(' . NOM_DE_CHAMP . '([^[)]*\)[^]\[]*)\]/S'); -define('BALISE_INCLURE','<INCLU[DR]E[[:space:]]*(\(([^)]*)\))?'); +define('BALISE_INCLURE','/<INCLU[DR]E[[:space:]]*(\(([^)]*)\))?/S'); define('SQL_ARGS', '(\([^)]*\))'); define('CHAMP_SQL_PLUS_FONC', '`?([A-Z_][A-Z_0-9]*)' . SQL_ARGS . '?`?'); @@ -56,11 +56,11 @@ function phraser_arguments_inclure($p,$rejet_filtres = false){ erreur_squelette(_T('zbug_parametres_inclus_incorrects'),$var); else { $champ->param[$k] = $v; - ereg("^([^=]*)(=)?(.*)$", $var->texte,$m); + preg_match(",^([^=]*)(=)?(.*)$,", $var->texte,$m); if ($m[2]) { $champ->param[$k][0] = $m[1]; $val = $m[3]; - if (ereg('^[\'"](.*)[\'"]$', $val, $m)) $val = $m[1]; + if (preg_match(',^[\'"](.*)[\'"]$,', $val, $m)) $val = $m[1]; $champ->param[$k][1][0]->texte = $val; } else @@ -74,7 +74,7 @@ function phraser_arguments_inclure($p,$rejet_filtres = false){ // http://doc.spip.org/@phraser_inclure function phraser_inclure($texte, $ligne, $result) { - while (ereg(BALISE_INCLURE, $texte, $match)) { + while (preg_match(BALISE_INCLURE, $texte, $match)) { $p = strpos($texte,$match[0]); $debut = substr($texte, 0, $p); if ($p) $result = phraser_idiomes($debut, $ligne, $result); @@ -143,7 +143,7 @@ function phraser_polyglotte($texte,$ligne, $result) { function phraser_idiomes($texte,$ligne,$result) { // Reperer les balises de traduction <:toto:> - while (eregi("<:(([a-z0-9_]+):)?([a-z0-9_]+)((\|[^:>]*)?:>)", $texte, $match)) { + while (preg_match(",<:(([a-z0-9_]+):)?([a-z0-9_]+)((\|[^:>]*)?:>),iS", $texte, $match)) { $p = strpos($texte, $match[0]); $debut = substr($texte, 0, $p); if ($p) $result = phraser_champs($debut, $ligne, $result); @@ -164,7 +164,7 @@ function phraser_idiomes($texte,$ligne,$result) { // http://doc.spip.org/@phraser_champs function phraser_champs($texte,$ligne,$result) { - while (ereg(NOM_DE_CHAMP, $texte, $match)) { + while (preg_match("/".NOM_DE_CHAMP."/S", $texte, $match)) { $p = strpos($texte, $match[0]); $suite = substr($texte,$p+strlen($match[0])); if ($match[5] || (strpos($suite[0], "[0-9]") === false)) { @@ -265,7 +265,7 @@ function phraser_arg(&$texte, $sep, $result, &$pointeur_champ) { $collecte[] = $champ; $args = ltrim($regs[count($regs)-1]); } else { - if (!ereg(NOM_DE_CHAMP ."[{|]", $arg, $r)) { + if (!preg_match("/".NOM_DE_CHAMP ."[{|]/", $arg, $r)) { // 0 est un aveu d'impuissance. A completer $arg = phraser_champs_exterieurs($arg, 0, $sep, $result); @@ -277,7 +277,7 @@ function phraser_arg(&$texte, $sep, $result, &$pointeur_champ) { $n = strpos($args,$r[0]); $pred = substr($args, 0, $n); $par = ',}'; - if (ereg('^(.*)\($', $pred, $m)) + if (preg_match('/^(.*)\($/', $pred, $m)) {$pred = $m[1]; $par =')';} if ($pred) { $champ = new Texte; @@ -341,7 +341,7 @@ function phraser_champs_interieurs($texte, $ligne, $sep, $result) { while (true) { $j=$i; $n = $ligne; - while (ereg(CHAMP_ETENDU, $texte, $match)) { + while (preg_match(CHAMP_ETENDU, $texte, $match)) { $p = strpos($texte, $match[0]); $debut = substr($texte, 0, $p); if ($p) { @@ -378,7 +378,7 @@ function phraser_champs_interieurs($texte, $ligne, $sep, $result) { $x.=$z; $j++; } - if (ereg(CHAMP_ETENDU, $x)) + if (preg_match(CHAMP_ETENDU, $x)) $texte = $x; else return phraser_champs_exterieurs($x, $ligne, $sep, $result); @@ -396,7 +396,7 @@ function phraser_criteres($params, &$result) { foreach($params as $v) { $var = $v[1][0]; $param = ($var->type != 'texte') ? "" : $var->texte; - if ((count($v) > 2) && (!eregi("[^A-Za-z]IN[^A-Za-z]",$param))) + if ((count($v) > 2) && (!preg_match(",[^A-Za-z]IN[^A-Za-z],i",$param))) { // plus d'un argument et pas le critere IN: // detecter comme on peut si c'est le critere implicite LIMIT debut, fin @@ -453,7 +453,7 @@ function phraser_criteres($params, &$result) { else { // pas d'emplacement statique, faut un dynamique /// mais il y a 2 cas qui ont les 2 ! - if (($param == 'unique') || (ereg('^!?doublons *', $param))) + if (($param == 'unique') || (preg_match(',^!?doublons *,', $param))) { // cette variable sera inseree dans le code // et son nom sert d'indicateur des maintenant @@ -463,12 +463,12 @@ function phraser_criteres($params, &$result) { elseif ($param == 'recherche') // meme chose (a cause de #nom_de_boucle:URL_*) $result->hash = true; - if (ereg('^ *([0-9-]+) *(/) *(.+) *$', $param, $m)) { + if (preg_match(',^ *([0-9-]+) *(/) *(.+) *$,', $param, $m)) { $crit = phraser_critere_infixe($m[1], $m[3],$v, '/', '', ''); } elseif (preg_match(',^(' . CHAMP_SQL_PLUS_FONC . ')[[:space:]]*(\??)(!?)(<=?|>=?|==?|\b(?:IN|LIKE)\b)(.*)$,is', $param, $m)) { $a2 = trim($m[7]); - if (ereg("^'.*'$", $a2) OR ereg('^".*"$', $a2)) + if (($a2{0}=="'" OR $a2{0}=='"') AND ($a2{0}==substr($a2,-1))) $a2 = substr($a2,1,-1); $crit = phraser_critere_infixe($m[1], $a2, $v, (($m[1] == 'lang_select') ? $m[1] : $m[6]), @@ -495,7 +495,7 @@ function phraser_criteres($params, &$result) { erreur_squelette(_T('zbug_critere_inconnu', array('critere' => $param))); } - if ((!ereg('^!?doublons *', $param)) || $crit->not) + if ((!preg_match(',^!?doublons *,', $param)) || $crit->not) $args[] = $crit; else $doublons[] = $crit; @@ -537,7 +537,7 @@ function public_phraser_html($texte, $id_parent, &$boucles, $nom, $ligne=1) { # attention: reperer la premiere des 2 balises: pre_boucle ou boucle - $n = ereg(BALISE_PRE_BOUCLE . '[0-9_]', $texte, $r); + $n = preg_match(",".BALISE_PRE_BOUCLE . '[0-9_],', $texte, $r); if ($n) $n = strpos($texte, $r[0]); if (($n === false) || ($n > $p)) { $debut = substr($texte, 0, $p); @@ -563,7 +563,7 @@ function public_phraser_html($texte, $id_parent, &$boucles, $nom, $ligne=1) { strlen(BALISE_PRE_BOUCLE), $k - strlen(BALISE_PRE_BOUCLE)); - if (!ereg(BALISE_BOUCLE . $id_boucle . "[[:space:]]*\(", $milieu, $r)) + if (!preg_match(",".BALISE_BOUCLE . $id_boucle . "[[:space:]]*\(,", $milieu, $r)) erreur_squelette((_T('zbug_erreur_boucle_syntaxe')), $id_boucle); $p = strpos($milieu, $r[0]); $result->avant = substr($milieu, $k+1, $p-$k-1); @@ -593,7 +593,7 @@ function public_phraser_html($texte, $id_parent, &$boucles, $nom, $ligne=1) { // // analyser les criteres et distinguer la boucle recursive // - if (substr($soustype, 0, 6) == TYPE_RECURSIF) { + if (strncmp($soustype, TYPE_RECURSIF, strlen(TYPE_RECURSIF)) == 0) { $result->type_requete = TYPE_RECURSIF; $result->param[0] = substr($type, strlen(TYPE_RECURSIF)); $milieu = substr($milieu, strpos($milieu, '>')+1); diff --git a/ecrire/public/references.php b/ecrire/public/references.php index 0678c9f995..225bdefd6d 100644 --- a/ecrire/public/references.php +++ b/ecrire/public/references.php @@ -214,7 +214,7 @@ function calculer_balise($nom, $p) { } // S'agit-il d'un logo ? Une fonction speciale les traite tous - if (ereg('^LOGO_', $nom)) { + if (strncmp('LOGO_', $nom,5)==0) { if (!function_exists($f = 'calculer_balise_logo')) $f .= '_dist'; $res = $f($p); if ($res !== NULL) -- GitLab