@@ -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/serial'); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * en droit de l'éliminer |
| 28 | 28 | */ |
| 29 | 29 | if (!defined('_AGE_CACHE_ATIME')) { |
| 30 | - define('_AGE_CACHE_ATIME', 3600); |
|
| 30 | + define('_AGE_CACHE_ATIME', 3600); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -40,31 +40,31 @@ discard block |
||
| 40 | 40 | * @return int Taille approximative en octets |
| 41 | 41 | **/ |
| 42 | 42 | function taille_du_cache() { |
| 43 | - # check dirs until we reach > 500 files |
|
| 44 | - $t = 0; |
|
| 45 | - $n = 0; |
|
| 46 | - $time = $GLOBALS['meta']['cache_mark'] ?? 0; |
|
| 47 | - for ($i = 0; $i < 256; $i++) { |
|
| 48 | - $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 49 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 50 | - while (($f = readdir($d)) !== false) { |
|
| 51 | - if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
|
| 52 | - $n++; |
|
| 53 | - if ($a['mtime'] >= $time) { |
|
| 54 | - if ($a['blocks'] > 0) { |
|
| 55 | - $t += 512 * $a['blocks']; |
|
| 56 | - } else { |
|
| 57 | - $t += $a['size']; |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - if ($n > 500) { |
|
| 64 | - return intval(256 * $t / (1 + $i)); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - return $t; |
|
| 43 | + # check dirs until we reach > 500 files |
|
| 44 | + $t = 0; |
|
| 45 | + $n = 0; |
|
| 46 | + $time = $GLOBALS['meta']['cache_mark'] ?? 0; |
|
| 47 | + for ($i = 0; $i < 256; $i++) { |
|
| 48 | + $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 49 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 50 | + while (($f = readdir($d)) !== false) { |
|
| 51 | + if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
|
| 52 | + $n++; |
|
| 53 | + if ($a['mtime'] >= $time) { |
|
| 54 | + if ($a['blocks'] > 0) { |
|
| 55 | + $t += 512 * $a['blocks']; |
|
| 56 | + } else { |
|
| 57 | + $t += $a['size']; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + if ($n > 500) { |
|
| 64 | + return intval(256 * $t / (1 + $i)); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + return $t; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -91,30 +91,30 @@ discard block |
||
| 91 | 91 | * Inutilisé |
| 92 | 92 | **/ |
| 93 | 93 | function inc_suivre_invalideur_dist($cond, $modif = true) { |
| 94 | - if (!$modif) { |
|
| 95 | - return; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // determiner l'objet modifie : forum, article, etc |
|
| 99 | - if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 100 | - $objet = objet_type($r[1]); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 104 | - if (isset($objet)) { |
|
| 105 | - ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 109 | - // n'affecter la meta que si un de ces objets est modifie |
|
| 110 | - if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | - if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 112 | - ecrire_meta('derniere_modif', time()); |
|
| 113 | - } |
|
| 114 | - } // sinon, cas standard, toujours affecter la meta |
|
| 115 | - else { |
|
| 116 | - ecrire_meta('derniere_modif', time()); |
|
| 117 | - } |
|
| 94 | + if (!$modif) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // determiner l'objet modifie : forum, article, etc |
|
| 99 | + if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 100 | + $objet = objet_type($r[1]); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 104 | + if (isset($objet)) { |
|
| 105 | + ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 109 | + // n'affecter la meta que si un de ces objets est modifie |
|
| 110 | + if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | + if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 112 | + ecrire_meta('derniere_modif', time()); |
|
| 113 | + } |
|
| 114 | + } // sinon, cas standard, toujours affecter la meta |
|
| 115 | + else { |
|
| 116 | + ecrire_meta('derniere_modif', time()); |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -139,57 +139,57 @@ discard block |
||
| 139 | 139 | * Nombre de fichiers supprimés |
| 140 | 140 | **/ |
| 141 | 141 | function purger_repertoire($dir, $options = []) { |
| 142 | - if (!is_dir($dir) or !is_readable($dir)) { |
|
| 143 | - return 0; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - // sur certains sites on veut absolument garder certains caches référencés dans un CDN |
|
| 147 | - // on peut donc inhiber la purge de ces répertoires pour eviter tout probleme |
|
| 148 | - if (file_exists(rtrim($dir, '/') . '/inhib_purger_repertoire.txt')) { |
|
| 149 | - return 0; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - $handle = opendir($dir); |
|
| 153 | - if (!$handle) { |
|
| 154 | - return 0; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - $total = 0; |
|
| 158 | - |
|
| 159 | - while (($fichier = @readdir($handle)) !== false) { |
|
| 160 | - // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 161 | - if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') { |
|
| 162 | - continue; |
|
| 163 | - } |
|
| 164 | - $chemin = "$dir/$fichier"; |
|
| 165 | - if (is_file($chemin)) { |
|
| 166 | - if ( |
|
| 167 | - (!isset($options['atime']) or (@fileatime($chemin) < $options['atime'])) |
|
| 168 | - and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime'])) |
|
| 169 | - ) { |
|
| 170 | - supprimer_fichier($chemin); |
|
| 171 | - $total++; |
|
| 172 | - } |
|
| 173 | - } else { |
|
| 174 | - if (is_dir($chemin)) { |
|
| 175 | - $opts = $options; |
|
| 176 | - if (isset($options['limit'])) { |
|
| 177 | - $opts['limit'] = $options['limit'] - $total; |
|
| 178 | - } |
|
| 179 | - $total += purger_repertoire($chemin, $opts); |
|
| 180 | - if (isset($options['subdir']) && $options['subdir']) { |
|
| 181 | - spip_unlink($chemin); |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - if (isset($options['limit']) and $total >= $options['limit']) { |
|
| 187 | - break; |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - closedir($handle); |
|
| 191 | - |
|
| 192 | - return $total; |
|
| 142 | + if (!is_dir($dir) or !is_readable($dir)) { |
|
| 143 | + return 0; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + // sur certains sites on veut absolument garder certains caches référencés dans un CDN |
|
| 147 | + // on peut donc inhiber la purge de ces répertoires pour eviter tout probleme |
|
| 148 | + if (file_exists(rtrim($dir, '/') . '/inhib_purger_repertoire.txt')) { |
|
| 149 | + return 0; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + $handle = opendir($dir); |
|
| 153 | + if (!$handle) { |
|
| 154 | + return 0; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + $total = 0; |
|
| 158 | + |
|
| 159 | + while (($fichier = @readdir($handle)) !== false) { |
|
| 160 | + // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 161 | + if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') { |
|
| 162 | + continue; |
|
| 163 | + } |
|
| 164 | + $chemin = "$dir/$fichier"; |
|
| 165 | + if (is_file($chemin)) { |
|
| 166 | + if ( |
|
| 167 | + (!isset($options['atime']) or (@fileatime($chemin) < $options['atime'])) |
|
| 168 | + and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime'])) |
|
| 169 | + ) { |
|
| 170 | + supprimer_fichier($chemin); |
|
| 171 | + $total++; |
|
| 172 | + } |
|
| 173 | + } else { |
|
| 174 | + if (is_dir($chemin)) { |
|
| 175 | + $opts = $options; |
|
| 176 | + if (isset($options['limit'])) { |
|
| 177 | + $opts['limit'] = $options['limit'] - $total; |
|
| 178 | + } |
|
| 179 | + $total += purger_repertoire($chemin, $opts); |
|
| 180 | + if (isset($options['subdir']) && $options['subdir']) { |
|
| 181 | + spip_unlink($chemin); |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + if (isset($options['limit']) and $total >= $options['limit']) { |
|
| 187 | + break; |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + closedir($handle); |
|
| 191 | + |
|
| 192 | + return $total; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | |
@@ -200,26 +200,26 @@ discard block |
||
| 200 | 200 | // Securite : est sur que c'est un cache |
| 201 | 201 | function retire_cache($cache) { |
| 202 | 202 | |
| 203 | - if ( |
|
| 204 | - preg_match( |
|
| 205 | - ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 206 | - $cache |
|
| 207 | - ) |
|
| 208 | - ) { |
|
| 209 | - // supprimer le fichier (de facon propre) |
|
| 210 | - supprimer_fichier(_DIR_CACHE . $cache); |
|
| 211 | - } else { |
|
| 212 | - spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 213 | - } |
|
| 203 | + if ( |
|
| 204 | + preg_match( |
|
| 205 | + ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 206 | + $cache |
|
| 207 | + ) |
|
| 208 | + ) { |
|
| 209 | + // supprimer le fichier (de facon propre) |
|
| 210 | + supprimer_fichier(_DIR_CACHE . $cache); |
|
| 211 | + } else { |
|
| 212 | + spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 213 | + } |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Supprimer les caches marques "x" |
| 217 | 217 | // A priori dans cette version la fonction ne sera pas appelee, car |
| 218 | 218 | // la meta est toujours false ; mais evitons un bug si elle est appellee |
| 219 | 219 | function inc_retire_caches_dist($chemin = '') { |
| 220 | - if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 221 | - effacer_meta('invalider_caches'); |
|
| 222 | - } # concurrence |
|
| 220 | + if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 221 | + effacer_meta('invalider_caches'); |
|
| 222 | + } # concurrence |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | ####################################################################### |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | ## |
| 231 | 231 | |
| 232 | 232 | function retire_caches($chemin = '') { |
| 233 | - if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 234 | - return $retire_caches($chemin); |
|
| 235 | - } |
|
| 233 | + if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 234 | + return $retire_caches($chemin); |
|
| 235 | + } |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | // (note: si absente, n'est pas appellee) |
| 241 | 241 | |
| 242 | 242 | function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) { |
| 243 | - if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 244 | - return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 245 | - } |
|
| 246 | - return $corps; |
|
| 243 | + if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 244 | + return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 245 | + } |
|
| 246 | + return $corps; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -252,41 +252,41 @@ discard block |
||
| 252 | 252 | // invoquee quand on vide tout le cache en bloc (action/purger) |
| 253 | 253 | // |
| 254 | 254 | function supprime_invalideurs() { |
| 255 | - if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 256 | - return $supprime_invalideurs(); |
|
| 257 | - } |
|
| 255 | + if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 256 | + return $supprime_invalideurs(); |
|
| 257 | + } |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | // Calcul des pages : noter dans la base les liens d'invalidation |
| 262 | 262 | function maj_invalideurs($fichier, &$page) { |
| 263 | - if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) { |
|
| 264 | - return $maj_invalideurs($fichier, $page); |
|
| 265 | - } |
|
| 263 | + if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) { |
|
| 264 | + return $maj_invalideurs($fichier, $page); |
|
| 265 | + } |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
| 269 | 269 | // les invalideurs sont de la forme "objet/id_objet" |
| 270 | 270 | function insere_invalideur($inval, $fichier) { |
| 271 | - if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 272 | - return $insere_invalideur($inval, $fichier); |
|
| 273 | - } |
|
| 271 | + if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 272 | + return $insere_invalideur($inval, $fichier); |
|
| 273 | + } |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // |
| 277 | 277 | // Marquer les fichiers caches invalides comme etant a supprimer |
| 278 | 278 | // |
| 279 | 279 | function applique_invalideur($depart) { |
| 280 | - if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 281 | - return $applique_invalideur($depart); |
|
| 282 | - } |
|
| 280 | + if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 281 | + return $applique_invalideur($depart); |
|
| 282 | + } |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // |
| 286 | 286 | // Invalider les caches liés à telle condition |
| 287 | 287 | // |
| 288 | 288 | function suivre_invalideur($cond, $modif = true) { |
| 289 | - if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 290 | - return $suivre_invalideur($cond, $modif); |
|
| 291 | - } |
|
| 289 | + if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 290 | + return $suivre_invalideur($cond, $modif); |
|
| 291 | + } |
|
| 292 | 292 | } |
@@ -11,187 +11,187 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function trace_query_start() { |
| 18 | - static $trace = '?'; |
|
| 19 | - if ($trace === '?' or defined('_DEBUG_TRACE_QUERIES')) { |
|
| 20 | - if (defined('_DEBUG_TRACE_QUERIES') and _DEBUG_TRACE_QUERIES) { |
|
| 21 | - $trace = true; |
|
| 22 | - } |
|
| 23 | - else { |
|
| 24 | - if (empty($GLOBALS['visiteur_session'])) { |
|
| 25 | - // si un anonyme fait un var_profile on est oblige de remplir le tableau des temps en attendant de savoir |
|
| 26 | - // car ici on ne sait pas si c'est un hit anonyme |
|
| 27 | - // ou une requete SQL faite avant chargement de la session |
|
| 28 | - $trace = (!empty($_GET['var_profile']) ? '?' : false); |
|
| 29 | - } |
|
| 30 | - else { |
|
| 31 | - include_spip('inc/autoriser'); |
|
| 32 | - // gare au bouclage sur calcul de droits au premier appel |
|
| 33 | - // A fortiori quand on demande une trace |
|
| 34 | - $trace = false; // on ne trace pas la requete provoquee par autoriser('debug') |
|
| 35 | - $trace = (!empty($_GET['var_profile']) and autoriser('debug')); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - return $trace ? microtime() : 0; |
|
| 18 | + static $trace = '?'; |
|
| 19 | + if ($trace === '?' or defined('_DEBUG_TRACE_QUERIES')) { |
|
| 20 | + if (defined('_DEBUG_TRACE_QUERIES') and _DEBUG_TRACE_QUERIES) { |
|
| 21 | + $trace = true; |
|
| 22 | + } |
|
| 23 | + else { |
|
| 24 | + if (empty($GLOBALS['visiteur_session'])) { |
|
| 25 | + // si un anonyme fait un var_profile on est oblige de remplir le tableau des temps en attendant de savoir |
|
| 26 | + // car ici on ne sait pas si c'est un hit anonyme |
|
| 27 | + // ou une requete SQL faite avant chargement de la session |
|
| 28 | + $trace = (!empty($_GET['var_profile']) ? '?' : false); |
|
| 29 | + } |
|
| 30 | + else { |
|
| 31 | + include_spip('inc/autoriser'); |
|
| 32 | + // gare au bouclage sur calcul de droits au premier appel |
|
| 33 | + // A fortiori quand on demande une trace |
|
| 34 | + $trace = false; // on ne trace pas la requete provoquee par autoriser('debug') |
|
| 35 | + $trace = (!empty($_GET['var_profile']) and autoriser('debug')); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + return $trace ? microtime() : 0; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | function trace_query_end($query, $start, $result, $erreur, $serveur = '') { |
| 44 | - static $trace = '?'; |
|
| 45 | - if ($trace === '?') { |
|
| 46 | - if (empty($GLOBALS['visiteur_session'])) { |
|
| 47 | - // si un anonyme fait un var_profile on est oblige de remplir le tableau des temps en attendant de savoir |
|
| 48 | - // car ici on ne sait pas si c'est un hit anonyme |
|
| 49 | - // ou une requete SQL faite avant chargement de la session |
|
| 50 | - $trace = (!empty($_GET['var_profile']) ? '?' : false); |
|
| 51 | - } |
|
| 52 | - else { |
|
| 53 | - include_spip('inc/autoriser'); |
|
| 54 | - // gare au bouclage sur calcul de droits au premier appel |
|
| 55 | - // A fortiori quand on demande une trace |
|
| 56 | - $trace = false; // on ne trace pas la requete provoquee par autoriser('debug') |
|
| 57 | - $trace = (!empty($_GET['var_profile']) and autoriser('debug')); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - if ($start) { |
|
| 61 | - $end = microtime(); |
|
| 62 | - [$usec, $sec] = explode(' ', $start); |
|
| 63 | - [$usec2, $sec2] = explode(' ', $end); |
|
| 64 | - $dt = $sec2 + $usec2 - $sec - $usec; |
|
| 65 | - pipeline('trig_trace_query', ['query' => $query, 'start' => $start, 'end' => $end, 'time' => $dt, 'result' => $result, 'erreur' => $erreur, 'serveur' => $serveur]); |
|
| 66 | - if ($trace) { |
|
| 67 | - trace_query_chrono($dt, $query, $result, $serveur); |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - // tracer les erreurs, sauf pour select, c'est fait dans abstract_sql |
|
| 71 | - if ($trace and $erreur and !preg_match('/^select\b/i', $query)) { |
|
| 72 | - erreur_squelette([sql_errno($serveur), $erreur, $query]); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return $result; |
|
| 44 | + static $trace = '?'; |
|
| 45 | + if ($trace === '?') { |
|
| 46 | + if (empty($GLOBALS['visiteur_session'])) { |
|
| 47 | + // si un anonyme fait un var_profile on est oblige de remplir le tableau des temps en attendant de savoir |
|
| 48 | + // car ici on ne sait pas si c'est un hit anonyme |
|
| 49 | + // ou une requete SQL faite avant chargement de la session |
|
| 50 | + $trace = (!empty($_GET['var_profile']) ? '?' : false); |
|
| 51 | + } |
|
| 52 | + else { |
|
| 53 | + include_spip('inc/autoriser'); |
|
| 54 | + // gare au bouclage sur calcul de droits au premier appel |
|
| 55 | + // A fortiori quand on demande une trace |
|
| 56 | + $trace = false; // on ne trace pas la requete provoquee par autoriser('debug') |
|
| 57 | + $trace = (!empty($_GET['var_profile']) and autoriser('debug')); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + if ($start) { |
|
| 61 | + $end = microtime(); |
|
| 62 | + [$usec, $sec] = explode(' ', $start); |
|
| 63 | + [$usec2, $sec2] = explode(' ', $end); |
|
| 64 | + $dt = $sec2 + $usec2 - $sec - $usec; |
|
| 65 | + pipeline('trig_trace_query', ['query' => $query, 'start' => $start, 'end' => $end, 'time' => $dt, 'result' => $result, 'erreur' => $erreur, 'serveur' => $serveur]); |
|
| 66 | + if ($trace) { |
|
| 67 | + trace_query_chrono($dt, $query, $result, $serveur); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + // tracer les erreurs, sauf pour select, c'est fait dans abstract_sql |
|
| 71 | + if ($trace and $erreur and !preg_match('/^select\b/i', $query)) { |
|
| 72 | + erreur_squelette([sql_errno($serveur), $erreur, $query]); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return $result; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function trace_query_chrono($dt, $query, $result, $serveur = '') { |
| 79 | - include_spip('inc/filtres_mini'); |
|
| 80 | - static $tt = 0, $nb = 0; |
|
| 81 | - |
|
| 82 | - $x = _request('var_mode_objet'); |
|
| 83 | - if (isset($GLOBALS['debug']['aucasou'])) { |
|
| 84 | - [, $boucle, $serveur, $contexte] = $GLOBALS['debug']['aucasou']; |
|
| 85 | - if ($x and !preg_match("/$boucle\$/", $x)) { |
|
| 86 | - return; |
|
| 87 | - } |
|
| 88 | - if ($serveur) { |
|
| 89 | - $boucle .= " ($serveur)"; |
|
| 90 | - } |
|
| 91 | - $boucle = "<b>$boucle</b>"; |
|
| 92 | - } else { |
|
| 93 | - if ($x) { |
|
| 94 | - return; |
|
| 95 | - } |
|
| 96 | - $boucle = $contexte = ''; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $tt += $dt; |
|
| 100 | - $nb++; |
|
| 101 | - |
|
| 102 | - $q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n<br />$2", spip_htmlentities($query)); |
|
| 103 | - $e = sql_explain($query, $serveur); |
|
| 104 | - $r = str_replace('Resource id ', '', (is_object($result) ? get_class($result) : $result)); |
|
| 105 | - $GLOBALS['tableau_des_temps'][] = [$dt, $nb, $boucle, $q, $e, $r, $contexte]; |
|
| 79 | + include_spip('inc/filtres_mini'); |
|
| 80 | + static $tt = 0, $nb = 0; |
|
| 81 | + |
|
| 82 | + $x = _request('var_mode_objet'); |
|
| 83 | + if (isset($GLOBALS['debug']['aucasou'])) { |
|
| 84 | + [, $boucle, $serveur, $contexte] = $GLOBALS['debug']['aucasou']; |
|
| 85 | + if ($x and !preg_match("/$boucle\$/", $x)) { |
|
| 86 | + return; |
|
| 87 | + } |
|
| 88 | + if ($serveur) { |
|
| 89 | + $boucle .= " ($serveur)"; |
|
| 90 | + } |
|
| 91 | + $boucle = "<b>$boucle</b>"; |
|
| 92 | + } else { |
|
| 93 | + if ($x) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 96 | + $boucle = $contexte = ''; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $tt += $dt; |
|
| 100 | + $nb++; |
|
| 101 | + |
|
| 102 | + $q = preg_replace('/([a-z)`])\s+([A-Z])/', "$1\n<br />$2", spip_htmlentities($query)); |
|
| 103 | + $e = sql_explain($query, $serveur); |
|
| 104 | + $r = str_replace('Resource id ', '', (is_object($result) ? get_class($result) : $result)); |
|
| 105 | + $GLOBALS['tableau_des_temps'][] = [$dt, $nb, $boucle, $q, $e, $r, $contexte]; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | function chrono_requete($temps) { |
| 110 | - $total = 0; |
|
| 111 | - $hors = '<i>' . _T('zbug_hors_compilation') . '</i>'; |
|
| 112 | - $t = $q = $n = $d = []; |
|
| 113 | - // Totaliser les temps et completer le Explain |
|
| 114 | - foreach ($temps as $key => $v) { |
|
| 115 | - [$dt, $nb, $boucle, $query, $explain, $res, $contexte] = $v; |
|
| 116 | - if (is_array($contexte)) { |
|
| 117 | - $k = ($contexte[0] . " $boucle"); |
|
| 118 | - include_spip('public/compiler'); |
|
| 119 | - $env = reconstruire_contexte_compil($contexte); |
|
| 120 | - } else { |
|
| 121 | - $k = $env = $boucle; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - $total += $dt; |
|
| 125 | - $t[$key] = $dt; |
|
| 126 | - $q[$key] = $nb; |
|
| 127 | - if (!isset($d[$k])) { |
|
| 128 | - $d[$k] = 0; |
|
| 129 | - $n[$k] = 0; |
|
| 130 | - } |
|
| 131 | - $d[$k] += $dt; |
|
| 132 | - ++$n[$k]; |
|
| 133 | - |
|
| 134 | - if (!is_array($explain)) { |
|
| 135 | - $explain = []; |
|
| 136 | - } |
|
| 137 | - foreach ($explain as $j => $v) { |
|
| 138 | - $explain[$j] = "<tr><th>$j</th><td>" |
|
| 139 | - . str_replace(';', '<br />', $v) |
|
| 140 | - . '</td></tr>'; |
|
| 141 | - } |
|
| 142 | - $e = "<table class='explain'>" |
|
| 143 | - . '<caption>' |
|
| 144 | - . $query |
|
| 145 | - . '</caption>' |
|
| 146 | - . "<tr><th>Time</th><td>$dt</td></tr>" |
|
| 147 | - . "<tr><th>Order</th><td>$nb</td></tr>" |
|
| 148 | - . "<tr><th>Res</th><td>$res</td></tr>" |
|
| 149 | - . join('', $explain) |
|
| 150 | - . '</table>'; |
|
| 151 | - |
|
| 152 | - $temps[$key] = [$e, $env, $k]; |
|
| 153 | - } |
|
| 154 | - // Trier par temps d'execution decroissant |
|
| 155 | - array_multisort($t, SORT_DESC, $q, $temps); |
|
| 156 | - arsort($d); |
|
| 157 | - $i = 1; |
|
| 158 | - $t = []; |
|
| 159 | - // Fabriquer les liens de navigations dans le tableau des temps |
|
| 160 | - foreach ($temps as $k => $v) { |
|
| 161 | - $titre = strip_tags($v[2]); |
|
| 162 | - $href = quote_amp($GLOBALS['REQUEST_URI']) . "#req$i"; |
|
| 163 | - $href = str_replace("\\'", ''', $href); |
|
| 164 | - |
|
| 165 | - if (!isset($t[$v[2]])) { |
|
| 166 | - $t[$v[2]] = []; |
|
| 167 | - } |
|
| 168 | - $t[$v[2]][] = "<span class='spip-debug-arg'> " |
|
| 169 | - . "<a title='$titre' href='$href'>$i</a>" |
|
| 170 | - . '</span>' |
|
| 171 | - . ((count($t[$v[2]]) % 10 == 9) ? '<br />' : ''); |
|
| 172 | - $i++; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - if ($d['']) { |
|
| 176 | - $d[$hors] = $d['']; |
|
| 177 | - $n[$hors] = $n['']; |
|
| 178 | - $t[$hors] = $t['']; |
|
| 179 | - } |
|
| 180 | - unset($d['']); |
|
| 181 | - // Fabriquer le tableau des liens de navigation dans le grand tableau |
|
| 182 | - foreach ($d as $k => $v) { |
|
| 183 | - $d[$k] = $n[$k] . "</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>" |
|
| 184 | - . join('', $t[$k]); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $navigation = [ |
|
| 188 | - _T('zbug_statistiques'), |
|
| 189 | - '<tr><td>' |
|
| 190 | - . join("</td></tr>\n<tr><td>", $d) |
|
| 191 | - . "</td></tr>\n" |
|
| 192 | - . (# _request('var_mode_objet') ? '' : |
|
| 193 | - ('<tr><td>' . (is_countable($temps) ? count($temps) : 0) . '</td><td>' . _T('info_total') . '</td><td class="time">' . $total . '</td><td></td></tr>')) |
|
| 194 | - ]; |
|
| 195 | - |
|
| 196 | - return [$temps, $navigation]; |
|
| 110 | + $total = 0; |
|
| 111 | + $hors = '<i>' . _T('zbug_hors_compilation') . '</i>'; |
|
| 112 | + $t = $q = $n = $d = []; |
|
| 113 | + // Totaliser les temps et completer le Explain |
|
| 114 | + foreach ($temps as $key => $v) { |
|
| 115 | + [$dt, $nb, $boucle, $query, $explain, $res, $contexte] = $v; |
|
| 116 | + if (is_array($contexte)) { |
|
| 117 | + $k = ($contexte[0] . " $boucle"); |
|
| 118 | + include_spip('public/compiler'); |
|
| 119 | + $env = reconstruire_contexte_compil($contexte); |
|
| 120 | + } else { |
|
| 121 | + $k = $env = $boucle; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + $total += $dt; |
|
| 125 | + $t[$key] = $dt; |
|
| 126 | + $q[$key] = $nb; |
|
| 127 | + if (!isset($d[$k])) { |
|
| 128 | + $d[$k] = 0; |
|
| 129 | + $n[$k] = 0; |
|
| 130 | + } |
|
| 131 | + $d[$k] += $dt; |
|
| 132 | + ++$n[$k]; |
|
| 133 | + |
|
| 134 | + if (!is_array($explain)) { |
|
| 135 | + $explain = []; |
|
| 136 | + } |
|
| 137 | + foreach ($explain as $j => $v) { |
|
| 138 | + $explain[$j] = "<tr><th>$j</th><td>" |
|
| 139 | + . str_replace(';', '<br />', $v) |
|
| 140 | + . '</td></tr>'; |
|
| 141 | + } |
|
| 142 | + $e = "<table class='explain'>" |
|
| 143 | + . '<caption>' |
|
| 144 | + . $query |
|
| 145 | + . '</caption>' |
|
| 146 | + . "<tr><th>Time</th><td>$dt</td></tr>" |
|
| 147 | + . "<tr><th>Order</th><td>$nb</td></tr>" |
|
| 148 | + . "<tr><th>Res</th><td>$res</td></tr>" |
|
| 149 | + . join('', $explain) |
|
| 150 | + . '</table>'; |
|
| 151 | + |
|
| 152 | + $temps[$key] = [$e, $env, $k]; |
|
| 153 | + } |
|
| 154 | + // Trier par temps d'execution decroissant |
|
| 155 | + array_multisort($t, SORT_DESC, $q, $temps); |
|
| 156 | + arsort($d); |
|
| 157 | + $i = 1; |
|
| 158 | + $t = []; |
|
| 159 | + // Fabriquer les liens de navigations dans le tableau des temps |
|
| 160 | + foreach ($temps as $k => $v) { |
|
| 161 | + $titre = strip_tags($v[2]); |
|
| 162 | + $href = quote_amp($GLOBALS['REQUEST_URI']) . "#req$i"; |
|
| 163 | + $href = str_replace("\\'", ''', $href); |
|
| 164 | + |
|
| 165 | + if (!isset($t[$v[2]])) { |
|
| 166 | + $t[$v[2]] = []; |
|
| 167 | + } |
|
| 168 | + $t[$v[2]][] = "<span class='spip-debug-arg'> " |
|
| 169 | + . "<a title='$titre' href='$href'>$i</a>" |
|
| 170 | + . '</span>' |
|
| 171 | + . ((count($t[$v[2]]) % 10 == 9) ? '<br />' : ''); |
|
| 172 | + $i++; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + if ($d['']) { |
|
| 176 | + $d[$hors] = $d['']; |
|
| 177 | + $n[$hors] = $n['']; |
|
| 178 | + $t[$hors] = $t['']; |
|
| 179 | + } |
|
| 180 | + unset($d['']); |
|
| 181 | + // Fabriquer le tableau des liens de navigation dans le grand tableau |
|
| 182 | + foreach ($d as $k => $v) { |
|
| 183 | + $d[$k] = $n[$k] . "</td><td>$k</td><td class='time'>$v</td><td class='liste-reqs'>" |
|
| 184 | + . join('', $t[$k]); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $navigation = [ |
|
| 188 | + _T('zbug_statistiques'), |
|
| 189 | + '<tr><td>' |
|
| 190 | + . join("</td></tr>\n<tr><td>", $d) |
|
| 191 | + . "</td></tr>\n" |
|
| 192 | + . (# _request('var_mode_objet') ? '' : |
|
| 193 | + ('<tr><td>' . (is_countable($temps) ? count($temps) : 0) . '</td><td>' . _T('info_total') . '</td><td class="time">' . $total . '</td><td></td></tr>')) |
|
| 194 | + ]; |
|
| 195 | + |
|
| 196 | + return [$temps, $navigation]; |
|
| 197 | 197 | } |
@@ -11,140 +11,140 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/presentation'); |
| 17 | 17 | include_spip('inc/config'); |
| 18 | 18 | |
| 19 | 19 | function formulaires_configurer_relayeur_charger_dist() { |
| 20 | - $valeurs = [ |
|
| 21 | - 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 22 | - 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 23 | - 'test_proxy' => 'https://www.spip.net/', |
|
| 24 | - ]; |
|
| 20 | + $valeurs = [ |
|
| 21 | + 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 22 | + 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 23 | + 'test_proxy' => 'https://www.spip.net/', |
|
| 24 | + ]; |
|
| 25 | 25 | |
| 26 | - return $valeurs; |
|
| 26 | + return $valeurs; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | function formulaires_configurer_relayeur_verifier_dist() { |
| 30 | - $erreurs = []; |
|
| 31 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 32 | - $http_noproxy = _request('http_noproxy'); |
|
| 33 | - |
|
| 34 | - if ($http_proxy and !tester_url_absolue($http_proxy)) { |
|
| 35 | - $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) { |
|
| 39 | - if (!$http_proxy) { |
|
| 40 | - $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 41 | - } else { |
|
| 42 | - include_spip('inc/distant'); |
|
| 43 | - $test_proxy = _request('test_proxy'); |
|
| 44 | - $t = parse_url($test_proxy); |
|
| 45 | - if (!@$t['host']) { |
|
| 46 | - $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 47 | - } else { |
|
| 48 | - include_spip('inc/texte'); // pour aide, couper, lang |
|
| 49 | - $info = ''; |
|
| 50 | - if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 51 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // il faut fausser le proxy actuel pour faire le test ! |
|
| 55 | - $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 56 | - $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 57 | - $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 58 | - $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 59 | - $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 60 | - $page = $page['page'] ?? ''; |
|
| 61 | - $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 62 | - $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 63 | - if ($page) { |
|
| 64 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 65 | - $erreurs['message_erreur'] = ''; |
|
| 66 | - } else { |
|
| 67 | - $erreurs['message_erreur'] = $info . _T( |
|
| 68 | - 'info_impossible_lire_page', |
|
| 69 | - ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 70 | - ) |
|
| 71 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 72 | - . aider('confhttpproxy'); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - return $erreurs; |
|
| 30 | + $erreurs = []; |
|
| 31 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 32 | + $http_noproxy = _request('http_noproxy'); |
|
| 33 | + |
|
| 34 | + if ($http_proxy and !tester_url_absolue($http_proxy)) { |
|
| 35 | + $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) { |
|
| 39 | + if (!$http_proxy) { |
|
| 40 | + $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 41 | + } else { |
|
| 42 | + include_spip('inc/distant'); |
|
| 43 | + $test_proxy = _request('test_proxy'); |
|
| 44 | + $t = parse_url($test_proxy); |
|
| 45 | + if (!@$t['host']) { |
|
| 46 | + $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 47 | + } else { |
|
| 48 | + include_spip('inc/texte'); // pour aide, couper, lang |
|
| 49 | + $info = ''; |
|
| 50 | + if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 51 | + $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // il faut fausser le proxy actuel pour faire le test ! |
|
| 55 | + $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 56 | + $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 57 | + $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 58 | + $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 59 | + $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 60 | + $page = $page['page'] ?? ''; |
|
| 61 | + $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 62 | + $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 63 | + if ($page) { |
|
| 64 | + $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 65 | + $erreurs['message_erreur'] = ''; |
|
| 66 | + } else { |
|
| 67 | + $erreurs['message_erreur'] = $info . _T( |
|
| 68 | + 'info_impossible_lire_page', |
|
| 69 | + ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 70 | + ) |
|
| 71 | + . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 72 | + . aider('confhttpproxy'); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + return $erreurs; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function formulaires_configurer_relayeur_traiter_dist() { |
| 82 | - $res = ['editable' => true]; |
|
| 82 | + $res = ['editable' => true]; |
|
| 83 | 83 | |
| 84 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 85 | - $http_noproxy = _request('http_noproxy'); |
|
| 86 | - if ($http_proxy !== null) { |
|
| 87 | - ecrire_meta('http_proxy', $http_proxy); |
|
| 88 | - } |
|
| 84 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 85 | + $http_noproxy = _request('http_noproxy'); |
|
| 86 | + if ($http_proxy !== null) { |
|
| 87 | + ecrire_meta('http_proxy', $http_proxy); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - if ($http_noproxy !== null) { |
|
| 91 | - ecrire_meta('http_noproxy', $http_noproxy); |
|
| 92 | - } |
|
| 90 | + if ($http_noproxy !== null) { |
|
| 91 | + ecrire_meta('http_noproxy', $http_noproxy); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 94 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 95 | 95 | |
| 96 | - return $res; |
|
| 96 | + return $res; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | function relayeur_saisie_ou_config($http_proxy, $default) { |
| 100 | - // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 101 | - if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 102 | - $http_proxy = $default; |
|
| 103 | - } |
|
| 100 | + // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 101 | + if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 102 | + $http_proxy = $default; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $http_proxy; |
|
| 105 | + return $http_proxy; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Function glue_url : le pendant de parse_url |
| 109 | 109 | function glue_url($url) { |
| 110 | - if (!is_array($url)) { |
|
| 111 | - return false; |
|
| 112 | - } |
|
| 113 | - // scheme |
|
| 114 | - $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | - // user & pass |
|
| 116 | - if (!empty($url['user'])) { |
|
| 117 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | - } |
|
| 119 | - // host |
|
| 120 | - $uri .= $url['host']; |
|
| 121 | - // port |
|
| 122 | - $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | - $uri .= $port; |
|
| 124 | - // path |
|
| 125 | - $uri .= $url['path']; |
|
| 110 | + if (!is_array($url)) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + // scheme |
|
| 114 | + $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | + // user & pass |
|
| 116 | + if (!empty($url['user'])) { |
|
| 117 | + $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | + } |
|
| 119 | + // host |
|
| 120 | + $uri .= $url['host']; |
|
| 121 | + // port |
|
| 122 | + $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | + $uri .= $port; |
|
| 124 | + // path |
|
| 125 | + $uri .= $url['path']; |
|
| 126 | 126 | // fragment or query |
| 127 | - if (isset($url['fragment'])) { |
|
| 128 | - $uri .= '#' . $url['fragment']; |
|
| 129 | - } elseif (isset($url['query'])) { |
|
| 130 | - $uri .= '?' . $url['query']; |
|
| 131 | - } |
|
| 127 | + if (isset($url['fragment'])) { |
|
| 128 | + $uri .= '#' . $url['fragment']; |
|
| 129 | + } elseif (isset($url['query'])) { |
|
| 130 | + $uri .= '?' . $url['query']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return $uri; |
|
| 133 | + return $uri; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | // Ne pas afficher la partie 'password' du proxy |
| 138 | 138 | function no_password_proxy_url($http_proxy) { |
| 139 | - if ( |
|
| 140 | - $http_proxy |
|
| 141 | - and $p = @parse_url($http_proxy) |
|
| 142 | - and isset($p['pass']) |
|
| 143 | - and $p['pass'] |
|
| 144 | - ) { |
|
| 145 | - $p['pass'] = '****'; |
|
| 146 | - $http_proxy = glue_url($p); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - return $http_proxy; |
|
| 139 | + if ( |
|
| 140 | + $http_proxy |
|
| 141 | + and $p = @parse_url($http_proxy) |
|
| 142 | + and isset($p['pass']) |
|
| 143 | + and $p['pass'] |
|
| 144 | + ) { |
|
| 145 | + $p['pass'] = '****'; |
|
| 146 | + $http_proxy = glue_url($p); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + return $http_proxy; |
|
| 150 | 150 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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('inc/autoriser'); |
@@ -35,42 +35,42 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function action_menu_rubriques_dist() { |
| 37 | 37 | |
| 38 | - // si pas acces a ecrire, pas acces au menu |
|
| 39 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | - if (!autoriser('ecrire')) { |
|
| 41 | - $retour = |
|
| 42 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | - '</a>' . |
|
| 47 | - '</li>' . |
|
| 48 | - '</ul>'; |
|
| 49 | - include_spip('inc/actions'); |
|
| 50 | - ajax_retour($retour); |
|
| 51 | - exit; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($date = intval(_request('date'))) { |
|
| 55 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - $r = gen_liste_rubriques(); |
|
| 59 | - if ( |
|
| 60 | - !$r |
|
| 61 | - and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | - ) { |
|
| 64 | - include_spip('inc/headers'); |
|
| 65 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | - http_response_code(304); |
|
| 67 | - exit; |
|
| 68 | - } else { |
|
| 69 | - include_spip('inc/actions'); |
|
| 70 | - $ret = menu_rubriques(); |
|
| 71 | - ajax_retour($ret); |
|
| 72 | - exit; |
|
| 73 | - } |
|
| 38 | + // si pas acces a ecrire, pas acces au menu |
|
| 39 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | + if (!autoriser('ecrire')) { |
|
| 41 | + $retour = |
|
| 42 | + '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | + '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | + '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | + '</a>' . |
|
| 47 | + '</li>' . |
|
| 48 | + '</ul>'; |
|
| 49 | + include_spip('inc/actions'); |
|
| 50 | + ajax_retour($retour); |
|
| 51 | + exit; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($date = intval(_request('date'))) { |
|
| 55 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + $r = gen_liste_rubriques(); |
|
| 59 | + if ( |
|
| 60 | + !$r |
|
| 61 | + and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | + ) { |
|
| 64 | + include_spip('inc/headers'); |
|
| 65 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | + http_response_code(304); |
|
| 67 | + exit; |
|
| 68 | + } else { |
|
| 69 | + include_spip('inc/actions'); |
|
| 70 | + $ret = menu_rubriques(); |
|
| 71 | + ajax_retour($ret); |
|
| 72 | + exit; |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -84,44 +84,44 @@ discard block |
||
| 84 | 84 | * Code HTML présentant la liste des rubriques |
| 85 | 85 | **/ |
| 86 | 86 | function menu_rubriques($complet = true) { |
| 87 | - $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | - . '</a>' |
|
| 91 | - . '</li>'; |
|
| 92 | - |
|
| 93 | - if (!$complet) { |
|
| 94 | - return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | - gen_liste_rubriques(); |
|
| 99 | - } |
|
| 100 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | - |
|
| 102 | - $total_lignes = $i = sizeof($arr_low); |
|
| 103 | - |
|
| 104 | - if ($i > 0) { |
|
| 105 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | - if ($nb_col <= 1) { |
|
| 107 | - $nb_col = ceil($total_lignes / 10); |
|
| 108 | - } |
|
| 109 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | - $i++; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | - $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | - . $ret |
|
| 119 | - . "\n</ul>\n"; |
|
| 120 | - } else { |
|
| 121 | - $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $ret; |
|
| 87 | + $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | + . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | + . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | + . '</a>' |
|
| 91 | + . '</li>'; |
|
| 92 | + |
|
| 93 | + if (!$complet) { |
|
| 94 | + return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | + gen_liste_rubriques(); |
|
| 99 | + } |
|
| 100 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | + |
|
| 102 | + $total_lignes = $i = sizeof($arr_low); |
|
| 103 | + |
|
| 104 | + if ($i > 0) { |
|
| 105 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | + if ($nb_col <= 1) { |
|
| 107 | + $nb_col = ceil($total_lignes / 10); |
|
| 108 | + } |
|
| 109 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | + $i++; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | + $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | + . $ret |
|
| 119 | + . "\n</ul>\n"; |
|
| 120 | + } else { |
|
| 121 | + $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $ret; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,48 +142,48 @@ discard block |
||
| 142 | 142 | * Code HTML présentant la liste des rubriques |
| 143 | 143 | **/ |
| 144 | 144 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) { |
| 145 | - static $zmax = 6; |
|
| 146 | - $profondeur_next = $profondeur + 1; |
|
| 147 | - |
|
| 148 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | - . "</a>\n"; |
|
| 151 | - |
|
| 152 | - // Limiter volontairement le nombre de sous-menus |
|
| 153 | - if (!(--$zmax)) { |
|
| 154 | - $zmax++; |
|
| 155 | - |
|
| 156 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | - $i = sizeof($arr_rub); |
|
| 161 | - if (!$i) { |
|
| 162 | - $zmax++; |
|
| 163 | - |
|
| 164 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - $nb_col = 1; |
|
| 169 | - if ($nb_rub = count($arr_rub)) { |
|
| 170 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | - } |
|
| 172 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | - $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | - . $nav |
|
| 175 | - . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | - $i++; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $ret .= "</ul></li>\n"; |
|
| 184 | - $zmax++; |
|
| 185 | - |
|
| 186 | - return $ret; |
|
| 145 | + static $zmax = 6; |
|
| 146 | + $profondeur_next = $profondeur + 1; |
|
| 147 | + |
|
| 148 | + $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | + . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | + . "</a>\n"; |
|
| 151 | + |
|
| 152 | + // Limiter volontairement le nombre de sous-menus |
|
| 153 | + if (!(--$zmax)) { |
|
| 154 | + $zmax++; |
|
| 155 | + |
|
| 156 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | + $i = sizeof($arr_rub); |
|
| 161 | + if (!$i) { |
|
| 162 | + $zmax++; |
|
| 163 | + |
|
| 164 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + $nb_col = 1; |
|
| 169 | + if ($nb_rub = count($arr_rub)) { |
|
| 170 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | + } |
|
| 172 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | + $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | + . $nav |
|
| 175 | + . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | + $i++; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $ret .= "</ul></li>\n"; |
|
| 184 | + $zmax++; |
|
| 185 | + |
|
| 186 | + return $ret; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 202 | 202 | **/ |
| 203 | 203 | function extraire_article($id_p, $t) { |
| 204 | - return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 204 | + return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -217,42 +217,42 @@ discard block |
||
| 217 | 217 | **/ |
| 218 | 218 | function gen_liste_rubriques() { |
| 219 | 219 | |
| 220 | - $cache = null; |
|
| 221 | - include_spip('inc/config'); |
|
| 222 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | - [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | - if ($date == $last) { |
|
| 227 | - return false; |
|
| 228 | - } // c'etait en cache :-) |
|
| 229 | - } |
|
| 230 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | - |
|
| 232 | - $where = sql_in_select( |
|
| 233 | - 'id_rubrique', |
|
| 234 | - 'id_rubrique', |
|
| 235 | - 'spip_rubriques', |
|
| 236 | - '', |
|
| 237 | - '', |
|
| 238 | - 'id_parent=0 DESC, date DESC', |
|
| 239 | - _CACHE_RUBRIQUES_MAX |
|
| 240 | - ); |
|
| 241 | - |
|
| 242 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | - |
|
| 244 | - $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | - |
|
| 246 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | - // car on met le resultat en cache, commun a tout le monde |
|
| 248 | - $GLOBALS['db_art_cache'] = []; |
|
| 249 | - while ($r = sql_fetch($res)) { |
|
| 250 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | - |
|
| 257 | - return true; |
|
| 220 | + $cache = null; |
|
| 221 | + include_spip('inc/config'); |
|
| 222 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | + [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | + if ($date == $last) { |
|
| 227 | + return false; |
|
| 228 | + } // c'etait en cache :-) |
|
| 229 | + } |
|
| 230 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | + |
|
| 232 | + $where = sql_in_select( |
|
| 233 | + 'id_rubrique', |
|
| 234 | + 'id_rubrique', |
|
| 235 | + 'spip_rubriques', |
|
| 236 | + '', |
|
| 237 | + '', |
|
| 238 | + 'id_parent=0 DESC, date DESC', |
|
| 239 | + _CACHE_RUBRIQUES_MAX |
|
| 240 | + ); |
|
| 241 | + |
|
| 242 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | + |
|
| 244 | + $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | + |
|
| 246 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | + // car on met le resultat en cache, commun a tout le monde |
|
| 248 | + $GLOBALS['db_art_cache'] = []; |
|
| 249 | + while ($r = sql_fetch($res)) { |
|
| 250 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | + |
|
| 257 | + return true; |
|
| 258 | 258 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -36,56 +36,56 @@ discard block |
||
| 36 | 36 | * ``` |
| 37 | 37 | **/ |
| 38 | 38 | function action_redirect_dist() { |
| 39 | - $type = _request('type'); |
|
| 40 | - $id = intval(_request('id')); |
|
| 41 | - $page = false; |
|
| 39 | + $type = _request('type'); |
|
| 40 | + $id = intval(_request('id')); |
|
| 41 | + $page = false; |
|
| 42 | 42 | |
| 43 | - // verifier le type ou page transmis |
|
| 44 | - if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | - $page = _request('page'); |
|
| 46 | - if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 49 | - } |
|
| 43 | + // verifier le type ou page transmis |
|
| 44 | + if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | + $page = _request('page'); |
|
| 46 | + if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($var_mode = _request('var_mode')) { |
|
| 52 | - // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | - if (!defined('_VAR_URLS')) { |
|
| 54 | - define('_VAR_URLS', true); |
|
| 55 | - } |
|
| 56 | - } |
|
| 51 | + if ($var_mode = _request('var_mode')) { |
|
| 52 | + // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | + if (!defined('_VAR_URLS')) { |
|
| 54 | + define('_VAR_URLS', true); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - if ($page) { |
|
| 59 | - $url = generer_url_public($page, '', true); |
|
| 60 | - } else { |
|
| 61 | - $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | - } |
|
| 58 | + if ($page) { |
|
| 59 | + $url = generer_url_public($page, '', true); |
|
| 60 | + } else { |
|
| 61 | + $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $status = '302'; |
|
| 65 | - if ($url) { |
|
| 66 | - if ($var_mode) { |
|
| 67 | - $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | - } |
|
| 64 | + $status = '302'; |
|
| 65 | + if ($url) { |
|
| 66 | + if ($var_mode) { |
|
| 67 | + $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if ( |
|
| 71 | - $var_mode == 'preview' |
|
| 72 | - and defined('_PREVIEW_TOKEN') |
|
| 73 | - and _PREVIEW_TOKEN |
|
| 74 | - and autoriser('previsualiser') |
|
| 75 | - ) { |
|
| 76 | - include_spip('inc/securiser_action'); |
|
| 77 | - $token = calculer_token_previsu($url); |
|
| 78 | - $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | - } |
|
| 70 | + if ( |
|
| 71 | + $var_mode == 'preview' |
|
| 72 | + and defined('_PREVIEW_TOKEN') |
|
| 73 | + and _PREVIEW_TOKEN |
|
| 74 | + and autoriser('previsualiser') |
|
| 75 | + ) { |
|
| 76 | + include_spip('inc/securiser_action'); |
|
| 77 | + $token = calculer_token_previsu($url); |
|
| 78 | + $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if (_request('status') and _request('status') == '301') { |
|
| 82 | - $status = '301'; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - $url = generer_url_public('404', '', true); |
|
| 86 | - } |
|
| 81 | + if (_request('status') and _request('status') == '301') { |
|
| 82 | + $status = '301'; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + $url = generer_url_public('404', '', true); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 88 | + redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -100,35 +100,35 @@ discard block |
||
| 100 | 100 | * @return string|null |
| 101 | 101 | */ |
| 102 | 102 | function calculer_url_redirect_entite($type, $id, $var_mode) { |
| 103 | - $desc = null; |
|
| 104 | - $publie = null; |
|
| 105 | - $url = null; |
|
| 106 | - // invalider le cache à chaque modif en bdd |
|
| 107 | - $date = 0; |
|
| 108 | - if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | - $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | - } |
|
| 111 | - $key = "url-$date-$type-$id"; |
|
| 103 | + $desc = null; |
|
| 104 | + $publie = null; |
|
| 105 | + $url = null; |
|
| 106 | + // invalider le cache à chaque modif en bdd |
|
| 107 | + $date = 0; |
|
| 108 | + if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | + $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | + } |
|
| 111 | + $key = "url-$date-$type-$id"; |
|
| 112 | 112 | |
| 113 | - // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | - if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | - [$url, $publie] = $desc; |
|
| 116 | - } |
|
| 117 | - // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | - if (empty($desc) or $var_mode) { |
|
| 119 | - $publie = objet_test_si_publie($type, $id); |
|
| 120 | - $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | - if (function_exists('cache_set')) { |
|
| 122 | - cache_set($key, [$url, $publie], 3600); |
|
| 123 | - } |
|
| 124 | - } |
|
| 113 | + // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | + if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | + [$url, $publie] = $desc; |
|
| 116 | + } |
|
| 117 | + // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | + if (empty($desc) or $var_mode) { |
|
| 119 | + $publie = objet_test_si_publie($type, $id); |
|
| 120 | + $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | + if (function_exists('cache_set')) { |
|
| 122 | + cache_set($key, [$url, $publie], 3600); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | - if ($publie) { |
|
| 128 | - return $url; |
|
| 129 | - } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | - return $url; |
|
| 131 | - } |
|
| 126 | + // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | + if ($publie) { |
|
| 128 | + return $url; |
|
| 129 | + } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | + return $url; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return; |
|
| 133 | + return; |
|
| 134 | 134 | } |
@@ -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 | include_spip('inc/charsets'); |
| 17 | 17 | |
@@ -27,90 +27,90 @@ discard block |
||
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | 29 | function plugins_afficher_liste_dist( |
| 30 | - $url_page, |
|
| 31 | - $liste_plugins, |
|
| 32 | - $liste_plugins_checked, |
|
| 33 | - $liste_plugins_actifs, |
|
| 34 | - $dir_plugins = _DIR_PLUGINS, |
|
| 35 | - $afficher_un = 'afficher_plugin' |
|
| 30 | + $url_page, |
|
| 31 | + $liste_plugins, |
|
| 32 | + $liste_plugins_checked, |
|
| 33 | + $liste_plugins_actifs, |
|
| 34 | + $dir_plugins = _DIR_PLUGINS, |
|
| 35 | + $afficher_un = 'afficher_plugin' |
|
| 36 | 36 | ) { |
| 37 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 38 | - $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 37 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 38 | + $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 39 | 39 | |
| 40 | - $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 40 | + $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 41 | 41 | |
| 42 | - $all_infos = pipeline( |
|
| 43 | - 'filtrer_liste_plugins', |
|
| 44 | - [ |
|
| 45 | - 'args' => [ |
|
| 46 | - 'liste_plugins' => $liste_plugins, |
|
| 47 | - 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | - 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | - 'dir_plugins' => $dir_plugins |
|
| 50 | - ], |
|
| 51 | - 'data' => $all_infos |
|
| 52 | - ] |
|
| 53 | - ); |
|
| 42 | + $all_infos = pipeline( |
|
| 43 | + 'filtrer_liste_plugins', |
|
| 44 | + [ |
|
| 45 | + 'args' => [ |
|
| 46 | + 'liste_plugins' => $liste_plugins, |
|
| 47 | + 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | + 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | + 'dir_plugins' => $dir_plugins |
|
| 50 | + ], |
|
| 51 | + 'data' => $all_infos |
|
| 52 | + ] |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - $liste_plugins = array_flip($liste_plugins); |
|
| 56 | - foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | - // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | - if (isset($all_infos[$chemin])) { |
|
| 59 | - $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | - } else { |
|
| 61 | - unset($liste_plugins[$chemin]); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - asort($liste_plugins); |
|
| 65 | - $exposed = urldecode(_request('plugin') ?? ''); |
|
| 55 | + $liste_plugins = array_flip($liste_plugins); |
|
| 56 | + foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | + // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | + if (isset($all_infos[$chemin])) { |
|
| 59 | + $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | + } else { |
|
| 61 | + unset($liste_plugins[$chemin]); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + asort($liste_plugins); |
|
| 65 | + $exposed = urldecode(_request('plugin') ?? ''); |
|
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | - $fast_liste_plugins_actifs = []; |
|
| 69 | - $fast_liste_plugins_checked = []; |
|
| 70 | - if (is_array($liste_plugins_actifs)) { |
|
| 71 | - $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | - } |
|
| 73 | - if (is_array($liste_plugins_checked)) { |
|
| 74 | - $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | - } |
|
| 67 | + $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | + $fast_liste_plugins_actifs = []; |
|
| 69 | + $fast_liste_plugins_checked = []; |
|
| 70 | + if (is_array($liste_plugins_actifs)) { |
|
| 71 | + $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | + } |
|
| 73 | + if (is_array($liste_plugins_checked)) { |
|
| 74 | + $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $res = ''; |
|
| 78 | - $block = ''; |
|
| 79 | - $initiale = ''; |
|
| 80 | - $block_actif = false; |
|
| 81 | - foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | - if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | - $initiale = $i; |
|
| 85 | - $block = ''; |
|
| 86 | - $block_actif = false; |
|
| 87 | - } |
|
| 88 | - // le rep suivant |
|
| 89 | - $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | - $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | - $block_actif = $block_actif | $actif; |
|
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 93 | - $dir_plugins, |
|
| 94 | - strlen(_DIR_RACINE) |
|
| 95 | - ) . $plug)); |
|
| 96 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 97 | - } |
|
| 98 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 99 | - $class = basename($dir_plugins); |
|
| 77 | + $res = ''; |
|
| 78 | + $block = ''; |
|
| 79 | + $initiale = ''; |
|
| 80 | + $block_actif = false; |
|
| 81 | + foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | + if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | + $initiale = $i; |
|
| 85 | + $block = ''; |
|
| 86 | + $block_actif = false; |
|
| 87 | + } |
|
| 88 | + // le rep suivant |
|
| 89 | + $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | + $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | + $block_actif = $block_actif | $actif; |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 93 | + $dir_plugins, |
|
| 94 | + strlen(_DIR_RACINE) |
|
| 95 | + ) . $plug)); |
|
| 96 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 97 | + } |
|
| 98 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 99 | + $class = basename($dir_plugins); |
|
| 100 | 100 | |
| 101 | - return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 101 | + return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | function affiche_block_initiale($initiale, $block, $block_actif) { |
| 106 | - if (strlen($block)) { |
|
| 107 | - return "<li class='item'>" |
|
| 108 | - . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 109 | - . debut_block_depliable($block_actif) |
|
| 110 | - . "<ul>$block</ul>" |
|
| 111 | - . fin_block() |
|
| 112 | - . '</li>'; |
|
| 113 | - } |
|
| 106 | + if (strlen($block)) { |
|
| 107 | + return "<li class='item'>" |
|
| 108 | + . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 109 | + . debut_block_depliable($block_actif) |
|
| 110 | + . "<ul>$block</ul>" |
|
| 111 | + . fin_block() |
|
| 112 | + . '</li>'; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - return ''; |
|
| 115 | + return ''; |
|
| 116 | 116 | } |
@@ -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 (!$code) { |
|
| 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 (!$code) { |
|
| 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 | } |