Skip to content
Extraits de code Groupes Projets
Valider 460aab55 rédigé par cerdic's avatar cerdic
Parcourir les fichiers

suite de #329 sur les ereg

parent 4e3dfbe9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 33 ajouts et 33 suppressions
...@@ -26,7 +26,7 @@ function auth_http($url) { ...@@ -26,7 +26,7 @@ function auth_http($url) {
_T('login_retour_site'), _T('login_retour_site'),
"url=".rawurlencode($url), "url=".rawurlencode($url),
_T('login_nouvelle_tentative'), _T('login_nouvelle_tentative'),
(ereg(_DIR_RESTREINT_ABS, $url))); (strpos($url,_DIR_RESTREINT_ABS)!==false));
exit; exit;
} }
} }
...@@ -102,7 +102,7 @@ if ($essai_login == "oui") { ...@@ -102,7 +102,7 @@ if ($essai_login == "oui") {
// Marche pas, renvoyer le formulaire avec message d'erreur si 2e fois // Marche pas, renvoyer le formulaire avec message d'erreur si 2e fois
if (!$row_auteur) { if (!$row_auteur) {
if (ereg(_DIR_RESTREINT_ABS, $redirect)) if (strpos($redirect,_DIR_RESTREINT_ABS)!==false)
$redirect = generer_url_public('login', $redirect = generer_url_public('login',
"var_login=$session_login", true); "var_login=$session_login", true);
if ($session_password || $session_password_md5) if ($session_password || $session_password_md5)
...@@ -113,7 +113,7 @@ if ($essai_login == "oui") { ...@@ -113,7 +113,7 @@ if ($essai_login == "oui") {
spip_log("login de $session_login vers $redirect"); spip_log("login de $session_login vers $redirect");
// Si on se connecte dans l'espace prive, // Si on se connecte dans l'espace prive,
// ajouter "bonjour" (repere a peu pres les cookies desactives) // ajouter "bonjour" (repere a peu pres les cookies desactives)
if (ereg(_DIR_RESTREINT_ABS, $redirect)) { if (strpos($redirect,_DIR_RESTREINT_ABS)!==false) {
$redirect .= ((false !== strpos($redirect, "?")) ? "&" : "?") $redirect .= ((false !== strpos($redirect, "?")) ? "&" : "?")
. 'bonjour=oui'; . 'bonjour=oui';
} }
......
...@@ -63,7 +63,7 @@ function action_legender_auteur_post($r) { ...@@ -63,7 +63,7 @@ function action_legender_auteur_post($r) {
$source = 'spip'; $source = 'spip';
$statut = '1comite'; // statut par defaut $statut = '1comite'; // statut par defaut
if ($s) { if ($s) {
if (ereg("^(0minirezo|1comite|5poubelle|6forum)$",$s)) if (in_array($s,array('0minirezo','1comite','5poubelle','6forum')))
$statut = $s; $statut = $s;
else spip_log("action_legender_auteur_dist: statut $s incompris"); else spip_log("action_legender_auteur_dist: statut $s incompris");
} }
...@@ -199,7 +199,7 @@ function action_legender_auteur_post($r) { ...@@ -199,7 +199,7 @@ function action_legender_auteur_post($r) {
if ($statut = _request('statut') if ($statut = _request('statut')
AND autoriser('modifier', 'auteur', $id_auteur, $qui = null, AND autoriser('modifier', 'auteur', $id_auteur, $qui = null,
$opt = array('statut'=>$statut))) { $opt = array('statut'=>$statut))) {
if (!ereg("^(0minirezo|1comite|5poubelle|6forum)$",$statut)) { if (!in_array($s,array('0minirezo','1comite','5poubelle','6forum'))) {
spip_log("action_instituer_auteur_dist: $statut incompris pour $id_auteur"); spip_log("action_instituer_auteur_dist: $statut incompris pour $id_auteur");
} else { } else {
spip_query("UPDATE spip_auteurs SET statut="._q($statut) . " WHERE id_auteur=" . _q($id_auteur)); spip_query("UPDATE spip_auteurs SET statut="._q($statut) . " WHERE id_auteur=" . _q($id_auteur));
......
...@@ -29,7 +29,7 @@ function action_instituer_auteur_dist() { ...@@ -29,7 +29,7 @@ function action_instituer_auteur_dist() {
spip_abstract_insert('spip_auteurs_rubriques', "(id_auteur,id_rubrique)", "(" .$id_auteur .',' . $id_parent . ')'); spip_abstract_insert('spip_auteurs_rubriques', "(id_auteur,id_rubrique)", "(" .$id_auteur .',' . $id_parent . ')');
} }
if ($statut = _request('statut')) { if ($statut = _request('statut')) {
if (!ereg("^(0minirezo|1comite|5poubelle|6forum)$",$statut)) if (!in_array($s,array('0minirezo','1comite','5poubelle','6forum')))
spip_log("action_instituer_auteur_dist: $statut incompris pour $id_auteur"); spip_log("action_instituer_auteur_dist: $statut incompris pour $id_auteur");
else { else {
spip_query("UPDATE spip_auteurs SET statut='".$statut . "' WHERE id_auteur=" . $id_auteur); spip_query("UPDATE spip_auteurs SET statut='".$statut . "' WHERE id_auteur=" . $id_auteur);
......
...@@ -78,7 +78,7 @@ function action_test_dirs_dist() ...@@ -78,7 +78,7 @@ function action_test_dirs_dist()
$chmod = 0; $chmod = 0;
if ($test_dir) { if ($test_dir) {
if (!ereg("/$", $test_dir)) $test_dir .= '/'; if (substr($test_dir,-1)!=='/') $test_dir .= '/';
if (!in_array($test_dir, $test_dirs)) $test_dirs[] = $test_dir; if (!in_array($test_dir, $test_dirs)) $test_dirs[] = $test_dir;
} }
else { else {
......
...@@ -127,7 +127,7 @@ function action_tester_dist() { ...@@ -127,7 +127,7 @@ function action_tester_dist() {
} }
// et maintenant envoyer la vignette de tests // et maintenant envoyer la vignette de tests
if (ereg("^(gd1|gd2|imagick|convert|netpbm)$", $arg)) { if (in_array($arg,array("gd1","gd2","imagick","convert","netpbm"))) {
include_spip('inc/filtres'); include_spip('inc/filtres');
include_spip('inc/filtres_images'); include_spip('inc/filtres_images');
//$taille_preview = $GLOBALS['meta']["taille_preview"]; //$taille_preview = $GLOBALS['meta']["taille_preview"];
......
...@@ -50,7 +50,7 @@ function login_explicite($login, $cible) { ...@@ -50,7 +50,7 @@ function login_explicite($login, $cible) {
$cible = parametre_url($cible, 'var_erreur', '', '&'); $cible = parametre_url($cible, 'var_erreur', '', '&');
$cible = parametre_url($cible, 'var_login', '', '&'); $cible = parametre_url($cible, 'var_login', '', '&');
} else { } else {
if (ereg("[?&]url=([^&]*)", $action, $m)) if (preg_match(",[?&]url=([^&]*),", $action, $m))
$cible = rawurldecode($m[1]); $cible = rawurldecode($m[1]);
else else
$cible = _DIR_RESTREINT ; $cible = _DIR_RESTREINT ;
...@@ -103,7 +103,7 @@ function login_pour_tous($login, $cible, $action) { ...@@ -103,7 +103,7 @@ function login_pour_tous($login, $cible, $action) {
if ($echec_cookie AND !$ignore_auth_http) { if ($echec_cookie AND !$ignore_auth_http) {
if (($GLOBALS['flag_sapi_name'] if (($GLOBALS['flag_sapi_name']
AND eregi("apache", @php_sapi_name())) AND eregi("apache", @php_sapi_name()))
OR ereg("^Apache.* PHP", $_SERVER['SERVER_SOFTWARE'])) OR preg_match(",^Apache.* PHP,", $_SERVER['SERVER_SOFTWARE']))
$auth_http = $pose_cookie; $auth_http = $pose_cookie;
} }
// Attention dans le cas 'intranet' la proposition de se loger // Attention dans le cas 'intranet' la proposition de se loger
...@@ -113,7 +113,7 @@ function login_pour_tous($login, $cible, $action) { ...@@ -113,7 +113,7 @@ function login_pour_tous($login, $cible, $action) {
// Le login est memorise dans le cookie d'admin eventuel // Le login est memorise dans le cookie d'admin eventuel
if (!$login) { if (!$login) {
if (ereg("^@(.*)$", $_COOKIE['spip_admin'], $regs)) if (preg_match(",^@(.*)$,", $_COOKIE['spip_admin'], $regs))
$login = $regs[1]; $login = $regs[1];
} else if ($login == '-1') } else if ($login == '-1')
$login = ''; $login = '';
......
...@@ -39,7 +39,7 @@ if ($f = include_spip('mes_fonctions', false)) { ...@@ -39,7 +39,7 @@ if ($f = include_spip('mes_fonctions', false)) {
function verifier_sauvegarde ($archive, $dir) { function verifier_sauvegarde ($archive, $dir) {
global $spip_version; global $spip_version;
$g = ereg("\.gz$", $archive); $g = preg_match(",\.gz$,", $archive);
$_fopen = ($g) ? gzopen : fopen; $_fopen = ($g) ? gzopen : fopen;
$_fread = ($g) ? gzread : fread; $_fread = ($g) ? gzread : fread;
$buf_len = 1024; // la version doit etre dans le premier ko $buf_len = 1024; // la version doit etre dans le premier ko
......
...@@ -48,7 +48,7 @@ function tester_compatibilite_hebergement() { ...@@ -48,7 +48,7 @@ function tester_compatibilite_hebergement() {
$err = array(); $err = array();
$p = phpversion(); $p = phpversion();
if (ereg('^([0-9]+)\.([0-9]+)\.([0-9]+)', $p, $regs)) { if (preg_match(',^([0-9]+)\.([0-9]+)\.([0-9]+),', $p, $regs)) {
$php = array($regs[1], $regs[2], $regs[3]); $php = array($regs[1], $regs[2], $regs[3]);
$m = '4.0.8'; $m = '4.0.8';
$min = explode('.', $m); $min = explode('.', $m);
...@@ -91,16 +91,16 @@ function login_hebergeur() { ...@@ -91,16 +91,16 @@ function login_hebergeur() {
// Lycos (ex-Multimachin) // Lycos (ex-Multimachin)
if ($HTTP_X_HOST == 'membres.lycos.fr') { if ($HTTP_X_HOST == 'membres.lycos.fr') {
ereg('^/([^/]*)', $REQUEST_URI, $regs); preg_match(',^/([^/]*),', $REQUEST_URI, $regs);
$login_hebergeur = $regs[1]; $login_hebergeur = $regs[1];
} }
// Altern // Altern
else if (ereg('altern\.com$', $SERVER_NAME)) { else if (preg_match(',altern\.com$,', $SERVER_NAME)) {
ereg('([^.]*\.[^.]*)$', $HTTP_HOST, $regs); preg_match(',([^.]*\.[^.]*)$,', $HTTP_HOST, $regs);
$login_hebergeur = preg_replace('[^\w\d]', '_', $regs[1]); $login_hebergeur = preg_replace('[^\w\d]', '_', $regs[1]);
} }
// Free // Free
else if (ereg('(.*)\.free\.fr$', $SERVER_NAME, $regs)) { else if (preg_match(',(.*)\.free\.fr$,', $SERVER_NAME, $regs)) {
$base_hebergeur = 'sql.free.fr'; $base_hebergeur = 'sql.free.fr';
$login_hebergeur = $regs[1]; $login_hebergeur = $regs[1];
} }
......
...@@ -84,7 +84,7 @@ function afficher_raccourcis($module = "public") { ...@@ -84,7 +84,7 @@ function afficher_raccourcis($module = "public") {
echo "<div>&nbsp;</div>"; echo "<div>&nbsp;</div>";
foreach (preg_files(repertoire_lang().$module.'_[a-z_]+\.php[3]?$') as $f) foreach (preg_files(repertoire_lang().$module.'_[a-z_]+\.php[3]?$') as $f)
if (ereg("^".$module."\_([a-z_]+)\.php[3]?$", $f, $regs)) if (preg_match(",^".$module."\_([a-z_]+)\.php[3]?$,", $f, $regs))
$langue_module[$regs[1]] = traduire_nom_langue($regs[1]); $langue_module[$regs[1]] = traduire_nom_langue($regs[1]);
if (isset($langue_module) && ($langue_module)) { if (isset($langue_module) && ($langue_module)) {
......
...@@ -407,7 +407,7 @@ function exec_affiche_message_dist($id_message, $cherche_auteur, $forcer_dest) ...@@ -407,7 +407,7 @@ function exec_affiche_message_dist($id_message, $cherche_auteur, $forcer_dest)
{ {
foreach ($v as $l => $e) foreach ($v as $l => $e)
{ {
if (ereg("=$id_message$", $e['URL'])) if (preg_match(",=$id_message$,", $e['URL']))
{ {
$ah[$k][$l]['CATEGORIES'] = "calendrier-nb"; $ah[$k][$l]['CATEGORIES'] = "calendrier-nb";
break; break;
......
...@@ -49,7 +49,7 @@ function exec_recherche_dist() ...@@ -49,7 +49,7 @@ function exec_recherche_dist()
$query_breves['FROM'] = 'spip_breves'; $query_breves['FROM'] = 'spip_breves';
$query_rubriques['FROM'] = 'spip_rubriques'; $query_rubriques['FROM'] = 'spip_rubriques';
$query_sites['FROM'] = 'spip_syndic'; $query_sites['FROM'] = 'spip_syndic';
$testnum = ereg("^[0-9]+$", $recherche); $testnum = preg_match(",^[0-9]+$,", $recherche);
// Eviter les symboles '%', caracteres SQL speciaux // Eviter les symboles '%', caracteres SQL speciaux
......
...@@ -706,7 +706,7 @@ if ($GLOBALS['accepte_svg']) { ...@@ -706,7 +706,7 @@ if ($GLOBALS['accepte_svg']) {
echo http_img_rien($largeur, 1, 'background-color:#333333;'); echo http_img_rien($largeur, 1, 'background-color:#333333;');
echo http_img_rien($largeur, $difference, '', $tagtitle); echo http_img_rien($largeur, $difference, '', $tagtitle);
echo http_img_rien($largeur,1,"background-color:$couleur_foncee;"); echo http_img_rien($largeur,1,"background-color:$couleur_foncee;");
if (ereg("-01",$key)){ // janvier en couleur foncee if (preg_match(",-01,",$key)){ // janvier en couleur foncee
echo http_img_rien($largeur,$hauteur,"background-color:$couleur_foncee;", $tagtitle); echo http_img_rien($largeur,$hauteur,"background-color:$couleur_foncee;", $tagtitle);
} }
else { else {
...@@ -716,7 +716,7 @@ if ($GLOBALS['accepte_svg']) { ...@@ -716,7 +716,7 @@ if ($GLOBALS['accepte_svg']) {
else if ($hauteur_moyenne < $hauteur) { else if ($hauteur_moyenne < $hauteur) {
$difference = ($hauteur - $hauteur_moyenne) -1; $difference = ($hauteur - $hauteur_moyenne) -1;
echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle); echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle);
if (ereg("-01",$key)){ // janvier en couleur foncee if (preg_match(",-01,",$key)){ // janvier en couleur foncee
$couleur = $couleur_foncee; $couleur = $couleur_foncee;
} }
else { else {
...@@ -728,7 +728,7 @@ if ($GLOBALS['accepte_svg']) { ...@@ -728,7 +728,7 @@ if ($GLOBALS['accepte_svg']) {
} }
else { else {
echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle); echo http_img_rien($largeur,1,"background-color:$couleur_foncee;", $tagtitle);
if (ereg("-01",$key)){ // janvier en couleur foncee if (preg_match(",-01,",$key)){ // janvier en couleur foncee
echo http_img_rien($largeur, $hauteur, "background-color:$couleur_foncee;", $tagtitle); echo http_img_rien($largeur, $hauteur, "background-color:$couleur_foncee;", $tagtitle);
} }
else { else {
......
...@@ -47,7 +47,7 @@ function calendrier_retire_args_ancre($script) ...@@ -47,7 +47,7 @@ function calendrier_retire_args_ancre($script)
{ {
$script = str_replace('&amp;', '&', $script); $script = str_replace('&amp;', '&', $script);
$script = str_replace('?bonjour=oui&?','?',$script); $script = str_replace('?bonjour=oui&?','?',$script);
if (ereg('^(.*)#([^=&]*)$',$script, $m)) { if (preg_match(',^(.*)#([^=&]*)$,',$script, $m)) {
$script = $m[1]; $script = $m[1];
$ancre = $m[2]; $ancre = $m[2];
} else { $ancre = ''; } } else { $ancre = ''; }
...@@ -56,7 +56,7 @@ function calendrier_retire_args_ancre($script) ...@@ -56,7 +56,7 @@ function calendrier_retire_args_ancre($script)
$script = preg_replace("/([?&])$arg=[^&]*&/",'\1', $script); $script = preg_replace("/([?&])$arg=[^&]*&/",'\1', $script);
$script = preg_replace("/([?&])$arg=[^&]*$/",'\1', $script); $script = preg_replace("/([?&])$arg=[^&]*$/",'\1', $script);
} }
if (ereg('[?&]$', $script)) $script = substr($script,0,-1); if (in_array(substr($script,-1),array('&','?'))) $script = substr($script,0,-1);
return array(quote_amp($script), $ancre); return array(quote_amp($script), $ancre);
} }
...@@ -1442,7 +1442,7 @@ function sql_calendrier_interval_rv($avant, $apres) { ...@@ -1442,7 +1442,7 @@ function sql_calendrier_interval_rv($avant, $apres) {
$amj = date_anneemoisjour("$annee_avant-$mois_avant-".sprintf("%02d", $j+($jour_avant))); $amj = date_anneemoisjour("$annee_avant-$mois_avant-".sprintf("%02d", $j+($jour_avant)));
while ($amj <= $ical_apres) { while ($amj <= $ical_apres) {
if (!($amj == date_anneemoisjour($date_fin) AND ereg("00:00:00", $date_fin))) // Ne pas prendre la fin a minuit sur jour precedent if (!($amj == date_anneemoisjour($date_fin) AND preg_match(",00:00:00,", $date_fin))) // Ne pas prendre la fin a minuit sur jour precedent
$evenements[$amj][$id_message]= $evenements[$amj][$id_message]=
array( array(
'URL' => generer_url_ecrire("message","id_message=$id_message"), 'URL' => generer_url_ecrire("message","id_message=$id_message"),
......
...@@ -63,7 +63,7 @@ function inc_ajouter_documents_dist ($source, $nom_envoye, $type_lien, $id_lien, ...@@ -63,7 +63,7 @@ function inc_ajouter_documents_dist ($source, $nom_envoye, $type_lien, $id_lien,
// - interdit a l'upload ? // - interdit a l'upload ?
// - quel numero dans spip_types_documents ? =-( // - quel numero dans spip_types_documents ? =-(
// - est-ce "inclus" comme une image ? // - est-ce "inclus" comme une image ?
ereg("\.([^.]+)$", $nom_envoye, $match); preg_match(",\.([^.]+)$,", $nom_envoye, $match);
$ext = (corriger_extension(strtolower($match[1]))); $ext = (corriger_extension(strtolower($match[1])));
// Si le fichier est de type inconnu, on va le stocker en .zip // Si le fichier est de type inconnu, on va le stocker en .zip
......
...@@ -523,14 +523,14 @@ function unicode_to_javascript($texte) { ...@@ -523,14 +523,14 @@ function unicode_to_javascript($texte) {
// convertit les %uxxxx (envoyes par javascript) // convertit les %uxxxx (envoyes par javascript)
// http://doc.spip.org/@javascript_to_unicode // http://doc.spip.org/@javascript_to_unicode
function javascript_to_unicode ($texte) { function javascript_to_unicode ($texte) {
while (ereg("%u([0-9A-F][0-9A-F][0-9A-F][0-9A-F])", $texte, $regs)) while (preg_match(",%u([0-9A-F][0-9A-F][0-9A-F][0-9A-F]),", $texte, $regs))
$texte = str_replace($regs[0],"&#".hexdec($regs[1]).";", $texte); $texte = str_replace($regs[0],"&#".hexdec($regs[1]).";", $texte);
return $texte; return $texte;
} }
// convertit les %E9 (envoyes par le browser) en chaine du charset du site (binaire) // convertit les %E9 (envoyes par le browser) en chaine du charset du site (binaire)
// http://doc.spip.org/@javascript_to_binary // http://doc.spip.org/@javascript_to_binary
function javascript_to_binary ($texte) { function javascript_to_binary ($texte) {
while (ereg("%([0-9A-F][0-9A-F])", $texte, $regs)) while (preg_match(",%([0-9A-F][0-9A-F]),", $texte, $regs))
$texte = str_replace($regs[0],chr(hexdec($regs[1])), $texte); $texte = str_replace($regs[0],chr(hexdec($regs[1])), $texte);
return $texte; return $texte;
} }
......
...@@ -22,7 +22,7 @@ function inc_dater_dist($id, $flag, $statut, $type, $script, $date, $date_redac= ...@@ -22,7 +22,7 @@ function inc_dater_dist($id, $flag, $statut, $type, $script, $date, $date_redac=
{ {
global $spip_lang_left, $spip_lang_right, $options; global $spip_lang_left, $spip_lang_right, $options;
if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})( ([0-9]{2}):([0-9]{2}))?", $date_redac, $regs)) { if (preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})( ([0-9]{2}):([0-9]{2}))?/", $date_redac, $regs)) {
$annee_redac = $regs[1]; $annee_redac = $regs[1];
$mois_redac = $regs[2]; $mois_redac = $regs[2];
$jour_redac = $regs[3]; $jour_redac = $regs[3];
...@@ -33,7 +33,7 @@ function inc_dater_dist($id, $flag, $statut, $type, $script, $date, $date_redac= ...@@ -33,7 +33,7 @@ function inc_dater_dist($id, $flag, $statut, $type, $script, $date, $date_redac=
$possedeDateRedac= ($annee_redac + $mois_redac + $jour_redac); $possedeDateRedac= ($annee_redac + $mois_redac + $jour_redac);
if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})( ([0-9]{2}):([0-9]{2}))?", $date, $regs)) { if (preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})( ([0-9]{2}):([0-9]{2}))?/", $date, $regs)) {
$annee = $regs[1]; $annee = $regs[1];
$mois = $regs[2]; $mois = $regs[2];
$jour = $regs[3]; $jour = $regs[3];
......
...@@ -186,7 +186,7 @@ function recuperer_page($url, $munge_charset=false, $get_headers=false, ...@@ -186,7 +186,7 @@ function recuperer_page($url, $munge_charset=false, $get_headers=false,
// Reponse du serveur distant // Reponse du serveur distant
$s = trim(fgets($f, 16384)); $s = trim(fgets($f, 16384));
if (ereg('^HTTP/[0-9]+\.[0-9]+ ([0-9]+)', $s, $r)) { if (preg_match(',^HTTP/[0-9]+\.[0-9]+ ([0-9]+),', $s, $r)) {
$status = $r[1]; $status = $r[1];
} }
else return; else return;
......
...@@ -24,7 +24,7 @@ if ($HTTP_X_HOST == 'membres.lycos.fr') { ...@@ -24,7 +24,7 @@ if ($HTTP_X_HOST == 'membres.lycos.fr') {
$hebergeur = 'lycos'; $hebergeur = 'lycos';
} }
// Altern // Altern
else if (ereg('altern\.com$', $SERVER_NAME)) { else if (preg_match(',altern\.com$,', $SERVER_NAME)) {
$hebergeur = 'altern'; $hebergeur = 'altern';
} }
// NexenServices // NexenServices
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter