Browse Source

SPIP 1.8.3: bardée d'occurrences de {{{ereg}}} et consorts, remplacements uniquement destinés à permettre de vérifier que la faille de [15849] est absente de cette version. Vérification ok, on garde ces remplacements mais il y en aurait plein d'autres à faire pour que cette version tourne en PHP5 sans Warning.

1.8
Committo,Ergo:sum 11 years ago
parent
commit
61644347f1
  1. 6
      ecrire/inc_acces.php3
  2. 8
      ecrire/inc_lang.php3
  3. 2
      ecrire/inc_meta.php3
  4. 44
      ecrire/inc_version.php3
  5. 10
      ecrire/install.php3
  6. 6
      formulaires/inc-login_public.php3
  7. 12
      inc-cache.php3

6
ecrire/inc_acces.php3

@ -39,9 +39,9 @@ function creer_pass_aleatoire($longueur = 8, $sel = "") {
$pass .= $x;
$s = substr($s, 2);
}
$pass = ereg_replace("[./]", "a", $pass);
$pass = ereg_replace("[I1l]", "L", $pass);
$pass = ereg_replace("[0O]", "o", $pass);
$pass = preg_replace(",[./],", "a", $pass);
$pass = preg_replace(",[I1l],", "L", $pass);
$pass = preg_replace(",[0O],", "o", $pass);
return $pass;
}

8
ecrire/inc_lang.php3

@ -82,7 +82,7 @@ function changer_langue($lang) {
$liste_langues = $all_langs.','.lire_meta('langues_multilingue');
if ($lang && ereg(",$lang,", ",$liste_langues,")) {
if ($lang && preg_match("/,$lang,/", ",$liste_langues,")) {
$GLOBALS['spip_lang'] = $lang;
$spip_lang_rtl = lang_dir($lang, '', '_rtl');
@ -106,7 +106,7 @@ function regler_langue_navigateur() {
$accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
if (is_array($accept_langs)) {
while(list(, $s) = each($accept_langs)) {
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.]+)?$/i', trim($s), $r)) {
$lang = strtolower($r[1]);
if (changer_langue($lang)) return $lang;
}
@ -568,7 +568,7 @@ function init_langues() {
if (!$all_langs || !$langue_site || !_DIR_RESTREINT) {
if (!$d = @opendir(_DIR_LANG)) return;
while ($f = readdir($d)) {
if (ereg('^spip_([a-z_]+)\.php3?$', $f, $regs))
if (preg_match('/^spip_([a-z_]+)\.php3?$/', $f, $regs))
$toutes_langs[] = $regs[1];
}
closedir($d);
@ -580,7 +580,7 @@ function init_langues() {
$all_langs = $all_langs2;
if (!$langue_site) {
// Initialisation : le francais par defaut, sinon la premiere langue trouvee
if (ereg(',fr,', ",$all_langs,")) $langue_site = 'fr';
if (preg_match('/,fr,/', ",$all_langs,")) $langue_site = 'fr';
else list(, $langue_site) = each($toutes_langs);
if (defined("_ECRIRE_INC_META"))
ecrire_meta('langue_site', $langue_site);

2
ecrire/inc_meta.php3

@ -55,7 +55,7 @@ function ecrire_metas() {
reset($meta);
while (list($key, $val) = each($meta)) {
$key = addslashes($key);
$val = ereg_replace("([\\\\'])", "\\\\1", $val);
$val = preg_replace(",([\\\\']),", "\\\\1", $val);
$s .= "\$GLOBALS['meta']['$key'] = '$val';\n";
}
$s .= "\n";

44
ecrire/inc_version.php3

@ -450,7 +450,7 @@ $flag_ini_get = (function_exists("ini_get")
&& (@ini_get('max_execution_time') > 0)); // verifier pas desactivee
$flag_gz = function_exists("gzencode"); #php 4.0.4
$flag_ob = ($flag_ini_get
&& !ereg("ob_", ini_get('disable_functions'))
&& !preg_match("/ob_/", ini_get('disable_functions'))
&& function_exists("ob_start"));
$flag_crypt = function_exists("crypt");
$flag_wordwrap = function_exists("wordwrap");
@ -473,7 +473,7 @@ $flag_revisions = function_exists("gzcompress");
// Appliquer le prefixe cookie
//
function spip_setcookie ($name='', $value='', $expire=0, $path='AUTO', $domain='', $secure='') {
$name = ereg_replace ('^spip_', $GLOBALS['cookie_prefix'].'_', $name);
$name = preg_replace ('/^spip_/', $GLOBALS['cookie_prefix'].'_', $name);
if ($path == 'AUTO') $path=$GLOBALS['cookie_path'];
if ($secure)
@ -490,14 +490,14 @@ function spip_setcookie ($name='', $value='', $expire=0, $path='AUTO', $domain='
if ($cookie_prefix != 'spip') {
foreach ($_COOKIE as $name => $value) {
if (ereg('^spip_', $name)) {
if (preg_match('/^spip_/', $name)) {
unset($_COOKIE[$name]);
unset($$name);
}
}
foreach ($_COOKIE as $name => $value) {
if (ereg('^'.$cookie_prefix.'_', $name)) {
$spipname = ereg_replace ('^'.$cookie_prefix.'_', 'spip_', $name);
if (preg_match('/^'.$cookie_prefix.'_/', $name)) {
$spipname = preg_replace ('/^'.$cookie_prefix.'_/', 'spip_', $name);
$_COOKIE[$spipname] = $INSECURE[$spipname] = $value;
$$spipname = $value;
}
@ -528,7 +528,7 @@ function spip_log($message, $logname='spip') {
if (!$ip = $GLOBALS['REMOTE_ADDR']) $ip = '-';
$message = date("M d H:i:s")." $ip $pid "
.ereg_replace("\n*$", "\n", $message);
.preg_replace("/\n*$/", "\n", $message);
$logfile = _DIR_SESSIONS . $logname . '.log';
if (@file_exists($logfile) && (@filesize($logfile) > 10*1024)) {
@ -573,7 +573,7 @@ if (!$PATH_TRANSLATED) {
# obsoletes: utiliser les constantes ci-dessus.
# Conserver pour compatibilite vieilles contrib uniquement
$flag_ecrire = !@file_exists(_DIR_RESTREINT_ABS . 'inc_version.php3');
$dir_ecrire = (ereg("/ecrire/", $GLOBALS['REQUEST_URI'])) ? '' : 'ecrire/';
$dir_ecrire = (preg_match(",/ecrire/,", $GLOBALS['REQUEST_URI'])) ? '' : 'ecrire/';
// API d'appel a la base de donnees
function spip_query($query) {
@ -609,9 +609,9 @@ function spip_query($query) {
//
// cf. liste des sapi_name - http://fr.php.net/php_sapi_name
$php_module = (($flag_sapi_name AND eregi("apache", @php_sapi_name())) OR
ereg("^Apache.* PHP", $SERVER_SOFTWARE));
$php_cgi = ($flag_sapi_name AND eregi("cgi", @php_sapi_name()));
$php_module = (($flag_sapi_name AND preg_match("/apache/i", @php_sapi_name())) OR
preg_match("/^Apache.* PHP/", $SERVER_SOFTWARE));
$php_cgi = ($flag_sapi_name AND preg_match("/cgi/i", @php_sapi_name()));
function http_status($status) {
global $php_cgi, $REDIRECT_STATUS;
@ -638,7 +638,7 @@ function http_last_modified($lastmodified, $expire = 0) {
if ($GLOBALS['HTTP_IF_MODIFIED_SINCE']
AND !preg_match(',IIS/,', $_SERVER['SERVER_SOFTWARE'])) # MSoft IIS is dumb
{
$if_modified_since = ereg_replace(';.*$', '', $GLOBALS['HTTP_IF_MODIFIED_SINCE']);
$if_modified_since = preg_replace('/;.*$/', '', $GLOBALS['HTTP_IF_MODIFIED_SINCE']);
$if_modified_since = trim(str_replace('GMT', '', $if_modified_since));
if ($if_modified_since == $gmoddate) {
http_status(304);
@ -669,12 +669,12 @@ function test_obgz () {
&& (phpversion()<>'4.0.4')
&& function_exists("ob_gzhandler")
// special bug de proxy
&& !eregi("NetCache|Hasd_proxy", $GLOBALS['HTTP_VIA'])
&& !preg_match("/NetCache|Hasd_proxy/i", $GLOBALS['HTTP_VIA'])
// special bug Netscape Win 4.0x
&& !eregi("Mozilla/4\.0[^ ].*Win", $GLOBALS['HTTP_USER_AGENT'])
&& !preg_match(",Mozilla/4\.0[^ ].*Win,i", $GLOBALS['HTTP_USER_AGENT'])
// special bug Apache2x
&& !eregi("Apache(-[^ ]+)?/2", $GLOBALS['SERVER_SOFTWARE'])
&& !($GLOBALS['flag_sapi_name'] AND ereg("^apache2", @php_sapi_name()))
&& !preg_match(",Apache(-[^ ]+)?/2,i", $GLOBALS['SERVER_SOFTWARE'])
&& !($GLOBALS['flag_sapi_name'] AND preg_match("/^apache2/", @php_sapi_name()))
// si la compression est deja commencee, stop
&& !@ini_get("zlib.output_compression")
&& !@ini_get("output_handler")
@ -711,13 +711,13 @@ class Link {
// Normal case
if ($link) {
if ($url) {
$v = split('[\?\&]', $url);
$v = preg_split('/[\?\&]/', $url);
list(, $this->file) = each($v);
while (list(, $var) = each($v)) {
list($name, $value) = split('=', $var, 2);
list($name, $value) = preg_split(',=,', $var, 2);
$name = urldecode($name);
$value = urldecode($value);
if (ereg('^(.*)\[\]$', $name, $regs)) {
if (preg_match('/^(.*)\[\]$/', $name, $regs)) {
$this->arrays[$regs[1]][] = $value;
}
else {
@ -757,14 +757,14 @@ class Link {
$vars[$var] = $val;
}
}
$v = split('[\?\&]', $url);
$v = preg_split(',[\?\&],', $url);
list(, $this->file) = each($v);
if (!$vars) {
while (list(,$var) = each($v)) {
list($name, $value) = split('=', $var, 2);
list($name, $value) = preg_split(',=,', $var, 2);
$name = urldecode($name);
$value = urldecode($value);
if (ereg('^(.*)\[\]$', $name, $regs))
if (preg_match('/^(.*)\[\]$/', $name, $regs))
$vars[$regs[1]][] = $value;
else
$vars[$name] = $value;
@ -1167,7 +1167,7 @@ function find_in_path ($filename, $path='AUTO') {
$racine = (_DIR_RESTREINT ? '' : '../');
// Parcourir le chemin
foreach (split(':', $path) as $dir) {
foreach (preg_split(',:,', $path) as $dir) {
if (substr($dir, 0,1)<>'/') $dir = "$racine$dir";
if (substr($dir, -1,1)<>'/') $dir .= "/";
$f = "$dir$filename";

10
ecrire/install.php3

@ -25,7 +25,7 @@ function tester_compatibilite_hebergement() {
$err = array();
$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]);
$m = '4.0.8';
$min = explode('.', $m);
@ -67,16 +67,16 @@ function login_hebergeur() {
// Lycos (ex-Multimachin)
if ($HTTP_X_HOST == 'membres.lycos.fr') {
ereg('^/([^/]*)', $REQUEST_URI, $regs);
preg_match(',^/([^/]*),', $REQUEST_URI, $regs);
$login_hebergeur = $regs[1];
}
// Altern
else if (ereg('altern\.com$', $SERVER_NAME)) {
ereg('([^.]*\.[^.]*)$', $HTTP_HOST, $regs);
else if (preg_match(',altern\.com$,', $SERVER_NAME)) {
preg_match(',([^.]*\.[^.]*)$,', $HTTP_HOST, $regs);
$login_hebergeur = ereg_replace('[^a-zA-Z0-9]', '_', $regs[1]);
}
// Free
else if (ereg('(.*)\.free\.fr$', $SERVER_NAME, $regs)) {
else if (preg_match(',(.*)\.free\.fr$,', $SERVER_NAME, $regs)) {
$base_hebergeur = 'sql.free.fr';
$login_hebergeur = $regs[1];
}

6
formulaires/inc-login_public.php3

@ -42,10 +42,10 @@ function login_explicite($login, $cible) {
$action = $link->getUrl();
if ($cible) {
$cible = ereg_replace("[?&]var_erreur=[^&]*", '', $cible);
$cible = ereg_replace("[?&]var_login=[^&]*", '', $cible);
$cible = preg_replace(",[?&]var_erreur=[^&]*,", '', $cible);
$cible = preg_replace(",[?&]var_login=[^&]*,", '', $cible);
} else {
if (ereg("[?&]url=([^&]*)", $action, $m))
if (preg_match(",[?&]url=([^&]*),", $action, $m))
$cible = urldecode($m[1]);
else
$cible = _DIR_RESTREINT ;

12
inc-cache.php3

@ -23,8 +23,8 @@ define("_INC_CACHE", "1");
function nettoyer_uri() {
$fichier_requete = $GLOBALS['REQUEST_URI'];
$fichier_requete = eregi_replace
('[?&](PHPSESSID|(var_[^=&]*))=[^&]*',
$fichier_requete = preg_replace
(',[?&](PHPSESSID|(var_[^=&]*))=[^&]*,i',
'', $fichier_requete);
return $fichier_requete;
}
@ -45,12 +45,12 @@ function generer_nom_fichier_cache($contexte='', $fond='') {
$fichier_requete .= "&$var=$val";
}
$fichier_cache = ereg_replace('^/+', '', $fichier_requete);
$fichier_cache = ereg_replace('\.[a-zA-Z0-9]*', '', $fichier_cache);
$fichier_cache = ereg_replace('&[^&]+=([^&]+)', '&\1', $fichier_cache);
$fichier_cache = preg_replace(',^/+,', '', $fichier_requete);
$fichier_cache = preg_replace(',\.[a-zA-Z0-9]*,', '', $fichier_cache);
$fichier_cache = preg_replace(',&[^&]+=([^&]+),', '&\1', $fichier_cache);
$fichier_cache = rawurlencode(strtr($fichier_cache, '/&-', '--_'));
if (strlen($fichier_cache) > 24)
$fichier_cache = substr(ereg_replace('([a-zA-Z]{1,3})[^-]*-',
$fichier_cache = substr(preg_replace('/([a-zA-Z]{1,3})[^-]*-/',
'\1-', $fichier_cache), -22);
// Pour la page d'accueil

Loading…
Cancel
Save