@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | require_once __DIR__ . '/bootstrap/config/initial.php'; |
| 25 | 25 | |
| 26 | 26 | // inclure l'ecran de securite si il n'a pas été inclus en prepend php |
| 27 | 27 | if ( |
| 28 | - !defined('_ECRAN_SECURITE') |
|
| 29 | - && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 28 | + !defined('_ECRAN_SECURITE') |
|
| 29 | + && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 30 | 30 | ) { |
| 31 | - include $f; |
|
| 31 | + include $f; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // et on peut lancer l'autoloader |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | // Definition personnelles eventuelles |
| 76 | 76 | |
| 77 | 77 | if (_FILE_OPTIONS) { |
| 78 | - include_once _FILE_OPTIONS; |
|
| 78 | + include_once _FILE_OPTIONS; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | if (!defined('SPIP_ERREUR_REPORT')) { |
| 82 | - /** Masquer les warning */ |
|
| 83 | - define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 82 | + /** Masquer les warning */ |
|
| 83 | + define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | ErrorHandler::setup(SPIP_ERREUR_REPORT); |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | // ===> on execute en neutralisant les messages d'erreur |
| 95 | 95 | |
| 96 | 96 | spip_initialisation_core( |
| 97 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 98 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 99 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 100 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 97 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 98 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 99 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 100 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | 103 | // chargement des plugins : doit arriver en dernier |
@@ -106,72 +106,72 @@ discard block |
||
| 106 | 106 | // donc il faut avoir tout fini ici avant de charger les plugins |
| 107 | 107 | |
| 108 | 108 | if (@is_readable(_CACHE_PLUGINS_OPT) && @is_readable(_CACHE_PLUGINS_PATH)) { |
| 109 | - // chargement optimise precompile |
|
| 110 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 109 | + // chargement optimise precompile |
|
| 110 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 111 | 111 | } else { |
| 112 | - spip_initialisation_suite(); |
|
| 113 | - include_spip('inc/plugin'); |
|
| 114 | - // generer les fichiers php precompiles |
|
| 115 | - // de chargement des plugins et des pipelines |
|
| 116 | - actualise_plugins_actifs(); |
|
| 112 | + spip_initialisation_suite(); |
|
| 113 | + include_spip('inc/plugin'); |
|
| 114 | + // generer les fichiers php precompiles |
|
| 115 | + // de chargement des plugins et des pipelines |
|
| 116 | + actualise_plugins_actifs(); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Initialisations non critiques surchargeables par les plugins |
| 120 | 120 | spip_initialisation_suite(); |
| 121 | 121 | |
| 122 | 122 | if (!defined('_LOG_FILTRE_GRAVITE')) { |
| 123 | - /** niveau maxi d'enregistrement des logs */ |
|
| 124 | - define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 123 | + /** niveau maxi d'enregistrement des logs */ |
|
| 124 | + define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | if (!defined('_OUTILS_DEVELOPPEURS')) { |
| 128 | - /** Activer des outils pour développeurs ? */ |
|
| 129 | - define('_OUTILS_DEVELOPPEURS', false); |
|
| 128 | + /** Activer des outils pour développeurs ? */ |
|
| 129 | + define('_OUTILS_DEVELOPPEURS', false); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // charger systematiquement inc/autoriser dans l'espace restreint |
| 133 | 133 | if (test_espace_prive()) { |
| 134 | - include_spip('inc/autoriser'); |
|
| 134 | + include_spip('inc/autoriser'); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // |
| 138 | 138 | // Installer Spip si pas installe... sauf si justement on est en train |
| 139 | 139 | // |
| 140 | 140 | if ( |
| 141 | - !(_FILE_CONNECT |
|
| 142 | - || autoriser_sans_cookie(_request('exec')) |
|
| 143 | - || _request('action') == 'cookie' |
|
| 144 | - || _request('action') == 'converser' |
|
| 145 | - || _request('action') == 'test_dirs') |
|
| 141 | + !(_FILE_CONNECT |
|
| 142 | + || autoriser_sans_cookie(_request('exec')) |
|
| 143 | + || _request('action') == 'cookie' |
|
| 144 | + || _request('action') == 'converser' |
|
| 145 | + || _request('action') == 'test_dirs') |
|
| 146 | 146 | ) { |
| 147 | - // Si on peut installer, on lance illico |
|
| 148 | - if (test_espace_prive()) { |
|
| 149 | - include_spip('inc/headers'); |
|
| 150 | - redirige_url_ecrire('install'); |
|
| 151 | - } else { |
|
| 152 | - // Si on est dans le site public, dire que qq s'en occupe |
|
| 153 | - include_spip('inc/lang'); |
|
| 154 | - utiliser_langue_visiteur(); |
|
| 155 | - include_spip('inc/minipres'); |
|
| 156 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 157 | - exit; |
|
| 158 | - } |
|
| 159 | - // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 147 | + // Si on peut installer, on lance illico |
|
| 148 | + if (test_espace_prive()) { |
|
| 149 | + include_spip('inc/headers'); |
|
| 150 | + redirige_url_ecrire('install'); |
|
| 151 | + } else { |
|
| 152 | + // Si on est dans le site public, dire que qq s'en occupe |
|
| 153 | + include_spip('inc/lang'); |
|
| 154 | + utiliser_langue_visiteur(); |
|
| 155 | + include_spip('inc/minipres'); |
|
| 156 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 157 | + exit; |
|
| 158 | + } |
|
| 159 | + // autrement c'est une install ad hoc (spikini...), on sait pas faire |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // memoriser un tri sessionne eventuel |
| 163 | 163 | if ( |
| 164 | - isset($_REQUEST['var_memotri']) |
|
| 165 | - && ($t = $_REQUEST['var_memotri']) |
|
| 166 | - && (str_starts_with((string) $t, 'trisession') || str_starts_with((string) $t, 'senssession')) |
|
| 164 | + isset($_REQUEST['var_memotri']) |
|
| 165 | + && ($t = $_REQUEST['var_memotri']) |
|
| 166 | + && (str_starts_with((string) $t, 'trisession') || str_starts_with((string) $t, 'senssession')) |
|
| 167 | 167 | ) { |
| 168 | - if (!function_exists('session_set')) { |
|
| 169 | - include_spip('inc/session'); |
|
| 170 | - } |
|
| 171 | - $t = preg_replace(',\W,', '_', (string) $t); |
|
| 172 | - if ($v = _request($t)) { |
|
| 173 | - session_set($t, $v); |
|
| 174 | - } |
|
| 168 | + if (!function_exists('session_set')) { |
|
| 169 | + include_spip('inc/session'); |
|
| 170 | + } |
|
| 171 | + $t = preg_replace(',\W,', '_', (string) $t); |
|
| 172 | + if ($v = _request($t)) { |
|
| 173 | + session_set($t, $v); |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -181,22 +181,22 @@ discard block |
||
| 181 | 181 | * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite |
| 182 | 182 | */ |
| 183 | 183 | if (!defined('_HEADER_COMPOSED_BY')) { |
| 184 | - define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 184 | + define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP'); |
|
| 185 | 185 | } |
| 186 | 186 | if (!headers_sent() && _HEADER_COMPOSED_BY) { |
| 187 | - if (!defined('_HEADER_VARY')) { |
|
| 188 | - define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 189 | - } |
|
| 190 | - if (_HEADER_VARY) { |
|
| 191 | - header(_HEADER_VARY); |
|
| 192 | - } |
|
| 193 | - if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
|
| 194 | - include_spip('inc/filtres_mini'); |
|
| 195 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 196 | - } else { |
|
| 197 | - // header minimal |
|
| 198 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 199 | - } |
|
| 187 | + if (!defined('_HEADER_VARY')) { |
|
| 188 | + define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding'); |
|
| 189 | + } |
|
| 190 | + if (_HEADER_VARY) { |
|
| 191 | + header(_HEADER_VARY); |
|
| 192 | + } |
|
| 193 | + if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
|
| 194 | + include_spip('inc/filtres_mini'); |
|
| 195 | + header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 196 | + } else { |
|
| 197 | + // header minimal |
|
| 198 | + header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 199 | + } |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
@@ -21,22 +21,22 @@ discard block |
||
| 21 | 21 | return; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -require_once __DIR__ . '/bootstrap/config/initial.php'; |
|
| 24 | +require_once __DIR__.'/bootstrap/config/initial.php'; |
|
| 25 | 25 | |
| 26 | 26 | // inclure l'ecran de securite si il n'a pas été inclus en prepend php |
| 27 | 27 | if ( |
| 28 | 28 | !defined('_ECRAN_SECURITE') |
| 29 | - && @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php') |
|
| 29 | + && @file_exists($f = _ROOT_RACINE._NOM_PERMANENTS_INACCESSIBLES.'ecran_securite.php') |
|
| 30 | 30 | ) { |
| 31 | 31 | include $f; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // et on peut lancer l'autoloader |
| 35 | -require_once dirname(__DIR__) . '/vendor/autoload.php'; |
|
| 35 | +require_once dirname(__DIR__).'/vendor/autoload.php'; |
|
| 36 | 36 | |
| 37 | -require_once __DIR__ . '/bootstrap/config/globals.php'; |
|
| 38 | -require_once __DIR__ . '/bootstrap/proxy.php'; |
|
| 39 | -require_once __DIR__ . '/bootstrap/mitigation.php'; |
|
| 37 | +require_once __DIR__.'/bootstrap/config/globals.php'; |
|
| 38 | +require_once __DIR__.'/bootstrap/proxy.php'; |
|
| 39 | +require_once __DIR__.'/bootstrap/mitigation.php'; |
|
| 40 | 40 | |
| 41 | 41 | // numero de branche, utilise par les plugins |
| 42 | 42 | // pour specifier les versions de SPIP necessaires |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | // |
| 71 | 71 | // Charger les fonctions liees aux serveurs Http et Sql. |
| 72 | 72 | // |
| 73 | -require_once __DIR__ . '/bootstrap/functions.php'; |
|
| 73 | +require_once __DIR__.'/bootstrap/functions.php'; |
|
| 74 | 74 | |
| 75 | 75 | // Definition personnelles eventuelles |
| 76 | 76 | |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | // ===> on execute en neutralisant les messages d'erreur |
| 95 | 95 | |
| 96 | 96 | spip_initialisation_core( |
| 97 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 98 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 99 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 100 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 97 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 98 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 99 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 100 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | 103 | // chargement des plugins : doit arriver en dernier |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | include_spip('inc/lang'); |
| 154 | 154 | utiliser_langue_visiteur(); |
| 155 | 155 | include_spip('inc/minipres'); |
| 156 | - echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]); |
|
| 156 | + echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>"._T('info_travaux_texte').'</p>', ['status' => 503]); |
|
| 157 | 157 | exit; |
| 158 | 158 | } |
| 159 | 159 | // autrement c'est une install ad hoc (spikini...), on sait pas faire |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | if (!isset($GLOBALS['spip_header_silencieux']) || !$GLOBALS['spip_header_silencieux']) { |
| 194 | 194 | include_spip('inc/filtres_mini'); |
| 195 | - header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt')); |
|
| 195 | + header(_HEADER_COMPOSED_BY." $spip_version_affichee @ www.spip.net + ".url_absolue(_DIR_VAR.'config.txt')); |
|
| 196 | 196 | } else { |
| 197 | 197 | // header minimal |
| 198 | - header(_HEADER_COMPOSED_BY . ' @ www.spip.net'); |
|
| 198 | + header(_HEADER_COMPOSED_BY.' @ www.spip.net'); |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : '')); |
| 203 | -spip_log($methode . ' ' . self() . ' - ' . _FILE_CONNECT, _LOG_DEBUG); |
|
| 203 | +spip_log($methode.' '.self().' - '._FILE_CONNECT, _LOG_DEBUG); |
|
@@ -6,19 +6,19 @@ |
||
| 6 | 6 | * Ces fichiers ne peuvent pas être surchargés dans des plugins |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -include_once __DIR__ . '/inc/auth.php'; |
|
| 10 | -include_once __DIR__ . '/inc/form.php'; |
|
| 11 | -include_once __DIR__ . '/inc/initialization.php'; |
|
| 12 | -include_once __DIR__ . '/inc/i18n.php'; |
|
| 13 | -include_once __DIR__ . '/inc/jobs.php'; |
|
| 14 | -include_once __DIR__ . '/inc/loading.php'; |
|
| 15 | -include_once __DIR__ . '/inc/logging.php'; |
|
| 16 | -include_once __DIR__ . '/inc/path.php'; |
|
| 17 | -include_once __DIR__ . '/inc/pipeline.php'; |
|
| 18 | -include_once __DIR__ . '/inc/request.php'; |
|
| 19 | -include_once __DIR__ . '/inc/sanitize.php'; |
|
| 20 | -include_once __DIR__ . '/inc/templating.php'; |
|
| 21 | -include_once __DIR__ . '/inc/utils.php'; |
|
| 22 | -include_once __DIR__ . '/inc/urls.php'; |
|
| 23 | -require_once dirname(__DIR__) . '/base/connect_sql.php'; |
|
| 9 | +include_once __DIR__.'/inc/auth.php'; |
|
| 10 | +include_once __DIR__.'/inc/form.php'; |
|
| 11 | +include_once __DIR__.'/inc/initialization.php'; |
|
| 12 | +include_once __DIR__.'/inc/i18n.php'; |
|
| 13 | +include_once __DIR__.'/inc/jobs.php'; |
|
| 14 | +include_once __DIR__.'/inc/loading.php'; |
|
| 15 | +include_once __DIR__.'/inc/logging.php'; |
|
| 16 | +include_once __DIR__.'/inc/path.php'; |
|
| 17 | +include_once __DIR__.'/inc/pipeline.php'; |
|
| 18 | +include_once __DIR__.'/inc/request.php'; |
|
| 19 | +include_once __DIR__.'/inc/sanitize.php'; |
|
| 20 | +include_once __DIR__.'/inc/templating.php'; |
|
| 21 | +include_once __DIR__.'/inc/utils.php'; |
|
| 22 | +include_once __DIR__.'/inc/urls.php'; |
|
| 23 | +require_once dirname(__DIR__).'/base/connect_sql.php'; |
|
| 24 | 24 | |
@@ -4,18 +4,18 @@ |
||
| 4 | 4 | * Détecteur de robot d'indexation |
| 5 | 5 | */ |
| 6 | 6 | if (!defined('_IS_BOT')) { |
| 7 | - define( |
|
| 8 | - '_IS_BOT', |
|
| 9 | - isset($_SERVER['HTTP_USER_AGENT']) |
|
| 10 | - && preg_match( |
|
| 11 | - // mots generiques |
|
| 12 | - ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 13 | - // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 14 | - . 'MSIE 6\.0|' |
|
| 15 | - // UA plus cibles |
|
| 16 | - . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 17 | - . ',i', |
|
| 18 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 19 | - ) |
|
| 20 | - ); |
|
| 7 | + define( |
|
| 8 | + '_IS_BOT', |
|
| 9 | + isset($_SERVER['HTTP_USER_AGENT']) |
|
| 10 | + && preg_match( |
|
| 11 | + // mots generiques |
|
| 12 | + ',bot|slurp|crawler|spider|webvac|yandex|' |
|
| 13 | + // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot |
|
| 14 | + . 'MSIE 6\.0|' |
|
| 15 | + // UA plus cibles |
|
| 16 | + . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
|
| 17 | + . ',i', |
|
| 18 | + (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 19 | + ) |
|
| 20 | + ); |
|
| 21 | 21 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | // UA plus cibles |
| 16 | 16 | . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti' |
| 17 | 17 | . ',i', |
| 18 | - (string)$_SERVER['HTTP_USER_AGENT'] |
|
| 18 | + (string) $_SERVER['HTTP_USER_AGENT'] |
|
| 19 | 19 | ) |
| 20 | 20 | ); |
| 21 | 21 | } |
@@ -8,48 +8,48 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
| 11 | - if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 12 | - $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 13 | - } |
|
| 14 | - if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 15 | - $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 16 | - } |
|
| 11 | + if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
|
| 12 | + $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST']; |
|
| 13 | + } |
|
| 14 | + if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 15 | + $_SERVER['HTTP_X_FORWARDED_PORT'] = 443; |
|
| 16 | + } |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { |
| 20 | - if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) && is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 21 | - $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 22 | - if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 23 | - $_SERVER['HTTPS'] = 'on'; |
|
| 24 | - if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 25 | - $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 26 | - } |
|
| 27 | - } |
|
| 28 | - } |
|
| 29 | - $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 30 | - if (str_contains((string) $host, ',')) { |
|
| 31 | - $h = explode(',', (string) $host); |
|
| 32 | - $host = trim(reset($h)); |
|
| 33 | - } |
|
| 34 | - // securite sur le contenu de l'entete |
|
| 35 | - $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 36 | - $_SERVER['HTTP_HOST'] = $host; |
|
| 20 | + if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) && is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) { |
|
| 21 | + $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT']; |
|
| 22 | + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
| 23 | + $_SERVER['HTTPS'] = 'on'; |
|
| 24 | + if (isset($_SERVER['REQUEST_SCHEME'])) { |
|
| 25 | + $_SERVER['REQUEST_SCHEME'] = 'https'; |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; |
|
| 30 | + if (str_contains((string) $host, ',')) { |
|
| 31 | + $h = explode(',', (string) $host); |
|
| 32 | + $host = trim(reset($h)); |
|
| 33 | + } |
|
| 34 | + // securite sur le contenu de l'entete |
|
| 35 | + $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________'); |
|
| 36 | + $_SERVER['HTTP_HOST'] = $host; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // |
| 40 | 40 | // On note le numero IP du client dans la variable $ip |
| 41 | 41 | // |
| 42 | 42 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 43 | - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 44 | - if (str_contains((string) $ip, ',')) { |
|
| 45 | - $ip = explode(',', (string) $ip); |
|
| 46 | - $ip = reset($ip); |
|
| 47 | - } |
|
| 48 | - // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 49 | - if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 50 | - $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 51 | - } |
|
| 43 | + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
| 44 | + if (str_contains((string) $ip, ',')) { |
|
| 45 | + $ip = explode(',', (string) $ip); |
|
| 46 | + $ip = reset($ip); |
|
| 47 | + } |
|
| 48 | + // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost |
|
| 49 | + if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] === '127.0.0.1') { |
|
| 50 | + $_SERVER['REMOTE_ADDR'] = $ip; |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | if (isset($_SERVER['REMOTE_ADDR'])) { |
| 54 | - $ip = $_SERVER['REMOTE_ADDR']; |
|
| 54 | + $ip = $_SERVER['REMOTE_ADDR']; |
|
| 55 | 55 | } |
@@ -28,52 +28,52 @@ discard block |
||
| 28 | 28 | * texte |
| 29 | 29 | */ |
| 30 | 30 | function _T($texte, $args = [], $options = []) { |
| 31 | - static $traduire = false; |
|
| 32 | - $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 33 | - if ($options) { |
|
| 34 | - // support de l'ancien argument $class |
|
| 35 | - if (is_string($options)) { |
|
| 36 | - $options = ['class' => $options]; |
|
| 37 | - } |
|
| 38 | - $o = array_merge($o, $options); |
|
| 39 | - } |
|
| 31 | + static $traduire = false; |
|
| 32 | + $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 33 | + if ($options) { |
|
| 34 | + // support de l'ancien argument $class |
|
| 35 | + if (is_string($options)) { |
|
| 36 | + $options = ['class' => $options]; |
|
| 37 | + } |
|
| 38 | + $o = array_merge($o, $options); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - if (!$traduire) { |
|
| 42 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 43 | - include_spip('inc/lang'); |
|
| 44 | - } |
|
| 41 | + if (!$traduire) { |
|
| 42 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 43 | + include_spip('inc/lang'); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // On peut passer explicitement la langue dans le tableau |
|
| 47 | - // On utilise le même nom de variable que la globale |
|
| 48 | - if (isset($args['spip_lang'])) { |
|
| 49 | - $lang = $args['spip_lang']; |
|
| 50 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 51 | - unset($args['spip_lang']); |
|
| 52 | - } // Sinon on prend la langue du contexte |
|
| 53 | - else { |
|
| 54 | - $lang = $GLOBALS['spip_lang']; |
|
| 55 | - } |
|
| 56 | - $text = $traduire($texte, $lang); |
|
| 46 | + // On peut passer explicitement la langue dans le tableau |
|
| 47 | + // On utilise le même nom de variable que la globale |
|
| 48 | + if (isset($args['spip_lang'])) { |
|
| 49 | + $lang = $args['spip_lang']; |
|
| 50 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 51 | + unset($args['spip_lang']); |
|
| 52 | + } // Sinon on prend la langue du contexte |
|
| 53 | + else { |
|
| 54 | + $lang = $GLOBALS['spip_lang']; |
|
| 55 | + } |
|
| 56 | + $text = $traduire($texte, $lang); |
|
| 57 | 57 | |
| 58 | - if ($text === null || !strlen($text)) { |
|
| 59 | - if (!$o['force']) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 58 | + if ($text === null || !strlen($text)) { |
|
| 59 | + if (!$o['force']) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $text = $texte; |
|
| 63 | + $text = $texte; |
|
| 64 | 64 | |
| 65 | - // pour les chaines non traduites, assurer un service minimum |
|
| 66 | - if (!$GLOBALS['test_i18n'] && _request('var_mode') != 'traduction') { |
|
| 67 | - $n = strpos($text, ':'); |
|
| 68 | - if ($n !== false) { |
|
| 69 | - $text = substr($text, $n + 1); |
|
| 70 | - } |
|
| 71 | - $text = str_replace('_', ' ', $text); |
|
| 72 | - } |
|
| 73 | - $o['class'] = null; |
|
| 74 | - } |
|
| 65 | + // pour les chaines non traduites, assurer un service minimum |
|
| 66 | + if (!$GLOBALS['test_i18n'] && _request('var_mode') != 'traduction') { |
|
| 67 | + $n = strpos($text, ':'); |
|
| 68 | + if ($n !== false) { |
|
| 69 | + $text = substr($text, $n + 1); |
|
| 70 | + } |
|
| 71 | + $text = str_replace('_', ' ', $text); |
|
| 72 | + } |
|
| 73 | + $o['class'] = null; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return _L($text, $args, $o); |
|
| 76 | + return _L($text, $args, $o); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
@@ -100,53 +100,53 @@ discard block |
||
| 100 | 100 | * texte |
| 101 | 101 | */ |
| 102 | 102 | function _L($text, $args = [], $options = []) { |
| 103 | - $f = $text; |
|
| 104 | - $defaut_options = [ |
|
| 105 | - 'class' => null, |
|
| 106 | - 'sanitize' => true, |
|
| 107 | - ]; |
|
| 108 | - // support de l'ancien argument $class |
|
| 109 | - if ($options && is_string($options)) { |
|
| 110 | - $options = ['class' => $options]; |
|
| 111 | - } |
|
| 112 | - if (is_array($options)) { |
|
| 113 | - $options += $defaut_options; |
|
| 114 | - } else { |
|
| 115 | - $options = $defaut_options; |
|
| 116 | - } |
|
| 103 | + $f = $text; |
|
| 104 | + $defaut_options = [ |
|
| 105 | + 'class' => null, |
|
| 106 | + 'sanitize' => true, |
|
| 107 | + ]; |
|
| 108 | + // support de l'ancien argument $class |
|
| 109 | + if ($options && is_string($options)) { |
|
| 110 | + $options = ['class' => $options]; |
|
| 111 | + } |
|
| 112 | + if (is_array($options)) { |
|
| 113 | + $options += $defaut_options; |
|
| 114 | + } else { |
|
| 115 | + $options = $defaut_options; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - if (is_array($args) && count($args)) { |
|
| 119 | - if (!function_exists('interdire_scripts')) { |
|
| 120 | - include_spip('inc/texte'); |
|
| 121 | - } |
|
| 122 | - if (!function_exists('echapper_html_suspect')) { |
|
| 123 | - include_spip('inc/texte_mini'); |
|
| 124 | - } |
|
| 125 | - foreach ($args as $name => $value) { |
|
| 126 | - if (str_contains($text, (string) "@$name@")) { |
|
| 127 | - if ($options['sanitize']) { |
|
| 128 | - $value = echapper_html_suspect($value); |
|
| 129 | - $value = interdire_scripts($value, -1); |
|
| 130 | - } |
|
| 131 | - if (!empty($options['class'])) { |
|
| 132 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 133 | - } |
|
| 134 | - $text = str_replace("@$name@", (string) $value, (string) $text); |
|
| 135 | - unset($args[$name]); |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 139 | - // (chaines de langues pas a jour) |
|
| 140 | - if ($args) { |
|
| 141 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 142 | - } |
|
| 143 | - } |
|
| 118 | + if (is_array($args) && count($args)) { |
|
| 119 | + if (!function_exists('interdire_scripts')) { |
|
| 120 | + include_spip('inc/texte'); |
|
| 121 | + } |
|
| 122 | + if (!function_exists('echapper_html_suspect')) { |
|
| 123 | + include_spip('inc/texte_mini'); |
|
| 124 | + } |
|
| 125 | + foreach ($args as $name => $value) { |
|
| 126 | + if (str_contains($text, (string) "@$name@")) { |
|
| 127 | + if ($options['sanitize']) { |
|
| 128 | + $value = echapper_html_suspect($value); |
|
| 129 | + $value = interdire_scripts($value, -1); |
|
| 130 | + } |
|
| 131 | + if (!empty($options['class'])) { |
|
| 132 | + $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 133 | + } |
|
| 134 | + $text = str_replace("@$name@", (string) $value, (string) $text); |
|
| 135 | + unset($args[$name]); |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 139 | + // (chaines de langues pas a jour) |
|
| 140 | + if ($args) { |
|
| 141 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if (($GLOBALS['test_i18n'] || _request('var_mode') == 'traduction') && is_null($options['class'])) { |
|
| 146 | - return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 147 | - } else { |
|
| 148 | - return $text; |
|
| 149 | - } |
|
| 145 | + if (($GLOBALS['test_i18n'] || _request('var_mode') == 'traduction') && is_null($options['class'])) { |
|
| 146 | + return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 147 | + } else { |
|
| 148 | + return $text; |
|
| 149 | + } |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
@@ -169,19 +169,19 @@ discard block |
||
| 169 | 169 | * - string Langue utilisée. |
| 170 | 170 | **/ |
| 171 | 171 | function lang_select($lang = null) { |
| 172 | - static $pile_langues = []; |
|
| 173 | - if (!function_exists('changer_langue')) { |
|
| 174 | - include_spip('inc/lang'); |
|
| 175 | - } |
|
| 176 | - if ($lang === null) { |
|
| 177 | - $lang = array_pop($pile_langues); |
|
| 178 | - } else { |
|
| 179 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 180 | - } |
|
| 181 | - if (isset($GLOBALS['spip_lang']) && $lang == $GLOBALS['spip_lang']) { |
|
| 182 | - return $lang; |
|
| 183 | - } |
|
| 184 | - changer_langue($lang); |
|
| 172 | + static $pile_langues = []; |
|
| 173 | + if (!function_exists('changer_langue')) { |
|
| 174 | + include_spip('inc/lang'); |
|
| 175 | + } |
|
| 176 | + if ($lang === null) { |
|
| 177 | + $lang = array_pop($pile_langues); |
|
| 178 | + } else { |
|
| 179 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 180 | + } |
|
| 181 | + if (isset($GLOBALS['spip_lang']) && $lang == $GLOBALS['spip_lang']) { |
|
| 182 | + return $lang; |
|
| 183 | + } |
|
| 184 | + changer_langue($lang); |
|
| 185 | 185 | |
| 186 | - return $lang; |
|
| 186 | + return $lang; |
|
| 187 | 187 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $value = interdire_scripts($value, -1); |
| 130 | 130 | } |
| 131 | 131 | if (!empty($options['class'])) { |
| 132 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 132 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 133 | 133 | } |
| 134 | 134 | $text = str_replace("@$name@", (string) $value, (string) $text); |
| 135 | 135 | unset($args[$name]); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | // Si des variables n'ont pas ete inserees, le signaler |
| 139 | 139 | // (chaines de langues pas a jour) |
| 140 | 140 | if ($args) { |
| 141 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 141 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | * - string si $message à false. |
| 19 | 19 | **/ |
| 20 | 20 | function erreur_squelette($message = '', $lieu = '') { |
| 21 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 22 | - if (is_array($lieu)) { |
|
| 23 | - include_spip('public/compiler'); |
|
| 24 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 25 | - } |
|
| 21 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 22 | + if (is_array($lieu)) { |
|
| 23 | + include_spip('public/compiler'); |
|
| 24 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - return $debusquer($message, $lieu); |
|
| 27 | + return $debusquer($message, $lieu); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -61,106 +61,106 @@ discard block |
||
| 61 | 61 | * - ou tableau d'information sur le squelette. |
| 62 | 62 | */ |
| 63 | 63 | function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') { |
| 64 | - if (!function_exists('evaluer_fond')) { |
|
| 65 | - include_spip('public/assembler'); |
|
| 66 | - } |
|
| 67 | - // assurer la compat avec l'ancienne syntaxe |
|
| 68 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 69 | - if (!is_array($options)) { |
|
| 70 | - $options = ['trim' => $options]; |
|
| 71 | - } |
|
| 72 | - if (!isset($options['trim'])) { |
|
| 73 | - $options['trim'] = true; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - if (isset($contexte['connect'])) { |
|
| 77 | - $connect = $contexte['connect']; |
|
| 78 | - unset($contexte['connect']); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - $texte = ''; |
|
| 82 | - $pages = []; |
|
| 83 | - $lang_select = ''; |
|
| 84 | - if (!isset($options['etoile']) || !$options['etoile']) { |
|
| 85 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 86 | - if (!isset($contexte['lang'])) { |
|
| 87 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 91 | - $lang_select = lang_select($contexte['lang']); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 96 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 100 | - |
|
| 101 | - // fix #4235 |
|
| 102 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 106 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 107 | - |
|
| 108 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 109 | - if ($page === '') { |
|
| 110 | - $c = $options['compil'] ?? ''; |
|
| 111 | - $a = ['fichier' => $f]; |
|
| 112 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 113 | - erreur_squelette($erreur, $c); |
|
| 114 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 115 | - $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $page = pipeline('recuperer_fond', [ |
|
| 119 | - 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 120 | - 'data' => $page |
|
| 121 | - ]); |
|
| 122 | - if (isset($options['ajax']) && $options['ajax']) { |
|
| 123 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 124 | - include_spip('inc/filtres'); |
|
| 125 | - } |
|
| 126 | - $page['texte'] = encoder_contexte_ajax( |
|
| 127 | - array_merge( |
|
| 128 | - $contexte, |
|
| 129 | - ['fond' => $f], |
|
| 130 | - ($connect ? ['connect' => $connect] : []) |
|
| 131 | - ), |
|
| 132 | - '', |
|
| 133 | - $page['texte'], |
|
| 134 | - $options['ajax'] |
|
| 135 | - ); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if (isset($options['raw']) && $options['raw']) { |
|
| 139 | - $pages[] = $page; |
|
| 140 | - } else { |
|
| 141 | - $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte']; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 145 | - if (isset($page['invalideurs']['session'])) { |
|
| 146 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - // restaurer le sessionnement du contexte appelant, |
|
| 151 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 152 | - if (isset($cache_utilise_session_appelant)) { |
|
| 153 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 157 | - |
|
| 158 | - if ($lang_select) { |
|
| 159 | - lang_select(); |
|
| 160 | - } |
|
| 161 | - if (isset($options['raw']) && $options['raw']) { |
|
| 162 | - return is_array($fond) ? $pages : reset($pages); |
|
| 163 | - } else { |
|
| 164 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 165 | - } |
|
| 64 | + if (!function_exists('evaluer_fond')) { |
|
| 65 | + include_spip('public/assembler'); |
|
| 66 | + } |
|
| 67 | + // assurer la compat avec l'ancienne syntaxe |
|
| 68 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 69 | + if (!is_array($options)) { |
|
| 70 | + $options = ['trim' => $options]; |
|
| 71 | + } |
|
| 72 | + if (!isset($options['trim'])) { |
|
| 73 | + $options['trim'] = true; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + if (isset($contexte['connect'])) { |
|
| 77 | + $connect = $contexte['connect']; |
|
| 78 | + unset($contexte['connect']); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + $texte = ''; |
|
| 82 | + $pages = []; |
|
| 83 | + $lang_select = ''; |
|
| 84 | + if (!isset($options['etoile']) || !$options['etoile']) { |
|
| 85 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 86 | + if (!isset($contexte['lang'])) { |
|
| 87 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 91 | + $lang_select = lang_select($contexte['lang']); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 96 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 100 | + |
|
| 101 | + // fix #4235 |
|
| 102 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 106 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 107 | + |
|
| 108 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 109 | + if ($page === '') { |
|
| 110 | + $c = $options['compil'] ?? ''; |
|
| 111 | + $a = ['fichier' => $f]; |
|
| 112 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 113 | + erreur_squelette($erreur, $c); |
|
| 114 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 115 | + $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + $page = pipeline('recuperer_fond', [ |
|
| 119 | + 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 120 | + 'data' => $page |
|
| 121 | + ]); |
|
| 122 | + if (isset($options['ajax']) && $options['ajax']) { |
|
| 123 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 124 | + include_spip('inc/filtres'); |
|
| 125 | + } |
|
| 126 | + $page['texte'] = encoder_contexte_ajax( |
|
| 127 | + array_merge( |
|
| 128 | + $contexte, |
|
| 129 | + ['fond' => $f], |
|
| 130 | + ($connect ? ['connect' => $connect] : []) |
|
| 131 | + ), |
|
| 132 | + '', |
|
| 133 | + $page['texte'], |
|
| 134 | + $options['ajax'] |
|
| 135 | + ); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if (isset($options['raw']) && $options['raw']) { |
|
| 139 | + $pages[] = $page; |
|
| 140 | + } else { |
|
| 141 | + $texte .= $options['trim'] ? rtrim($page['texte'] ?? '') : $page['texte']; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 145 | + if (isset($page['invalideurs']['session'])) { |
|
| 146 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + // restaurer le sessionnement du contexte appelant, |
|
| 151 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 152 | + if (isset($cache_utilise_session_appelant)) { |
|
| 153 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 157 | + |
|
| 158 | + if ($lang_select) { |
|
| 159 | + lang_select(); |
|
| 160 | + } |
|
| 161 | + if (isset($options['raw']) && $options['raw']) { |
|
| 162 | + return is_array($fond) ? $pages : reset($pages); |
|
| 163 | + } else { |
|
| 164 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 165 | + } |
|
| 166 | 166 | } |
@@ -99,11 +99,11 @@ |
||
| 99 | 99 | $GLOBALS['_INC_PUBLIC']++; |
| 100 | 100 | |
| 101 | 101 | // fix #4235 |
| 102 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 102 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | foreach (is_array($fond) ? $fond : [$fond] as $f) { |
| 106 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 106 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 107 | 107 | |
| 108 | 108 | $page = evaluer_fond($f, $contexte, $connect); |
| 109 | 109 | if ($page === '') { |
@@ -27,71 +27,71 @@ discard block |
||
| 27 | 27 | * Nom de la fonction, ou false. |
| 28 | 28 | */ |
| 29 | 29 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 30 | - static $echecs = []; |
|
| 31 | - |
|
| 32 | - if (strlen($dossier) && !str_ends_with($dossier, '/')) { |
|
| 33 | - $dossier .= '/'; |
|
| 34 | - } |
|
| 35 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 36 | - |
|
| 37 | - if (function_exists($f)) { |
|
| 38 | - return $f; |
|
| 39 | - } |
|
| 40 | - if (function_exists($g = $f . '_dist')) { |
|
| 41 | - return $g; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - if (isset($echecs[$f])) { |
|
| 45 | - return $echecs[$f]; |
|
| 46 | - } |
|
| 47 | - // Sinon charger le fichier de declaration si plausible |
|
| 48 | - |
|
| 49 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 50 | - if ($continue) { |
|
| 51 | - return false; |
|
| 52 | - } //appel interne, on passe |
|
| 53 | - include_spip('inc/minipres'); |
|
| 54 | - echo minipres(); |
|
| 55 | - exit; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - // passer en minuscules (cf les balises de formulaires) |
|
| 59 | - // et inclure le fichier |
|
| 60 | - if ( |
|
| 61 | - !($inc = include_spip($dossier . ($d = strtolower($nom)))) |
|
| 62 | - && strlen(dirname($dossier)) |
|
| 63 | - && dirname($dossier) != '.' |
|
| 64 | - ) { |
|
| 65 | - include_spip(substr($dossier, 0, -1)); |
|
| 66 | - } |
|
| 67 | - if (function_exists($f)) { |
|
| 68 | - return $f; |
|
| 69 | - } |
|
| 70 | - if (function_exists($g)) { |
|
| 71 | - return $g; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if ($continue) { |
|
| 75 | - return $echecs[$f] = false; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // Echec : message d'erreur |
|
| 79 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 80 | - ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 81 | - |
|
| 82 | - include_spip('inc/minipres'); |
|
| 83 | - include_spip('inc/filtres_mini'); |
|
| 84 | - echo minipres( |
|
| 85 | - _T('forum_titre_erreur'), |
|
| 86 | - $inc ? |
|
| 87 | - _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 88 | - . '<br />' |
|
| 89 | - . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 90 | - : |
|
| 91 | - _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 92 | - ['all_inline' => true,'status' => 404] |
|
| 93 | - ); |
|
| 94 | - exit; |
|
| 30 | + static $echecs = []; |
|
| 31 | + |
|
| 32 | + if (strlen($dossier) && !str_ends_with($dossier, '/')) { |
|
| 33 | + $dossier .= '/'; |
|
| 34 | + } |
|
| 35 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 36 | + |
|
| 37 | + if (function_exists($f)) { |
|
| 38 | + return $f; |
|
| 39 | + } |
|
| 40 | + if (function_exists($g = $f . '_dist')) { |
|
| 41 | + return $g; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + if (isset($echecs[$f])) { |
|
| 45 | + return $echecs[$f]; |
|
| 46 | + } |
|
| 47 | + // Sinon charger le fichier de declaration si plausible |
|
| 48 | + |
|
| 49 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 50 | + if ($continue) { |
|
| 51 | + return false; |
|
| 52 | + } //appel interne, on passe |
|
| 53 | + include_spip('inc/minipres'); |
|
| 54 | + echo minipres(); |
|
| 55 | + exit; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + // passer en minuscules (cf les balises de formulaires) |
|
| 59 | + // et inclure le fichier |
|
| 60 | + if ( |
|
| 61 | + !($inc = include_spip($dossier . ($d = strtolower($nom)))) |
|
| 62 | + && strlen(dirname($dossier)) |
|
| 63 | + && dirname($dossier) != '.' |
|
| 64 | + ) { |
|
| 65 | + include_spip(substr($dossier, 0, -1)); |
|
| 66 | + } |
|
| 67 | + if (function_exists($f)) { |
|
| 68 | + return $f; |
|
| 69 | + } |
|
| 70 | + if (function_exists($g)) { |
|
| 71 | + return $g; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if ($continue) { |
|
| 75 | + return $echecs[$f] = false; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // Echec : message d'erreur |
|
| 79 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 80 | + ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 81 | + |
|
| 82 | + include_spip('inc/minipres'); |
|
| 83 | + include_spip('inc/filtres_mini'); |
|
| 84 | + echo minipres( |
|
| 85 | + _T('forum_titre_erreur'), |
|
| 86 | + $inc ? |
|
| 87 | + _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 88 | + . '<br />' |
|
| 89 | + . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 90 | + : |
|
| 91 | + _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 92 | + ['all_inline' => true,'status' => 404] |
|
| 93 | + ); |
|
| 94 | + exit; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | * @return bool |
| 102 | 102 | */ |
| 103 | 103 | function include_once_check($file) { |
| 104 | - if (file_exists($file)) { |
|
| 105 | - include_once $file; |
|
| 104 | + if (file_exists($file)) { |
|
| 105 | + include_once $file; |
|
| 106 | 106 | |
| 107 | - return true; |
|
| 108 | - } |
|
| 109 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 110 | - $crash = ($crash ?: []); |
|
| 111 | - $crash[$file] = true; |
|
| 112 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 107 | + return true; |
|
| 108 | + } |
|
| 109 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 110 | + $crash = ($crash ?: []); |
|
| 111 | + $crash[$file] = true; |
|
| 112 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 113 | 113 | |
| 114 | - return false; |
|
| 114 | + return false; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * - string : chemin du fichier trouvé |
| 136 | 136 | **/ |
| 137 | 137 | function include_spip($f, $include = true) { |
| 138 | - return find_in_path($f . '.php', '', $include); |
|
| 138 | + return find_in_path($f . '.php', '', $include); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * - string : chemin du fichier trouvé |
| 156 | 156 | **/ |
| 157 | 157 | function require_spip($f) { |
| 158 | - return find_in_path($f . '.php', '', 'required'); |
|
| 158 | + return find_in_path($f . '.php', '', 'required'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -165,27 +165,27 @@ discard block |
||
| 165 | 165 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 166 | 166 | */ |
| 167 | 167 | function include_fichiers_fonctions() { |
| 168 | - static $done = false; |
|
| 169 | - if (!$done) { |
|
| 170 | - include_spip('inc/lang'); |
|
| 171 | - |
|
| 172 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 173 | - // donc il faut l'inclure "en globals" |
|
| 174 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 175 | - global $dossier_squelettes; |
|
| 176 | - include_once(_ROOT_CWD . $f); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 180 | - // chargement optimise precompile |
|
| 181 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 182 | - } |
|
| 183 | - if (test_espace_prive()) { |
|
| 184 | - include_spip('inc/filtres_ecrire'); |
|
| 185 | - } |
|
| 186 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 187 | - $done = true; |
|
| 188 | - } |
|
| 168 | + static $done = false; |
|
| 169 | + if (!$done) { |
|
| 170 | + include_spip('inc/lang'); |
|
| 171 | + |
|
| 172 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 173 | + // donc il faut l'inclure "en globals" |
|
| 174 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 175 | + global $dossier_squelettes; |
|
| 176 | + include_once(_ROOT_CWD . $f); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 180 | + // chargement optimise precompile |
|
| 181 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 182 | + } |
|
| 183 | + if (test_espace_prive()) { |
|
| 184 | + include_spip('inc/filtres_ecrire'); |
|
| 185 | + } |
|
| 186 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 187 | + $done = true; |
|
| 188 | + } |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -198,59 +198,59 @@ discard block |
||
| 198 | 198 | * @return string |
| 199 | 199 | */ |
| 200 | 200 | function charger_fonction_url(string $quoi, string $type = '') { |
| 201 | - if ($type === 'defaut') { |
|
| 202 | - $objet = objet_type($quoi); |
|
| 203 | - if ( |
|
| 204 | - ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)) |
|
| 205 | - || ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated |
|
| 206 | - ) { |
|
| 207 | - return $f; |
|
| 208 | - } |
|
| 209 | - return ''; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $url_type = $type; |
|
| 213 | - if (!$url_type) { |
|
| 214 | - $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - // inclure le module d'url |
|
| 218 | - include_spip('urls/' . $url_type); |
|
| 219 | - |
|
| 220 | - switch ($quoi) { |
|
| 221 | - case 'page': |
|
| 222 | - if ( |
|
| 223 | - function_exists($f = "urls_{$url_type}_generer_url_page") |
|
| 224 | - || function_exists($f .= '_dist') |
|
| 225 | - // ou une fonction custom utilisateur independante du type d'url |
|
| 226 | - || function_exists($f = 'generer_url_page') |
|
| 227 | - || function_exists($f .= '_dist') |
|
| 228 | - ) { |
|
| 229 | - return $f; |
|
| 230 | - } |
|
| 231 | - // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 232 | - return ''; |
|
| 233 | - case 'objet': |
|
| 234 | - case 'decoder': |
|
| 235 | - default: |
|
| 236 | - $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 237 | - if ( |
|
| 238 | - function_exists($f = "urls_{$url_type}_{$fquoi}") |
|
| 239 | - || function_exists($f .= '_dist') |
|
| 240 | - ) { |
|
| 241 | - return $f; |
|
| 242 | - } |
|
| 243 | - // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 244 | - // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 245 | - if ($f = charger_fonction($url_type, 'urls', true)) { |
|
| 246 | - return $f; |
|
| 247 | - } |
|
| 248 | - // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement |
|
| 249 | - if (!$type && $url_type !== 'page') { |
|
| 250 | - return charger_fonction_url($quoi, 'page'); |
|
| 251 | - } |
|
| 252 | - return ''; |
|
| 253 | - } |
|
| 201 | + if ($type === 'defaut') { |
|
| 202 | + $objet = objet_type($quoi); |
|
| 203 | + if ( |
|
| 204 | + ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)) |
|
| 205 | + || ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated |
|
| 206 | + ) { |
|
| 207 | + return $f; |
|
| 208 | + } |
|
| 209 | + return ''; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $url_type = $type; |
|
| 213 | + if (!$url_type) { |
|
| 214 | + $url_type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + // inclure le module d'url |
|
| 218 | + include_spip('urls/' . $url_type); |
|
| 219 | + |
|
| 220 | + switch ($quoi) { |
|
| 221 | + case 'page': |
|
| 222 | + if ( |
|
| 223 | + function_exists($f = "urls_{$url_type}_generer_url_page") |
|
| 224 | + || function_exists($f .= '_dist') |
|
| 225 | + // ou une fonction custom utilisateur independante du type d'url |
|
| 226 | + || function_exists($f = 'generer_url_page') |
|
| 227 | + || function_exists($f .= '_dist') |
|
| 228 | + ) { |
|
| 229 | + return $f; |
|
| 230 | + } |
|
| 231 | + // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 232 | + return ''; |
|
| 233 | + case 'objet': |
|
| 234 | + case 'decoder': |
|
| 235 | + default: |
|
| 236 | + $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 237 | + if ( |
|
| 238 | + function_exists($f = "urls_{$url_type}_{$fquoi}") |
|
| 239 | + || function_exists($f .= '_dist') |
|
| 240 | + ) { |
|
| 241 | + return $f; |
|
| 242 | + } |
|
| 243 | + // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 244 | + // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 245 | + if ($f = charger_fonction($url_type, 'urls', true)) { |
|
| 246 | + return $f; |
|
| 247 | + } |
|
| 248 | + // sinon on se rabat sur les urls page si ce n'est pas un type demande explicitement |
|
| 249 | + if (!$type && $url_type !== 'page') { |
|
| 250 | + return charger_fonction_url($quoi, 'page'); |
|
| 251 | + } |
|
| 252 | + return ''; |
|
| 253 | + } |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @return string |
| 262 | 262 | */ |
| 263 | 263 | function trouve_modele($nom) { |
| 264 | - return trouver_fond($nom, 'modeles/'); |
|
| 264 | + return trouver_fond($nom, 'modeles/'); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -277,21 +277,21 @@ discard block |
||
| 277 | 277 | * @return array|string |
| 278 | 278 | */ |
| 279 | 279 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 280 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 281 | - if (!$pathinfo) { |
|
| 282 | - return $f; |
|
| 283 | - } |
|
| 284 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 285 | - $p = pathinfo($f); |
|
| 286 | - if (!isset($p['extension']) || !$p['extension']) { |
|
| 287 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 288 | - } |
|
| 289 | - if (!isset($p['extension']) || !$p['filename']) { |
|
| 290 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 291 | - } |
|
| 292 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 293 | - |
|
| 294 | - return $p; |
|
| 280 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 281 | + if (!$pathinfo) { |
|
| 282 | + return $f; |
|
| 283 | + } |
|
| 284 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 285 | + $p = pathinfo($f); |
|
| 286 | + if (!isset($p['extension']) || !$p['extension']) { |
|
| 287 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 288 | + } |
|
| 289 | + if (!isset($p['extension']) || !$p['filename']) { |
|
| 290 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 291 | + } |
|
| 292 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 293 | + |
|
| 294 | + return $p; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | * Lien sur une icone d'aide |
| 310 | 310 | **/ |
| 311 | 311 | function aider($aide = '', $distante = false) { |
| 312 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 312 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 313 | 313 | |
| 314 | - return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 314 | + return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | * Nom de l'exec, sinon chaîne vide. |
| 333 | 333 | **/ |
| 334 | 334 | function tester_url_ecrire($nom) { |
| 335 | - static $exec = []; |
|
| 336 | - if (isset($exec[$nom])) { |
|
| 337 | - return $exec[$nom]; |
|
| 338 | - } |
|
| 339 | - // tester si c'est une page en squelette |
|
| 340 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 341 | - return $exec[$nom] = 'fond'; |
|
| 342 | - } // echafaudage d'un fond ! |
|
| 343 | - elseif (include_spip('public/styliser_par_z') && z_echafaudable($nom)) { |
|
| 344 | - return $exec[$nom] = 'fond'; |
|
| 345 | - } |
|
| 346 | - // attention, il ne faut pas inclure l'exec ici |
|
| 347 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 348 | - // et des define intrusifs potentiels |
|
| 349 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') || charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 335 | + static $exec = []; |
|
| 336 | + if (isset($exec[$nom])) { |
|
| 337 | + return $exec[$nom]; |
|
| 338 | + } |
|
| 339 | + // tester si c'est une page en squelette |
|
| 340 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 341 | + return $exec[$nom] = 'fond'; |
|
| 342 | + } // echafaudage d'un fond ! |
|
| 343 | + elseif (include_spip('public/styliser_par_z') && z_echafaudable($nom)) { |
|
| 344 | + return $exec[$nom] = 'fond'; |
|
| 345 | + } |
|
| 346 | + // attention, il ne faut pas inclure l'exec ici |
|
| 347 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 348 | + // et des define intrusifs potentiels |
|
| 349 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') || charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 350 | 350 | } |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | if (strlen($dossier) && !str_ends_with($dossier, '/')) { |
| 33 | 33 | $dossier .= '/'; |
| 34 | 34 | } |
| 35 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 35 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 36 | 36 | |
| 37 | 37 | if (function_exists($f)) { |
| 38 | 38 | return $f; |
| 39 | 39 | } |
| 40 | - if (function_exists($g = $f . '_dist')) { |
|
| 40 | + if (function_exists($g = $f.'_dist')) { |
|
| 41 | 41 | return $g; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | // passer en minuscules (cf les balises de formulaires) |
| 59 | 59 | // et inclure le fichier |
| 60 | 60 | if ( |
| 61 | - !($inc = include_spip($dossier . ($d = strtolower($nom)))) |
|
| 61 | + !($inc = include_spip($dossier.($d = strtolower($nom)))) |
|
| 62 | 62 | && strlen(dirname($dossier)) |
| 63 | 63 | && dirname($dossier) != '.' |
| 64 | 64 | ) { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Echec : message d'erreur |
| 79 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 79 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 80 | 80 | ($inc ? '' : " (fichier $d absent de $dossier)")); |
| 81 | 81 | |
| 82 | 82 | include_spip('inc/minipres'); |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | echo minipres( |
| 85 | 85 | _T('forum_titre_erreur'), |
| 86 | 86 | $inc ? |
| 87 | - _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($f) . '</code>']) |
|
| 87 | + _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($f).'</code>']) |
|
| 88 | 88 | . '<br />' |
| 89 | - . _T('fonction_introuvable', ['fonction' => '<code>' . spip_htmlentities($g) . '</code>']) |
|
| 89 | + . _T('fonction_introuvable', ['fonction' => '<code>'.spip_htmlentities($g).'</code>']) |
|
| 90 | 90 | : |
| 91 | - _T('fichier_introuvable', ['fichier' => '<code>' . spip_htmlentities($d) . '</code>']), |
|
| 92 | - ['all_inline' => true,'status' => 404] |
|
| 91 | + _T('fichier_introuvable', ['fichier' => '<code>'.spip_htmlentities($d).'</code>']), |
|
| 92 | + ['all_inline' => true, 'status' => 404] |
|
| 93 | 93 | ); |
| 94 | 94 | exit; |
| 95 | 95 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * - string : chemin du fichier trouvé |
| 136 | 136 | **/ |
| 137 | 137 | function include_spip($f, $include = true) { |
| 138 | - return find_in_path($f . '.php', '', $include); |
|
| 138 | + return find_in_path($f.'.php', '', $include); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * - string : chemin du fichier trouvé |
| 156 | 156 | **/ |
| 157 | 157 | function require_spip($f) { |
| 158 | - return find_in_path($f . '.php', '', 'required'); |
|
| 158 | + return find_in_path($f.'.php', '', 'required'); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | // donc il faut l'inclure "en globals" |
| 174 | 174 | if ($f = find_in_path('mes_fonctions.php')) { |
| 175 | 175 | global $dossier_squelettes; |
| 176 | - include_once(_ROOT_CWD . $f); |
|
| 176 | + include_once(_ROOT_CWD.$f); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | if ($type === 'defaut') { |
| 202 | 202 | $objet = objet_type($quoi); |
| 203 | 203 | if ( |
| 204 | - ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true)) |
|
| 205 | - || ($f = charger_fonction('generer_url_' . $objet, 'urls', true)) // deprecated |
|
| 204 | + ($f = charger_fonction('generer_'.$objet.'_url', 'urls', true)) |
|
| 205 | + || ($f = charger_fonction('generer_url_'.$objet, 'urls', true)) // deprecated |
|
| 206 | 206 | ) { |
| 207 | 207 | return $f; |
| 208 | 208 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // inclure le module d'url |
| 218 | - include_spip('urls/' . $url_type); |
|
| 218 | + include_spip('urls/'.$url_type); |
|
| 219 | 219 | |
| 220 | 220 | switch ($quoi) { |
| 221 | 221 | case 'page': |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @return array|string |
| 278 | 278 | */ |
| 279 | 279 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 280 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 280 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 281 | 281 | if (!$pathinfo) { |
| 282 | 282 | return $f; |
| 283 | 283 | } |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | * @param string $ta Répertoire temporaire accessible |
| 10 | 10 | */ |
| 11 | 11 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 12 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 13 | - spip_initialisation_suite(); |
|
| 12 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 13 | + spip_initialisation_suite(); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -30,311 +30,311 @@ discard block |
||
| 30 | 30 | * @param string $ta Répertoire temporaire accessible |
| 31 | 31 | */ |
| 32 | 32 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 33 | - static $too_late = 0; |
|
| 34 | - if ($too_late++) { |
|
| 35 | - return; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - // Declaration des repertoires |
|
| 39 | - |
|
| 40 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 41 | - if (!defined('_DIR_PLUGINS')) { |
|
| 42 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 46 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 47 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // le nom du repertoire des librairies |
|
| 51 | - if (!defined('_DIR_LIB')) { |
|
| 52 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - // répertoire des libs via Composer |
|
| 56 | - if (!defined('_DIR_VENDOR')) { |
|
| 57 | - define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - if (!defined('_DIR_IMG')) { |
|
| 61 | - define('_DIR_IMG', $pa); |
|
| 62 | - } |
|
| 63 | - if (!defined('_DIR_LOGOS')) { |
|
| 64 | - define('_DIR_LOGOS', $pa); |
|
| 65 | - } |
|
| 66 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 67 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if (!defined('_DIR_DUMP')) { |
|
| 71 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 72 | - } |
|
| 73 | - if (!defined('_DIR_SESSIONS')) { |
|
| 74 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 75 | - } |
|
| 76 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 77 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 78 | - } |
|
| 79 | - if (!defined('_DIR_CACHE')) { |
|
| 80 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 81 | - } |
|
| 82 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 83 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 84 | - } |
|
| 85 | - if (!defined('_DIR_SKELS')) { |
|
| 86 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 87 | - } |
|
| 88 | - if (!defined('_DIR_AIDE')) { |
|
| 89 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 90 | - } |
|
| 91 | - if (!defined('_DIR_TMP')) { |
|
| 92 | - define('_DIR_TMP', $ti); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if (!defined('_DIR_VAR')) { |
|
| 96 | - define('_DIR_VAR', $ta); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if (!defined('_DIR_ETC')) { |
|
| 100 | - define('_DIR_ETC', $pi); |
|
| 101 | - } |
|
| 102 | - if (!defined('_DIR_CONNECT')) { |
|
| 103 | - define('_DIR_CONNECT', $pi); |
|
| 104 | - } |
|
| 105 | - if (!defined('_DIR_CHMOD')) { |
|
| 106 | - define('_DIR_CHMOD', $pi); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - if (!isset($GLOBALS['test_dirs'])) { |
|
| 110 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 111 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 112 | - $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // Declaration des fichiers |
|
| 116 | - |
|
| 117 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 118 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 119 | - } |
|
| 120 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 121 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 122 | - } |
|
| 123 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 124 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 125 | - } |
|
| 126 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 127 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 128 | - } |
|
| 129 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 130 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 134 | - if (!defined('_FILE_META')) { |
|
| 135 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 136 | - } |
|
| 137 | - if (!defined('_DIR_LOG')) { |
|
| 138 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 139 | - } |
|
| 140 | - if (!defined('_FILE_LOG')) { |
|
| 141 | - define('_FILE_LOG', 'spip'); |
|
| 142 | - } |
|
| 143 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 144 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // Le fichier de connexion a la base de donnees |
|
| 148 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 149 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 150 | - } |
|
| 151 | - if (!defined('_FILE_CONNECT')) { |
|
| 152 | - define( |
|
| 153 | - '_FILE_CONNECT', |
|
| 154 | - @is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false |
|
| 155 | - ); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - // Le fichier de reglages des droits |
|
| 159 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 160 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 161 | - } |
|
| 162 | - if (!defined('_FILE_CHMOD')) { |
|
| 163 | - define( |
|
| 164 | - '_FILE_CHMOD', |
|
| 165 | - @is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false |
|
| 166 | - ); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - if (!defined('_FILE_LDAP')) { |
|
| 170 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 174 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 175 | - } |
|
| 176 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 177 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 178 | - } |
|
| 179 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 180 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // Definition des droits d'acces en ecriture |
|
| 184 | - if (!defined('_SPIP_CHMOD') && _FILE_CHMOD) { |
|
| 185 | - include_once _FILE_CHMOD; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - // Se mefier des fichiers mal remplis! |
|
| 189 | - if (!defined('_SPIP_CHMOD')) { |
|
| 190 | - define('_SPIP_CHMOD', 0777); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 194 | - /** Le charset par défaut lors de l'installation */ |
|
| 195 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 196 | - } |
|
| 197 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 198 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 199 | - } |
|
| 200 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 201 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 202 | - } |
|
| 203 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 204 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - // La taille des Log |
|
| 208 | - if (!defined('_MAX_LOG')) { |
|
| 209 | - define('_MAX_LOG', 100); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - // Sommes-nous dans l'empire du Mal ? |
|
| 213 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 214 | - if (isset($_SERVER['SERVER_SOFTWARE']) && str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) { |
|
| 215 | - if (!defined('_OS_SERVEUR')) { |
|
| 216 | - define('_OS_SERVEUR', 'windows'); |
|
| 217 | - } |
|
| 218 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 219 | - define('_SPIP_LOCK_MODE', 1); |
|
| 220 | - } // utiliser le flock php |
|
| 221 | - } else { |
|
| 222 | - if (!defined('_OS_SERVEUR')) { |
|
| 223 | - define('_OS_SERVEUR', ''); |
|
| 224 | - } |
|
| 225 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 226 | - define('_SPIP_LOCK_MODE', 1); |
|
| 227 | - } // utiliser le flock php |
|
| 228 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - // Langue par defaut |
|
| 232 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 233 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - // |
|
| 237 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 238 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 239 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 240 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 241 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 242 | - |
|
| 243 | - // charger tout de suite le path et son cache |
|
| 244 | - load_path_cache(); |
|
| 245 | - |
|
| 246 | - // *********** traiter les variables ************ |
|
| 247 | - |
|
| 248 | - // |
|
| 249 | - // Securite |
|
| 250 | - // |
|
| 251 | - |
|
| 252 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 253 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 254 | - die(); |
|
| 255 | - } |
|
| 256 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 257 | - spip_desinfecte($_GET); |
|
| 258 | - spip_desinfecte($_POST); |
|
| 259 | - spip_desinfecte($_COOKIE); |
|
| 260 | - spip_desinfecte($_REQUEST); |
|
| 261 | - |
|
| 262 | - // appliquer le cookie_prefix |
|
| 263 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 264 | - include_spip('inc/cookie'); |
|
| 265 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 269 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 270 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 271 | - } else { |
|
| 272 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 273 | - if ( |
|
| 274 | - !empty($_SERVER['QUERY_STRING']) |
|
| 275 | - && !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 276 | - ) { |
|
| 277 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 282 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 283 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 284 | - } |
|
| 285 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 286 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 290 | - // charge aussi effacer_meta et ecrire_meta |
|
| 291 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 292 | - $inc_meta(); |
|
| 293 | - |
|
| 294 | - // nombre de repertoires depuis la racine |
|
| 295 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 296 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 297 | - // le calcul est faux) |
|
| 298 | - if (!_DIR_RESTREINT) { |
|
| 299 | - $GLOBALS['profondeur_url'] = 1; |
|
| 300 | - } else { |
|
| 301 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 302 | - $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 303 | - if ( |
|
| 304 | - !$uri_ref |
|
| 305 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 306 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 307 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 308 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 309 | - || $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 310 | - ) { |
|
| 311 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 312 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 313 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 314 | - } else { |
|
| 315 | - $uri_ref = ''; |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - if (!$uri || !$uri_ref) { |
|
| 319 | - $GLOBALS['profondeur_url'] = 0; |
|
| 320 | - } else { |
|
| 321 | - $GLOBALS['profondeur_url'] = max( |
|
| 322 | - 0, |
|
| 323 | - substr_count($uri[0], '/') |
|
| 324 | - - substr_count($uri_ref, '/') |
|
| 325 | - ); |
|
| 326 | - } |
|
| 327 | - } |
|
| 328 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 329 | - if (_FILE_CONNECT) { |
|
| 330 | - if ( |
|
| 331 | - verifier_visiteur() == '0minirezo' |
|
| 332 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 333 | - && !isset($_COOKIE['spip_admin']) |
|
| 334 | - ) { |
|
| 335 | - clear_path_cache(); |
|
| 336 | - } |
|
| 337 | - } |
|
| 33 | + static $too_late = 0; |
|
| 34 | + if ($too_late++) { |
|
| 35 | + return; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + // Declaration des repertoires |
|
| 39 | + |
|
| 40 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 41 | + if (!defined('_DIR_PLUGINS')) { |
|
| 42 | + define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 46 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 47 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // le nom du repertoire des librairies |
|
| 51 | + if (!defined('_DIR_LIB')) { |
|
| 52 | + define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + // répertoire des libs via Composer |
|
| 56 | + if (!defined('_DIR_VENDOR')) { |
|
| 57 | + define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + if (!defined('_DIR_IMG')) { |
|
| 61 | + define('_DIR_IMG', $pa); |
|
| 62 | + } |
|
| 63 | + if (!defined('_DIR_LOGOS')) { |
|
| 64 | + define('_DIR_LOGOS', $pa); |
|
| 65 | + } |
|
| 66 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 67 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if (!defined('_DIR_DUMP')) { |
|
| 71 | + define('_DIR_DUMP', $ti . 'dump/'); |
|
| 72 | + } |
|
| 73 | + if (!defined('_DIR_SESSIONS')) { |
|
| 74 | + define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 75 | + } |
|
| 76 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 77 | + define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 78 | + } |
|
| 79 | + if (!defined('_DIR_CACHE')) { |
|
| 80 | + define('_DIR_CACHE', $ti . 'cache/'); |
|
| 81 | + } |
|
| 82 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 83 | + define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 84 | + } |
|
| 85 | + if (!defined('_DIR_SKELS')) { |
|
| 86 | + define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 87 | + } |
|
| 88 | + if (!defined('_DIR_AIDE')) { |
|
| 89 | + define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 90 | + } |
|
| 91 | + if (!defined('_DIR_TMP')) { |
|
| 92 | + define('_DIR_TMP', $ti); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if (!defined('_DIR_VAR')) { |
|
| 96 | + define('_DIR_VAR', $ta); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if (!defined('_DIR_ETC')) { |
|
| 100 | + define('_DIR_ETC', $pi); |
|
| 101 | + } |
|
| 102 | + if (!defined('_DIR_CONNECT')) { |
|
| 103 | + define('_DIR_CONNECT', $pi); |
|
| 104 | + } |
|
| 105 | + if (!defined('_DIR_CHMOD')) { |
|
| 106 | + define('_DIR_CHMOD', $pi); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 110 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 111 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 112 | + $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // Declaration des fichiers |
|
| 116 | + |
|
| 117 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 118 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 119 | + } |
|
| 120 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 121 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 122 | + } |
|
| 123 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 124 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 125 | + } |
|
| 126 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 127 | + define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 128 | + } |
|
| 129 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 130 | + define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 134 | + if (!defined('_FILE_META')) { |
|
| 135 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 136 | + } |
|
| 137 | + if (!defined('_DIR_LOG')) { |
|
| 138 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 139 | + } |
|
| 140 | + if (!defined('_FILE_LOG')) { |
|
| 141 | + define('_FILE_LOG', 'spip'); |
|
| 142 | + } |
|
| 143 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 144 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // Le fichier de connexion a la base de donnees |
|
| 148 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 149 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 150 | + } |
|
| 151 | + if (!defined('_FILE_CONNECT')) { |
|
| 152 | + define( |
|
| 153 | + '_FILE_CONNECT', |
|
| 154 | + @is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false |
|
| 155 | + ); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + // Le fichier de reglages des droits |
|
| 159 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 160 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 161 | + } |
|
| 162 | + if (!defined('_FILE_CHMOD')) { |
|
| 163 | + define( |
|
| 164 | + '_FILE_CHMOD', |
|
| 165 | + @is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false |
|
| 166 | + ); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + if (!defined('_FILE_LDAP')) { |
|
| 170 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 174 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 175 | + } |
|
| 176 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 177 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 178 | + } |
|
| 179 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 180 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // Definition des droits d'acces en ecriture |
|
| 184 | + if (!defined('_SPIP_CHMOD') && _FILE_CHMOD) { |
|
| 185 | + include_once _FILE_CHMOD; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + // Se mefier des fichiers mal remplis! |
|
| 189 | + if (!defined('_SPIP_CHMOD')) { |
|
| 190 | + define('_SPIP_CHMOD', 0777); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 194 | + /** Le charset par défaut lors de l'installation */ |
|
| 195 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 196 | + } |
|
| 197 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 198 | + define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 199 | + } |
|
| 200 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 201 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 202 | + } |
|
| 203 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 204 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + // La taille des Log |
|
| 208 | + if (!defined('_MAX_LOG')) { |
|
| 209 | + define('_MAX_LOG', 100); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // Sommes-nous dans l'empire du Mal ? |
|
| 213 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 214 | + if (isset($_SERVER['SERVER_SOFTWARE']) && str_contains($_SERVER['SERVER_SOFTWARE'], '(Win')) { |
|
| 215 | + if (!defined('_OS_SERVEUR')) { |
|
| 216 | + define('_OS_SERVEUR', 'windows'); |
|
| 217 | + } |
|
| 218 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 219 | + define('_SPIP_LOCK_MODE', 1); |
|
| 220 | + } // utiliser le flock php |
|
| 221 | + } else { |
|
| 222 | + if (!defined('_OS_SERVEUR')) { |
|
| 223 | + define('_OS_SERVEUR', ''); |
|
| 224 | + } |
|
| 225 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 226 | + define('_SPIP_LOCK_MODE', 1); |
|
| 227 | + } // utiliser le flock php |
|
| 228 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + // Langue par defaut |
|
| 232 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 233 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + // |
|
| 237 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 238 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 239 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 240 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 241 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 242 | + |
|
| 243 | + // charger tout de suite le path et son cache |
|
| 244 | + load_path_cache(); |
|
| 245 | + |
|
| 246 | + // *********** traiter les variables ************ |
|
| 247 | + |
|
| 248 | + // |
|
| 249 | + // Securite |
|
| 250 | + // |
|
| 251 | + |
|
| 252 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 253 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 254 | + die(); |
|
| 255 | + } |
|
| 256 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 257 | + spip_desinfecte($_GET); |
|
| 258 | + spip_desinfecte($_POST); |
|
| 259 | + spip_desinfecte($_COOKIE); |
|
| 260 | + spip_desinfecte($_REQUEST); |
|
| 261 | + |
|
| 262 | + // appliquer le cookie_prefix |
|
| 263 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 264 | + include_spip('inc/cookie'); |
|
| 265 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 269 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 270 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 271 | + } else { |
|
| 272 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 273 | + if ( |
|
| 274 | + !empty($_SERVER['QUERY_STRING']) |
|
| 275 | + && !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 276 | + ) { |
|
| 277 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 282 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 283 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 284 | + } |
|
| 285 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 286 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 290 | + // charge aussi effacer_meta et ecrire_meta |
|
| 291 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 292 | + $inc_meta(); |
|
| 293 | + |
|
| 294 | + // nombre de repertoires depuis la racine |
|
| 295 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 296 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 297 | + // le calcul est faux) |
|
| 298 | + if (!_DIR_RESTREINT) { |
|
| 299 | + $GLOBALS['profondeur_url'] = 1; |
|
| 300 | + } else { |
|
| 301 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 302 | + $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 303 | + if ( |
|
| 304 | + !$uri_ref |
|
| 305 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 306 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 307 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 308 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 309 | + || $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 310 | + ) { |
|
| 311 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 312 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 313 | + $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 314 | + } else { |
|
| 315 | + $uri_ref = ''; |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + if (!$uri || !$uri_ref) { |
|
| 319 | + $GLOBALS['profondeur_url'] = 0; |
|
| 320 | + } else { |
|
| 321 | + $GLOBALS['profondeur_url'] = max( |
|
| 322 | + 0, |
|
| 323 | + substr_count($uri[0], '/') |
|
| 324 | + - substr_count($uri_ref, '/') |
|
| 325 | + ); |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 329 | + if (_FILE_CONNECT) { |
|
| 330 | + if ( |
|
| 331 | + verifier_visiteur() == '0minirezo' |
|
| 332 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 333 | + && !isset($_COOKIE['spip_admin']) |
|
| 334 | + ) { |
|
| 335 | + clear_path_cache(); |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -343,158 +343,158 @@ discard block |
||
| 343 | 343 | * |
| 344 | 344 | */ |
| 345 | 345 | function spip_initialisation_suite() { |
| 346 | - static $too_late = 0; |
|
| 347 | - if ($too_late++) { |
|
| 348 | - return; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - // taille mini des login |
|
| 352 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 353 | - define('_LOGIN_TROP_COURT', 4); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 357 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 358 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 359 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 360 | - |
|
| 361 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 362 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 363 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 364 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 365 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 366 | - |
|
| 367 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 368 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - // largeur maximale des images dans l'administration |
|
| 372 | - if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 373 | - define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 377 | - if (!defined('_IMG_QUALITE')) { |
|
| 378 | - define('_IMG_QUALITE', 85); |
|
| 379 | - } # valeur par defaut |
|
| 380 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 381 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 382 | - } # surcharge pour la lib GD |
|
| 383 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 384 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 385 | - } # surcharge pour imagick en ligne de commande |
|
| 386 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 387 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 388 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 389 | - } # surcharge pour imagick en PHP |
|
| 390 | - |
|
| 391 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 392 | - define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 393 | - } // poids en octet |
|
| 394 | - |
|
| 395 | - // qq chaines standard |
|
| 396 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 397 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 398 | - } |
|
| 399 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 400 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 401 | - } |
|
| 402 | - if (!defined('_SPIP_DUMP')) { |
|
| 403 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 404 | - } |
|
| 405 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 406 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 407 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 408 | - } |
|
| 409 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 410 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 411 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 415 | - /** |
|
| 416 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 417 | - * @var int Nombre de caractères */ |
|
| 418 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 422 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 426 | - /** Définit le doctype de l’espace privé */ |
|
| 427 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 428 | - } |
|
| 429 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 430 | - /** Définit le doctype de l’aide en ligne */ |
|
| 431 | - define( |
|
| 432 | - '_DOCTYPE_AIDE', |
|
| 433 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 434 | - ); |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 438 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 439 | - * le script de l'espace public, alias index.php */ |
|
| 440 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 441 | - } |
|
| 442 | - if (!defined('_SPIP_PAGE')) { |
|
| 443 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 444 | - define('_SPIP_PAGE', 'page'); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - // le script de l'espace prive |
|
| 448 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 449 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 450 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 451 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 452 | - if (!empty($_SERVER['SERVER_SOFTWARE']) && preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 453 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 454 | - } else { |
|
| 455 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 456 | - } |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - |
|
| 460 | - if (!defined('_SPIP_AJAX')) { |
|
| 461 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 462 | - ? 1 |
|
| 463 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - // La requete est-elle en ajax ? |
|
| 467 | - if (!defined('_AJAX')) { |
|
| 468 | - define( |
|
| 469 | - '_AJAX', |
|
| 470 | - ( |
|
| 471 | - isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 472 | - || !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuer |
|
| 473 | - || !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 474 | - || !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 475 | - ) |
|
| 476 | - && empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 477 | - ); |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 481 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 482 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 483 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 484 | - define( |
|
| 485 | - '_IMG_GD_MAX_PIXELS', |
|
| 486 | - (isset($GLOBALS['meta']['max_taille_vignettes']) && $GLOBALS['meta']['max_taille_vignettes']) |
|
| 487 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 488 | - : 0 |
|
| 489 | - ); |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - // Protocoles a normaliser dans les chaines de langues |
|
| 493 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 494 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - init_var_mode(); |
|
| 346 | + static $too_late = 0; |
|
| 347 | + if ($too_late++) { |
|
| 348 | + return; |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + // taille mini des login |
|
| 352 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 353 | + define('_LOGIN_TROP_COURT', 4); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 357 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 358 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 359 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 360 | + |
|
| 361 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 362 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 363 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 364 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 365 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 366 | + |
|
| 367 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 368 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + // largeur maximale des images dans l'administration |
|
| 372 | + if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 373 | + define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 377 | + if (!defined('_IMG_QUALITE')) { |
|
| 378 | + define('_IMG_QUALITE', 85); |
|
| 379 | + } # valeur par defaut |
|
| 380 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 381 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 382 | + } # surcharge pour la lib GD |
|
| 383 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 384 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 385 | + } # surcharge pour imagick en ligne de commande |
|
| 386 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 387 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 388 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 389 | + } # surcharge pour imagick en PHP |
|
| 390 | + |
|
| 391 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 392 | + define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 393 | + } // poids en octet |
|
| 394 | + |
|
| 395 | + // qq chaines standard |
|
| 396 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 397 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 398 | + } |
|
| 399 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 400 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 401 | + } |
|
| 402 | + if (!defined('_SPIP_DUMP')) { |
|
| 403 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 404 | + } |
|
| 405 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 406 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 407 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 408 | + } |
|
| 409 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 410 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 411 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 415 | + /** |
|
| 416 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 417 | + * @var int Nombre de caractères */ |
|
| 418 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 422 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 426 | + /** Définit le doctype de l’espace privé */ |
|
| 427 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 428 | + } |
|
| 429 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 430 | + /** Définit le doctype de l’aide en ligne */ |
|
| 431 | + define( |
|
| 432 | + '_DOCTYPE_AIDE', |
|
| 433 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 434 | + ); |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 438 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 439 | + * le script de l'espace public, alias index.php */ |
|
| 440 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 441 | + } |
|
| 442 | + if (!defined('_SPIP_PAGE')) { |
|
| 443 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 444 | + define('_SPIP_PAGE', 'page'); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + // le script de l'espace prive |
|
| 448 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 449 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 450 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 451 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 452 | + if (!empty($_SERVER['SERVER_SOFTWARE']) && preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 453 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 454 | + } else { |
|
| 455 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 456 | + } |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + |
|
| 460 | + if (!defined('_SPIP_AJAX')) { |
|
| 461 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 462 | + ? 1 |
|
| 463 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + // La requete est-elle en ajax ? |
|
| 467 | + if (!defined('_AJAX')) { |
|
| 468 | + define( |
|
| 469 | + '_AJAX', |
|
| 470 | + ( |
|
| 471 | + isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 472 | + || !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuer |
|
| 473 | + || !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 474 | + || !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 475 | + ) |
|
| 476 | + && empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 477 | + ); |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 481 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 482 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 483 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 484 | + define( |
|
| 485 | + '_IMG_GD_MAX_PIXELS', |
|
| 486 | + (isset($GLOBALS['meta']['max_taille_vignettes']) && $GLOBALS['meta']['max_taille_vignettes']) |
|
| 487 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 488 | + : 0 |
|
| 489 | + ); |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + // Protocoles a normaliser dans les chaines de langues |
|
| 493 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 494 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + init_var_mode(); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -528,134 +528,134 @@ discard block |
||
| 528 | 528 | * ` var_mode` (calcul ou recalcul). |
| 529 | 529 | */ |
| 530 | 530 | function init_var_mode() { |
| 531 | - static $done = false; |
|
| 532 | - if (!$done) { |
|
| 533 | - if (isset($_GET['var_mode'])) { |
|
| 534 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 535 | - // tout le monde peut calcul/recalcul |
|
| 536 | - if (!defined('_VAR_MODE')) { |
|
| 537 | - if (in_array('recalcul', $var_mode)) { |
|
| 538 | - define('_VAR_MODE', 'recalcul'); |
|
| 539 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 540 | - define('_VAR_MODE', 'calcul'); |
|
| 541 | - } |
|
| 542 | - } |
|
| 543 | - $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 544 | - if ($var_mode) { |
|
| 545 | - include_spip('inc/autoriser'); |
|
| 546 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 547 | - if ( |
|
| 548 | - autoriser( |
|
| 549 | - ($_GET['var_mode'] == 'preview') |
|
| 550 | - ? 'previsualiser' |
|
| 551 | - : 'debug' |
|
| 552 | - ) |
|
| 553 | - ) { |
|
| 554 | - if (in_array('traduction', $var_mode)) { |
|
| 555 | - // forcer le calcul pour passer dans traduire |
|
| 556 | - if (!defined('_VAR_MODE')) { |
|
| 557 | - define('_VAR_MODE', 'calcul'); |
|
| 558 | - } |
|
| 559 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 560 | - if (!defined('_VAR_NOCACHE')) { |
|
| 561 | - define('_VAR_NOCACHE', true); |
|
| 562 | - } |
|
| 563 | - $var_mode = array_diff($var_mode, ['traduction']); |
|
| 564 | - } |
|
| 565 | - if (in_array('preview', $var_mode)) { |
|
| 566 | - // basculer sur les criteres de preview dans les boucles |
|
| 567 | - if (!defined('_VAR_PREVIEW')) { |
|
| 568 | - define('_VAR_PREVIEW', true); |
|
| 569 | - } |
|
| 570 | - // forcer le calcul |
|
| 571 | - if (!defined('_VAR_MODE')) { |
|
| 572 | - define('_VAR_MODE', 'calcul'); |
|
| 573 | - } |
|
| 574 | - // et ne pas enregistrer de cache |
|
| 575 | - if (!defined('_VAR_NOCACHE')) { |
|
| 576 | - define('_VAR_NOCACHE', true); |
|
| 577 | - } |
|
| 578 | - $var_mode = array_diff($var_mode, ['preview']); |
|
| 579 | - } |
|
| 580 | - if (in_array('inclure', $var_mode)) { |
|
| 581 | - // forcer le compilo et ignorer les caches existants |
|
| 582 | - if (!defined('_VAR_MODE')) { |
|
| 583 | - define('_VAR_MODE', 'calcul'); |
|
| 584 | - } |
|
| 585 | - if (!defined('_VAR_INCLURE')) { |
|
| 586 | - define('_VAR_INCLURE', true); |
|
| 587 | - } |
|
| 588 | - // et ne pas enregistrer de cache |
|
| 589 | - if (!defined('_VAR_NOCACHE')) { |
|
| 590 | - define('_VAR_NOCACHE', true); |
|
| 591 | - } |
|
| 592 | - $var_mode = array_diff($var_mode, ['inclure']); |
|
| 593 | - } |
|
| 594 | - if (in_array('urls', $var_mode)) { |
|
| 595 | - // forcer le compilo et ignorer les caches existants |
|
| 596 | - if (!defined('_VAR_MODE')) { |
|
| 597 | - define('_VAR_MODE', 'calcul'); |
|
| 598 | - } |
|
| 599 | - if (!defined('_VAR_URLS')) { |
|
| 600 | - define('_VAR_URLS', true); |
|
| 601 | - } |
|
| 602 | - $var_mode = array_diff($var_mode, ['urls']); |
|
| 603 | - } |
|
| 604 | - if (in_array('images', $var_mode)) { |
|
| 605 | - // forcer le compilo et ignorer les caches existants |
|
| 606 | - if (!defined('_VAR_MODE')) { |
|
| 607 | - define('_VAR_MODE', 'calcul'); |
|
| 608 | - } |
|
| 609 | - // indiquer qu'on doit recalculer les images |
|
| 610 | - if (!defined('_VAR_IMAGES')) { |
|
| 611 | - define('_VAR_IMAGES', true); |
|
| 612 | - } |
|
| 613 | - $var_mode = array_diff($var_mode, ['images']); |
|
| 614 | - } |
|
| 615 | - if (in_array('debug', $var_mode)) { |
|
| 616 | - if (!defined('_VAR_MODE')) { |
|
| 617 | - define('_VAR_MODE', 'debug'); |
|
| 618 | - } |
|
| 619 | - // et ne pas enregistrer de cache |
|
| 620 | - if (!defined('_VAR_NOCACHE')) { |
|
| 621 | - define('_VAR_NOCACHE', true); |
|
| 622 | - } |
|
| 623 | - $var_mode = array_diff($var_mode, ['debug']); |
|
| 624 | - } |
|
| 625 | - if (count($var_mode) && !defined('_VAR_MODE')) { |
|
| 626 | - define('_VAR_MODE', reset($var_mode)); |
|
| 627 | - } |
|
| 628 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 629 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 630 | - . ' ' . _VAR_MODE); |
|
| 631 | - } |
|
| 632 | - } // pas autorise ? |
|
| 633 | - else { |
|
| 634 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 635 | - if ( |
|
| 636 | - !$GLOBALS['visiteur_session'] |
|
| 637 | - && !empty($_SERVER['HTTP_HOST']) |
|
| 638 | - && !empty($_SERVER['REQUEST_METHOD']) |
|
| 639 | - && $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 640 | - ) { |
|
| 641 | - $self = self('&', true); |
|
| 642 | - if (!str_contains($self, 'page=login')) { |
|
| 643 | - include_spip('inc/headers'); |
|
| 644 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 645 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 646 | - } |
|
| 647 | - } |
|
| 648 | - // sinon tant pis |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - if (!defined('_VAR_MODE')) { |
|
| 653 | - /** |
|
| 654 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 655 | - * @see init_var_mode() |
|
| 656 | - */ |
|
| 657 | - define('_VAR_MODE', false); |
|
| 658 | - } |
|
| 659 | - $done = true; |
|
| 660 | - } |
|
| 531 | + static $done = false; |
|
| 532 | + if (!$done) { |
|
| 533 | + if (isset($_GET['var_mode'])) { |
|
| 534 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 535 | + // tout le monde peut calcul/recalcul |
|
| 536 | + if (!defined('_VAR_MODE')) { |
|
| 537 | + if (in_array('recalcul', $var_mode)) { |
|
| 538 | + define('_VAR_MODE', 'recalcul'); |
|
| 539 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 540 | + define('_VAR_MODE', 'calcul'); |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 544 | + if ($var_mode) { |
|
| 545 | + include_spip('inc/autoriser'); |
|
| 546 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 547 | + if ( |
|
| 548 | + autoriser( |
|
| 549 | + ($_GET['var_mode'] == 'preview') |
|
| 550 | + ? 'previsualiser' |
|
| 551 | + : 'debug' |
|
| 552 | + ) |
|
| 553 | + ) { |
|
| 554 | + if (in_array('traduction', $var_mode)) { |
|
| 555 | + // forcer le calcul pour passer dans traduire |
|
| 556 | + if (!defined('_VAR_MODE')) { |
|
| 557 | + define('_VAR_MODE', 'calcul'); |
|
| 558 | + } |
|
| 559 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 560 | + if (!defined('_VAR_NOCACHE')) { |
|
| 561 | + define('_VAR_NOCACHE', true); |
|
| 562 | + } |
|
| 563 | + $var_mode = array_diff($var_mode, ['traduction']); |
|
| 564 | + } |
|
| 565 | + if (in_array('preview', $var_mode)) { |
|
| 566 | + // basculer sur les criteres de preview dans les boucles |
|
| 567 | + if (!defined('_VAR_PREVIEW')) { |
|
| 568 | + define('_VAR_PREVIEW', true); |
|
| 569 | + } |
|
| 570 | + // forcer le calcul |
|
| 571 | + if (!defined('_VAR_MODE')) { |
|
| 572 | + define('_VAR_MODE', 'calcul'); |
|
| 573 | + } |
|
| 574 | + // et ne pas enregistrer de cache |
|
| 575 | + if (!defined('_VAR_NOCACHE')) { |
|
| 576 | + define('_VAR_NOCACHE', true); |
|
| 577 | + } |
|
| 578 | + $var_mode = array_diff($var_mode, ['preview']); |
|
| 579 | + } |
|
| 580 | + if (in_array('inclure', $var_mode)) { |
|
| 581 | + // forcer le compilo et ignorer les caches existants |
|
| 582 | + if (!defined('_VAR_MODE')) { |
|
| 583 | + define('_VAR_MODE', 'calcul'); |
|
| 584 | + } |
|
| 585 | + if (!defined('_VAR_INCLURE')) { |
|
| 586 | + define('_VAR_INCLURE', true); |
|
| 587 | + } |
|
| 588 | + // et ne pas enregistrer de cache |
|
| 589 | + if (!defined('_VAR_NOCACHE')) { |
|
| 590 | + define('_VAR_NOCACHE', true); |
|
| 591 | + } |
|
| 592 | + $var_mode = array_diff($var_mode, ['inclure']); |
|
| 593 | + } |
|
| 594 | + if (in_array('urls', $var_mode)) { |
|
| 595 | + // forcer le compilo et ignorer les caches existants |
|
| 596 | + if (!defined('_VAR_MODE')) { |
|
| 597 | + define('_VAR_MODE', 'calcul'); |
|
| 598 | + } |
|
| 599 | + if (!defined('_VAR_URLS')) { |
|
| 600 | + define('_VAR_URLS', true); |
|
| 601 | + } |
|
| 602 | + $var_mode = array_diff($var_mode, ['urls']); |
|
| 603 | + } |
|
| 604 | + if (in_array('images', $var_mode)) { |
|
| 605 | + // forcer le compilo et ignorer les caches existants |
|
| 606 | + if (!defined('_VAR_MODE')) { |
|
| 607 | + define('_VAR_MODE', 'calcul'); |
|
| 608 | + } |
|
| 609 | + // indiquer qu'on doit recalculer les images |
|
| 610 | + if (!defined('_VAR_IMAGES')) { |
|
| 611 | + define('_VAR_IMAGES', true); |
|
| 612 | + } |
|
| 613 | + $var_mode = array_diff($var_mode, ['images']); |
|
| 614 | + } |
|
| 615 | + if (in_array('debug', $var_mode)) { |
|
| 616 | + if (!defined('_VAR_MODE')) { |
|
| 617 | + define('_VAR_MODE', 'debug'); |
|
| 618 | + } |
|
| 619 | + // et ne pas enregistrer de cache |
|
| 620 | + if (!defined('_VAR_NOCACHE')) { |
|
| 621 | + define('_VAR_NOCACHE', true); |
|
| 622 | + } |
|
| 623 | + $var_mode = array_diff($var_mode, ['debug']); |
|
| 624 | + } |
|
| 625 | + if (count($var_mode) && !defined('_VAR_MODE')) { |
|
| 626 | + define('_VAR_MODE', reset($var_mode)); |
|
| 627 | + } |
|
| 628 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 629 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 630 | + . ' ' . _VAR_MODE); |
|
| 631 | + } |
|
| 632 | + } // pas autorise ? |
|
| 633 | + else { |
|
| 634 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 635 | + if ( |
|
| 636 | + !$GLOBALS['visiteur_session'] |
|
| 637 | + && !empty($_SERVER['HTTP_HOST']) |
|
| 638 | + && !empty($_SERVER['REQUEST_METHOD']) |
|
| 639 | + && $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 640 | + ) { |
|
| 641 | + $self = self('&', true); |
|
| 642 | + if (!str_contains($self, 'page=login')) { |
|
| 643 | + include_spip('inc/headers'); |
|
| 644 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 645 | + redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 646 | + } |
|
| 647 | + } |
|
| 648 | + // sinon tant pis |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + if (!defined('_VAR_MODE')) { |
|
| 653 | + /** |
|
| 654 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 655 | + * @see init_var_mode() |
|
| 656 | + */ |
|
| 657 | + define('_VAR_MODE', false); |
|
| 658 | + } |
|
| 659 | + $done = true; |
|
| 660 | + } |
|
| 661 | 661 | } |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // le nom du repertoire plugins/ activables/desactivables |
| 41 | 41 | if (!defined('_DIR_PLUGINS')) { |
| 42 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 42 | + define('_DIR_PLUGINS', _DIR_RACINE.'plugins/'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 46 | 46 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 47 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 47 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // le nom du repertoire des librairies |
| 51 | 51 | if (!defined('_DIR_LIB')) { |
| 52 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 52 | + define('_DIR_LIB', _DIR_RACINE.'lib/'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // répertoire des libs via Composer |
| 56 | 56 | if (!defined('_DIR_VENDOR')) { |
| 57 | - define('_DIR_VENDOR', _DIR_RACINE . 'vendor/'); |
|
| 57 | + define('_DIR_VENDOR', _DIR_RACINE.'vendor/'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if (!defined('_DIR_IMG')) { |
@@ -64,29 +64,29 @@ discard block |
||
| 64 | 64 | define('_DIR_LOGOS', $pa); |
| 65 | 65 | } |
| 66 | 66 | if (!defined('_DIR_IMG_ICONES')) { |
| 67 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 67 | + define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if (!defined('_DIR_DUMP')) { |
| 71 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 71 | + define('_DIR_DUMP', $ti.'dump/'); |
|
| 72 | 72 | } |
| 73 | 73 | if (!defined('_DIR_SESSIONS')) { |
| 74 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 74 | + define('_DIR_SESSIONS', $ti.'sessions/'); |
|
| 75 | 75 | } |
| 76 | 76 | if (!defined('_DIR_TRANSFERT')) { |
| 77 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 77 | + define('_DIR_TRANSFERT', $ti.'upload/'); |
|
| 78 | 78 | } |
| 79 | 79 | if (!defined('_DIR_CACHE')) { |
| 80 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 80 | + define('_DIR_CACHE', $ti.'cache/'); |
|
| 81 | 81 | } |
| 82 | 82 | if (!defined('_DIR_CACHE_XML')) { |
| 83 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 83 | + define('_DIR_CACHE_XML', _DIR_CACHE.'xml/'); |
|
| 84 | 84 | } |
| 85 | 85 | if (!defined('_DIR_SKELS')) { |
| 86 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 86 | + define('_DIR_SKELS', _DIR_CACHE.'skel/'); |
|
| 87 | 87 | } |
| 88 | 88 | if (!defined('_DIR_AIDE')) { |
| 89 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 89 | + define('_DIR_AIDE', _DIR_CACHE.'aide/'); |
|
| 90 | 90 | } |
| 91 | 91 | if (!defined('_DIR_TMP')) { |
| 92 | 92 | define('_DIR_TMP', $ti); |
@@ -115,27 +115,27 @@ discard block |
||
| 115 | 115 | // Declaration des fichiers |
| 116 | 116 | |
| 117 | 117 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 118 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 118 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php'); |
|
| 119 | 119 | } |
| 120 | 120 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 121 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 121 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php'); |
|
| 122 | 122 | } |
| 123 | 123 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 124 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 124 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php'); |
|
| 125 | 125 | } |
| 126 | 126 | if (!defined('_CACHE_PIPELINES')) { |
| 127 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 127 | + define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php'); |
|
| 128 | 128 | } |
| 129 | 129 | if (!defined('_CACHE_CHEMIN')) { |
| 130 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 130 | + define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt'); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | # attention .php obligatoire pour ecrire_fichier_securise |
| 134 | 134 | if (!defined('_FILE_META')) { |
| 135 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 135 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 136 | 136 | } |
| 137 | 137 | if (!defined('_DIR_LOG')) { |
| 138 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 138 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 139 | 139 | } |
| 140 | 140 | if (!defined('_FILE_LOG')) { |
| 141 | 141 | define('_FILE_LOG', 'spip'); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | if (!defined('_FILE_CONNECT')) { |
| 152 | 152 | define( |
| 153 | 153 | '_FILE_CONNECT', |
| 154 | - @is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : false |
|
| 154 | + @is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f : false |
|
| 155 | 155 | ); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | if (!defined('_FILE_CHMOD')) { |
| 163 | 163 | define( |
| 164 | 164 | '_FILE_CHMOD', |
| 165 | - @is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false |
|
| 165 | + @is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f : false |
|
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 175 | 175 | } |
| 176 | 176 | if (!defined('_FILE_CONNECT_TMP')) { |
| 177 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 177 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 178 | 178 | } |
| 179 | 179 | if (!defined('_FILE_CHMOD_TMP')) { |
| 180 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 180 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // Definition des droits d'acces en ecriture |
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 196 | 196 | } |
| 197 | 197 | if (!defined('_ROOT_PLUGINS')) { |
| 198 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 198 | + define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/'); |
|
| 199 | 199 | } |
| 200 | 200 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 201 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 201 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/'); |
|
| 202 | 202 | } |
| 203 | 203 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 204 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 204 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // La taille des Log |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 239 | 239 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 240 | 240 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 241 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 241 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 242 | 242 | |
| 243 | 243 | // charger tout de suite le path et son cache |
| 244 | 244 | load_path_cache(); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | !empty($_SERVER['QUERY_STRING']) |
| 275 | 275 | && !strpos($_SERVER['REQUEST_URI'], '?') |
| 276 | 276 | ) { |
| 277 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 277 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | ) { |
| 311 | 311 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 312 | 312 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 313 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 313 | + $uri_ref = ($uri_ref['path'] ?? '').'/'; |
|
| 314 | 314 | } else { |
| 315 | 315 | $uri_ref = ''; |
| 316 | 316 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | } |
| 405 | 405 | if (!defined('_CACHE_RUBRIQUES')) { |
| 406 | 406 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 407 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 407 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 408 | 408 | } |
| 409 | 409 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 410 | 410 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | } |
| 628 | 628 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 629 | 629 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 630 | - . ' ' . _VAR_MODE); |
|
| 630 | + . ' '._VAR_MODE); |
|
| 631 | 631 | } |
| 632 | 632 | } // pas autorise ? |
| 633 | 633 | else { |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | if (!str_contains($self, 'page=login')) { |
| 643 | 643 | include_spip('inc/headers'); |
| 644 | 644 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 645 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 645 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | // sinon tant pis |
@@ -22,19 +22,19 @@ discard block |
||
| 22 | 22 | **/ |
| 23 | 23 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 24 | 24 | |
| 25 | - $script1 = explode('&', $script); |
|
| 26 | - $script1 = reset($script1); |
|
| 25 | + $script1 = explode('&', $script); |
|
| 26 | + $script1 = reset($script1); |
|
| 27 | 27 | |
| 28 | - return "<form action='" |
|
| 29 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 30 | - . "' " |
|
| 31 | - . ($atts ?: " method='post'") |
|
| 32 | - . "><div>\n" |
|
| 33 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 34 | - . $corps |
|
| 35 | - . (!$submit ? '' : |
|
| 36 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 37 | - . "</div></form>\n"; |
|
| 28 | + return "<form action='" |
|
| 29 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 30 | + . "' " |
|
| 31 | + . ($atts ?: " method='post'") |
|
| 32 | + . "><div>\n" |
|
| 33 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 34 | + . $corps |
|
| 35 | + . (!$submit ? '' : |
|
| 36 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 37 | + . "</div></form>\n"; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -51,20 +51,20 @@ discard block |
||
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | 53 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 54 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 55 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 56 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 57 | - $h = (_DIR_RACINE && !$public) |
|
| 58 | - ? generer_url_ecrire(_request('exec')) |
|
| 59 | - : generer_url_public(); |
|
| 54 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 55 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 56 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 57 | + $h = (_DIR_RACINE && !$public) |
|
| 58 | + ? generer_url_ecrire(_request('exec')) |
|
| 59 | + : generer_url_public(); |
|
| 60 | 60 | |
| 61 | - return "\n<form action='" . |
|
| 62 | - $h . |
|
| 63 | - "'" . |
|
| 64 | - $atts . |
|
| 65 | - ">\n" . |
|
| 66 | - '<div>' . |
|
| 67 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 68 | - $corps . |
|
| 69 | - '</div></form>'; |
|
| 61 | + return "\n<form action='" . |
|
| 62 | + $h . |
|
| 63 | + "'" . |
|
| 64 | + $atts . |
|
| 65 | + ">\n" . |
|
| 66 | + '<div>' . |
|
| 67 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 68 | + $corps . |
|
| 69 | + '</div></form>'; |
|
| 70 | 70 | } |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | . "><div>\n" |
| 33 | 33 | . "<input type='hidden' name='exec' value='$script1' />" |
| 34 | 34 | . $corps |
| 35 | - . (!$submit ? '' : |
|
| 36 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 35 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>')) |
|
| 37 | 36 | . "</div></form>\n"; |
| 38 | 37 | } |
| 39 | 38 | |
@@ -58,13 +57,13 @@ discard block |
||
| 58 | 57 | ? generer_url_ecrire(_request('exec')) |
| 59 | 58 | : generer_url_public(); |
| 60 | 59 | |
| 61 | - return "\n<form action='" . |
|
| 62 | - $h . |
|
| 63 | - "'" . |
|
| 64 | - $atts . |
|
| 65 | - ">\n" . |
|
| 66 | - '<div>' . |
|
| 67 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 68 | - $corps . |
|
| 60 | + return "\n<form action='". |
|
| 61 | + $h. |
|
| 62 | + "'". |
|
| 63 | + $atts. |
|
| 64 | + ">\n". |
|
| 65 | + '<div>'. |
|
| 66 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 67 | + $corps. |
|
| 69 | 68 | '</div></form>'; |
| 70 | 69 | } |