@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * true si espace privé, false sinon. |
| 32 | 32 | **/ |
| 33 | 33 | function is_url_prive($cible) { |
| 34 | - include_spip('inc/filtres_mini'); |
|
| 35 | - $path = parse_url(tester_url_absolue($cible) ? $cible : url_absolue($cible)); |
|
| 36 | - $path = ($path['path'] ?? ''); |
|
| 34 | + include_spip('inc/filtres_mini'); |
|
| 35 | + $path = parse_url(tester_url_absolue($cible) ? $cible : url_absolue($cible)); |
|
| 36 | + $path = ($path['path'] ?? ''); |
|
| 37 | 37 | |
| 38 | - return strncmp(substr($path, -strlen(_DIR_RESTREINT_ABS)), _DIR_RESTREINT_ABS, strlen(_DIR_RESTREINT_ABS)) == 0; |
|
| 38 | + return strncmp(substr($path, -strlen(_DIR_RESTREINT_ABS)), _DIR_RESTREINT_ABS, strlen(_DIR_RESTREINT_ABS)) == 0; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -60,111 +60,111 @@ discard block |
||
| 60 | 60 | * Environnement du formulaire |
| 61 | 61 | **/ |
| 62 | 62 | function formulaires_login_charger_dist($cible = '', $options = [], $deprecated = null) { |
| 63 | - $erreur = _request('var_erreur'); |
|
| 64 | - |
|
| 65 | - if (!is_array($options)) { |
|
| 66 | - $options = [ |
|
| 67 | - 'login' => $options, |
|
| 68 | - 'prive' => $deprecated |
|
| 69 | - ]; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $login = (empty($options['login']) ? '' : $options['login']); |
|
| 73 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 74 | - // conserver le fonctionnement historique |
|
| 75 | - if (!isset($options['autofocus'])) { |
|
| 76 | - $options['autofocus'] = true; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - if (!$login) { |
|
| 80 | - $login = strval(_request('var_login')); |
|
| 81 | - } |
|
| 82 | - // si on est deja identifie |
|
| 83 | - if (!$login and isset($GLOBALS['visiteur_session']['email'])) { |
|
| 84 | - $login = $GLOBALS['visiteur_session']['email']; |
|
| 85 | - } |
|
| 86 | - if (!$login and isset($GLOBALS['visiteur_session']['login'])) { |
|
| 87 | - $login = $GLOBALS['visiteur_session']['login']; |
|
| 88 | - } |
|
| 89 | - // ou si on a un cookie admin |
|
| 90 | - if (!$login) { |
|
| 91 | - if ( |
|
| 92 | - isset($_COOKIE['spip_admin']) |
|
| 93 | - and preg_match(',^@(.*)$,', $_COOKIE['spip_admin'], $regs) |
|
| 94 | - ) { |
|
| 95 | - $login = $regs[1]; |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $lang = $GLOBALS['spip_lang']; |
|
| 100 | - include_spip('inc/auth'); |
|
| 101 | - $row = auth_informer_login($login); |
|
| 102 | - |
|
| 103 | - // retablir la langue de l'URL si forcee (on ignore la langue de l'auteur dans ce cas) |
|
| 104 | - if (_request('lang') === $lang and $GLOBALS['spip_lang'] !== $lang) { |
|
| 105 | - changer_langue($lang); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // Construire l'environnement du squelette |
|
| 109 | - // Ne pas proposer de "rester connecte quelques jours" |
|
| 110 | - // si la duree de l'alea est inferieure a 12 h (valeur par defaut) |
|
| 111 | - |
|
| 112 | - $valeurs = [ |
|
| 113 | - 'var_login' => $login, |
|
| 114 | - 'editable' => !$row, |
|
| 115 | - 'cnx' => $row['cnx'] ?? '0', |
|
| 116 | - 'auth_http' => login_auth_http(), |
|
| 117 | - 'rester_connecte' => ((_RENOUVELLE_ALEA < 12 * 3600) ? '' : ' '), |
|
| 118 | - '_logo' => $row['logo'] ?? '', |
|
| 119 | - '_alea_actuel' => $row['alea_actuel'] ?? '', |
|
| 120 | - '_alea_futur' => $row['alea_futur'] ?? '', |
|
| 121 | - '_pipeline' => 'affiche_formulaire_login', // faire passer le formulaire dans un pipe dedie pour les methodes auth |
|
| 122 | - '_autofocus' => ($options['autofocus'] and $options['autofocus'] !== 'non') ? ' ' : '', |
|
| 123 | - ]; |
|
| 124 | - |
|
| 125 | - if ($erreur or !isset($GLOBALS['visiteur_session']['id_auteur']) or !$GLOBALS['visiteur_session']['id_auteur']) { |
|
| 126 | - $valeurs['editable'] = true; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 130 | - include_spip('inc/autoriser'); |
|
| 131 | - $loge = autoriser('ecrire'); |
|
| 132 | - } else { |
|
| 133 | - $loge = (isset($GLOBALS['visiteur_session']['auth']) and $GLOBALS['visiteur_session']['auth'] != ''); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // Si on est connecte, appeler traiter() |
|
| 137 | - // et lancer la redirection si besoin |
|
| 138 | - if (!$valeurs['editable'] and $loge and _request('formulaire_action') !== 'login') { |
|
| 139 | - $traiter = charger_fonction('traiter', 'formulaires/login'); |
|
| 140 | - $res = $traiter($cible, $login, $prive); |
|
| 141 | - $valeurs = array_merge($valeurs, $res); |
|
| 142 | - |
|
| 143 | - if (isset($res['redirect']) and $res['redirect']) { |
|
| 144 | - include_spip('inc/headers'); |
|
| 145 | - # preparer un lien pour quand redirige_formulaire ne fonctionne pas |
|
| 146 | - $m = redirige_formulaire($res['redirect']); |
|
| 147 | - $valeurs['_deja_loge'] = inserer_attribut( |
|
| 148 | - '<a>' . _T('login_par_ici') . "</a>$m", |
|
| 149 | - 'href', |
|
| 150 | - $res['redirect'] |
|
| 151 | - ); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - // en cas d'echec de cookie, inc_auth a renvoye vers le script de |
|
| 155 | - // pose de cookie ; s'il n'est pas la, c'est echec cookie |
|
| 156 | - // s'il est la, c'est probablement un bookmark sur bonjour=oui, |
|
| 157 | - // et pas un echec cookie. |
|
| 158 | - if ($erreur == 'cookie') { |
|
| 159 | - $valeurs['echec_cookie'] = ' '; |
|
| 160 | - } elseif ($erreur) { |
|
| 161 | - // une erreur d'un SSO indique dans la redirection vers ici |
|
| 162 | - // mais il faut se proteger de toute tentative d'injection malveilante |
|
| 163 | - include_spip('inc/filtres'); |
|
| 164 | - $valeurs['message_erreur'] = textebrut($erreur); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - return $valeurs; |
|
| 63 | + $erreur = _request('var_erreur'); |
|
| 64 | + |
|
| 65 | + if (!is_array($options)) { |
|
| 66 | + $options = [ |
|
| 67 | + 'login' => $options, |
|
| 68 | + 'prive' => $deprecated |
|
| 69 | + ]; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $login = (empty($options['login']) ? '' : $options['login']); |
|
| 73 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 74 | + // conserver le fonctionnement historique |
|
| 75 | + if (!isset($options['autofocus'])) { |
|
| 76 | + $options['autofocus'] = true; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + if (!$login) { |
|
| 80 | + $login = strval(_request('var_login')); |
|
| 81 | + } |
|
| 82 | + // si on est deja identifie |
|
| 83 | + if (!$login and isset($GLOBALS['visiteur_session']['email'])) { |
|
| 84 | + $login = $GLOBALS['visiteur_session']['email']; |
|
| 85 | + } |
|
| 86 | + if (!$login and isset($GLOBALS['visiteur_session']['login'])) { |
|
| 87 | + $login = $GLOBALS['visiteur_session']['login']; |
|
| 88 | + } |
|
| 89 | + // ou si on a un cookie admin |
|
| 90 | + if (!$login) { |
|
| 91 | + if ( |
|
| 92 | + isset($_COOKIE['spip_admin']) |
|
| 93 | + and preg_match(',^@(.*)$,', $_COOKIE['spip_admin'], $regs) |
|
| 94 | + ) { |
|
| 95 | + $login = $regs[1]; |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $lang = $GLOBALS['spip_lang']; |
|
| 100 | + include_spip('inc/auth'); |
|
| 101 | + $row = auth_informer_login($login); |
|
| 102 | + |
|
| 103 | + // retablir la langue de l'URL si forcee (on ignore la langue de l'auteur dans ce cas) |
|
| 104 | + if (_request('lang') === $lang and $GLOBALS['spip_lang'] !== $lang) { |
|
| 105 | + changer_langue($lang); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // Construire l'environnement du squelette |
|
| 109 | + // Ne pas proposer de "rester connecte quelques jours" |
|
| 110 | + // si la duree de l'alea est inferieure a 12 h (valeur par defaut) |
|
| 111 | + |
|
| 112 | + $valeurs = [ |
|
| 113 | + 'var_login' => $login, |
|
| 114 | + 'editable' => !$row, |
|
| 115 | + 'cnx' => $row['cnx'] ?? '0', |
|
| 116 | + 'auth_http' => login_auth_http(), |
|
| 117 | + 'rester_connecte' => ((_RENOUVELLE_ALEA < 12 * 3600) ? '' : ' '), |
|
| 118 | + '_logo' => $row['logo'] ?? '', |
|
| 119 | + '_alea_actuel' => $row['alea_actuel'] ?? '', |
|
| 120 | + '_alea_futur' => $row['alea_futur'] ?? '', |
|
| 121 | + '_pipeline' => 'affiche_formulaire_login', // faire passer le formulaire dans un pipe dedie pour les methodes auth |
|
| 122 | + '_autofocus' => ($options['autofocus'] and $options['autofocus'] !== 'non') ? ' ' : '', |
|
| 123 | + ]; |
|
| 124 | + |
|
| 125 | + if ($erreur or !isset($GLOBALS['visiteur_session']['id_auteur']) or !$GLOBALS['visiteur_session']['id_auteur']) { |
|
| 126 | + $valeurs['editable'] = true; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 130 | + include_spip('inc/autoriser'); |
|
| 131 | + $loge = autoriser('ecrire'); |
|
| 132 | + } else { |
|
| 133 | + $loge = (isset($GLOBALS['visiteur_session']['auth']) and $GLOBALS['visiteur_session']['auth'] != ''); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // Si on est connecte, appeler traiter() |
|
| 137 | + // et lancer la redirection si besoin |
|
| 138 | + if (!$valeurs['editable'] and $loge and _request('formulaire_action') !== 'login') { |
|
| 139 | + $traiter = charger_fonction('traiter', 'formulaires/login'); |
|
| 140 | + $res = $traiter($cible, $login, $prive); |
|
| 141 | + $valeurs = array_merge($valeurs, $res); |
|
| 142 | + |
|
| 143 | + if (isset($res['redirect']) and $res['redirect']) { |
|
| 144 | + include_spip('inc/headers'); |
|
| 145 | + # preparer un lien pour quand redirige_formulaire ne fonctionne pas |
|
| 146 | + $m = redirige_formulaire($res['redirect']); |
|
| 147 | + $valeurs['_deja_loge'] = inserer_attribut( |
|
| 148 | + '<a>' . _T('login_par_ici') . "</a>$m", |
|
| 149 | + 'href', |
|
| 150 | + $res['redirect'] |
|
| 151 | + ); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + // en cas d'echec de cookie, inc_auth a renvoye vers le script de |
|
| 155 | + // pose de cookie ; s'il n'est pas la, c'est echec cookie |
|
| 156 | + // s'il est la, c'est probablement un bookmark sur bonjour=oui, |
|
| 157 | + // et pas un echec cookie. |
|
| 158 | + if ($erreur == 'cookie') { |
|
| 159 | + $valeurs['echec_cookie'] = ' '; |
|
| 160 | + } elseif ($erreur) { |
|
| 161 | + // une erreur d'un SSO indique dans la redirection vers ici |
|
| 162 | + // mais il faut se proteger de toute tentative d'injection malveilante |
|
| 163 | + include_spip('inc/filtres'); |
|
| 164 | + $valeurs['message_erreur'] = textebrut($erreur); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + return $valeurs; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
@@ -179,20 +179,20 @@ discard block |
||
| 179 | 179 | * - chaîne vide sinon. |
| 180 | 180 | **/ |
| 181 | 181 | function login_auth_http() { |
| 182 | - if ( |
|
| 183 | - !$GLOBALS['ignore_auth_http'] |
|
| 184 | - and _request('var_erreur') == 'cookie' |
|
| 185 | - and (!isset($_COOKIE['spip_session']) or $_COOKIE['spip_session'] != 'test_echec_cookie') |
|
| 186 | - and (($GLOBALS['flag_sapi_name'] and preg_match(',apache,i', @php_sapi_name())) |
|
| 187 | - or preg_match(',^Apache.* PHP,', $_SERVER['SERVER_SOFTWARE'])) |
|
| 188 | - // Attention dans le cas 'intranet' la proposition de se loger |
|
| 189 | - // par auth_http peut conduire a l'echec. |
|
| 190 | - and !(isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) |
|
| 191 | - ) { |
|
| 192 | - return generer_url_action('cookie', '', false, true); |
|
| 193 | - } else { |
|
| 194 | - return ''; |
|
| 195 | - } |
|
| 182 | + if ( |
|
| 183 | + !$GLOBALS['ignore_auth_http'] |
|
| 184 | + and _request('var_erreur') == 'cookie' |
|
| 185 | + and (!isset($_COOKIE['spip_session']) or $_COOKIE['spip_session'] != 'test_echec_cookie') |
|
| 186 | + and (($GLOBALS['flag_sapi_name'] and preg_match(',apache,i', @php_sapi_name())) |
|
| 187 | + or preg_match(',^Apache.* PHP,', $_SERVER['SERVER_SOFTWARE'])) |
|
| 188 | + // Attention dans le cas 'intranet' la proposition de se loger |
|
| 189 | + // par auth_http peut conduire a l'echec. |
|
| 190 | + and !(isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW'])) |
|
| 191 | + ) { |
|
| 192 | + return generer_url_action('cookie', '', false, true); |
|
| 193 | + } else { |
|
| 194 | + return ''; |
|
| 195 | + } |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
@@ -218,65 +218,65 @@ discard block |
||
| 218 | 218 | **/ |
| 219 | 219 | function formulaires_login_verifier_dist($cible = '', $options = [], $deprecated = null) { |
| 220 | 220 | |
| 221 | - $erreurs = []; |
|
| 222 | - if (!is_array($options)) { |
|
| 223 | - $options = [ |
|
| 224 | - 'login' => $options, |
|
| 225 | - 'prive' => $deprecated |
|
| 226 | - ]; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 230 | - |
|
| 231 | - $session_login = _request('var_login'); |
|
| 232 | - $session_password = _request('password'); |
|
| 233 | - $session_remember = _request('session_remember'); |
|
| 234 | - |
|
| 235 | - if (!$session_login) { |
|
| 236 | - # pas de login saisi ! |
|
| 237 | - return ['var_login' => _T('info_obligatoire')]; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // appeler auth_identifier_login qui va : |
|
| 241 | - // - renvoyer un string si echec (message d'erreur) |
|
| 242 | - // - un array decrivant l'auteur identifie si possible |
|
| 243 | - // - rediriger vers un SSO qui renverra in fine sur action/auth qui finira l'authentification |
|
| 244 | - include_spip('inc/auth'); |
|
| 245 | - $auteur = auth_identifier_login($session_login, $session_password); |
|
| 246 | - // on arrive ici si on ne s'est pas identifie avec un SSO |
|
| 247 | - if (!is_array($auteur)) { |
|
| 248 | - $erreurs = []; |
|
| 249 | - if (is_string($auteur) and strlen($auteur)) { |
|
| 250 | - $erreurs['var_login'] = $auteur; |
|
| 251 | - } |
|
| 252 | - include_spip('inc/cookie'); |
|
| 253 | - spip_setcookie('spip_admin', '', time() - 3600); |
|
| 254 | - if (strlen($session_password)) { |
|
| 255 | - $erreurs['password'] = _T('login_erreur_pass'); |
|
| 256 | - } else { |
|
| 257 | - // sinon c'est un login en deux passe old style (ou js en panne) |
|
| 258 | - // pas de message d'erreur |
|
| 259 | - $erreurs['password'] = ' '; |
|
| 260 | - $erreurs['message_erreur'] = ''; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - return |
|
| 264 | - $erreurs; |
|
| 265 | - } |
|
| 266 | - // on a ete authentifie, construire la session |
|
| 267 | - // en gerant la duree demandee pour son cookie |
|
| 268 | - if ($session_remember !== null) { |
|
| 269 | - $auteur['cookie'] = $session_remember; |
|
| 270 | - } |
|
| 271 | - // si la connexion est refusee on renvoi un message erreur de mot de passe |
|
| 272 | - // car en donnant plus de detail on renseignerait un assaillant sur l'existence d'un compte |
|
| 273 | - if (auth_loger($auteur) === false) { |
|
| 274 | - $erreurs['message_erreur'] = _T('login_erreur_pass'); |
|
| 275 | - return $erreurs; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - return (is_null($prive) ? is_url_prive($cible) : $prive) |
|
| 279 | - ? login_autoriser() : []; |
|
| 221 | + $erreurs = []; |
|
| 222 | + if (!is_array($options)) { |
|
| 223 | + $options = [ |
|
| 224 | + 'login' => $options, |
|
| 225 | + 'prive' => $deprecated |
|
| 226 | + ]; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 230 | + |
|
| 231 | + $session_login = _request('var_login'); |
|
| 232 | + $session_password = _request('password'); |
|
| 233 | + $session_remember = _request('session_remember'); |
|
| 234 | + |
|
| 235 | + if (!$session_login) { |
|
| 236 | + # pas de login saisi ! |
|
| 237 | + return ['var_login' => _T('info_obligatoire')]; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // appeler auth_identifier_login qui va : |
|
| 241 | + // - renvoyer un string si echec (message d'erreur) |
|
| 242 | + // - un array decrivant l'auteur identifie si possible |
|
| 243 | + // - rediriger vers un SSO qui renverra in fine sur action/auth qui finira l'authentification |
|
| 244 | + include_spip('inc/auth'); |
|
| 245 | + $auteur = auth_identifier_login($session_login, $session_password); |
|
| 246 | + // on arrive ici si on ne s'est pas identifie avec un SSO |
|
| 247 | + if (!is_array($auteur)) { |
|
| 248 | + $erreurs = []; |
|
| 249 | + if (is_string($auteur) and strlen($auteur)) { |
|
| 250 | + $erreurs['var_login'] = $auteur; |
|
| 251 | + } |
|
| 252 | + include_spip('inc/cookie'); |
|
| 253 | + spip_setcookie('spip_admin', '', time() - 3600); |
|
| 254 | + if (strlen($session_password)) { |
|
| 255 | + $erreurs['password'] = _T('login_erreur_pass'); |
|
| 256 | + } else { |
|
| 257 | + // sinon c'est un login en deux passe old style (ou js en panne) |
|
| 258 | + // pas de message d'erreur |
|
| 259 | + $erreurs['password'] = ' '; |
|
| 260 | + $erreurs['message_erreur'] = ''; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + return |
|
| 264 | + $erreurs; |
|
| 265 | + } |
|
| 266 | + // on a ete authentifie, construire la session |
|
| 267 | + // en gerant la duree demandee pour son cookie |
|
| 268 | + if ($session_remember !== null) { |
|
| 269 | + $auteur['cookie'] = $session_remember; |
|
| 270 | + } |
|
| 271 | + // si la connexion est refusee on renvoi un message erreur de mot de passe |
|
| 272 | + // car en donnant plus de detail on renseignerait un assaillant sur l'existence d'un compte |
|
| 273 | + if (auth_loger($auteur) === false) { |
|
| 274 | + $erreurs['message_erreur'] = _T('login_erreur_pass'); |
|
| 275 | + return $erreurs; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + return (is_null($prive) ? is_url_prive($cible) : $prive) |
|
| 279 | + ? login_autoriser() : []; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -291,21 +291,21 @@ discard block |
||
| 291 | 291 | * - tableau vide sinon. |
| 292 | 292 | **/ |
| 293 | 293 | function login_autoriser() { |
| 294 | - include_spip('inc/autoriser'); |
|
| 295 | - if (!autoriser('ecrire')) { |
|
| 296 | - $h = generer_url_action('logout', 'logout=prive&url=' . urlencode(self())); |
|
| 297 | - |
|
| 298 | - return [ |
|
| 299 | - 'message_erreur' => '<h1>' |
|
| 300 | - . _T('avis_erreur_visiteur') |
|
| 301 | - . '</h1><p>' |
|
| 302 | - . _T('texte_erreur_visiteur') |
|
| 303 | - . "</p><p class='retour'>[<a href='$h'>" |
|
| 304 | - . _T('icone_deconnecter') . '</a>]</p>' |
|
| 305 | - ]; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - return []; |
|
| 294 | + include_spip('inc/autoriser'); |
|
| 295 | + if (!autoriser('ecrire')) { |
|
| 296 | + $h = generer_url_action('logout', 'logout=prive&url=' . urlencode(self())); |
|
| 297 | + |
|
| 298 | + return [ |
|
| 299 | + 'message_erreur' => '<h1>' |
|
| 300 | + . _T('avis_erreur_visiteur') |
|
| 301 | + . '</h1><p>' |
|
| 302 | + . _T('texte_erreur_visiteur') |
|
| 303 | + . "</p><p class='retour'>[<a href='$h'>" |
|
| 304 | + . _T('icone_deconnecter') . '</a>]</p>' |
|
| 305 | + ]; |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + return []; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -326,55 +326,55 @@ discard block |
||
| 326 | 326 | * Retours du traitement |
| 327 | 327 | **/ |
| 328 | 328 | function formulaires_login_traiter_dist($cible = '', $options = [], $deprecated = null) { |
| 329 | - $res = []; |
|
| 330 | - |
|
| 331 | - if (!is_array($options)) { |
|
| 332 | - $options = [ |
|
| 333 | - 'login' => $options, |
|
| 334 | - 'prive' => $deprecated |
|
| 335 | - ]; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - $login = (empty($options['login']) ? '' : $options['login']); |
|
| 339 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 340 | - |
|
| 341 | - // Si on se connecte dans l'espace prive, |
|
| 342 | - // ajouter "bonjour" (repere a peu pres les cookies desactives) |
|
| 343 | - if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 344 | - $cible = parametre_url($cible, 'bonjour', 'oui', '&'); |
|
| 345 | - } |
|
| 346 | - if ($cible == '@page_auteur') { |
|
| 347 | - $cible = generer_objet_url($GLOBALS['auteur_session']['id_auteur'], 'auteur'); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - if ($cible) { |
|
| 351 | - $cible = parametre_url($cible, 'var_login', '', '&'); |
|
| 352 | - |
|
| 353 | - // transformer la cible absolue en cible relative |
|
| 354 | - // pour pas echouer quand la meta adresse_site est foireuse |
|
| 355 | - if (strncmp($cible, $u = url_de_base(), strlen($u)) == 0) { |
|
| 356 | - $cible = './' . substr($cible, strlen($u)); |
|
| 357 | - } elseif (tester_url_absolue($cible) and !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) { |
|
| 358 | - // si c'est une url absolue, refuser la redirection |
|
| 359 | - // sauf si cette securite est levee volontairement par le webmestre |
|
| 360 | - $cible = ''; |
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - // Si on est connecte, envoyer vers la destination |
|
| 365 | - if ($cible and ($cible != self('&')) and ($cible != self())) { |
|
| 366 | - $res['redirect'] = $cible; |
|
| 367 | - $res['message_ok'] = inserer_attribut( |
|
| 368 | - '<a>' . _T('login_par_ici') . '</a>', |
|
| 369 | - 'href', |
|
| 370 | - $cible |
|
| 371 | - ); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - // avant de rediriger il faut mettre a jour les sessions sur le disque si on a charge une session |
|
| 375 | - if (function_exists('terminer_actualiser_sessions')) { |
|
| 376 | - terminer_actualiser_sessions(); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - return $res; |
|
| 329 | + $res = []; |
|
| 330 | + |
|
| 331 | + if (!is_array($options)) { |
|
| 332 | + $options = [ |
|
| 333 | + 'login' => $options, |
|
| 334 | + 'prive' => $deprecated |
|
| 335 | + ]; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + $login = (empty($options['login']) ? '' : $options['login']); |
|
| 339 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 340 | + |
|
| 341 | + // Si on se connecte dans l'espace prive, |
|
| 342 | + // ajouter "bonjour" (repere a peu pres les cookies desactives) |
|
| 343 | + if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 344 | + $cible = parametre_url($cible, 'bonjour', 'oui', '&'); |
|
| 345 | + } |
|
| 346 | + if ($cible == '@page_auteur') { |
|
| 347 | + $cible = generer_objet_url($GLOBALS['auteur_session']['id_auteur'], 'auteur'); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + if ($cible) { |
|
| 351 | + $cible = parametre_url($cible, 'var_login', '', '&'); |
|
| 352 | + |
|
| 353 | + // transformer la cible absolue en cible relative |
|
| 354 | + // pour pas echouer quand la meta adresse_site est foireuse |
|
| 355 | + if (strncmp($cible, $u = url_de_base(), strlen($u)) == 0) { |
|
| 356 | + $cible = './' . substr($cible, strlen($u)); |
|
| 357 | + } elseif (tester_url_absolue($cible) and !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) { |
|
| 358 | + // si c'est une url absolue, refuser la redirection |
|
| 359 | + // sauf si cette securite est levee volontairement par le webmestre |
|
| 360 | + $cible = ''; |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + // Si on est connecte, envoyer vers la destination |
|
| 365 | + if ($cible and ($cible != self('&')) and ($cible != self())) { |
|
| 366 | + $res['redirect'] = $cible; |
|
| 367 | + $res['message_ok'] = inserer_attribut( |
|
| 368 | + '<a>' . _T('login_par_ici') . '</a>', |
|
| 369 | + 'href', |
|
| 370 | + $cible |
|
| 371 | + ); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + // avant de rediriger il faut mettre a jour les sessions sur le disque si on a charge une session |
|
| 375 | + if (function_exists('terminer_actualiser_sessions')) { |
|
| 376 | + terminer_actualiser_sessions(); |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + return $res; |
|
| 380 | 380 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * Pile complétée du code compilé |
| 43 | 43 | **/ |
| 44 | 44 | function balise_FORMULAIRE_ADMIN($p) { |
| 45 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []); |
|
| 45 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * - chaîne vide sinon. |
| 60 | 60 | */ |
| 61 | 61 | function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) { |
| 62 | - return $args; |
|
| 62 | + return $args; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -84,66 +84,66 @@ discard block |
||
| 84 | 84 | **/ |
| 85 | 85 | function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') { |
| 86 | 86 | |
| 87 | - static $dejafait = false; |
|
| 87 | + static $dejafait = false; |
|
| 88 | 88 | |
| 89 | - if (empty($_COOKIE['spip_admin'])) { |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 89 | + if (empty($_COOKIE['spip_admin'])) { |
|
| 90 | + return ''; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if (!is_array($debug)) { |
|
| 94 | - if ($dejafait) { |
|
| 95 | - return ''; |
|
| 96 | - } |
|
| 97 | - } else { |
|
| 98 | - if ($dejafait) { |
|
| 99 | - if (empty($debug['sourcefile'])) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - foreach ($debug['sourcefile'] as $k => $v) { |
|
| 103 | - if (strpos($v, 'administration.') !== false) { |
|
| 104 | - if (isset($debug['resultat'][$k . 'tout'])) { |
|
| 105 | - return $debug['resultat'][$k . 'tout']; |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 93 | + if (!is_array($debug)) { |
|
| 94 | + if ($dejafait) { |
|
| 95 | + return ''; |
|
| 96 | + } |
|
| 97 | + } else { |
|
| 98 | + if ($dejafait) { |
|
| 99 | + if (empty($debug['sourcefile'])) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + foreach ($debug['sourcefile'] as $k => $v) { |
|
| 103 | + if (strpos($v, 'administration.') !== false) { |
|
| 104 | + if (isset($debug['resultat'][$k . 'tout'])) { |
|
| 105 | + return $debug['resultat'][$k . 'tout']; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - return ''; |
|
| 111 | - } |
|
| 112 | - } |
|
| 110 | + return ''; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - include_spip('inc/autoriser'); |
|
| 115 | - include_spip('base/abstract_sql'); |
|
| 114 | + include_spip('inc/autoriser'); |
|
| 115 | + include_spip('base/abstract_sql'); |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | - $dejafait = true; |
|
| 118 | + $dejafait = true; |
|
| 119 | 119 | |
| 120 | - // Preparer le #ENV des boutons |
|
| 120 | + // Preparer le #ENV des boutons |
|
| 121 | 121 | |
| 122 | - $env = admin_objet(); |
|
| 122 | + $env = admin_objet(); |
|
| 123 | 123 | |
| 124 | - // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
|
| 125 | - if (!$env) { |
|
| 126 | - $env['ecrire'] = _DIR_RESTREINT_ABS; |
|
| 127 | - } |
|
| 124 | + // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
|
| 125 | + if (!$env) { |
|
| 126 | + $env['ecrire'] = _DIR_RESTREINT_ABS; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - $env['divclass'] = $float; |
|
| 130 | - $env['lang'] = admin_lang(); |
|
| 131 | - $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); |
|
| 132 | - $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug()); |
|
| 133 | - $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider(); |
|
| 134 | - $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : ''); |
|
| 129 | + $env['divclass'] = $float; |
|
| 130 | + $env['lang'] = admin_lang(); |
|
| 131 | + $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); |
|
| 132 | + $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug()); |
|
| 133 | + $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider(); |
|
| 134 | + $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : ''); |
|
| 135 | 135 | |
| 136 | - if (empty($GLOBALS['use_cache'])) { |
|
| 137 | - $env['use_cache'] = ' *'; |
|
| 138 | - } |
|
| 136 | + if (empty($GLOBALS['use_cache'])) { |
|
| 137 | + $env['use_cache'] = ' *'; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - if (isset($debug['validation'])) { |
|
| 141 | - $env['xhtml_error'] = $debug['validation']; |
|
| 142 | - } |
|
| 140 | + if (isset($debug['validation'])) { |
|
| 141 | + $env['xhtml_error'] = $debug['validation']; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - $env['_pipelines']['formulaire_admin'] = []; |
|
| 144 | + $env['_pipelines']['formulaire_admin'] = []; |
|
| 145 | 145 | |
| 146 | - return ['formulaires/administration', 0, $env]; |
|
| 146 | + return ['formulaires/administration', 0, $env]; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -161,47 +161,47 @@ discard block |
||
| 161 | 161 | * Tableau de l'environnement calculé |
| 162 | 162 | **/ |
| 163 | 163 | function admin_objet() { |
| 164 | - include_spip('inc/urls'); |
|
| 165 | - $env = []; |
|
| 166 | - |
|
| 167 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 168 | - $objets = urls_liste_objets(false); |
|
| 169 | - $objets = array_diff($objets, ['rubrique']); |
|
| 170 | - $objets = array_reverse($objets); |
|
| 171 | - array_unshift($objets, 'rubrique'); |
|
| 172 | - foreach ($objets as $obj) { |
|
| 173 | - $type = $obj; |
|
| 174 | - if ( |
|
| 175 | - $type == objet_type($type, false) |
|
| 176 | - and $_id_type = id_table_objet($type) |
|
| 177 | - and isset($GLOBALS['contexte'][$_id_type]) |
|
| 178 | - and $id = $GLOBALS['contexte'][$_id_type] |
|
| 179 | - and !is_array($id) |
|
| 180 | - and $id = intval($id) |
|
| 181 | - and $desc = $trouver_table(table_objet_sql($type)) |
|
| 182 | - ) { |
|
| 183 | - $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id)); |
|
| 184 | - if ($id) { |
|
| 185 | - $env[$_id_type] = $id; |
|
| 186 | - $env['objet'] = $type; |
|
| 187 | - $env['id_objet'] = $id; |
|
| 188 | - $env['voir_' . $obj] = |
|
| 189 | - str_replace('&', '&', generer_objet_url($id, $obj, '', '', false)); |
|
| 190 | - if ( |
|
| 191 | - isset($desc['field']['id_rubrique']) |
|
| 192 | - and $type != 'rubrique' |
|
| 193 | - ) { |
|
| 194 | - unset($env['id_rubrique']); |
|
| 195 | - unset($env['voir_rubrique']); |
|
| 196 | - if (admin_preview($type, $id, $desc)) { |
|
| 197 | - $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&'); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - return $env; |
|
| 164 | + include_spip('inc/urls'); |
|
| 165 | + $env = []; |
|
| 166 | + |
|
| 167 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 168 | + $objets = urls_liste_objets(false); |
|
| 169 | + $objets = array_diff($objets, ['rubrique']); |
|
| 170 | + $objets = array_reverse($objets); |
|
| 171 | + array_unshift($objets, 'rubrique'); |
|
| 172 | + foreach ($objets as $obj) { |
|
| 173 | + $type = $obj; |
|
| 174 | + if ( |
|
| 175 | + $type == objet_type($type, false) |
|
| 176 | + and $_id_type = id_table_objet($type) |
|
| 177 | + and isset($GLOBALS['contexte'][$_id_type]) |
|
| 178 | + and $id = $GLOBALS['contexte'][$_id_type] |
|
| 179 | + and !is_array($id) |
|
| 180 | + and $id = intval($id) |
|
| 181 | + and $desc = $trouver_table(table_objet_sql($type)) |
|
| 182 | + ) { |
|
| 183 | + $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id)); |
|
| 184 | + if ($id) { |
|
| 185 | + $env[$_id_type] = $id; |
|
| 186 | + $env['objet'] = $type; |
|
| 187 | + $env['id_objet'] = $id; |
|
| 188 | + $env['voir_' . $obj] = |
|
| 189 | + str_replace('&', '&', generer_objet_url($id, $obj, '', '', false)); |
|
| 190 | + if ( |
|
| 191 | + isset($desc['field']['id_rubrique']) |
|
| 192 | + and $type != 'rubrique' |
|
| 193 | + ) { |
|
| 194 | + unset($env['id_rubrique']); |
|
| 195 | + unset($env['voir_rubrique']); |
|
| 196 | + if (admin_preview($type, $id, $desc)) { |
|
| 197 | + $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&'); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + return $env; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | |
@@ -219,30 +219,30 @@ discard block |
||
| 219 | 219 | * - Tableau d'un élément sinon. |
| 220 | 220 | **/ |
| 221 | 221 | function admin_preview($type, $id, $desc = null) { |
| 222 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) { |
|
| 223 | - return ''; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - if (!$desc) { |
|
| 227 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 228 | - $desc = $trouver_table(table_objet_sql($type)); |
|
| 229 | - } |
|
| 230 | - if (!$desc or !isset($desc['field']['statut'])) { |
|
| 231 | - return ''; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - include_spip('inc/autoriser'); |
|
| 235 | - if (!autoriser('previsualiser')) { |
|
| 236 | - return ''; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $notpub = sql_in('statut', ['prop', 'prive']); |
|
| 240 | - |
|
| 241 | - if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') { |
|
| 242 | - $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 222 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) { |
|
| 223 | + return ''; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + if (!$desc) { |
|
| 227 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 228 | + $desc = $trouver_table(table_objet_sql($type)); |
|
| 229 | + } |
|
| 230 | + if (!$desc or !isset($desc['field']['statut'])) { |
|
| 231 | + return ''; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + include_spip('inc/autoriser'); |
|
| 235 | + if (!autoriser('previsualiser')) { |
|
| 236 | + return ''; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $notpub = sql_in('statut', ['prop', 'prive']); |
|
| 240 | + |
|
| 241 | + if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') { |
|
| 242 | + $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -253,25 +253,25 @@ discard block |
||
| 253 | 253 | * Code de langue |
| 254 | 254 | **/ |
| 255 | 255 | function admin_lang() { |
| 256 | - $alang = ''; |
|
| 257 | - if (!empty($_COOKIE['spip_admin'])) { |
|
| 258 | - $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']); |
|
| 259 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 260 | - if (!$alang) { |
|
| 261 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - if (!$alang) { |
|
| 265 | - return ''; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - $l = lang_select($alang); |
|
| 269 | - $alang = $GLOBALS['spip_lang']; |
|
| 270 | - if ($l) { |
|
| 271 | - lang_select(); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - return $alang; |
|
| 256 | + $alang = ''; |
|
| 257 | + if (!empty($_COOKIE['spip_admin'])) { |
|
| 258 | + $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']); |
|
| 259 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 260 | + if (!$alang) { |
|
| 261 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + if (!$alang) { |
|
| 265 | + return ''; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + $l = lang_select($alang); |
|
| 269 | + $alang = $GLOBALS['spip_lang']; |
|
| 270 | + if ($l) { |
|
| 271 | + lang_select(); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + return $alang; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -281,11 +281,11 @@ discard block |
||
| 281 | 281 | **/ |
| 282 | 282 | function admin_valider() { |
| 283 | 283 | |
| 284 | - return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ? |
|
| 285 | - (parametre_url(self(), 'var_mode', 'debug', '&') |
|
| 286 | - . '&var_mode_affiche=validation') : |
|
| 287 | - ('http://validator.w3.org/check?uri=' |
|
| 288 | - . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 284 | + return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ? |
|
| 285 | + (parametre_url(self(), 'var_mode', 'debug', '&') |
|
| 286 | + . '&var_mode_affiche=validation') : |
|
| 287 | + ('http://validator.w3.org/check?uri=' |
|
| 288 | + . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | * @return string |
| 295 | 295 | **/ |
| 296 | 296 | function admin_debug() { |
| 297 | - return (( |
|
| 298 | - (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug']) |
|
| 299 | - or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug']) |
|
| 300 | - or ( |
|
| 301 | - defined('_VAR_MODE') and _VAR_MODE == 'debug' |
|
| 302 | - and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug'] |
|
| 303 | - ) |
|
| 304 | - ) and autoriser('debug') |
|
| 305 | - ) |
|
| 306 | - ? parametre_url(self(), 'var_mode', 'debug', '&') : ''; |
|
| 297 | + return (( |
|
| 298 | + (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug']) |
|
| 299 | + or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug']) |
|
| 300 | + or ( |
|
| 301 | + defined('_VAR_MODE') and _VAR_MODE == 'debug' |
|
| 302 | + and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug'] |
|
| 303 | + ) |
|
| 304 | + ) and autoriser('debug') |
|
| 305 | + ) |
|
| 306 | + ? parametre_url(self(), 'var_mode', 'debug', '&') : ''; |
|
| 307 | 307 | } |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | foreach ($debug['sourcefile'] as $k => $v) { |
| 103 | 103 | if (strpos($v, 'administration.') !== false) { |
| 104 | - if (isset($debug['resultat'][$k . 'tout'])) { |
|
| 105 | - return $debug['resultat'][$k . 'tout']; |
|
| 104 | + if (isset($debug['resultat'][$k.'tout'])) { |
|
| 105 | + return $debug['resultat'][$k.'tout']; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | and $id = intval($id) |
| 181 | 181 | and $desc = $trouver_table(table_objet_sql($type)) |
| 182 | 182 | ) { |
| 183 | - $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id)); |
|
| 183 | + $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=".intval($id)); |
|
| 184 | 184 | if ($id) { |
| 185 | 185 | $env[$_id_type] = $id; |
| 186 | 186 | $env['objet'] = $type; |
| 187 | 187 | $env['id_objet'] = $id; |
| 188 | - $env['voir_' . $obj] = |
|
| 188 | + $env['voir_'.$obj] = |
|
| 189 | 189 | str_replace('&', '&', generer_objet_url($id, $obj, '', '', false)); |
| 190 | 190 | if ( |
| 191 | 191 | isset($desc['field']['id_rubrique']) |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | $notpub = sql_in('statut', ['prop', 'prive']); |
| 240 | 240 | |
| 241 | 241 | if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') { |
| 242 | - $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 242 | + $notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).')'; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 245 | + return sql_fetsel('1', table_objet_sql($type), id_table_objet($type).'='.$id." AND ($notpub)"); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | $alang = ''; |
| 257 | 257 | if (!empty($_COOKIE['spip_admin'])) { |
| 258 | 258 | $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']); |
| 259 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 259 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'email='.sql_quote($email_or_login)); |
|
| 260 | 260 | if (!$alang) { |
| 261 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 261 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'login='.sql_quote($email_or_login)); |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | if (!$alang) { |
@@ -283,9 +283,8 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ? |
| 285 | 285 | (parametre_url(self(), 'var_mode', 'debug', '&') |
| 286 | - . '&var_mode_affiche=validation') : |
|
| 287 | - ('http://validator.w3.org/check?uri=' |
|
| 288 | - . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 286 | + . '&var_mode_affiche=validation') : ('http://validator.w3.org/check?uri=' |
|
| 287 | + . rawurlencode('http://'.$_SERVER['HTTP_HOST'].nettoyer_uri()))); |
|
| 289 | 288 | } |
| 290 | 289 | |
| 291 | 290 | /** |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Formulaires |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres'); |
@@ -35,22 +35,22 @@ discard block |
||
| 35 | 35 | * Saisie protégée |
| 36 | 36 | **/ |
| 37 | 37 | function protege_champ($texte) { |
| 38 | - if (is_array($texte)) { |
|
| 39 | - return array_map('protege_champ', $texte); |
|
| 40 | - } elseif ($texte === null) { |
|
| 41 | - return $texte; |
|
| 42 | - } elseif (is_bool($texte)) { |
|
| 43 | - return $texte ? '1' : ''; |
|
| 44 | - } elseif (is_string($texte) and $texte) { |
|
| 45 | - if (preg_match(',^[abis]:\d+[:;],', $texte) and @unserialize($texte) !== false) { |
|
| 46 | - // ne pas corrompre une valeur serialize |
|
| 47 | - return $texte; |
|
| 48 | - } elseif (strpbrk($texte, "&\"'<>") !== false) { |
|
| 49 | - return spip_htmlspecialchars($texte, ENT_QUOTES); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return $texte; |
|
| 38 | + if (is_array($texte)) { |
|
| 39 | + return array_map('protege_champ', $texte); |
|
| 40 | + } elseif ($texte === null) { |
|
| 41 | + return $texte; |
|
| 42 | + } elseif (is_bool($texte)) { |
|
| 43 | + return $texte ? '1' : ''; |
|
| 44 | + } elseif (is_string($texte) and $texte) { |
|
| 45 | + if (preg_match(',^[abis]:\d+[:;],', $texte) and @unserialize($texte) !== false) { |
|
| 46 | + // ne pas corrompre une valeur serialize |
|
| 47 | + return $texte; |
|
| 48 | + } elseif (strpbrk($texte, "&\"'<>") !== false) { |
|
| 49 | + return spip_htmlspecialchars($texte, ENT_QUOTES); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return $texte; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -64,17 +64,17 @@ discard block |
||
| 64 | 64 | * - false : pas de squelette trouvé |
| 65 | 65 | **/ |
| 66 | 66 | function existe_formulaire($form) { |
| 67 | - if (substr($form, 0, 11) == 'FORMULAIRE_') { |
|
| 68 | - $form = strtolower(substr($form, 11)); |
|
| 69 | - } else { |
|
| 70 | - $form = strtolower($form); |
|
| 71 | - } |
|
| 67 | + if (substr($form, 0, 11) == 'FORMULAIRE_') { |
|
| 68 | + $form = strtolower(substr($form, 11)); |
|
| 69 | + } else { |
|
| 70 | + $form = strtolower($form); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if (!$form) { |
|
| 74 | - return ''; |
|
| 75 | - } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 73 | + if (!$form) { |
|
| 74 | + return ''; |
|
| 75 | + } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 76 | 76 | |
| 77 | - return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 77 | + return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,31 +83,31 @@ discard block |
||
| 83 | 83 | * @return false|array |
| 84 | 84 | */ |
| 85 | 85 | function test_formulaire_inclus_par_modele() { |
| 86 | - $trace = debug_backtrace(null, 20); |
|
| 87 | - $trace_fonctions = array_column($trace, 'function'); |
|
| 88 | - $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 89 | - |
|
| 90 | - // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 91 | - if ( |
|
| 92 | - function_exists('arguments_balise_dyn_depuis_modele') |
|
| 93 | - and $form = arguments_balise_dyn_depuis_modele(null, 'read') |
|
| 94 | - ) { |
|
| 95 | - if (in_array('balise_formulaire__dyn', $trace_fonctions)) { |
|
| 96 | - $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 97 | - if ($trace[$k]['args'][0] === $form) { |
|
| 98 | - return $trace[$k]['args']; |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 104 | - // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 105 | - if (in_array('eval', $trace_fonctions) and in_array('inclure_modele', $trace_fonctions)) { |
|
| 106 | - $k = array_search('inclure_modele', $trace_fonctions); |
|
| 107 | - // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 108 | - return $trace[$k - 1]['args'][1]['args']; |
|
| 109 | - } |
|
| 110 | - return false; |
|
| 86 | + $trace = debug_backtrace(null, 20); |
|
| 87 | + $trace_fonctions = array_column($trace, 'function'); |
|
| 88 | + $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 89 | + |
|
| 90 | + // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 91 | + if ( |
|
| 92 | + function_exists('arguments_balise_dyn_depuis_modele') |
|
| 93 | + and $form = arguments_balise_dyn_depuis_modele(null, 'read') |
|
| 94 | + ) { |
|
| 95 | + if (in_array('balise_formulaire__dyn', $trace_fonctions)) { |
|
| 96 | + $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 97 | + if ($trace[$k]['args'][0] === $form) { |
|
| 98 | + return $trace[$k]['args']; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 104 | + // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 105 | + if (in_array('eval', $trace_fonctions) and in_array('inclure_modele', $trace_fonctions)) { |
|
| 106 | + $k = array_search('inclure_modele', $trace_fonctions); |
|
| 107 | + // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 108 | + return $trace[$k - 1]['args'][1]['args']; |
|
| 109 | + } |
|
| 110 | + return false; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -122,32 +122,32 @@ discard block |
||
| 122 | 122 | **/ |
| 123 | 123 | function balise_FORMULAIRE__dist($p) { |
| 124 | 124 | |
| 125 | - // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 126 | - // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 127 | - if (existe_formulaire($p->nom_champ) === false) { |
|
| 128 | - $p->code = "''"; |
|
| 129 | - $p->interdire_scripts = false; |
|
| 130 | - |
|
| 131 | - return $p; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // sinon renvoyer un code php dynamique |
|
| 135 | - $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 136 | - |
|
| 137 | - if ( |
|
| 138 | - !test_espace_prive() |
|
| 139 | - and !empty($p->descr['sourcefile']) |
|
| 140 | - and $f = $p->descr['sourcefile'] |
|
| 141 | - and basename(dirname($f)) === 'modeles' |
|
| 142 | - ) { |
|
| 143 | - // un modele est toujours inséré en texte dans son contenant |
|
| 144 | - // donc si on est dans le public avec un cache on va perdre le dynamisme |
|
| 145 | - // et on risque de mettre en cache les valeurs pre-remplies du formulaire |
|
| 146 | - // on injecte donc le PHP qui va appeler la fonction pour generer le formulaire au lieu de directement la fonction |
|
| 147 | - $p->code = "'<'.'?php echo (" . texte_script($p->code) . "); ?'.'>'"; |
|
| 148 | - // dans l'espace prive on a pas de cache, donc pas de soucis (et un leak serait moins grave) |
|
| 149 | - } |
|
| 150 | - return $p; |
|
| 125 | + // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 126 | + // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 127 | + if (existe_formulaire($p->nom_champ) === false) { |
|
| 128 | + $p->code = "''"; |
|
| 129 | + $p->interdire_scripts = false; |
|
| 130 | + |
|
| 131 | + return $p; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // sinon renvoyer un code php dynamique |
|
| 135 | + $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 136 | + |
|
| 137 | + if ( |
|
| 138 | + !test_espace_prive() |
|
| 139 | + and !empty($p->descr['sourcefile']) |
|
| 140 | + and $f = $p->descr['sourcefile'] |
|
| 141 | + and basename(dirname($f)) === 'modeles' |
|
| 142 | + ) { |
|
| 143 | + // un modele est toujours inséré en texte dans son contenant |
|
| 144 | + // donc si on est dans le public avec un cache on va perdre le dynamisme |
|
| 145 | + // et on risque de mettre en cache les valeurs pre-remplies du formulaire |
|
| 146 | + // on injecte donc le PHP qui va appeler la fonction pour generer le formulaire au lieu de directement la fonction |
|
| 147 | + $p->code = "'<'.'?php echo (" . texte_script($p->code) . "); ?'.'>'"; |
|
| 148 | + // dans l'espace prive on a pas de cache, donc pas de soucis (et un leak serait moins grave) |
|
| 149 | + } |
|
| 150 | + return $p; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -167,17 +167,17 @@ discard block |
||
| 167 | 167 | * - string : texte à afficher directement |
| 168 | 168 | */ |
| 169 | 169 | function balise_FORMULAIRE__dyn($form, ...$args) { |
| 170 | - $form = existe_formulaire($form); |
|
| 171 | - if (!$form) { |
|
| 172 | - return ''; |
|
| 173 | - } |
|
| 170 | + $form = existe_formulaire($form); |
|
| 171 | + if (!$form) { |
|
| 172 | + return ''; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 176 | - if (!is_array($contexte)) { |
|
| 177 | - return $contexte; |
|
| 178 | - } |
|
| 175 | + $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 176 | + if (!is_array($contexte)) { |
|
| 177 | + return $contexte; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - return ["formulaires/$form", 3600, $contexte]; |
|
| 180 | + return ["formulaires/$form", 3600, $contexte]; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -191,84 +191,84 @@ discard block |
||
| 191 | 191 | * Contexte d'environnement à envoyer au squelette |
| 192 | 192 | **/ |
| 193 | 193 | function balise_FORMULAIRE__contexte($form, $args) { |
| 194 | - // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 195 | - // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 196 | - // si poste, on recupere les erreurs |
|
| 197 | - |
|
| 198 | - $je_suis_poste = false; |
|
| 199 | - if ( |
|
| 200 | - $post_form = _request('formulaire_action') |
|
| 201 | - and $post_form == $form |
|
| 202 | - and $p = _request('formulaire_action_args') |
|
| 203 | - and is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 204 | - ) { |
|
| 205 | - // enlever le faux attribut de langue masque |
|
| 206 | - array_shift($p); |
|
| 207 | - if (formulaire__identifier($form, $args, $p)) { |
|
| 208 | - $je_suis_poste = true; |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $editable = true; |
|
| 213 | - $erreurs = $post = []; |
|
| 214 | - if ($je_suis_poste) { |
|
| 215 | - $post = traiter_formulaires_dynamiques(true); |
|
| 216 | - $e = "erreurs_$form"; |
|
| 217 | - $erreurs = $post[$e] ?? []; |
|
| 218 | - $editable = "editable_$form"; |
|
| 219 | - $editable = (!isset($post[$e])) |
|
| 220 | - || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 221 | - || (isset($post[$editable]) && $post[$editable]); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 225 | - |
|
| 226 | - // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 227 | - // C'est plus fort qu'editable qui est gere par le squelette |
|
| 228 | - // Idealement $valeur doit etre alors un message explicatif. |
|
| 229 | - if (!is_array($valeurs)) { |
|
| 230 | - return is_string($valeurs) ? $valeurs : ''; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 234 | - // ou une action vide si elle ne sert pas |
|
| 235 | - $action = $valeurs['action'] ?? self('&', true); |
|
| 236 | - // bug IEx : si action finit par / |
|
| 237 | - // IE croit que le <form ... action=../ > est autoferme |
|
| 238 | - if (substr($action, -1) == '/') { |
|
| 239 | - // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 240 | - $action .= '#'; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - // recuperer la saisie en cours si erreurs |
|
| 244 | - // seulement si c'est ce formulaire qui est poste |
|
| 245 | - // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 246 | - $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 247 | - foreach (array_keys($valeurs) as $champ) { |
|
| 248 | - if ($champ[0] !== '_' and !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 249 | - if ($dispo and (($v = _request($champ)) !== null)) { |
|
| 250 | - $valeurs[$champ] = $v; |
|
| 251 | - } |
|
| 252 | - // nettoyer l'url des champs qui vont etre saisis |
|
| 253 | - if ($action) { |
|
| 254 | - $action = parametre_url($action, $champ, ''); |
|
| 255 | - } |
|
| 256 | - // proteger les ' et les " dans les champs que l'on va injecter |
|
| 257 | - $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - if ($action) { |
|
| 262 | - // nettoyer l'url |
|
| 263 | - $action = parametre_url($action, 'formulaire_action', ''); |
|
| 264 | - $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * @deprecated 4.0 |
|
| 269 | - * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide |
|
| 270 | - */ |
|
| 271 | - /* |
|
| 194 | + // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 195 | + // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 196 | + // si poste, on recupere les erreurs |
|
| 197 | + |
|
| 198 | + $je_suis_poste = false; |
|
| 199 | + if ( |
|
| 200 | + $post_form = _request('formulaire_action') |
|
| 201 | + and $post_form == $form |
|
| 202 | + and $p = _request('formulaire_action_args') |
|
| 203 | + and is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 204 | + ) { |
|
| 205 | + // enlever le faux attribut de langue masque |
|
| 206 | + array_shift($p); |
|
| 207 | + if (formulaire__identifier($form, $args, $p)) { |
|
| 208 | + $je_suis_poste = true; |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $editable = true; |
|
| 213 | + $erreurs = $post = []; |
|
| 214 | + if ($je_suis_poste) { |
|
| 215 | + $post = traiter_formulaires_dynamiques(true); |
|
| 216 | + $e = "erreurs_$form"; |
|
| 217 | + $erreurs = $post[$e] ?? []; |
|
| 218 | + $editable = "editable_$form"; |
|
| 219 | + $editable = (!isset($post[$e])) |
|
| 220 | + || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 221 | + || (isset($post[$editable]) && $post[$editable]); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 225 | + |
|
| 226 | + // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 227 | + // C'est plus fort qu'editable qui est gere par le squelette |
|
| 228 | + // Idealement $valeur doit etre alors un message explicatif. |
|
| 229 | + if (!is_array($valeurs)) { |
|
| 230 | + return is_string($valeurs) ? $valeurs : ''; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 234 | + // ou une action vide si elle ne sert pas |
|
| 235 | + $action = $valeurs['action'] ?? self('&', true); |
|
| 236 | + // bug IEx : si action finit par / |
|
| 237 | + // IE croit que le <form ... action=../ > est autoferme |
|
| 238 | + if (substr($action, -1) == '/') { |
|
| 239 | + // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 240 | + $action .= '#'; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + // recuperer la saisie en cours si erreurs |
|
| 244 | + // seulement si c'est ce formulaire qui est poste |
|
| 245 | + // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 246 | + $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 247 | + foreach (array_keys($valeurs) as $champ) { |
|
| 248 | + if ($champ[0] !== '_' and !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 249 | + if ($dispo and (($v = _request($champ)) !== null)) { |
|
| 250 | + $valeurs[$champ] = $v; |
|
| 251 | + } |
|
| 252 | + // nettoyer l'url des champs qui vont etre saisis |
|
| 253 | + if ($action) { |
|
| 254 | + $action = parametre_url($action, $champ, ''); |
|
| 255 | + } |
|
| 256 | + // proteger les ' et les " dans les champs que l'on va injecter |
|
| 257 | + $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + if ($action) { |
|
| 262 | + // nettoyer l'url |
|
| 263 | + $action = parametre_url($action, 'formulaire_action', ''); |
|
| 264 | + $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * @deprecated 4.0 |
|
| 269 | + * servait pour poster sur les actions de type editer_xxx() qui ne prenaient pas d'argument autrement que par _request('arg') et pour lesquelles il fallait donc passer un hash valide |
|
| 270 | + */ |
|
| 271 | + /* |
|
| 272 | 272 | if (isset($valeurs['_action'])) { |
| 273 | 273 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 274 | 274 | $secu = $securiser_action(reset($valeurs['_action']), end($valeurs['_action']), '', -1); |
@@ -278,59 +278,59 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | */ |
| 280 | 280 | |
| 281 | - // empiler la lang en tant que premier argument implicite du CVT |
|
| 282 | - // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 283 | - array_unshift($args, $GLOBALS['spip_lang']); |
|
| 284 | - |
|
| 285 | - $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 286 | - $valeurs['erreurs'] = $erreurs; |
|
| 287 | - $valeurs['action'] = $action; |
|
| 288 | - $valeurs['form'] = $form; |
|
| 289 | - |
|
| 290 | - $valeurs['formulaire_sign'] = ''; |
|
| 291 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 292 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 293 | - $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 294 | - $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - if (!isset($valeurs['id'])) { |
|
| 298 | - $valeurs['id'] = 'new'; |
|
| 299 | - } |
|
| 300 | - // editable peut venir de charger() ou de traiter() sinon |
|
| 301 | - if (!isset($valeurs['editable'])) { |
|
| 302 | - $valeurs['editable'] = $editable; |
|
| 303 | - } |
|
| 304 | - // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 305 | - $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 306 | - |
|
| 307 | - if ($je_suis_poste) { |
|
| 308 | - $valeurs['message_erreur'] = ''; |
|
| 309 | - if (isset($erreurs['message_erreur'])) { |
|
| 310 | - $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - $valeurs['message_ok'] = ''; |
|
| 314 | - if (isset($post["message_ok_$form"])) { |
|
| 315 | - $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 316 | - } elseif (isset($erreurs['message_ok'])) { |
|
| 317 | - $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 321 | - // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 322 | - // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 323 | - if (html5_permis()) { |
|
| 324 | - foreach ($erreurs as $k => $v) { |
|
| 325 | - if (is_string($v) and strlen(trim($v)) and strpos($k, '_') !== 0) { |
|
| 326 | - // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 327 | - $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - return $valeurs; |
|
| 281 | + // empiler la lang en tant que premier argument implicite du CVT |
|
| 282 | + // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 283 | + array_unshift($args, $GLOBALS['spip_lang']); |
|
| 284 | + |
|
| 285 | + $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 286 | + $valeurs['erreurs'] = $erreurs; |
|
| 287 | + $valeurs['action'] = $action; |
|
| 288 | + $valeurs['form'] = $form; |
|
| 289 | + |
|
| 290 | + $valeurs['formulaire_sign'] = ''; |
|
| 291 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 292 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 293 | + $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 294 | + $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + if (!isset($valeurs['id'])) { |
|
| 298 | + $valeurs['id'] = 'new'; |
|
| 299 | + } |
|
| 300 | + // editable peut venir de charger() ou de traiter() sinon |
|
| 301 | + if (!isset($valeurs['editable'])) { |
|
| 302 | + $valeurs['editable'] = $editable; |
|
| 303 | + } |
|
| 304 | + // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 305 | + $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 306 | + |
|
| 307 | + if ($je_suis_poste) { |
|
| 308 | + $valeurs['message_erreur'] = ''; |
|
| 309 | + if (isset($erreurs['message_erreur'])) { |
|
| 310 | + $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + $valeurs['message_ok'] = ''; |
|
| 314 | + if (isset($post["message_ok_$form"])) { |
|
| 315 | + $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 316 | + } elseif (isset($erreurs['message_ok'])) { |
|
| 317 | + $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 321 | + // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 322 | + // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 323 | + if (html5_permis()) { |
|
| 324 | + foreach ($erreurs as $k => $v) { |
|
| 325 | + if (is_string($v) and strlen(trim($v)) and strpos($k, '_') !== 0) { |
|
| 326 | + // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 327 | + $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + return $valeurs; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -342,51 +342,51 @@ discard block |
||
| 342 | 342 | * @return array |
| 343 | 343 | */ |
| 344 | 344 | function formulaire__charger($form, $args, $poste) { |
| 345 | - if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 346 | - $valeurs = call_user_func_array($charger_valeurs, $args); |
|
| 347 | - } else { |
|
| 348 | - $valeurs = []; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - $valeurs = pipeline( |
|
| 352 | - 'formulaire_charger', |
|
| 353 | - [ |
|
| 354 | - 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 355 | - 'data' => $valeurs |
|
| 356 | - ] |
|
| 357 | - ); |
|
| 358 | - |
|
| 359 | - // prise en charge CVT multi etape |
|
| 360 | - if (is_array($valeurs) and isset($valeurs['_etapes'])) { |
|
| 361 | - include_spip('inc/cvt_multietapes'); |
|
| 362 | - $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 363 | - ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 364 | - $valeurs |
|
| 365 | - ); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 369 | - if (is_array($valeurs)) { |
|
| 370 | - if (!isset($valeurs['_pipelines'])) { |
|
| 371 | - $valeurs['_pipelines'] = []; |
|
| 372 | - } |
|
| 373 | - // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 374 | - // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 375 | - if (isset($valeurs['_pipeline'])) { |
|
| 376 | - $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 377 | - $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 378 | - |
|
| 379 | - $pipelines = [$pipe => $args]; |
|
| 380 | - $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 384 | - // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 385 | - // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 386 | - $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - return $valeurs; |
|
| 345 | + if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 346 | + $valeurs = call_user_func_array($charger_valeurs, $args); |
|
| 347 | + } else { |
|
| 348 | + $valeurs = []; |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + $valeurs = pipeline( |
|
| 352 | + 'formulaire_charger', |
|
| 353 | + [ |
|
| 354 | + 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 355 | + 'data' => $valeurs |
|
| 356 | + ] |
|
| 357 | + ); |
|
| 358 | + |
|
| 359 | + // prise en charge CVT multi etape |
|
| 360 | + if (is_array($valeurs) and isset($valeurs['_etapes'])) { |
|
| 361 | + include_spip('inc/cvt_multietapes'); |
|
| 362 | + $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 363 | + ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 364 | + $valeurs |
|
| 365 | + ); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 369 | + if (is_array($valeurs)) { |
|
| 370 | + if (!isset($valeurs['_pipelines'])) { |
|
| 371 | + $valeurs['_pipelines'] = []; |
|
| 372 | + } |
|
| 373 | + // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 374 | + // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 375 | + if (isset($valeurs['_pipeline'])) { |
|
| 376 | + $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 377 | + $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 378 | + |
|
| 379 | + $pipelines = [$pipe => $args]; |
|
| 380 | + $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 384 | + // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 385 | + // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 386 | + $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + return $valeurs; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | * @return bool |
| 406 | 406 | */ |
| 407 | 407 | function formulaire__identifier($form, $args, $p) { |
| 408 | - if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 409 | - return call_user_func_array($identifier_args, $args) === call_user_func_array($identifier_args, $p); |
|
| 410 | - } |
|
| 408 | + if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 409 | + return call_user_func_array($identifier_args, $args) === call_user_func_array($identifier_args, $p); |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - return $args === $p; |
|
| 412 | + return $args === $p; |
|
| 413 | 413 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * Code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function generer_generer_url($type, $p) { |
| 40 | - $_id = interprete_argument_balise(1, $p); |
|
| 40 | + $_id = interprete_argument_balise(1, $p); |
|
| 41 | 41 | |
| 42 | - if (!$_id) { |
|
| 43 | - $primary = id_table_objet($type); |
|
| 44 | - $_id = champ_sql($primary, $p); |
|
| 45 | - } |
|
| 42 | + if (!$_id) { |
|
| 43 | + $primary = id_table_objet($type); |
|
| 44 | + $_id = champ_sql($primary, $p); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return generer_generer_url_arg($type, $p, $_id); |
|
| 47 | + return generer_generer_url_arg($type, $p, $_id); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -73,28 +73,28 @@ discard block |
||
| 73 | 73 | * Code compilé |
| 74 | 74 | **/ |
| 75 | 75 | function generer_generer_url_arg($type, $p, $_id) { |
| 76 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 77 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 78 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 79 | - return $f($type, $_id, $s); |
|
| 80 | - } |
|
| 81 | - if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
|
| 82 | - return null; |
|
| 83 | - } |
|
| 84 | - $s = _q($s); |
|
| 85 | - # exception des urls de documents sur un serveur distant... |
|
| 86 | - if ($type == 'document') { |
|
| 87 | - return |
|
| 88 | - "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | - "quete_meta('dir_img', $s) . \n\t" . |
|
| 90 | - "quete_fichier($_id,$s)"; |
|
| 91 | - } |
|
| 92 | - $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 93 | - } else { |
|
| 94 | - $s = ", '', '', true"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 76 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 77 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 78 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 79 | + return $f($type, $_id, $s); |
|
| 80 | + } |
|
| 81 | + if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
|
| 82 | + return null; |
|
| 83 | + } |
|
| 84 | + $s = _q($s); |
|
| 85 | + # exception des urls de documents sur un serveur distant... |
|
| 86 | + if ($type == 'document') { |
|
| 87 | + return |
|
| 88 | + "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | + "quete_meta('dir_img', $s) . \n\t" . |
|
| 90 | + "quete_fichier($_id,$s)"; |
|
| 91 | + } |
|
| 92 | + $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 93 | + } else { |
|
| 94 | + $s = ", '', '', true"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -119,27 +119,27 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function balise_URL__dist($p) { |
| 121 | 121 | |
| 122 | - $nom = $p->nom_champ; |
|
| 123 | - if ($nom === 'URL_') { |
|
| 124 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 125 | - erreur_squelette($msg, $p); |
|
| 126 | - $p->interdire_scripts = false; |
|
| 127 | - |
|
| 128 | - return $p; |
|
| 129 | - } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 130 | - return $f($p); |
|
| 131 | - } else { |
|
| 132 | - $nom = strtolower($nom); |
|
| 133 | - $code = generer_generer_url(substr($nom, 4), $p); |
|
| 134 | - $code = champ_sql($nom, $p, $code); |
|
| 135 | - $p->code = $code; |
|
| 136 | - if (!$p->etoile) { |
|
| 137 | - $p->code = "vider_url($code)"; |
|
| 138 | - } |
|
| 139 | - $p->interdire_scripts = false; |
|
| 140 | - |
|
| 141 | - return $p; |
|
| 142 | - } |
|
| 122 | + $nom = $p->nom_champ; |
|
| 123 | + if ($nom === 'URL_') { |
|
| 124 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 125 | + erreur_squelette($msg, $p); |
|
| 126 | + $p->interdire_scripts = false; |
|
| 127 | + |
|
| 128 | + return $p; |
|
| 129 | + } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 130 | + return $f($p); |
|
| 131 | + } else { |
|
| 132 | + $nom = strtolower($nom); |
|
| 133 | + $code = generer_generer_url(substr($nom, 4), $p); |
|
| 134 | + $code = champ_sql($nom, $p, $code); |
|
| 135 | + $p->code = $code; |
|
| 136 | + if (!$p->etoile) { |
|
| 137 | + $p->code = "vider_url($code)"; |
|
| 138 | + } |
|
| 139 | + $p->interdire_scripts = false; |
|
| 140 | + |
|
| 141 | + return $p; |
|
| 142 | + } |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -163,20 +163,20 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | function balise_URL_ARTICLE_dist($p) { |
| 165 | 165 | |
| 166 | - // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 167 | - if ($p->type_requete == 'syndic_articles') { |
|
| 168 | - $code = champ_sql('url', $p); |
|
| 169 | - } else { |
|
| 170 | - $code = generer_generer_url('article', $p); |
|
| 171 | - } |
|
| 166 | + // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 167 | + if ($p->type_requete == 'syndic_articles') { |
|
| 168 | + $code = champ_sql('url', $p); |
|
| 169 | + } else { |
|
| 170 | + $code = generer_generer_url('article', $p); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $p->code = $code; |
|
| 174 | - if (!$p->etoile) { |
|
| 175 | - $p->code = "vider_url($code)"; |
|
| 176 | - } |
|
| 177 | - $p->interdire_scripts = false; |
|
| 173 | + $p->code = $code; |
|
| 174 | + if (!$p->etoile) { |
|
| 175 | + $p->code = "vider_url($code)"; |
|
| 176 | + } |
|
| 177 | + $p->interdire_scripts = false; |
|
| 178 | 178 | |
| 179 | - return $p; |
|
| 179 | + return $p; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -196,21 +196,21 @@ discard block |
||
| 196 | 196 | * Pile complétée par le code à générer |
| 197 | 197 | */ |
| 198 | 198 | function balise_URL_SITE_dist($p) { |
| 199 | - $code = champ_sql('url_site', $p); |
|
| 200 | - if (strpos($code, '@$Pile[0]') !== false) { |
|
| 201 | - $code = generer_generer_url('site', $p); |
|
| 202 | - if ($code === null) { |
|
| 203 | - return null; |
|
| 204 | - } |
|
| 205 | - } else { |
|
| 206 | - if (!$p->etoile) { |
|
| 207 | - $code = "calculer_url($code,'','url', \$connect)"; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - $p->code = $code; |
|
| 211 | - $p->interdire_scripts = false; |
|
| 212 | - |
|
| 213 | - return $p; |
|
| 199 | + $code = champ_sql('url_site', $p); |
|
| 200 | + if (strpos($code, '@$Pile[0]') !== false) { |
|
| 201 | + $code = generer_generer_url('site', $p); |
|
| 202 | + if ($code === null) { |
|
| 203 | + return null; |
|
| 204 | + } |
|
| 205 | + } else { |
|
| 206 | + if (!$p->etoile) { |
|
| 207 | + $code = "calculer_url($code,'','url', \$connect)"; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + $p->code = $code; |
|
| 211 | + $p->interdire_scripts = false; |
|
| 212 | + |
|
| 213 | + return $p; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Autres balises URL_*, qui ne concernent pas une table |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | * Pile complétée par le code à générer |
| 230 | 230 | */ |
| 231 | 231 | function balise_URL_SITE_SPIP_dist($p) { |
| 232 | - $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 233 | - $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 234 | - $p->interdire_scripts = false; |
|
| 232 | + $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 233 | + $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 234 | + $p->interdire_scripts = false; |
|
| 235 | 235 | |
| 236 | - return $p; |
|
| 236 | + return $p; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
@@ -262,42 +262,42 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function balise_URL_PAGE_dist($p) { |
| 264 | 264 | |
| 265 | - $code = interprete_argument_balise(1, $p); |
|
| 266 | - $args = interprete_argument_balise(2, $p); |
|
| 267 | - if ($args == null) { |
|
| 268 | - $args = "''"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 272 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 273 | - // elle devra aussi traiter le cas derogatoire type=page |
|
| 274 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 275 | - if ($args and $args !== "''") { |
|
| 276 | - $code .= ", $args"; |
|
| 277 | - } |
|
| 278 | - $code = $f('page', $code, $s); |
|
| 279 | - $p->code = $code; |
|
| 280 | - return $p; |
|
| 281 | - } |
|
| 282 | - $s = 'connect=' . addslashes($s); |
|
| 283 | - $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - if (!$code) { |
|
| 287 | - $noentities = $p->etoile ? "'&'" : ''; |
|
| 288 | - $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 289 | - } else { |
|
| 290 | - if (!$args) { |
|
| 291 | - $args = "''"; |
|
| 292 | - } |
|
| 293 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 294 | - $code = "generer_url_public($code, $args$noentities)"; |
|
| 295 | - } |
|
| 296 | - $p->code = $code; |
|
| 297 | - spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 298 | - |
|
| 299 | - #$p->interdire_scripts = true; |
|
| 300 | - return $p; |
|
| 265 | + $code = interprete_argument_balise(1, $p); |
|
| 266 | + $args = interprete_argument_balise(2, $p); |
|
| 267 | + if ($args == null) { |
|
| 268 | + $args = "''"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 272 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 273 | + // elle devra aussi traiter le cas derogatoire type=page |
|
| 274 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 275 | + if ($args and $args !== "''") { |
|
| 276 | + $code .= ", $args"; |
|
| 277 | + } |
|
| 278 | + $code = $f('page', $code, $s); |
|
| 279 | + $p->code = $code; |
|
| 280 | + return $p; |
|
| 281 | + } |
|
| 282 | + $s = 'connect=' . addslashes($s); |
|
| 283 | + $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + if (!$code) { |
|
| 287 | + $noentities = $p->etoile ? "'&'" : ''; |
|
| 288 | + $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 289 | + } else { |
|
| 290 | + if (!$args) { |
|
| 291 | + $args = "''"; |
|
| 292 | + } |
|
| 293 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 294 | + $code = "generer_url_public($code, $args$noentities)"; |
|
| 295 | + } |
|
| 296 | + $p->code = $code; |
|
| 297 | + spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 298 | + |
|
| 299 | + #$p->interdire_scripts = true; |
|
| 300 | + return $p; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
@@ -324,24 +324,24 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | function balise_URL_ECRIRE_dist($p) { |
| 326 | 326 | |
| 327 | - $code = interprete_argument_balise(1, $p); |
|
| 328 | - if (!$code) { |
|
| 329 | - $fonc = "''"; |
|
| 330 | - } else { |
|
| 331 | - $fonc = $code; |
|
| 332 | - $args = interprete_argument_balise(2, $p); |
|
| 333 | - if ($args === null) { |
|
| 334 | - $args = "''"; |
|
| 335 | - } |
|
| 336 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 337 | - if (($args != "''") or $noentities) { |
|
| 338 | - $fonc .= ",$args$noentities"; |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 342 | - $p->interdire_scripts = false; |
|
| 343 | - |
|
| 344 | - return $p; |
|
| 327 | + $code = interprete_argument_balise(1, $p); |
|
| 328 | + if (!$code) { |
|
| 329 | + $fonc = "''"; |
|
| 330 | + } else { |
|
| 331 | + $fonc = $code; |
|
| 332 | + $args = interprete_argument_balise(2, $p); |
|
| 333 | + if ($args === null) { |
|
| 334 | + $args = "''"; |
|
| 335 | + } |
|
| 336 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 337 | + if (($args != "''") or $noentities) { |
|
| 338 | + $fonc .= ",$args$noentities"; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 342 | + $p->interdire_scripts = false; |
|
| 343 | + |
|
| 344 | + return $p; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
@@ -367,24 +367,24 @@ discard block |
||
| 367 | 367 | * Pile complétée par le code à générer |
| 368 | 368 | */ |
| 369 | 369 | function balise_URL_ACTION_AUTEUR_dist($p) { |
| 370 | - $p->descr['session'] = true; |
|
| 371 | - |
|
| 372 | - $p->code = interprete_argument_balise(1, $p); |
|
| 373 | - |
|
| 374 | - $args = interprete_argument_balise(2, $p); |
|
| 375 | - if ($args != "''" && $args !== null) { |
|
| 376 | - $p->code .= ',' . $args; |
|
| 377 | - } |
|
| 378 | - $redirect = interprete_argument_balise(3, $p); |
|
| 379 | - if ($redirect != "''" && $redirect !== null) { |
|
| 380 | - if ($args == "''" || $args === null) { |
|
| 381 | - $p->code .= ",''"; |
|
| 382 | - } |
|
| 383 | - $p->code .= ',' . $redirect; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 387 | - $p->interdire_scripts = false; |
|
| 388 | - |
|
| 389 | - return $p; |
|
| 370 | + $p->descr['session'] = true; |
|
| 371 | + |
|
| 372 | + $p->code = interprete_argument_balise(1, $p); |
|
| 373 | + |
|
| 374 | + $args = interprete_argument_balise(2, $p); |
|
| 375 | + if ($args != "''" && $args !== null) { |
|
| 376 | + $p->code .= ',' . $args; |
|
| 377 | + } |
|
| 378 | + $redirect = interprete_argument_balise(3, $p); |
|
| 379 | + if ($redirect != "''" && $redirect !== null) { |
|
| 380 | + if ($args == "''" || $args === null) { |
|
| 381 | + $p->code .= ",''"; |
|
| 382 | + } |
|
| 383 | + $p->code .= ',' . $redirect; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 387 | + $p->interdire_scripts = false; |
|
| 388 | + |
|
| 389 | + return $p; |
|
| 390 | 390 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -40,29 +40,29 @@ discard block |
||
| 40 | 40 | * Pile complétée par le code à générer |
| 41 | 41 | */ |
| 42 | 42 | function balise_INFO__dist($p) { |
| 43 | - $info = $p->nom_champ; |
|
| 44 | - $type_objet = interprete_argument_balise(1, $p); |
|
| 45 | - $id_objet = interprete_argument_balise(2, $p); |
|
| 46 | - if ($info === 'INFO_' or !$type_objet or !$id_objet) { |
|
| 47 | - $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 48 | - erreur_squelette($msg, $p); |
|
| 49 | - $p->interdire_scripts = true; |
|
| 43 | + $info = $p->nom_champ; |
|
| 44 | + $type_objet = interprete_argument_balise(1, $p); |
|
| 45 | + $id_objet = interprete_argument_balise(2, $p); |
|
| 46 | + if ($info === 'INFO_' or !$type_objet or !$id_objet) { |
|
| 47 | + $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 48 | + erreur_squelette($msg, $p); |
|
| 49 | + $p->interdire_scripts = true; |
|
| 50 | 50 | |
| 51 | - return $p; |
|
| 52 | - } else { |
|
| 53 | - // Récupérer tous les params à la suite de objet et id_objet |
|
| 54 | - $_params = '['; |
|
| 55 | - $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 56 | - for ($i = 3; $i < $nb_params; $i++) { |
|
| 57 | - $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 58 | - } |
|
| 59 | - $_params .= ']'; |
|
| 51 | + return $p; |
|
| 52 | + } else { |
|
| 53 | + // Récupérer tous les params à la suite de objet et id_objet |
|
| 54 | + $_params = '['; |
|
| 55 | + $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 56 | + for ($i = 3; $i < $nb_params; $i++) { |
|
| 57 | + $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 58 | + } |
|
| 59 | + $_params .= ']'; |
|
| 60 | 60 | |
| 61 | - $info_sql = strtolower(substr($info, 5)); |
|
| 62 | - $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 63 | - $p->code = champ_sql($info, $p, $code); |
|
| 64 | - $p->interdire_scripts = true; |
|
| 61 | + $info_sql = strtolower(substr($info, 5)); |
|
| 62 | + $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 63 | + $p->code = champ_sql($info, $p, $code); |
|
| 64 | + $p->interdire_scripts = true; |
|
| 65 | 65 | |
| 66 | - return $p; |
|
| 67 | - } |
|
| 66 | + return $p; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -54,12 +54,12 @@ |
||
| 54 | 54 | $_params = '['; |
| 55 | 55 | $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
| 56 | 56 | for ($i = 3; $i < $nb_params; $i++) { |
| 57 | - $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 57 | + $_params .= interprete_argument_balise($i, $p).','; |
|
| 58 | 58 | } |
| 59 | 59 | $_params .= ']'; |
| 60 | 60 | |
| 61 | 61 | $info_sql = strtolower(substr($info, 5)); |
| 62 | - $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 62 | + $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', ".($p->etoile ? _q($p->etoile) : "''").", $_params)"; |
|
| 63 | 63 | $p->code = champ_sql($info, $p, $code); |
| 64 | 64 | $p->interdire_scripts = true; |
| 65 | 65 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | define('URLS_PAGE_EXEMPLE', 'spip.php?article12'); |
@@ -37,23 +37,23 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function urls_page_generer_url_objet_dist(int $id, string $objet, string $args = '', string $ancre = ''): string { |
| 39 | 39 | |
| 40 | - if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) { |
|
| 41 | - $url = $generer_url_externe($id, $args, $ancre); |
|
| 42 | - // une url === null indique "je ne traite pas cette url, appliquez le calcul standard" |
|
| 43 | - // une url vide est une url vide, ne rien faire de plus |
|
| 44 | - if (!is_null($url)) { |
|
| 45 | - return $url; |
|
| 46 | - } |
|
| 47 | - } |
|
| 40 | + if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) { |
|
| 41 | + $url = $generer_url_externe($id, $args, $ancre); |
|
| 42 | + // une url === null indique "je ne traite pas cette url, appliquez le calcul standard" |
|
| 43 | + // une url vide est une url vide, ne rien faire de plus |
|
| 44 | + if (!is_null($url)) { |
|
| 45 | + return $url; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 50 | - . $id . \_terminaison_urls_page; |
|
| 49 | + $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 50 | + . $id . \_terminaison_urls_page; |
|
| 51 | 51 | |
| 52 | - if ($args) { |
|
| 53 | - $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 54 | - } |
|
| 52 | + if ($args) { |
|
| 53 | + $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 56 | + return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -69,27 +69,27 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | function urls_page_decoder_url_dist(string $url, string $entite, array $contexte = []): array { |
| 71 | 71 | |
| 72 | - // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 73 | - if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 74 | - return [[], '404']; |
|
| 75 | - } |
|
| 72 | + // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 73 | + if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 74 | + return [[], '404']; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - include_spip('inc/urls'); |
|
| 78 | - $r = nettoyer_url_page($url, $contexte); |
|
| 79 | - if ($r) { |
|
| 80 | - array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 81 | - return $r; |
|
| 82 | - } |
|
| 77 | + include_spip('inc/urls'); |
|
| 78 | + $r = nettoyer_url_page($url, $contexte); |
|
| 79 | + if ($r) { |
|
| 80 | + array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 81 | + return $r; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /* |
|
| 84 | + /* |
|
| 85 | 85 | * Le bloc qui suit sert a faciliter les transitions depuis |
| 86 | 86 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' |
| 87 | 87 | * Il est inutile de le recopier si vous personnalisez vos URLs |
| 88 | 88 | * et votre .htaccess |
| 89 | 89 | */ |
| 90 | - // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 91 | - // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 92 | - $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? ''; |
|
| 93 | - return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte); |
|
| 94 | - /* Fin du bloc compatibilite url-propres */ |
|
| 90 | + // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 91 | + // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 92 | + $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? ''; |
|
| 93 | + return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte); |
|
| 94 | + /* Fin du bloc compatibilite url-propres */ |
|
| 95 | 95 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite |
| 24 | 24 | define('_separateur_urls_page', ''); |
| 25 | 25 | # on peut indiquer '' si on a installe le .htaccess |
| 26 | -define('_debut_urls_page', get_spip_script('./') . '?'); |
|
| 26 | +define('_debut_urls_page', get_spip_script('./').'?'); |
|
| 27 | 27 | ####### |
| 28 | 28 | |
| 29 | 29 | |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 50 | - . $id . \_terminaison_urls_page; |
|
| 49 | + $url = \_debut_urls_page.$objet.\_separateur_urls_page |
|
| 50 | + . $id.\_terminaison_urls_page; |
|
| 51 | 51 | |
| 52 | 52 | if ($args) { |
| 53 | 53 | $args = strpos($url, '?') ? "&$args" : "?$args"; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 56 | + return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : ''); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/autoriser'); |
@@ -30,80 +30,80 @@ discard block |
||
| 30 | 30 | * Un tableau des sous rubriques |
| 31 | 31 | */ |
| 32 | 32 | function enfant_rub($collection, $debut = 0, $limite = 500) { |
| 33 | - $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); |
|
| 34 | - $logo = ''; |
|
| 35 | - |
|
| 36 | - if ($voir_logo) { |
|
| 37 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 38 | - include_spip('inc/filtres_images_mini'); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - $res = []; |
|
| 42 | - |
|
| 43 | - $result = sql_select( |
|
| 44 | - 'id_rubrique, id_parent, titre, descriptif, lang', |
|
| 45 | - 'spip_rubriques', |
|
| 46 | - 'id_parent=' . intval($collection), |
|
| 47 | - '', |
|
| 48 | - '0+titre,titre', |
|
| 49 | - "$debut,$limite" |
|
| 50 | - ); |
|
| 51 | - while ($row = sql_fetch($result)) { |
|
| 52 | - $id_rubrique = $row['id_rubrique']; |
|
| 53 | - $id_parent = $row['id_parent']; |
|
| 54 | - // pour etre sur de passer par tous les traitements |
|
| 55 | - $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre'); |
|
| 56 | - if ('' !== ($rang = recuperer_numero($row['titre']))) { |
|
| 57 | - $rang = "<span class='rang'>$rang.</span> "; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 61 | - $les_sous_enfants = sous_enfant_rub($id_rubrique); |
|
| 62 | - |
|
| 63 | - changer_typo($row['lang']); |
|
| 64 | - $lang_dir = lang_dir($row['lang']); |
|
| 65 | - $descriptif = propre($row['descriptif']); |
|
| 66 | - |
|
| 67 | - if ($voir_logo) { |
|
| 68 | - if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { |
|
| 69 | - [$fid, $dir, $nom, $format] = $logo; |
|
| 70 | - $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70); |
|
| 71 | - if ($logo) { |
|
| 72 | - $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">'); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 78 | - http_img_pack( |
|
| 79 | - 'auteur-0minirezo-16.png', |
|
| 80 | - '', |
|
| 81 | - " width='16' height='16'", |
|
| 82 | - _T('image_administrer_rubrique') |
|
| 83 | - )) . |
|
| 84 | - " <a class='titremlien' dir='$lang_dir'" . |
|
| 85 | - ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 86 | - " href='" . |
|
| 87 | - generer_objet_url($id_rubrique, 'rubrique') . |
|
| 88 | - "'><span class='titre'>" . |
|
| 89 | - $rang . $titre |
|
| 90 | - . '</span>' |
|
| 91 | - . (is_string($logo) ? $logo : '') |
|
| 92 | - . '</a>'; |
|
| 93 | - |
|
| 94 | - $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique") |
|
| 95 | - . (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") |
|
| 96 | - ; |
|
| 97 | - |
|
| 98 | - $res[] = |
|
| 99 | - debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 100 | - $les_sous_enfants . |
|
| 101 | - fin_cadre_sous_rub(); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
|
| 106 | - return $res; |
|
| 33 | + $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); |
|
| 34 | + $logo = ''; |
|
| 35 | + |
|
| 36 | + if ($voir_logo) { |
|
| 37 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 38 | + include_spip('inc/filtres_images_mini'); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + $res = []; |
|
| 42 | + |
|
| 43 | + $result = sql_select( |
|
| 44 | + 'id_rubrique, id_parent, titre, descriptif, lang', |
|
| 45 | + 'spip_rubriques', |
|
| 46 | + 'id_parent=' . intval($collection), |
|
| 47 | + '', |
|
| 48 | + '0+titre,titre', |
|
| 49 | + "$debut,$limite" |
|
| 50 | + ); |
|
| 51 | + while ($row = sql_fetch($result)) { |
|
| 52 | + $id_rubrique = $row['id_rubrique']; |
|
| 53 | + $id_parent = $row['id_parent']; |
|
| 54 | + // pour etre sur de passer par tous les traitements |
|
| 55 | + $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre'); |
|
| 56 | + if ('' !== ($rang = recuperer_numero($row['titre']))) { |
|
| 57 | + $rang = "<span class='rang'>$rang.</span> "; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 61 | + $les_sous_enfants = sous_enfant_rub($id_rubrique); |
|
| 62 | + |
|
| 63 | + changer_typo($row['lang']); |
|
| 64 | + $lang_dir = lang_dir($row['lang']); |
|
| 65 | + $descriptif = propre($row['descriptif']); |
|
| 66 | + |
|
| 67 | + if ($voir_logo) { |
|
| 68 | + if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { |
|
| 69 | + [$fid, $dir, $nom, $format] = $logo; |
|
| 70 | + $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70); |
|
| 71 | + if ($logo) { |
|
| 72 | + $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">'); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 78 | + http_img_pack( |
|
| 79 | + 'auteur-0minirezo-16.png', |
|
| 80 | + '', |
|
| 81 | + " width='16' height='16'", |
|
| 82 | + _T('image_administrer_rubrique') |
|
| 83 | + )) . |
|
| 84 | + " <a class='titremlien' dir='$lang_dir'" . |
|
| 85 | + ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 86 | + " href='" . |
|
| 87 | + generer_objet_url($id_rubrique, 'rubrique') . |
|
| 88 | + "'><span class='titre'>" . |
|
| 89 | + $rang . $titre |
|
| 90 | + . '</span>' |
|
| 91 | + . (is_string($logo) ? $logo : '') |
|
| 92 | + . '</a>'; |
|
| 93 | + |
|
| 94 | + $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique") |
|
| 95 | + . (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") |
|
| 96 | + ; |
|
| 97 | + |
|
| 98 | + $res[] = |
|
| 99 | + debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 100 | + $les_sous_enfants . |
|
| 101 | + fin_cadre_sous_rub(); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
|
| 106 | + return $res; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -116,71 +116,71 @@ discard block |
||
| 116 | 116 | * Le contenu du bloc dépliable |
| 117 | 117 | */ |
| 118 | 118 | function sous_enfant_rub($collection2) { |
| 119 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2)); |
|
| 120 | - |
|
| 121 | - $retour = ''; |
|
| 122 | - $pagination = ''; |
|
| 123 | - $debut = 0; |
|
| 124 | - $limite = 500; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * On ne va afficher que 500 résultats max |
|
| 128 | - * Si > 500 on affiche une pagination |
|
| 129 | - */ |
|
| 130 | - if ($nb > $limite) { |
|
| 131 | - $debut = _request('debut_rubrique' . $collection2) ?: $debut; |
|
| 132 | - $pagination = chercher_filtre('pagination'); |
|
| 133 | - $pagination = '<p class="pagination">' . $pagination( |
|
| 134 | - $nb, |
|
| 135 | - '_rubrique' . $collection2, |
|
| 136 | - $debut, |
|
| 137 | - $limite, |
|
| 138 | - true, |
|
| 139 | - 'prive' |
|
| 140 | - ) . '</p>'; |
|
| 141 | - $limite = $debut + $limite; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - $result = sql_select( |
|
| 145 | - 'id_rubrique, id_parent, titre, lang', |
|
| 146 | - 'spip_rubriques', |
|
| 147 | - 'id_parent=' . intval($collection2), |
|
| 148 | - '', |
|
| 149 | - '0+titre,titre', |
|
| 150 | - "$debut,$limite" |
|
| 151 | - ); |
|
| 152 | - |
|
| 153 | - while ($row = sql_fetch($result)) { |
|
| 154 | - $id_rubrique2 = $row['id_rubrique']; |
|
| 155 | - $titre2 = generer_objet_info( |
|
| 156 | - $id_rubrique2, |
|
| 157 | - 'rubrique', |
|
| 158 | - 'titre' |
|
| 159 | - ); // pour etre sur de passer par tous les traitements |
|
| 160 | - if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
|
| 161 | - $rang2 = "<span class='rang'>$rang2.</span> "; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - changer_typo($row['lang']); |
|
| 165 | - $lang_dir = lang_dir($row['lang']); |
|
| 166 | - if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
|
| 167 | - $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url( |
|
| 168 | - $id_rubrique2, |
|
| 169 | - 'rubrique' |
|
| 170 | - ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - $retour = $pagination . $retour . $pagination; |
|
| 175 | - |
|
| 176 | - if (!$retour) { |
|
| 177 | - return ''; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
|
| 181 | - . "\n<ul class='liste-items sous-sous-rub'>\n" |
|
| 182 | - . $retour |
|
| 183 | - . "</ul>\n" . fin_block() . "\n\n"; |
|
| 119 | + $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2)); |
|
| 120 | + |
|
| 121 | + $retour = ''; |
|
| 122 | + $pagination = ''; |
|
| 123 | + $debut = 0; |
|
| 124 | + $limite = 500; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * On ne va afficher que 500 résultats max |
|
| 128 | + * Si > 500 on affiche une pagination |
|
| 129 | + */ |
|
| 130 | + if ($nb > $limite) { |
|
| 131 | + $debut = _request('debut_rubrique' . $collection2) ?: $debut; |
|
| 132 | + $pagination = chercher_filtre('pagination'); |
|
| 133 | + $pagination = '<p class="pagination">' . $pagination( |
|
| 134 | + $nb, |
|
| 135 | + '_rubrique' . $collection2, |
|
| 136 | + $debut, |
|
| 137 | + $limite, |
|
| 138 | + true, |
|
| 139 | + 'prive' |
|
| 140 | + ) . '</p>'; |
|
| 141 | + $limite = $debut + $limite; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + $result = sql_select( |
|
| 145 | + 'id_rubrique, id_parent, titre, lang', |
|
| 146 | + 'spip_rubriques', |
|
| 147 | + 'id_parent=' . intval($collection2), |
|
| 148 | + '', |
|
| 149 | + '0+titre,titre', |
|
| 150 | + "$debut,$limite" |
|
| 151 | + ); |
|
| 152 | + |
|
| 153 | + while ($row = sql_fetch($result)) { |
|
| 154 | + $id_rubrique2 = $row['id_rubrique']; |
|
| 155 | + $titre2 = generer_objet_info( |
|
| 156 | + $id_rubrique2, |
|
| 157 | + 'rubrique', |
|
| 158 | + 'titre' |
|
| 159 | + ); // pour etre sur de passer par tous les traitements |
|
| 160 | + if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
|
| 161 | + $rang2 = "<span class='rang'>$rang2.</span> "; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + changer_typo($row['lang']); |
|
| 165 | + $lang_dir = lang_dir($row['lang']); |
|
| 166 | + if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
|
| 167 | + $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url( |
|
| 168 | + $id_rubrique2, |
|
| 169 | + 'rubrique' |
|
| 170 | + ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + $retour = $pagination . $retour . $pagination; |
|
| 175 | + |
|
| 176 | + if (!$retour) { |
|
| 177 | + return ''; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
|
| 181 | + . "\n<ul class='liste-items sous-sous-rub'>\n" |
|
| 182 | + . $retour |
|
| 183 | + . "</ul>\n" . fin_block() . "\n\n"; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -195,44 +195,44 @@ discard block |
||
| 195 | 195 | * Le contenu textuel affiché, la liste des sous rubriques |
| 196 | 196 | */ |
| 197 | 197 | function afficher_enfant_rub($id_rubrique = 0) { |
| 198 | - $pagination = ''; |
|
| 199 | - $debut = 0; |
|
| 200 | - $limite = 500; |
|
| 201 | - |
|
| 202 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique)); |
|
| 203 | - |
|
| 204 | - if ($nb > $limite) { |
|
| 205 | - $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut; |
|
| 206 | - $pagination = chercher_filtre('pagination'); |
|
| 207 | - $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 208 | - $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 209 | - '</p>'; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
|
| 213 | - |
|
| 214 | - if (!$n = count($les_enfants)) { |
|
| 215 | - return ''; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - if ($n == 1) { |
|
| 219 | - $les_enfants = reset($les_enfants); |
|
| 220 | - $les_enfants2 = ''; |
|
| 221 | - } else { |
|
| 222 | - $n = ceil($n / 2); |
|
| 223 | - $les_enfants2 = implode('', array_slice($les_enfants, $n)); |
|
| 224 | - $les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $res = |
|
| 228 | - $pagination |
|
| 229 | - . "<div class='gauche'>" |
|
| 230 | - . $les_enfants |
|
| 231 | - . '</div>' |
|
| 232 | - . "<div class='droite'>" |
|
| 233 | - . $les_enfants2 |
|
| 234 | - . '</div>' |
|
| 235 | - . $pagination; |
|
| 236 | - |
|
| 237 | - return $res; |
|
| 198 | + $pagination = ''; |
|
| 199 | + $debut = 0; |
|
| 200 | + $limite = 500; |
|
| 201 | + |
|
| 202 | + $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique)); |
|
| 203 | + |
|
| 204 | + if ($nb > $limite) { |
|
| 205 | + $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut; |
|
| 206 | + $pagination = chercher_filtre('pagination'); |
|
| 207 | + $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 208 | + $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 209 | + '</p>'; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
|
| 213 | + |
|
| 214 | + if (!$n = count($les_enfants)) { |
|
| 215 | + return ''; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + if ($n == 1) { |
|
| 219 | + $les_enfants = reset($les_enfants); |
|
| 220 | + $les_enfants2 = ''; |
|
| 221 | + } else { |
|
| 222 | + $n = ceil($n / 2); |
|
| 223 | + $les_enfants2 = implode('', array_slice($les_enfants, $n)); |
|
| 224 | + $les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $res = |
|
| 228 | + $pagination |
|
| 229 | + . "<div class='gauche'>" |
|
| 230 | + . $les_enfants |
|
| 231 | + . '</div>' |
|
| 232 | + . "<div class='droite'>" |
|
| 233 | + . $les_enfants2 |
|
| 234 | + . '</div>' |
|
| 235 | + . $pagination; |
|
| 236 | + |
|
| 237 | + return $res; |
|
| 238 | 238 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $result = sql_select( |
| 44 | 44 | 'id_rubrique, id_parent, titre, descriptif, lang', |
| 45 | 45 | 'spip_rubriques', |
| 46 | - 'id_parent=' . intval($collection), |
|
| 46 | + 'id_parent='.intval($collection), |
|
| 47 | 47 | '', |
| 48 | 48 | '0+titre,titre', |
| 49 | 49 | "$debut,$limite" |
@@ -74,19 +74,18 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 78 | - http_img_pack( |
|
| 77 | + $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : http_img_pack( |
|
| 79 | 78 | 'auteur-0minirezo-16.png', |
| 80 | 79 | '', |
| 81 | 80 | " width='16' height='16'", |
| 82 | 81 | _T('image_administrer_rubrique') |
| 83 | - )) . |
|
| 84 | - " <a class='titremlien' dir='$lang_dir'" . |
|
| 85 | - ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 86 | - " href='" . |
|
| 87 | - generer_objet_url($id_rubrique, 'rubrique') . |
|
| 88 | - "'><span class='titre'>" . |
|
| 89 | - $rang . $titre |
|
| 82 | + )). |
|
| 83 | + " <a class='titremlien' dir='$lang_dir'". |
|
| 84 | + ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='".$row['lang']."'" : ''). |
|
| 85 | + " href='". |
|
| 86 | + generer_objet_url($id_rubrique, 'rubrique'). |
|
| 87 | + "'><span class='titre'>". |
|
| 88 | + $rang.$titre |
|
| 90 | 89 | . '</span>' |
| 91 | 90 | . (is_string($logo) ? $logo : '') |
| 92 | 91 | . '</a>'; |
@@ -96,8 +95,8 @@ discard block |
||
| 96 | 95 | ; |
| 97 | 96 | |
| 98 | 97 | $res[] = |
| 99 | - debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 100 | - $les_sous_enfants . |
|
| 98 | + debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre). |
|
| 99 | + $les_sous_enfants. |
|
| 101 | 100 | fin_cadre_sous_rub(); |
| 102 | 101 | } |
| 103 | 102 | } |
@@ -116,7 +115,7 @@ discard block |
||
| 116 | 115 | * Le contenu du bloc dépliable |
| 117 | 116 | */ |
| 118 | 117 | function sous_enfant_rub($collection2) { |
| 119 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2)); |
|
| 118 | + $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2)); |
|
| 120 | 119 | |
| 121 | 120 | $retour = ''; |
| 122 | 121 | $pagination = ''; |
@@ -128,23 +127,23 @@ discard block |
||
| 128 | 127 | * Si > 500 on affiche une pagination |
| 129 | 128 | */ |
| 130 | 129 | if ($nb > $limite) { |
| 131 | - $debut = _request('debut_rubrique' . $collection2) ?: $debut; |
|
| 130 | + $debut = _request('debut_rubrique'.$collection2) ?: $debut; |
|
| 132 | 131 | $pagination = chercher_filtre('pagination'); |
| 133 | - $pagination = '<p class="pagination">' . $pagination( |
|
| 132 | + $pagination = '<p class="pagination">'.$pagination( |
|
| 134 | 133 | $nb, |
| 135 | - '_rubrique' . $collection2, |
|
| 134 | + '_rubrique'.$collection2, |
|
| 136 | 135 | $debut, |
| 137 | 136 | $limite, |
| 138 | 137 | true, |
| 139 | 138 | 'prive' |
| 140 | - ) . '</p>'; |
|
| 139 | + ).'</p>'; |
|
| 141 | 140 | $limite = $debut + $limite; |
| 142 | 141 | } |
| 143 | 142 | |
| 144 | 143 | $result = sql_select( |
| 145 | 144 | 'id_rubrique, id_parent, titre, lang', |
| 146 | 145 | 'spip_rubriques', |
| 147 | - 'id_parent=' . intval($collection2), |
|
| 146 | + 'id_parent='.intval($collection2), |
|
| 148 | 147 | '', |
| 149 | 148 | '0+titre,titre', |
| 150 | 149 | "$debut,$limite" |
@@ -164,14 +163,14 @@ discard block |
||
| 164 | 163 | changer_typo($row['lang']); |
| 165 | 164 | $lang_dir = lang_dir($row['lang']); |
| 166 | 165 | if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
| 167 | - $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url( |
|
| 166 | + $retour .= "\n<li class='item' dir='$lang_dir'><a href='".generer_objet_url( |
|
| 168 | 167 | $id_rubrique2, |
| 169 | 168 | 'rubrique' |
| 170 | - ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 169 | + )."'>".$rang2.$titre2."</a></li>\n"; |
|
| 171 | 170 | } |
| 172 | 171 | } |
| 173 | 172 | |
| 174 | - $retour = $pagination . $retour . $pagination; |
|
| 173 | + $retour = $pagination.$retour.$pagination; |
|
| 175 | 174 | |
| 176 | 175 | if (!$retour) { |
| 177 | 176 | return ''; |
@@ -180,7 +179,7 @@ discard block |
||
| 180 | 179 | return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
| 181 | 180 | . "\n<ul class='liste-items sous-sous-rub'>\n" |
| 182 | 181 | . $retour |
| 183 | - . "</ul>\n" . fin_block() . "\n\n"; |
|
| 182 | + . "</ul>\n".fin_block()."\n\n"; |
|
| 184 | 183 | } |
| 185 | 184 | |
| 186 | 185 | /** |
@@ -199,13 +198,13 @@ discard block |
||
| 199 | 198 | $debut = 0; |
| 200 | 199 | $limite = 500; |
| 201 | 200 | |
| 202 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique)); |
|
| 201 | + $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)); |
|
| 203 | 202 | |
| 204 | 203 | if ($nb > $limite) { |
| 205 | - $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut; |
|
| 204 | + $debut = _request('debut_rubrique'.$id_rubrique) ?: $debut; |
|
| 206 | 205 | $pagination = chercher_filtre('pagination'); |
| 207 | - $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 208 | - $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 206 | + $pagination = '<br class="nettoyeur"><p class="pagination">'. |
|
| 207 | + $pagination($nb, '_rubrique'.$id_rubrique, $debut, $limite, true, 'prive'). |
|
| 209 | 208 | '</p>'; |
| 210 | 209 | } |
| 211 | 210 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('base/abstract_sql'); |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | // |
| 24 | 24 | |
| 25 | 25 | function inc_lien_dist( |
| 26 | - $lien, |
|
| 27 | - $texte = '', |
|
| 28 | - $class = '', |
|
| 29 | - $title = '', |
|
| 30 | - $hlang = '', |
|
| 31 | - $rel = '', |
|
| 32 | - string $connect = '', |
|
| 33 | - $env = [] |
|
| 26 | + $lien, |
|
| 27 | + $texte = '', |
|
| 28 | + $class = '', |
|
| 29 | + $title = '', |
|
| 30 | + $hlang = '', |
|
| 31 | + $rel = '', |
|
| 32 | + string $connect = '', |
|
| 33 | + $env = [] |
|
| 34 | 34 | ) { |
| 35 | - return $lien; |
|
| 35 | + return $lien; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
@@ -43,28 +43,28 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | function expanser_liens($t, string $connect = '', $env = []) { |
| 45 | 45 | |
| 46 | - $t = pipeline('pre_liens', $t); |
|
| 46 | + $t = pipeline('pre_liens', $t); |
|
| 47 | 47 | |
| 48 | - // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 49 | - // de remettre le texte d'origine dans les parametres du modele |
|
| 50 | - $t = traiter_modeles($t, false, false, $connect); |
|
| 48 | + // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 49 | + // de remettre le texte d'origine dans les parametres du modele |
|
| 50 | + $t = traiter_modeles($t, false, false, $connect); |
|
| 51 | 51 | |
| 52 | - return $t; |
|
| 52 | + return $t; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Meme analyse mais pour eliminer les liens |
| 56 | 56 | // et ne laisser que leur titre, a expliciter si ce n'est fait |
| 57 | 57 | function nettoyer_raccourcis_typo($texte, string $connect = '') { |
| 58 | - return $texte; |
|
| 58 | + return $texte; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Repere dans la partie texte d'un raccourci [texte->...] |
| 62 | 62 | // la langue et la bulle eventuelles |
| 63 | 63 | function traiter_raccourci_lien_atts($texte) { |
| 64 | - $bulle = ''; |
|
| 65 | - $hlang = ''; |
|
| 64 | + $bulle = ''; |
|
| 65 | + $hlang = ''; |
|
| 66 | 66 | |
| 67 | - return [trim($texte), $bulle, $hlang]; |
|
| 67 | + return [trim($texte), $bulle, $hlang]; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/'); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | 82 | function virtuel_redirige($virtuel, $url = false) { |
| 83 | - return $virtuel; |
|
| 83 | + return $virtuel; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Cherche un lien du type [->raccourci 123] |
@@ -93,121 +93,121 @@ discard block |
||
| 93 | 93 | // 'url': seulement U (i.e. generer_url_RACCOURCI) |
| 94 | 94 | |
| 95 | 95 | function calculer_url($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) { |
| 96 | - $r = traiter_lien_implicite($ref, $texte, $pour, $connect); |
|
| 96 | + $r = traiter_lien_implicite($ref, $texte, $pour, $connect); |
|
| 97 | 97 | |
| 98 | - return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 98 | + return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
| 102 | 102 | |
| 103 | 103 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) { |
| 104 | - if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 105 | - return ($pour != 'tout') ? '' : ['', '', '', '']; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $lien = entites_html(trim($ref)); |
|
| 109 | - |
|
| 110 | - // Liens explicites |
|
| 111 | - if (!$texte) { |
|
| 112 | - $texte = str_replace('"', '', $lien); |
|
| 113 | - // evite l'affichage de trops longues urls. |
|
| 114 | - $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 115 | - $texte = $lien_court($texte); |
|
| 116 | - if ($echappe_typo) { |
|
| 117 | - $texte = '<html>' . quote_amp($texte) . '</html>'; |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // petites corrections d'URL |
|
| 122 | - if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 123 | - $lien = 'http://' . $lien; |
|
| 124 | - } else { |
|
| 125 | - if (strpos($lien, '@') && email_valide($lien)) { |
|
| 126 | - if (!$texte) { |
|
| 127 | - $texte = $lien; |
|
| 128 | - } |
|
| 129 | - $lien = 'mailto:' . $lien; |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - if ($pour == 'url') { |
|
| 134 | - return $lien; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - if ($pour == 'titre') { |
|
| 138 | - return $texte; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - return ['url' => $lien, 'titre' => $texte]; |
|
| 104 | + if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 105 | + return ($pour != 'tout') ? '' : ['', '', '', '']; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $lien = entites_html(trim($ref)); |
|
| 109 | + |
|
| 110 | + // Liens explicites |
|
| 111 | + if (!$texte) { |
|
| 112 | + $texte = str_replace('"', '', $lien); |
|
| 113 | + // evite l'affichage de trops longues urls. |
|
| 114 | + $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 115 | + $texte = $lien_court($texte); |
|
| 116 | + if ($echappe_typo) { |
|
| 117 | + $texte = '<html>' . quote_amp($texte) . '</html>'; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // petites corrections d'URL |
|
| 122 | + if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 123 | + $lien = 'http://' . $lien; |
|
| 124 | + } else { |
|
| 125 | + if (strpos($lien, '@') && email_valide($lien)) { |
|
| 126 | + if (!$texte) { |
|
| 127 | + $texte = $lien; |
|
| 128 | + } |
|
| 129 | + $lien = 'mailto:' . $lien; |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + if ($pour == 'url') { |
|
| 134 | + return $lien; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + if ($pour == 'titre') { |
|
| 138 | + return $texte; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + return ['url' => $lien, 'titre' => $texte]; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, string $connect = '') { |
| 145 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 146 | - $url = $f($texte, $id); |
|
| 147 | - } else { |
|
| 148 | - $url = glossaire_std($texte); |
|
| 149 | - } |
|
| 145 | + if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 146 | + $url = $f($texte, $id); |
|
| 147 | + } else { |
|
| 148 | + $url = glossaire_std($texte); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - return $url; |
|
| 151 | + return $url; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function traiter_lien_implicite($ref, $texte = '', $pour = 'url', string $connect = '') { |
| 155 | - $url = null; |
|
| 156 | - if (!($match = typer_raccourci($ref))) { |
|
| 157 | - return false; |
|
| 158 | - } |
|
| 159 | - [$type, , $id, , $args, , $ancre] = array_pad($match, 7, null); |
|
| 160 | - // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 161 | - // la page locale du site, mais directement sur le site lui-meme |
|
| 162 | - if ($f = charger_fonction("implicite_$type", 'liens', true)) { |
|
| 163 | - $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 164 | - } |
|
| 165 | - if (!$url) { |
|
| 166 | - $url = generer_objet_url($id, $type, $args, $ancre, $connect ?: null); |
|
| 167 | - } |
|
| 168 | - if (!$url) { |
|
| 169 | - return false; |
|
| 170 | - } |
|
| 171 | - if (is_array($url)) { |
|
| 172 | - [$type, $id] = array_pad($url, 2, null); |
|
| 173 | - $url = generer_objet_url($id, $type, $args, $ancre, $connect ?: null); |
|
| 174 | - } |
|
| 175 | - if ($pour === 'url') { |
|
| 176 | - return $url; |
|
| 177 | - } |
|
| 178 | - $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 179 | - if ($r) { |
|
| 180 | - $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 181 | - } |
|
| 182 | - if ($texte = trim($texte)) { |
|
| 183 | - $r['titre'] = $texte; |
|
| 184 | - } |
|
| 185 | - if (!@$r['titre']) { |
|
| 186 | - $r['titre'] = _T($type) . " $id"; |
|
| 187 | - } |
|
| 188 | - if ($pour == 'titre') { |
|
| 189 | - return $r['titre']; |
|
| 190 | - } |
|
| 191 | - $r['url'] = $url; |
|
| 192 | - |
|
| 193 | - // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 194 | - if ( |
|
| 195 | - $type == 'document' |
|
| 196 | - and $mime = sql_getfetsel( |
|
| 197 | - 'mime_type', |
|
| 198 | - 'spip_types_documents', |
|
| 199 | - 'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')', |
|
| 200 | - '', |
|
| 201 | - '', |
|
| 202 | - '', |
|
| 203 | - '', |
|
| 204 | - $connect |
|
| 205 | - ) |
|
| 206 | - ) { |
|
| 207 | - $r['mime'] = $mime; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - return $r; |
|
| 155 | + $url = null; |
|
| 156 | + if (!($match = typer_raccourci($ref))) { |
|
| 157 | + return false; |
|
| 158 | + } |
|
| 159 | + [$type, , $id, , $args, , $ancre] = array_pad($match, 7, null); |
|
| 160 | + // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 161 | + // la page locale du site, mais directement sur le site lui-meme |
|
| 162 | + if ($f = charger_fonction("implicite_$type", 'liens', true)) { |
|
| 163 | + $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 164 | + } |
|
| 165 | + if (!$url) { |
|
| 166 | + $url = generer_objet_url($id, $type, $args, $ancre, $connect ?: null); |
|
| 167 | + } |
|
| 168 | + if (!$url) { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 171 | + if (is_array($url)) { |
|
| 172 | + [$type, $id] = array_pad($url, 2, null); |
|
| 173 | + $url = generer_objet_url($id, $type, $args, $ancre, $connect ?: null); |
|
| 174 | + } |
|
| 175 | + if ($pour === 'url') { |
|
| 176 | + return $url; |
|
| 177 | + } |
|
| 178 | + $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 179 | + if ($r) { |
|
| 180 | + $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 181 | + } |
|
| 182 | + if ($texte = trim($texte)) { |
|
| 183 | + $r['titre'] = $texte; |
|
| 184 | + } |
|
| 185 | + if (!@$r['titre']) { |
|
| 186 | + $r['titre'] = _T($type) . " $id"; |
|
| 187 | + } |
|
| 188 | + if ($pour == 'titre') { |
|
| 189 | + return $r['titre']; |
|
| 190 | + } |
|
| 191 | + $r['url'] = $url; |
|
| 192 | + |
|
| 193 | + // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 194 | + if ( |
|
| 195 | + $type == 'document' |
|
| 196 | + and $mime = sql_getfetsel( |
|
| 197 | + 'mime_type', |
|
| 198 | + 'spip_types_documents', |
|
| 199 | + 'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')', |
|
| 200 | + '', |
|
| 201 | + '', |
|
| 202 | + '', |
|
| 203 | + '', |
|
| 204 | + $connect |
|
| 205 | + ) |
|
| 206 | + ) { |
|
| 207 | + $r['mime'] = $mime; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + return $r; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes |
@@ -215,41 +215,41 @@ discard block |
||
| 215 | 215 | define('_RACCOURCI_URL', '/^\s*(\w*?)\s*(\d+)(\?(.*?))?(#([^\s]*))?\s*$/S'); |
| 216 | 216 | |
| 217 | 217 | function typer_raccourci($lien) { |
| 218 | - if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 219 | - return []; |
|
| 220 | - } |
|
| 221 | - $f = $match[1]; |
|
| 222 | - // valeur par defaut et alias historiques |
|
| 223 | - if (!$f) { |
|
| 224 | - $f = 'article'; |
|
| 225 | - } else { |
|
| 226 | - if ($f == 'art') { |
|
| 227 | - $f = 'article'; |
|
| 228 | - } else { |
|
| 229 | - if ($f == 'br') { |
|
| 230 | - $f = 'breve'; |
|
| 231 | - } else { |
|
| 232 | - if ($f == 'rub') { |
|
| 233 | - $f = 'rubrique'; |
|
| 234 | - } else { |
|
| 235 | - if ($f == 'aut') { |
|
| 236 | - $f = 'auteur'; |
|
| 237 | - } else { |
|
| 238 | - if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 239 | - $f = 'document'; |
|
| 240 | - } else { |
|
| 241 | - if (preg_match('/^br..?ve$/S', $f)) { |
|
| 242 | - $f = 'breve'; |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } # accents :( |
|
| 250 | - $match[0] = $f; |
|
| 251 | - |
|
| 252 | - return $match; |
|
| 218 | + if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 219 | + return []; |
|
| 220 | + } |
|
| 221 | + $f = $match[1]; |
|
| 222 | + // valeur par defaut et alias historiques |
|
| 223 | + if (!$f) { |
|
| 224 | + $f = 'article'; |
|
| 225 | + } else { |
|
| 226 | + if ($f == 'art') { |
|
| 227 | + $f = 'article'; |
|
| 228 | + } else { |
|
| 229 | + if ($f == 'br') { |
|
| 230 | + $f = 'breve'; |
|
| 231 | + } else { |
|
| 232 | + if ($f == 'rub') { |
|
| 233 | + $f = 'rubrique'; |
|
| 234 | + } else { |
|
| 235 | + if ($f == 'aut') { |
|
| 236 | + $f = 'auteur'; |
|
| 237 | + } else { |
|
| 238 | + if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 239 | + $f = 'document'; |
|
| 240 | + } else { |
|
| 241 | + if (preg_match('/^br..?ve$/S', $f)) { |
|
| 242 | + $f = 'breve'; |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } # accents :( |
|
| 250 | + $match[0] = $f; |
|
| 251 | + |
|
| 252 | + return $match; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -264,25 +264,25 @@ discard block |
||
| 264 | 264 | * } |
| 265 | 265 | **/ |
| 266 | 266 | function traiter_raccourci_titre($id, $type, $connect = null) { |
| 267 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 268 | - $desc = $trouver_table(table_objet($type)); |
|
| 269 | - if (!($desc and $s = $desc['titre'])) { |
|
| 270 | - return []; |
|
| 271 | - } |
|
| 272 | - $_id = $desc['key']['PRIMARY KEY']; |
|
| 273 | - $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 274 | - if (!$r) { |
|
| 275 | - return []; |
|
| 276 | - } |
|
| 277 | - $r['titre'] = supprimer_numero($r['titre']); |
|
| 278 | - if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 279 | - $r['titre'] = $r['surnom']; |
|
| 280 | - } |
|
| 281 | - if (!isset($r['lang'])) { |
|
| 282 | - $r['lang'] = ''; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - return $r; |
|
| 267 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 268 | + $desc = $trouver_table(table_objet($type)); |
|
| 269 | + if (!($desc and $s = $desc['titre'])) { |
|
| 270 | + return []; |
|
| 271 | + } |
|
| 272 | + $_id = $desc['key']['PRIMARY KEY']; |
|
| 273 | + $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 274 | + if (!$r) { |
|
| 275 | + return []; |
|
| 276 | + } |
|
| 277 | + $r['titre'] = supprimer_numero($r['titre']); |
|
| 278 | + if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 279 | + $r['titre'] = $r['surnom']; |
|
| 280 | + } |
|
| 281 | + if (!isset($r['lang'])) { |
|
| 282 | + $r['lang'] = ''; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + return $r; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // traite les modeles (dans la fonction typo), en remplacant |
@@ -293,136 +293,136 @@ discard block |
||
| 293 | 293 | // mais on renvoie les params (pour l'indexation par le moteur de recherche) |
| 294 | 294 | |
| 295 | 295 | define( |
| 296 | - '_RACCOURCI_MODELE', |
|
| 297 | - '(<([a-z_-]{3,})' # <modele |
|
| 298 | - . '\s*([0-9]*)\s*' # id |
|
| 299 | - . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 300 | - . '\s*/?' . '>)' # fin du modele > |
|
| 301 | - . '\s*(<\/a>)?' # eventuel </a> |
|
| 296 | + '_RACCOURCI_MODELE', |
|
| 297 | + '(<([a-z_-]{3,})' # <modele |
|
| 298 | + . '\s*([0-9]*)\s*' # id |
|
| 299 | + . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 300 | + . '\s*/?' . '>)' # fin du modele > |
|
| 301 | + . '\s*(<\/a>)?' # eventuel </a> |
|
| 302 | 302 | ); |
| 303 | 303 | |
| 304 | 304 | define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
| 305 | 305 | |
| 306 | 306 | function traiter_modeles($texte, $doublons = false, $echap = '', string $connect = '', $liens = null, $env = []) { |
| 307 | - // preserver la compatibilite : true = recherche des documents |
|
| 308 | - if ($doublons === true) { |
|
| 309 | - $doublons = ['documents' => ['doc', 'emb', 'img']]; |
|
| 310 | - } |
|
| 311 | - // detecter les modeles (rapide) |
|
| 312 | - if ( |
|
| 313 | - strpos($texte, '<') !== false and |
|
| 314 | - preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 315 | - ) { |
|
| 316 | - include_spip('public/assembler'); |
|
| 317 | - $wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true); |
|
| 318 | - foreach ($matches as $match) { |
|
| 319 | - // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 320 | - |
|
| 321 | - $a = strpos($texte, (string) $match[0]); |
|
| 322 | - preg_match( |
|
| 323 | - _RACCOURCI_MODELE_DEBUT, |
|
| 324 | - substr($texte, $a), |
|
| 325 | - $regs |
|
| 326 | - ); |
|
| 327 | - $regs[] = ''; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 328 | - [, $mod, $type, $id, $params, $fin] = $regs; |
|
| 329 | - if ( |
|
| 330 | - $fin and |
|
| 331 | - preg_match( |
|
| 332 | - '/<a\s[^<>]*>\s*$/i', |
|
| 333 | - substr($texte, 0, $a), |
|
| 334 | - $r |
|
| 335 | - ) |
|
| 336 | - ) { |
|
| 337 | - $lien = [ |
|
| 338 | - 'href' => extraire_attribut($r[0], 'href'), |
|
| 339 | - 'class' => extraire_attribut($r[0], 'class'), |
|
| 340 | - 'mime' => extraire_attribut($r[0], 'type'), |
|
| 341 | - 'title' => extraire_attribut($r[0], 'title'), |
|
| 342 | - 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 343 | - ]; |
|
| 344 | - $n = strlen($r[0]); |
|
| 345 | - $a -= $n; |
|
| 346 | - $cherche = $n + strlen($regs[0]); |
|
| 347 | - } else { |
|
| 348 | - $lien = false; |
|
| 349 | - $cherche = strlen($mod); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - // calculer le modele |
|
| 353 | - # hack indexation |
|
| 354 | - if ($doublons) { |
|
| 355 | - $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 356 | - } # version normale |
|
| 357 | - else { |
|
| 358 | - // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 359 | - // dans les parametres, plutot que les liens echappes |
|
| 360 | - if (!is_null($liens)) { |
|
| 361 | - $params = str_replace($liens[0], $liens[1], $params); |
|
| 362 | - } |
|
| 363 | - $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 364 | - // en cas d'echec, |
|
| 365 | - // si l'objet demande a une url, |
|
| 366 | - // creer un petit encadre vers elle |
|
| 367 | - if ($modele === false) { |
|
| 368 | - if (!$lien) { |
|
| 369 | - $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 370 | - } |
|
| 371 | - if ($lien) { |
|
| 372 | - $modele = '<a href="' |
|
| 373 | - . $lien['url'] |
|
| 374 | - . '" class="spip_modele' |
|
| 375 | - . '">' |
|
| 376 | - . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 377 | - . '</a>'; |
|
| 378 | - } else { |
|
| 379 | - $modele = ''; |
|
| 380 | - if (test_espace_prive()) { |
|
| 381 | - $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 382 | - if (!is_null($liens)) { |
|
| 383 | - $modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>'; |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - } |
|
| 388 | - // le remplacer dans le texte |
|
| 389 | - if ($modele !== false) { |
|
| 390 | - $modele = protege_js_modeles($modele); |
|
| 391 | - if ($wrap_embed_html) { |
|
| 392 | - $modele = $wrap_embed_html($mod, $modele); |
|
| 393 | - } |
|
| 394 | - $rempl = code_echappement($modele, $echap); |
|
| 395 | - $texte = substr($texte, 0, $a) |
|
| 396 | - . $rempl |
|
| 397 | - . substr($texte, $a + $cherche); |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - // hack pour tout l'espace prive |
|
| 402 | - if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 403 | - foreach ($doublons ?: ['documents' => ['doc', 'emb', 'img']] as $quoi => $modeles) { |
|
| 404 | - if (in_array($type, $modeles)) { |
|
| 405 | - $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - return $texte; |
|
| 307 | + // preserver la compatibilite : true = recherche des documents |
|
| 308 | + if ($doublons === true) { |
|
| 309 | + $doublons = ['documents' => ['doc', 'emb', 'img']]; |
|
| 310 | + } |
|
| 311 | + // detecter les modeles (rapide) |
|
| 312 | + if ( |
|
| 313 | + strpos($texte, '<') !== false and |
|
| 314 | + preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 315 | + ) { |
|
| 316 | + include_spip('public/assembler'); |
|
| 317 | + $wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true); |
|
| 318 | + foreach ($matches as $match) { |
|
| 319 | + // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 320 | + |
|
| 321 | + $a = strpos($texte, (string) $match[0]); |
|
| 322 | + preg_match( |
|
| 323 | + _RACCOURCI_MODELE_DEBUT, |
|
| 324 | + substr($texte, $a), |
|
| 325 | + $regs |
|
| 326 | + ); |
|
| 327 | + $regs[] = ''; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 328 | + [, $mod, $type, $id, $params, $fin] = $regs; |
|
| 329 | + if ( |
|
| 330 | + $fin and |
|
| 331 | + preg_match( |
|
| 332 | + '/<a\s[^<>]*>\s*$/i', |
|
| 333 | + substr($texte, 0, $a), |
|
| 334 | + $r |
|
| 335 | + ) |
|
| 336 | + ) { |
|
| 337 | + $lien = [ |
|
| 338 | + 'href' => extraire_attribut($r[0], 'href'), |
|
| 339 | + 'class' => extraire_attribut($r[0], 'class'), |
|
| 340 | + 'mime' => extraire_attribut($r[0], 'type'), |
|
| 341 | + 'title' => extraire_attribut($r[0], 'title'), |
|
| 342 | + 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 343 | + ]; |
|
| 344 | + $n = strlen($r[0]); |
|
| 345 | + $a -= $n; |
|
| 346 | + $cherche = $n + strlen($regs[0]); |
|
| 347 | + } else { |
|
| 348 | + $lien = false; |
|
| 349 | + $cherche = strlen($mod); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + // calculer le modele |
|
| 353 | + # hack indexation |
|
| 354 | + if ($doublons) { |
|
| 355 | + $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 356 | + } # version normale |
|
| 357 | + else { |
|
| 358 | + // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 359 | + // dans les parametres, plutot que les liens echappes |
|
| 360 | + if (!is_null($liens)) { |
|
| 361 | + $params = str_replace($liens[0], $liens[1], $params); |
|
| 362 | + } |
|
| 363 | + $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 364 | + // en cas d'echec, |
|
| 365 | + // si l'objet demande a une url, |
|
| 366 | + // creer un petit encadre vers elle |
|
| 367 | + if ($modele === false) { |
|
| 368 | + if (!$lien) { |
|
| 369 | + $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 370 | + } |
|
| 371 | + if ($lien) { |
|
| 372 | + $modele = '<a href="' |
|
| 373 | + . $lien['url'] |
|
| 374 | + . '" class="spip_modele' |
|
| 375 | + . '">' |
|
| 376 | + . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 377 | + . '</a>'; |
|
| 378 | + } else { |
|
| 379 | + $modele = ''; |
|
| 380 | + if (test_espace_prive()) { |
|
| 381 | + $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 382 | + if (!is_null($liens)) { |
|
| 383 | + $modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>'; |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | + // le remplacer dans le texte |
|
| 389 | + if ($modele !== false) { |
|
| 390 | + $modele = protege_js_modeles($modele); |
|
| 391 | + if ($wrap_embed_html) { |
|
| 392 | + $modele = $wrap_embed_html($mod, $modele); |
|
| 393 | + } |
|
| 394 | + $rempl = code_echappement($modele, $echap); |
|
| 395 | + $texte = substr($texte, 0, $a) |
|
| 396 | + . $rempl |
|
| 397 | + . substr($texte, $a + $cherche); |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + // hack pour tout l'espace prive |
|
| 402 | + if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 403 | + foreach ($doublons ?: ['documents' => ['doc', 'emb', 'img']] as $quoi => $modeles) { |
|
| 404 | + if (in_array($type, $modeles)) { |
|
| 405 | + $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + return $texte; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // |
| 416 | 416 | // Raccourcis ancre [#ancre<-] |
| 417 | 417 | // |
| 418 | 418 | function traiter_raccourci_ancre($letexte) { |
| 419 | - return $letexte; |
|
| 419 | + return $letexte; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | function traiter_raccourci_glossaire($texte) { |
| 423 | - return $texte; |
|
| 423 | + return $texte; |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | function glossaire_std($terme) { |
| 427 | - return $terme; |
|
| 427 | + return $terme; |
|
| 428 | 428 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -48,66 +48,66 @@ discard block |
||
| 48 | 48 | * Nom de la fonction, ou false. |
| 49 | 49 | */ |
| 50 | 50 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 51 | - static $echecs = []; |
|
| 52 | - |
|
| 53 | - if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | - $dossier .= '/'; |
|
| 55 | - } |
|
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | - |
|
| 58 | - if (function_exists($f)) { |
|
| 59 | - return $f; |
|
| 60 | - } |
|
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 62 | - return $g; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if (isset($echecs[$f])) { |
|
| 66 | - return $echecs[$f]; |
|
| 67 | - } |
|
| 68 | - // Sinon charger le fichier de declaration si plausible |
|
| 69 | - |
|
| 70 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | - if ($continue) { |
|
| 72 | - return false; |
|
| 73 | - } //appel interne, on passe |
|
| 74 | - include_spip('inc/minipres'); |
|
| 75 | - echo minipres(); |
|
| 76 | - exit; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // passer en minuscules (cf les balises de formulaires) |
|
| 80 | - // et inclure le fichier |
|
| 81 | - if ( |
|
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 83 | - // si le fichier truc/machin/nom.php n'existe pas, |
|
| 84 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 85 | - and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 86 | - ) { |
|
| 87 | - include_spip(substr($dossier, 0, -1)); |
|
| 88 | - } |
|
| 89 | - if (function_exists($f)) { |
|
| 90 | - return $f; |
|
| 91 | - } |
|
| 92 | - if (function_exists($g)) { |
|
| 93 | - return $g; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if ($continue) { |
|
| 97 | - return $echecs[$f] = false; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // Echec : message d'erreur |
|
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 102 | - ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 103 | - |
|
| 104 | - include_spip('inc/minipres'); |
|
| 105 | - echo minipres( |
|
| 106 | - _T('forum_titre_erreur'), |
|
| 107 | - _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | - ['all_inline' => true,'status' => 404] |
|
| 109 | - ); |
|
| 110 | - exit; |
|
| 51 | + static $echecs = []; |
|
| 52 | + |
|
| 53 | + if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | + $dossier .= '/'; |
|
| 55 | + } |
|
| 56 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | + |
|
| 58 | + if (function_exists($f)) { |
|
| 59 | + return $f; |
|
| 60 | + } |
|
| 61 | + if (function_exists($g = $f . '_dist')) { |
|
| 62 | + return $g; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if (isset($echecs[$f])) { |
|
| 66 | + return $echecs[$f]; |
|
| 67 | + } |
|
| 68 | + // Sinon charger le fichier de declaration si plausible |
|
| 69 | + |
|
| 70 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | + if ($continue) { |
|
| 72 | + return false; |
|
| 73 | + } //appel interne, on passe |
|
| 74 | + include_spip('inc/minipres'); |
|
| 75 | + echo minipres(); |
|
| 76 | + exit; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // passer en minuscules (cf les balises de formulaires) |
|
| 80 | + // et inclure le fichier |
|
| 81 | + if ( |
|
| 82 | + !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 83 | + // si le fichier truc/machin/nom.php n'existe pas, |
|
| 84 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 85 | + and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 86 | + ) { |
|
| 87 | + include_spip(substr($dossier, 0, -1)); |
|
| 88 | + } |
|
| 89 | + if (function_exists($f)) { |
|
| 90 | + return $f; |
|
| 91 | + } |
|
| 92 | + if (function_exists($g)) { |
|
| 93 | + return $g; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if ($continue) { |
|
| 97 | + return $echecs[$f] = false; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // Echec : message d'erreur |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 102 | + ($inc ? '' : " (fichier $d absent de $dossier)")); |
|
| 103 | + |
|
| 104 | + include_spip('inc/minipres'); |
|
| 105 | + echo minipres( |
|
| 106 | + _T('forum_titre_erreur'), |
|
| 107 | + _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | + ['all_inline' => true,'status' => 404] |
|
| 109 | + ); |
|
| 110 | + exit; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -117,17 +117,17 @@ discard block |
||
| 117 | 117 | * @return bool |
| 118 | 118 | */ |
| 119 | 119 | function include_once_check($file) { |
| 120 | - if (file_exists($file)) { |
|
| 121 | - include_once $file; |
|
| 120 | + if (file_exists($file)) { |
|
| 121 | + include_once $file; |
|
| 122 | 122 | |
| 123 | - return true; |
|
| 124 | - } |
|
| 125 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 126 | - $crash = ($crash ?: []); |
|
| 127 | - $crash[$file] = true; |
|
| 128 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 123 | + return true; |
|
| 124 | + } |
|
| 125 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 126 | + $crash = ($crash ?: []); |
|
| 127 | + $crash[$file] = true; |
|
| 128 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 129 | 129 | |
| 130 | - return false; |
|
| 130 | + return false; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * - string : chemin du fichier trouvé |
| 152 | 152 | **/ |
| 153 | 153 | function include_spip($f, $include = true) { |
| 154 | - return find_in_path($f . '.php', '', $include); |
|
| 154 | + return find_in_path($f . '.php', '', $include); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * - string : chemin du fichier trouvé |
| 172 | 172 | **/ |
| 173 | 173 | function require_spip($f) { |
| 174 | - return find_in_path($f . '.php', '', 'required'); |
|
| 174 | + return find_in_path($f . '.php', '', 'required'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -180,27 +180,27 @@ discard block |
||
| 180 | 180 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 181 | 181 | */ |
| 182 | 182 | function include_fichiers_fonctions() { |
| 183 | - static $done = false; |
|
| 184 | - if (!$done) { |
|
| 185 | - include_spip('inc/lang'); |
|
| 186 | - |
|
| 187 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 188 | - // donc il faut l'inclure "en globals" |
|
| 189 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 190 | - global $dossier_squelettes; |
|
| 191 | - include_once(_ROOT_CWD . $f); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 195 | - // chargement optimise precompile |
|
| 196 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 197 | - } |
|
| 198 | - if (test_espace_prive()) { |
|
| 199 | - include_spip('inc/filtres_ecrire'); |
|
| 200 | - } |
|
| 201 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 202 | - $done = true; |
|
| 203 | - } |
|
| 183 | + static $done = false; |
|
| 184 | + if (!$done) { |
|
| 185 | + include_spip('inc/lang'); |
|
| 186 | + |
|
| 187 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 188 | + // donc il faut l'inclure "en globals" |
|
| 189 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 190 | + global $dossier_squelettes; |
|
| 191 | + include_once(_ROOT_CWD . $f); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 195 | + // chargement optimise precompile |
|
| 196 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 197 | + } |
|
| 198 | + if (test_espace_prive()) { |
|
| 199 | + include_spip('inc/filtres_ecrire'); |
|
| 200 | + } |
|
| 201 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 202 | + $done = true; |
|
| 203 | + } |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -226,23 +226,23 @@ discard block |
||
| 226 | 226 | * Les paramètres du pipeline modifiés |
| 227 | 227 | **/ |
| 228 | 228 | function minipipe($fonc, &$val) { |
| 229 | - // fonction |
|
| 230 | - if (function_exists($fonc)) { |
|
| 231 | - $val = call_user_func($fonc, $val); |
|
| 232 | - } // Class::Methode |
|
| 233 | - else { |
|
| 234 | - if ( |
|
| 235 | - preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 236 | - and $methode = [$regs[1], $regs[2]] |
|
| 237 | - and is_callable($methode) |
|
| 238 | - ) { |
|
| 239 | - $val = call_user_func($methode, $val); |
|
| 240 | - } else { |
|
| 241 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - return $val; |
|
| 229 | + // fonction |
|
| 230 | + if (function_exists($fonc)) { |
|
| 231 | + $val = call_user_func($fonc, $val); |
|
| 232 | + } // Class::Methode |
|
| 233 | + else { |
|
| 234 | + if ( |
|
| 235 | + preg_match('/^(\w*)::(\w*)$/S', $fonc, $regs) |
|
| 236 | + and $methode = [$regs[1], $regs[2]] |
|
| 237 | + and is_callable($methode) |
|
| 238 | + ) { |
|
| 239 | + $val = call_user_func($methode, $val); |
|
| 240 | + } else { |
|
| 241 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + return $val; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -273,46 +273,46 @@ discard block |
||
| 273 | 273 | * Résultat |
| 274 | 274 | */ |
| 275 | 275 | function pipeline($action, $val = null) { |
| 276 | - static $charger; |
|
| 277 | - |
|
| 278 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 279 | - if (!$charger) { |
|
| 280 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 281 | - include_spip('inc/plugin'); |
|
| 282 | - // generer les fichiers php precompiles |
|
| 283 | - // de chargement des plugins et des pipelines |
|
| 284 | - actualise_plugins_actifs(); |
|
| 285 | - if (!($ok = @is_readable($charger))) { |
|
| 286 | - spip_log("fichier $charger pas cree"); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - if ($ok) { |
|
| 291 | - include_once $charger; |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - // appliquer notre fonction si elle existe |
|
| 296 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 297 | - if (function_exists($fonc)) { |
|
| 298 | - $val = $fonc($val); |
|
| 299 | - } // plantage ? |
|
| 300 | - else { |
|
| 301 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // si le flux est une table avec 2 cle args&data |
|
| 305 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 306 | - // array_key_exists pour php 4.1.0 |
|
| 307 | - if ( |
|
| 308 | - is_array($val) |
|
| 309 | - and count($val) == 2 |
|
| 310 | - and (array_key_exists('data', $val)) |
|
| 311 | - ) { |
|
| 312 | - $val = $val['data']; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - return $val; |
|
| 276 | + static $charger; |
|
| 277 | + |
|
| 278 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 279 | + if (!$charger) { |
|
| 280 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 281 | + include_spip('inc/plugin'); |
|
| 282 | + // generer les fichiers php precompiles |
|
| 283 | + // de chargement des plugins et des pipelines |
|
| 284 | + actualise_plugins_actifs(); |
|
| 285 | + if (!($ok = @is_readable($charger))) { |
|
| 286 | + spip_log("fichier $charger pas cree"); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + if ($ok) { |
|
| 291 | + include_once $charger; |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + // appliquer notre fonction si elle existe |
|
| 296 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 297 | + if (function_exists($fonc)) { |
|
| 298 | + $val = $fonc($val); |
|
| 299 | + } // plantage ? |
|
| 300 | + else { |
|
| 301 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // si le flux est une table avec 2 cle args&data |
|
| 305 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 306 | + // array_key_exists pour php 4.1.0 |
|
| 307 | + if ( |
|
| 308 | + is_array($val) |
|
| 309 | + and count($val) == 2 |
|
| 310 | + and (array_key_exists('data', $val)) |
|
| 311 | + ) { |
|
| 312 | + $val = $val['data']; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + return $val; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -356,38 +356,38 @@ discard block |
||
| 356 | 356 | * paramètre est planté pour cause de compatibilité ascendante. |
| 357 | 357 | */ |
| 358 | 358 | function spip_log($message = null, $name = null) { |
| 359 | - static $pre = []; |
|
| 360 | - static $log; |
|
| 361 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 362 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 363 | - $logname = null; |
|
| 364 | - } |
|
| 365 | - if (!isset($regs[2])) { |
|
| 366 | - $niveau = _LOG_INFO; |
|
| 367 | - } |
|
| 368 | - else { |
|
| 369 | - $niveau = intval($regs[2]); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 373 | - if (!$pre) { |
|
| 374 | - $pre = [ |
|
| 375 | - _LOG_HS => 'HS:', |
|
| 376 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 377 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 378 | - _LOG_ERREUR => 'ERREUR:', |
|
| 379 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 380 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 381 | - _LOG_INFO => 'info:', |
|
| 382 | - _LOG_DEBUG => 'debug:' |
|
| 383 | - ]; |
|
| 384 | - $log = charger_fonction('log', 'inc'); |
|
| 385 | - } |
|
| 386 | - if (!is_string($message)) { |
|
| 387 | - $message = print_r($message, true); |
|
| 388 | - } |
|
| 389 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 390 | - } |
|
| 359 | + static $pre = []; |
|
| 360 | + static $log; |
|
| 361 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 362 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 363 | + $logname = null; |
|
| 364 | + } |
|
| 365 | + if (!isset($regs[2])) { |
|
| 366 | + $niveau = _LOG_INFO; |
|
| 367 | + } |
|
| 368 | + else { |
|
| 369 | + $niveau = intval($regs[2]); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 373 | + if (!$pre) { |
|
| 374 | + $pre = [ |
|
| 375 | + _LOG_HS => 'HS:', |
|
| 376 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 377 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 378 | + _LOG_ERREUR => 'ERREUR:', |
|
| 379 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 380 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 381 | + _LOG_INFO => 'info:', |
|
| 382 | + _LOG_DEBUG => 'debug:' |
|
| 383 | + ]; |
|
| 384 | + $log = charger_fonction('log', 'inc'); |
|
| 385 | + } |
|
| 386 | + if (!is_string($message)) { |
|
| 387 | + $message = print_r($message, true); |
|
| 388 | + } |
|
| 389 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 390 | + } |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -398,8 +398,8 @@ discard block |
||
| 398 | 398 | * @param array $opt Tableau d'options |
| 399 | 399 | **/ |
| 400 | 400 | function journal($phrase, $opt = []) { |
| 401 | - $journal = charger_fonction('journal', 'inc'); |
|
| 402 | - $journal($phrase, $opt); |
|
| 401 | + $journal = charger_fonction('journal', 'inc'); |
|
| 402 | + $journal($phrase, $opt); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | |
@@ -418,37 +418,37 @@ discard block |
||
| 418 | 418 | **/ |
| 419 | 419 | function _request($var, $c = false) { |
| 420 | 420 | |
| 421 | - if (is_array($c)) { |
|
| 422 | - return $c[$var] ?? null; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - if (isset($_GET[$var])) { |
|
| 426 | - $a = $_GET[$var]; |
|
| 427 | - } elseif (isset($_POST[$var])) { |
|
| 428 | - $a = $_POST[$var]; |
|
| 429 | - } else { |
|
| 430 | - return null; |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - // Si on est en ajax et en POST tout a ete encode |
|
| 434 | - // via encodeURIComponent, il faut donc repasser |
|
| 435 | - // dans le charset local... |
|
| 436 | - if ( |
|
| 437 | - defined('_AJAX') |
|
| 438 | - and _AJAX |
|
| 439 | - and isset($GLOBALS['meta']['charset']) |
|
| 440 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 441 | - and is_string($a) |
|
| 442 | - // check rapide mais pas fiable |
|
| 443 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 444 | - // check fiable |
|
| 445 | - and include_spip('inc/charsets') |
|
| 446 | - and is_utf8($a) |
|
| 447 | - ) { |
|
| 448 | - return importer_charset($a, 'utf-8'); |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - return $a; |
|
| 421 | + if (is_array($c)) { |
|
| 422 | + return $c[$var] ?? null; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + if (isset($_GET[$var])) { |
|
| 426 | + $a = $_GET[$var]; |
|
| 427 | + } elseif (isset($_POST[$var])) { |
|
| 428 | + $a = $_POST[$var]; |
|
| 429 | + } else { |
|
| 430 | + return null; |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + // Si on est en ajax et en POST tout a ete encode |
|
| 434 | + // via encodeURIComponent, il faut donc repasser |
|
| 435 | + // dans le charset local... |
|
| 436 | + if ( |
|
| 437 | + defined('_AJAX') |
|
| 438 | + and _AJAX |
|
| 439 | + and isset($GLOBALS['meta']['charset']) |
|
| 440 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 441 | + and is_string($a) |
|
| 442 | + // check rapide mais pas fiable |
|
| 443 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 444 | + // check fiable |
|
| 445 | + and include_spip('inc/charsets') |
|
| 446 | + and is_utf8($a) |
|
| 447 | + ) { |
|
| 448 | + return importer_charset($a, 'utf-8'); |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + return $a; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
@@ -466,22 +466,22 @@ discard block |
||
| 466 | 466 | * - false sinon |
| 467 | 467 | **/ |
| 468 | 468 | function set_request($var, $val = null, $c = false) { |
| 469 | - if (is_array($c)) { |
|
| 470 | - unset($c[$var]); |
|
| 471 | - if ($val !== null) { |
|
| 472 | - $c[$var] = $val; |
|
| 473 | - } |
|
| 469 | + if (is_array($c)) { |
|
| 470 | + unset($c[$var]); |
|
| 471 | + if ($val !== null) { |
|
| 472 | + $c[$var] = $val; |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - return $c; |
|
| 476 | - } |
|
| 475 | + return $c; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - unset($_GET[$var]); |
|
| 479 | - unset($_POST[$var]); |
|
| 480 | - if ($val !== null) { |
|
| 481 | - $_GET[$var] = $val; |
|
| 482 | - } |
|
| 478 | + unset($_GET[$var]); |
|
| 479 | + unset($_POST[$var]); |
|
| 480 | + if ($val !== null) { |
|
| 481 | + $_GET[$var] = $val; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - return false; # n'affecte pas $c |
|
| 484 | + return false; # n'affecte pas $c |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -501,25 +501,25 @@ discard block |
||
| 501 | 501 | * @return array|mixed|string |
| 502 | 502 | */ |
| 503 | 503 | function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') { |
| 504 | - if (is_array($value)) { |
|
| 505 | - if ($key == '*') { |
|
| 506 | - $key = array_keys($value); |
|
| 507 | - } |
|
| 508 | - if (!is_array($key)) { |
|
| 509 | - $key = [$key]; |
|
| 510 | - } |
|
| 511 | - foreach ($key as $k) { |
|
| 512 | - if (!empty($value[$k])) { |
|
| 513 | - $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - return $value; |
|
| 517 | - } |
|
| 518 | - // si la valeur vient des GET ou POST on la sanitize |
|
| 519 | - if (!empty($value) and $value == _request($key)) { |
|
| 520 | - $value = $sanitize_function($value); |
|
| 521 | - } |
|
| 522 | - return $value; |
|
| 504 | + if (is_array($value)) { |
|
| 505 | + if ($key == '*') { |
|
| 506 | + $key = array_keys($value); |
|
| 507 | + } |
|
| 508 | + if (!is_array($key)) { |
|
| 509 | + $key = [$key]; |
|
| 510 | + } |
|
| 511 | + foreach ($key as $k) { |
|
| 512 | + if (!empty($value[$k])) { |
|
| 513 | + $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + return $value; |
|
| 517 | + } |
|
| 518 | + // si la valeur vient des GET ou POST on la sanitize |
|
| 519 | + if (!empty($value) and $value == _request($key)) { |
|
| 520 | + $value = $sanitize_function($value); |
|
| 521 | + } |
|
| 522 | + return $value; |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
@@ -527,23 +527,22 @@ discard block |
||
| 527 | 527 | * |
| 528 | 528 | * On est sur le web, on exclut certains protocoles, |
| 529 | 529 | * notamment 'file://', 'php://' et d'autres… |
| 530 | - |
|
| 531 | 530 | * @param string $url |
| 532 | 531 | * @return bool |
| 533 | 532 | */ |
| 534 | 533 | function tester_url_absolue($url) { |
| 535 | - $url = trim($url); |
|
| 536 | - if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 537 | - if ( |
|
| 538 | - isset($m[1]) |
|
| 539 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 540 | - and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 541 | - ) { |
|
| 542 | - return false; |
|
| 543 | - } |
|
| 544 | - return true; |
|
| 545 | - } |
|
| 546 | - return false; |
|
| 534 | + $url = trim($url); |
|
| 535 | + if (preg_match(';^([a-z]{3,7}:)?//;Uims', $url, $m)) { |
|
| 536 | + if ( |
|
| 537 | + isset($m[1]) |
|
| 538 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 539 | + and in_array($p, ['file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip']) |
|
| 540 | + ) { |
|
| 541 | + return false; |
|
| 542 | + } |
|
| 543 | + return true; |
|
| 544 | + } |
|
| 545 | + return false; |
|
| 547 | 546 | } |
| 548 | 547 | |
| 549 | 548 | /** |
@@ -565,95 +564,95 @@ discard block |
||
| 565 | 564 | * @return string URL |
| 566 | 565 | */ |
| 567 | 566 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 568 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 569 | - if (strpos($c, '|') !== false and is_null($v)) { |
|
| 570 | - return null; |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - // lever l'#ancre |
|
| 574 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 575 | - $url = $r[1]; |
|
| 576 | - $ancre = $r[2]; |
|
| 577 | - } else { |
|
| 578 | - $ancre = ''; |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - // eclater |
|
| 582 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 583 | - |
|
| 584 | - // recuperer la base |
|
| 585 | - $a = array_shift($url); |
|
| 586 | - if (!$a) { |
|
| 587 | - $a = './'; |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 591 | - $ajouts = array_flip(explode('|', $c)); |
|
| 592 | - $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 593 | - $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 594 | - $v_read = null; |
|
| 595 | - // lire les variables et agir |
|
| 596 | - foreach ($url as $n => $val) { |
|
| 597 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 598 | - $r = array_pad($r, 3, null); |
|
| 599 | - if ($v === null) { |
|
| 600 | - // c'est un tableau, on memorise les valeurs |
|
| 601 | - if (substr($r[1], -2) == '[]') { |
|
| 602 | - if (!$v_read) { |
|
| 603 | - $v_read = []; |
|
| 604 | - } |
|
| 605 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 606 | - } // c'est un scalaire, on retourne direct |
|
| 607 | - else { |
|
| 608 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 609 | - } |
|
| 610 | - } // suppression |
|
| 611 | - elseif (!$testv) { |
|
| 612 | - unset($url[$n]); |
|
| 613 | - } |
|
| 614 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 615 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 616 | - elseif (substr($r[1], -2) != '[]') { |
|
| 617 | - $url[$n] = $r[1] . '=' . $u; |
|
| 618 | - unset($ajouts[$r[1]]); |
|
| 619 | - } |
|
| 620 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 621 | - // départ, on remplira à l'étape suivante |
|
| 622 | - else { |
|
| 623 | - unset($url[$n]); |
|
| 624 | - } |
|
| 625 | - } |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - // traiter les parametres pas encore trouves |
|
| 629 | - if ( |
|
| 630 | - $v === null |
|
| 631 | - and $args = func_get_args() |
|
| 632 | - and count($args) == 2 |
|
| 633 | - ) { |
|
| 634 | - return $v_read; // rien trouve ou un tableau |
|
| 635 | - } elseif ($testv) { |
|
| 636 | - foreach ($ajouts as $k => $n) { |
|
| 637 | - if (!is_array($v)) { |
|
| 638 | - $url[] = $k . '=' . $u; |
|
| 639 | - } else { |
|
| 640 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 641 | - foreach ($v as $w) { |
|
| 642 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 643 | - } |
|
| 644 | - } |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - // eliminer les vides |
|
| 649 | - $url = array_filter($url); |
|
| 650 | - |
|
| 651 | - // recomposer l'adresse |
|
| 652 | - if ($url) { |
|
| 653 | - $a .= '?' . join($sep, $url); |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - return $a . $ancre; |
|
| 567 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 568 | + if (strpos($c, '|') !== false and is_null($v)) { |
|
| 569 | + return null; |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + // lever l'#ancre |
|
| 573 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 574 | + $url = $r[1]; |
|
| 575 | + $ancre = $r[2]; |
|
| 576 | + } else { |
|
| 577 | + $ancre = ''; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + // eclater |
|
| 581 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 582 | + |
|
| 583 | + // recuperer la base |
|
| 584 | + $a = array_shift($url); |
|
| 585 | + if (!$a) { |
|
| 586 | + $a = './'; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 590 | + $ajouts = array_flip(explode('|', $c)); |
|
| 591 | + $u = is_array($v) ? $v : rawurlencode((string) $v); |
|
| 592 | + $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
|
| 593 | + $v_read = null; |
|
| 594 | + // lire les variables et agir |
|
| 595 | + foreach ($url as $n => $val) { |
|
| 596 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 597 | + $r = array_pad($r, 3, null); |
|
| 598 | + if ($v === null) { |
|
| 599 | + // c'est un tableau, on memorise les valeurs |
|
| 600 | + if (substr($r[1], -2) == '[]') { |
|
| 601 | + if (!$v_read) { |
|
| 602 | + $v_read = []; |
|
| 603 | + } |
|
| 604 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 605 | + } // c'est un scalaire, on retourne direct |
|
| 606 | + else { |
|
| 607 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 608 | + } |
|
| 609 | + } // suppression |
|
| 610 | + elseif (!$testv) { |
|
| 611 | + unset($url[$n]); |
|
| 612 | + } |
|
| 613 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 614 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 615 | + elseif (substr($r[1], -2) != '[]') { |
|
| 616 | + $url[$n] = $r[1] . '=' . $u; |
|
| 617 | + unset($ajouts[$r[1]]); |
|
| 618 | + } |
|
| 619 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 620 | + // départ, on remplira à l'étape suivante |
|
| 621 | + else { |
|
| 622 | + unset($url[$n]); |
|
| 623 | + } |
|
| 624 | + } |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + // traiter les parametres pas encore trouves |
|
| 628 | + if ( |
|
| 629 | + $v === null |
|
| 630 | + and $args = func_get_args() |
|
| 631 | + and count($args) == 2 |
|
| 632 | + ) { |
|
| 633 | + return $v_read; // rien trouve ou un tableau |
|
| 634 | + } elseif ($testv) { |
|
| 635 | + foreach ($ajouts as $k => $n) { |
|
| 636 | + if (!is_array($v)) { |
|
| 637 | + $url[] = $k . '=' . $u; |
|
| 638 | + } else { |
|
| 639 | + $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 640 | + foreach ($v as $w) { |
|
| 641 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 642 | + } |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + // eliminer les vides |
|
| 648 | + $url = array_filter($url); |
|
| 649 | + |
|
| 650 | + // recomposer l'adresse |
|
| 651 | + if ($url) { |
|
| 652 | + $a .= '?' . join($sep, $url); |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + return $a . $ancre; |
|
| 657 | 656 | } |
| 658 | 657 | |
| 659 | 658 | /** |
@@ -671,21 +670,21 @@ discard block |
||
| 671 | 670 | * @return string |
| 672 | 671 | */ |
| 673 | 672 | function ancre_url($url, $ancre) { |
| 674 | - // lever l'#ancre |
|
| 675 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 676 | - $url = $r[1]; |
|
| 677 | - } |
|
| 678 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 679 | - if (!function_exists('translitteration')) { |
|
| 680 | - include_spip('inc/charsets'); |
|
| 681 | - } |
|
| 682 | - $ancre = preg_replace( |
|
| 683 | - ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 684 | - ['', '-'], |
|
| 685 | - translitteration($ancre) |
|
| 686 | - ); |
|
| 687 | - } |
|
| 688 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 673 | + // lever l'#ancre |
|
| 674 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 675 | + $url = $r[1]; |
|
| 676 | + } |
|
| 677 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 678 | + if (!function_exists('translitteration')) { |
|
| 679 | + include_spip('inc/charsets'); |
|
| 680 | + } |
|
| 681 | + $ancre = preg_replace( |
|
| 682 | + ['/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'], |
|
| 683 | + ['', '-'], |
|
| 684 | + translitteration($ancre) |
|
| 685 | + ); |
|
| 686 | + } |
|
| 687 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 689 | 688 | } |
| 690 | 689 | |
| 691 | 690 | /** |
@@ -695,16 +694,16 @@ discard block |
||
| 695 | 694 | * @return string |
| 696 | 695 | */ |
| 697 | 696 | function nettoyer_uri($reset = null) { |
| 698 | - static $done = false; |
|
| 699 | - static $propre = ''; |
|
| 700 | - if (!is_null($reset)) { |
|
| 701 | - return $propre = $reset; |
|
| 702 | - } |
|
| 703 | - if ($done) { |
|
| 704 | - return $propre; |
|
| 705 | - } |
|
| 706 | - $done = true; |
|
| 707 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 697 | + static $done = false; |
|
| 698 | + static $propre = ''; |
|
| 699 | + if (!is_null($reset)) { |
|
| 700 | + return $propre = $reset; |
|
| 701 | + } |
|
| 702 | + if ($done) { |
|
| 703 | + return $propre; |
|
| 704 | + } |
|
| 705 | + $done = true; |
|
| 706 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 708 | 707 | } |
| 709 | 708 | |
| 710 | 709 | /** |
@@ -716,16 +715,16 @@ discard block |
||
| 716 | 715 | * @return string |
| 717 | 716 | */ |
| 718 | 717 | function nettoyer_uri_var($request_uri) { |
| 719 | - $uri1 = $request_uri; |
|
| 720 | - do { |
|
| 721 | - $uri = $uri1; |
|
| 722 | - $uri1 = preg_replace( |
|
| 723 | - ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 724 | - '\1', |
|
| 725 | - $uri |
|
| 726 | - ); |
|
| 727 | - } while ($uri <> $uri1); |
|
| 728 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 718 | + $uri1 = $request_uri; |
|
| 719 | + do { |
|
| 720 | + $uri = $uri1; |
|
| 721 | + $uri1 = preg_replace( |
|
| 722 | + ',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 723 | + '\1', |
|
| 724 | + $uri |
|
| 725 | + ); |
|
| 726 | + } while ($uri <> $uri1); |
|
| 727 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 729 | 728 | } |
| 730 | 729 | |
| 731 | 730 | |
@@ -739,48 +738,48 @@ discard block |
||
| 739 | 738 | * URL vers soi-même |
| 740 | 739 | **/ |
| 741 | 740 | function self($amp = '&', $root = false) { |
| 742 | - $url = nettoyer_uri(); |
|
| 743 | - if ( |
|
| 744 | - !$root |
|
| 745 | - and ( |
|
| 746 | - // si pas de profondeur on peut tronquer |
|
| 747 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 748 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 749 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 750 | - ) { |
|
| 751 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 752 | - } |
|
| 753 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 754 | - foreach ($_POST as $v => $c) { |
|
| 755 | - if (substr($v, 0, 3) == 'id_') { |
|
| 756 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 757 | - } |
|
| 758 | - } |
|
| 759 | - |
|
| 760 | - // supprimer les variables sans interet |
|
| 761 | - if (test_espace_prive()) { |
|
| 762 | - $url = preg_replace(',([?&])(' |
|
| 763 | - . 'lang|show_docs|' |
|
| 764 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 765 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 766 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 767 | - } |
|
| 768 | - |
|
| 769 | - // eviter les hacks |
|
| 770 | - include_spip('inc/filtres_mini'); |
|
| 771 | - $url = spip_htmlspecialchars($url); |
|
| 772 | - |
|
| 773 | - $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 774 | - |
|
| 775 | - // & ? |
|
| 776 | - if ($amp != '&') { |
|
| 777 | - $url = str_replace('&', $amp, $url); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - // Si ca demarre par ? ou vide, donner './' |
|
| 781 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 782 | - |
|
| 783 | - return $url; |
|
| 741 | + $url = nettoyer_uri(); |
|
| 742 | + if ( |
|
| 743 | + !$root |
|
| 744 | + and ( |
|
| 745 | + // si pas de profondeur on peut tronquer |
|
| 746 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 747 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 748 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 749 | + ) { |
|
| 750 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 751 | + } |
|
| 752 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 753 | + foreach ($_POST as $v => $c) { |
|
| 754 | + if (substr($v, 0, 3) == 'id_') { |
|
| 755 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 756 | + } |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + // supprimer les variables sans interet |
|
| 760 | + if (test_espace_prive()) { |
|
| 761 | + $url = preg_replace(',([?&])(' |
|
| 762 | + . 'lang|show_docs|' |
|
| 763 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 764 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 765 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + // eviter les hacks |
|
| 769 | + include_spip('inc/filtres_mini'); |
|
| 770 | + $url = spip_htmlspecialchars($url); |
|
| 771 | + |
|
| 772 | + $url = str_replace(["'", '"', '<', '[', ']', ':'], ['%27', '%22', '%3C', '%5B', '%5D', '%3A'], $url); |
|
| 773 | + |
|
| 774 | + // & ? |
|
| 775 | + if ($amp != '&') { |
|
| 776 | + $url = str_replace('&', $amp, $url); |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + // Si ca demarre par ? ou vide, donner './' |
|
| 780 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 781 | + |
|
| 782 | + return $url; |
|
| 784 | 783 | } |
| 785 | 784 | |
| 786 | 785 | |
@@ -791,7 +790,7 @@ discard block |
||
| 791 | 790 | * true si c'est le cas, false sinon. |
| 792 | 791 | */ |
| 793 | 792 | function test_espace_prive() { |
| 794 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 793 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 795 | 794 | } |
| 796 | 795 | |
| 797 | 796 | /** |
@@ -801,7 +800,7 @@ discard block |
||
| 801 | 800 | * @return bool |
| 802 | 801 | */ |
| 803 | 802 | function test_plugin_actif($plugin) { |
| 804 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 803 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 805 | 804 | } |
| 806 | 805 | |
| 807 | 806 | /** |
@@ -832,52 +831,52 @@ discard block |
||
| 832 | 831 | * Texte |
| 833 | 832 | */ |
| 834 | 833 | function _T($texte, $args = [], $options = []) { |
| 835 | - static $traduire = false; |
|
| 836 | - $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 837 | - if ($options) { |
|
| 838 | - // support de l'ancien argument $class |
|
| 839 | - if (is_string($options)) { |
|
| 840 | - $options = ['class' => $options]; |
|
| 841 | - } |
|
| 842 | - $o = array_merge($o, $options); |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - if (!$traduire) { |
|
| 846 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 847 | - include_spip('inc/lang'); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - // On peut passer explicitement la langue dans le tableau |
|
| 851 | - // On utilise le même nom de variable que la globale |
|
| 852 | - if (isset($args['spip_lang'])) { |
|
| 853 | - $lang = $args['spip_lang']; |
|
| 854 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 855 | - unset($args['spip_lang']); |
|
| 856 | - } // Sinon on prend la langue du contexte |
|
| 857 | - else { |
|
| 858 | - $lang = $GLOBALS['spip_lang']; |
|
| 859 | - } |
|
| 860 | - $text = $traduire($texte, $lang); |
|
| 861 | - |
|
| 862 | - if ($text === null || !strlen($text)) { |
|
| 863 | - if (!$o['force']) { |
|
| 864 | - return ''; |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - $text = $texte; |
|
| 868 | - |
|
| 869 | - // pour les chaines non traduites, assurer un service minimum |
|
| 870 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 871 | - $n = strpos($text, ':'); |
|
| 872 | - if ($n !== false) { |
|
| 873 | - $text = substr($text, $n + 1); |
|
| 874 | - } |
|
| 875 | - $text = str_replace('_', ' ', $text); |
|
| 876 | - } |
|
| 877 | - $o['class'] = null; |
|
| 878 | - } |
|
| 879 | - |
|
| 880 | - return _L($text, $args, $o); |
|
| 834 | + static $traduire = false; |
|
| 835 | + $o = ['class' => '', 'force' => true, 'sanitize' => true]; |
|
| 836 | + if ($options) { |
|
| 837 | + // support de l'ancien argument $class |
|
| 838 | + if (is_string($options)) { |
|
| 839 | + $options = ['class' => $options]; |
|
| 840 | + } |
|
| 841 | + $o = array_merge($o, $options); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + if (!$traduire) { |
|
| 845 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 846 | + include_spip('inc/lang'); |
|
| 847 | + } |
|
| 848 | + |
|
| 849 | + // On peut passer explicitement la langue dans le tableau |
|
| 850 | + // On utilise le même nom de variable que la globale |
|
| 851 | + if (isset($args['spip_lang'])) { |
|
| 852 | + $lang = $args['spip_lang']; |
|
| 853 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 854 | + unset($args['spip_lang']); |
|
| 855 | + } // Sinon on prend la langue du contexte |
|
| 856 | + else { |
|
| 857 | + $lang = $GLOBALS['spip_lang']; |
|
| 858 | + } |
|
| 859 | + $text = $traduire($texte, $lang); |
|
| 860 | + |
|
| 861 | + if ($text === null || !strlen($text)) { |
|
| 862 | + if (!$o['force']) { |
|
| 863 | + return ''; |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + $text = $texte; |
|
| 867 | + |
|
| 868 | + // pour les chaines non traduites, assurer un service minimum |
|
| 869 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 870 | + $n = strpos($text, ':'); |
|
| 871 | + if ($n !== false) { |
|
| 872 | + $text = substr($text, $n + 1); |
|
| 873 | + } |
|
| 874 | + $text = str_replace('_', ' ', $text); |
|
| 875 | + } |
|
| 876 | + $o['class'] = null; |
|
| 877 | + } |
|
| 878 | + |
|
| 879 | + return _L($text, $args, $o); |
|
| 881 | 880 | } |
| 882 | 881 | |
| 883 | 882 | |
@@ -904,53 +903,53 @@ discard block |
||
| 904 | 903 | * Texte |
| 905 | 904 | */ |
| 906 | 905 | function _L($text, $args = [], $options = []) { |
| 907 | - $f = $text; |
|
| 908 | - $defaut_options = [ |
|
| 909 | - 'class' => null, |
|
| 910 | - 'sanitize' => true, |
|
| 911 | - ]; |
|
| 912 | - // support de l'ancien argument $class |
|
| 913 | - if ($options and is_string($options)) { |
|
| 914 | - $options = ['class' => $options]; |
|
| 915 | - } |
|
| 916 | - if (is_array($options)) { |
|
| 917 | - $options += $defaut_options; |
|
| 918 | - } else { |
|
| 919 | - $options = $defaut_options; |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - if (is_array($args) and count($args)) { |
|
| 923 | - if (!function_exists('interdire_scripts')) { |
|
| 924 | - include_spip('inc/texte'); |
|
| 925 | - } |
|
| 926 | - if (!function_exists('echapper_html_suspect')) { |
|
| 927 | - include_spip('inc/texte_mini'); |
|
| 928 | - } |
|
| 929 | - foreach ($args as $name => $value) { |
|
| 930 | - if (strpos($text, (string) "@$name@") !== false) { |
|
| 931 | - if ($options['sanitize']) { |
|
| 932 | - $value = echapper_html_suspect($value); |
|
| 933 | - $value = interdire_scripts($value, -1); |
|
| 934 | - } |
|
| 935 | - if (!empty($options['class'])) { |
|
| 936 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 937 | - } |
|
| 938 | - $text = str_replace("@$name@", $value, $text); |
|
| 939 | - unset($args[$name]); |
|
| 940 | - } |
|
| 941 | - } |
|
| 942 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 943 | - // (chaines de langues pas a jour) |
|
| 944 | - if ($args) { |
|
| 945 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 946 | - } |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 950 | - return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 951 | - } else { |
|
| 952 | - return $text; |
|
| 953 | - } |
|
| 906 | + $f = $text; |
|
| 907 | + $defaut_options = [ |
|
| 908 | + 'class' => null, |
|
| 909 | + 'sanitize' => true, |
|
| 910 | + ]; |
|
| 911 | + // support de l'ancien argument $class |
|
| 912 | + if ($options and is_string($options)) { |
|
| 913 | + $options = ['class' => $options]; |
|
| 914 | + } |
|
| 915 | + if (is_array($options)) { |
|
| 916 | + $options += $defaut_options; |
|
| 917 | + } else { |
|
| 918 | + $options = $defaut_options; |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + if (is_array($args) and count($args)) { |
|
| 922 | + if (!function_exists('interdire_scripts')) { |
|
| 923 | + include_spip('inc/texte'); |
|
| 924 | + } |
|
| 925 | + if (!function_exists('echapper_html_suspect')) { |
|
| 926 | + include_spip('inc/texte_mini'); |
|
| 927 | + } |
|
| 928 | + foreach ($args as $name => $value) { |
|
| 929 | + if (strpos($text, (string) "@$name@") !== false) { |
|
| 930 | + if ($options['sanitize']) { |
|
| 931 | + $value = echapper_html_suspect($value); |
|
| 932 | + $value = interdire_scripts($value, -1); |
|
| 933 | + } |
|
| 934 | + if (!empty($options['class'])) { |
|
| 935 | + $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 936 | + } |
|
| 937 | + $text = str_replace("@$name@", $value, $text); |
|
| 938 | + unset($args[$name]); |
|
| 939 | + } |
|
| 940 | + } |
|
| 941 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 942 | + // (chaines de langues pas a jour) |
|
| 943 | + if ($args) { |
|
| 944 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 945 | + } |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 949 | + return "<span class='debug-traduction-erreur'>$text</span>"; |
|
| 950 | + } else { |
|
| 951 | + return $text; |
|
| 952 | + } |
|
| 954 | 953 | } |
| 955 | 954 | |
| 956 | 955 | |
@@ -964,13 +963,13 @@ discard block |
||
| 964 | 963 | * @return string |
| 965 | 964 | */ |
| 966 | 965 | function joli_repertoire($rep) { |
| 967 | - $a = substr($rep, 0, 1); |
|
| 968 | - if ($a <> '.' and $a <> '/') { |
|
| 969 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 970 | - } |
|
| 971 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 966 | + $a = substr($rep, 0, 1); |
|
| 967 | + if ($a <> '.' and $a <> '/') { |
|
| 968 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 969 | + } |
|
| 970 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 972 | 971 | |
| 973 | - return $rep; |
|
| 972 | + return $rep; |
|
| 974 | 973 | } |
| 975 | 974 | |
| 976 | 975 | |
@@ -995,54 +994,54 @@ discard block |
||
| 995 | 994 | * @return float|int|string|void |
| 996 | 995 | */ |
| 997 | 996 | function spip_timer($t = 'rien', $raw = false) { |
| 998 | - static $time; |
|
| 999 | - $a = time(); |
|
| 1000 | - $b = microtime(); |
|
| 1001 | - // microtime peut contenir les microsecondes et le temps |
|
| 1002 | - $b = explode(' ', $b); |
|
| 1003 | - if (count($b) == 2) { |
|
| 1004 | - $a = end($b); |
|
| 1005 | - } // plus precis ! |
|
| 1006 | - $b = reset($b); |
|
| 1007 | - if (!isset($time[$t])) { |
|
| 1008 | - $time[$t] = $a + $b; |
|
| 1009 | - } else { |
|
| 1010 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 1011 | - unset($time[$t]); |
|
| 997 | + static $time; |
|
| 998 | + $a = time(); |
|
| 999 | + $b = microtime(); |
|
| 1000 | + // microtime peut contenir les microsecondes et le temps |
|
| 1001 | + $b = explode(' ', $b); |
|
| 1002 | + if (count($b) == 2) { |
|
| 1003 | + $a = end($b); |
|
| 1004 | + } // plus precis ! |
|
| 1005 | + $b = reset($b); |
|
| 1006 | + if (!isset($time[$t])) { |
|
| 1007 | + $time[$t] = $a + $b; |
|
| 1008 | + } else { |
|
| 1009 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 1010 | + unset($time[$t]); |
|
| 1012 | 1011 | # echo "'$p'";exit; |
| 1013 | - if ($raw) { |
|
| 1014 | - return $p; |
|
| 1015 | - } |
|
| 1016 | - if ($p < 1000) { |
|
| 1017 | - $s = ''; |
|
| 1018 | - } else { |
|
| 1019 | - $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1020 | - $p -= ($x * 1000); |
|
| 1021 | - } |
|
| 1012 | + if ($raw) { |
|
| 1013 | + return $p; |
|
| 1014 | + } |
|
| 1015 | + if ($p < 1000) { |
|
| 1016 | + $s = ''; |
|
| 1017 | + } else { |
|
| 1018 | + $s = sprintf('%d ', $x = floor($p / 1000)); |
|
| 1019 | + $p -= ($x * 1000); |
|
| 1020 | + } |
|
| 1022 | 1021 | |
| 1023 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1024 | - } |
|
| 1022 | + return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1023 | + } |
|
| 1025 | 1024 | } |
| 1026 | 1025 | |
| 1027 | 1026 | |
| 1028 | 1027 | // Renvoie False si un fichier n'est pas plus vieux que $duree secondes, |
| 1029 | 1028 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 1030 | 1029 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 1031 | - if ($duree) { |
|
| 1032 | - clearstatcache(); |
|
| 1033 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1034 | - return false; |
|
| 1035 | - } |
|
| 1036 | - } |
|
| 1037 | - if ($touch !== false) { |
|
| 1038 | - if (!@touch($fichier)) { |
|
| 1039 | - spip_unlink($fichier); |
|
| 1040 | - @touch($fichier); |
|
| 1041 | - }; |
|
| 1042 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1043 | - } |
|
| 1030 | + if ($duree) { |
|
| 1031 | + clearstatcache(); |
|
| 1032 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1033 | + return false; |
|
| 1034 | + } |
|
| 1035 | + } |
|
| 1036 | + if ($touch !== false) { |
|
| 1037 | + if (!@touch($fichier)) { |
|
| 1038 | + spip_unlink($fichier); |
|
| 1039 | + @touch($fichier); |
|
| 1040 | + }; |
|
| 1041 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1042 | + } |
|
| 1044 | 1043 | |
| 1045 | - return true; |
|
| 1044 | + return true; |
|
| 1046 | 1045 | } |
| 1047 | 1046 | |
| 1048 | 1047 | |
@@ -1053,11 +1052,11 @@ discard block |
||
| 1053 | 1052 | * @uses cron() |
| 1054 | 1053 | **/ |
| 1055 | 1054 | function action_cron() { |
| 1056 | - include_spip('inc/headers'); |
|
| 1057 | - http_response_code(204); // No Content |
|
| 1058 | - header('Connection: close'); |
|
| 1059 | - define('_DIRECT_CRON_FORCE', true); |
|
| 1060 | - cron(); |
|
| 1055 | + include_spip('inc/headers'); |
|
| 1056 | + http_response_code(204); // No Content |
|
| 1057 | + header('Connection: close'); |
|
| 1058 | + define('_DIRECT_CRON_FORCE', true); |
|
| 1059 | + cron(); |
|
| 1061 | 1060 | } |
| 1062 | 1061 | |
| 1063 | 1062 | /** |
@@ -1073,26 +1072,26 @@ discard block |
||
| 1073 | 1072 | * True si la tache a pu être effectuée |
| 1074 | 1073 | */ |
| 1075 | 1074 | function cron($taches = [], $taches_old = []) { |
| 1076 | - // si pas en mode cron force, laisser tomber. |
|
| 1077 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1078 | - return false; |
|
| 1079 | - } |
|
| 1080 | - if (!is_array($taches)) { |
|
| 1081 | - $taches = $taches_old; |
|
| 1082 | - } // compat anciens appels |
|
| 1083 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1084 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1085 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1086 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1087 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1088 | - return false; |
|
| 1089 | - } |
|
| 1090 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1091 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1092 | - return $genie($taches); |
|
| 1093 | - } |
|
| 1094 | - |
|
| 1095 | - return false; |
|
| 1075 | + // si pas en mode cron force, laisser tomber. |
|
| 1076 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1077 | + return false; |
|
| 1078 | + } |
|
| 1079 | + if (!is_array($taches)) { |
|
| 1080 | + $taches = $taches_old; |
|
| 1081 | + } // compat anciens appels |
|
| 1082 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1083 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1084 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1085 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1086 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1087 | + return false; |
|
| 1088 | + } |
|
| 1089 | + spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1090 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1091 | + return $genie($taches); |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + return false; |
|
| 1096 | 1095 | } |
| 1097 | 1096 | |
| 1098 | 1097 | /** |
@@ -1124,17 +1123,17 @@ discard block |
||
| 1124 | 1123 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1125 | 1124 | */ |
| 1126 | 1125 | function job_queue_add( |
| 1127 | - $function, |
|
| 1128 | - $description, |
|
| 1129 | - $arguments = [], |
|
| 1130 | - $file = '', |
|
| 1131 | - $no_duplicate = false, |
|
| 1132 | - $time = 0, |
|
| 1133 | - $priority = 0 |
|
| 1126 | + $function, |
|
| 1127 | + $description, |
|
| 1128 | + $arguments = [], |
|
| 1129 | + $file = '', |
|
| 1130 | + $no_duplicate = false, |
|
| 1131 | + $time = 0, |
|
| 1132 | + $priority = 0 |
|
| 1134 | 1133 | ) { |
| 1135 | - include_spip('inc/queue'); |
|
| 1134 | + include_spip('inc/queue'); |
|
| 1136 | 1135 | |
| 1137 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1136 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1138 | 1137 | } |
| 1139 | 1138 | |
| 1140 | 1139 | /** |
@@ -1145,9 +1144,9 @@ discard block |
||
| 1145 | 1144 | * @return bool |
| 1146 | 1145 | */ |
| 1147 | 1146 | function job_queue_remove($id_job) { |
| 1148 | - include_spip('inc/queue'); |
|
| 1147 | + include_spip('inc/queue'); |
|
| 1149 | 1148 | |
| 1150 | - return queue_remove_job($id_job); |
|
| 1149 | + return queue_remove_job($id_job); |
|
| 1151 | 1150 | } |
| 1152 | 1151 | |
| 1153 | 1152 | /** |
@@ -1160,9 +1159,9 @@ discard block |
||
| 1160 | 1159 | * or an array of simple array to link multiples objet in one time |
| 1161 | 1160 | */ |
| 1162 | 1161 | function job_queue_link($id_job, $objets) { |
| 1163 | - include_spip('inc/queue'); |
|
| 1162 | + include_spip('inc/queue'); |
|
| 1164 | 1163 | |
| 1165 | - return queue_link_job($id_job, $objets); |
|
| 1164 | + return queue_link_job($id_job, $objets); |
|
| 1166 | 1165 | } |
| 1167 | 1166 | |
| 1168 | 1167 | |
@@ -1182,36 +1181,36 @@ discard block |
||
| 1182 | 1181 | * - `null` si la queue n'est pas encore initialisée |
| 1183 | 1182 | */ |
| 1184 | 1183 | function queue_sleep_time_to_next_job($force = null) { |
| 1185 | - static $queue_next_job_time = -1; |
|
| 1186 | - if ($force === true) { |
|
| 1187 | - $queue_next_job_time = -1; |
|
| 1188 | - } elseif ($force) { |
|
| 1189 | - $queue_next_job_time = $force; |
|
| 1190 | - } |
|
| 1191 | - |
|
| 1192 | - if ($queue_next_job_time == -1) { |
|
| 1193 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1194 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1195 | - } |
|
| 1196 | - // utiliser un cache memoire si dispo |
|
| 1197 | - if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1198 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1199 | - } else { |
|
| 1200 | - $queue_next_job_time = null; |
|
| 1201 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1202 | - $queue_next_job_time = intval($contenu); |
|
| 1203 | - } |
|
| 1204 | - } |
|
| 1205 | - } |
|
| 1206 | - |
|
| 1207 | - if (is_null($queue_next_job_time)) { |
|
| 1208 | - return null; |
|
| 1209 | - } |
|
| 1210 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1211 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1212 | - } |
|
| 1213 | - |
|
| 1214 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1184 | + static $queue_next_job_time = -1; |
|
| 1185 | + if ($force === true) { |
|
| 1186 | + $queue_next_job_time = -1; |
|
| 1187 | + } elseif ($force) { |
|
| 1188 | + $queue_next_job_time = $force; |
|
| 1189 | + } |
|
| 1190 | + |
|
| 1191 | + if ($queue_next_job_time == -1) { |
|
| 1192 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1193 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1194 | + } |
|
| 1195 | + // utiliser un cache memoire si dispo |
|
| 1196 | + if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1197 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1198 | + } else { |
|
| 1199 | + $queue_next_job_time = null; |
|
| 1200 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1201 | + $queue_next_job_time = intval($contenu); |
|
| 1202 | + } |
|
| 1203 | + } |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + if (is_null($queue_next_job_time)) { |
|
| 1207 | + return null; |
|
| 1208 | + } |
|
| 1209 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1210 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1215 | 1214 | } |
| 1216 | 1215 | |
| 1217 | 1216 | |
@@ -1223,11 +1222,11 @@ discard block |
||
| 1223 | 1222 | * @return string |
| 1224 | 1223 | */ |
| 1225 | 1224 | function quote_amp($u) { |
| 1226 | - return preg_replace( |
|
| 1227 | - '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1228 | - '&', |
|
| 1229 | - $u |
|
| 1230 | - ); |
|
| 1225 | + return preg_replace( |
|
| 1226 | + '/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i', |
|
| 1227 | + '&', |
|
| 1228 | + $u |
|
| 1229 | + ); |
|
| 1231 | 1230 | } |
| 1232 | 1231 | |
| 1233 | 1232 | |
@@ -1250,27 +1249,27 @@ discard block |
||
| 1250 | 1249 | * Balise HTML `<script>` et son contenu |
| 1251 | 1250 | **/ |
| 1252 | 1251 | function http_script($script, $src = '', $noscript = '') { |
| 1253 | - static $done = []; |
|
| 1252 | + static $done = []; |
|
| 1254 | 1253 | |
| 1255 | - if ($src && !isset($done[$src])) { |
|
| 1256 | - $done[$src] = true; |
|
| 1257 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1258 | - $src = " src='$src'"; |
|
| 1259 | - } else { |
|
| 1260 | - $src = ''; |
|
| 1261 | - } |
|
| 1262 | - if ($script) { |
|
| 1263 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1264 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1265 | - '/*]]>*/'); |
|
| 1266 | - } |
|
| 1267 | - if ($noscript) { |
|
| 1268 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1269 | - } |
|
| 1254 | + if ($src && !isset($done[$src])) { |
|
| 1255 | + $done[$src] = true; |
|
| 1256 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1257 | + $src = " src='$src'"; |
|
| 1258 | + } else { |
|
| 1259 | + $src = ''; |
|
| 1260 | + } |
|
| 1261 | + if ($script) { |
|
| 1262 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1263 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1264 | + '/*]]>*/'); |
|
| 1265 | + } |
|
| 1266 | + if ($noscript) { |
|
| 1267 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1268 | + } |
|
| 1270 | 1269 | |
| 1271 | - return ($src or $script or $noscript) |
|
| 1272 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1273 | - : ''; |
|
| 1270 | + return ($src or $script or $noscript) |
|
| 1271 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1272 | + : ''; |
|
| 1274 | 1273 | } |
| 1275 | 1274 | |
| 1276 | 1275 | |
@@ -1305,7 +1304,7 @@ discard block |
||
| 1305 | 1304 | * Texte échappé |
| 1306 | 1305 | **/ |
| 1307 | 1306 | function texte_script(string $texte): string { |
| 1308 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1307 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1309 | 1308 | } |
| 1310 | 1309 | |
| 1311 | 1310 | |
@@ -1342,68 +1341,68 @@ discard block |
||
| 1342 | 1341 | * Liste des chemins, par ordre de priorité. |
| 1343 | 1342 | **/ |
| 1344 | 1343 | function _chemin($dir_path = null) { |
| 1345 | - static $path_base = null; |
|
| 1346 | - static $path_full = null; |
|
| 1347 | - if ($path_base == null) { |
|
| 1348 | - // Chemin standard depuis l'espace public |
|
| 1349 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1350 | - _DIR_RACINE . ':' . |
|
| 1351 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1352 | - _DIR_RACINE . 'prive/:' . |
|
| 1353 | - _DIR_RESTREINT; |
|
| 1354 | - // Ajouter squelettes/ |
|
| 1355 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1356 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1357 | - } |
|
| 1358 | - foreach (explode(':', $path) as $dir) { |
|
| 1359 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1360 | - $dir .= '/'; |
|
| 1361 | - } |
|
| 1362 | - $path_base[] = $dir; |
|
| 1363 | - } |
|
| 1364 | - $path_full = $path_base; |
|
| 1365 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1366 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1367 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1368 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1369 | - } |
|
| 1370 | - } |
|
| 1371 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1372 | - } |
|
| 1373 | - if ($dir_path === null) { |
|
| 1374 | - return $path_full; |
|
| 1375 | - } |
|
| 1376 | - |
|
| 1377 | - if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1378 | - $tete = ''; |
|
| 1379 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1380 | - $tete = array_shift($path_base); |
|
| 1381 | - } |
|
| 1382 | - $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1383 | - $dirs = array_reverse($dirs); |
|
| 1384 | - foreach ($dirs as $dir_path) { |
|
| 1385 | - if (substr($dir_path, -1) != '/') { |
|
| 1386 | - $dir_path .= '/'; |
|
| 1387 | - } |
|
| 1388 | - if (!in_array($dir_path, $path_base)) { |
|
| 1389 | - array_unshift($path_base, $dir_path); |
|
| 1390 | - } |
|
| 1391 | - } |
|
| 1392 | - if (strlen($tete)) { |
|
| 1393 | - array_unshift($path_base, $tete); |
|
| 1394 | - } |
|
| 1395 | - } |
|
| 1396 | - $path_full = $path_base; |
|
| 1397 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1398 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1399 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1400 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1401 | - } |
|
| 1402 | - } |
|
| 1403 | - |
|
| 1404 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1405 | - |
|
| 1406 | - return $path_full; |
|
| 1344 | + static $path_base = null; |
|
| 1345 | + static $path_full = null; |
|
| 1346 | + if ($path_base == null) { |
|
| 1347 | + // Chemin standard depuis l'espace public |
|
| 1348 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1349 | + _DIR_RACINE . ':' . |
|
| 1350 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1351 | + _DIR_RACINE . 'prive/:' . |
|
| 1352 | + _DIR_RESTREINT; |
|
| 1353 | + // Ajouter squelettes/ |
|
| 1354 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1355 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1356 | + } |
|
| 1357 | + foreach (explode(':', $path) as $dir) { |
|
| 1358 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1359 | + $dir .= '/'; |
|
| 1360 | + } |
|
| 1361 | + $path_base[] = $dir; |
|
| 1362 | + } |
|
| 1363 | + $path_full = $path_base; |
|
| 1364 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1365 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1366 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1367 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1368 | + } |
|
| 1369 | + } |
|
| 1370 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1371 | + } |
|
| 1372 | + if ($dir_path === null) { |
|
| 1373 | + return $path_full; |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1377 | + $tete = ''; |
|
| 1378 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1379 | + $tete = array_shift($path_base); |
|
| 1380 | + } |
|
| 1381 | + $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1382 | + $dirs = array_reverse($dirs); |
|
| 1383 | + foreach ($dirs as $dir_path) { |
|
| 1384 | + if (substr($dir_path, -1) != '/') { |
|
| 1385 | + $dir_path .= '/'; |
|
| 1386 | + } |
|
| 1387 | + if (!in_array($dir_path, $path_base)) { |
|
| 1388 | + array_unshift($path_base, $dir_path); |
|
| 1389 | + } |
|
| 1390 | + } |
|
| 1391 | + if (strlen($tete)) { |
|
| 1392 | + array_unshift($path_base, $tete); |
|
| 1393 | + } |
|
| 1394 | + } |
|
| 1395 | + $path_full = $path_base; |
|
| 1396 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1397 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1398 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1399 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1400 | + } |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1404 | + |
|
| 1405 | + return $path_full; |
|
| 1407 | 1406 | } |
| 1408 | 1407 | |
| 1409 | 1408 | /** |
@@ -1416,78 +1415,78 @@ discard block |
||
| 1416 | 1415 | * @return array Liste de chemins |
| 1417 | 1416 | **/ |
| 1418 | 1417 | function creer_chemin() { |
| 1419 | - $path_a = _chemin(); |
|
| 1420 | - static $c = ''; |
|
| 1418 | + $path_a = _chemin(); |
|
| 1419 | + static $c = ''; |
|
| 1421 | 1420 | |
| 1422 | - // on calcule le chemin si le dossier skel a change |
|
| 1423 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1424 | - // assurer le non plantage lors de la montee de version : |
|
| 1425 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1426 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1427 | - } |
|
| 1421 | + // on calcule le chemin si le dossier skel a change |
|
| 1422 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1423 | + // assurer le non plantage lors de la montee de version : |
|
| 1424 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1425 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1426 | + } |
|
| 1428 | 1427 | |
| 1429 | - return $path_a; |
|
| 1428 | + return $path_a; |
|
| 1430 | 1429 | } |
| 1431 | 1430 | |
| 1432 | 1431 | |
| 1433 | 1432 | function lister_themes_prives() { |
| 1434 | - static $themes = null; |
|
| 1435 | - if (is_null($themes)) { |
|
| 1436 | - // si pas encore definie |
|
| 1437 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1438 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1439 | - } |
|
| 1440 | - $themes = [_SPIP_THEME_PRIVE]; |
|
| 1441 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1442 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1443 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1444 | - } else { |
|
| 1445 | - $prefs = []; |
|
| 1446 | - } |
|
| 1447 | - if (is_string($prefs)) { |
|
| 1448 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1449 | - } |
|
| 1450 | - if ( |
|
| 1451 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1452 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1453 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1454 | - ) { |
|
| 1455 | - array_unshift($themes, $theme); |
|
| 1456 | - } // placer le theme choisi en tete |
|
| 1457 | - } |
|
| 1458 | - |
|
| 1459 | - return $themes; |
|
| 1433 | + static $themes = null; |
|
| 1434 | + if (is_null($themes)) { |
|
| 1435 | + // si pas encore definie |
|
| 1436 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1437 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1438 | + } |
|
| 1439 | + $themes = [_SPIP_THEME_PRIVE]; |
|
| 1440 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1441 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1442 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1443 | + } else { |
|
| 1444 | + $prefs = []; |
|
| 1445 | + } |
|
| 1446 | + if (is_string($prefs)) { |
|
| 1447 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1448 | + } |
|
| 1449 | + if ( |
|
| 1450 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1451 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1452 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1453 | + ) { |
|
| 1454 | + array_unshift($themes, $theme); |
|
| 1455 | + } // placer le theme choisi en tete |
|
| 1456 | + } |
|
| 1457 | + |
|
| 1458 | + return $themes; |
|
| 1460 | 1459 | } |
| 1461 | 1460 | |
| 1462 | 1461 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1463 | - static $themefiles = []; |
|
| 1464 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1465 | - return $themefiles["$subdir$file"]; |
|
| 1466 | - } |
|
| 1467 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1468 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1469 | - if ( |
|
| 1470 | - preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1471 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1472 | - and $f = find_in_theme("$file_svg_generique") |
|
| 1473 | - ) { |
|
| 1474 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1475 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1476 | - } |
|
| 1477 | - else { |
|
| 1478 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1479 | - } |
|
| 1480 | - } |
|
| 1481 | - |
|
| 1482 | - $themes = lister_themes_prives(); |
|
| 1483 | - foreach ($themes as $theme) { |
|
| 1484 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1485 | - return $themefiles["$subdir$file"] = $f; |
|
| 1486 | - } |
|
| 1487 | - } |
|
| 1488 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1489 | - |
|
| 1490 | - return $themefiles["$subdir$file"] = ''; |
|
| 1462 | + static $themefiles = []; |
|
| 1463 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1464 | + return $themefiles["$subdir$file"]; |
|
| 1465 | + } |
|
| 1466 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1467 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1468 | + if ( |
|
| 1469 | + preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1470 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1471 | + and $f = find_in_theme("$file_svg_generique") |
|
| 1472 | + ) { |
|
| 1473 | + if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1474 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1475 | + } |
|
| 1476 | + else { |
|
| 1477 | + return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1478 | + } |
|
| 1479 | + } |
|
| 1480 | + |
|
| 1481 | + $themes = lister_themes_prives(); |
|
| 1482 | + foreach ($themes as $theme) { |
|
| 1483 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1484 | + return $themefiles["$subdir$file"] = $f; |
|
| 1485 | + } |
|
| 1486 | + } |
|
| 1487 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1488 | + |
|
| 1489 | + return $themefiles["$subdir$file"] = ''; |
|
| 1491 | 1490 | } |
| 1492 | 1491 | |
| 1493 | 1492 | |
@@ -1511,31 +1510,31 @@ discard block |
||
| 1511 | 1510 | * sinon chaîne vide. |
| 1512 | 1511 | **/ |
| 1513 | 1512 | function chemin_image($icone) { |
| 1514 | - static $icone_renommer; |
|
| 1515 | - if ($p = strpos($icone, '?')) { |
|
| 1516 | - $icone = substr($icone, 0, $p); |
|
| 1517 | - } |
|
| 1518 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1519 | - if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1520 | - return $icone; |
|
| 1521 | - } |
|
| 1522 | - |
|
| 1523 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1524 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1525 | - return $f; |
|
| 1526 | - } |
|
| 1527 | - // sinon passer par le module de renommage |
|
| 1528 | - if (is_null($icone_renommer)) { |
|
| 1529 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1530 | - } |
|
| 1531 | - if ($icone_renommer) { |
|
| 1532 | - [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1533 | - if (file_exists($icone)) { |
|
| 1534 | - return $icone; |
|
| 1535 | - } |
|
| 1536 | - } |
|
| 1537 | - |
|
| 1538 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1513 | + static $icone_renommer; |
|
| 1514 | + if ($p = strpos($icone, '?')) { |
|
| 1515 | + $icone = substr($icone, 0, $p); |
|
| 1516 | + } |
|
| 1517 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1518 | + if (strpos($icone, '/') !== false and file_exists($icone)) { |
|
| 1519 | + return $icone; |
|
| 1520 | + } |
|
| 1521 | + |
|
| 1522 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1523 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1524 | + return $f; |
|
| 1525 | + } |
|
| 1526 | + // sinon passer par le module de renommage |
|
| 1527 | + if (is_null($icone_renommer)) { |
|
| 1528 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1529 | + } |
|
| 1530 | + if ($icone_renommer) { |
|
| 1531 | + [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 1532 | + if (file_exists($icone)) { |
|
| 1533 | + return $icone; |
|
| 1534 | + } |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1539 | 1538 | } |
| 1540 | 1539 | |
| 1541 | 1540 | // |
@@ -1573,128 +1572,128 @@ discard block |
||
| 1573 | 1572 | * - false : fichier introuvable |
| 1574 | 1573 | **/ |
| 1575 | 1574 | function find_in_path($file, $dirname = '', $include = false) { |
| 1576 | - static $dirs = []; |
|
| 1577 | - static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1578 | - static $c = ''; |
|
| 1579 | - |
|
| 1580 | - if (!$file and !strlen($file)) { |
|
| 1581 | - return false; |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - // on calcule le chemin si le dossier skel a change |
|
| 1585 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1586 | - // assurer le non plantage lors de la montee de version : |
|
| 1587 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1588 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1589 | - } |
|
| 1590 | - |
|
| 1591 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1592 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1593 | - return false; |
|
| 1594 | - } |
|
| 1595 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1596 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1598 | - } |
|
| 1599 | - |
|
| 1600 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1601 | - } |
|
| 1602 | - |
|
| 1603 | - $a = strrpos($file, '/'); |
|
| 1604 | - if ($a !== false) { |
|
| 1605 | - $dirname .= substr($file, 0, ++$a); |
|
| 1606 | - $file = substr($file, $a); |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - foreach (creer_chemin() as $dir) { |
|
| 1610 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1611 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1612 | - } |
|
| 1613 | - if ($dirs[$a]) { |
|
| 1614 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1615 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1616 | - include_once _ROOT_CWD . $a; |
|
| 1617 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1618 | - } |
|
| 1619 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1620 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1621 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1622 | - return $a; |
|
| 1623 | - } |
|
| 1624 | - define('_SAUVER_CHEMIN', true); |
|
| 1625 | - } |
|
| 1626 | - |
|
| 1627 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1628 | - } |
|
| 1629 | - } |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - if ($include) { |
|
| 1633 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1634 | - if ($include === 'required') { |
|
| 1635 | - echo '<pre>', |
|
| 1636 | - '<strong>Erreur Fatale</strong><br />'; |
|
| 1637 | - if (function_exists('debug_print_backtrace')) { |
|
| 1638 | - echo debug_print_backtrace(); |
|
| 1639 | - } |
|
| 1640 | - echo '</pre>'; |
|
| 1641 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1642 | - } |
|
| 1643 | - } |
|
| 1644 | - |
|
| 1645 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1646 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1647 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1648 | - return false; |
|
| 1649 | - } |
|
| 1650 | - define('_SAUVER_CHEMIN', true); |
|
| 1651 | - } |
|
| 1652 | - |
|
| 1653 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1575 | + static $dirs = []; |
|
| 1576 | + static $inc = []; # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1577 | + static $c = ''; |
|
| 1578 | + |
|
| 1579 | + if (!$file and !strlen($file)) { |
|
| 1580 | + return false; |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + // on calcule le chemin si le dossier skel a change |
|
| 1584 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1585 | + // assurer le non plantage lors de la montee de version : |
|
| 1586 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1587 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1588 | + } |
|
| 1589 | + |
|
| 1590 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1591 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1592 | + return false; |
|
| 1593 | + } |
|
| 1594 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1595 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1596 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1597 | + } |
|
| 1598 | + |
|
| 1599 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1600 | + } |
|
| 1601 | + |
|
| 1602 | + $a = strrpos($file, '/'); |
|
| 1603 | + if ($a !== false) { |
|
| 1604 | + $dirname .= substr($file, 0, ++$a); |
|
| 1605 | + $file = substr($file, $a); |
|
| 1606 | + } |
|
| 1607 | + |
|
| 1608 | + foreach (creer_chemin() as $dir) { |
|
| 1609 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1610 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1611 | + } |
|
| 1612 | + if ($dirs[$a]) { |
|
| 1613 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1614 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1615 | + include_once _ROOT_CWD . $a; |
|
| 1616 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1617 | + } |
|
| 1618 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1619 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1620 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1621 | + return $a; |
|
| 1622 | + } |
|
| 1623 | + define('_SAUVER_CHEMIN', true); |
|
| 1624 | + } |
|
| 1625 | + |
|
| 1626 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1627 | + } |
|
| 1628 | + } |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + if ($include) { |
|
| 1632 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1633 | + if ($include === 'required') { |
|
| 1634 | + echo '<pre>', |
|
| 1635 | + '<strong>Erreur Fatale</strong><br />'; |
|
| 1636 | + if (function_exists('debug_print_backtrace')) { |
|
| 1637 | + echo debug_print_backtrace(); |
|
| 1638 | + } |
|
| 1639 | + echo '</pre>'; |
|
| 1640 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1641 | + } |
|
| 1642 | + } |
|
| 1643 | + |
|
| 1644 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1645 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1646 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1647 | + return false; |
|
| 1648 | + } |
|
| 1649 | + define('_SAUVER_CHEMIN', true); |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1654 | 1653 | } |
| 1655 | 1654 | |
| 1656 | 1655 | function clear_path_cache() { |
| 1657 | - $GLOBALS['path_files'] = []; |
|
| 1658 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1656 | + $GLOBALS['path_files'] = []; |
|
| 1657 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1659 | 1658 | } |
| 1660 | 1659 | |
| 1661 | 1660 | function load_path_cache() { |
| 1662 | - // charger le path des plugins |
|
| 1663 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1664 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1665 | - } |
|
| 1666 | - $GLOBALS['path_files'] = []; |
|
| 1667 | - // si le visiteur est admin, |
|
| 1668 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1669 | - if ( |
|
| 1670 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1671 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1672 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1673 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1674 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1675 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1676 | - !_request('var_mode') |
|
| 1677 | - ) { |
|
| 1678 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1679 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1680 | - // mais si semble corrompu on relit avec un verrou |
|
| 1681 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1682 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1683 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1684 | - $GLOBALS['path_files'] = []; |
|
| 1685 | - } |
|
| 1686 | - } |
|
| 1687 | - } |
|
| 1688 | - } |
|
| 1661 | + // charger le path des plugins |
|
| 1662 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1663 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1664 | + } |
|
| 1665 | + $GLOBALS['path_files'] = []; |
|
| 1666 | + // si le visiteur est admin, |
|
| 1667 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1668 | + if ( |
|
| 1669 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1670 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1671 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1672 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1673 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1674 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1675 | + !_request('var_mode') |
|
| 1676 | + ) { |
|
| 1677 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1678 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1679 | + // mais si semble corrompu on relit avec un verrou |
|
| 1680 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1681 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1682 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1683 | + $GLOBALS['path_files'] = []; |
|
| 1684 | + } |
|
| 1685 | + } |
|
| 1686 | + } |
|
| 1687 | + } |
|
| 1689 | 1688 | } |
| 1690 | 1689 | |
| 1691 | 1690 | function save_path_cache() { |
| 1692 | - if ( |
|
| 1693 | - defined('_SAUVER_CHEMIN') |
|
| 1694 | - and _SAUVER_CHEMIN |
|
| 1695 | - ) { |
|
| 1696 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1697 | - } |
|
| 1691 | + if ( |
|
| 1692 | + defined('_SAUVER_CHEMIN') |
|
| 1693 | + and _SAUVER_CHEMIN |
|
| 1694 | + ) { |
|
| 1695 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1696 | + } |
|
| 1698 | 1697 | } |
| 1699 | 1698 | |
| 1700 | 1699 | |
@@ -1714,33 +1713,33 @@ discard block |
||
| 1714 | 1713 | * @return array |
| 1715 | 1714 | */ |
| 1716 | 1715 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1717 | - $liste_fichiers = []; |
|
| 1718 | - $maxfiles = 10000; |
|
| 1719 | - |
|
| 1720 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1721 | - // on a pas encore inclus flock.php |
|
| 1722 | - if (!function_exists('preg_files')) { |
|
| 1723 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1724 | - } |
|
| 1725 | - |
|
| 1726 | - // Parcourir le chemin |
|
| 1727 | - foreach (creer_chemin() as $d) { |
|
| 1728 | - $f = $d . $dir; |
|
| 1729 | - if (@is_dir($f)) { |
|
| 1730 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1731 | - foreach ($liste as $chemin) { |
|
| 1732 | - $nom = basename($chemin); |
|
| 1733 | - // ne prendre que les fichiers pas deja trouves |
|
| 1734 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1735 | - // les autres sont donc masques |
|
| 1736 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1737 | - $liste_fichiers[$nom] = $chemin; |
|
| 1738 | - } |
|
| 1739 | - } |
|
| 1740 | - } |
|
| 1741 | - } |
|
| 1742 | - |
|
| 1743 | - return $liste_fichiers; |
|
| 1716 | + $liste_fichiers = []; |
|
| 1717 | + $maxfiles = 10000; |
|
| 1718 | + |
|
| 1719 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1720 | + // on a pas encore inclus flock.php |
|
| 1721 | + if (!function_exists('preg_files')) { |
|
| 1722 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1723 | + } |
|
| 1724 | + |
|
| 1725 | + // Parcourir le chemin |
|
| 1726 | + foreach (creer_chemin() as $d) { |
|
| 1727 | + $f = $d . $dir; |
|
| 1728 | + if (@is_dir($f)) { |
|
| 1729 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 1730 | + foreach ($liste as $chemin) { |
|
| 1731 | + $nom = basename($chemin); |
|
| 1732 | + // ne prendre que les fichiers pas deja trouves |
|
| 1733 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1734 | + // les autres sont donc masques |
|
| 1735 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1736 | + $liste_fichiers[$nom] = $chemin; |
|
| 1737 | + } |
|
| 1738 | + } |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1741 | + |
|
| 1742 | + return $liste_fichiers; |
|
| 1744 | 1743 | } |
| 1745 | 1744 | |
| 1746 | 1745 | /** |
@@ -1752,17 +1751,17 @@ discard block |
||
| 1752 | 1751 | * @return bool |
| 1753 | 1752 | */ |
| 1754 | 1753 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1755 | - static $autsanscookie = ['install', 'base_repair']; |
|
| 1754 | + static $autsanscookie = ['install', 'base_repair']; |
|
| 1756 | 1755 | |
| 1757 | - if (in_array($nom, $autsanscookie)) { |
|
| 1758 | - if (test_espace_prive()) { |
|
| 1759 | - include_spip('base/connect_sql'); |
|
| 1760 | - if (!$strict or !spip_connect()) { |
|
| 1761 | - return true; |
|
| 1762 | - } |
|
| 1763 | - } |
|
| 1764 | - } |
|
| 1765 | - return false; |
|
| 1756 | + if (in_array($nom, $autsanscookie)) { |
|
| 1757 | + if (test_espace_prive()) { |
|
| 1758 | + include_spip('base/connect_sql'); |
|
| 1759 | + if (!$strict or !spip_connect()) { |
|
| 1760 | + return true; |
|
| 1761 | + } |
|
| 1762 | + } |
|
| 1763 | + } |
|
| 1764 | + return false; |
|
| 1766 | 1765 | } |
| 1767 | 1766 | |
| 1768 | 1767 | /** |
@@ -1772,56 +1771,56 @@ discard block |
||
| 1772 | 1771 | * @return string |
| 1773 | 1772 | */ |
| 1774 | 1773 | function charger_fonction_url(string $quoi, string $type = '') { |
| 1775 | - if ($type === 'defaut') { |
|
| 1776 | - $objet = objet_type($quoi); |
|
| 1777 | - if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1778 | - // deprecated |
|
| 1779 | - or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1780 | - ) { |
|
| 1781 | - return $f; |
|
| 1782 | - } |
|
| 1783 | - return ''; |
|
| 1784 | - } |
|
| 1785 | - |
|
| 1786 | - if (!$type) { |
|
| 1787 | - $type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1788 | - } |
|
| 1789 | - |
|
| 1790 | - // inclure le module d'url |
|
| 1791 | - include_spip('urls/'.$type); |
|
| 1792 | - |
|
| 1793 | - switch ($quoi) { |
|
| 1794 | - case 'page': |
|
| 1795 | - if ( |
|
| 1796 | - function_exists($f = "urls_{$type}_generer_url_page") |
|
| 1797 | - or function_exists($f .= "_dist") |
|
| 1798 | - // ou une fonction custom utilisateur independante du type d'url |
|
| 1799 | - or function_exists($f = "generer_url_page") |
|
| 1800 | - or function_exists($f .= "_dist") |
|
| 1801 | - ) { |
|
| 1802 | - return $f; |
|
| 1803 | - } |
|
| 1804 | - // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 1805 | - return ''; |
|
| 1806 | - case 'objet': |
|
| 1807 | - case 'decoder': |
|
| 1808 | - default: |
|
| 1809 | - $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 1810 | - if (function_exists($f = "urls_{$type}_{$fquoi}") |
|
| 1811 | - or function_exists($f .= "_dist")) { |
|
| 1812 | - return $f; |
|
| 1813 | - } |
|
| 1814 | - // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 1815 | - // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 1816 | - if ($f = charger_fonction($type, 'urls', true)) { |
|
| 1817 | - return $f; |
|
| 1818 | - } |
|
| 1819 | - // sinon on se rabat sur les urls page |
|
| 1820 | - if ($type !== 'page') { |
|
| 1821 | - return charger_fonction_url($quoi, 'page'); |
|
| 1822 | - } |
|
| 1823 | - return ''; |
|
| 1824 | - } |
|
| 1774 | + if ($type === 'defaut') { |
|
| 1775 | + $objet = objet_type($quoi); |
|
| 1776 | + if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1777 | + // deprecated |
|
| 1778 | + or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1779 | + ) { |
|
| 1780 | + return $f; |
|
| 1781 | + } |
|
| 1782 | + return ''; |
|
| 1783 | + } |
|
| 1784 | + |
|
| 1785 | + if (!$type) { |
|
| 1786 | + $type = $GLOBALS['type_urls'] ?? $GLOBALS['meta']['type_urls'] ?? 'page'; // sinon type "page" par défaut |
|
| 1787 | + } |
|
| 1788 | + |
|
| 1789 | + // inclure le module d'url |
|
| 1790 | + include_spip('urls/'.$type); |
|
| 1791 | + |
|
| 1792 | + switch ($quoi) { |
|
| 1793 | + case 'page': |
|
| 1794 | + if ( |
|
| 1795 | + function_exists($f = "urls_{$type}_generer_url_page") |
|
| 1796 | + or function_exists($f .= "_dist") |
|
| 1797 | + // ou une fonction custom utilisateur independante du type d'url |
|
| 1798 | + or function_exists($f = "generer_url_page") |
|
| 1799 | + or function_exists($f .= "_dist") |
|
| 1800 | + ) { |
|
| 1801 | + return $f; |
|
| 1802 | + } |
|
| 1803 | + // pas de compat ancienne version ici, c'est une nouvelle feature |
|
| 1804 | + return ''; |
|
| 1805 | + case 'objet': |
|
| 1806 | + case 'decoder': |
|
| 1807 | + default: |
|
| 1808 | + $fquoi = ($quoi === 'objet' ? 'generer_url_objet' : 'decoder_url'); |
|
| 1809 | + if (function_exists($f = "urls_{$type}_{$fquoi}") |
|
| 1810 | + or function_exists($f .= "_dist")) { |
|
| 1811 | + return $f; |
|
| 1812 | + } |
|
| 1813 | + // est-ce qu'on a une ancienne fonction urls_xxx_dist() ? |
|
| 1814 | + // c'est un ancien module d'url, on appelle l'ancienne fonction qui fait tout |
|
| 1815 | + if ($f = charger_fonction($type, 'urls', true)) { |
|
| 1816 | + return $f; |
|
| 1817 | + } |
|
| 1818 | + // sinon on se rabat sur les urls page |
|
| 1819 | + if ($type !== 'page') { |
|
| 1820 | + return charger_fonction_url($quoi, 'page'); |
|
| 1821 | + } |
|
| 1822 | + return ''; |
|
| 1823 | + } |
|
| 1825 | 1824 | } |
| 1826 | 1825 | |
| 1827 | 1826 | |
@@ -1848,47 +1847,47 @@ discard block |
||
| 1848 | 1847 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_spip_url et une fonction generer_spip_url_ecrire) |
| 1849 | 1848 | */ |
| 1850 | 1849 | function generer_objet_url($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1851 | - if ($public === null) { |
|
| 1852 | - $public = !test_espace_prive(); |
|
| 1853 | - } |
|
| 1854 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1855 | - |
|
| 1856 | - if (!$public) { |
|
| 1857 | - if (!$entite) { |
|
| 1858 | - return ''; |
|
| 1859 | - } |
|
| 1860 | - if (!function_exists('generer_objet_url_ecrire')) { |
|
| 1861 | - include_spip('inc/urls'); |
|
| 1862 | - } |
|
| 1863 | - $res = generer_objet_url_ecrire($entite, $id, $args, $ancre, false); |
|
| 1864 | - } else { |
|
| 1865 | - $f = charger_fonction_url('objet', $type ?? ''); |
|
| 1866 | - |
|
| 1867 | - // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 1868 | - // @see charger_fonction_url |
|
| 1869 | - if (!$entite) { |
|
| 1870 | - return $f; |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1874 | - // base distante |
|
| 1875 | - if ( |
|
| 1876 | - is_string($public) |
|
| 1877 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1878 | - ) { |
|
| 1879 | - $f = $g; |
|
| 1880 | - } |
|
| 1881 | - |
|
| 1882 | - $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $public); |
|
| 1883 | - } |
|
| 1884 | - if ($res) { |
|
| 1885 | - return $res; |
|
| 1886 | - } |
|
| 1887 | - |
|
| 1888 | - // On a ete gentil mais la .... |
|
| 1889 | - spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public"); |
|
| 1890 | - |
|
| 1891 | - return ''; |
|
| 1850 | + if ($public === null) { |
|
| 1851 | + $public = !test_espace_prive(); |
|
| 1852 | + } |
|
| 1853 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1854 | + |
|
| 1855 | + if (!$public) { |
|
| 1856 | + if (!$entite) { |
|
| 1857 | + return ''; |
|
| 1858 | + } |
|
| 1859 | + if (!function_exists('generer_objet_url_ecrire')) { |
|
| 1860 | + include_spip('inc/urls'); |
|
| 1861 | + } |
|
| 1862 | + $res = generer_objet_url_ecrire($entite, $id, $args, $ancre, false); |
|
| 1863 | + } else { |
|
| 1864 | + $f = charger_fonction_url('objet', $type ?? ''); |
|
| 1865 | + |
|
| 1866 | + // @deprecated si $entite='', on veut la fonction de passage URL ==> id |
|
| 1867 | + // @see charger_fonction_url |
|
| 1868 | + if (!$entite) { |
|
| 1869 | + return $f; |
|
| 1870 | + } |
|
| 1871 | + |
|
| 1872 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1873 | + // base distante |
|
| 1874 | + if ( |
|
| 1875 | + is_string($public) |
|
| 1876 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1877 | + ) { |
|
| 1878 | + $f = $g; |
|
| 1879 | + } |
|
| 1880 | + |
|
| 1881 | + $res = $f(intval($id), $entite, $args ?: '', $ancre ?: '', $public); |
|
| 1882 | + } |
|
| 1883 | + if ($res) { |
|
| 1884 | + return $res; |
|
| 1885 | + } |
|
| 1886 | + |
|
| 1887 | + // On a ete gentil mais la .... |
|
| 1888 | + spip_log("generer_objet_url: entite $entite ($f) inconnue $type $public"); |
|
| 1889 | + |
|
| 1890 | + return ''; |
|
| 1892 | 1891 | } |
| 1893 | 1892 | |
| 1894 | 1893 | /** |
@@ -1896,7 +1895,7 @@ discard block |
||
| 1896 | 1895 | * @see generer_objet_url |
| 1897 | 1896 | */ |
| 1898 | 1897 | function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null){ |
| 1899 | - return generer_objet_url($id, $entite, $args, $ancre, $public, $type); |
|
| 1898 | + return generer_objet_url($id, $entite, $args, $ancre, $public, $type); |
|
| 1900 | 1899 | } |
| 1901 | 1900 | |
| 1902 | 1901 | /** |
@@ -1908,18 +1907,18 @@ discard block |
||
| 1908 | 1907 | * @return string |
| 1909 | 1908 | */ |
| 1910 | 1909 | function generer_objet_url_ecrire_edit($id, $entite, $args = '', $ancre = '') { |
| 1911 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1912 | - $url = generer_url_ecrire($exec, $args); |
|
| 1913 | - if (intval($id)) { |
|
| 1914 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1915 | - } else { |
|
| 1916 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1917 | - } |
|
| 1918 | - if ($ancre) { |
|
| 1919 | - $url = ancre_url($url, $ancre); |
|
| 1920 | - } |
|
| 1910 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1911 | + $url = generer_url_ecrire($exec, $args); |
|
| 1912 | + if (intval($id)) { |
|
| 1913 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1914 | + } else { |
|
| 1915 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1916 | + } |
|
| 1917 | + if ($ancre) { |
|
| 1918 | + $url = ancre_url($url, $ancre); |
|
| 1919 | + } |
|
| 1921 | 1920 | |
| 1922 | - return $url; |
|
| 1921 | + return $url; |
|
| 1923 | 1922 | } |
| 1924 | 1923 | |
| 1925 | 1924 | /** |
@@ -1927,18 +1926,18 @@ discard block |
||
| 1927 | 1926 | * @see generer_objet_url_ecrire_edit |
| 1928 | 1927 | */ |
| 1929 | 1928 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = ''){ |
| 1930 | - return generer_objet_url_ecrire_edit($id, $entite, $args, $ancre); |
|
| 1929 | + return generer_objet_url_ecrire_edit($id, $entite, $args, $ancre); |
|
| 1931 | 1930 | } |
| 1932 | 1931 | |
| 1933 | 1932 | |
| 1934 | 1933 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1935 | - include_spip('base/connect_sql'); |
|
| 1936 | - $id_type = id_table_objet($entite, $public); |
|
| 1934 | + include_spip('base/connect_sql'); |
|
| 1935 | + $id_type = id_table_objet($entite, $public); |
|
| 1937 | 1936 | |
| 1938 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1939 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1940 | - . (!$args ? '' : "&$args") |
|
| 1941 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1937 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1938 | + . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1939 | + . (!$args ? '' : "&$args") |
|
| 1940 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1942 | 1941 | } |
| 1943 | 1942 | |
| 1944 | 1943 | |
@@ -1949,18 +1948,18 @@ discard block |
||
| 1949 | 1948 | * @return string |
| 1950 | 1949 | */ |
| 1951 | 1950 | function urlencode_1738($url) { |
| 1952 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1953 | - $uri = ''; |
|
| 1954 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1955 | - if (ord($a = $url[$i]) > 127) { |
|
| 1956 | - $a = rawurlencode($a); |
|
| 1957 | - } |
|
| 1958 | - $uri .= $a; |
|
| 1959 | - } |
|
| 1960 | - $url = $uri; |
|
| 1961 | - } |
|
| 1951 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1952 | + $uri = ''; |
|
| 1953 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1954 | + if (ord($a = $url[$i]) > 127) { |
|
| 1955 | + $a = rawurlencode($a); |
|
| 1956 | + } |
|
| 1957 | + $uri .= $a; |
|
| 1958 | + } |
|
| 1959 | + $url = $uri; |
|
| 1960 | + } |
|
| 1962 | 1961 | |
| 1963 | - return quote_amp($url); |
|
| 1962 | + return quote_amp($url); |
|
| 1964 | 1963 | } |
| 1965 | 1964 | |
| 1966 | 1965 | /** |
@@ -1974,16 +1973,16 @@ discard block |
||
| 1974 | 1973 | * @return string |
| 1975 | 1974 | */ |
| 1976 | 1975 | function generer_objet_url_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { |
| 1977 | - if (!$connect) { |
|
| 1978 | - $connect = true; |
|
| 1979 | - } |
|
| 1980 | - $h = generer_objet_url($id, $entite, $args, $ancre, $connect); |
|
| 1981 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1982 | - include_spip('inc/filtres_mini'); |
|
| 1983 | - $h = url_absolue($h); |
|
| 1984 | - } |
|
| 1976 | + if (!$connect) { |
|
| 1977 | + $connect = true; |
|
| 1978 | + } |
|
| 1979 | + $h = generer_objet_url($id, $entite, $args, $ancre, $connect); |
|
| 1980 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1981 | + include_spip('inc/filtres_mini'); |
|
| 1982 | + $h = url_absolue($h); |
|
| 1983 | + } |
|
| 1985 | 1984 | |
| 1986 | - return $h; |
|
| 1985 | + return $h; |
|
| 1987 | 1986 | } |
| 1988 | 1987 | |
| 1989 | 1988 | /** |
@@ -1991,7 +1990,7 @@ discard block |
||
| 1991 | 1990 | * @see generer_objet_url_absolue |
| 1992 | 1991 | */ |
| 1993 | 1992 | function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null){ |
| 1994 | - return generer_objet_url_absolue($id, $entite, $args, $args, $ancre, $connect); |
|
| 1993 | + return generer_objet_url_absolue($id, $entite, $args, $args, $ancre, $connect); |
|
| 1995 | 1994 | } |
| 1996 | 1995 | |
| 1997 | 1996 | |
@@ -2007,11 +2006,11 @@ discard block |
||
| 2007 | 2006 | * true si la valeur est considérée active ; false sinon. |
| 2008 | 2007 | **/ |
| 2009 | 2008 | function test_valeur_serveur($truc) { |
| 2010 | - if (!$truc) { |
|
| 2011 | - return false; |
|
| 2012 | - } |
|
| 2009 | + if (!$truc) { |
|
| 2010 | + return false; |
|
| 2011 | + } |
|
| 2013 | 2012 | |
| 2014 | - return (strtolower($truc) !== 'off'); |
|
| 2013 | + return (strtolower($truc) !== 'off'); |
|
| 2015 | 2014 | } |
| 2016 | 2015 | |
| 2017 | 2016 | // |
@@ -2039,82 +2038,82 @@ discard block |
||
| 2039 | 2038 | */ |
| 2040 | 2039 | function url_de_base($profondeur = null) { |
| 2041 | 2040 | |
| 2042 | - static $url = []; |
|
| 2043 | - if (is_array($profondeur)) { |
|
| 2044 | - return $url = $profondeur; |
|
| 2045 | - } |
|
| 2046 | - if ($profondeur === false) { |
|
| 2047 | - return $url; |
|
| 2048 | - } |
|
| 2049 | - |
|
| 2050 | - if (is_null($profondeur)) { |
|
| 2051 | - $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 2052 | - } |
|
| 2053 | - |
|
| 2054 | - if (isset($url[$profondeur])) { |
|
| 2055 | - return $url[$profondeur]; |
|
| 2056 | - } |
|
| 2057 | - |
|
| 2058 | - $http = 'http'; |
|
| 2059 | - |
|
| 2060 | - if ( |
|
| 2061 | - isset($_SERVER['SCRIPT_URI']) |
|
| 2062 | - and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 2063 | - ) { |
|
| 2064 | - $http = 'https'; |
|
| 2065 | - } elseif ( |
|
| 2066 | - isset($_SERVER['HTTPS']) |
|
| 2067 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 2068 | - ) { |
|
| 2069 | - $http = 'https'; |
|
| 2070 | - } |
|
| 2071 | - |
|
| 2072 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 2073 | - $host = $_SERVER['HTTP_HOST'] ?? null; |
|
| 2074 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 2075 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2076 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 2077 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 2078 | - $http = $scheme; |
|
| 2079 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 2080 | - } |
|
| 2081 | - } |
|
| 2082 | - if ( |
|
| 2083 | - isset($_SERVER['SERVER_PORT']) |
|
| 2084 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 2085 | - and strpos($host, ':') == false |
|
| 2086 | - ) { |
|
| 2087 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2088 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 2089 | - } |
|
| 2090 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2091 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2092 | - } |
|
| 2093 | - if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2094 | - $host .= ":$port"; |
|
| 2095 | - } |
|
| 2096 | - if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2097 | - $host .= ":$port"; |
|
| 2098 | - } |
|
| 2099 | - } |
|
| 2100 | - |
|
| 2101 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 2102 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2103 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2104 | - } else { |
|
| 2105 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2106 | - if ( |
|
| 2107 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2108 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2109 | - ) { |
|
| 2110 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2111 | - } |
|
| 2112 | - } |
|
| 2113 | - } |
|
| 2114 | - |
|
| 2115 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2116 | - |
|
| 2117 | - return $url[$profondeur]; |
|
| 2041 | + static $url = []; |
|
| 2042 | + if (is_array($profondeur)) { |
|
| 2043 | + return $url = $profondeur; |
|
| 2044 | + } |
|
| 2045 | + if ($profondeur === false) { |
|
| 2046 | + return $url; |
|
| 2047 | + } |
|
| 2048 | + |
|
| 2049 | + if (is_null($profondeur)) { |
|
| 2050 | + $profondeur = $GLOBALS['profondeur_url'] ?? (_DIR_RESTREINT ? 0 : 1); |
|
| 2051 | + } |
|
| 2052 | + |
|
| 2053 | + if (isset($url[$profondeur])) { |
|
| 2054 | + return $url[$profondeur]; |
|
| 2055 | + } |
|
| 2056 | + |
|
| 2057 | + $http = 'http'; |
|
| 2058 | + |
|
| 2059 | + if ( |
|
| 2060 | + isset($_SERVER['SCRIPT_URI']) |
|
| 2061 | + and substr($_SERVER['SCRIPT_URI'], 0, 5) == 'https' |
|
| 2062 | + ) { |
|
| 2063 | + $http = 'https'; |
|
| 2064 | + } elseif ( |
|
| 2065 | + isset($_SERVER['HTTPS']) |
|
| 2066 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 2067 | + ) { |
|
| 2068 | + $http = 'https'; |
|
| 2069 | + } |
|
| 2070 | + |
|
| 2071 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 2072 | + $host = $_SERVER['HTTP_HOST'] ?? null; |
|
| 2073 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 2074 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2075 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 2076 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 2077 | + $http = $scheme; |
|
| 2078 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 2079 | + } |
|
| 2080 | + } |
|
| 2081 | + if ( |
|
| 2082 | + isset($_SERVER['SERVER_PORT']) |
|
| 2083 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 2084 | + and strpos($host, ':') == false |
|
| 2085 | + ) { |
|
| 2086 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 2087 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 2088 | + } |
|
| 2089 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2090 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2091 | + } |
|
| 2092 | + if ($http == 'http' and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2093 | + $host .= ":$port"; |
|
| 2094 | + } |
|
| 2095 | + if ($http == 'https' and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2096 | + $host .= ":$port"; |
|
| 2097 | + } |
|
| 2098 | + } |
|
| 2099 | + |
|
| 2100 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 2101 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2102 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2103 | + } else { |
|
| 2104 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2105 | + if ( |
|
| 2106 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2107 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2108 | + ) { |
|
| 2109 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2110 | + } |
|
| 2111 | + } |
|
| 2112 | + } |
|
| 2113 | + |
|
| 2114 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2115 | + |
|
| 2116 | + return $url[$profondeur]; |
|
| 2118 | 2117 | } |
| 2119 | 2118 | |
| 2120 | 2119 | /** |
@@ -2127,26 +2126,26 @@ discard block |
||
| 2127 | 2126 | * @return string |
| 2128 | 2127 | */ |
| 2129 | 2128 | function url_de_($http, $host, $request, $prof = 0) { |
| 2130 | - $prof = max($prof, 0); |
|
| 2129 | + $prof = max($prof, 0); |
|
| 2131 | 2130 | |
| 2132 | - $myself = ltrim($request, '/'); |
|
| 2133 | - # supprimer la chaine de GET |
|
| 2134 | - [$myself] = explode('?', $myself); |
|
| 2135 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2136 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2137 | - if (strpos($myself, '://') !== false) { |
|
| 2138 | - $myself = explode('://', $myself); |
|
| 2139 | - array_shift($myself); |
|
| 2140 | - $myself = implode('://', $myself); |
|
| 2141 | - $myself = explode('/', $myself); |
|
| 2142 | - array_shift($myself); |
|
| 2143 | - $myself = implode('/', $myself); |
|
| 2144 | - } |
|
| 2145 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2131 | + $myself = ltrim($request, '/'); |
|
| 2132 | + # supprimer la chaine de GET |
|
| 2133 | + [$myself] = explode('?', $myself); |
|
| 2134 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2135 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2136 | + if (strpos($myself, '://') !== false) { |
|
| 2137 | + $myself = explode('://', $myself); |
|
| 2138 | + array_shift($myself); |
|
| 2139 | + $myself = implode('://', $myself); |
|
| 2140 | + $myself = explode('/', $myself); |
|
| 2141 | + array_shift($myself); |
|
| 2142 | + $myself = implode('/', $myself); |
|
| 2143 | + } |
|
| 2144 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2146 | 2145 | |
| 2147 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2146 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2148 | 2147 | |
| 2149 | - return $url; |
|
| 2148 | + return $url; |
|
| 2150 | 2149 | } |
| 2151 | 2150 | |
| 2152 | 2151 | |
@@ -2181,25 +2180,25 @@ discard block |
||
| 2181 | 2180 | * @return string URL |
| 2182 | 2181 | **/ |
| 2183 | 2182 | function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) { |
| 2184 | - if (!$rel) { |
|
| 2185 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2186 | - } else { |
|
| 2187 | - if (!is_string($rel)) { |
|
| 2188 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2189 | - } |
|
| 2190 | - } |
|
| 2191 | - |
|
| 2192 | - [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2193 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2194 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2195 | - } elseif ($args) { |
|
| 2196 | - $args = "?$args"; |
|
| 2197 | - } |
|
| 2198 | - if ($ancre) { |
|
| 2199 | - $args .= "#$ancre"; |
|
| 2200 | - } |
|
| 2201 | - |
|
| 2202 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2183 | + if (!$rel) { |
|
| 2184 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2185 | + } else { |
|
| 2186 | + if (!is_string($rel)) { |
|
| 2187 | + $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2188 | + } |
|
| 2189 | + } |
|
| 2190 | + |
|
| 2191 | + [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
|
| 2192 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2193 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2194 | + } elseif ($args) { |
|
| 2195 | + $args = "?$args"; |
|
| 2196 | + } |
|
| 2197 | + if ($ancre) { |
|
| 2198 | + $args .= "#$ancre"; |
|
| 2199 | + } |
|
| 2200 | + |
|
| 2201 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2203 | 2202 | } |
| 2204 | 2203 | |
| 2205 | 2204 | // |
@@ -2221,15 +2220,15 @@ discard block |
||
| 2221 | 2220 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2222 | 2221 | **/ |
| 2223 | 2222 | function get_spip_script($default = '') { |
| 2224 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2225 | - return 'spip.php'; |
|
| 2226 | - } |
|
| 2227 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2228 | - if (_SPIP_SCRIPT) { |
|
| 2229 | - return _SPIP_SCRIPT; |
|
| 2230 | - } else { |
|
| 2231 | - return $default; |
|
| 2232 | - } |
|
| 2223 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2224 | + return 'spip.php'; |
|
| 2225 | + } |
|
| 2226 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2227 | + if (_SPIP_SCRIPT) { |
|
| 2228 | + return _SPIP_SCRIPT; |
|
| 2229 | + } else { |
|
| 2230 | + return $default; |
|
| 2231 | + } |
|
| 2233 | 2232 | } |
| 2234 | 2233 | |
| 2235 | 2234 | /** |
@@ -2258,45 +2257,45 @@ discard block |
||
| 2258 | 2257 | * @return string URL |
| 2259 | 2258 | **/ |
| 2260 | 2259 | function generer_url_public($script = '', $args = '', $no_entities = false, $rel = true, $action = '') { |
| 2261 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2262 | - // standardiser vers la nouvelle API |
|
| 2263 | - |
|
| 2264 | - if (is_array($args)) { |
|
| 2265 | - $args = http_build_query($args); |
|
| 2266 | - } |
|
| 2267 | - |
|
| 2268 | - $url = ''; |
|
| 2269 | - if ($f = charger_fonction_url('page')) { |
|
| 2270 | - $url = $f($script, $args); |
|
| 2271 | - if ($url and !$rel) { |
|
| 2272 | - include_spip('inc/filtres_mini'); |
|
| 2273 | - $url = url_absolue($url); |
|
| 2274 | - } |
|
| 2275 | - } |
|
| 2276 | - if (!$url) { |
|
| 2277 | - if (!$action) { |
|
| 2278 | - $action = get_spip_script(); |
|
| 2279 | - } |
|
| 2280 | - if ($script) { |
|
| 2281 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2282 | - } |
|
| 2283 | - if ($args) { |
|
| 2284 | - $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2285 | - } |
|
| 2286 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2287 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2288 | - } |
|
| 2289 | - |
|
| 2290 | - if (!$no_entities) { |
|
| 2291 | - $url = quote_amp($url); |
|
| 2292 | - } |
|
| 2293 | - |
|
| 2294 | - return $url; |
|
| 2260 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2261 | + // standardiser vers la nouvelle API |
|
| 2262 | + |
|
| 2263 | + if (is_array($args)) { |
|
| 2264 | + $args = http_build_query($args); |
|
| 2265 | + } |
|
| 2266 | + |
|
| 2267 | + $url = ''; |
|
| 2268 | + if ($f = charger_fonction_url('page')) { |
|
| 2269 | + $url = $f($script, $args); |
|
| 2270 | + if ($url and !$rel) { |
|
| 2271 | + include_spip('inc/filtres_mini'); |
|
| 2272 | + $url = url_absolue($url); |
|
| 2273 | + } |
|
| 2274 | + } |
|
| 2275 | + if (!$url) { |
|
| 2276 | + if (!$action) { |
|
| 2277 | + $action = get_spip_script(); |
|
| 2278 | + } |
|
| 2279 | + if ($script) { |
|
| 2280 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2281 | + } |
|
| 2282 | + if ($args) { |
|
| 2283 | + $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2284 | + } |
|
| 2285 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2286 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2287 | + } |
|
| 2288 | + |
|
| 2289 | + if (!$no_entities) { |
|
| 2290 | + $url = quote_amp($url); |
|
| 2291 | + } |
|
| 2292 | + |
|
| 2293 | + return $url; |
|
| 2295 | 2294 | } |
| 2296 | 2295 | |
| 2297 | 2296 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2298 | 2297 | |
| 2299 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2298 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2300 | 2299 | } |
| 2301 | 2300 | |
| 2302 | 2301 | // Pour les formulaires en methode POST, |
@@ -2321,19 +2320,19 @@ discard block |
||
| 2321 | 2320 | **/ |
| 2322 | 2321 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2323 | 2322 | |
| 2324 | - $script1 = explode('&', $script); |
|
| 2325 | - $script1 = reset($script1); |
|
| 2323 | + $script1 = explode('&', $script); |
|
| 2324 | + $script1 = reset($script1); |
|
| 2326 | 2325 | |
| 2327 | - return "<form action='" |
|
| 2328 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2329 | - . "' " |
|
| 2330 | - . ($atts ?: " method='post'") |
|
| 2331 | - . "><div>\n" |
|
| 2332 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2333 | - . $corps |
|
| 2334 | - . (!$submit ? '' : |
|
| 2335 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2336 | - . "</div></form>\n"; |
|
| 2326 | + return "<form action='" |
|
| 2327 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2328 | + . "' " |
|
| 2329 | + . ($atts ?: " method='post'") |
|
| 2330 | + . "><div>\n" |
|
| 2331 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2332 | + . $corps |
|
| 2333 | + . (!$submit ? '' : |
|
| 2334 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2335 | + . "</div></form>\n"; |
|
| 2337 | 2336 | } |
| 2338 | 2337 | |
| 2339 | 2338 | /** |
@@ -2350,22 +2349,22 @@ discard block |
||
| 2350 | 2349 | * @return string |
| 2351 | 2350 | */ |
| 2352 | 2351 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2353 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2354 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2355 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2356 | - $h = (_DIR_RACINE and !$public) |
|
| 2357 | - ? generer_url_ecrire(_request('exec')) |
|
| 2358 | - : generer_url_public(); |
|
| 2352 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2353 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2354 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2355 | + $h = (_DIR_RACINE and !$public) |
|
| 2356 | + ? generer_url_ecrire(_request('exec')) |
|
| 2357 | + : generer_url_public(); |
|
| 2359 | 2358 | |
| 2360 | - return "\n<form action='" . |
|
| 2361 | - $h . |
|
| 2362 | - "'" . |
|
| 2363 | - $atts . |
|
| 2364 | - ">\n" . |
|
| 2365 | - '<div>' . |
|
| 2366 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2367 | - $corps . |
|
| 2368 | - '</div></form>'; |
|
| 2359 | + return "\n<form action='" . |
|
| 2360 | + $h . |
|
| 2361 | + "'" . |
|
| 2362 | + $atts . |
|
| 2363 | + ">\n" . |
|
| 2364 | + '<div>' . |
|
| 2365 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2366 | + $corps . |
|
| 2367 | + '</div></form>'; |
|
| 2369 | 2368 | } |
| 2370 | 2369 | |
| 2371 | 2370 | /** |
@@ -2384,22 +2383,22 @@ discard block |
||
| 2384 | 2383 | * URL |
| 2385 | 2384 | */ |
| 2386 | 2385 | function generer_url_action($script, $args = '', $no_entities = false, $public = false) { |
| 2387 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2388 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2389 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2390 | - $url = (_DIR_RACINE and !$public) |
|
| 2391 | - ? generer_url_ecrire(_request('exec')) |
|
| 2392 | - : generer_url_public('', '', false, false); |
|
| 2393 | - $url = parametre_url($url, 'action', $script); |
|
| 2394 | - if ($args) { |
|
| 2395 | - $url .= quote_amp('&' . $args); |
|
| 2396 | - } |
|
| 2386 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2387 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2388 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2389 | + $url = (_DIR_RACINE and !$public) |
|
| 2390 | + ? generer_url_ecrire(_request('exec')) |
|
| 2391 | + : generer_url_public('', '', false, false); |
|
| 2392 | + $url = parametre_url($url, 'action', $script); |
|
| 2393 | + if ($args) { |
|
| 2394 | + $url .= quote_amp('&' . $args); |
|
| 2395 | + } |
|
| 2397 | 2396 | |
| 2398 | - if ($no_entities) { |
|
| 2399 | - $url = str_replace('&', '&', $url); |
|
| 2400 | - } |
|
| 2397 | + if ($no_entities) { |
|
| 2398 | + $url = str_replace('&', '&', $url); |
|
| 2399 | + } |
|
| 2401 | 2400 | |
| 2402 | - return $url; |
|
| 2401 | + return $url; |
|
| 2403 | 2402 | } |
| 2404 | 2403 | |
| 2405 | 2404 | |
@@ -2412,8 +2411,8 @@ discard block |
||
| 2412 | 2411 | * @param string $ta Répertoire temporaire accessible |
| 2413 | 2412 | */ |
| 2414 | 2413 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2415 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2416 | - spip_initialisation_suite(); |
|
| 2414 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2415 | + spip_initialisation_suite(); |
|
| 2417 | 2416 | } |
| 2418 | 2417 | |
| 2419 | 2418 | /** |
@@ -2433,322 +2432,322 @@ discard block |
||
| 2433 | 2432 | * @param string $ta Répertoire temporaire accessible |
| 2434 | 2433 | */ |
| 2435 | 2434 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2436 | - static $too_late = 0; |
|
| 2437 | - if ($too_late++) { |
|
| 2438 | - return; |
|
| 2439 | - } |
|
| 2440 | - |
|
| 2441 | - // Declaration des repertoires |
|
| 2442 | - |
|
| 2443 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2444 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2445 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2446 | - } |
|
| 2447 | - |
|
| 2448 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2449 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2450 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2451 | - } |
|
| 2452 | - |
|
| 2453 | - // le nom du repertoire des librairies |
|
| 2454 | - if (!defined('_DIR_LIB')) { |
|
| 2455 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2456 | - } |
|
| 2457 | - |
|
| 2458 | - if (!defined('_DIR_IMG')) { |
|
| 2459 | - define('_DIR_IMG', $pa); |
|
| 2460 | - } |
|
| 2461 | - if (!defined('_DIR_LOGOS')) { |
|
| 2462 | - define('_DIR_LOGOS', $pa); |
|
| 2463 | - } |
|
| 2464 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2465 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2466 | - } |
|
| 2467 | - |
|
| 2468 | - if (!defined('_DIR_DUMP')) { |
|
| 2469 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2470 | - } |
|
| 2471 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2472 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2473 | - } |
|
| 2474 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2475 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2476 | - } |
|
| 2477 | - if (!defined('_DIR_CACHE')) { |
|
| 2478 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2479 | - } |
|
| 2480 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2481 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2482 | - } |
|
| 2483 | - if (!defined('_DIR_SKELS')) { |
|
| 2484 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2485 | - } |
|
| 2486 | - if (!defined('_DIR_AIDE')) { |
|
| 2487 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2488 | - } |
|
| 2489 | - if (!defined('_DIR_TMP')) { |
|
| 2490 | - define('_DIR_TMP', $ti); |
|
| 2491 | - } |
|
| 2492 | - |
|
| 2493 | - if (!defined('_DIR_VAR')) { |
|
| 2494 | - define('_DIR_VAR', $ta); |
|
| 2495 | - } |
|
| 2496 | - |
|
| 2497 | - if (!defined('_DIR_ETC')) { |
|
| 2498 | - define('_DIR_ETC', $pi); |
|
| 2499 | - } |
|
| 2500 | - if (!defined('_DIR_CONNECT')) { |
|
| 2501 | - define('_DIR_CONNECT', $pi); |
|
| 2502 | - } |
|
| 2503 | - if (!defined('_DIR_CHMOD')) { |
|
| 2504 | - define('_DIR_CHMOD', $pi); |
|
| 2505 | - } |
|
| 2506 | - |
|
| 2507 | - if (!isset($GLOBALS['test_dirs'])) { |
|
| 2508 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2509 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2510 | - $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2511 | - } |
|
| 2512 | - |
|
| 2513 | - // Declaration des fichiers |
|
| 2514 | - |
|
| 2515 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2516 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2517 | - } |
|
| 2518 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2519 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2520 | - } |
|
| 2521 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2522 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2523 | - } |
|
| 2524 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2525 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2526 | - } |
|
| 2527 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2528 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2529 | - } |
|
| 2530 | - |
|
| 2531 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2532 | - if (!defined('_FILE_META')) { |
|
| 2533 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2534 | - } |
|
| 2535 | - if (!defined('_DIR_LOG')) { |
|
| 2536 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2537 | - } |
|
| 2538 | - if (!defined('_FILE_LOG')) { |
|
| 2539 | - define('_FILE_LOG', 'spip'); |
|
| 2540 | - } |
|
| 2541 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2542 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2543 | - } |
|
| 2544 | - |
|
| 2545 | - // Le fichier de connexion a la base de donnees |
|
| 2546 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2547 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2548 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2549 | - } |
|
| 2550 | - if (!defined('_FILE_CONNECT')) { |
|
| 2551 | - define( |
|
| 2552 | - '_FILE_CONNECT', |
|
| 2553 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2554 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2555 | - : false)) |
|
| 2556 | - ); |
|
| 2557 | - } |
|
| 2558 | - |
|
| 2559 | - // Le fichier de reglages des droits |
|
| 2560 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2561 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2562 | - } |
|
| 2563 | - if (!defined('_FILE_CHMOD')) { |
|
| 2564 | - define( |
|
| 2565 | - '_FILE_CHMOD', |
|
| 2566 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2567 | - : false) |
|
| 2568 | - ); |
|
| 2569 | - } |
|
| 2570 | - |
|
| 2571 | - if (!defined('_FILE_LDAP')) { |
|
| 2572 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2573 | - } |
|
| 2574 | - |
|
| 2575 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2576 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2577 | - } |
|
| 2578 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2579 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2580 | - } |
|
| 2581 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2582 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2583 | - } |
|
| 2584 | - |
|
| 2585 | - // Definition des droits d'acces en ecriture |
|
| 2586 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2587 | - include_once _FILE_CHMOD; |
|
| 2588 | - } |
|
| 2589 | - |
|
| 2590 | - // Se mefier des fichiers mal remplis! |
|
| 2591 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2592 | - define('_SPIP_CHMOD', 0777); |
|
| 2593 | - } |
|
| 2594 | - |
|
| 2595 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2596 | - /** Le charset par défaut lors de l'installation */ |
|
| 2597 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2598 | - } |
|
| 2599 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2600 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2601 | - } |
|
| 2602 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2603 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2604 | - } |
|
| 2605 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2606 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2607 | - } |
|
| 2608 | - |
|
| 2609 | - // La taille des Log |
|
| 2610 | - if (!defined('_MAX_LOG')) { |
|
| 2611 | - define('_MAX_LOG', 100); |
|
| 2612 | - } |
|
| 2613 | - |
|
| 2614 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2615 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2616 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2617 | - if (!defined('_OS_SERVEUR')) { |
|
| 2618 | - define('_OS_SERVEUR', 'windows'); |
|
| 2619 | - } |
|
| 2620 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2621 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2622 | - } // utiliser le flock php |
|
| 2623 | - } else { |
|
| 2624 | - if (!defined('_OS_SERVEUR')) { |
|
| 2625 | - define('_OS_SERVEUR', ''); |
|
| 2626 | - } |
|
| 2627 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2628 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2629 | - } // utiliser le flock php |
|
| 2630 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2631 | - } |
|
| 2632 | - |
|
| 2633 | - // Langue par defaut |
|
| 2634 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2635 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2636 | - } |
|
| 2637 | - |
|
| 2638 | - // |
|
| 2639 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2640 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2641 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2642 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2643 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2644 | - |
|
| 2645 | - // charger tout de suite le path et son cache |
|
| 2646 | - load_path_cache(); |
|
| 2647 | - |
|
| 2648 | - // *********** traiter les variables ************ |
|
| 2649 | - |
|
| 2650 | - // |
|
| 2651 | - // Securite |
|
| 2652 | - // |
|
| 2653 | - |
|
| 2654 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2655 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2656 | - die(); |
|
| 2657 | - } |
|
| 2658 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2659 | - spip_desinfecte($_GET); |
|
| 2660 | - spip_desinfecte($_POST); |
|
| 2661 | - spip_desinfecte($_COOKIE); |
|
| 2662 | - spip_desinfecte($_REQUEST); |
|
| 2663 | - |
|
| 2664 | - // appliquer le cookie_prefix |
|
| 2665 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2666 | - include_spip('inc/cookie'); |
|
| 2667 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2668 | - } |
|
| 2669 | - |
|
| 2670 | - // |
|
| 2671 | - // Capacites php (en fonction de la version) |
|
| 2672 | - // |
|
| 2673 | - $GLOBALS['flag_ob'] = (function_exists('ob_start') |
|
| 2674 | - && function_exists('ini_get') |
|
| 2675 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2676 | - $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name'); |
|
| 2677 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ''); |
|
| 2678 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2679 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2680 | - |
|
| 2681 | - |
|
| 2682 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2683 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2684 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2685 | - } else { |
|
| 2686 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2687 | - if ( |
|
| 2688 | - !empty($_SERVER['QUERY_STRING']) |
|
| 2689 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2690 | - ) { |
|
| 2691 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2692 | - } |
|
| 2693 | - } |
|
| 2694 | - |
|
| 2695 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2696 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2697 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2698 | - } |
|
| 2699 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2700 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2701 | - } |
|
| 2702 | - |
|
| 2703 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2704 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2705 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2706 | - $inc_meta(); |
|
| 2707 | - |
|
| 2708 | - // nombre de repertoires depuis la racine |
|
| 2709 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2710 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2711 | - // le calcul est faux) |
|
| 2712 | - if (!_DIR_RESTREINT) { |
|
| 2713 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2714 | - } else { |
|
| 2715 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2716 | - $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2717 | - if ( |
|
| 2718 | - !$uri_ref |
|
| 2719 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2720 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2721 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2722 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2723 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2724 | - ) { |
|
| 2725 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2726 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2727 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2728 | - } else { |
|
| 2729 | - $uri_ref = ''; |
|
| 2730 | - } |
|
| 2731 | - } |
|
| 2732 | - if (!$uri or !$uri_ref) { |
|
| 2733 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2734 | - } else { |
|
| 2735 | - $GLOBALS['profondeur_url'] = max( |
|
| 2736 | - 0, |
|
| 2737 | - substr_count($uri[0], '/') |
|
| 2738 | - - substr_count($uri_ref, '/') |
|
| 2739 | - ); |
|
| 2740 | - } |
|
| 2741 | - } |
|
| 2742 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2743 | - if (_FILE_CONNECT) { |
|
| 2744 | - if ( |
|
| 2745 | - verifier_visiteur() == '0minirezo' |
|
| 2746 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2747 | - and !isset($_COOKIE['spip_admin']) |
|
| 2748 | - ) { |
|
| 2749 | - clear_path_cache(); |
|
| 2750 | - } |
|
| 2751 | - } |
|
| 2435 | + static $too_late = 0; |
|
| 2436 | + if ($too_late++) { |
|
| 2437 | + return; |
|
| 2438 | + } |
|
| 2439 | + |
|
| 2440 | + // Declaration des repertoires |
|
| 2441 | + |
|
| 2442 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2443 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2444 | + define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2445 | + } |
|
| 2446 | + |
|
| 2447 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2448 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2449 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2450 | + } |
|
| 2451 | + |
|
| 2452 | + // le nom du repertoire des librairies |
|
| 2453 | + if (!defined('_DIR_LIB')) { |
|
| 2454 | + define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2455 | + } |
|
| 2456 | + |
|
| 2457 | + if (!defined('_DIR_IMG')) { |
|
| 2458 | + define('_DIR_IMG', $pa); |
|
| 2459 | + } |
|
| 2460 | + if (!defined('_DIR_LOGOS')) { |
|
| 2461 | + define('_DIR_LOGOS', $pa); |
|
| 2462 | + } |
|
| 2463 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2464 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2465 | + } |
|
| 2466 | + |
|
| 2467 | + if (!defined('_DIR_DUMP')) { |
|
| 2468 | + define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2469 | + } |
|
| 2470 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2471 | + define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2472 | + } |
|
| 2473 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2474 | + define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2475 | + } |
|
| 2476 | + if (!defined('_DIR_CACHE')) { |
|
| 2477 | + define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2478 | + } |
|
| 2479 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2480 | + define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2481 | + } |
|
| 2482 | + if (!defined('_DIR_SKELS')) { |
|
| 2483 | + define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2484 | + } |
|
| 2485 | + if (!defined('_DIR_AIDE')) { |
|
| 2486 | + define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2487 | + } |
|
| 2488 | + if (!defined('_DIR_TMP')) { |
|
| 2489 | + define('_DIR_TMP', $ti); |
|
| 2490 | + } |
|
| 2491 | + |
|
| 2492 | + if (!defined('_DIR_VAR')) { |
|
| 2493 | + define('_DIR_VAR', $ta); |
|
| 2494 | + } |
|
| 2495 | + |
|
| 2496 | + if (!defined('_DIR_ETC')) { |
|
| 2497 | + define('_DIR_ETC', $pi); |
|
| 2498 | + } |
|
| 2499 | + if (!defined('_DIR_CONNECT')) { |
|
| 2500 | + define('_DIR_CONNECT', $pi); |
|
| 2501 | + } |
|
| 2502 | + if (!defined('_DIR_CHMOD')) { |
|
| 2503 | + define('_DIR_CHMOD', $pi); |
|
| 2504 | + } |
|
| 2505 | + |
|
| 2506 | + if (!isset($GLOBALS['test_dirs'])) { |
|
| 2507 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2508 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2509 | + $GLOBALS['test_dirs'] = [$pa, $ti, $ta]; |
|
| 2510 | + } |
|
| 2511 | + |
|
| 2512 | + // Declaration des fichiers |
|
| 2513 | + |
|
| 2514 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2515 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2516 | + } |
|
| 2517 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2518 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2519 | + } |
|
| 2520 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2521 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2522 | + } |
|
| 2523 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2524 | + define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2525 | + } |
|
| 2526 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2527 | + define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2528 | + } |
|
| 2529 | + |
|
| 2530 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2531 | + if (!defined('_FILE_META')) { |
|
| 2532 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2533 | + } |
|
| 2534 | + if (!defined('_DIR_LOG')) { |
|
| 2535 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2536 | + } |
|
| 2537 | + if (!defined('_FILE_LOG')) { |
|
| 2538 | + define('_FILE_LOG', 'spip'); |
|
| 2539 | + } |
|
| 2540 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2541 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2542 | + } |
|
| 2543 | + |
|
| 2544 | + // Le fichier de connexion a la base de donnees |
|
| 2545 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2546 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2547 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2548 | + } |
|
| 2549 | + if (!defined('_FILE_CONNECT')) { |
|
| 2550 | + define( |
|
| 2551 | + '_FILE_CONNECT', |
|
| 2552 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2553 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2554 | + : false)) |
|
| 2555 | + ); |
|
| 2556 | + } |
|
| 2557 | + |
|
| 2558 | + // Le fichier de reglages des droits |
|
| 2559 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2560 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2561 | + } |
|
| 2562 | + if (!defined('_FILE_CHMOD')) { |
|
| 2563 | + define( |
|
| 2564 | + '_FILE_CHMOD', |
|
| 2565 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2566 | + : false) |
|
| 2567 | + ); |
|
| 2568 | + } |
|
| 2569 | + |
|
| 2570 | + if (!defined('_FILE_LDAP')) { |
|
| 2571 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2572 | + } |
|
| 2573 | + |
|
| 2574 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2575 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2576 | + } |
|
| 2577 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2578 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2579 | + } |
|
| 2580 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2581 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2582 | + } |
|
| 2583 | + |
|
| 2584 | + // Definition des droits d'acces en ecriture |
|
| 2585 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2586 | + include_once _FILE_CHMOD; |
|
| 2587 | + } |
|
| 2588 | + |
|
| 2589 | + // Se mefier des fichiers mal remplis! |
|
| 2590 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2591 | + define('_SPIP_CHMOD', 0777); |
|
| 2592 | + } |
|
| 2593 | + |
|
| 2594 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2595 | + /** Le charset par défaut lors de l'installation */ |
|
| 2596 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2597 | + } |
|
| 2598 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2599 | + define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2600 | + } |
|
| 2601 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2602 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2603 | + } |
|
| 2604 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2605 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2606 | + } |
|
| 2607 | + |
|
| 2608 | + // La taille des Log |
|
| 2609 | + if (!defined('_MAX_LOG')) { |
|
| 2610 | + define('_MAX_LOG', 100); |
|
| 2611 | + } |
|
| 2612 | + |
|
| 2613 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2614 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2615 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2616 | + if (!defined('_OS_SERVEUR')) { |
|
| 2617 | + define('_OS_SERVEUR', 'windows'); |
|
| 2618 | + } |
|
| 2619 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2620 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2621 | + } // utiliser le flock php |
|
| 2622 | + } else { |
|
| 2623 | + if (!defined('_OS_SERVEUR')) { |
|
| 2624 | + define('_OS_SERVEUR', ''); |
|
| 2625 | + } |
|
| 2626 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2627 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2628 | + } // utiliser le flock php |
|
| 2629 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2630 | + } |
|
| 2631 | + |
|
| 2632 | + // Langue par defaut |
|
| 2633 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2634 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2635 | + } |
|
| 2636 | + |
|
| 2637 | + // |
|
| 2638 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2639 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2640 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2641 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2642 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2643 | + |
|
| 2644 | + // charger tout de suite le path et son cache |
|
| 2645 | + load_path_cache(); |
|
| 2646 | + |
|
| 2647 | + // *********** traiter les variables ************ |
|
| 2648 | + |
|
| 2649 | + // |
|
| 2650 | + // Securite |
|
| 2651 | + // |
|
| 2652 | + |
|
| 2653 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2654 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2655 | + die(); |
|
| 2656 | + } |
|
| 2657 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2658 | + spip_desinfecte($_GET); |
|
| 2659 | + spip_desinfecte($_POST); |
|
| 2660 | + spip_desinfecte($_COOKIE); |
|
| 2661 | + spip_desinfecte($_REQUEST); |
|
| 2662 | + |
|
| 2663 | + // appliquer le cookie_prefix |
|
| 2664 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2665 | + include_spip('inc/cookie'); |
|
| 2666 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2667 | + } |
|
| 2668 | + |
|
| 2669 | + // |
|
| 2670 | + // Capacites php (en fonction de la version) |
|
| 2671 | + // |
|
| 2672 | + $GLOBALS['flag_ob'] = (function_exists('ob_start') |
|
| 2673 | + && function_exists('ini_get') |
|
| 2674 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2675 | + $GLOBALS['flag_sapi_name'] = function_exists('php_sapi_name'); |
|
| 2676 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ''); |
|
| 2677 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2678 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2679 | + |
|
| 2680 | + |
|
| 2681 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2682 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2683 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2684 | + } else { |
|
| 2685 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2686 | + if ( |
|
| 2687 | + !empty($_SERVER['QUERY_STRING']) |
|
| 2688 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2689 | + ) { |
|
| 2690 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2691 | + } |
|
| 2692 | + } |
|
| 2693 | + |
|
| 2694 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2695 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2696 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2697 | + } |
|
| 2698 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2699 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2700 | + } |
|
| 2701 | + |
|
| 2702 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2703 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2704 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2705 | + $inc_meta(); |
|
| 2706 | + |
|
| 2707 | + // nombre de repertoires depuis la racine |
|
| 2708 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2709 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2710 | + // le calcul est faux) |
|
| 2711 | + if (!_DIR_RESTREINT) { |
|
| 2712 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2713 | + } else { |
|
| 2714 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2715 | + $uri_ref = $_SERVER['SCRIPT_NAME']; |
|
| 2716 | + if ( |
|
| 2717 | + !$uri_ref |
|
| 2718 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2719 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2720 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2721 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2722 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2723 | + ) { |
|
| 2724 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2725 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2726 | + $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2727 | + } else { |
|
| 2728 | + $uri_ref = ''; |
|
| 2729 | + } |
|
| 2730 | + } |
|
| 2731 | + if (!$uri or !$uri_ref) { |
|
| 2732 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2733 | + } else { |
|
| 2734 | + $GLOBALS['profondeur_url'] = max( |
|
| 2735 | + 0, |
|
| 2736 | + substr_count($uri[0], '/') |
|
| 2737 | + - substr_count($uri_ref, '/') |
|
| 2738 | + ); |
|
| 2739 | + } |
|
| 2740 | + } |
|
| 2741 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2742 | + if (_FILE_CONNECT) { |
|
| 2743 | + if ( |
|
| 2744 | + verifier_visiteur() == '0minirezo' |
|
| 2745 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2746 | + and !isset($_COOKIE['spip_admin']) |
|
| 2747 | + ) { |
|
| 2748 | + clear_path_cache(); |
|
| 2749 | + } |
|
| 2750 | + } |
|
| 2752 | 2751 | } |
| 2753 | 2752 | |
| 2754 | 2753 | /** |
@@ -2757,190 +2756,190 @@ discard block |
||
| 2757 | 2756 | * |
| 2758 | 2757 | */ |
| 2759 | 2758 | function spip_initialisation_suite() { |
| 2760 | - static $too_late = 0; |
|
| 2761 | - if ($too_late++) { |
|
| 2762 | - return; |
|
| 2763 | - } |
|
| 2764 | - |
|
| 2765 | - // taille mini des login |
|
| 2766 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2767 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2768 | - } |
|
| 2769 | - |
|
| 2770 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2771 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2772 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2773 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2774 | - |
|
| 2775 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2776 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2777 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2778 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2779 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2780 | - |
|
| 2781 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2782 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2783 | - } |
|
| 2784 | - |
|
| 2785 | - // largeur maximale des images dans l'administration |
|
| 2786 | - if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2787 | - define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2788 | - } |
|
| 2789 | - |
|
| 2790 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2791 | - if (!defined('_IMG_QUALITE')) { |
|
| 2792 | - define('_IMG_QUALITE', 85); |
|
| 2793 | - } # valeur par defaut |
|
| 2794 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2795 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2796 | - } # surcharge pour la lib GD |
|
| 2797 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2798 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2799 | - } # surcharge pour imagick en ligne de commande |
|
| 2800 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2801 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2802 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2803 | - } # surcharge pour imagick en PHP |
|
| 2804 | - |
|
| 2805 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2806 | - define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2807 | - } // poids en octet |
|
| 2808 | - |
|
| 2809 | - // qq chaines standard |
|
| 2810 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2811 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2812 | - } |
|
| 2813 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2814 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2815 | - } |
|
| 2816 | - if (!defined('_SPIP_DUMP')) { |
|
| 2817 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2818 | - } |
|
| 2819 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2820 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2821 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2822 | - } |
|
| 2823 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2824 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2825 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2826 | - } |
|
| 2827 | - |
|
| 2828 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2829 | - /** |
|
| 2830 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2831 | - * @var int Nombre de caractères */ |
|
| 2832 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2833 | - } |
|
| 2834 | - |
|
| 2835 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2836 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2837 | - } |
|
| 2838 | - |
|
| 2839 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2840 | - /** Définit le doctype de l’espace privé */ |
|
| 2841 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2842 | - } |
|
| 2843 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2844 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2845 | - define( |
|
| 2846 | - '_DOCTYPE_AIDE', |
|
| 2847 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2848 | - ); |
|
| 2849 | - } |
|
| 2850 | - |
|
| 2851 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2852 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2853 | - * le script de l'espace public, alias index.php */ |
|
| 2854 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2855 | - } |
|
| 2856 | - if (!defined('_SPIP_PAGE')) { |
|
| 2857 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2858 | - define('_SPIP_PAGE', 'page'); |
|
| 2859 | - } |
|
| 2860 | - |
|
| 2861 | - // le script de l'espace prive |
|
| 2862 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2863 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2864 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2865 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2866 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2867 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2868 | - } else { |
|
| 2869 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2870 | - } |
|
| 2871 | - } |
|
| 2872 | - |
|
| 2873 | - |
|
| 2874 | - if (!defined('_SPIP_AJAX')) { |
|
| 2875 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2876 | - ? 1 |
|
| 2877 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2878 | - } |
|
| 2879 | - |
|
| 2880 | - // La requete est-elle en ajax ? |
|
| 2881 | - if (!defined('_AJAX')) { |
|
| 2882 | - define( |
|
| 2883 | - '_AJAX', |
|
| 2884 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2885 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2886 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2887 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2888 | - ) |
|
| 2889 | - and 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 |
|
| 2890 | - ); |
|
| 2891 | - } |
|
| 2892 | - |
|
| 2893 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2894 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2895 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2896 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2897 | - define( |
|
| 2898 | - '_IMG_GD_MAX_PIXELS', |
|
| 2899 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2900 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2901 | - : 0 |
|
| 2902 | - ); |
|
| 2903 | - } |
|
| 2904 | - |
|
| 2905 | - if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2906 | - define('_MEMORY_LIMIT_MIN', 16); |
|
| 2907 | - } // en Mo |
|
| 2908 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2909 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2910 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2911 | - if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2912 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2913 | - $unit = strtolower(substr($memory, -1)); |
|
| 2914 | - $memory = substr($memory, 0, -1); |
|
| 2915 | - switch ($unit) { |
|
| 2916 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2917 | - case 'g': |
|
| 2918 | - $memory *= 1024; |
|
| 2919 | - case 'm': |
|
| 2920 | - $memory *= 1024; |
|
| 2921 | - case 'k': |
|
| 2922 | - $memory *= 1024; |
|
| 2923 | - } |
|
| 2924 | - if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2925 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2926 | - if (trim(ini_get('memory_limit')) != $m) { |
|
| 2927 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2928 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2929 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2930 | - } |
|
| 2931 | - } |
|
| 2932 | - } else { |
|
| 2933 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2934 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2935 | - } |
|
| 2936 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2937 | - } |
|
| 2938 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2939 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2940 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2941 | - } |
|
| 2942 | - |
|
| 2943 | - init_var_mode(); |
|
| 2759 | + static $too_late = 0; |
|
| 2760 | + if ($too_late++) { |
|
| 2761 | + return; |
|
| 2762 | + } |
|
| 2763 | + |
|
| 2764 | + // taille mini des login |
|
| 2765 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2766 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2767 | + } |
|
| 2768 | + |
|
| 2769 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2770 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2771 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2772 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2773 | + |
|
| 2774 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2775 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2776 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2777 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2778 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2779 | + |
|
| 2780 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2781 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2782 | + } |
|
| 2783 | + |
|
| 2784 | + // largeur maximale des images dans l'administration |
|
| 2785 | + if (!defined('_IMG_ADMIN_MAX_WIDTH')) { |
|
| 2786 | + define('_IMG_ADMIN_MAX_WIDTH', 768); |
|
| 2787 | + } |
|
| 2788 | + |
|
| 2789 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2790 | + if (!defined('_IMG_QUALITE')) { |
|
| 2791 | + define('_IMG_QUALITE', 85); |
|
| 2792 | + } # valeur par defaut |
|
| 2793 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2794 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2795 | + } # surcharge pour la lib GD |
|
| 2796 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2797 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2798 | + } # surcharge pour imagick en ligne de commande |
|
| 2799 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2800 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2801 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2802 | + } # surcharge pour imagick en PHP |
|
| 2803 | + |
|
| 2804 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2805 | + define('_COPIE_LOCALE_MAX_SIZE', 33_554_432); |
|
| 2806 | + } // poids en octet |
|
| 2807 | + |
|
| 2808 | + // qq chaines standard |
|
| 2809 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2810 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2811 | + } |
|
| 2812 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2813 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2814 | + } |
|
| 2815 | + if (!defined('_SPIP_DUMP')) { |
|
| 2816 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2817 | + } |
|
| 2818 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2819 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2820 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2821 | + } |
|
| 2822 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2823 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2824 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2825 | + } |
|
| 2826 | + |
|
| 2827 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2828 | + /** |
|
| 2829 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2830 | + * @var int Nombre de caractères */ |
|
| 2831 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2832 | + } |
|
| 2833 | + |
|
| 2834 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2835 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2836 | + } |
|
| 2837 | + |
|
| 2838 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2839 | + /** Définit le doctype de l’espace privé */ |
|
| 2840 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2841 | + } |
|
| 2842 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2843 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2844 | + define( |
|
| 2845 | + '_DOCTYPE_AIDE', |
|
| 2846 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>" |
|
| 2847 | + ); |
|
| 2848 | + } |
|
| 2849 | + |
|
| 2850 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2851 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2852 | + * le script de l'espace public, alias index.php */ |
|
| 2853 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2854 | + } |
|
| 2855 | + if (!defined('_SPIP_PAGE')) { |
|
| 2856 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2857 | + define('_SPIP_PAGE', 'page'); |
|
| 2858 | + } |
|
| 2859 | + |
|
| 2860 | + // le script de l'espace prive |
|
| 2861 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2862 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2863 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2864 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2865 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2866 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2867 | + } else { |
|
| 2868 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2869 | + } |
|
| 2870 | + } |
|
| 2871 | + |
|
| 2872 | + |
|
| 2873 | + if (!defined('_SPIP_AJAX')) { |
|
| 2874 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2875 | + ? 1 |
|
| 2876 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2877 | + } |
|
| 2878 | + |
|
| 2879 | + // La requete est-elle en ajax ? |
|
| 2880 | + if (!defined('_AJAX')) { |
|
| 2881 | + define( |
|
| 2882 | + '_AJAX', |
|
| 2883 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2884 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2885 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2886 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2887 | + ) |
|
| 2888 | + and 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 |
|
| 2889 | + ); |
|
| 2890 | + } |
|
| 2891 | + |
|
| 2892 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2893 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2894 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2895 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2896 | + define( |
|
| 2897 | + '_IMG_GD_MAX_PIXELS', |
|
| 2898 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2899 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2900 | + : 0 |
|
| 2901 | + ); |
|
| 2902 | + } |
|
| 2903 | + |
|
| 2904 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2905 | + define('_MEMORY_LIMIT_MIN', 16); |
|
| 2906 | + } // en Mo |
|
| 2907 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2908 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2909 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2910 | + if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2911 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2912 | + $unit = strtolower(substr($memory, -1)); |
|
| 2913 | + $memory = substr($memory, 0, -1); |
|
| 2914 | + switch ($unit) { |
|
| 2915 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2916 | + case 'g': |
|
| 2917 | + $memory *= 1024; |
|
| 2918 | + case 'm': |
|
| 2919 | + $memory *= 1024; |
|
| 2920 | + case 'k': |
|
| 2921 | + $memory *= 1024; |
|
| 2922 | + } |
|
| 2923 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2924 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2925 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 2926 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2927 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2928 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2929 | + } |
|
| 2930 | + } |
|
| 2931 | + } else { |
|
| 2932 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2933 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2934 | + } |
|
| 2935 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2936 | + } |
|
| 2937 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2938 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2939 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2940 | + } |
|
| 2941 | + |
|
| 2942 | + init_var_mode(); |
|
| 2944 | 2943 | } |
| 2945 | 2944 | |
| 2946 | 2945 | /** |
@@ -2974,219 +2973,219 @@ discard block |
||
| 2974 | 2973 | * ` var_mode` (calcul ou recalcul). |
| 2975 | 2974 | */ |
| 2976 | 2975 | function init_var_mode() { |
| 2977 | - static $done = false; |
|
| 2978 | - if (!$done) { |
|
| 2979 | - if (isset($_GET['var_mode'])) { |
|
| 2980 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 2981 | - // tout le monde peut calcul/recalcul |
|
| 2982 | - if (!defined('_VAR_MODE')) { |
|
| 2983 | - if (in_array('recalcul', $var_mode)) { |
|
| 2984 | - define('_VAR_MODE', 'recalcul'); |
|
| 2985 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 2986 | - define('_VAR_MODE', 'calcul'); |
|
| 2987 | - } |
|
| 2988 | - } |
|
| 2989 | - $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 2990 | - if ($var_mode) { |
|
| 2991 | - include_spip('inc/autoriser'); |
|
| 2992 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2993 | - if ( |
|
| 2994 | - autoriser( |
|
| 2995 | - ($_GET['var_mode'] == 'preview') |
|
| 2996 | - ? 'previsualiser' |
|
| 2997 | - : 'debug' |
|
| 2998 | - ) |
|
| 2999 | - ) { |
|
| 3000 | - if (in_array('traduction', $var_mode)) { |
|
| 3001 | - // forcer le calcul pour passer dans traduire |
|
| 3002 | - if (!defined('_VAR_MODE')) { |
|
| 3003 | - define('_VAR_MODE', 'calcul'); |
|
| 3004 | - } |
|
| 3005 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 3006 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3007 | - define('_VAR_NOCACHE', true); |
|
| 3008 | - } |
|
| 3009 | - $var_mode = array_diff($var_mode, ['traduction']); |
|
| 3010 | - } |
|
| 3011 | - if (in_array('preview', $var_mode)) { |
|
| 3012 | - // basculer sur les criteres de preview dans les boucles |
|
| 3013 | - if (!defined('_VAR_PREVIEW')) { |
|
| 3014 | - define('_VAR_PREVIEW', true); |
|
| 3015 | - } |
|
| 3016 | - // forcer le calcul |
|
| 3017 | - if (!defined('_VAR_MODE')) { |
|
| 3018 | - define('_VAR_MODE', 'calcul'); |
|
| 3019 | - } |
|
| 3020 | - // et ne pas enregistrer de cache |
|
| 3021 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3022 | - define('_VAR_NOCACHE', true); |
|
| 3023 | - } |
|
| 3024 | - $var_mode = array_diff($var_mode, ['preview']); |
|
| 3025 | - } |
|
| 3026 | - if (in_array('inclure', $var_mode)) { |
|
| 3027 | - // forcer le compilo et ignorer les caches existants |
|
| 3028 | - if (!defined('_VAR_MODE')) { |
|
| 3029 | - define('_VAR_MODE', 'calcul'); |
|
| 3030 | - } |
|
| 3031 | - if (!defined('_VAR_INCLURE')) { |
|
| 3032 | - define('_VAR_INCLURE', true); |
|
| 3033 | - } |
|
| 3034 | - // et ne pas enregistrer de cache |
|
| 3035 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3036 | - define('_VAR_NOCACHE', true); |
|
| 3037 | - } |
|
| 3038 | - $var_mode = array_diff($var_mode, ['inclure']); |
|
| 3039 | - } |
|
| 3040 | - if (in_array('urls', $var_mode)) { |
|
| 3041 | - // forcer le compilo et ignorer les caches existants |
|
| 3042 | - if (!defined('_VAR_MODE')) { |
|
| 3043 | - define('_VAR_MODE', 'calcul'); |
|
| 3044 | - } |
|
| 3045 | - if (!defined('_VAR_URLS')) { |
|
| 3046 | - define('_VAR_URLS', true); |
|
| 3047 | - } |
|
| 3048 | - $var_mode = array_diff($var_mode, ['urls']); |
|
| 3049 | - } |
|
| 3050 | - if (in_array('images', $var_mode)) { |
|
| 3051 | - // forcer le compilo et ignorer les caches existants |
|
| 3052 | - if (!defined('_VAR_MODE')) { |
|
| 3053 | - define('_VAR_MODE', 'calcul'); |
|
| 3054 | - } |
|
| 3055 | - // indiquer qu'on doit recalculer les images |
|
| 3056 | - if (!defined('_VAR_IMAGES')) { |
|
| 3057 | - define('_VAR_IMAGES', true); |
|
| 3058 | - } |
|
| 3059 | - $var_mode = array_diff($var_mode, ['images']); |
|
| 3060 | - } |
|
| 3061 | - if (in_array('debug', $var_mode)) { |
|
| 3062 | - if (!defined('_VAR_MODE')) { |
|
| 3063 | - define('_VAR_MODE', 'debug'); |
|
| 3064 | - } |
|
| 3065 | - // et ne pas enregistrer de cache |
|
| 3066 | - if (!defined('_VAR_NOCACHE')) { |
|
| 3067 | - define('_VAR_NOCACHE', true); |
|
| 3068 | - } |
|
| 3069 | - $var_mode = array_diff($var_mode, ['debug']); |
|
| 3070 | - } |
|
| 3071 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 3072 | - define('_VAR_MODE', reset($var_mode)); |
|
| 3073 | - } |
|
| 3074 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 3075 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 3076 | - . ' ' . _VAR_MODE); |
|
| 3077 | - } |
|
| 3078 | - } // pas autorise ? |
|
| 3079 | - else { |
|
| 3080 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 3081 | - if ( |
|
| 3082 | - !$GLOBALS['visiteur_session'] |
|
| 3083 | - and !empty($_SERVER['HTTP_HOST']) |
|
| 3084 | - and !empty($_SERVER['REQUEST_METHOD']) |
|
| 3085 | - and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 3086 | - ) { |
|
| 3087 | - $self = self('&', true); |
|
| 3088 | - if (strpos($self, 'page=login') === false) { |
|
| 3089 | - include_spip('inc/headers'); |
|
| 3090 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3091 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3092 | - } |
|
| 3093 | - } |
|
| 3094 | - // sinon tant pis |
|
| 3095 | - } |
|
| 3096 | - } |
|
| 3097 | - } |
|
| 3098 | - if (!defined('_VAR_MODE')) { |
|
| 3099 | - /** |
|
| 3100 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 3101 | - * @see init_var_mode() |
|
| 3102 | - */ |
|
| 3103 | - define('_VAR_MODE', false); |
|
| 3104 | - } |
|
| 3105 | - $done = true; |
|
| 3106 | - } |
|
| 2976 | + static $done = false; |
|
| 2977 | + if (!$done) { |
|
| 2978 | + if (isset($_GET['var_mode'])) { |
|
| 2979 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 2980 | + // tout le monde peut calcul/recalcul |
|
| 2981 | + if (!defined('_VAR_MODE')) { |
|
| 2982 | + if (in_array('recalcul', $var_mode)) { |
|
| 2983 | + define('_VAR_MODE', 'recalcul'); |
|
| 2984 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 2985 | + define('_VAR_MODE', 'calcul'); |
|
| 2986 | + } |
|
| 2987 | + } |
|
| 2988 | + $var_mode = array_diff($var_mode, ['calcul', 'recalcul']); |
|
| 2989 | + if ($var_mode) { |
|
| 2990 | + include_spip('inc/autoriser'); |
|
| 2991 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2992 | + if ( |
|
| 2993 | + autoriser( |
|
| 2994 | + ($_GET['var_mode'] == 'preview') |
|
| 2995 | + ? 'previsualiser' |
|
| 2996 | + : 'debug' |
|
| 2997 | + ) |
|
| 2998 | + ) { |
|
| 2999 | + if (in_array('traduction', $var_mode)) { |
|
| 3000 | + // forcer le calcul pour passer dans traduire |
|
| 3001 | + if (!defined('_VAR_MODE')) { |
|
| 3002 | + define('_VAR_MODE', 'calcul'); |
|
| 3003 | + } |
|
| 3004 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 3005 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3006 | + define('_VAR_NOCACHE', true); |
|
| 3007 | + } |
|
| 3008 | + $var_mode = array_diff($var_mode, ['traduction']); |
|
| 3009 | + } |
|
| 3010 | + if (in_array('preview', $var_mode)) { |
|
| 3011 | + // basculer sur les criteres de preview dans les boucles |
|
| 3012 | + if (!defined('_VAR_PREVIEW')) { |
|
| 3013 | + define('_VAR_PREVIEW', true); |
|
| 3014 | + } |
|
| 3015 | + // forcer le calcul |
|
| 3016 | + if (!defined('_VAR_MODE')) { |
|
| 3017 | + define('_VAR_MODE', 'calcul'); |
|
| 3018 | + } |
|
| 3019 | + // et ne pas enregistrer de cache |
|
| 3020 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3021 | + define('_VAR_NOCACHE', true); |
|
| 3022 | + } |
|
| 3023 | + $var_mode = array_diff($var_mode, ['preview']); |
|
| 3024 | + } |
|
| 3025 | + if (in_array('inclure', $var_mode)) { |
|
| 3026 | + // forcer le compilo et ignorer les caches existants |
|
| 3027 | + if (!defined('_VAR_MODE')) { |
|
| 3028 | + define('_VAR_MODE', 'calcul'); |
|
| 3029 | + } |
|
| 3030 | + if (!defined('_VAR_INCLURE')) { |
|
| 3031 | + define('_VAR_INCLURE', true); |
|
| 3032 | + } |
|
| 3033 | + // et ne pas enregistrer de cache |
|
| 3034 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3035 | + define('_VAR_NOCACHE', true); |
|
| 3036 | + } |
|
| 3037 | + $var_mode = array_diff($var_mode, ['inclure']); |
|
| 3038 | + } |
|
| 3039 | + if (in_array('urls', $var_mode)) { |
|
| 3040 | + // forcer le compilo et ignorer les caches existants |
|
| 3041 | + if (!defined('_VAR_MODE')) { |
|
| 3042 | + define('_VAR_MODE', 'calcul'); |
|
| 3043 | + } |
|
| 3044 | + if (!defined('_VAR_URLS')) { |
|
| 3045 | + define('_VAR_URLS', true); |
|
| 3046 | + } |
|
| 3047 | + $var_mode = array_diff($var_mode, ['urls']); |
|
| 3048 | + } |
|
| 3049 | + if (in_array('images', $var_mode)) { |
|
| 3050 | + // forcer le compilo et ignorer les caches existants |
|
| 3051 | + if (!defined('_VAR_MODE')) { |
|
| 3052 | + define('_VAR_MODE', 'calcul'); |
|
| 3053 | + } |
|
| 3054 | + // indiquer qu'on doit recalculer les images |
|
| 3055 | + if (!defined('_VAR_IMAGES')) { |
|
| 3056 | + define('_VAR_IMAGES', true); |
|
| 3057 | + } |
|
| 3058 | + $var_mode = array_diff($var_mode, ['images']); |
|
| 3059 | + } |
|
| 3060 | + if (in_array('debug', $var_mode)) { |
|
| 3061 | + if (!defined('_VAR_MODE')) { |
|
| 3062 | + define('_VAR_MODE', 'debug'); |
|
| 3063 | + } |
|
| 3064 | + // et ne pas enregistrer de cache |
|
| 3065 | + if (!defined('_VAR_NOCACHE')) { |
|
| 3066 | + define('_VAR_NOCACHE', true); |
|
| 3067 | + } |
|
| 3068 | + $var_mode = array_diff($var_mode, ['debug']); |
|
| 3069 | + } |
|
| 3070 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 3071 | + define('_VAR_MODE', reset($var_mode)); |
|
| 3072 | + } |
|
| 3073 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 3074 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 3075 | + . ' ' . _VAR_MODE); |
|
| 3076 | + } |
|
| 3077 | + } // pas autorise ? |
|
| 3078 | + else { |
|
| 3079 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 3080 | + if ( |
|
| 3081 | + !$GLOBALS['visiteur_session'] |
|
| 3082 | + and !empty($_SERVER['HTTP_HOST']) |
|
| 3083 | + and !empty($_SERVER['REQUEST_METHOD']) |
|
| 3084 | + and $_SERVER['REQUEST_METHOD'] === 'GET' |
|
| 3085 | + ) { |
|
| 3086 | + $self = self('&', true); |
|
| 3087 | + if (strpos($self, 'page=login') === false) { |
|
| 3088 | + include_spip('inc/headers'); |
|
| 3089 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 3090 | + redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3091 | + } |
|
| 3092 | + } |
|
| 3093 | + // sinon tant pis |
|
| 3094 | + } |
|
| 3095 | + } |
|
| 3096 | + } |
|
| 3097 | + if (!defined('_VAR_MODE')) { |
|
| 3098 | + /** |
|
| 3099 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 3100 | + * @see init_var_mode() |
|
| 3101 | + */ |
|
| 3102 | + define('_VAR_MODE', false); |
|
| 3103 | + } |
|
| 3104 | + $done = true; |
|
| 3105 | + } |
|
| 3107 | 3106 | } |
| 3108 | 3107 | |
| 3109 | 3108 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
| 3110 | 3109 | // supprimer aussi les eventuels caracteres nuls %00, qui peuvent tromper |
| 3111 | 3110 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 3112 | 3111 | function spip_desinfecte(&$t, $deep = true) { |
| 3113 | - foreach ($t as $key => $val) { |
|
| 3114 | - if (is_string($t[$key])) { |
|
| 3115 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3116 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 3117 | - else { |
|
| 3118 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3119 | - spip_desinfecte($t[$key], $deep); |
|
| 3120 | - } |
|
| 3121 | - } |
|
| 3122 | - } |
|
| 3112 | + foreach ($t as $key => $val) { |
|
| 3113 | + if (is_string($t[$key])) { |
|
| 3114 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3115 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 3116 | + else { |
|
| 3117 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3118 | + spip_desinfecte($t[$key], $deep); |
|
| 3119 | + } |
|
| 3120 | + } |
|
| 3121 | + } |
|
| 3123 | 3122 | } |
| 3124 | 3123 | |
| 3125 | 3124 | // retourne le statut du visiteur s'il s'annonce |
| 3126 | 3125 | |
| 3127 | 3126 | function verifier_visiteur() { |
| 3128 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 3129 | - // il faut forcer l'init si ce n'est fait |
|
| 3130 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3131 | - // certaines constantes |
|
| 3132 | - @spip_initialisation_core( |
|
| 3133 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3134 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3135 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3136 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3137 | - ); |
|
| 3138 | - |
|
| 3139 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3140 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3141 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 3142 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3143 | - $variables_session = ['session_nom', 'session_email']; |
|
| 3144 | - foreach ($variables_session as $var) { |
|
| 3145 | - if (_request($var) !== null) { |
|
| 3146 | - $init = true; |
|
| 3147 | - break; |
|
| 3148 | - } |
|
| 3149 | - } |
|
| 3150 | - if (isset($init)) { |
|
| 3151 | - #@spip_initialisation_suite(); |
|
| 3152 | - $session = charger_fonction('session', 'inc'); |
|
| 3153 | - $session(); |
|
| 3154 | - include_spip('inc/texte'); |
|
| 3155 | - foreach ($variables_session as $var) { |
|
| 3156 | - if (($a = _request($var)) !== null) { |
|
| 3157 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3158 | - } |
|
| 3159 | - } |
|
| 3160 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3161 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3162 | - } |
|
| 3163 | - $session($GLOBALS['visiteur_session']); |
|
| 3164 | - |
|
| 3165 | - return 0; |
|
| 3166 | - } |
|
| 3167 | - |
|
| 3168 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3169 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3170 | - $session = charger_fonction('session', 'inc'); |
|
| 3171 | - if ($session()) { |
|
| 3172 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3173 | - } |
|
| 3174 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3175 | - include_spip('inc/auth'); |
|
| 3176 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3177 | - } |
|
| 3178 | - if ($h) { |
|
| 3179 | - $GLOBALS['visiteur_session'] = $h; |
|
| 3180 | - |
|
| 3181 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3182 | - } |
|
| 3183 | - } |
|
| 3184 | - |
|
| 3185 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3186 | - include_spip('inc/lang'); |
|
| 3187 | - utiliser_langue_visiteur(); |
|
| 3188 | - |
|
| 3189 | - return false; |
|
| 3127 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 3128 | + // il faut forcer l'init si ce n'est fait |
|
| 3129 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3130 | + // certaines constantes |
|
| 3131 | + @spip_initialisation_core( |
|
| 3132 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3133 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3134 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3135 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3136 | + ); |
|
| 3137 | + |
|
| 3138 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3139 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3140 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 3141 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3142 | + $variables_session = ['session_nom', 'session_email']; |
|
| 3143 | + foreach ($variables_session as $var) { |
|
| 3144 | + if (_request($var) !== null) { |
|
| 3145 | + $init = true; |
|
| 3146 | + break; |
|
| 3147 | + } |
|
| 3148 | + } |
|
| 3149 | + if (isset($init)) { |
|
| 3150 | + #@spip_initialisation_suite(); |
|
| 3151 | + $session = charger_fonction('session', 'inc'); |
|
| 3152 | + $session(); |
|
| 3153 | + include_spip('inc/texte'); |
|
| 3154 | + foreach ($variables_session as $var) { |
|
| 3155 | + if (($a = _request($var)) !== null) { |
|
| 3156 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3157 | + } |
|
| 3158 | + } |
|
| 3159 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3160 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3161 | + } |
|
| 3162 | + $session($GLOBALS['visiteur_session']); |
|
| 3163 | + |
|
| 3164 | + return 0; |
|
| 3165 | + } |
|
| 3166 | + |
|
| 3167 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3168 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3169 | + $session = charger_fonction('session', 'inc'); |
|
| 3170 | + if ($session()) { |
|
| 3171 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3172 | + } |
|
| 3173 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3174 | + include_spip('inc/auth'); |
|
| 3175 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3176 | + } |
|
| 3177 | + if ($h) { |
|
| 3178 | + $GLOBALS['visiteur_session'] = $h; |
|
| 3179 | + |
|
| 3180 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3181 | + } |
|
| 3182 | + } |
|
| 3183 | + |
|
| 3184 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3185 | + include_spip('inc/lang'); |
|
| 3186 | + utiliser_langue_visiteur(); |
|
| 3187 | + |
|
| 3188 | + return false; |
|
| 3190 | 3189 | } |
| 3191 | 3190 | |
| 3192 | 3191 | |
@@ -3209,21 +3208,21 @@ discard block |
||
| 3209 | 3208 | * - string Langue utilisée. |
| 3210 | 3209 | **/ |
| 3211 | 3210 | function lang_select($lang = null) { |
| 3212 | - static $pile_langues = []; |
|
| 3213 | - if (!function_exists('changer_langue')) { |
|
| 3214 | - include_spip('inc/lang'); |
|
| 3215 | - } |
|
| 3216 | - if ($lang === null) { |
|
| 3217 | - $lang = array_pop($pile_langues); |
|
| 3218 | - } else { |
|
| 3219 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3220 | - } |
|
| 3221 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3222 | - return $lang; |
|
| 3223 | - } |
|
| 3224 | - changer_langue($lang); |
|
| 3211 | + static $pile_langues = []; |
|
| 3212 | + if (!function_exists('changer_langue')) { |
|
| 3213 | + include_spip('inc/lang'); |
|
| 3214 | + } |
|
| 3215 | + if ($lang === null) { |
|
| 3216 | + $lang = array_pop($pile_langues); |
|
| 3217 | + } else { |
|
| 3218 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3219 | + } |
|
| 3220 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3221 | + return $lang; |
|
| 3222 | + } |
|
| 3223 | + changer_langue($lang); |
|
| 3225 | 3224 | |
| 3226 | - return $lang; |
|
| 3225 | + return $lang; |
|
| 3227 | 3226 | } |
| 3228 | 3227 | |
| 3229 | 3228 | /** |
@@ -3240,20 +3239,20 @@ discard block |
||
| 3240 | 3239 | * Identifiant de la session |
| 3241 | 3240 | **/ |
| 3242 | 3241 | function spip_session($force = false) { |
| 3243 | - static $session; |
|
| 3244 | - if ($force or !isset($session)) { |
|
| 3245 | - $s = pipeline( |
|
| 3246 | - 'definir_session', |
|
| 3247 | - $GLOBALS['visiteur_session'] |
|
| 3248 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3249 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3250 | - : '' |
|
| 3251 | - ); |
|
| 3252 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3253 | - } |
|
| 3242 | + static $session; |
|
| 3243 | + if ($force or !isset($session)) { |
|
| 3244 | + $s = pipeline( |
|
| 3245 | + 'definir_session', |
|
| 3246 | + $GLOBALS['visiteur_session'] |
|
| 3247 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3248 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3249 | + : '' |
|
| 3250 | + ); |
|
| 3251 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3252 | + } |
|
| 3254 | 3253 | |
| 3255 | - #spip_log('session: '.$session); |
|
| 3256 | - return $session; |
|
| 3254 | + #spip_log('session: '.$session); |
|
| 3255 | + return $session; |
|
| 3257 | 3256 | } |
| 3258 | 3257 | |
| 3259 | 3258 | |
@@ -3272,9 +3271,9 @@ discard block |
||
| 3272 | 3271 | * Lien sur une icone d'aide |
| 3273 | 3272 | **/ |
| 3274 | 3273 | function aider($aide = '', $distante = false) { |
| 3275 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3274 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3276 | 3275 | |
| 3277 | - return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3276 | + return $aider ? $aider($aide, '', [], $distante) : ''; |
|
| 3278 | 3277 | } |
| 3279 | 3278 | |
| 3280 | 3279 | /** |
@@ -3284,24 +3283,24 @@ discard block |
||
| 3284 | 3283 | */ |
| 3285 | 3284 | function exec_info_dist() { |
| 3286 | 3285 | |
| 3287 | - include_spip('inc/autoriser'); |
|
| 3288 | - if (autoriser('phpinfos')) { |
|
| 3289 | - $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3290 | - $cookies_backup = []; |
|
| 3291 | - foreach ($cookies_masques as $k) { |
|
| 3292 | - if (!empty($_COOKIE[$k])) { |
|
| 3293 | - $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3294 | - $_COOKIE[$k] = '******************************'; |
|
| 3295 | - } |
|
| 3296 | - } |
|
| 3297 | - phpinfo(); |
|
| 3298 | - foreach ($cookies_backup as $k => $v) { |
|
| 3299 | - $_COOKIE[$k] = $v; |
|
| 3300 | - } |
|
| 3301 | - } else { |
|
| 3302 | - include_spip('inc/filtres'); |
|
| 3303 | - sinon_interdire_acces(); |
|
| 3304 | - } |
|
| 3286 | + include_spip('inc/autoriser'); |
|
| 3287 | + if (autoriser('phpinfos')) { |
|
| 3288 | + $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3289 | + $cookies_backup = []; |
|
| 3290 | + foreach ($cookies_masques as $k) { |
|
| 3291 | + if (!empty($_COOKIE[$k])) { |
|
| 3292 | + $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3293 | + $_COOKIE[$k] = '******************************'; |
|
| 3294 | + } |
|
| 3295 | + } |
|
| 3296 | + phpinfo(); |
|
| 3297 | + foreach ($cookies_backup as $k => $v) { |
|
| 3298 | + $_COOKIE[$k] = $v; |
|
| 3299 | + } |
|
| 3300 | + } else { |
|
| 3301 | + include_spip('inc/filtres'); |
|
| 3302 | + sinon_interdire_acces(); |
|
| 3303 | + } |
|
| 3305 | 3304 | } |
| 3306 | 3305 | |
| 3307 | 3306 | /** |
@@ -3321,13 +3320,13 @@ discard block |
||
| 3321 | 3320 | * - string si $message à false. |
| 3322 | 3321 | **/ |
| 3323 | 3322 | function erreur_squelette($message = '', $lieu = '') { |
| 3324 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3325 | - if (is_array($lieu)) { |
|
| 3326 | - include_spip('public/compiler'); |
|
| 3327 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3328 | - } |
|
| 3323 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3324 | + if (is_array($lieu)) { |
|
| 3325 | + include_spip('public/compiler'); |
|
| 3326 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3327 | + } |
|
| 3329 | 3328 | |
| 3330 | - return $debusquer($message, $lieu); |
|
| 3329 | + return $debusquer($message, $lieu); |
|
| 3331 | 3330 | } |
| 3332 | 3331 | |
| 3333 | 3332 | /** |
@@ -3364,108 +3363,108 @@ discard block |
||
| 3364 | 3363 | * - ou tableau d'information sur le squelette. |
| 3365 | 3364 | */ |
| 3366 | 3365 | function recuperer_fond($fond, $contexte = [], $options = [], string $connect = '') { |
| 3367 | - if (!function_exists('evaluer_fond')) { |
|
| 3368 | - include_spip('public/assembler'); |
|
| 3369 | - } |
|
| 3370 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3371 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3372 | - if (!is_array($options)) { |
|
| 3373 | - $options = ['trim' => $options]; |
|
| 3374 | - } |
|
| 3375 | - if (!isset($options['trim'])) { |
|
| 3376 | - $options['trim'] = true; |
|
| 3377 | - } |
|
| 3378 | - |
|
| 3379 | - if (isset($contexte['connect'])) { |
|
| 3380 | - $connect = $contexte['connect']; |
|
| 3381 | - unset($contexte['connect']); |
|
| 3382 | - } |
|
| 3383 | - |
|
| 3384 | - $texte = ''; |
|
| 3385 | - $pages = []; |
|
| 3386 | - $lang_select = ''; |
|
| 3387 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3388 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3389 | - if (!isset($contexte['lang'])) { |
|
| 3390 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3391 | - } |
|
| 3392 | - |
|
| 3393 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3394 | - $lang_select = lang_select($contexte['lang']); |
|
| 3395 | - } |
|
| 3396 | - } |
|
| 3397 | - |
|
| 3398 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3399 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3400 | - } |
|
| 3401 | - |
|
| 3402 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3403 | - |
|
| 3404 | - // fix #4235 |
|
| 3405 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3406 | - |
|
| 3407 | - |
|
| 3408 | - foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3409 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3410 | - |
|
| 3411 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3412 | - if ($page === '') { |
|
| 3413 | - $c = $options['compil'] ?? ''; |
|
| 3414 | - $a = ['fichier' => $f]; |
|
| 3415 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3416 | - erreur_squelette($erreur, $c); |
|
| 3417 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3418 | - $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3419 | - } |
|
| 3420 | - |
|
| 3421 | - $page = pipeline('recuperer_fond', [ |
|
| 3422 | - 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3423 | - 'data' => $page |
|
| 3424 | - ]); |
|
| 3425 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3426 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3427 | - include_spip('inc/filtres'); |
|
| 3428 | - } |
|
| 3429 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3430 | - array_merge( |
|
| 3431 | - $contexte, |
|
| 3432 | - ['fond' => $f], |
|
| 3433 | - ($connect ? ['connect' => $connect] : []) |
|
| 3434 | - ), |
|
| 3435 | - '', |
|
| 3436 | - $page['texte'], |
|
| 3437 | - $options['ajax'] |
|
| 3438 | - ); |
|
| 3439 | - } |
|
| 3440 | - |
|
| 3441 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3442 | - $pages[] = $page; |
|
| 3443 | - } else { |
|
| 3444 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3445 | - } |
|
| 3446 | - |
|
| 3447 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3448 | - if (isset($page['invalideurs']['session'])) { |
|
| 3449 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3450 | - } |
|
| 3451 | - } |
|
| 3452 | - |
|
| 3453 | - // restaurer le sessionnement du contexte appelant, |
|
| 3454 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3455 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3456 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3457 | - } |
|
| 3458 | - |
|
| 3459 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3460 | - |
|
| 3461 | - if ($lang_select) { |
|
| 3462 | - lang_select(); |
|
| 3463 | - } |
|
| 3464 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3465 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3466 | - } else { |
|
| 3467 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3468 | - } |
|
| 3366 | + if (!function_exists('evaluer_fond')) { |
|
| 3367 | + include_spip('public/assembler'); |
|
| 3368 | + } |
|
| 3369 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3370 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3371 | + if (!is_array($options)) { |
|
| 3372 | + $options = ['trim' => $options]; |
|
| 3373 | + } |
|
| 3374 | + if (!isset($options['trim'])) { |
|
| 3375 | + $options['trim'] = true; |
|
| 3376 | + } |
|
| 3377 | + |
|
| 3378 | + if (isset($contexte['connect'])) { |
|
| 3379 | + $connect = $contexte['connect']; |
|
| 3380 | + unset($contexte['connect']); |
|
| 3381 | + } |
|
| 3382 | + |
|
| 3383 | + $texte = ''; |
|
| 3384 | + $pages = []; |
|
| 3385 | + $lang_select = ''; |
|
| 3386 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3387 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3388 | + if (!isset($contexte['lang'])) { |
|
| 3389 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3390 | + } |
|
| 3391 | + |
|
| 3392 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3393 | + $lang_select = lang_select($contexte['lang']); |
|
| 3394 | + } |
|
| 3395 | + } |
|
| 3396 | + |
|
| 3397 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3398 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3399 | + } |
|
| 3400 | + |
|
| 3401 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3402 | + |
|
| 3403 | + // fix #4235 |
|
| 3404 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3405 | + |
|
| 3406 | + |
|
| 3407 | + foreach (is_array($fond) ? $fond : [$fond] as $f) { |
|
| 3408 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3409 | + |
|
| 3410 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3411 | + if ($page === '') { |
|
| 3412 | + $c = $options['compil'] ?? ''; |
|
| 3413 | + $a = ['fichier' => $f]; |
|
| 3414 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3415 | + erreur_squelette($erreur, $c); |
|
| 3416 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3417 | + $page = ['texte' => '', 'erreur' => $erreur]; |
|
| 3418 | + } |
|
| 3419 | + |
|
| 3420 | + $page = pipeline('recuperer_fond', [ |
|
| 3421 | + 'args' => ['fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect], |
|
| 3422 | + 'data' => $page |
|
| 3423 | + ]); |
|
| 3424 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3425 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3426 | + include_spip('inc/filtres'); |
|
| 3427 | + } |
|
| 3428 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3429 | + array_merge( |
|
| 3430 | + $contexte, |
|
| 3431 | + ['fond' => $f], |
|
| 3432 | + ($connect ? ['connect' => $connect] : []) |
|
| 3433 | + ), |
|
| 3434 | + '', |
|
| 3435 | + $page['texte'], |
|
| 3436 | + $options['ajax'] |
|
| 3437 | + ); |
|
| 3438 | + } |
|
| 3439 | + |
|
| 3440 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3441 | + $pages[] = $page; |
|
| 3442 | + } else { |
|
| 3443 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3444 | + } |
|
| 3445 | + |
|
| 3446 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3447 | + if (isset($page['invalideurs']['session'])) { |
|
| 3448 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3449 | + } |
|
| 3450 | + } |
|
| 3451 | + |
|
| 3452 | + // restaurer le sessionnement du contexte appelant, |
|
| 3453 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3454 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3455 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3456 | + } |
|
| 3457 | + |
|
| 3458 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3459 | + |
|
| 3460 | + if ($lang_select) { |
|
| 3461 | + lang_select(); |
|
| 3462 | + } |
|
| 3463 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3464 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3465 | + } else { |
|
| 3466 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3467 | + } |
|
| 3469 | 3468 | } |
| 3470 | 3469 | |
| 3471 | 3470 | /** |
@@ -3475,7 +3474,7 @@ discard block |
||
| 3475 | 3474 | * @return string |
| 3476 | 3475 | */ |
| 3477 | 3476 | function trouve_modele($nom) { |
| 3478 | - return trouver_fond($nom, 'modeles/'); |
|
| 3477 | + return trouver_fond($nom, 'modeles/'); |
|
| 3479 | 3478 | } |
| 3480 | 3479 | |
| 3481 | 3480 | /** |
@@ -3491,21 +3490,21 @@ discard block |
||
| 3491 | 3490 | * @return array|string |
| 3492 | 3491 | */ |
| 3493 | 3492 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3494 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3495 | - if (!$pathinfo) { |
|
| 3496 | - return $f; |
|
| 3497 | - } |
|
| 3498 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3499 | - $p = pathinfo($f); |
|
| 3500 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3501 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3502 | - } |
|
| 3503 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3504 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3505 | - } |
|
| 3506 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3493 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3494 | + if (!$pathinfo) { |
|
| 3495 | + return $f; |
|
| 3496 | + } |
|
| 3497 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3498 | + $p = pathinfo($f); |
|
| 3499 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3500 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3501 | + } |
|
| 3502 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3503 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3504 | + } |
|
| 3505 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3507 | 3506 | |
| 3508 | - return $p; |
|
| 3507 | + return $p; |
|
| 3509 | 3508 | } |
| 3510 | 3509 | |
| 3511 | 3510 | /** |
@@ -3525,21 +3524,21 @@ discard block |
||
| 3525 | 3524 | * Nom de l'exec, sinon chaîne vide. |
| 3526 | 3525 | **/ |
| 3527 | 3526 | function tester_url_ecrire($nom) { |
| 3528 | - static $exec = []; |
|
| 3529 | - if (isset($exec[$nom])) { |
|
| 3530 | - return $exec[$nom]; |
|
| 3531 | - } |
|
| 3532 | - // tester si c'est une page en squelette |
|
| 3533 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3534 | - return $exec[$nom] = 'fond'; |
|
| 3535 | - } // echafaudage d'un fond ! |
|
| 3536 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3537 | - return $exec[$nom] = 'fond'; |
|
| 3538 | - } |
|
| 3539 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3540 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3541 | - // et des define intrusifs potentiels |
|
| 3542 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3527 | + static $exec = []; |
|
| 3528 | + if (isset($exec[$nom])) { |
|
| 3529 | + return $exec[$nom]; |
|
| 3530 | + } |
|
| 3531 | + // tester si c'est une page en squelette |
|
| 3532 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3533 | + return $exec[$nom] = 'fond'; |
|
| 3534 | + } // echafaudage d'un fond ! |
|
| 3535 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3536 | + return $exec[$nom] = 'fond'; |
|
| 3537 | + } |
|
| 3538 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3539 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3540 | + // et des define intrusifs potentiels |
|
| 3541 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3543 | 3542 | } |
| 3544 | 3543 | |
| 3545 | 3544 | /** |
@@ -3549,8 +3548,8 @@ discard block |
||
| 3549 | 3548 | * true si la constante _VERSION_HTML n'est pas définie ou égale à html5 |
| 3550 | 3549 | **/ |
| 3551 | 3550 | function html5_permis() { |
| 3552 | - return (!defined('_VERSION_HTML') |
|
| 3553 | - or _VERSION_HTML !== 'html4'); |
|
| 3551 | + return (!defined('_VERSION_HTML') |
|
| 3552 | + or _VERSION_HTML !== 'html4'); |
|
| 3554 | 3553 | } |
| 3555 | 3554 | |
| 3556 | 3555 | /** |
@@ -3560,30 +3559,30 @@ discard block |
||
| 3560 | 3559 | * @return array |
| 3561 | 3560 | */ |
| 3562 | 3561 | function formats_image_acceptables($gd = null, $svg_allowed = true) { |
| 3563 | - $formats = null; |
|
| 3564 | - if (!is_null($gd)) { |
|
| 3565 | - $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3566 | - if (isset($GLOBALS['meta'][$config])) { |
|
| 3567 | - $formats = $GLOBALS['meta'][$config]; |
|
| 3568 | - $formats = explode(',', $formats); |
|
| 3569 | - $formats = array_filter($formats); |
|
| 3570 | - $formats = array_map('trim', $formats); |
|
| 3571 | - } |
|
| 3572 | - } |
|
| 3573 | - if (is_null($formats)) { |
|
| 3574 | - include_spip('inc/filtres_images_lib_mini'); |
|
| 3575 | - $formats = _image_extensions_acceptees_en_entree(); |
|
| 3576 | - } |
|
| 3577 | - |
|
| 3578 | - if ($svg_allowed) { |
|
| 3579 | - if (!in_array('svg', $formats)) { |
|
| 3580 | - $formats[] = 'svg'; |
|
| 3581 | - } |
|
| 3582 | - } |
|
| 3583 | - else { |
|
| 3584 | - $formats = array_diff($formats, ['svg']); |
|
| 3585 | - } |
|
| 3586 | - return $formats; |
|
| 3562 | + $formats = null; |
|
| 3563 | + if (!is_null($gd)) { |
|
| 3564 | + $config = ($gd ? 'gd_formats' : 'formats_graphiques'); |
|
| 3565 | + if (isset($GLOBALS['meta'][$config])) { |
|
| 3566 | + $formats = $GLOBALS['meta'][$config]; |
|
| 3567 | + $formats = explode(',', $formats); |
|
| 3568 | + $formats = array_filter($formats); |
|
| 3569 | + $formats = array_map('trim', $formats); |
|
| 3570 | + } |
|
| 3571 | + } |
|
| 3572 | + if (is_null($formats)) { |
|
| 3573 | + include_spip('inc/filtres_images_lib_mini'); |
|
| 3574 | + $formats = _image_extensions_acceptees_en_entree(); |
|
| 3575 | + } |
|
| 3576 | + |
|
| 3577 | + if ($svg_allowed) { |
|
| 3578 | + if (!in_array('svg', $formats)) { |
|
| 3579 | + $formats[] = 'svg'; |
|
| 3580 | + } |
|
| 3581 | + } |
|
| 3582 | + else { |
|
| 3583 | + $formats = array_diff($formats, ['svg']); |
|
| 3584 | + } |
|
| 3585 | + return $formats; |
|
| 3587 | 3586 | } |
| 3588 | 3587 | |
| 3589 | 3588 | /** |
@@ -3592,20 +3591,20 @@ discard block |
||
| 3592 | 3591 | * @return array|bool |
| 3593 | 3592 | */ |
| 3594 | 3593 | function spip_getimagesize($fichier) { |
| 3595 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3596 | - include_spip('inc/svg'); |
|
| 3597 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3598 | - [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3599 | - $imagesize = [ |
|
| 3600 | - $width, |
|
| 3601 | - $height, |
|
| 3602 | - IMAGETYPE_SVG, |
|
| 3603 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3604 | - 'mime' => 'image/svg+xml' |
|
| 3605 | - ]; |
|
| 3606 | - } |
|
| 3607 | - } |
|
| 3608 | - return $imagesize; |
|
| 3594 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3595 | + include_spip('inc/svg'); |
|
| 3596 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3597 | + [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 3598 | + $imagesize = [ |
|
| 3599 | + $width, |
|
| 3600 | + $height, |
|
| 3601 | + IMAGETYPE_SVG, |
|
| 3602 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3603 | + 'mime' => 'image/svg+xml' |
|
| 3604 | + ]; |
|
| 3605 | + } |
|
| 3606 | + } |
|
| 3607 | + return $imagesize; |
|
| 3609 | 3608 | } |
| 3610 | 3609 | |
| 3611 | 3610 | /** |
@@ -3619,19 +3618,19 @@ discard block |
||
| 3619 | 3618 | * @param string $statut |
| 3620 | 3619 | */ |
| 3621 | 3620 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3622 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3623 | - if ( |
|
| 3624 | - !$alertes |
|
| 3625 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3626 | - ) { |
|
| 3627 | - $alertes = []; |
|
| 3628 | - } |
|
| 3621 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3622 | + if ( |
|
| 3623 | + !$alertes |
|
| 3624 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3625 | + ) { |
|
| 3626 | + $alertes = []; |
|
| 3627 | + } |
|
| 3629 | 3628 | |
| 3630 | - if (!isset($alertes[$statut])) { |
|
| 3631 | - $alertes[$statut] = []; |
|
| 3632 | - } |
|
| 3633 | - $alertes[$statut][$nom] = $message; |
|
| 3634 | - ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3629 | + if (!isset($alertes[$statut])) { |
|
| 3630 | + $alertes[$statut] = []; |
|
| 3631 | + } |
|
| 3632 | + $alertes[$statut][$nom] = $message; |
|
| 3633 | + ecrire_meta('message_alertes_auteurs', serialize($alertes)); |
|
| 3635 | 3634 | } |
| 3636 | 3635 | |
| 3637 | 3636 | /** |
@@ -3645,10 +3644,10 @@ discard block |
||
| 3645 | 3644 | * @return string|string[] |
| 3646 | 3645 | */ |
| 3647 | 3646 | function spip_sanitize_classname($classes) { |
| 3648 | - if (is_array($classes)) { |
|
| 3649 | - return array_map('spip_sanitize_classname', $classes); |
|
| 3650 | - } |
|
| 3651 | - return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3647 | + if (is_array($classes)) { |
|
| 3648 | + return array_map('spip_sanitize_classname', $classes); |
|
| 3649 | + } |
|
| 3650 | + return preg_replace('/[^ 0-9a-z_\-+@]/i', '', $classes); |
|
| 3652 | 3651 | } |
| 3653 | 3652 | |
| 3654 | 3653 | |
@@ -3673,32 +3672,32 @@ discard block |
||
| 3673 | 3672 | * Avec operateur : bool. |
| 3674 | 3673 | **/ |
| 3675 | 3674 | function spip_version_compare($v1, $v2, $op = null) { |
| 3676 | - $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3677 | - $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3678 | - $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3679 | - $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3680 | - |
|
| 3681 | - $v1 = explode('.', $v1); |
|
| 3682 | - $v2 = explode('.', $v2); |
|
| 3683 | - // $v1 est toujours une version, donc sans etoile |
|
| 3684 | - while (count($v1) < count($v2)) { |
|
| 3685 | - $v1[] = '0'; |
|
| 3686 | - } |
|
| 3687 | - |
|
| 3688 | - // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3689 | - $etoile = false; |
|
| 3690 | - foreach ($v1 as $k => $v) { |
|
| 3691 | - if (!isset($v2[$k])) { |
|
| 3692 | - $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3693 | - } else { |
|
| 3694 | - if ($v2[$k] == '*') { |
|
| 3695 | - $etoile = true; |
|
| 3696 | - $v2[$k] = $v; |
|
| 3697 | - } |
|
| 3698 | - } |
|
| 3699 | - } |
|
| 3700 | - $v1 = implode('.', $v1); |
|
| 3701 | - $v2 = implode('.', $v2); |
|
| 3702 | - |
|
| 3703 | - return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3675 | + $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3676 | + $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3677 | + $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3678 | + $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3679 | + |
|
| 3680 | + $v1 = explode('.', $v1); |
|
| 3681 | + $v2 = explode('.', $v2); |
|
| 3682 | + // $v1 est toujours une version, donc sans etoile |
|
| 3683 | + while (count($v1) < count($v2)) { |
|
| 3684 | + $v1[] = '0'; |
|
| 3685 | + } |
|
| 3686 | + |
|
| 3687 | + // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3688 | + $etoile = false; |
|
| 3689 | + foreach ($v1 as $k => $v) { |
|
| 3690 | + if (!isset($v2[$k])) { |
|
| 3691 | + $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3692 | + } else { |
|
| 3693 | + if ($v2[$k] == '*') { |
|
| 3694 | + $etoile = true; |
|
| 3695 | + $v2[$k] = $v; |
|
| 3696 | + } |
|
| 3697 | + } |
|
| 3698 | + } |
|
| 3699 | + $v1 = implode('.', $v1); |
|
| 3700 | + $v2 = implode('.', $v2); |
|
| 3701 | + |
|
| 3702 | + return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3704 | 3703 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | if (strlen($dossier) and substr($dossier, -1) != '/') { |
| 54 | 54 | $dossier .= '/'; |
| 55 | 55 | } |
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 56 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 57 | 57 | |
| 58 | 58 | if (function_exists($f)) { |
| 59 | 59 | return $f; |
| 60 | 60 | } |
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 61 | + if (function_exists($g = $f.'_dist')) { |
|
| 62 | 62 | return $g; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | // passer en minuscules (cf les balises de formulaires) |
| 80 | 80 | // et inclure le fichier |
| 81 | 81 | if ( |
| 82 | - !$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | + !$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 83 | 83 | // si le fichier truc/machin/nom.php n'existe pas, |
| 84 | 84 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 85 | 85 | and strlen(dirname($dossier)) and dirname($dossier) != '.' |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Echec : message d'erreur |
| 101 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 102 | 102 | ($inc ? '' : " (fichier $d absent de $dossier)")); |
| 103 | 103 | |
| 104 | 104 | include_spip('inc/minipres'); |
| 105 | 105 | echo minipres( |
| 106 | 106 | _T('forum_titre_erreur'), |
| 107 | - _T('fichier_introuvable', ['fichier' => '<b>' . spip_htmlentities($d) . '</b>']), |
|
| 108 | - ['all_inline' => true,'status' => 404] |
|
| 107 | + _T('fichier_introuvable', ['fichier' => '<b>'.spip_htmlentities($d).'</b>']), |
|
| 108 | + ['all_inline' => true, 'status' => 404] |
|
| 109 | 109 | ); |
| 110 | 110 | exit; |
| 111 | 111 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * - string : chemin du fichier trouvé |
| 152 | 152 | **/ |
| 153 | 153 | function include_spip($f, $include = true) { |
| 154 | - return find_in_path($f . '.php', '', $include); |
|
| 154 | + return find_in_path($f.'.php', '', $include); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * - string : chemin du fichier trouvé |
| 172 | 172 | **/ |
| 173 | 173 | function require_spip($f) { |
| 174 | - return find_in_path($f . '.php', '', 'required'); |
|
| 174 | + return find_in_path($f.'.php', '', 'required'); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | // donc il faut l'inclure "en globals" |
| 189 | 189 | if ($f = find_in_path('mes_fonctions.php')) { |
| 190 | 190 | global $dossier_squelettes; |
| 191 | - include_once(_ROOT_CWD . $f); |
|
| 191 | + include_once(_ROOT_CWD.$f); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // appliquer notre fonction si elle existe |
| 296 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 296 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 297 | 297 | if (function_exists($fonc)) { |
| 298 | 298 | $val = $fonc($val); |
| 299 | 299 | } // plantage ? |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | function spip_log($message = null, $name = null) { |
| 359 | 359 | static $pre = []; |
| 360 | 360 | static $log; |
| 361 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 361 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 362 | 362 | if (!isset($regs[1]) or !$logname = $regs[1]) { |
| 363 | 363 | $logname = null; |
| 364 | 364 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | if (!is_string($message)) { |
| 387 | 387 | $message = print_r($message, true); |
| 388 | 388 | } |
| 389 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 389 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | $a = './'; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 590 | + $regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; |
|
| 591 | 591 | $ajouts = array_flip(explode('|', $c)); |
| 592 | 592 | $u = is_array($v) ? $v : rawurlencode((string) $v); |
| 593 | 593 | $testv = (is_array($v) ? count($v) : strlen((string) $v)); |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 615 | 615 | // pour un tableau ce sera fait dans la prochaine boucle |
| 616 | 616 | elseif (substr($r[1], -2) != '[]') { |
| 617 | - $url[$n] = $r[1] . '=' . $u; |
|
| 617 | + $url[$n] = $r[1].'='.$u; |
|
| 618 | 618 | unset($ajouts[$r[1]]); |
| 619 | 619 | } |
| 620 | 620 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -635,11 +635,11 @@ discard block |
||
| 635 | 635 | } elseif ($testv) { |
| 636 | 636 | foreach ($ajouts as $k => $n) { |
| 637 | 637 | if (!is_array($v)) { |
| 638 | - $url[] = $k . '=' . $u; |
|
| 638 | + $url[] = $k.'='.$u; |
|
| 639 | 639 | } else { |
| 640 | - $id = (substr($k, -2) == '[]') ? $k : ($k . '[]'); |
|
| 640 | + $id = (substr($k, -2) == '[]') ? $k : ($k.'[]'); |
|
| 641 | 641 | foreach ($v as $w) { |
| 642 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 642 | + $url[] = $id.'='.(is_array($w) ? 'Array' : rawurlencode($w)); |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | } |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | // recomposer l'adresse |
| 652 | 652 | if ($url) { |
| 653 | - $a .= '?' . join($sep, $url); |
|
| 653 | + $a .= '?'.join($sep, $url); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - return $a . $ancre; |
|
| 656 | + return $a.$ancre; |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | /** |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | translitteration($ancre) |
| 686 | 686 | ); |
| 687 | 687 | } |
| 688 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 688 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | * @return bool |
| 802 | 802 | */ |
| 803 | 803 | function test_plugin_actif($plugin) { |
| 804 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 804 | + return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | $value = interdire_scripts($value, -1); |
| 934 | 934 | } |
| 935 | 935 | if (!empty($options['class'])) { |
| 936 | - $value = "<span class='" . $options['class'] . "'>$value</span>"; |
|
| 936 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 937 | 937 | } |
| 938 | 938 | $text = str_replace("@$name@", $value, $text); |
| 939 | 939 | unset($args[$name]); |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | // Si des variables n'ont pas ete inserees, le signaler |
| 943 | 943 | // (chaines de langues pas a jour) |
| 944 | 944 | if ($args) { |
| 945 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 945 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 946 | 946 | } |
| 947 | 947 | } |
| 948 | 948 | |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | function joli_repertoire($rep) { |
| 967 | 967 | $a = substr($rep, 0, 1); |
| 968 | 968 | if ($a <> '.' and $a <> '/') { |
| 969 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 969 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 970 | 970 | } |
| 971 | 971 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 972 | 972 | |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | $p -= ($x * 1000); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - return $s . sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1023 | + return $s.sprintf($s ? '%07.3f ms' : '%.3f ms', $p); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | if ($taches and count($taches) and !spip_connect()) { |
| 1088 | 1088 | return false; |
| 1089 | 1089 | } |
| 1090 | - spip_log('cron !', 'jq' . _LOG_DEBUG); |
|
| 1090 | + spip_log('cron !', 'jq'._LOG_DEBUG); |
|
| 1091 | 1091 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 1092 | 1092 | return $genie($taches); |
| 1093 | 1093 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | |
| 1192 | 1192 | if ($queue_next_job_time == -1) { |
| 1193 | 1193 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 1194 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . 'job_queue_next.txt'); |
|
| 1194 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP.'job_queue_next.txt'); |
|
| 1195 | 1195 | } |
| 1196 | 1196 | // utiliser un cache memoire si dispo |
| 1197 | 1197 | if (function_exists('cache_get') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
@@ -1260,8 +1260,8 @@ discard block |
||
| 1260 | 1260 | $src = ''; |
| 1261 | 1261 | } |
| 1262 | 1262 | if ($script) { |
| 1263 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1264 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1263 | + $script = ("/*<![CDATA[*/\n". |
|
| 1264 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 1265 | 1265 | '/*]]>*/'); |
| 1266 | 1266 | } |
| 1267 | 1267 | if ($noscript) { |
@@ -1347,13 +1347,13 @@ discard block |
||
| 1347 | 1347 | if ($path_base == null) { |
| 1348 | 1348 | // Chemin standard depuis l'espace public |
| 1349 | 1349 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 1350 | - _DIR_RACINE . ':' . |
|
| 1351 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1352 | - _DIR_RACINE . 'prive/:' . |
|
| 1350 | + _DIR_RACINE.':'. |
|
| 1351 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 1352 | + _DIR_RACINE.'prive/:'. |
|
| 1353 | 1353 | _DIR_RESTREINT; |
| 1354 | 1354 | // Ajouter squelettes/ |
| 1355 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1356 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1355 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 1356 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 1357 | 1357 | } |
| 1358 | 1358 | foreach (explode(':', $path) as $dir) { |
| 1359 | 1359 | if (strlen($dir) and substr($dir, -1) != '/') { |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | // Et le(s) dossier(s) des squelettes nommes |
| 1366 | 1366 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1367 | 1367 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1368 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1368 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | } |
| 1371 | 1371 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | |
| 1377 | 1377 | if (is_array($dir_path) or strlen($dir_path)) { |
| 1378 | 1378 | $tete = ''; |
| 1379 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1379 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') { |
|
| 1380 | 1380 | $tete = array_shift($path_base); |
| 1381 | 1381 | } |
| 1382 | 1382 | $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | // Et le(s) dossier(s) des squelettes nommes |
| 1398 | 1398 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1399 | 1399 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1400 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1400 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/'); |
|
| 1401 | 1401 | } |
| 1402 | 1402 | } |
| 1403 | 1403 | |
@@ -1468,14 +1468,14 @@ discard block |
||
| 1468 | 1468 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 1469 | 1469 | if ( |
| 1470 | 1470 | preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 1471 | - and $file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 1471 | + and $file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg' |
|
| 1472 | 1472 | and $f = find_in_theme("$file_svg_generique") |
| 1473 | 1473 | ) { |
| 1474 | - if ($fsize = substr($f, 0, -6) . $m[1] . '.svg' and file_exists($fsize)) { |
|
| 1474 | + if ($fsize = substr($f, 0, -6).$m[1].'.svg' and file_exists($fsize)) { |
|
| 1475 | 1475 | return $themefiles["$subdir$file"] = $fsize; |
| 1476 | 1476 | } |
| 1477 | 1477 | else { |
| 1478 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 1478 | + return $themefiles["$subdir$file"] = "$f?".$m[1].'px'; |
|
| 1479 | 1479 | } |
| 1480 | 1480 | } |
| 1481 | 1481 | |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | return $themefiles["$subdir$file"] = $f; |
| 1486 | 1486 | } |
| 1487 | 1487 | } |
| 1488 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1488 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 1489 | 1489 | |
| 1490 | 1490 | return $themefiles["$subdir$file"] = ''; |
| 1491 | 1491 | } |
@@ -1593,8 +1593,8 @@ discard block |
||
| 1593 | 1593 | return false; |
| 1594 | 1594 | } |
| 1595 | 1595 | if ($include and !isset($inc[$dirname][$file])) { |
| 1596 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1596 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1597 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | 1600 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
@@ -1607,14 +1607,14 @@ discard block |
||
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | foreach (creer_chemin() as $dir) { |
| 1610 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1611 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1610 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 1611 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 1612 | 1612 | } |
| 1613 | 1613 | if ($dirs[$a]) { |
| 1614 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1614 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 1615 | 1615 | if ($include and !isset($inc[$dirname][$file])) { |
| 1616 | - include_once _ROOT_CWD . $a; |
|
| 1617 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1616 | + include_once _ROOT_CWD.$a; |
|
| 1617 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1618 | 1618 | } |
| 1619 | 1619 | if (!defined('_SAUVER_CHEMIN')) { |
| 1620 | 1620 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | define('_SAUVER_CHEMIN', true); |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1627 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 1628 | 1628 | } |
| 1629 | 1629 | } |
| 1630 | 1630 | } |
@@ -1650,7 +1650,7 @@ discard block |
||
| 1650 | 1650 | define('_SAUVER_CHEMIN', true); |
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1653 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | function clear_path_cache() { |
@@ -1720,12 +1720,12 @@ discard block |
||
| 1720 | 1720 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 1721 | 1721 | // on a pas encore inclus flock.php |
| 1722 | 1722 | if (!function_exists('preg_files')) { |
| 1723 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1723 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1724 | 1724 | } |
| 1725 | 1725 | |
| 1726 | 1726 | // Parcourir le chemin |
| 1727 | 1727 | foreach (creer_chemin() as $d) { |
| 1728 | - $f = $d . $dir; |
|
| 1728 | + $f = $d.$dir; |
|
| 1729 | 1729 | if (@is_dir($f)) { |
| 1730 | 1730 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
| 1731 | 1731 | foreach ($liste as $chemin) { |
@@ -1774,9 +1774,9 @@ discard block |
||
| 1774 | 1774 | function charger_fonction_url(string $quoi, string $type = '') { |
| 1775 | 1775 | if ($type === 'defaut') { |
| 1776 | 1776 | $objet = objet_type($quoi); |
| 1777 | - if ($f = charger_fonction('generer_' . $objet . '_url', 'urls', true) |
|
| 1777 | + if ($f = charger_fonction('generer_'.$objet.'_url', 'urls', true) |
|
| 1778 | 1778 | // deprecated |
| 1779 | - or $f = charger_fonction('generer_url_' . $objet, 'urls', true) |
|
| 1779 | + or $f = charger_fonction('generer_url_'.$objet, 'urls', true) |
|
| 1780 | 1780 | ) { |
| 1781 | 1781 | return $f; |
| 1782 | 1782 | } |
@@ -1895,7 +1895,7 @@ discard block |
||
| 1895 | 1895 | * @deprecated 4.1 |
| 1896 | 1896 | * @see generer_objet_url |
| 1897 | 1897 | */ |
| 1898 | -function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null){ |
|
| 1898 | +function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
|
| 1899 | 1899 | return generer_objet_url($id, $entite, $args, $ancre, $public, $type); |
| 1900 | 1900 | } |
| 1901 | 1901 | |
@@ -1926,7 +1926,7 @@ discard block |
||
| 1926 | 1926 | * @deprecated 4.1 |
| 1927 | 1927 | * @see generer_objet_url_ecrire_edit |
| 1928 | 1928 | */ |
| 1929 | -function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = ''){ |
|
| 1929 | +function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
|
| 1930 | 1930 | return generer_objet_url_ecrire_edit($id, $entite, $args, $ancre); |
| 1931 | 1931 | } |
| 1932 | 1932 | |
@@ -1935,8 +1935,8 @@ discard block |
||
| 1935 | 1935 | include_spip('base/connect_sql'); |
| 1936 | 1936 | $id_type = id_table_objet($entite, $public); |
| 1937 | 1937 | |
| 1938 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1939 | - . '?' . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1938 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1939 | + . '?'._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1940 | 1940 | . (!$args ? '' : "&$args") |
| 1941 | 1941 | . (!$ancre ? '' : "#$ancre"); |
| 1942 | 1942 | } |
@@ -1990,7 +1990,7 @@ discard block |
||
| 1990 | 1990 | * @deprecated 4.1 |
| 1991 | 1991 | * @see generer_objet_url_absolue |
| 1992 | 1992 | */ |
| 1993 | -function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null){ |
|
| 1993 | +function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { |
|
| 1994 | 1994 | return generer_objet_url_absolue($id, $entite, $args, $args, $ancre, $connect); |
| 1995 | 1995 | } |
| 1996 | 1996 | |
@@ -2107,7 +2107,7 @@ discard block |
||
| 2107 | 2107 | !empty($_SERVER['QUERY_STRING']) |
| 2108 | 2108 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2109 | 2109 | ) { |
| 2110 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2110 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2111 | 2111 | } |
| 2112 | 2112 | } |
| 2113 | 2113 | } |
@@ -2142,9 +2142,9 @@ discard block |
||
| 2142 | 2142 | array_shift($myself); |
| 2143 | 2143 | $myself = implode('/', $myself); |
| 2144 | 2144 | } |
| 2145 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2145 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 2146 | 2146 | |
| 2147 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2147 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 2148 | 2148 | |
| 2149 | 2149 | return $url; |
| 2150 | 2150 | } |
@@ -2182,16 +2182,16 @@ discard block |
||
| 2182 | 2182 | **/ |
| 2183 | 2183 | function generer_url_ecrire($script = '', $args = '', $no_entities = false, $rel = false) { |
| 2184 | 2184 | if (!$rel) { |
| 2185 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2185 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 2186 | 2186 | } else { |
| 2187 | 2187 | if (!is_string($rel)) { |
| 2188 | - $rel = _DIR_RESTREINT ?: './' . _SPIP_ECRIRE_SCRIPT; |
|
| 2188 | + $rel = _DIR_RESTREINT ?: './'._SPIP_ECRIRE_SCRIPT; |
|
| 2189 | 2189 | } |
| 2190 | 2190 | } |
| 2191 | 2191 | |
| 2192 | 2192 | [$script, $ancre] = array_pad(explode('#', $script), 2, null); |
| 2193 | 2193 | if ($script and ($script <> 'accueil' or $rel)) { |
| 2194 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2194 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 2195 | 2195 | } elseif ($args) { |
| 2196 | 2196 | $args = "?$args"; |
| 2197 | 2197 | } |
@@ -2199,7 +2199,7 @@ discard block |
||
| 2199 | 2199 | $args .= "#$ancre"; |
| 2200 | 2200 | } |
| 2201 | 2201 | |
| 2202 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2202 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2203 | 2203 | } |
| 2204 | 2204 | |
| 2205 | 2205 | // |
@@ -2281,10 +2281,10 @@ discard block |
||
| 2281 | 2281 | $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
| 2282 | 2282 | } |
| 2283 | 2283 | if ($args) { |
| 2284 | - $action .= (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2284 | + $action .= (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 2285 | 2285 | } |
| 2286 | 2286 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 2287 | - $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2287 | + $url = ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(',^/[.]/,', '/', "/$action")); |
|
| 2288 | 2288 | } |
| 2289 | 2289 | |
| 2290 | 2290 | if (!$no_entities) { |
@@ -2296,7 +2296,7 @@ discard block |
||
| 2296 | 2296 | |
| 2297 | 2297 | function generer_url_prive($script, $args = '', $no_entities = false) { |
| 2298 | 2298 | |
| 2299 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2299 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 2300 | 2300 | } |
| 2301 | 2301 | |
| 2302 | 2302 | // Pour les formulaires en methode POST, |
@@ -2331,8 +2331,7 @@ discard block |
||
| 2331 | 2331 | . "><div>\n" |
| 2332 | 2332 | . "<input type='hidden' name='exec' value='$script1' />" |
| 2333 | 2333 | . $corps |
| 2334 | - . (!$submit ? '' : |
|
| 2335 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . '" /></div>')) |
|
| 2334 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit).'" /></div>')) |
|
| 2336 | 2335 | . "</div></form>\n"; |
| 2337 | 2336 | } |
| 2338 | 2337 | |
@@ -2357,14 +2356,14 @@ discard block |
||
| 2357 | 2356 | ? generer_url_ecrire(_request('exec')) |
| 2358 | 2357 | : generer_url_public(); |
| 2359 | 2358 | |
| 2360 | - return "\n<form action='" . |
|
| 2361 | - $h . |
|
| 2362 | - "'" . |
|
| 2363 | - $atts . |
|
| 2364 | - ">\n" . |
|
| 2365 | - '<div>' . |
|
| 2366 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2367 | - $corps . |
|
| 2359 | + return "\n<form action='". |
|
| 2360 | + $h. |
|
| 2361 | + "'". |
|
| 2362 | + $atts. |
|
| 2363 | + ">\n". |
|
| 2364 | + '<div>'. |
|
| 2365 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 2366 | + $corps. |
|
| 2368 | 2367 | '</div></form>'; |
| 2369 | 2368 | } |
| 2370 | 2369 | |
@@ -2392,7 +2391,7 @@ discard block |
||
| 2392 | 2391 | : generer_url_public('', '', false, false); |
| 2393 | 2392 | $url = parametre_url($url, 'action', $script); |
| 2394 | 2393 | if ($args) { |
| 2395 | - $url .= quote_amp('&' . $args); |
|
| 2394 | + $url .= quote_amp('&'.$args); |
|
| 2396 | 2395 | } |
| 2397 | 2396 | |
| 2398 | 2397 | if ($no_entities) { |
@@ -2442,17 +2441,17 @@ discard block |
||
| 2442 | 2441 | |
| 2443 | 2442 | // le nom du repertoire plugins/ activables/desactivables |
| 2444 | 2443 | if (!defined('_DIR_PLUGINS')) { |
| 2445 | - define('_DIR_PLUGINS', _DIR_RACINE . 'plugins/'); |
|
| 2444 | + define('_DIR_PLUGINS', _DIR_RACINE.'plugins/'); |
|
| 2446 | 2445 | } |
| 2447 | 2446 | |
| 2448 | 2447 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 2449 | 2448 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 2450 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . 'plugins-dist/'); |
|
| 2449 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE.'plugins-dist/'); |
|
| 2451 | 2450 | } |
| 2452 | 2451 | |
| 2453 | 2452 | // le nom du repertoire des librairies |
| 2454 | 2453 | if (!defined('_DIR_LIB')) { |
| 2455 | - define('_DIR_LIB', _DIR_RACINE . 'lib/'); |
|
| 2454 | + define('_DIR_LIB', _DIR_RACINE.'lib/'); |
|
| 2456 | 2455 | } |
| 2457 | 2456 | |
| 2458 | 2457 | if (!defined('_DIR_IMG')) { |
@@ -2462,29 +2461,29 @@ discard block |
||
| 2462 | 2461 | define('_DIR_LOGOS', $pa); |
| 2463 | 2462 | } |
| 2464 | 2463 | if (!defined('_DIR_IMG_ICONES')) { |
| 2465 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . 'icones/'); |
|
| 2464 | + define('_DIR_IMG_ICONES', _DIR_LOGOS.'icones/'); |
|
| 2466 | 2465 | } |
| 2467 | 2466 | |
| 2468 | 2467 | if (!defined('_DIR_DUMP')) { |
| 2469 | - define('_DIR_DUMP', $ti . 'dump/'); |
|
| 2468 | + define('_DIR_DUMP', $ti.'dump/'); |
|
| 2470 | 2469 | } |
| 2471 | 2470 | if (!defined('_DIR_SESSIONS')) { |
| 2472 | - define('_DIR_SESSIONS', $ti . 'sessions/'); |
|
| 2471 | + define('_DIR_SESSIONS', $ti.'sessions/'); |
|
| 2473 | 2472 | } |
| 2474 | 2473 | if (!defined('_DIR_TRANSFERT')) { |
| 2475 | - define('_DIR_TRANSFERT', $ti . 'upload/'); |
|
| 2474 | + define('_DIR_TRANSFERT', $ti.'upload/'); |
|
| 2476 | 2475 | } |
| 2477 | 2476 | if (!defined('_DIR_CACHE')) { |
| 2478 | - define('_DIR_CACHE', $ti . 'cache/'); |
|
| 2477 | + define('_DIR_CACHE', $ti.'cache/'); |
|
| 2479 | 2478 | } |
| 2480 | 2479 | if (!defined('_DIR_CACHE_XML')) { |
| 2481 | - define('_DIR_CACHE_XML', _DIR_CACHE . 'xml/'); |
|
| 2480 | + define('_DIR_CACHE_XML', _DIR_CACHE.'xml/'); |
|
| 2482 | 2481 | } |
| 2483 | 2482 | if (!defined('_DIR_SKELS')) { |
| 2484 | - define('_DIR_SKELS', _DIR_CACHE . 'skel/'); |
|
| 2483 | + define('_DIR_SKELS', _DIR_CACHE.'skel/'); |
|
| 2485 | 2484 | } |
| 2486 | 2485 | if (!defined('_DIR_AIDE')) { |
| 2487 | - define('_DIR_AIDE', _DIR_CACHE . 'aide/'); |
|
| 2486 | + define('_DIR_AIDE', _DIR_CACHE.'aide/'); |
|
| 2488 | 2487 | } |
| 2489 | 2488 | if (!defined('_DIR_TMP')) { |
| 2490 | 2489 | define('_DIR_TMP', $ti); |
@@ -2513,27 +2512,27 @@ discard block |
||
| 2513 | 2512 | // Declaration des fichiers |
| 2514 | 2513 | |
| 2515 | 2514 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 2516 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . 'charger_plugins_chemins.php'); |
|
| 2515 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE.'charger_plugins_chemins.php'); |
|
| 2517 | 2516 | } |
| 2518 | 2517 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 2519 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . 'charger_plugins_options.php'); |
|
| 2518 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE.'charger_plugins_options.php'); |
|
| 2520 | 2519 | } |
| 2521 | 2520 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 2522 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . 'charger_plugins_fonctions.php'); |
|
| 2521 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE.'charger_plugins_fonctions.php'); |
|
| 2523 | 2522 | } |
| 2524 | 2523 | if (!defined('_CACHE_PIPELINES')) { |
| 2525 | - define('_CACHE_PIPELINES', _DIR_CACHE . 'charger_pipelines.php'); |
|
| 2524 | + define('_CACHE_PIPELINES', _DIR_CACHE.'charger_pipelines.php'); |
|
| 2526 | 2525 | } |
| 2527 | 2526 | if (!defined('_CACHE_CHEMIN')) { |
| 2528 | - define('_CACHE_CHEMIN', _DIR_CACHE . 'chemin.txt'); |
|
| 2527 | + define('_CACHE_CHEMIN', _DIR_CACHE.'chemin.txt'); |
|
| 2529 | 2528 | } |
| 2530 | 2529 | |
| 2531 | 2530 | # attention .php obligatoire pour ecrire_fichier_securise |
| 2532 | 2531 | if (!defined('_FILE_META')) { |
| 2533 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2532 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 2534 | 2533 | } |
| 2535 | 2534 | if (!defined('_DIR_LOG')) { |
| 2536 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2535 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 2537 | 2536 | } |
| 2538 | 2537 | if (!defined('_FILE_LOG')) { |
| 2539 | 2538 | define('_FILE_LOG', 'spip'); |
@@ -2550,8 +2549,8 @@ discard block |
||
| 2550 | 2549 | if (!defined('_FILE_CONNECT')) { |
| 2551 | 2550 | define( |
| 2552 | 2551 | '_FILE_CONNECT', |
| 2553 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2554 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2552 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 2553 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 2555 | 2554 | : false)) |
| 2556 | 2555 | ); |
| 2557 | 2556 | } |
@@ -2563,7 +2562,7 @@ discard block |
||
| 2563 | 2562 | if (!defined('_FILE_CHMOD')) { |
| 2564 | 2563 | define( |
| 2565 | 2564 | '_FILE_CHMOD', |
| 2566 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2565 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 2567 | 2566 | : false) |
| 2568 | 2567 | ); |
| 2569 | 2568 | } |
@@ -2576,10 +2575,10 @@ discard block |
||
| 2576 | 2575 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 2577 | 2576 | } |
| 2578 | 2577 | if (!defined('_FILE_CONNECT_TMP')) { |
| 2579 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2578 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 2580 | 2579 | } |
| 2581 | 2580 | if (!defined('_FILE_CHMOD_TMP')) { |
| 2582 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2581 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 2583 | 2582 | } |
| 2584 | 2583 | |
| 2585 | 2584 | // Definition des droits d'acces en ecriture |
@@ -2597,13 +2596,13 @@ discard block |
||
| 2597 | 2596 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 2598 | 2597 | } |
| 2599 | 2598 | if (!defined('_ROOT_PLUGINS')) { |
| 2600 | - define('_ROOT_PLUGINS', _ROOT_RACINE . 'plugins/'); |
|
| 2599 | + define('_ROOT_PLUGINS', _ROOT_RACINE.'plugins/'); |
|
| 2601 | 2600 | } |
| 2602 | 2601 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 2603 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . 'plugins-dist/'); |
|
| 2602 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE.'plugins-dist/'); |
|
| 2604 | 2603 | } |
| 2605 | 2604 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 2606 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2605 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2607 | 2606 | } |
| 2608 | 2607 | |
| 2609 | 2608 | // La taille des Log |
@@ -2640,7 +2639,7 @@ discard block |
||
| 2640 | 2639 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 2641 | 2640 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 2642 | 2641 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 2643 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2642 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 2644 | 2643 | |
| 2645 | 2644 | // charger tout de suite le path et son cache |
| 2646 | 2645 | load_path_cache(); |
@@ -2688,7 +2687,7 @@ discard block |
||
| 2688 | 2687 | !empty($_SERVER['QUERY_STRING']) |
| 2689 | 2688 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2690 | 2689 | ) { |
| 2691 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2690 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2692 | 2691 | } |
| 2693 | 2692 | } |
| 2694 | 2693 | |
@@ -2724,7 +2723,7 @@ discard block |
||
| 2724 | 2723 | ) { |
| 2725 | 2724 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 2726 | 2725 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 2727 | - $uri_ref = ($uri_ref['path'] ?? '') . '/'; |
|
| 2726 | + $uri_ref = ($uri_ref['path'] ?? '').'/'; |
|
| 2728 | 2727 | } else { |
| 2729 | 2728 | $uri_ref = ''; |
| 2730 | 2729 | } |
@@ -2818,7 +2817,7 @@ discard block |
||
| 2818 | 2817 | } |
| 2819 | 2818 | if (!defined('_CACHE_RUBRIQUES')) { |
| 2820 | 2819 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 2821 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2820 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2822 | 2821 | } |
| 2823 | 2822 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 2824 | 2823 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -2922,7 +2921,7 @@ discard block |
||
| 2922 | 2921 | $memory *= 1024; |
| 2923 | 2922 | } |
| 2924 | 2923 | if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
| 2925 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2924 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M'); |
|
| 2926 | 2925 | if (trim(ini_get('memory_limit')) != $m) { |
| 2927 | 2926 | if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
| 2928 | 2927 | define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
@@ -3073,7 +3072,7 @@ discard block |
||
| 3073 | 3072 | } |
| 3074 | 3073 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 3075 | 3074 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 3076 | - . ' ' . _VAR_MODE); |
|
| 3075 | + . ' '._VAR_MODE); |
|
| 3077 | 3076 | } |
| 3078 | 3077 | } // pas autorise ? |
| 3079 | 3078 | else { |
@@ -3088,7 +3087,7 @@ discard block |
||
| 3088 | 3087 | if (strpos($self, 'page=login') === false) { |
| 3089 | 3088 | include_spip('inc/headers'); |
| 3090 | 3089 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 3091 | - redirige_par_entete(generer_url_public('login', 'url=' . rawurlencode($redirect), true)); |
|
| 3090 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 3092 | 3091 | } |
| 3093 | 3092 | } |
| 3094 | 3093 | // sinon tant pis |
@@ -3130,10 +3129,10 @@ discard block |
||
| 3130 | 3129 | // mais on risque de perturber des plugins en initialisant trop tot |
| 3131 | 3130 | // certaines constantes |
| 3132 | 3131 | @spip_initialisation_core( |
| 3133 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3134 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3135 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3136 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3132 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 3133 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 3134 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3135 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3137 | 3136 | ); |
| 3138 | 3137 | |
| 3139 | 3138 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -3166,7 +3165,7 @@ discard block |
||
| 3166 | 3165 | } |
| 3167 | 3166 | |
| 3168 | 3167 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
| 3169 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3168 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 3170 | 3169 | $session = charger_fonction('session', 'inc'); |
| 3171 | 3170 | if ($session()) { |
| 3172 | 3171 | return $GLOBALS['visiteur_session']['statut']; |
@@ -3246,7 +3245,7 @@ discard block |
||
| 3246 | 3245 | 'definir_session', |
| 3247 | 3246 | $GLOBALS['visiteur_session'] |
| 3248 | 3247 | ? serialize($GLOBALS['visiteur_session']) |
| 3249 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3248 | + . '_'.@$_COOKIE['spip_session'] |
|
| 3250 | 3249 | : '' |
| 3251 | 3250 | ); |
| 3252 | 3251 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -3402,11 +3401,11 @@ discard block |
||
| 3402 | 3401 | $GLOBALS['_INC_PUBLIC']++; |
| 3403 | 3402 | |
| 3404 | 3403 | // fix #4235 |
| 3405 | - $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3404 | + $cache_utilise_session_appelant = ($GLOBALS['cache_utilise_session'] ?? null); |
|
| 3406 | 3405 | |
| 3407 | 3406 | |
| 3408 | 3407 | foreach (is_array($fond) ? $fond : [$fond] as $f) { |
| 3409 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3408 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3410 | 3409 | |
| 3411 | 3410 | $page = evaluer_fond($f, $contexte, $connect); |
| 3412 | 3411 | if ($page === '') { |
@@ -3491,7 +3490,7 @@ discard block |
||
| 3491 | 3490 | * @return array|string |
| 3492 | 3491 | */ |
| 3493 | 3492 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3494 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3493 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 3495 | 3494 | if (!$pathinfo) { |
| 3496 | 3495 | return $f; |
| 3497 | 3496 | } |