From 81f0ac628e5f7de254106310c95bdcdb3146e875 Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Sun, 13 Dec 2015 11:03:08 +0000 Subject: [PATCH] utiliser $GLOBALS plutot que global pour favoriser la lisibilite du code --- ecrire/inc/acces.php | 8 ++-- ecrire/inc/aider.php | 14 +++---- ecrire/inc/auth.php | 41 +++++++++----------- ecrire/inc/autoriser.php | 3 +- ecrire/inc/charsets.php | 19 ++++------ ecrire/inc/chercher_logo.php | 6 +-- ecrire/inc/chercher_rubrique.php | 7 ++-- ecrire/inc/commencer_page.php | 6 +-- ecrire/inc/distant.php | 5 +-- ecrire/inc/documents.php | 3 +- ecrire/inc/filtres.php | 4 +- ecrire/inc/filtres_ecrire.php | 17 ++++----- ecrire/inc/headers.php | 6 +-- ecrire/inc/install.php | 11 +++--- ecrire/inc/invalideur.php | 10 ++--- ecrire/inc/lang.php | 12 +++--- ecrire/inc/layer.php | 64 ++++++++++++++++---------------- ecrire/inc/log.php | 9 ++--- ecrire/inc/math.php | 6 +-- ecrire/inc/minipres.php | 3 +- ecrire/inc/pipelines.php | 7 ++-- ecrire/inc/plonger.php | 9 ++--- ecrire/inc/plugin.php | 7 ++-- ecrire/inc/precharger_objet.php | 7 ++-- ecrire/inc/presentation_mini.php | 5 +-- ecrire/inc/selectionner.php | 5 +-- ecrire/inc/utils.php | 7 ++-- 27 files changed, 133 insertions(+), 168 deletions(-) diff --git a/ecrire/inc/acces.php b/ecrire/inc/acces.php index 8c4551928d..45ff7c6c2f 100644 --- a/ecrire/inc/acces.php +++ b/ecrire/inc/acces.php @@ -211,8 +211,8 @@ function effacer_low_sec($id_auteur) { * @return void|bool */ function initialiser_sel() { - global $htsalt; - if (CRYPT_MD5) $htsalt = '$1$'.creer_pass_aleatoire(); + + if (CRYPT_MD5) $GLOBALS['htsalt'] = '$1$'.creer_pass_aleatoire(); else return ""; } @@ -281,9 +281,9 @@ function ecrire_acces() { * La chaîne hachée si fonction crypt présente, rien sinon. */ function generer_htpass($pass) { - global $htsalt; + if (function_exists('crypt')) { - return crypt($pass, $htsalt); + return crypt($pass, $GLOBALS['htsalt']); } } diff --git a/ecrire/inc/aider.php b/ecrire/inc/aider.php index 6f479e5fd1..f904365cfa 100644 --- a/ecrire/inc/aider.php +++ b/ecrire/inc/aider.php @@ -78,12 +78,11 @@ $GLOBALS['aider_index'] = array( * @return string **/ function inc_aider_dist($aide = '', $skel = '', $env = array(), $aide_spip_directe = false) { - global $spip_lang, $aider_index; if (($skel = basename($skel)) - AND isset($aider_index[$skel]) - AND isset($aider_index[$skel][$aide])) - $aide = $aider_index[$skel][$aide]; + AND isset($GLOBALS['aider_index'][$skel]) + AND isset($GLOBALS['aider_index'][$skel][$aide])) + $aide = $GLOBALS['aider_index'][$skel][$aide]; if ($aide_spip_directe) { // on suppose que spip.net est le premier present @@ -93,9 +92,9 @@ function inc_aider_dist($aide = '', $skel = '', $env = array(), $aide_spip_direc $url = array_shift($help_server) . '/'; $url = parametre_url($url, 'exec', 'aide'); $url = parametre_url($url, 'aide', $aide); - $url = parametre_url($url, 'var_lang', $spip_lang); + $url = parametre_url($url, 'var_lang', $GLOBALS['spip_lang']); } else { - $args = "aide=$aide&var_lang=$spip_lang"; + $args = "aide=$aide&var_lang=" . $GLOBALS['spip_lang']; $url = generer_url_ecrire("aide", $args); } @@ -116,11 +115,10 @@ function inc_aider_dist($aide = '', $skel = '', $env = array(), $aide_spip_direc */ function aider_icone($url, $clic= '') { - global $spip_lang, $spip_lang_rtl; if (!$clic) { $t = _T('titre_image_aide'); - $clic = http_img_pack("aide".aide_lang_dir($spip_lang,$spip_lang_rtl)."-16.png", + $clic = http_img_pack("aide".aide_lang_dir($GLOBALS['spip_lang'],$GLOBALS['spip_lang_rtl'])."-16.png", _T('info_image_aide'), " title=\"$t\" class='aide'"); } diff --git a/ecrire/inc/auth.php b/ecrire/inc/auth.php index fe52216295..e3d9d785f8 100644 --- a/ecrire/inc/auth.php +++ b/ecrire/inc/auth.php @@ -36,13 +36,11 @@ include_spip('base/abstract_sql'); */ function inc_auth_dist() { - global $connect_login ; - $row = auth_mode(); if ($row) return auth_init_droits($row); - if (!$connect_login) return auth_a_loger(); + if (!$GLOBALS['connect_login']) return auth_a_loger(); // Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui // C'est soit parce que la base est inutilisable, @@ -51,7 +49,7 @@ function inc_auth_dist() { // Renvoyer le nom fautif et une URL de remise a zero if (spip_connect()) - return array('login' => $connect_login, + return array('login' => $GLOBALS['connect_login'], 'site' => generer_url_public('', "action=logout&logout=prive")); $n = intval(sql_errno()); @@ -107,16 +105,14 @@ function auth_echec($raison) */ function auth_mode() { - global $auth_can_disconnect, $ignore_auth_http, $ignore_remote_user; - global $connect_login ; // // Initialiser variables (eviter hacks par URL) // - $connect_login = ''; + $GLOBALS['connect_login'] = ''; $id_auteur = NULL; - $auth_can_disconnect = false; + $GLOBALS['auth_can_disconnect'] = false; // // Recuperer les donnees d'identification @@ -129,14 +125,14 @@ function auth_mode() if ($id_auteur = $session() OR $id_auteur===0 // reprise sur restauration ) { - $auth_can_disconnect = true; - $connect_login = session_get('login'); + $GLOBALS['auth_can_disconnect'] = true; + $GLOBALS['connect_login'] = session_get('login'); } else unset($_COOKIE['spip_session']); } // Essayer auth http si significatif // (ignorer les login d'intranet independants de spip) - if (!$ignore_auth_http) { + if (!$GLOBALS['ignore_auth_http']) { if ( (isset($_SERVER['PHP_AUTH_USER']) AND isset($_SERVER['PHP_AUTH_PW']) AND $r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) @@ -149,9 +145,9 @@ function auth_mode() ) { if (!$id_auteur) { $_SERVER['PHP_AUTH_PW'] = ''; - $auth_can_disconnect = true; + $GLOBALS['auth_can_disconnect'] = true; $GLOBALS['visiteur_session'] = $r; - $connect_login = session_get('login'); + $GLOBALS['connect_login'] = session_get('login'); $id_auteur = $r['id_auteur']; } else { // cas de la session en plus de PHP_AUTH @@ -165,14 +161,14 @@ function auth_mode() // Authentification .htaccess old style, car .htaccess semble // souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW else if (isset($_SERVER['REMOTE_USER'])) - $connect_login = $_SERVER['REMOTE_USER']; + $GLOBALS['connect_login'] = $_SERVER['REMOTE_USER']; } $where = (is_numeric($id_auteur) /*AND $id_auteur>0*/ // reprise lors des restaurations ) ? "id_auteur=$id_auteur" : - (!strlen($connect_login) ? '' : "login=" . sql_quote($connect_login,'','text')); + (!strlen($GLOBALS['connect_login']) ? '' : "login=" . sql_quote($GLOBALS['connect_login'],'','text')); if (!$where) return ''; @@ -197,16 +193,15 @@ function auth_mode() */ function auth_init_droits($row) { - global $connect_statut, $connect_toutes_rubriques, $connect_id_rubrique, $connect_login, $connect_id_auteur; if ($row['statut']=='nouveau'){ include_spip('action/inscrire_auteur'); $row = confirmer_statut_inscription($row); } - $connect_id_auteur = $row['id_auteur']; - $connect_login = $row['login']; - $connect_statut = $row['statut']; + $GLOBALS['connect_id_auteur'] = $row['id_auteur']; + $GLOBALS['connect_login'] = $row['login']; + $GLOBALS['connect_statut'] = $row['statut']; $GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row); @@ -253,12 +248,12 @@ function auth_init_droits($row) auth_trace($row); // Administrateurs - if (in_array($connect_statut, explode(',', _STATUT_AUTEUR_RUBRIQUE))) { + if (in_array($GLOBALS['connect_statut'], explode(',', _STATUT_AUTEUR_RUBRIQUE))) { if (is_array($GLOBALS['visiteur_session']['restreint'])) { - $connect_id_rubrique = $GLOBALS['visiteur_session']['restreint']; + $GLOBALS['connect_id_rubrique'] = $GLOBALS['visiteur_session']['restreint']; } - if ($connect_statut == '0minirezo') { - $connect_toutes_rubriques = !$connect_id_rubrique; + if ($GLOBALS['connect_statut'] == '0minirezo') { + $GLOBALS['connect_toutes_rubriques'] = !$GLOBALS['connect_id_rubrique']; } } // Pour les redacteurs, inc_version a fait l'initialisation minimale diff --git a/ecrire/inc/autoriser.php b/ecrire/inc/autoriser.php index b98e014a8a..230eeae5f5 100644 --- a/ecrire/inc/autoriser.php +++ b/ecrire/inc/autoriser.php @@ -1450,9 +1450,8 @@ function auteurs_article($id_article, $cond = '') * @return bool true si administrateur de cette rubrique, false sinon. */ function acces_restreint_rubrique($id_rubrique) { - global $connect_id_rubrique; - return (isset($connect_id_rubrique[$id_rubrique])); + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); } diff --git a/ecrire/inc/charsets.php b/ecrire/inc/charsets.php index 2f25879338..f8252ec0d4 100644 --- a/ecrire/inc/charsets.php +++ b/ecrire/inc/charsets.php @@ -291,9 +291,8 @@ function html2unicode($texte, $secure = false) { if (strpos($texte,'&') === false) return $texte; static $trans = array(); if (!$trans) { - global $CHARSET; load_charset('html'); - foreach ($CHARSET['html'] as $key => $val) { + foreach ($GLOBALS['CHARSET']['html'] as $key => $val) { $trans["&$key;"] = $val; } } @@ -320,10 +319,9 @@ function html2unicode($texte, $secure = false) { function mathml2unicode($texte) { static $trans; if (!$trans) { - global $CHARSET; load_charset('mathml'); - foreach ($CHARSET['mathml'] as $key => $val) + foreach ($GLOBALS['CHARSET']['mathml'] as $key => $val) $trans["&$key;"] = $val; } @@ -380,10 +378,9 @@ function charset2unicode($texte, $charset = 'AUTO' /* $forcer: obsolete*/) { // Sinon, peut-etre connaissons-nous ce charset ? if (!isset($trans[$charset])) { - global $CHARSET; if ($cset = load_charset($charset) - AND is_array($CHARSET[$cset])) - foreach ($CHARSET[$cset] as $key => $val) { + AND is_array($GLOBALS['CHARSET'][$cset])) + foreach ($GLOBALS['CHARSET'][$cset] as $key => $val) { $trans[$charset][chr($key)] = '&#'.$val.';'; } } @@ -489,10 +486,9 @@ function importer_charset($texte, $charset = 'AUTO') { } // Sinon, peut-etre connaissons-nous ce charset ? if (!isset($trans[$charset])) { - global $CHARSET; if ($cset = load_charset($charset) - AND is_array($CHARSET[$cset])) - foreach ($CHARSET[$cset] as $key => $val) { + AND is_array($GLOBALS['CHARSET'][$cset])) + foreach ($GLOBALS['CHARSET'][$cset] as $key => $val) { $trans[$charset][chr($key)] = unicode2charset('&#'.$val.';'); } } @@ -770,9 +766,8 @@ function translitteration_rapide($texte, $charset = 'AUTO', $complexe = '') { // 2. Translitterer grace a la table predefinie if (!$trans[$complexe]) { - global $CHARSET; load_charset($table_translit); - foreach ($CHARSET[$table_translit] as $key => $val) + foreach ($GLOBALS['CHARSET'][$table_translit] as $key => $val) $trans[$complexe][caractere_utf_8($key)] = $val; } diff --git a/ecrire/inc/chercher_logo.php b/ecrire/inc/chercher_logo.php index 11832899b4..d8f56d3f38 100644 --- a/ecrire/inc/chercher_logo.php +++ b/ecrire/inc/chercher_logo.php @@ -34,13 +34,12 @@ if (!defined('_ECRIRE_INC_VERSION')) return; * - array vide aucun logo trouvé. **/ function inc_chercher_logo_dist($id, $_id_objet, $mode = 'on') { - global $formats_logos; # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() $type = type_du_logo($_id_objet); $nom = $type . $mode . intval($id); - foreach ($formats_logos as $format) { + foreach ($GLOBALS['formats_logos'] as $format) { if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { return array($d, _DIR_LOGOS, $nom, $format, @filemtime($d)); } @@ -70,8 +69,7 @@ function type_du_logo($_id_objet) { } // Exceptions standards (historique) -global $table_logos; -$table_logos = array( +$GLOBALS['table_logos'] = array( 'id_article' => 'art', 'id_auteur' => 'aut', 'id_rubrique' => 'rub', diff --git a/ecrire/inc/chercher_rubrique.php b/ecrire/inc/chercher_rubrique.php index 2e55d1017b..7f35fae14d 100644 --- a/ecrire/inc/chercher_rubrique.php +++ b/ecrire/inc/chercher_rubrique.php @@ -75,12 +75,11 @@ $GLOBALS['selecteur_rubrique'] = 'inc_chercher_rubrique_dist'; * Liste (classe CSS, styles en ligne, Espaces insécables) **/ function style_menu_rubriques($i) { - global $browser_name, $spip_lang_left; $espace = ''; - if (preg_match(",mozilla,i", $browser_name)) { - $style = "padding-$spip_lang_left: 16px; " - . "margin-$spip_lang_left: ".(($i-1)*16)."px;"; + if (preg_match(",mozilla,i", $GLOBALS['browser_name'])) { + $style = "padding-" . $GLOBALS['spip_lang_left'] . ": 16px; " + . "margin-" . $GLOBALS['spip_lang_left'] . ": ".(($i-1)*16)."px;"; } else { $style = ''; for ($count = 0; $count <= $i; $count ++) diff --git a/ecrire/inc/commencer_page.php b/ecrire/inc/commencer_page.php index fea95b881c..988a622547 100644 --- a/ecrire/inc/commencer_page.php +++ b/ecrire/inc/commencer_page.php @@ -41,7 +41,6 @@ if (!defined('_ECRIRE_INC_VERSION')) return; * @return string Code HTML **/ function inc_commencer_page_dist($titre = "", $rubrique = "accueil", $sous_rubrique = "accueil", $id_rubrique = "", $menu = true, $minipres = false, $alertes = true) { - global $connect_id_auteur; include_spip('inc/headers'); @@ -50,8 +49,8 @@ function inc_commencer_page_dist($titre = "", $rubrique = "accueil", $sous_rubri return init_entete($titre, $id_rubrique, $minipres) . init_body($rubrique, $sous_rubrique, $id_rubrique,$menu) . "<div id='page'>" - . auteurs_recemment_connectes($connect_id_auteur) - . ($alertes?alertes_auteur($connect_id_auteur):'') + . auteurs_recemment_connectes($GLOBALS['connect_id_auteur']) + . ($alertes?alertes_auteur($GLOBALS['connect_id_auteur']):'') . '<div class="largeur">'; } @@ -121,7 +120,6 @@ function init_head($titre = '', $dummy = 0, $minipres = false) { * @return string */ function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) { - global $connect_id_auteur, $auth_can_disconnect; $res = pipeline('body_prive',"<body class='" . init_body_class()." "._request('exec')."'" diff --git a/ecrire/inc/distant.php b/ecrire/inc/distant.php index f918738b92..7d9ca70439 100644 --- a/ecrire/inc/distant.php +++ b/ecrire/inc/distant.php @@ -845,7 +845,6 @@ function recuperer_infos_distantes($source, $max = 0, $charger_si_petite_image = # charger les alias des types mime include_spip('base/typedoc'); - global $mime_alias; $a = array(); $mime_type = ''; @@ -861,8 +860,8 @@ function recuperer_infos_distantes($source, $max = 0, $charger_si_petite_image = $mime_type = ''; // inconnu // Appliquer les alias - while (isset($mime_alias[$mime_type])) - $mime_type = $mime_alias[$mime_type]; + while (isset($GLOBALS['mime_alias'][$mime_type])) + $mime_type = $GLOBALS['mime_alias'][$mime_type]; // Si on a un mime-type insignifiant // text/plain,application/octet-stream ou vide diff --git a/ecrire/inc/documents.php b/ecrire/inc/documents.php index d268cc27ef..87bae65742 100644 --- a/ecrire/inc/documents.php +++ b/ecrire/inc/documents.php @@ -231,7 +231,6 @@ function deplacer_fichier_upload($source, $dest, $move = false) { * @return boolean|string */ function check_upload_error($error, $msg = '', $return = false) { - global $spip_lang_right; if (!$error) return false; @@ -274,7 +273,7 @@ function check_upload_error($error, $msg = '', $return = false) { include_spip('inc/minipres'); echo minipres($msg, - "<div style='text-align: $spip_lang_right'><a href='" . rawurldecode($GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . "</button></a></div>"); + "<div style='text-align: ".$GLOBALS['spip_lang_right']."'><a href='" . rawurldecode($GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . "</button></a></div>"); exit; } ?> diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index f9c78dcf9f..3affd497ff 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -2252,8 +2252,8 @@ function centrer($letexte) {return aligner($letexte, 'center');} * @return string Style CSS **/ function style_align($bof) { - global $spip_lang_left; - return "text-align: $spip_lang_left"; + + return "text-align: " . $GLOBALS['spip_lang_left']; } // diff --git a/ecrire/inc/filtres_ecrire.php b/ecrire/inc/filtres_ecrire.php index 8860df8dd1..935772a258 100644 --- a/ecrire/inc/filtres_ecrire.php +++ b/ecrire/inc/filtres_ecrire.php @@ -37,7 +37,6 @@ include_spip('inc/pipelines_ecrire'); * @return string */ function parametres_css_prive(){ - global $visiteur_session; $args = array(); $args['v'] = $GLOBALS['spip_version_code']; @@ -47,9 +46,9 @@ function parametres_css_prive(){ // un md5 des menus : si un menu change il faut maj la css $args['md5b'] = (function_exists('md5_boutons_plugins')?md5_boutons_plugins():''); - $c = (is_array($visiteur_session) - AND is_array($visiteur_session['prefs'])) - ? $visiteur_session['prefs']['couleur'] + $c = (is_array($GLOBALS['visiteur_session']) + AND is_array($GLOBALS['visiteur_session']['prefs'])) + ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 9; $couleurs = charger_fonction('couleurs', 'inc'); @@ -82,7 +81,7 @@ function parametres_css_prive(){ * @return string */ function chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable = false, $retour_sans_cadre = false){ - global $spip_lang_right; + include_spip('inc/autoriser'); if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) return ""; @@ -116,7 +115,7 @@ function chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $ $form .= $confirm; if ($actionable){ if (strpos($form,'<select')!==false) { - $form .= "<div style='text-align: $spip_lang_right;'>" + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" . '<input class="fondo" type="submit" value="'._T('bouton_choisir').'"/>' . "</div>"; } @@ -318,11 +317,11 @@ function auteurs_lister_statuts($quoi = 'tous', $en_base = true) { * @return int Identifiant de la rubrique dans laquelle créer l'objet */ function trouver_rubrique_creer_objet($id_rubrique, $objet){ - global $connect_id_rubrique; + if (!$id_rubrique AND defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') AND _CHOIX_RUBRIQUE_PAR_DEFAUT){ - $in = !count($connect_id_rubrique) + $in = !count($GLOBALS['connect_id_rubrique']) ? '' - : (" AND ".sql_in('id_rubrique', $connect_id_rubrique)); + : (" AND ".sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement if ($objet == 'rubrique') { diff --git a/ecrire/inc/headers.php b/ecrire/inc/headers.php index f793d586c8..f2a119477e 100644 --- a/ecrire/inc/headers.php +++ b/ecrire/inc/headers.php @@ -170,7 +170,7 @@ function redirige_url_ecrire($script = '', $args = '', $equiv = '') { * Code d'erreur **/ function http_status($status) { - global $REDIRECT_STATUS, $flag_sapi_name; + static $status_string = array( 200 => '200 OK', 204 => '204 No Content', @@ -183,9 +183,9 @@ function http_status($status) { 503 => '503 Service Unavailable' ); - if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return; + if ($GLOBALS['REDIRECT_STATUS'] && $GLOBALS['REDIRECT_STATUS'] == $status) return; - $php_cgi = ($flag_sapi_name AND preg_match(",cgi,i", @php_sapi_name())); + $php_cgi = ($GLOBALS['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/install.php b/ecrire/inc/install.php index e699839a15..be4b667543 100644 --- a/ecrire/inc/install.php +++ b/ecrire/inc/install.php @@ -214,22 +214,21 @@ function tester_compatibilite_hebergement() { // Une fonction pour faciliter la recherche du login (superflu ?) // http://code.spip.net/@login_hebergeur function login_hebergeur() { - global $HTTP_X_HOST, $REQUEST_URI, $SERVER_NAME, $HTTP_HOST; $base_hebergeur = 'localhost'; # par defaut // Lycos (ex-Multimachin) - if ($HTTP_X_HOST == 'membres.lycos.fr') { - preg_match(',^/([^/]*),', $REQUEST_URI, $regs); + if ($GLOBALS['HTTP_X_HOST'] == 'membres.lycos.fr') { + preg_match(',^/([^/]*),', $GLOBALS['REQUEST_URI'], $regs); $login_hebergeur = $regs[1]; } // Altern - else if (preg_match(',altern\.com$,', $SERVER_NAME)) { - preg_match(',([^.]*\.[^.]*)$,', $HTTP_HOST, $regs); + else if (preg_match(',altern\.com$,', $GLOBALS['SERVER_NAME'])) { + preg_match(',([^.]*\.[^.]*)$,', $GLOBALS['HTTP_HOST'], $regs); $login_hebergeur = preg_replace('[^\w\d]', '_', $regs[1]); } // Free - else if (preg_match(',(.*)\.free\.fr$,', $SERVER_NAME, $regs)) { + else if (preg_match(',(.*)\.free\.fr$,', $GLOBALS['SERVER_NAME'], $regs)) { $base_hebergeur = 'sql.free.fr'; $login_hebergeur = $regs[1]; } else $login_hebergeur = ''; diff --git a/ecrire/inc/invalideur.php b/ecrire/inc/invalideur.php index 93b8b970e1..cc1e55da01 100644 --- a/ecrire/inc/invalideur.php +++ b/ecrire/inc/invalideur.php @@ -194,7 +194,7 @@ function purger_repertoire($dir, $options = array()) { // // http://code.spip.net/@appliquer_quota_cache function appliquer_quota_cache() { - global $quota_cache; + $encore = false; $tour_quota_cache = intval(1+$GLOBALS['meta']['tour_quota_cache'])%16; @@ -208,9 +208,9 @@ function appliquer_quota_cache() { .(intval(16*$total_cache/(1024*1024/10))/10)." Mo","invalideur"); // Nombre max de fichiers a supprimer - if ($quota_cache > 0 + if ($GLOBALS['quota_cache'] > 0 AND $taille > 0) { - $trop = $total_cache - ($quota_cache/16)*1024*1024; + $trop = $total_cache - ($GLOBALS['quota_cache']/16)*1024*1024; $trop = 3 * intval($trop / $taille); if ($trop > 0) { $n = purger_repertoire($dir, @@ -222,12 +222,12 @@ function appliquer_quota_cache() { ); spip_log("$dir : $n/$trop caches supprimes [taille moyenne $taille]","invalideur"); $total_cache = intval(max(0,(16*$total_cache) - $n*$taille)/(1024*1024)*10)/10; - spip_log("cache restant estime : $total_cache Mo, ratio ".$total_cache/$quota_cache,"invalideur"); + spip_log("cache restant estime : $total_cache Mo, ratio ".$total_cache/$GLOBALS['quota_cache'],"invalideur"); // redemander la main pour eviter que le cache ne gonfle trop // mais pas si on ne peut pas purger car les fichiers sont trops recents if ( - $total_cache/$quota_cache>1.5 + $total_cache/$GLOBALS['quota_cache']>1.5 AND $n*50>$trop) { $encore = true; spip_log("Il faut encore purger","invalideur"); diff --git a/ecrire/inc/lang.php b/ecrire/inc/lang.php index a2b95502e8..5c400390fa 100644 --- a/ecrire/inc/lang.php +++ b/ecrire/inc/lang.php @@ -35,7 +35,6 @@ if (!defined('_ECRIRE_INC_VERSION')) return; * false : aucune langue ne correspondait à la demande **/ function changer_langue($lang) { - global $spip_lang_rtl, $spip_lang_right, $spip_lang_left; $liste_langues = ',' . @$GLOBALS['meta']['langues_proposees'] . ',' . @$GLOBALS['meta']['langues_multilingue'] . ','; @@ -50,9 +49,9 @@ function changer_langue($lang) { OR ($lang = preg_replace(',_.*,', '', $lang) AND strpos($liste_langues,",$lang,")!==false)) { - $spip_lang_rtl = lang_dir($lang, '', '_rtl'); - $spip_lang_right = $spip_lang_rtl ? 'left' : 'right'; - $spip_lang_left = $spip_lang_rtl ? 'right' : 'left'; + $GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl'); + $GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right'; + $GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left'; return $GLOBALS['spip_lang'] = $lang; } else @@ -270,7 +269,6 @@ function liste_options_langues($nom_select) { * @return void **/ function verifier_lang_url() { - global $spip_lang; // quelle langue est demandee ? $lang_demandee = (test_espace_prive()?$GLOBALS['spip_lang']:$GLOBALS['meta']['langue_site']); @@ -282,7 +280,7 @@ function verifier_lang_url() { $lang_demandee = $_GET['lang']; // Renvoyer si besoin (et si la langue demandee existe) - if ($spip_lang != $lang_demandee + if ($GLOBALS['spip_lang'] != $lang_demandee AND changer_langue($lang_demandee) AND $lang_demandee != @$_GET['lang']) { $destination = parametre_url(self(),'lang', $lang_demandee, '&'); @@ -298,7 +296,7 @@ function verifier_lang_url() { // Subtilite : si la langue demandee par cookie est la bonne // alors on fait comme si $lang etait passee dans l'URL // (pour criteres {lang}). - $GLOBALS['lang'] = $_GET['lang'] = $spip_lang; + $GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang']; } diff --git a/ecrire/inc/layer.php b/ecrire/inc/layer.php index b839c06eb3..c2919bf57b 100644 --- a/ecrire/inc/layer.php +++ b/ecrire/inc/layer.php @@ -95,51 +95,49 @@ function bouton_block_depliable($texte, $deplie, $ids = ""){ // http://code.spip.net/@verif_butineur function verif_butineur() { - global $browser_name, $browser_version; - global $browser_description, $browser_rev, $browser_barre; preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match); - $browser_name = $match[1]; - $browser_version = $match[2]; - $browser_description = $match[3]; + $GLOBALS['browser_name'] = $match[1]; + $GLOBALS['browser_version'] = $match[2]; + $GLOBALS['browser_description'] = $match[3]; $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur - $browser_barre = ''; + $GLOBALS['browser_barre'] = ''; - if (!preg_match(",opera,i", $browser_description)&&preg_match(",opera,i", $browser_name)) { - $browser_name = "Opera"; - $browser_version = $match[2]; - $browser_barre = ($browser_version >= 8.5); + if (!preg_match(",opera,i", $GLOBALS['browser_description'])&&preg_match(",opera,i", $GLOBALS['browser_name'])) { + $GLOBALS['browser_name'] = "Opera"; + $GLOBALS['browser_version'] = $match[2]; + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); } - else if (preg_match(",opera,i", $browser_description)) { - preg_match(",Opera ([^\ ]*),i", $browser_description, $match); - $browser_name = "Opera"; - $browser_version = $match[1]; - $browser_barre = ($browser_version >= 8.5); + else if (preg_match(",opera,i", $GLOBALS['browser_description'])) { + preg_match(",Opera ([^\ ]*),i", $GLOBALS['browser_description'], $match); + $GLOBALS['browser_name'] = "Opera"; + $GLOBALS['browser_version'] = $match[1]; + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); } - else if (preg_match(",msie,i", $browser_description)) { - preg_match(",MSIE ([^;]*),i", $browser_description, $match); - $browser_name = "MSIE"; - $browser_version = $match[1]; - $browser_barre = ($browser_version >= 5.5); + else if (preg_match(",msie,i", $GLOBALS['browser_description'])) { + preg_match(",MSIE ([^;]*),i", $GLOBALS['browser_description'], $match); + $GLOBALS['browser_name'] = "MSIE"; + $GLOBALS['browser_version'] = $match[1]; + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5); } - else if (preg_match(",KHTML,i", $browser_description) && - preg_match(",Safari/([^;]*),", $browser_description, $match)) { - $browser_name = "Safari"; - $browser_version = $match[1]; - $browser_barre = ($browser_version >= 5.0); + else if (preg_match(",KHTML,i", $GLOBALS['browser_description']) && + preg_match(",Safari/([^;]*),", $GLOBALS['browser_description'], $match)) { + $GLOBALS['browser_name'] = "Safari"; + $GLOBALS['browser_version'] = $match[1]; + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0); } - else if (preg_match(",mozilla,i", $browser_name) AND $browser_version >= 5) { + else if (preg_match(",mozilla,i", $GLOBALS['browser_name']) AND $GLOBALS['browser_version'] >= 5) { // Numero de version pour Mozilla "authentique" - if (preg_match(",rv:([0-9]+\.[0-9]+),", $browser_description, $match)) - $browser_rev = doubleval($match[1]); + if (preg_match(",rv:([0-9]+\.[0-9]+),", $GLOBALS['browser_description'], $match)) + $GLOBALS['browser_rev'] = doubleval($match[1]); // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) - else if (strpos($browser_description, "Gecko") and !strpos($browser_description, "KHTML")) - $browser_rev = 1.4; + else if (strpos($GLOBALS['browser_description'], "Gecko") and !strpos($GLOBALS['browser_description'], "KHTML")) + $GLOBALS['browser_rev'] = 1.4; // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) - else $browser_rev = 1.0; - $browser_barre = $browser_rev >= 1.3; + else $GLOBALS['browser_rev'] = 1.0; + $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3; } - if (!$browser_name) $browser_name = "Mozilla"; + if (!$GLOBALS['browser_name']) $GLOBALS['browser_name'] = "Mozilla"; } verif_butineur(); diff --git a/ecrire/inc/log.php b/ecrire/inc/log.php index d9e5053165..eae4904c8a 100644 --- a/ecrire/inc/log.php +++ b/ecrire/inc/log.php @@ -16,7 +16,6 @@ function inc_log_dist($message, $logname = NULL, $logdir = NULL, $logsuf = NULL) static $test_repertoire = array(); static $compteur = array(); static $debugverb = ""; // pour ne pas le recalculer au reappel - global $nombre_de_logs, $taille_des_logs; if (is_null($logname) OR !is_string($logname)) $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; @@ -25,8 +24,8 @@ function inc_log_dist($message, $logname = NULL, $logdir = NULL, $logsuf = NULL) AND defined('_MAX_LOG') AND ( $compteur[$logname]++ > _MAX_LOG - OR !$nombre_de_logs - OR !$taille_des_logs + OR !$GLOBALS['nombre_de_logs'] + OR !$GLOBALS['taille_des_logs'] )) return; @@ -67,8 +66,8 @@ function inc_log_dist($message, $logname = NULL, $logdir = NULL, $logsuf = NULL) if (@is_readable($logfile) - AND (!$s = @filesize($logfile) OR $s > $taille_des_logs * 1024)) { - $rotate = $nombre_de_logs; + AND (!$s = @filesize($logfile) OR $s > $GLOBALS['taille_des_logs'] * 1024)) { + $rotate = $GLOBALS['nombre_de_logs']; $m .= "[-- rotate --]\n"; } diff --git a/ecrire/inc/math.php b/ecrire/inc/math.php index d42527d279..329e3a25c9 100644 --- a/ecrire/inc/math.php +++ b/ecrire/inc/math.php @@ -20,8 +20,8 @@ if (!defined('_ECRIRE_INC_VERSION')) return; // http://code.spip.net/@image_math function produire_image_math($tex) { - global $traiter_math; - switch ($traiter_math) { + + switch ($GLOBALS['traiter_math']) { // Attention: mathml desactiv'e pour l'instant case 'mathml': $ext = '.xhtml'; @@ -56,7 +56,7 @@ function produire_image_math($tex) { if (@file_exists($fichier)) { // MathML - if ($traiter_math == 'mathml') { + if ($GLOBALS['traiter_math'] == 'mathml') { return join(file("$fichier"),""); } diff --git a/ecrire/inc/minipres.php b/ecrire/inc/minipres.php index 18f39822b4..cd75f1228a 100644 --- a/ecrire/inc/minipres.php +++ b/ecrire/inc/minipres.php @@ -43,8 +43,7 @@ include_spip('inc/texte'); //inclue inc/lang et inc/filtres * Code HTML */ function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) { - global $spip_lang_right,$spip_lang_left; - + utiliser_langue_visiteur(); http_no_cache(); diff --git a/ecrire/inc/pipelines.php b/ecrire/inc/pipelines.php index 79063a551c..16512f0af2 100644 --- a/ecrire/inc/pipelines.php +++ b/ecrire/inc/pipelines.php @@ -110,16 +110,15 @@ function f_tidy ($texte) { * - true : actif. * - false par défaut. */ - global $xhtml; - if ($xhtml # tidy demande + if ($GLOBALS['xhtml'] # tidy demande AND $GLOBALS['html'] # verifie que la page avait l'entete text/html AND strlen($texte) AND !headers_sent()) { # Compatibilite ascendante - if (!is_string($xhtml)) $xhtml ='tidy'; + if (!is_string($GLOBALS['xhtml'])) $GLOBALS['xhtml'] ='tidy'; - if (!$f = charger_fonction($xhtml, 'inc', true)) { + if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { spip_log("tidy absent, l'indenteur SPIP le remplace"); $f = charger_fonction('sax', 'xml'); } diff --git a/ecrire/inc/plonger.php b/ecrire/inc/plonger.php index 1e0c9e2d7a..b79dfb9390 100644 --- a/ecrire/inc/plonger.php +++ b/ecrire/inc/plonger.php @@ -16,8 +16,7 @@ include_spip('inc/texte'); // http://code.spip.net/@inc_plonger_dist function inc_plonger_dist($id_rubrique, $idom = "", $list = array(), $col = 1, $exclu = 0, $do = 'aff') { - global $spip_lang_left; - + if ($list) $id_rubrique = $list[$col-1]; $ret = ''; @@ -52,7 +51,7 @@ function inc_plonger_dist($id_rubrique, $idom = "", $list = array(), $col = 1, $ if ($ordre) { $rec = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclu&do=$do&col=".($col+1)); $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); - $args = "'$idom',this,$col,'$spip_lang_left','$info',event"; + $args = "'$idom',this,$col,'".$GLOBALS['spip_lang_left']."','$info',event"; while (list($id, $titrebrut) = each($ordre)) { $titre = supprimer_numero($titrebrut); @@ -96,10 +95,10 @@ function inc_plonger_dist($id_rubrique, $idom = "", $list = array(), $col = 1, $ $idom2 = $idom . "_col_".($col+1); $left = ($col*150); - return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_left: " + return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; ".$GLOBALS['spip_lang_left'].": " . ($left-30) . "px; top: 2px; z-index: 2;' id='img_$idom2'") - . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; $spip_lang_left: " + . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; ".$GLOBALS['spip_lang_left'].": " .($left-150) ."px;'>" . $ret diff --git a/ecrire/inc/plugin.php b/ecrire/inc/plugin.php index ade772916d..6fd3a9bc77 100644 --- a/ecrire/inc/plugin.php +++ b/ecrire/inc/plugin.php @@ -912,10 +912,9 @@ function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) // precompilation des pipelines // http://code.spip.net/@pipeline_precompile function pipeline_precompile($prepend_code = array()){ - global $spip_pipeline, $spip_matrice; $content = ""; - foreach($spip_pipeline as $action=>$pipeline){ + foreach($GLOBALS['spip_pipeline'] as $action=>$pipeline){ $s_inc = ""; $s_call = ""; $pipe = array_filter(explode('|',$pipeline)); @@ -923,8 +922,8 @@ function pipeline_precompile($prepend_code = array()){ foreach ($pipe as $fonc) { $fonc = trim($fonc); $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; - if (isset($spip_matrice[$fonc])){ - $file = $spip_matrice[$fonc]; + if (isset($GLOBALS['spip_matrice'][$fonc])){ + $file = $GLOBALS['spip_matrice'][$fonc]; $file = "'$file'"; // si un _DIR_XXX: est dans la chaine, on extrait la constante if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums",$file,$regs)){ diff --git a/ecrire/inc/precharger_objet.php b/ecrire/inc/precharger_objet.php index 288e03bb5a..569b31f586 100644 --- a/ecrire/inc/precharger_objet.php +++ b/ecrire/inc/precharger_objet.php @@ -43,8 +43,7 @@ include_spip('inc/autoriser'); // necessaire si appel de l'espace public * Couples clés / valeurs des champs du formulaire à charger. **/ function precharger_objet($type, $id_objet, $id_rubrique = 0, $lier_trad = 0, $champ_titre = 'titre') { - global $connect_id_rubrique, $spip_lang; - + $table = table_objet_sql($type); $_id_objet = id_table_objet($table); @@ -81,8 +80,8 @@ function precharger_objet($type, $id_objet, $id_rubrique = 0, $lier_trad = 0, $c // admin restreint ==> sa premiere rubrique // autre ==> la derniere rubrique cree if (!$row['id_rubrique']) { - if ($connect_id_rubrique) - $row['id_rubrique'] = $id_rubrique = current($connect_id_rubrique); + if ($GLOBALS['connect_id_rubrique']) + $row['id_rubrique'] = $id_rubrique = current($GLOBALS['connect_id_rubrique']); else { $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", 1); $row['id_rubrique'] = $id_rubrique = $row_rub['id_rubrique']; diff --git a/ecrire/inc/presentation_mini.php b/ecrire/inc/presentation_mini.php index a6e1007091..23791d8ceb 100644 --- a/ecrire/inc/presentation_mini.php +++ b/ecrire/inc/presentation_mini.php @@ -215,9 +215,8 @@ function info_maj_spip(){ * @return string Code HTML **/ function info_copyright() { - global $spip_version_affichee, $spip_lang; - $version = $spip_version_affichee; + $version = $GLOBALS['spip_version_affichee']; // // Mention, le cas echeant, de la revision SVN courante @@ -237,7 +236,7 @@ function info_copyright() { return _T('info_copyright', array('spip' => "<b>SPIP $version</b> ", 'lien_gpl' => - "<a href='". generer_url_ecrire("aide", "aide=licence&var_lang=$spip_lang") . "' class=\"aide popin\">" . _T('info_copyright_gpl')."</a>")) + "<a href='". generer_url_ecrire("aide", "aide=licence&var_lang=".$GLOBALS['spip_lang']) . "' class=\"aide popin\">" . _T('info_copyright_gpl')."</a>")) . $secu; } diff --git a/ecrire/inc/selectionner.php b/ecrire/inc/selectionner.php index 855a063e51..efb5a1eee6 100644 --- a/ecrire/inc/selectionner.php +++ b/ecrire/inc/selectionner.php @@ -97,7 +97,6 @@ function inc_selectionner_dist ($sel, $idom = "", $exclus = 0, $aff_racine = fal **/ function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { - global $spip_lang_right; $idom1 = $idom . "_champ_recherche"; $idom2 = $idom . "_principal"; @@ -111,9 +110,9 @@ function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, . ($url_init ? "\nhref='$url_init'" : '') . "></a>" . "<div class='recherche_rapide_parent'>" - . http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'") + . http_img_pack("searching.gif", "*", "style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'") . "" - . "<input style='width: 100px;float:$spip_lang_right;' type='search' id='$idom1'" + . "<input style='width: 100px;float:".$GLOBALS['spip_lang_right'].";' type='search' id='$idom1'" // eliminer Return car il provoque la soumission (balise unique) // et eliminer Tab pour la navigation au clavier // ce serait encore mieux de ne le faire que s'il y a encore plusieurs diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 35c3400377..55694bdd0b 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -1767,7 +1767,6 @@ function generer_url_prive($script, $args = "", $no_entities = false) { * Code HTML du formulaire **/ function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { - global $spip_lang_right; $script1 = explode('&', $script); $script1 = reset($script1); @@ -1780,7 +1779,7 @@ function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { . "<input type='hidden' name='exec' value='$script1' />" . $corps . (!$submit ? '' : - ("<div style='text-align: $spip_lang_right'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) + ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) . "</div></form>\n"; } @@ -2506,8 +2505,8 @@ function aide($aide = '', $distante = false) { * Si l’utiliseur est un administrateur. */ function exec_info_dist() { - global $connect_statut; - if ($connect_statut == '0minirezo') + + if ($GLOBALS['connect_statut'] == '0minirezo') phpinfo(); else echo "pas admin"; -- GitLab