@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('public/decompiler'); |
@@ -69,118 +69,118 @@ discard block |
||
| 69 | 69 | * - true si $opt 'erreurs' = 'reset' |
| 70 | 70 | **/ |
| 71 | 71 | function public_debusquer_dist($message = '', $lieu = '', $opt = []) { |
| 72 | - static $tableau_des_erreurs = []; |
|
| 73 | - |
|
| 74 | - // Pour des tests unitaires, pouvoir récupérer les erreurs générées |
|
| 75 | - if (isset($opt['erreurs'])) { |
|
| 76 | - if ($opt['erreurs'] == 'get') { |
|
| 77 | - return $tableau_des_erreurs; |
|
| 78 | - } |
|
| 79 | - if ($opt['erreurs'] == 'reset') { |
|
| 80 | - $tableau_des_erreurs = []; |
|
| 81 | - |
|
| 82 | - return true; |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - // Erreur ou appel final ? |
|
| 87 | - if ($message) { |
|
| 88 | - $message = debusquer_compose_message($message); |
|
| 89 | - $tableau_des_erreurs[] = [$message, $lieu]; |
|
| 90 | - set_request('var_mode', 'debug'); |
|
| 91 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 92 | - // Permettre a la compil de continuer |
|
| 93 | - if (is_object($lieu) && (!isset($lieu->code) || !$lieu->code)) { |
|
| 94 | - $lieu->code = "''"; |
|
| 95 | - } |
|
| 96 | - // loger |
|
| 97 | - debusquer_loger_erreur($message, $lieu); |
|
| 98 | - // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 99 | - $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS && (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 100 | - if (!$urgence) { |
|
| 101 | - return; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - // espace public ? |
|
| 105 | - if (empty($GLOBALS['debug_objets']['principal']) && isset($GLOBALS['fond'])) { |
|
| 106 | - $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - include_spip('inc/autoriser'); |
|
| 110 | - if (!autoriser('debug')) { |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - include_spip('inc/headers'); |
|
| 114 | - include_spip('inc/filtres'); |
|
| 115 | - |
|
| 116 | - lang_select($GLOBALS['visiteur_session']['lang'] ?? null); |
|
| 117 | - $fonc = preg_replace(',\W,', '_', _request('var_mode_objet') ?? ''); |
|
| 118 | - $mode = preg_replace(',\W,', '_', _request('var_mode_affiche') ?? ''); |
|
| 119 | - |
|
| 120 | - $self = str_replace("\\'", ''', (string) self()); |
|
| 121 | - $self = parametre_url($self, 'var_mode', 'debug'); |
|
| 122 | - |
|
| 123 | - $res = debusquer_bandeau($tableau_des_erreurs) |
|
| 124 | - . '<br />' |
|
| 125 | - . debusquer_squelette($fonc, $mode, $self); |
|
| 126 | - |
|
| 127 | - if (!_DIR_RESTREINT || headers_sent()) { |
|
| 128 | - return $res; |
|
| 129 | - } |
|
| 130 | - if ($tableau_des_erreurs) { |
|
| 131 | - http_response_code(503); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - http_no_cache(); |
|
| 135 | - if (isset($_GET['var_profile'])) { |
|
| 136 | - $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
|
| 137 | - $titre = parametre_url($titre, 'var_mode', ''); |
|
| 138 | - } else { |
|
| 139 | - if (!$fonc) { |
|
| 140 | - $fonc = $GLOBALS['debug_objets']['principal']; |
|
| 141 | - } |
|
| 142 | - $titre = $mode ? $mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '') : ($fonc); |
|
| 143 | - } |
|
| 144 | - if ($message === false) { |
|
| 145 | - lang_select(); |
|
| 146 | - |
|
| 147 | - return debusquer_entete($titre, $res); |
|
| 148 | - } else { |
|
| 149 | - echo debusquer_entete($titre, $res); |
|
| 150 | - } |
|
| 151 | - exit; |
|
| 72 | + static $tableau_des_erreurs = []; |
|
| 73 | + |
|
| 74 | + // Pour des tests unitaires, pouvoir récupérer les erreurs générées |
|
| 75 | + if (isset($opt['erreurs'])) { |
|
| 76 | + if ($opt['erreurs'] == 'get') { |
|
| 77 | + return $tableau_des_erreurs; |
|
| 78 | + } |
|
| 79 | + if ($opt['erreurs'] == 'reset') { |
|
| 80 | + $tableau_des_erreurs = []; |
|
| 81 | + |
|
| 82 | + return true; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // Erreur ou appel final ? |
|
| 87 | + if ($message) { |
|
| 88 | + $message = debusquer_compose_message($message); |
|
| 89 | + $tableau_des_erreurs[] = [$message, $lieu]; |
|
| 90 | + set_request('var_mode', 'debug'); |
|
| 91 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 92 | + // Permettre a la compil de continuer |
|
| 93 | + if (is_object($lieu) && (!isset($lieu->code) || !$lieu->code)) { |
|
| 94 | + $lieu->code = "''"; |
|
| 95 | + } |
|
| 96 | + // loger |
|
| 97 | + debusquer_loger_erreur($message, $lieu); |
|
| 98 | + // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 99 | + $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS && (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 100 | + if (!$urgence) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + // espace public ? |
|
| 105 | + if (empty($GLOBALS['debug_objets']['principal']) && isset($GLOBALS['fond'])) { |
|
| 106 | + $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + include_spip('inc/autoriser'); |
|
| 110 | + if (!autoriser('debug')) { |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + include_spip('inc/headers'); |
|
| 114 | + include_spip('inc/filtres'); |
|
| 115 | + |
|
| 116 | + lang_select($GLOBALS['visiteur_session']['lang'] ?? null); |
|
| 117 | + $fonc = preg_replace(',\W,', '_', _request('var_mode_objet') ?? ''); |
|
| 118 | + $mode = preg_replace(',\W,', '_', _request('var_mode_affiche') ?? ''); |
|
| 119 | + |
|
| 120 | + $self = str_replace("\\'", ''', (string) self()); |
|
| 121 | + $self = parametre_url($self, 'var_mode', 'debug'); |
|
| 122 | + |
|
| 123 | + $res = debusquer_bandeau($tableau_des_erreurs) |
|
| 124 | + . '<br />' |
|
| 125 | + . debusquer_squelette($fonc, $mode, $self); |
|
| 126 | + |
|
| 127 | + if (!_DIR_RESTREINT || headers_sent()) { |
|
| 128 | + return $res; |
|
| 129 | + } |
|
| 130 | + if ($tableau_des_erreurs) { |
|
| 131 | + http_response_code(503); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + http_no_cache(); |
|
| 135 | + if (isset($_GET['var_profile'])) { |
|
| 136 | + $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
|
| 137 | + $titre = parametre_url($titre, 'var_mode', ''); |
|
| 138 | + } else { |
|
| 139 | + if (!$fonc) { |
|
| 140 | + $fonc = $GLOBALS['debug_objets']['principal']; |
|
| 141 | + } |
|
| 142 | + $titre = $mode ? $mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '') : ($fonc); |
|
| 143 | + } |
|
| 144 | + if ($message === false) { |
|
| 145 | + lang_select(); |
|
| 146 | + |
|
| 147 | + return debusquer_entete($titre, $res); |
|
| 148 | + } else { |
|
| 149 | + echo debusquer_entete($titre, $res); |
|
| 150 | + } |
|
| 151 | + exit; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function debusquer_compose_message($msg) { |
| 155 | - if (is_array($msg)) { |
|
| 156 | - // si c'est un texte, c'est une traduction a faire, mais |
|
| 157 | - // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
|
| 158 | - $msg = !is_numeric($msg[0]) && count($msg) == 2 ? _T($msg[0], $msg[1], 'spip-debug-arg') : debusquer_requete($msg); |
|
| 159 | - } |
|
| 160 | - // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
|
| 161 | - // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
|
| 162 | - $fond = $GLOBALS['fond'] ?? ''; |
|
| 163 | - // une erreur critique sort $message en array |
|
| 164 | - $debug = is_array($msg) ? $msg[1] : $msg; |
|
| 165 | - spip_logger()->info('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 166 | - |
|
| 167 | - return $msg; |
|
| 155 | + if (is_array($msg)) { |
|
| 156 | + // si c'est un texte, c'est une traduction a faire, mais |
|
| 157 | + // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
|
| 158 | + $msg = !is_numeric($msg[0]) && count($msg) == 2 ? _T($msg[0], $msg[1], 'spip-debug-arg') : debusquer_requete($msg); |
|
| 159 | + } |
|
| 160 | + // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
|
| 161 | + // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
|
| 162 | + $fond = $GLOBALS['fond'] ?? ''; |
|
| 163 | + // une erreur critique sort $message en array |
|
| 164 | + $debug = is_array($msg) ? $msg[1] : $msg; |
|
| 165 | + spip_logger()->info('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 166 | + |
|
| 167 | + return $msg; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | function debusquer_bandeau($erreurs) { |
| 171 | 171 | |
| 172 | - if (!empty($erreurs)) { |
|
| 173 | - $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 172 | + if (!empty($erreurs)) { |
|
| 173 | + $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 174 | 174 | |
| 175 | - return debusquer_navigation($erreurs, $n); |
|
| 176 | - } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
|
| 177 | - include_spip('public/tracer'); |
|
| 178 | - [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']); |
|
| 175 | + return debusquer_navigation($erreurs, $n); |
|
| 176 | + } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
|
| 177 | + include_spip('public/tracer'); |
|
| 178 | + [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']); |
|
| 179 | 179 | |
| 180 | - return debusquer_navigation($temps, $nav, 'debug-profile'); |
|
| 181 | - } else { |
|
| 182 | - return ''; |
|
| 183 | - } |
|
| 180 | + return debusquer_navigation($temps, $nav, 'debug-profile'); |
|
| 181 | + } else { |
|
| 182 | + return ''; |
|
| 183 | + } |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -190,63 +190,63 @@ discard block |
||
| 190 | 190 | * @return string Code HTML |
| 191 | 191 | **/ |
| 192 | 192 | function debusquer_contexte($env) { |
| 193 | - if (is_string($env) && is_array($env_tab = @unserialize($env))) { |
|
| 194 | - $env = $env_tab; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - if (!$env) { |
|
| 198 | - return ''; |
|
| 199 | - } |
|
| 200 | - $res = ''; |
|
| 201 | - foreach ($env as $nom => $valeur) { |
|
| 202 | - if (is_array($valeur)) { |
|
| 203 | - $valeur_simple = []; |
|
| 204 | - foreach ($valeur as $v) { |
|
| 205 | - if (is_array($v)) { |
|
| 206 | - $valeur_simple[] = 'array:' . count($v); |
|
| 207 | - } elseif (is_object($v)) { |
|
| 208 | - $valeur_simple[] = $v::class; |
|
| 209 | - } elseif (is_string($v)) { |
|
| 210 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 211 | - } else { |
|
| 212 | - $valeur_simple[] = $v; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - $n = count($valeur); |
|
| 216 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 217 | - $valeur .= '[' . implode(', ', $valeur_simple) . ']'; |
|
| 218 | - } elseif (is_object($valeur)) { |
|
| 219 | - $valeur = $valeur::class; |
|
| 220 | - } elseif (is_string($valeur)) { |
|
| 221 | - $valeur = "'" . $valeur . "'"; |
|
| 222 | - } |
|
| 223 | - $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 224 | - . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 225 | - . "</td></tr>\n"; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 193 | + if (is_string($env) && is_array($env_tab = @unserialize($env))) { |
|
| 194 | + $env = $env_tab; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + if (!$env) { |
|
| 198 | + return ''; |
|
| 199 | + } |
|
| 200 | + $res = ''; |
|
| 201 | + foreach ($env as $nom => $valeur) { |
|
| 202 | + if (is_array($valeur)) { |
|
| 203 | + $valeur_simple = []; |
|
| 204 | + foreach ($valeur as $v) { |
|
| 205 | + if (is_array($v)) { |
|
| 206 | + $valeur_simple[] = 'array:' . count($v); |
|
| 207 | + } elseif (is_object($v)) { |
|
| 208 | + $valeur_simple[] = $v::class; |
|
| 209 | + } elseif (is_string($v)) { |
|
| 210 | + $valeur_simple[] = "'" . $v . "'"; |
|
| 211 | + } else { |
|
| 212 | + $valeur_simple[] = $v; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + $n = count($valeur); |
|
| 216 | + $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 217 | + $valeur .= '[' . implode(', ', $valeur_simple) . ']'; |
|
| 218 | + } elseif (is_object($valeur)) { |
|
| 219 | + $valeur = $valeur::class; |
|
| 220 | + } elseif (is_string($valeur)) { |
|
| 221 | + $valeur = "'" . $valeur . "'"; |
|
| 222 | + } |
|
| 223 | + $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 224 | + . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 225 | + . "</td></tr>\n"; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | |
| 232 | 232 | function debusquer_loger_erreur($msg, $lieu) { |
| 233 | - $boucle = $ligne = $skel = ''; |
|
| 234 | - if (is_object($lieu)) { |
|
| 235 | - $ligne = ($lieu->ligne ?? ''); |
|
| 236 | - $boucle = ($lieu->id_boucle ?? ''); |
|
| 237 | - $skel = ($lieu->descr['sourcefile'] ?? ''); |
|
| 238 | - } |
|
| 239 | - $msg = (is_array($msg) ? implode('', $msg) : $msg); |
|
| 240 | - if ($skel) { |
|
| 241 | - $msg .= " Squelette $skel"; |
|
| 242 | - } |
|
| 243 | - if ($boucle) { |
|
| 244 | - $msg .= " Boucle $boucle"; |
|
| 245 | - } |
|
| 246 | - if ($ligne) { |
|
| 247 | - $msg .= " L$ligne"; |
|
| 248 | - } |
|
| 249 | - spip_logger('debusquer')->error($msg); |
|
| 233 | + $boucle = $ligne = $skel = ''; |
|
| 234 | + if (is_object($lieu)) { |
|
| 235 | + $ligne = ($lieu->ligne ?? ''); |
|
| 236 | + $boucle = ($lieu->id_boucle ?? ''); |
|
| 237 | + $skel = ($lieu->descr['sourcefile'] ?? ''); |
|
| 238 | + } |
|
| 239 | + $msg = (is_array($msg) ? implode('', $msg) : $msg); |
|
| 240 | + if ($skel) { |
|
| 241 | + $msg .= " Squelette $skel"; |
|
| 242 | + } |
|
| 243 | + if ($boucle) { |
|
| 244 | + $msg .= " Boucle $boucle"; |
|
| 245 | + } |
|
| 246 | + if ($ligne) { |
|
| 247 | + $msg .= " L$ligne"; |
|
| 248 | + } |
|
| 249 | + spip_logger('debusquer')->error($msg); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
@@ -255,66 +255,66 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | function debusquer_navigation($tableau, $caption = [], $id = 'debug-nav') { |
| 257 | 257 | |
| 258 | - if (_request('exec') == 'valider_xml') { |
|
| 259 | - return ''; |
|
| 260 | - } |
|
| 261 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 262 | - $res = ''; |
|
| 263 | - $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 264 | - foreach ($tableau as $i => $err) { |
|
| 265 | - $boucle = $ligne = $skel = ''; |
|
| 266 | - [$msg, $lieu] = $err; |
|
| 267 | - if (is_object($lieu)) { |
|
| 268 | - $ligne = $lieu->ligne; |
|
| 269 | - $boucle = empty($lieu->id_boucle) ? '' : $lieu->id_boucle; |
|
| 270 | - if (isset($lieu->descr['nom'])) { |
|
| 271 | - $nom_code = $lieu->descr['nom']; |
|
| 272 | - $skel = $lieu->descr['sourcefile']; |
|
| 273 | - $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 274 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 275 | - $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 276 | - if ($boucle) { |
|
| 277 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 278 | - $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 279 | - } |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - $j = ($i + 1); |
|
| 284 | - $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 285 | - . $j |
|
| 286 | - . " </td><td style='text-align: left'>" |
|
| 287 | - . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 288 | - . "</td><td style='text-align: left'>" |
|
| 289 | - . ($skel ?: ' / ') |
|
| 290 | - . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 291 | - . ($boucle ?: ' / ') |
|
| 292 | - . "</td><td style='text-align: right'>" |
|
| 293 | - . $ligne |
|
| 294 | - . "</td></tr>\n"; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - return "\n<table id='$id'>" |
|
| 298 | - . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 299 | - . $caption[0] |
|
| 258 | + if (_request('exec') == 'valider_xml') { |
|
| 259 | + return ''; |
|
| 260 | + } |
|
| 261 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 262 | + $res = ''; |
|
| 263 | + $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 264 | + foreach ($tableau as $i => $err) { |
|
| 265 | + $boucle = $ligne = $skel = ''; |
|
| 266 | + [$msg, $lieu] = $err; |
|
| 267 | + if (is_object($lieu)) { |
|
| 268 | + $ligne = $lieu->ligne; |
|
| 269 | + $boucle = empty($lieu->id_boucle) ? '' : $lieu->id_boucle; |
|
| 270 | + if (isset($lieu->descr['nom'])) { |
|
| 271 | + $nom_code = $lieu->descr['nom']; |
|
| 272 | + $skel = $lieu->descr['sourcefile']; |
|
| 273 | + $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 274 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 275 | + $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 276 | + if ($boucle) { |
|
| 277 | + $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 278 | + $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + $j = ($i + 1); |
|
| 284 | + $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 285 | + . $j |
|
| 286 | + . " </td><td style='text-align: left'>" |
|
| 287 | + . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 288 | + . "</td><td style='text-align: left'>" |
|
| 289 | + . ($skel ?: ' / ') |
|
| 290 | + . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 291 | + . ($boucle ?: ' / ') |
|
| 292 | + . "</td><td style='text-align: right'>" |
|
| 293 | + . $ligne |
|
| 294 | + . "</td></tr>\n"; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + return "\n<table id='$id'>" |
|
| 298 | + . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 299 | + . $caption[0] |
|
| 300 | 300 | ## aide locale courte a ecrire, avec lien vers une grosse page de documentation |
| 301 | 301 | # aider('erreur_compilation'), |
| 302 | - . '</caption>' |
|
| 303 | - // fausse caption du chrono (mais vraie nav) |
|
| 304 | - . (empty($caption[1]) ? '' : $caption[1]) |
|
| 305 | - . '<tr><th>' |
|
| 306 | - . _T('numero') |
|
| 307 | - . '</th><th>' |
|
| 308 | - . _T('public:message') |
|
| 309 | - . '</th><th>' |
|
| 310 | - . _T('squelette') |
|
| 311 | - . '</th><th>' |
|
| 312 | - . _T('zbug_boucle') |
|
| 313 | - . '</th><th>' |
|
| 314 | - . _T('ligne') |
|
| 315 | - . '</th></tr>' |
|
| 316 | - . $res |
|
| 317 | - . '</table>'; |
|
| 302 | + . '</caption>' |
|
| 303 | + // fausse caption du chrono (mais vraie nav) |
|
| 304 | + . (empty($caption[1]) ? '' : $caption[1]) |
|
| 305 | + . '<tr><th>' |
|
| 306 | + . _T('numero') |
|
| 307 | + . '</th><th>' |
|
| 308 | + . _T('public:message') |
|
| 309 | + . '</th><th>' |
|
| 310 | + . _T('squelette') |
|
| 311 | + . '</th><th>' |
|
| 312 | + . _T('zbug_boucle') |
|
| 313 | + . '</th><th>' |
|
| 314 | + . _T('ligne') |
|
| 315 | + . '</th></tr>' |
|
| 316 | + . $res |
|
| 317 | + . '</table>'; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | |
@@ -334,518 +334,518 @@ discard block |
||
| 334 | 334 | * ou un tableau si l'erreur est critique |
| 335 | 335 | **/ |
| 336 | 336 | function debusquer_requete($message) { |
| 337 | - [$errno, $msg, $query] = $message; |
|
| 338 | - |
|
| 339 | - // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 340 | - // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 341 | - if (preg_match(',err(no|code):?[[:space:]]*(\d+),i', (string) $msg, $regs)) { |
|
| 342 | - $errno = $regs[2]; |
|
| 343 | - } elseif ( |
|
| 344 | - is_numeric($errno) && ($errno == 1030 || $errno <= 1026) |
|
| 345 | - && preg_match(',[^[:alnum:]](\d+)[^[:alnum:]],', (string) $msg, $regs) |
|
| 346 | - ) { |
|
| 347 | - $errno = $regs[1]; |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - // Erreur systeme |
|
| 351 | - if (is_numeric($errno) && $errno > 0 && $errno < 200) { |
|
| 352 | - $retour = '<tt><br /><br /><blink>' |
|
| 353 | - . _T('info_erreur_systeme', ['errsys' => $errno]) |
|
| 354 | - . "</blink><br />\n<b>" |
|
| 355 | - . _T( |
|
| 356 | - 'info_erreur_systeme2', |
|
| 357 | - ['script' => generer_url_ecrire('base_repair')] |
|
| 358 | - ) |
|
| 359 | - . '</b><br />'; |
|
| 360 | - spip_logger()->info("Erreur systeme $errno"); |
|
| 361 | - |
|
| 362 | - return [$retour, '']; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - // Requete erronee |
|
| 366 | - $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 367 | - . spip_htmlspecialchars($msg) |
|
| 368 | - . "\n<br /><span style='color: red'><b>" |
|
| 369 | - . spip_htmlspecialchars($query) |
|
| 370 | - . '</b></span></tt><br />'; |
|
| 371 | - |
|
| 372 | - //. aider('erreur_mysql'); |
|
| 373 | - |
|
| 374 | - return $err; |
|
| 337 | + [$errno, $msg, $query] = $message; |
|
| 338 | + |
|
| 339 | + // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 340 | + // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 341 | + if (preg_match(',err(no|code):?[[:space:]]*(\d+),i', (string) $msg, $regs)) { |
|
| 342 | + $errno = $regs[2]; |
|
| 343 | + } elseif ( |
|
| 344 | + is_numeric($errno) && ($errno == 1030 || $errno <= 1026) |
|
| 345 | + && preg_match(',[^[:alnum:]](\d+)[^[:alnum:]],', (string) $msg, $regs) |
|
| 346 | + ) { |
|
| 347 | + $errno = $regs[1]; |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + // Erreur systeme |
|
| 351 | + if (is_numeric($errno) && $errno > 0 && $errno < 200) { |
|
| 352 | + $retour = '<tt><br /><br /><blink>' |
|
| 353 | + . _T('info_erreur_systeme', ['errsys' => $errno]) |
|
| 354 | + . "</blink><br />\n<b>" |
|
| 355 | + . _T( |
|
| 356 | + 'info_erreur_systeme2', |
|
| 357 | + ['script' => generer_url_ecrire('base_repair')] |
|
| 358 | + ) |
|
| 359 | + . '</b><br />'; |
|
| 360 | + spip_logger()->info("Erreur systeme $errno"); |
|
| 361 | + |
|
| 362 | + return [$retour, '']; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + // Requete erronee |
|
| 366 | + $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 367 | + . spip_htmlspecialchars($msg) |
|
| 368 | + . "\n<br /><span style='color: red'><b>" |
|
| 369 | + . spip_htmlspecialchars($query) |
|
| 370 | + . '</b></span></tt><br />'; |
|
| 371 | + |
|
| 372 | + //. aider('erreur_mysql'); |
|
| 373 | + |
|
| 374 | + return $err; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | |
| 378 | 378 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') { |
| 379 | 379 | |
| 380 | - $id = $nom . $boucle; |
|
| 381 | - if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 382 | - foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 383 | - if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', (string) $v[0], $r)) { |
|
| 384 | - $y = substr_count((string) $v[0], "\n"); |
|
| 385 | - } else { |
|
| 386 | - if ($v[1][0] == '#') { // balise dynamique |
|
| 387 | - $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 388 | - } else // inclusion |
|
| 389 | - { |
|
| 390 | - $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 391 | - } |
|
| 392 | - $y = substr_count((string) $incl, "\n") |
|
| 393 | - + substr_count($r[1], "\n") |
|
| 394 | - + substr_count($r[3], "\n"); |
|
| 395 | - } |
|
| 396 | - if ($n <= ($y + $debut)) { |
|
| 397 | - if ($v[1][0] == '?') { |
|
| 398 | - return trouve_boucle_debug($n, $nom, $debut, substr((string) $v[1], 1)); |
|
| 399 | - } elseif ($v[1][0] == '!') { |
|
| 400 | - if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 401 | - return trouve_boucle_debug($n, $incl, $debut); |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - return [$nom, $boucle, $v[2] - 1 + $n - $debut]; |
|
| 406 | - } |
|
| 407 | - $debut += $y; |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - return [$nom, $boucle, $n - $debut]; |
|
| 380 | + $id = $nom . $boucle; |
|
| 381 | + if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 382 | + foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 383 | + if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', (string) $v[0], $r)) { |
|
| 384 | + $y = substr_count((string) $v[0], "\n"); |
|
| 385 | + } else { |
|
| 386 | + if ($v[1][0] == '#') { // balise dynamique |
|
| 387 | + $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 388 | + } else // inclusion |
|
| 389 | + { |
|
| 390 | + $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 391 | + } |
|
| 392 | + $y = substr_count((string) $incl, "\n") |
|
| 393 | + + substr_count($r[1], "\n") |
|
| 394 | + + substr_count($r[3], "\n"); |
|
| 395 | + } |
|
| 396 | + if ($n <= ($y + $debut)) { |
|
| 397 | + if ($v[1][0] == '?') { |
|
| 398 | + return trouve_boucle_debug($n, $nom, $debut, substr((string) $v[1], 1)); |
|
| 399 | + } elseif ($v[1][0] == '!') { |
|
| 400 | + if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 401 | + return trouve_boucle_debug($n, $incl, $debut); |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + return [$nom, $boucle, $v[2] - 1 + $n - $debut]; |
|
| 406 | + } |
|
| 407 | + $debut += $y; |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + return [$nom, $boucle, $n - $debut]; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | function trouve_squelette_inclus($script) { |
| 415 | 415 | |
| 416 | - preg_match('/include\(.(.*).php3?.\);/', (string) $script, $reg); |
|
| 417 | - // si le script X.php n'est pas ecrire/public.php |
|
| 418 | - // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 419 | - // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 420 | - // a defaut on cherche le param 'page' |
|
| 421 | - if ( |
|
| 422 | - $reg[1] == 'ecrire/public' |
|
| 423 | - && !preg_match("/'fond' => '([^']*)'/", (string) $script, $reg) |
|
| 424 | - && !preg_match("/'param' => '([^']*)'/", (string) $script, $reg) |
|
| 425 | - ) { |
|
| 426 | - $reg[1] = 'inconnu'; |
|
| 427 | - } |
|
| 428 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 429 | - |
|
| 430 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 431 | - if (preg_match($incl, (string) $v)) { |
|
| 432 | - return $k; |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - return ''; |
|
| 416 | + preg_match('/include\(.(.*).php3?.\);/', (string) $script, $reg); |
|
| 417 | + // si le script X.php n'est pas ecrire/public.php |
|
| 418 | + // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 419 | + // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 420 | + // a defaut on cherche le param 'page' |
|
| 421 | + if ( |
|
| 422 | + $reg[1] == 'ecrire/public' |
|
| 423 | + && !preg_match("/'fond' => '([^']*)'/", (string) $script, $reg) |
|
| 424 | + && !preg_match("/'param' => '([^']*)'/", (string) $script, $reg) |
|
| 425 | + ) { |
|
| 426 | + $reg[1] = 'inconnu'; |
|
| 427 | + } |
|
| 428 | + $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 429 | + |
|
| 430 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 431 | + if (preg_match($incl, (string) $v)) { |
|
| 432 | + return $k; |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + return ''; |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | function reference_boucle_debug($n, $nom, $self) { |
| 440 | - [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
|
| 441 | - |
|
| 442 | - if (!$boucle) { |
|
| 443 | - return $ligne |
|
| 444 | - ? ' (' . |
|
| 445 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 446 | - _T('squelette_ligne')) . |
|
| 447 | - " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)" |
|
| 448 | - : ''; |
|
| 449 | - } else { |
|
| 450 | - $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 451 | - |
|
| 452 | - return $ligne ? " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)" : |
|
| 453 | - " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)"; |
|
| 454 | - } |
|
| 440 | + [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
|
| 441 | + |
|
| 442 | + if (!$boucle) { |
|
| 443 | + return $ligne |
|
| 444 | + ? ' (' . |
|
| 445 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 446 | + _T('squelette_ligne')) . |
|
| 447 | + " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)" |
|
| 448 | + : ''; |
|
| 449 | + } else { |
|
| 450 | + $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 451 | + |
|
| 452 | + return $ligne ? " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)" : |
|
| 453 | + " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)"; |
|
| 454 | + } |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | // affiche un texte avec numero de ligne et ancre. |
| 458 | 458 | |
| 459 | 459 | function ancre_texte($texte, $fautifs = [], $nocpt = false) { |
| 460 | 460 | |
| 461 | - $var_mode_ligne = _request('var_mode_ligne'); |
|
| 462 | - if ($var_mode_ligne) { |
|
| 463 | - $fautifs[] = [$var_mode_ligne]; |
|
| 464 | - } |
|
| 465 | - $res = ''; |
|
| 466 | - |
|
| 467 | - $s = highlight_string($texte, true); |
|
| 468 | - if (str_starts_with($s, '<code>')) { |
|
| 469 | - $s = substr($s, 6); |
|
| 470 | - $res = '<code>'; |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - $s = preg_replace( |
|
| 474 | - ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 475 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 476 | - $s |
|
| 477 | - ); |
|
| 478 | - |
|
| 479 | - |
|
| 480 | - $tableau = explode('<br />', $s); |
|
| 481 | - |
|
| 482 | - $format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . (string) @strlen(count($tableau)) . "d</a></span> %s<br />\n"; |
|
| 483 | - |
|
| 484 | - $format10 = str_replace('white', 'lightgrey', $format); |
|
| 485 | - $formaterr = 'color: red;'; |
|
| 486 | - $i = 1; |
|
| 487 | - $flignes = []; |
|
| 488 | - $loc = [0, 0]; |
|
| 489 | - foreach ($fautifs as $lc) { |
|
| 490 | - if (is_array($lc)) { |
|
| 491 | - $l = array_shift($lc); |
|
| 492 | - $flignes[$l] = $lc; |
|
| 493 | - } else { |
|
| 494 | - $flignes[$lc] = $loc; |
|
| 495 | - } |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - $ancre = md5((string) $texte); |
|
| 499 | - foreach ($tableau as $ligne) { |
|
| 500 | - if (isset($flignes[$i])) { |
|
| 501 | - $ligne = str_replace(' ', ' ', $ligne); |
|
| 502 | - $indexmesg = $flignes[$i][1]; |
|
| 503 | - $err = textebrut($flignes[$i][2]); |
|
| 504 | - // tentative de pointer sur la colonne fautive; |
|
| 505 | - // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 506 | - // $m = $flignes[$i][0]; |
|
| 507 | - // $ligne = substr($ligne, 0, $m-1) . |
|
| 508 | - // sprintf($formaterr, substr($ligne,$m)); |
|
| 509 | - $bg = $formaterr; |
|
| 510 | - } else { |
|
| 511 | - $indexmesg = $ancre; |
|
| 512 | - $err = $bg = ''; |
|
| 513 | - } |
|
| 514 | - $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 515 | - $i++; |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - return "<div id='T$ancre'>" |
|
| 519 | - . '<div onclick="' |
|
| 520 | - . "jQuery(this).parent().find('a').toggle();" |
|
| 521 | - . '" title="' |
|
| 522 | - . _T('masquer_colonne') |
|
| 523 | - . '" style="cursor: pointer;">' |
|
| 524 | - . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 525 | - . '</div> |
|
| 461 | + $var_mode_ligne = _request('var_mode_ligne'); |
|
| 462 | + if ($var_mode_ligne) { |
|
| 463 | + $fautifs[] = [$var_mode_ligne]; |
|
| 464 | + } |
|
| 465 | + $res = ''; |
|
| 466 | + |
|
| 467 | + $s = highlight_string($texte, true); |
|
| 468 | + if (str_starts_with($s, '<code>')) { |
|
| 469 | + $s = substr($s, 6); |
|
| 470 | + $res = '<code>'; |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + $s = preg_replace( |
|
| 474 | + ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 475 | + '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 476 | + $s |
|
| 477 | + ); |
|
| 478 | + |
|
| 479 | + |
|
| 480 | + $tableau = explode('<br />', $s); |
|
| 481 | + |
|
| 482 | + $format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . (string) @strlen(count($tableau)) . "d</a></span> %s<br />\n"; |
|
| 483 | + |
|
| 484 | + $format10 = str_replace('white', 'lightgrey', $format); |
|
| 485 | + $formaterr = 'color: red;'; |
|
| 486 | + $i = 1; |
|
| 487 | + $flignes = []; |
|
| 488 | + $loc = [0, 0]; |
|
| 489 | + foreach ($fautifs as $lc) { |
|
| 490 | + if (is_array($lc)) { |
|
| 491 | + $l = array_shift($lc); |
|
| 492 | + $flignes[$l] = $lc; |
|
| 493 | + } else { |
|
| 494 | + $flignes[$lc] = $loc; |
|
| 495 | + } |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + $ancre = md5((string) $texte); |
|
| 499 | + foreach ($tableau as $ligne) { |
|
| 500 | + if (isset($flignes[$i])) { |
|
| 501 | + $ligne = str_replace(' ', ' ', $ligne); |
|
| 502 | + $indexmesg = $flignes[$i][1]; |
|
| 503 | + $err = textebrut($flignes[$i][2]); |
|
| 504 | + // tentative de pointer sur la colonne fautive; |
|
| 505 | + // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 506 | + // $m = $flignes[$i][0]; |
|
| 507 | + // $ligne = substr($ligne, 0, $m-1) . |
|
| 508 | + // sprintf($formaterr, substr($ligne,$m)); |
|
| 509 | + $bg = $formaterr; |
|
| 510 | + } else { |
|
| 511 | + $indexmesg = $ancre; |
|
| 512 | + $err = $bg = ''; |
|
| 513 | + } |
|
| 514 | + $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 515 | + $i++; |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + return "<div id='T$ancre'>" |
|
| 519 | + . '<div onclick="' |
|
| 520 | + . "jQuery(this).parent().find('a').toggle();" |
|
| 521 | + . '" title="' |
|
| 522 | + . _T('masquer_colonne') |
|
| 523 | + . '" style="cursor: pointer;">' |
|
| 524 | + . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 525 | + . '</div> |
|
| 526 | 526 | ' . $res . "</div>\n"; |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | // l'environnement graphique du debuggueur |
| 530 | 530 | |
| 531 | 531 | function debusquer_squelette($fonc, $mode, $self) { |
| 532 | - $legend = null; |
|
| 533 | - $texte = ''; |
|
| 534 | - |
|
| 535 | - if ($mode !== 'validation') { |
|
| 536 | - if (isset($GLOBALS['debug_objets']['sourcefile']) && $GLOBALS['debug_objets']['sourcefile']) { |
|
| 537 | - $res = "<div id='spip-boucles'>\n" |
|
| 538 | - . debusquer_navigation_squelettes($self) |
|
| 539 | - . '</div>'; |
|
| 540 | - } else { |
|
| 541 | - $res = ''; |
|
| 542 | - } |
|
| 543 | - if ($fonc) { |
|
| 544 | - $id = " id='$fonc'"; |
|
| 545 | - if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 546 | - [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
|
| 547 | - $texte .= $res2; |
|
| 548 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 549 | - $legend = _T('zbug_' . $mode); |
|
| 550 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 551 | - $texte = ancre_texte($texte, ['', '']); |
|
| 552 | - } |
|
| 553 | - } else { |
|
| 554 | - if (strlen(trim($res))) { |
|
| 555 | - return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 556 | - } else { |
|
| 557 | - // cas de l'appel sur erreur: montre la page |
|
| 558 | - return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
|
| 559 | - } |
|
| 560 | - } |
|
| 561 | - } else { |
|
| 562 | - $valider = charger_fonction('valider', 'xml'); |
|
| 563 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 564 | - // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 565 | - $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 566 | - [$texte, $err] = emboite_texte($val, $fonc, $self); |
|
| 567 | - if ($err === false) { |
|
| 568 | - $err = _T('impossible'); |
|
| 569 | - } elseif ($err === true) { |
|
| 570 | - $err = _T('correcte'); |
|
| 571 | - } else { |
|
| 572 | - $err = ": $err"; |
|
| 573 | - } |
|
| 574 | - $legend = _T('validation') . ' ' . $err; |
|
| 575 | - $res = $id = ''; |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - return trim((string) $texte) |
|
| 579 | - ? "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 580 | - . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 581 | - . "<a href='" . $self . '#f_' . substr((string) $fonc, 0, 37) . "'> ↑ " |
|
| 582 | - . ($legend ?: $mode) |
|
| 583 | - . '</a></legend>' |
|
| 584 | - . $texte |
|
| 585 | - . '</fieldset></div>' |
|
| 586 | - . '</div>' |
|
| 587 | - : ''; |
|
| 532 | + $legend = null; |
|
| 533 | + $texte = ''; |
|
| 534 | + |
|
| 535 | + if ($mode !== 'validation') { |
|
| 536 | + if (isset($GLOBALS['debug_objets']['sourcefile']) && $GLOBALS['debug_objets']['sourcefile']) { |
|
| 537 | + $res = "<div id='spip-boucles'>\n" |
|
| 538 | + . debusquer_navigation_squelettes($self) |
|
| 539 | + . '</div>'; |
|
| 540 | + } else { |
|
| 541 | + $res = ''; |
|
| 542 | + } |
|
| 543 | + if ($fonc) { |
|
| 544 | + $id = " id='$fonc'"; |
|
| 545 | + if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 546 | + [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
|
| 547 | + $texte .= $res2; |
|
| 548 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 549 | + $legend = _T('zbug_' . $mode); |
|
| 550 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 551 | + $texte = ancre_texte($texte, ['', '']); |
|
| 552 | + } |
|
| 553 | + } else { |
|
| 554 | + if (strlen(trim($res))) { |
|
| 555 | + return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 556 | + } else { |
|
| 557 | + // cas de l'appel sur erreur: montre la page |
|
| 558 | + return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
|
| 559 | + } |
|
| 560 | + } |
|
| 561 | + } else { |
|
| 562 | + $valider = charger_fonction('valider', 'xml'); |
|
| 563 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 564 | + // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 565 | + $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 566 | + [$texte, $err] = emboite_texte($val, $fonc, $self); |
|
| 567 | + if ($err === false) { |
|
| 568 | + $err = _T('impossible'); |
|
| 569 | + } elseif ($err === true) { |
|
| 570 | + $err = _T('correcte'); |
|
| 571 | + } else { |
|
| 572 | + $err = ": $err"; |
|
| 573 | + } |
|
| 574 | + $legend = _T('validation') . ' ' . $err; |
|
| 575 | + $res = $id = ''; |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + return trim((string) $texte) |
|
| 579 | + ? "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 580 | + . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 581 | + . "<a href='" . $self . '#f_' . substr((string) $fonc, 0, 37) . "'> ↑ " |
|
| 582 | + . ($legend ?: $mode) |
|
| 583 | + . '</a></legend>' |
|
| 584 | + . $texte |
|
| 585 | + . '</fieldset></div>' |
|
| 586 | + . '</div>' |
|
| 587 | + : ''; |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | |
| 591 | 591 | function emboite_texte($res, $fonc = '', $self = '') { |
| 592 | - $errs = $res->err; |
|
| 593 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 594 | - |
|
| 595 | - if (!$texte && !$errs) { |
|
| 596 | - return [ancre_texte('', ['', '']), false]; |
|
| 597 | - } |
|
| 598 | - if (!$errs) { |
|
| 599 | - return [ancre_texte($texte, ['', '']), true]; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - if (!isset($GLOBALS['debug_objets'])) { |
|
| 603 | - $colors = ['#e0e0f0', '#f8f8ff']; |
|
| 604 | - $encore = count_occ($errs); |
|
| 605 | - $encore2 = []; |
|
| 606 | - $fautifs = []; |
|
| 607 | - |
|
| 608 | - $err = '<tr><th>' |
|
| 609 | - . _T('numero') |
|
| 610 | - . '</th><th>' |
|
| 611 | - . _T('occurence') |
|
| 612 | - . '</th><th>' |
|
| 613 | - . _T('ligne') |
|
| 614 | - . '</th><th>' |
|
| 615 | - . _T('colonne') |
|
| 616 | - . '</th><th>' |
|
| 617 | - . _T('erreur') |
|
| 618 | - . '</th></tr>'; |
|
| 619 | - |
|
| 620 | - $i = 0; |
|
| 621 | - $style = "style='text-align: right; padding-right: 5px'"; |
|
| 622 | - foreach ($errs as $r) { |
|
| 623 | - $i++; |
|
| 624 | - [$msg, $ligne, $col] = $r; |
|
| 625 | - #spip_logger()->info("$r = [$msg, $ligne, $col]"); |
|
| 626 | - if (isset($encore2[$msg])) { |
|
| 627 | - $ref = ++$encore2[$msg]; |
|
| 628 | - } else { |
|
| 629 | - $encore2[$msg] = $ref = 1; |
|
| 630 | - } |
|
| 631 | - $err .= "<tr style='background-color: " |
|
| 632 | - . $colors[$i % 2] |
|
| 633 | - . "'><td $style><a href='#debut_err'>" |
|
| 634 | - . $i |
|
| 635 | - . "</a></td><td $style>" |
|
| 636 | - . "$ref/$encore[$msg]</td>" |
|
| 637 | - . "<td $style><a href='#L" |
|
| 638 | - . $ligne |
|
| 639 | - . "' id='T$i'>" |
|
| 640 | - . $ligne |
|
| 641 | - . "</a></td><td $style>" |
|
| 642 | - . $col |
|
| 643 | - . "</td><td>$msg</td></tr>\n"; |
|
| 644 | - $fautifs[] = [$ligne, $col, $i, $msg]; |
|
| 645 | - } |
|
| 646 | - $err = "<h2 style='text-align: center'>" |
|
| 647 | - . $i |
|
| 648 | - . "<a href='#fin_err'>" |
|
| 649 | - . ' ' . _T('erreur_texte') |
|
| 650 | - . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 651 | - . $err |
|
| 652 | - . " </table><a id='fin_err'></a>"; |
|
| 653 | - |
|
| 654 | - return [ancre_texte($texte, $fautifs), $err]; |
|
| 655 | - } else { |
|
| 656 | - [$msg, $fermant, $ouvrant] = $errs[0]; |
|
| 657 | - $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 658 | - $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 659 | - $err = $msg . |
|
| 660 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 661 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 662 | - |
|
| 663 | - return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
|
| 664 | - } |
|
| 592 | + $errs = $res->err; |
|
| 593 | + $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 594 | + |
|
| 595 | + if (!$texte && !$errs) { |
|
| 596 | + return [ancre_texte('', ['', '']), false]; |
|
| 597 | + } |
|
| 598 | + if (!$errs) { |
|
| 599 | + return [ancre_texte($texte, ['', '']), true]; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + if (!isset($GLOBALS['debug_objets'])) { |
|
| 603 | + $colors = ['#e0e0f0', '#f8f8ff']; |
|
| 604 | + $encore = count_occ($errs); |
|
| 605 | + $encore2 = []; |
|
| 606 | + $fautifs = []; |
|
| 607 | + |
|
| 608 | + $err = '<tr><th>' |
|
| 609 | + . _T('numero') |
|
| 610 | + . '</th><th>' |
|
| 611 | + . _T('occurence') |
|
| 612 | + . '</th><th>' |
|
| 613 | + . _T('ligne') |
|
| 614 | + . '</th><th>' |
|
| 615 | + . _T('colonne') |
|
| 616 | + . '</th><th>' |
|
| 617 | + . _T('erreur') |
|
| 618 | + . '</th></tr>'; |
|
| 619 | + |
|
| 620 | + $i = 0; |
|
| 621 | + $style = "style='text-align: right; padding-right: 5px'"; |
|
| 622 | + foreach ($errs as $r) { |
|
| 623 | + $i++; |
|
| 624 | + [$msg, $ligne, $col] = $r; |
|
| 625 | + #spip_logger()->info("$r = [$msg, $ligne, $col]"); |
|
| 626 | + if (isset($encore2[$msg])) { |
|
| 627 | + $ref = ++$encore2[$msg]; |
|
| 628 | + } else { |
|
| 629 | + $encore2[$msg] = $ref = 1; |
|
| 630 | + } |
|
| 631 | + $err .= "<tr style='background-color: " |
|
| 632 | + . $colors[$i % 2] |
|
| 633 | + . "'><td $style><a href='#debut_err'>" |
|
| 634 | + . $i |
|
| 635 | + . "</a></td><td $style>" |
|
| 636 | + . "$ref/$encore[$msg]</td>" |
|
| 637 | + . "<td $style><a href='#L" |
|
| 638 | + . $ligne |
|
| 639 | + . "' id='T$i'>" |
|
| 640 | + . $ligne |
|
| 641 | + . "</a></td><td $style>" |
|
| 642 | + . $col |
|
| 643 | + . "</td><td>$msg</td></tr>\n"; |
|
| 644 | + $fautifs[] = [$ligne, $col, $i, $msg]; |
|
| 645 | + } |
|
| 646 | + $err = "<h2 style='text-align: center'>" |
|
| 647 | + . $i |
|
| 648 | + . "<a href='#fin_err'>" |
|
| 649 | + . ' ' . _T('erreur_texte') |
|
| 650 | + . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 651 | + . $err |
|
| 652 | + . " </table><a id='fin_err'></a>"; |
|
| 653 | + |
|
| 654 | + return [ancre_texte($texte, $fautifs), $err]; |
|
| 655 | + } else { |
|
| 656 | + [$msg, $fermant, $ouvrant] = $errs[0]; |
|
| 657 | + $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 658 | + $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 659 | + $err = $msg . |
|
| 660 | + "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 661 | + "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 662 | + |
|
| 663 | + return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
|
| 664 | + } |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | function count_occ($regs) { |
| 668 | - $encore = []; |
|
| 669 | - foreach ($regs as $r) { |
|
| 670 | - if (isset($encore[$r[0]])) { |
|
| 671 | - $encore[$r[0]]++; |
|
| 672 | - } else { |
|
| 673 | - $encore[$r[0]] = 1; |
|
| 674 | - } |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - return $encore; |
|
| 668 | + $encore = []; |
|
| 669 | + foreach ($regs as $r) { |
|
| 670 | + if (isset($encore[$r[0]])) { |
|
| 671 | + $encore[$r[0]]++; |
|
| 672 | + } else { |
|
| 673 | + $encore[$r[0]] = 1; |
|
| 674 | + } |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + return $encore; |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | function debusquer_navigation_squelettes($self) { |
| 681 | 681 | |
| 682 | - $res = ''; |
|
| 683 | - $boucles = empty($GLOBALS['debug_objets']['boucle']) ? '' : $GLOBALS['debug_objets']['boucle']; |
|
| 684 | - $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 685 | - $t_skel = _T('squelette'); |
|
| 686 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 687 | - $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 688 | - $nav = $boucles ? debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile) : ''; |
|
| 689 | - $temps = isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? _T( |
|
| 690 | - 'zbug_profile', |
|
| 691 | - ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
|
| 692 | - ) : ''; |
|
| 693 | - |
|
| 694 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 695 | - . $t_skel |
|
| 696 | - . ' ' |
|
| 697 | - . $sourcefile |
|
| 698 | - . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 699 | - . $t_skel |
|
| 700 | - . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 701 | - . _T('zbug_resultat') |
|
| 702 | - . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 703 | - . _T('zbug_code') |
|
| 704 | - . "</a>\n<a href='" |
|
| 705 | - . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', (string) $self) |
|
| 706 | - . "'>" |
|
| 707 | - . _T('zbug_calcul') |
|
| 708 | - . '</a></legend>' |
|
| 709 | - . ($temps ? "\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />" : ('')) |
|
| 710 | - . debusquer_contexte($contexte[$sourcefile]) |
|
| 711 | - . ($nav ? "<table width='100%'>\n$nav</table>\n" : ('')) |
|
| 712 | - . "</fieldset>\n"; |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - return $res; |
|
| 682 | + $res = ''; |
|
| 683 | + $boucles = empty($GLOBALS['debug_objets']['boucle']) ? '' : $GLOBALS['debug_objets']['boucle']; |
|
| 684 | + $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 685 | + $t_skel = _T('squelette'); |
|
| 686 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 687 | + $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 688 | + $nav = $boucles ? debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile) : ''; |
|
| 689 | + $temps = isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? _T( |
|
| 690 | + 'zbug_profile', |
|
| 691 | + ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
|
| 692 | + ) : ''; |
|
| 693 | + |
|
| 694 | + $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 695 | + . $t_skel |
|
| 696 | + . ' ' |
|
| 697 | + . $sourcefile |
|
| 698 | + . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 699 | + . $t_skel |
|
| 700 | + . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 701 | + . _T('zbug_resultat') |
|
| 702 | + . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 703 | + . _T('zbug_code') |
|
| 704 | + . "</a>\n<a href='" |
|
| 705 | + . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', (string) $self) |
|
| 706 | + . "'>" |
|
| 707 | + . _T('zbug_calcul') |
|
| 708 | + . '</a></legend>' |
|
| 709 | + . ($temps ? "\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />" : ('')) |
|
| 710 | + . debusquer_contexte($contexte[$sourcefile]) |
|
| 711 | + . ($nav ? "<table width='100%'>\n$nav</table>\n" : ('')) |
|
| 712 | + . "</fieldset>\n"; |
|
| 713 | + } |
|
| 714 | + |
|
| 715 | + return $res; |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) { |
| 719 | - $i = 0; |
|
| 720 | - $res = ''; |
|
| 721 | - $var_mode_objet = _request('var_mode_objet'); |
|
| 722 | - $gram = preg_match('/[.](\w+)$/', (string) $nom_source, $r) ? $r[1] : ''; |
|
| 723 | - |
|
| 724 | - foreach ($boucles as $objet => $boucle) { |
|
| 725 | - if (str_starts_with((string) $objet, (string) $nom_skel)) { |
|
| 726 | - $i++; |
|
| 727 | - $nom = $boucle->id_boucle; |
|
| 728 | - $req = $boucle->type_requete; |
|
| 729 | - $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 730 | - $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 731 | - |
|
| 732 | - $res .= "\n<tr style='background-color: " . |
|
| 733 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 734 | - "'><td align='right'>$i</td><td>\n" . |
|
| 735 | - "<a class='debug_link_boucle' href='" . |
|
| 736 | - $self2 . |
|
| 737 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 738 | - _T('zbug_boucle') . |
|
| 739 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 740 | - $self2 . |
|
| 741 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 742 | - _T('zbug_resultat') . |
|
| 743 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 744 | - $self2 . |
|
| 745 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 746 | - _T('zbug_code') . |
|
| 747 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 748 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 749 | - "'>" . |
|
| 750 | - _T('zbug_calcul') . |
|
| 751 | - "</a></td><td>\n" . |
|
| 752 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 753 | - "</td><td>\n" . |
|
| 754 | - $req . |
|
| 755 | - "</td><td>\n" . |
|
| 756 | - spip_htmlspecialchars($crit) . |
|
| 757 | - '</td></tr>'; |
|
| 758 | - } |
|
| 759 | - } |
|
| 760 | - |
|
| 761 | - return $res; |
|
| 719 | + $i = 0; |
|
| 720 | + $res = ''; |
|
| 721 | + $var_mode_objet = _request('var_mode_objet'); |
|
| 722 | + $gram = preg_match('/[.](\w+)$/', (string) $nom_source, $r) ? $r[1] : ''; |
|
| 723 | + |
|
| 724 | + foreach ($boucles as $objet => $boucle) { |
|
| 725 | + if (str_starts_with((string) $objet, (string) $nom_skel)) { |
|
| 726 | + $i++; |
|
| 727 | + $nom = $boucle->id_boucle; |
|
| 728 | + $req = $boucle->type_requete; |
|
| 729 | + $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 730 | + $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 731 | + |
|
| 732 | + $res .= "\n<tr style='background-color: " . |
|
| 733 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 734 | + "'><td align='right'>$i</td><td>\n" . |
|
| 735 | + "<a class='debug_link_boucle' href='" . |
|
| 736 | + $self2 . |
|
| 737 | + "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 738 | + _T('zbug_boucle') . |
|
| 739 | + "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 740 | + $self2 . |
|
| 741 | + "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 742 | + _T('zbug_resultat') . |
|
| 743 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 744 | + $self2 . |
|
| 745 | + "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 746 | + _T('zbug_code') . |
|
| 747 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 748 | + str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 749 | + "'>" . |
|
| 750 | + _T('zbug_calcul') . |
|
| 751 | + "</a></td><td>\n" . |
|
| 752 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 753 | + "</td><td>\n" . |
|
| 754 | + $req . |
|
| 755 | + "</td><td>\n" . |
|
| 756 | + spip_htmlspecialchars($crit) . |
|
| 757 | + '</td></tr>'; |
|
| 758 | + } |
|
| 759 | + } |
|
| 760 | + |
|
| 761 | + return $res; |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | function debusquer_source($objet, $affiche) { |
| 765 | - $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 766 | - if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 767 | - $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 768 | - } else { |
|
| 769 | - $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 770 | - } |
|
| 771 | - $res2 = ''; |
|
| 772 | - |
|
| 773 | - if ($affiche == 'resultat') { |
|
| 774 | - $legend = $nom; |
|
| 775 | - $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 776 | - if (function_exists('_mysql_traite_query')) { |
|
| 777 | - $c = strtolower(_request('connect') ?? ''); |
|
| 778 | - $c = $GLOBALS['connexions'][$c ?: 0]['prefixe']; |
|
| 779 | - $req = _mysql_traite_query($req, '', $c); |
|
| 780 | - } |
|
| 781 | - // permettre le copier/coller facile |
|
| 782 | - // $res = ancre_texte($req, array(), true); |
|
| 783 | - $res = "<div id='T" . md5((string) $req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 784 | - // formatage et affichage des resultats bruts de la requete |
|
| 785 | - $ress_req = spip_query($req); |
|
| 786 | - $brut_sql = ''; |
|
| 787 | - $num = 1; |
|
| 788 | - // eviter l'affichage de milliers de lignes |
|
| 789 | - // personnalisation possible dans mes_options |
|
| 790 | - $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 791 | - while ($retours_sql = sql_fetch($ress_req)) { |
|
| 792 | - if ($num <= $max_aff) { |
|
| 793 | - $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 794 | - $brut_sql .= '<p>'; |
|
| 795 | - foreach ($retours_sql as $key => $val) { |
|
| 796 | - $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 797 | - } |
|
| 798 | - $brut_sql .= '</p>'; |
|
| 799 | - } |
|
| 800 | - $num++; |
|
| 801 | - } |
|
| 802 | - $res2 = interdire_scripts($brut_sql); |
|
| 803 | - foreach ($quoi as $view) { |
|
| 804 | - // ne pas afficher les $contexte_inclus |
|
| 805 | - $view = preg_replace(',<\?php.+\?[>],Uims', '', (string) $view); |
|
| 806 | - if ($view) { |
|
| 807 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 808 | - } |
|
| 809 | - } |
|
| 810 | - } elseif ($affiche == 'code') { |
|
| 811 | - $legend = $nom; |
|
| 812 | - $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 813 | - } elseif ($affiche == 'boucle') { |
|
| 814 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 815 | - // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 816 | - $gram = preg_match('/^([^_]+)_/', (string) $objet, $r) ? $r[1] : ''; |
|
| 817 | - $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 818 | - } elseif ($affiche == 'squelette') { |
|
| 819 | - $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 820 | - $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 821 | - } |
|
| 822 | - |
|
| 823 | - return [$legend, $res, $res2]; |
|
| 765 | + $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 766 | + if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 767 | + $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 768 | + } else { |
|
| 769 | + $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 770 | + } |
|
| 771 | + $res2 = ''; |
|
| 772 | + |
|
| 773 | + if ($affiche == 'resultat') { |
|
| 774 | + $legend = $nom; |
|
| 775 | + $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 776 | + if (function_exists('_mysql_traite_query')) { |
|
| 777 | + $c = strtolower(_request('connect') ?? ''); |
|
| 778 | + $c = $GLOBALS['connexions'][$c ?: 0]['prefixe']; |
|
| 779 | + $req = _mysql_traite_query($req, '', $c); |
|
| 780 | + } |
|
| 781 | + // permettre le copier/coller facile |
|
| 782 | + // $res = ancre_texte($req, array(), true); |
|
| 783 | + $res = "<div id='T" . md5((string) $req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 784 | + // formatage et affichage des resultats bruts de la requete |
|
| 785 | + $ress_req = spip_query($req); |
|
| 786 | + $brut_sql = ''; |
|
| 787 | + $num = 1; |
|
| 788 | + // eviter l'affichage de milliers de lignes |
|
| 789 | + // personnalisation possible dans mes_options |
|
| 790 | + $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 791 | + while ($retours_sql = sql_fetch($ress_req)) { |
|
| 792 | + if ($num <= $max_aff) { |
|
| 793 | + $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 794 | + $brut_sql .= '<p>'; |
|
| 795 | + foreach ($retours_sql as $key => $val) { |
|
| 796 | + $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 797 | + } |
|
| 798 | + $brut_sql .= '</p>'; |
|
| 799 | + } |
|
| 800 | + $num++; |
|
| 801 | + } |
|
| 802 | + $res2 = interdire_scripts($brut_sql); |
|
| 803 | + foreach ($quoi as $view) { |
|
| 804 | + // ne pas afficher les $contexte_inclus |
|
| 805 | + $view = preg_replace(',<\?php.+\?[>],Uims', '', (string) $view); |
|
| 806 | + if ($view) { |
|
| 807 | + $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 808 | + } |
|
| 809 | + } |
|
| 810 | + } elseif ($affiche == 'code') { |
|
| 811 | + $legend = $nom; |
|
| 812 | + $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 813 | + } elseif ($affiche == 'boucle') { |
|
| 814 | + $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 815 | + // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 816 | + $gram = preg_match('/^([^_]+)_/', (string) $objet, $r) ? $r[1] : ''; |
|
| 817 | + $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 818 | + } elseif ($affiche == 'squelette') { |
|
| 819 | + $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 820 | + $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 821 | + } |
|
| 822 | + |
|
| 823 | + return [$legend, $res, $res2]; |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | function debusquer_entete($titre, $corps) { |
| 827 | 827 | |
| 828 | - include_spip('balise/formulaire_admin'); |
|
| 829 | - include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 830 | - include_spip('inc/texte'); // pour corriger_typo |
|
| 831 | - |
|
| 832 | - return _DOCTYPE_ECRIRE . |
|
| 833 | - html_lang_attributes() . |
|
| 834 | - "<head>\n<title>" . |
|
| 835 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 836 | - _T('admin_debug') . ' ' . spip_htmlspecialchars($titre) . ' (' . |
|
| 837 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 838 | - ")</title>\n" . |
|
| 839 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 840 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 841 | - "' />\n" . |
|
| 842 | - http_script('', 'jquery.js') |
|
| 843 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 844 | - . "' type='text/css' />" . |
|
| 845 | - "</head>\n" . |
|
| 846 | - "<body style='margin:0 10px;'>\n" . |
|
| 847 | - "<div id='spip-debug-header'>" . |
|
| 848 | - $corps . |
|
| 849 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 850 | - '</div></body></html>'; |
|
| 828 | + include_spip('balise/formulaire_admin'); |
|
| 829 | + include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 830 | + include_spip('inc/texte'); // pour corriger_typo |
|
| 831 | + |
|
| 832 | + return _DOCTYPE_ECRIRE . |
|
| 833 | + html_lang_attributes() . |
|
| 834 | + "<head>\n<title>" . |
|
| 835 | + ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 836 | + _T('admin_debug') . ' ' . spip_htmlspecialchars($titre) . ' (' . |
|
| 837 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 838 | + ")</title>\n" . |
|
| 839 | + "<meta http-equiv='Content-Type' content='text/html" . |
|
| 840 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 841 | + "' />\n" . |
|
| 842 | + http_script('', 'jquery.js') |
|
| 843 | + . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 844 | + . "' type='text/css' />" . |
|
| 845 | + "</head>\n" . |
|
| 846 | + "<body style='margin:0 10px;'>\n" . |
|
| 847 | + "<div id='spip-debug-header'>" . |
|
| 848 | + $corps . |
|
| 849 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 850 | + '</div></body></html>'; |
|
| 851 | 851 | } |