@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $row = sql_fetsel( |
| 50 | 50 | '*', |
| 51 | 51 | 'spip_auteurs', |
| 52 | - 'login=' . sql_quote($login, $serveur, 'text') . " AND statut<>'5poubelle'", |
|
| 52 | + 'login='.sql_quote($login, $serveur, 'text')." AND statut<>'5poubelle'", |
|
| 53 | 53 | '', |
| 54 | 54 | '', |
| 55 | 55 | '', |
@@ -77,20 +77,20 @@ discard block |
||
| 77 | 77 | // legacy = md5 ou sha256 |
| 78 | 78 | case 32: |
| 79 | 79 | // tres anciens mots de passe encodes en md5(alea.pass) |
| 80 | - $hash = md5($row['alea_actuel'] . $pass); |
|
| 80 | + $hash = md5($row['alea_actuel'].$pass); |
|
| 81 | 81 | $methode = 'md5'; |
| 82 | 82 | case 64: |
| 83 | 83 | if (empty($hash)) { |
| 84 | 84 | // anciens mots de passe encodes en sha256(alea.pass) |
| 85 | 85 | include_spip('auth/sha256.inc'); |
| 86 | - $hash = spip_sha256($row['alea_actuel'] . $pass); |
|
| 86 | + $hash = spip_sha256($row['alea_actuel'].$pass); |
|
| 87 | 87 | $methode = 'sha256'; |
| 88 | 88 | } |
| 89 | 89 | if ($row['pass'] === $hash) { |
| 90 | - spip_log("validation du mot de passe pour l'auteur #" . $row['id_auteur'] . " $login via $methode", 'auth' . _LOG_DEBUG); |
|
| 90 | + spip_log("validation du mot de passe pour l'auteur #".$row['id_auteur']." $login via $methode", 'auth'._LOG_DEBUG); |
|
| 91 | 91 | // ce n'est pas cense arriver, mais si jamais c'est un backup inutilisable, il faut le nettoyer pour ne pas bloquer la creation d'une nouvelle cle d'auth |
| 92 | 92 | if (!empty($row['backup_cles'])) { |
| 93 | - sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 93 | + sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur='.intval($row['id_auteur'])); |
|
| 94 | 94 | } |
| 95 | 95 | break; |
| 96 | 96 | } |
@@ -108,19 +108,19 @@ discard block |
||
| 108 | 108 | and !empty($row['backup_cles']) |
| 109 | 109 | ) { |
| 110 | 110 | if ($cles->restore($row['backup_cles'], $pass, $row['pass'], $row['id_auteur'])) { |
| 111 | - spip_log('Les cles secretes ont ete restaurées avec le backup du webmestre #' . $row['id_auteur'], 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 111 | + spip_log('Les cles secretes ont ete restaurées avec le backup du webmestre #'.$row['id_auteur'], 'auth'._LOG_INFO_IMPORTANTE); |
|
| 112 | 112 | if ($cles->save()) { |
| 113 | 113 | $secret = $cles->getSecretAuth(); |
| 114 | 114 | } |
| 115 | 115 | else { |
| 116 | - spip_log("Echec restauration des cles : verifier les droits d'ecriture ?", 'auth' . _LOG_ERREUR); |
|
| 116 | + spip_log("Echec restauration des cles : verifier les droits d'ecriture ?", 'auth'._LOG_ERREUR); |
|
| 117 | 117 | // et on echoue car on ne veut pas que la situation reste telle quelle |
| 118 | - raler_fichier(_DIR_ETC . 'cles.php'); |
|
| 118 | + raler_fichier(_DIR_ETC.'cles.php'); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | else { |
| 122 | - spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) mais le backup du webmestre #' . $row['id_auteur'] . " n'est pas valide", 'auth' . _LOG_ERREUR); |
|
| 123 | - sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 122 | + spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) mais le backup du webmestre #'.$row['id_auteur']." n'est pas valide", 'auth'._LOG_ERREUR); |
|
| 123 | + sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur='.intval($row['id_auteur'])); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | unset($row); |
| 129 | 129 | } |
| 130 | 130 | else { |
| 131 | - spip_log("validation du mot de passe pour l'auteur #" . $row['id_auteur'] . " $login via Password::verifier", 'auth' . _LOG_DEBUG); |
|
| 131 | + spip_log("validation du mot de passe pour l'auteur #".$row['id_auteur']." $login via Password::verifier", 'auth'._LOG_DEBUG); |
|
| 132 | 132 | } |
| 133 | 133 | break; |
| 134 | 134 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | @sql_update( |
| 176 | 176 | 'spip_auteurs', |
| 177 | 177 | $set, |
| 178 | - 'id_auteur=' . intval($row['id_auteur']) . ' AND pass=' . sql_quote( |
|
| 178 | + 'id_auteur='.intval($row['id_auteur']).' AND pass='.sql_quote( |
|
| 179 | 179 | $row['pass'], |
| 180 | 180 | $serveur, |
| 181 | 181 | 'text' |
@@ -223,24 +223,24 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | // si force, on ne verifie pas la presence d'un backup chez un webmestre |
| 225 | 225 | if ($force) { |
| 226 | - spip_log('Pas de cle secrete disponible, on regenere une nouvelle cle forcee - tous les mots de passe sont invalides', 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 226 | + spip_log('Pas de cle secrete disponible, on regenere une nouvelle cle forcee - tous les mots de passe sont invalides', 'auth'._LOG_INFO_IMPORTANTE); |
|
| 227 | 227 | $secret = $cles->getSecretAuth(true); |
| 228 | 228 | return true; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $has_backup = sql_allfetsel('id_auteur', 'spip_auteurs', 'statut=' . sql_quote('0minirezo') . ' AND webmestre=' . sql_quote('oui') . " AND backup_cles!=''"); |
|
| 231 | + $has_backup = sql_allfetsel('id_auteur', 'spip_auteurs', 'statut='.sql_quote('0minirezo').' AND webmestre='.sql_quote('oui')." AND backup_cles!=''"); |
|
| 232 | 232 | $has_backup = array_column($has_backup, 'id_auteur'); |
| 233 | 233 | if (empty($has_backup)) { |
| 234 | - spip_log("Pas de cle secrete disponible, et aucun webmestre n'a de backup, on regenere une nouvelle cle - tous les mots de passe sont invalides", 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 234 | + spip_log("Pas de cle secrete disponible, et aucun webmestre n'a de backup, on regenere une nouvelle cle - tous les mots de passe sont invalides", 'auth'._LOG_INFO_IMPORTANTE); |
|
| 235 | 235 | if ($secret = $cles->getSecretAuth(true)) { |
| 236 | 236 | return true; |
| 237 | 237 | } |
| 238 | - spip_log("Echec generation d'une nouvelle cle : verifier les droits d'ecriture ?", 'auth' . _LOG_ERREUR); |
|
| 238 | + spip_log("Echec generation d'une nouvelle cle : verifier les droits d'ecriture ?", 'auth'._LOG_ERREUR); |
|
| 239 | 239 | // et on echoue car on ne veut pas que la situation reste telle quelle |
| 240 | - raler_fichier(_DIR_ETC . 'cles.php'); |
|
| 240 | + raler_fichier(_DIR_ETC.'cles.php'); |
|
| 241 | 241 | } |
| 242 | 242 | else { |
| 243 | - spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) un des webmestres #' . implode(', #', $has_backup) . ' doit se connecter pour restaurer son backup des cles', 'auth' . _LOG_ERREUR); |
|
| 243 | + spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) un des webmestres #'.implode(', #', $has_backup).' doit se connecter pour restaurer son backup des cles', 'auth'._LOG_ERREUR); |
|
| 244 | 244 | } |
| 245 | 245 | return false; |
| 246 | 246 | } |
@@ -257,8 +257,8 @@ discard block |
||
| 257 | 257 | $flux['data'] .= |
| 258 | 258 | '<script type="text/javascript">/*<![CDATA[*/' |
| 259 | 259 | . "$js\n" |
| 260 | - . "var login_info={'login':'" . $flux['args']['contexte']['var_login'] . "'," |
|
| 261 | - . "'page_auteur': '" . generer_url_public('informer_auteur') . "'," |
|
| 260 | + . "var login_info={'login':'".$flux['args']['contexte']['var_login']."'," |
|
| 261 | + . "'page_auteur': '".generer_url_public('informer_auteur')."'," |
|
| 262 | 262 | . "'informe_auteur_en_cours':false," |
| 263 | 263 | . "'attente_informe':0};" |
| 264 | 264 | . "jQuery(function(){jQuery('#var_login').change(actualise_auteur);});" |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | } else { |
| 302 | 302 | $n = sql_countsel( |
| 303 | 303 | 'spip_auteurs', |
| 304 | - 'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'", |
|
| 304 | + 'login='.sql_quote($new_login).' AND id_auteur!='.intval($id_auteur)." AND statut!='5poubelle'", |
|
| 305 | 305 | '', |
| 306 | 306 | '', |
| 307 | 307 | $serveur |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | if ( |
| 331 | 331 | !$id_auteur = intval($id_auteur) |
| 332 | - or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 332 | + or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur), '', '', '', '', $serveur) |
|
| 333 | 333 | ) { |
| 334 | 334 | return false; |
| 335 | 335 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $anciens = sql_allfetsel( |
| 345 | 345 | 'id_auteur', |
| 346 | 346 | 'spip_auteurs', |
| 347 | - 'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'", |
|
| 347 | + 'login='.sql_quote($new_login, $serveur, 'text')." AND statut='5poubelle'", |
|
| 348 | 348 | '', |
| 349 | 349 | '', |
| 350 | 350 | '', |
@@ -378,8 +378,8 @@ discard block |
||
| 378 | 378 | $r = sql_getfetsel( |
| 379 | 379 | 'login', |
| 380 | 380 | 'spip_auteurs', |
| 381 | - "statut<>'5poubelle'" . |
|
| 382 | - ' AND (length(pass)>0)' . |
|
| 381 | + "statut<>'5poubelle'". |
|
| 382 | + ' AND (length(pass)>0)'. |
|
| 383 | 383 | " AND (login=$l)", |
| 384 | 384 | '', |
| 385 | 385 | '', |
@@ -398,8 +398,8 @@ discard block |
||
| 398 | 398 | return sql_getfetsel( |
| 399 | 399 | 'login', |
| 400 | 400 | 'spip_auteurs', |
| 401 | - "statut<>'5poubelle'" . |
|
| 402 | - ' AND (length(pass)>0)' . |
|
| 401 | + "statut<>'5poubelle'". |
|
| 402 | + ' AND (length(pass)>0)'. |
|
| 403 | 403 | " AND (login<>'' AND (nom=$l OR email=$l))", |
| 404 | 404 | '', |
| 405 | 405 | '', |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | |
| 469 | 469 | if ( |
| 470 | 470 | !$id_auteur = intval($id_auteur) |
| 471 | - or !$auteur = sql_fetsel('login, statut, webmestre', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 471 | + or !$auteur = sql_fetsel('login, statut, webmestre', 'spip_auteurs', 'id_auteur='.intval($id_auteur), '', '', '', '', $serveur) |
|
| 472 | 472 | ) { |
| 473 | 473 | return false; |
| 474 | 474 | } |
@@ -529,8 +529,8 @@ discard block |
||
| 529 | 529 | or isset($champs['statut']) |
| 530 | 530 | or (isset($options['all']) and $options['all']) |
| 531 | 531 | ) { |
| 532 | - $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 533 | - $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 532 | + $htaccess = _DIR_RESTREINT._ACCESS_FILE_NAME; |
|
| 533 | + $htpasswd = _DIR_TMP._AUTH_USER_FILE; |
|
| 534 | 534 | |
| 535 | 535 | // Cette variable de configuration peut etre posee par un plugin |
| 536 | 536 | // par exemple acces_restreint ; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | and !@file_exists($htaccess) |
| 541 | 541 | ) { |
| 542 | 542 | spip_unlink($htpasswd); |
| 543 | - spip_unlink($htpasswd . '-admin'); |
|
| 543 | + spip_unlink($htpasswd.'-admin'); |
|
| 544 | 544 | |
| 545 | 545 | return; |
| 546 | 546 | } |
@@ -558,16 +558,16 @@ discard block |
||
| 558 | 558 | ); |
| 559 | 559 | while ($t = sql_fetch($s)) { |
| 560 | 560 | if (strlen($t['login']) and strlen($t['htpass'])) { |
| 561 | - $p1 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 561 | + $p1 .= $t['login'].':'.$t['htpass']."\n"; |
|
| 562 | 562 | if ($t['statut'] == '0minirezo') { |
| 563 | - $p2 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 563 | + $p2 .= $t['login'].':'.$t['htpass']."\n"; |
|
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | sql_free($s); |
| 568 | 568 | if ($p1) { |
| 569 | 569 | ecrire_fichier($htpasswd, $p1); |
| 570 | - ecrire_fichier($htpasswd . '-admin', $p2); |
|
| 570 | + ecrire_fichier($htpasswd.'-admin', $p2); |
|
| 571 | 571 | spip_log("Ecriture de $htpasswd et $htpasswd-admin"); |
| 572 | 572 | } |
| 573 | 573 | } |
@@ -111,14 +111,12 @@ discard block |
||
| 111 | 111 | spip_log('Les cles secretes ont ete restaurées avec le backup du webmestre #' . $row['id_auteur'], 'auth' . _LOG_INFO_IMPORTANTE); |
| 112 | 112 | if ($cles->save()) { |
| 113 | 113 | $secret = $cles->getSecretAuth(); |
| 114 | - } |
|
| 115 | - else { |
|
| 114 | + } else { |
|
| 116 | 115 | spip_log("Echec restauration des cles : verifier les droits d'ecriture ?", 'auth' . _LOG_ERREUR); |
| 117 | 116 | // et on echoue car on ne veut pas que la situation reste telle quelle |
| 118 | 117 | raler_fichier(_DIR_ETC . 'cles.php'); |
| 119 | 118 | } |
| 120 | - } |
|
| 121 | - else { |
|
| 119 | + } else { |
|
| 122 | 120 | spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) mais le backup du webmestre #' . $row['id_auteur'] . " n'est pas valide", 'auth' . _LOG_ERREUR); |
| 123 | 121 | sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur=' . intval($row['id_auteur'])); |
| 124 | 122 | } |
@@ -126,8 +124,7 @@ discard block |
||
| 126 | 124 | |
| 127 | 125 | if (!$secret or !Password::verifier($pass, $row['pass'], $secret)) { |
| 128 | 126 | unset($row); |
| 129 | - } |
|
| 130 | - else { |
|
| 127 | + } else { |
|
| 131 | 128 | spip_log("validation du mot de passe pour l'auteur #" . $row['id_auteur'] . " $login via Password::verifier", 'auth' . _LOG_DEBUG); |
| 132 | 129 | } |
| 133 | 130 | break; |
@@ -238,8 +235,7 @@ discard block |
||
| 238 | 235 | spip_log("Echec generation d'une nouvelle cle : verifier les droits d'ecriture ?", 'auth' . _LOG_ERREUR); |
| 239 | 236 | // et on echoue car on ne veut pas que la situation reste telle quelle |
| 240 | 237 | raler_fichier(_DIR_ETC . 'cles.php'); |
| 241 | - } |
|
| 242 | - else { |
|
| 238 | + } else { |
|
| 243 | 239 | spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) un des webmestres #' . implode(', #', $has_backup) . ' doit se connecter pour restaurer son backup des cles', 'auth' . _LOG_ERREUR); |
| 244 | 240 | } |
| 245 | 241 | return false; |
@@ -479,8 +475,7 @@ discard block |
||
| 479 | 475 | if (!$secret) { |
| 480 | 476 | if (auth_spip_initialiser_secret()) { |
| 481 | 477 | $secret = $cles->getSecretAuth(); |
| 482 | - } |
|
| 483 | - else { |
|
| 478 | + } else { |
|
| 484 | 479 | return false; |
| 485 | 480 | } |
| 486 | 481 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use Spip\Chiffrer\SpipCles; |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -33,169 +33,169 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function auth_spip_dist($login, #[\SensitiveParameter] $pass, $serveur = '', $phpauth = false) { |
| 35 | 35 | |
| 36 | - // retrouver le login |
|
| 37 | - $login = auth_spip_retrouver_login($login); |
|
| 38 | - // login inconnu, n'allons pas plus loin |
|
| 39 | - if (!$login) { |
|
| 40 | - return []; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $md5pass = ''; |
|
| 44 | - $shapass = $shanext = ''; |
|
| 45 | - $auteur_peut_sauver_cles = false; |
|
| 46 | - |
|
| 47 | - if ($pass) { |
|
| 48 | - $row = sql_fetsel( |
|
| 49 | - '*', |
|
| 50 | - 'spip_auteurs', |
|
| 51 | - 'login=' . sql_quote($login, $serveur, 'text') . " AND statut<>'5poubelle'", |
|
| 52 | - '', |
|
| 53 | - '', |
|
| 54 | - '', |
|
| 55 | - '', |
|
| 56 | - $serveur |
|
| 57 | - ); |
|
| 58 | - |
|
| 59 | - // lever un flag si cet auteur peut sauver les cles |
|
| 60 | - if ($row['statut'] === '0minirezo' and $row['webmestre'] === 'oui' and isset($row['backup_cles'])) { |
|
| 61 | - $auteur_peut_sauver_cles = true; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - // login inexistant ou mot de passe vide |
|
| 66 | - if (!$pass or !$row) { |
|
| 67 | - return []; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - $cles = SpipCles::instance(); |
|
| 71 | - $secret = $cles->getSecretAuth(); |
|
| 72 | - |
|
| 73 | - $hash = null; |
|
| 74 | - switch (strlen($row['pass'])) { |
|
| 75 | - // legacy = md5 ou sha256 |
|
| 76 | - case 32: |
|
| 77 | - // tres anciens mots de passe encodes en md5(alea.pass) |
|
| 78 | - $hash = md5($row['alea_actuel'] . $pass); |
|
| 79 | - $methode = 'md5'; |
|
| 80 | - case 64: |
|
| 81 | - if (empty($hash)) { |
|
| 82 | - // anciens mots de passe encodes en sha256(alea.pass) |
|
| 83 | - include_spip('auth/sha256.inc'); |
|
| 84 | - $hash = spip_sha256($row['alea_actuel'] . $pass); |
|
| 85 | - $methode = 'sha256'; |
|
| 86 | - } |
|
| 87 | - if ($row['pass'] === $hash) { |
|
| 88 | - spip_log("validation du mot de passe pour l'auteur #" . $row['id_auteur'] . " $login via $methode", 'auth' . _LOG_DEBUG); |
|
| 89 | - // ce n'est pas cense arriver, mais si jamais c'est un backup inutilisable, il faut le nettoyer pour ne pas bloquer la creation d'une nouvelle cle d'auth |
|
| 90 | - if (!empty($row['backup_cles'])) { |
|
| 91 | - sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 92 | - } |
|
| 93 | - break; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // on teste la methode par defaut, au cas ou ce serait un pass moderne qui a la malchance d'etre en 64char de long |
|
| 97 | - |
|
| 98 | - case 60: |
|
| 99 | - case 98: |
|
| 100 | - default: |
|
| 101 | - // doit-on restaurer un backup des cles ? |
|
| 102 | - // si on a le bon pass on peut decoder le backup, retrouver la cle, et du coup valider le pass |
|
| 103 | - if ( |
|
| 104 | - !$secret |
|
| 105 | - and $auteur_peut_sauver_cles |
|
| 106 | - and !empty($row['backup_cles']) |
|
| 107 | - ) { |
|
| 108 | - if ($cles->restore($row['backup_cles'], $pass, $row['pass'], $row['id_auteur'])) { |
|
| 109 | - spip_log('Les cles secretes ont ete restaurées avec le backup du webmestre #' . $row['id_auteur'], 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 110 | - if ($cles->save()) { |
|
| 111 | - $secret = $cles->getSecretAuth(); |
|
| 112 | - } |
|
| 113 | - else { |
|
| 114 | - spip_log("Echec restauration des cles : verifier les droits d'ecriture ?", 'auth' . _LOG_ERREUR); |
|
| 115 | - // et on echoue car on ne veut pas que la situation reste telle quelle |
|
| 116 | - raler_fichier(_DIR_ETC . 'cles.php'); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - else { |
|
| 120 | - spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) mais le backup du webmestre #' . $row['id_auteur'] . " n'est pas valide", 'auth' . _LOG_ERREUR); |
|
| 121 | - sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - if (!$secret or !Password::verifier($pass, $row['pass'], $secret)) { |
|
| 126 | - unset($row); |
|
| 127 | - } |
|
| 128 | - else { |
|
| 129 | - spip_log("validation du mot de passe pour l'auteur #" . $row['id_auteur'] . " $login via Password::verifier", 'auth' . _LOG_DEBUG); |
|
| 130 | - } |
|
| 131 | - break; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // Migration depuis ancienne version : si on a pas encore de cle |
|
| 135 | - // ET si c'est le login d'un auteur qui peut sauver la cle |
|
| 136 | - // créer la clé (en s'assurant bien que personne n'a de backup d'un precedent fichier cle.php) |
|
| 137 | - // si c'est un auteur normal, on ne fait rien, il garde son ancien pass hashé en sha256 en attendant le login d'un webmestre |
|
| 138 | - if (!$secret and $auteur_peut_sauver_cles) { |
|
| 139 | - if (auth_spip_initialiser_secret()) { |
|
| 140 | - $secret = $cles->getSecretAuth(); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - // login/mot de passe incorrect |
|
| 145 | - if (empty($row)) { |
|
| 146 | - return []; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - // fait tourner le codage du pass dans la base |
|
| 150 | - // sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action() |
|
| 151 | - if (!$phpauth and $secret) { |
|
| 152 | - include_spip('inc/acces'); // pour creer_uniqid et verifier_htaccess |
|
| 153 | - $pass_hash_next = Password::hacher($pass, $secret); |
|
| 154 | - if ($pass_hash_next) { |
|
| 155 | - $set = [ |
|
| 156 | - 'alea_actuel' => 'alea_futur', // @deprecated 4.1 |
|
| 157 | - 'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text'), // @deprecated 4.1 |
|
| 158 | - 'pass' => sql_quote($pass_hash_next, $serveur, 'text'), |
|
| 159 | - ]; |
|
| 160 | - |
|
| 161 | - // regenerer un htpass si on a active/desactive le plugin htpasswd |
|
| 162 | - // et/ou que l'algo a change - pour etre certain de toujours utiliser le bon algo |
|
| 163 | - $htpass = generer_htpass($pass); |
|
| 164 | - if (strlen($htpass) !== strlen($row['htpass'])) { |
|
| 165 | - $set['htpass'] = sql_quote($htpass, $serveur, 'text'); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // a chaque login de webmestre : sauvegarde chiffree des clés du site (avec les pass du webmestre) |
|
| 169 | - if ($auteur_peut_sauver_cles) { |
|
| 170 | - $set['backup_cles'] = sql_quote($cles->backup($pass), $serveur, 'text'); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - @sql_update( |
|
| 174 | - 'spip_auteurs', |
|
| 175 | - $set, |
|
| 176 | - 'id_auteur=' . intval($row['id_auteur']) . ' AND pass=' . sql_quote( |
|
| 177 | - $row['pass'], |
|
| 178 | - $serveur, |
|
| 179 | - 'text' |
|
| 180 | - ), |
|
| 181 | - [], |
|
| 182 | - $serveur |
|
| 183 | - ); |
|
| 184 | - |
|
| 185 | - // si on a change le htpass car changement d'algo, regenerer les fichiers htpasswd |
|
| 186 | - if (isset($set['htpass'])) { |
|
| 187 | - ecrire_acces(); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - // En profiter pour verifier la securite de tmp/ |
|
| 192 | - // Si elle ne fonctionne pas a l'installation, prevenir |
|
| 193 | - if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) { |
|
| 194 | - return false; |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - return $row; |
|
| 36 | + // retrouver le login |
|
| 37 | + $login = auth_spip_retrouver_login($login); |
|
| 38 | + // login inconnu, n'allons pas plus loin |
|
| 39 | + if (!$login) { |
|
| 40 | + return []; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $md5pass = ''; |
|
| 44 | + $shapass = $shanext = ''; |
|
| 45 | + $auteur_peut_sauver_cles = false; |
|
| 46 | + |
|
| 47 | + if ($pass) { |
|
| 48 | + $row = sql_fetsel( |
|
| 49 | + '*', |
|
| 50 | + 'spip_auteurs', |
|
| 51 | + 'login=' . sql_quote($login, $serveur, 'text') . " AND statut<>'5poubelle'", |
|
| 52 | + '', |
|
| 53 | + '', |
|
| 54 | + '', |
|
| 55 | + '', |
|
| 56 | + $serveur |
|
| 57 | + ); |
|
| 58 | + |
|
| 59 | + // lever un flag si cet auteur peut sauver les cles |
|
| 60 | + if ($row['statut'] === '0minirezo' and $row['webmestre'] === 'oui' and isset($row['backup_cles'])) { |
|
| 61 | + $auteur_peut_sauver_cles = true; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + // login inexistant ou mot de passe vide |
|
| 66 | + if (!$pass or !$row) { |
|
| 67 | + return []; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + $cles = SpipCles::instance(); |
|
| 71 | + $secret = $cles->getSecretAuth(); |
|
| 72 | + |
|
| 73 | + $hash = null; |
|
| 74 | + switch (strlen($row['pass'])) { |
|
| 75 | + // legacy = md5 ou sha256 |
|
| 76 | + case 32: |
|
| 77 | + // tres anciens mots de passe encodes en md5(alea.pass) |
|
| 78 | + $hash = md5($row['alea_actuel'] . $pass); |
|
| 79 | + $methode = 'md5'; |
|
| 80 | + case 64: |
|
| 81 | + if (empty($hash)) { |
|
| 82 | + // anciens mots de passe encodes en sha256(alea.pass) |
|
| 83 | + include_spip('auth/sha256.inc'); |
|
| 84 | + $hash = spip_sha256($row['alea_actuel'] . $pass); |
|
| 85 | + $methode = 'sha256'; |
|
| 86 | + } |
|
| 87 | + if ($row['pass'] === $hash) { |
|
| 88 | + spip_log("validation du mot de passe pour l'auteur #" . $row['id_auteur'] . " $login via $methode", 'auth' . _LOG_DEBUG); |
|
| 89 | + // ce n'est pas cense arriver, mais si jamais c'est un backup inutilisable, il faut le nettoyer pour ne pas bloquer la creation d'une nouvelle cle d'auth |
|
| 90 | + if (!empty($row['backup_cles'])) { |
|
| 91 | + sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 92 | + } |
|
| 93 | + break; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // on teste la methode par defaut, au cas ou ce serait un pass moderne qui a la malchance d'etre en 64char de long |
|
| 97 | + |
|
| 98 | + case 60: |
|
| 99 | + case 98: |
|
| 100 | + default: |
|
| 101 | + // doit-on restaurer un backup des cles ? |
|
| 102 | + // si on a le bon pass on peut decoder le backup, retrouver la cle, et du coup valider le pass |
|
| 103 | + if ( |
|
| 104 | + !$secret |
|
| 105 | + and $auteur_peut_sauver_cles |
|
| 106 | + and !empty($row['backup_cles']) |
|
| 107 | + ) { |
|
| 108 | + if ($cles->restore($row['backup_cles'], $pass, $row['pass'], $row['id_auteur'])) { |
|
| 109 | + spip_log('Les cles secretes ont ete restaurées avec le backup du webmestre #' . $row['id_auteur'], 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 110 | + if ($cles->save()) { |
|
| 111 | + $secret = $cles->getSecretAuth(); |
|
| 112 | + } |
|
| 113 | + else { |
|
| 114 | + spip_log("Echec restauration des cles : verifier les droits d'ecriture ?", 'auth' . _LOG_ERREUR); |
|
| 115 | + // et on echoue car on ne veut pas que la situation reste telle quelle |
|
| 116 | + raler_fichier(_DIR_ETC . 'cles.php'); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + else { |
|
| 120 | + spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) mais le backup du webmestre #' . $row['id_auteur'] . " n'est pas valide", 'auth' . _LOG_ERREUR); |
|
| 121 | + sql_updateq('spip_auteurs', ['backup_cles' => ''], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + if (!$secret or !Password::verifier($pass, $row['pass'], $secret)) { |
|
| 126 | + unset($row); |
|
| 127 | + } |
|
| 128 | + else { |
|
| 129 | + spip_log("validation du mot de passe pour l'auteur #" . $row['id_auteur'] . " $login via Password::verifier", 'auth' . _LOG_DEBUG); |
|
| 130 | + } |
|
| 131 | + break; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // Migration depuis ancienne version : si on a pas encore de cle |
|
| 135 | + // ET si c'est le login d'un auteur qui peut sauver la cle |
|
| 136 | + // créer la clé (en s'assurant bien que personne n'a de backup d'un precedent fichier cle.php) |
|
| 137 | + // si c'est un auteur normal, on ne fait rien, il garde son ancien pass hashé en sha256 en attendant le login d'un webmestre |
|
| 138 | + if (!$secret and $auteur_peut_sauver_cles) { |
|
| 139 | + if (auth_spip_initialiser_secret()) { |
|
| 140 | + $secret = $cles->getSecretAuth(); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + // login/mot de passe incorrect |
|
| 145 | + if (empty($row)) { |
|
| 146 | + return []; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + // fait tourner le codage du pass dans la base |
|
| 150 | + // sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action() |
|
| 151 | + if (!$phpauth and $secret) { |
|
| 152 | + include_spip('inc/acces'); // pour creer_uniqid et verifier_htaccess |
|
| 153 | + $pass_hash_next = Password::hacher($pass, $secret); |
|
| 154 | + if ($pass_hash_next) { |
|
| 155 | + $set = [ |
|
| 156 | + 'alea_actuel' => 'alea_futur', // @deprecated 4.1 |
|
| 157 | + 'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text'), // @deprecated 4.1 |
|
| 158 | + 'pass' => sql_quote($pass_hash_next, $serveur, 'text'), |
|
| 159 | + ]; |
|
| 160 | + |
|
| 161 | + // regenerer un htpass si on a active/desactive le plugin htpasswd |
|
| 162 | + // et/ou que l'algo a change - pour etre certain de toujours utiliser le bon algo |
|
| 163 | + $htpass = generer_htpass($pass); |
|
| 164 | + if (strlen($htpass) !== strlen($row['htpass'])) { |
|
| 165 | + $set['htpass'] = sql_quote($htpass, $serveur, 'text'); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // a chaque login de webmestre : sauvegarde chiffree des clés du site (avec les pass du webmestre) |
|
| 169 | + if ($auteur_peut_sauver_cles) { |
|
| 170 | + $set['backup_cles'] = sql_quote($cles->backup($pass), $serveur, 'text'); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + @sql_update( |
|
| 174 | + 'spip_auteurs', |
|
| 175 | + $set, |
|
| 176 | + 'id_auteur=' . intval($row['id_auteur']) . ' AND pass=' . sql_quote( |
|
| 177 | + $row['pass'], |
|
| 178 | + $serveur, |
|
| 179 | + 'text' |
|
| 180 | + ), |
|
| 181 | + [], |
|
| 182 | + $serveur |
|
| 183 | + ); |
|
| 184 | + |
|
| 185 | + // si on a change le htpass car changement d'algo, regenerer les fichiers htpasswd |
|
| 186 | + if (isset($set['htpass'])) { |
|
| 187 | + ecrire_acces(); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + // En profiter pour verifier la securite de tmp/ |
|
| 192 | + // Si elle ne fonctionne pas a l'installation, prevenir |
|
| 193 | + if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) { |
|
| 194 | + return false; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + return $row; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -210,36 +210,36 @@ discard block |
||
| 210 | 210 | * @return bool |
| 211 | 211 | */ |
| 212 | 212 | function auth_spip_initialiser_secret(bool $force = false): bool { |
| 213 | - $cles = SpipCles::instance(); |
|
| 214 | - $secret = $cles->getSecretAuth(); |
|
| 215 | - |
|
| 216 | - // on ne fait rien si on a un secret dispo |
|
| 217 | - if ($secret) { |
|
| 218 | - return false; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // si force, on ne verifie pas la presence d'un backup chez un webmestre |
|
| 222 | - if ($force) { |
|
| 223 | - spip_log('Pas de cle secrete disponible, on regenere une nouvelle cle forcee - tous les mots de passe sont invalides', 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 224 | - $secret = $cles->getSecretAuth(true); |
|
| 225 | - return true; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - $has_backup = sql_allfetsel('id_auteur', 'spip_auteurs', 'statut=' . sql_quote('0minirezo') . ' AND webmestre=' . sql_quote('oui') . " AND backup_cles!=''"); |
|
| 229 | - $has_backup = array_column($has_backup, 'id_auteur'); |
|
| 230 | - if (empty($has_backup)) { |
|
| 231 | - spip_log("Pas de cle secrete disponible, et aucun webmestre n'a de backup, on regenere une nouvelle cle - tous les mots de passe sont invalides", 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 232 | - if ($secret = $cles->getSecretAuth(true)) { |
|
| 233 | - return true; |
|
| 234 | - } |
|
| 235 | - spip_log("Echec generation d'une nouvelle cle : verifier les droits d'ecriture ?", 'auth' . _LOG_ERREUR); |
|
| 236 | - // et on echoue car on ne veut pas que la situation reste telle quelle |
|
| 237 | - raler_fichier(_DIR_ETC . 'cles.php'); |
|
| 238 | - } |
|
| 239 | - else { |
|
| 240 | - spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) un des webmestres #' . implode(', #', $has_backup) . ' doit se connecter pour restaurer son backup des cles', 'auth' . _LOG_ERREUR); |
|
| 241 | - } |
|
| 242 | - return false; |
|
| 213 | + $cles = SpipCles::instance(); |
|
| 214 | + $secret = $cles->getSecretAuth(); |
|
| 215 | + |
|
| 216 | + // on ne fait rien si on a un secret dispo |
|
| 217 | + if ($secret) { |
|
| 218 | + return false; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // si force, on ne verifie pas la presence d'un backup chez un webmestre |
|
| 222 | + if ($force) { |
|
| 223 | + spip_log('Pas de cle secrete disponible, on regenere une nouvelle cle forcee - tous les mots de passe sont invalides', 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 224 | + $secret = $cles->getSecretAuth(true); |
|
| 225 | + return true; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + $has_backup = sql_allfetsel('id_auteur', 'spip_auteurs', 'statut=' . sql_quote('0minirezo') . ' AND webmestre=' . sql_quote('oui') . " AND backup_cles!=''"); |
|
| 229 | + $has_backup = array_column($has_backup, 'id_auteur'); |
|
| 230 | + if (empty($has_backup)) { |
|
| 231 | + spip_log("Pas de cle secrete disponible, et aucun webmestre n'a de backup, on regenere une nouvelle cle - tous les mots de passe sont invalides", 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 232 | + if ($secret = $cles->getSecretAuth(true)) { |
|
| 233 | + return true; |
|
| 234 | + } |
|
| 235 | + spip_log("Echec generation d'une nouvelle cle : verifier les droits d'ecriture ?", 'auth' . _LOG_ERREUR); |
|
| 236 | + // et on echoue car on ne veut pas que la situation reste telle quelle |
|
| 237 | + raler_fichier(_DIR_ETC . 'cles.php'); |
|
| 238 | + } |
|
| 239 | + else { |
|
| 240 | + spip_log('Pas de cle secrete disponible (fichier config/cle.php absent ?) un des webmestres #' . implode(', #', $has_backup) . ' doit se connecter pour restaurer son backup des cles', 'auth' . _LOG_ERREUR); |
|
| 241 | + } |
|
| 242 | + return false; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -249,19 +249,19 @@ discard block |
||
| 249 | 249 | * @return array |
| 250 | 250 | */ |
| 251 | 251 | function auth_spip_formulaire_login($flux) { |
| 252 | - // javascript qui gere la securite du login en evitant de faire circuler le pass en clair |
|
| 253 | - $js = file_get_contents(find_in_path('prive/javascript/login.js')); |
|
| 254 | - $flux['data'] .= |
|
| 255 | - '<script type="text/javascript">/*<![CDATA[*/' |
|
| 256 | - . "$js\n" |
|
| 257 | - . "var login_info={'login':'" . $flux['args']['contexte']['var_login'] . "'," |
|
| 258 | - . "'page_auteur': '" . generer_url_public('informer_auteur') . "'," |
|
| 259 | - . "'informe_auteur_en_cours':false," |
|
| 260 | - . "'attente_informe':0};" |
|
| 261 | - . "jQuery(function(){jQuery('#var_login').change(actualise_auteur);});" |
|
| 262 | - . '/*]]>*/</script>'; |
|
| 263 | - |
|
| 264 | - return $flux; |
|
| 252 | + // javascript qui gere la securite du login en evitant de faire circuler le pass en clair |
|
| 253 | + $js = file_get_contents(find_in_path('prive/javascript/login.js')); |
|
| 254 | + $flux['data'] .= |
|
| 255 | + '<script type="text/javascript">/*<![CDATA[*/' |
|
| 256 | + . "$js\n" |
|
| 257 | + . "var login_info={'login':'" . $flux['args']['contexte']['var_login'] . "'," |
|
| 258 | + . "'page_auteur': '" . generer_url_public('informer_auteur') . "'," |
|
| 259 | + . "'informe_auteur_en_cours':false," |
|
| 260 | + . "'attente_informe':0};" |
|
| 261 | + . "jQuery(function(){jQuery('#var_login').change(actualise_auteur);});" |
|
| 262 | + . '/*]]>*/</script>'; |
|
| 263 | + |
|
| 264 | + return $flux; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | * toujours true pour un auteur cree dans SPIP |
| 274 | 274 | */ |
| 275 | 275 | function auth_spip_autoriser_modifier_login(string $serveur = ''): bool { |
| 276 | - // les fonctions d'ecriture sur base distante sont encore incompletes |
|
| 277 | - if (strlen($serveur)) { |
|
| 278 | - return false; |
|
| 279 | - } |
|
| 280 | - return true; |
|
| 276 | + // les fonctions d'ecriture sur base distante sont encore incompletes |
|
| 277 | + if (strlen($serveur)) { |
|
| 278 | + return false; |
|
| 279 | + } |
|
| 280 | + return true; |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -291,25 +291,25 @@ discard block |
||
| 291 | 291 | * message d'erreur si login non valide, chaine vide sinon |
| 292 | 292 | */ |
| 293 | 293 | function auth_spip_verifier_login($new_login, $id_auteur = 0, $serveur = '') { |
| 294 | - // login et mot de passe |
|
| 295 | - if (strlen($new_login)) { |
|
| 296 | - if (strlen($new_login) < _LOGIN_TROP_COURT) { |
|
| 297 | - return _T('info_login_trop_court_car_pluriel', ['nb' => _LOGIN_TROP_COURT]); |
|
| 298 | - } else { |
|
| 299 | - $n = sql_countsel( |
|
| 300 | - 'spip_auteurs', |
|
| 301 | - 'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'", |
|
| 302 | - '', |
|
| 303 | - '', |
|
| 304 | - $serveur |
|
| 305 | - ); |
|
| 306 | - if ($n) { |
|
| 307 | - return _T('info_login_existant'); |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - return ''; |
|
| 294 | + // login et mot de passe |
|
| 295 | + if (strlen($new_login)) { |
|
| 296 | + if (strlen($new_login) < _LOGIN_TROP_COURT) { |
|
| 297 | + return _T('info_login_trop_court_car_pluriel', ['nb' => _LOGIN_TROP_COURT]); |
|
| 298 | + } else { |
|
| 299 | + $n = sql_countsel( |
|
| 300 | + 'spip_auteurs', |
|
| 301 | + 'login=' . sql_quote($new_login) . ' AND id_auteur!=' . intval($id_auteur) . " AND statut!='5poubelle'", |
|
| 302 | + '', |
|
| 303 | + '', |
|
| 304 | + $serveur |
|
| 305 | + ); |
|
| 306 | + if ($n) { |
|
| 307 | + return _T('info_login_existant'); |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + return ''; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -321,41 +321,41 @@ discard block |
||
| 321 | 321 | * @return bool |
| 322 | 322 | */ |
| 323 | 323 | function auth_spip_modifier_login($new_login, $id_auteur, $serveur = '') { |
| 324 | - if (is_null($new_login) or auth_spip_verifier_login($new_login, $id_auteur, $serveur) != '') { |
|
| 325 | - return false; |
|
| 326 | - } |
|
| 327 | - if ( |
|
| 328 | - !$id_auteur = intval($id_auteur) |
|
| 329 | - or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 330 | - ) { |
|
| 331 | - return false; |
|
| 332 | - } |
|
| 333 | - if ($new_login == $auteur['login']) { |
|
| 334 | - return true; |
|
| 335 | - } // on a rien fait mais c'est bon ! |
|
| 336 | - |
|
| 337 | - include_spip('action/editer_auteur'); |
|
| 338 | - |
|
| 339 | - // vider le login des auteurs a la poubelle qui avaient ce meme login |
|
| 340 | - if (strlen($new_login)) { |
|
| 341 | - $anciens = sql_allfetsel( |
|
| 342 | - 'id_auteur', |
|
| 343 | - 'spip_auteurs', |
|
| 344 | - 'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'", |
|
| 345 | - '', |
|
| 346 | - '', |
|
| 347 | - '', |
|
| 348 | - '', |
|
| 349 | - $serveur |
|
| 350 | - ); |
|
| 351 | - while ($row = array_pop($anciens)) { |
|
| 352 | - auteur_modifier($row['id_auteur'], ['login' => ''], true); // manque la gestion de $serveur |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - auteur_modifier($id_auteur, ['login' => $new_login], true); // manque la gestion de $serveur |
|
| 357 | - |
|
| 358 | - return true; |
|
| 324 | + if (is_null($new_login) or auth_spip_verifier_login($new_login, $id_auteur, $serveur) != '') { |
|
| 325 | + return false; |
|
| 326 | + } |
|
| 327 | + if ( |
|
| 328 | + !$id_auteur = intval($id_auteur) |
|
| 329 | + or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 330 | + ) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 333 | + if ($new_login == $auteur['login']) { |
|
| 334 | + return true; |
|
| 335 | + } // on a rien fait mais c'est bon ! |
|
| 336 | + |
|
| 337 | + include_spip('action/editer_auteur'); |
|
| 338 | + |
|
| 339 | + // vider le login des auteurs a la poubelle qui avaient ce meme login |
|
| 340 | + if (strlen($new_login)) { |
|
| 341 | + $anciens = sql_allfetsel( |
|
| 342 | + 'id_auteur', |
|
| 343 | + 'spip_auteurs', |
|
| 344 | + 'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'", |
|
| 345 | + '', |
|
| 346 | + '', |
|
| 347 | + '', |
|
| 348 | + '', |
|
| 349 | + $serveur |
|
| 350 | + ); |
|
| 351 | + while ($row = array_pop($anciens)) { |
|
| 352 | + auteur_modifier($row['id_auteur'], ['login' => ''], true); // manque la gestion de $serveur |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + auteur_modifier($id_auteur, ['login' => $new_login], true); // manque la gestion de $serveur |
|
| 357 | + |
|
| 358 | + return true; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
@@ -367,44 +367,44 @@ discard block |
||
| 367 | 367 | * @return string |
| 368 | 368 | */ |
| 369 | 369 | function auth_spip_retrouver_login($login, $serveur = '') { |
| 370 | - if (!strlen($login)) { |
|
| 371 | - return null; |
|
| 372 | - } // pas la peine de requeter |
|
| 373 | - $l = sql_quote($login, $serveur, 'text'); |
|
| 374 | - if ( |
|
| 375 | - $r = sql_getfetsel( |
|
| 376 | - 'login', |
|
| 377 | - 'spip_auteurs', |
|
| 378 | - "statut<>'5poubelle'" . |
|
| 379 | - ' AND (length(pass)>0)' . |
|
| 380 | - " AND (login=$l)", |
|
| 381 | - '', |
|
| 382 | - '', |
|
| 383 | - '', |
|
| 384 | - '', |
|
| 385 | - $serveur |
|
| 386 | - ) |
|
| 387 | - ) { |
|
| 388 | - return $r; |
|
| 389 | - } |
|
| 390 | - // Si pas d'auteur avec ce login |
|
| 391 | - // regarder s'il a saisi son nom ou son mail. |
|
| 392 | - // Ne pas fusionner avec la requete precedente |
|
| 393 | - // car un nom peut etre homonyme d'un autre login |
|
| 394 | - else { |
|
| 395 | - return sql_getfetsel( |
|
| 396 | - 'login', |
|
| 397 | - 'spip_auteurs', |
|
| 398 | - "statut<>'5poubelle'" . |
|
| 399 | - ' AND (length(pass)>0)' . |
|
| 400 | - " AND (login<>'' AND (nom=$l OR email=$l))", |
|
| 401 | - '', |
|
| 402 | - '', |
|
| 403 | - '', |
|
| 404 | - '', |
|
| 405 | - $serveur |
|
| 406 | - ); |
|
| 407 | - } |
|
| 370 | + if (!strlen($login)) { |
|
| 371 | + return null; |
|
| 372 | + } // pas la peine de requeter |
|
| 373 | + $l = sql_quote($login, $serveur, 'text'); |
|
| 374 | + if ( |
|
| 375 | + $r = sql_getfetsel( |
|
| 376 | + 'login', |
|
| 377 | + 'spip_auteurs', |
|
| 378 | + "statut<>'5poubelle'" . |
|
| 379 | + ' AND (length(pass)>0)' . |
|
| 380 | + " AND (login=$l)", |
|
| 381 | + '', |
|
| 382 | + '', |
|
| 383 | + '', |
|
| 384 | + '', |
|
| 385 | + $serveur |
|
| 386 | + ) |
|
| 387 | + ) { |
|
| 388 | + return $r; |
|
| 389 | + } |
|
| 390 | + // Si pas d'auteur avec ce login |
|
| 391 | + // regarder s'il a saisi son nom ou son mail. |
|
| 392 | + // Ne pas fusionner avec la requete precedente |
|
| 393 | + // car un nom peut etre homonyme d'un autre login |
|
| 394 | + else { |
|
| 395 | + return sql_getfetsel( |
|
| 396 | + 'login', |
|
| 397 | + 'spip_auteurs', |
|
| 398 | + "statut<>'5poubelle'" . |
|
| 399 | + ' AND (length(pass)>0)' . |
|
| 400 | + " AND (login<>'' AND (nom=$l OR email=$l))", |
|
| 401 | + '', |
|
| 402 | + '', |
|
| 403 | + '', |
|
| 404 | + '', |
|
| 405 | + $serveur |
|
| 406 | + ); |
|
| 407 | + } |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -415,11 +415,11 @@ discard block |
||
| 415 | 415 | * toujours true pour un auteur cree dans SPIP |
| 416 | 416 | */ |
| 417 | 417 | function auth_spip_autoriser_modifier_pass(string $serveur = ''): bool { |
| 418 | - // les fonctions d'ecriture sur base distante sont encore incompletes |
|
| 419 | - if (strlen($serveur)) { |
|
| 420 | - return false; |
|
| 421 | - } |
|
| 422 | - return true; |
|
| 418 | + // les fonctions d'ecriture sur base distante sont encore incompletes |
|
| 419 | + if (strlen($serveur)) { |
|
| 420 | + return false; |
|
| 421 | + } |
|
| 422 | + return true; |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -440,12 +440,12 @@ discard block |
||
| 440 | 440 | * message d'erreur si login non valide, chaine vide sinon |
| 441 | 441 | */ |
| 442 | 442 | function auth_spip_verifier_pass($login, #[\SensitiveParameter] $new_pass, $id_auteur = 0, $serveur = '') { |
| 443 | - // login et mot de passe |
|
| 444 | - if (strlen($new_pass) < _PASS_LONGUEUR_MINI) { |
|
| 445 | - return _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]); |
|
| 446 | - } |
|
| 443 | + // login et mot de passe |
|
| 444 | + if (strlen($new_pass) < _PASS_LONGUEUR_MINI) { |
|
| 445 | + return _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]); |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | - return ''; |
|
| 448 | + return ''; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
@@ -459,47 +459,47 @@ discard block |
||
| 459 | 459 | * @return bool |
| 460 | 460 | */ |
| 461 | 461 | function auth_spip_modifier_pass($login, #[\SensitiveParameter] $new_pass, $id_auteur, $serveur = '') { |
| 462 | - if (is_null($new_pass) or auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 463 | - return false; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - if ( |
|
| 467 | - !$id_auteur = intval($id_auteur) |
|
| 468 | - or !$auteur = sql_fetsel('login, statut, webmestre', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 469 | - ) { |
|
| 470 | - return false; |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - $cles = SpipCles::instance(); |
|
| 474 | - $secret = $cles->getSecretAuth(); |
|
| 475 | - if (!$secret) { |
|
| 476 | - if (auth_spip_initialiser_secret()) { |
|
| 477 | - $secret = $cles->getSecretAuth(); |
|
| 478 | - } |
|
| 479 | - else { |
|
| 480 | - return false; |
|
| 481 | - } |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - |
|
| 485 | - include_spip('inc/acces'); |
|
| 486 | - $set = [ |
|
| 487 | - 'pass' => Password::hacher($new_pass, $secret), |
|
| 488 | - 'htpass' => generer_htpass($new_pass), |
|
| 489 | - 'alea_actuel' => creer_uniqid(), // @deprecated 4.1 |
|
| 490 | - 'alea_futur' => creer_uniqid(), // @deprecated 4.1 |
|
| 491 | - 'low_sec' => '', |
|
| 492 | - ]; |
|
| 493 | - |
|
| 494 | - // si c'est un webmestre, on met a jour son backup des cles |
|
| 495 | - if ($auteur['statut'] === '0minirezo' and $auteur['webmestre'] === 'oui') { |
|
| 496 | - $set['backup_cles'] = $cles->backup($new_pass); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - include_spip('action/editer_auteur'); |
|
| 500 | - auteur_modifier($id_auteur, $set, true); // manque la gestion de $serveur |
|
| 501 | - |
|
| 502 | - return true; // on a bien modifie le pass |
|
| 462 | + if (is_null($new_pass) or auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 463 | + return false; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + if ( |
|
| 467 | + !$id_auteur = intval($id_auteur) |
|
| 468 | + or !$auteur = sql_fetsel('login, statut, webmestre', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur) |
|
| 469 | + ) { |
|
| 470 | + return false; |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + $cles = SpipCles::instance(); |
|
| 474 | + $secret = $cles->getSecretAuth(); |
|
| 475 | + if (!$secret) { |
|
| 476 | + if (auth_spip_initialiser_secret()) { |
|
| 477 | + $secret = $cles->getSecretAuth(); |
|
| 478 | + } |
|
| 479 | + else { |
|
| 480 | + return false; |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + |
|
| 485 | + include_spip('inc/acces'); |
|
| 486 | + $set = [ |
|
| 487 | + 'pass' => Password::hacher($new_pass, $secret), |
|
| 488 | + 'htpass' => generer_htpass($new_pass), |
|
| 489 | + 'alea_actuel' => creer_uniqid(), // @deprecated 4.1 |
|
| 490 | + 'alea_futur' => creer_uniqid(), // @deprecated 4.1 |
|
| 491 | + 'low_sec' => '', |
|
| 492 | + ]; |
|
| 493 | + |
|
| 494 | + // si c'est un webmestre, on met a jour son backup des cles |
|
| 495 | + if ($auteur['statut'] === '0minirezo' and $auteur['webmestre'] === 'oui') { |
|
| 496 | + $set['backup_cles'] = $cles->backup($new_pass); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + include_spip('action/editer_auteur'); |
|
| 500 | + auteur_modifier($id_auteur, $set, true); // manque la gestion de $serveur |
|
| 501 | + |
|
| 502 | + return true; // on a bien modifie le pass |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | /** |
@@ -513,58 +513,58 @@ discard block |
||
| 513 | 513 | * @return void |
| 514 | 514 | */ |
| 515 | 515 | function auth_spip_synchroniser_distant($id_auteur, $champs, $options = [], string $serveur = ''): void { |
| 516 | - // ne rien faire pour une base distante : on ne sait pas regenerer les htaccess |
|
| 517 | - if (strlen($serveur)) { |
|
| 518 | - return; |
|
| 519 | - } |
|
| 520 | - // si un login, pass ou statut a ete modifie |
|
| 521 | - // regenerer les fichier htpass |
|
| 522 | - if ( |
|
| 523 | - isset($champs['login']) |
|
| 524 | - or isset($champs['pass']) |
|
| 525 | - or isset($champs['statut']) |
|
| 526 | - or (isset($options['all']) and $options['all']) |
|
| 527 | - ) { |
|
| 528 | - $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 529 | - $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 530 | - |
|
| 531 | - // Cette variable de configuration peut etre posee par un plugin |
|
| 532 | - // par exemple acces_restreint ; |
|
| 533 | - // si .htaccess existe, outrepasser spip_meta |
|
| 534 | - if ( |
|
| 535 | - (!isset($GLOBALS['meta']['creer_htpasswd']) or ($GLOBALS['meta']['creer_htpasswd'] != 'oui')) |
|
| 536 | - and !@file_exists($htaccess) |
|
| 537 | - ) { |
|
| 538 | - spip_unlink($htpasswd); |
|
| 539 | - spip_unlink($htpasswd . '-admin'); |
|
| 540 | - |
|
| 541 | - return; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre |
|
| 545 | - # de devenir redacteur le cas echeant (auth http)... a nettoyer |
|
| 546 | - // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) |
|
| 547 | - |
|
| 548 | - $p1 = ''; // login:htpass pour tous |
|
| 549 | - $p2 = ''; // login:htpass pour les admins |
|
| 550 | - $s = sql_select( |
|
| 551 | - 'login, htpass, statut', |
|
| 552 | - 'spip_auteurs', |
|
| 553 | - sql_in('statut', ['1comite', '0minirezo', 'nouveau']) |
|
| 554 | - ); |
|
| 555 | - while ($t = sql_fetch($s)) { |
|
| 556 | - if (strlen($t['login']) and strlen($t['htpass'])) { |
|
| 557 | - $p1 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 558 | - if ($t['statut'] == '0minirezo') { |
|
| 559 | - $p2 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 560 | - } |
|
| 561 | - } |
|
| 562 | - } |
|
| 563 | - sql_free($s); |
|
| 564 | - if ($p1) { |
|
| 565 | - ecrire_fichier($htpasswd, $p1); |
|
| 566 | - ecrire_fichier($htpasswd . '-admin', $p2); |
|
| 567 | - spip_log("Ecriture de $htpasswd et $htpasswd-admin"); |
|
| 568 | - } |
|
| 569 | - } |
|
| 516 | + // ne rien faire pour une base distante : on ne sait pas regenerer les htaccess |
|
| 517 | + if (strlen($serveur)) { |
|
| 518 | + return; |
|
| 519 | + } |
|
| 520 | + // si un login, pass ou statut a ete modifie |
|
| 521 | + // regenerer les fichier htpass |
|
| 522 | + if ( |
|
| 523 | + isset($champs['login']) |
|
| 524 | + or isset($champs['pass']) |
|
| 525 | + or isset($champs['statut']) |
|
| 526 | + or (isset($options['all']) and $options['all']) |
|
| 527 | + ) { |
|
| 528 | + $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME; |
|
| 529 | + $htpasswd = _DIR_TMP . _AUTH_USER_FILE; |
|
| 530 | + |
|
| 531 | + // Cette variable de configuration peut etre posee par un plugin |
|
| 532 | + // par exemple acces_restreint ; |
|
| 533 | + // si .htaccess existe, outrepasser spip_meta |
|
| 534 | + if ( |
|
| 535 | + (!isset($GLOBALS['meta']['creer_htpasswd']) or ($GLOBALS['meta']['creer_htpasswd'] != 'oui')) |
|
| 536 | + and !@file_exists($htaccess) |
|
| 537 | + ) { |
|
| 538 | + spip_unlink($htpasswd); |
|
| 539 | + spip_unlink($htpasswd . '-admin'); |
|
| 540 | + |
|
| 541 | + return; |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre |
|
| 545 | + # de devenir redacteur le cas echeant (auth http)... a nettoyer |
|
| 546 | + // attention, il faut au prealable se connecter a la base (necessaire car utilise par install) |
|
| 547 | + |
|
| 548 | + $p1 = ''; // login:htpass pour tous |
|
| 549 | + $p2 = ''; // login:htpass pour les admins |
|
| 550 | + $s = sql_select( |
|
| 551 | + 'login, htpass, statut', |
|
| 552 | + 'spip_auteurs', |
|
| 553 | + sql_in('statut', ['1comite', '0minirezo', 'nouveau']) |
|
| 554 | + ); |
|
| 555 | + while ($t = sql_fetch($s)) { |
|
| 556 | + if (strlen($t['login']) and strlen($t['htpass'])) { |
|
| 557 | + $p1 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 558 | + if ($t['statut'] == '0minirezo') { |
|
| 559 | + $p2 .= $t['login'] . ':' . $t['htpass'] . "\n"; |
|
| 560 | + } |
|
| 561 | + } |
|
| 562 | + } |
|
| 563 | + sql_free($s); |
|
| 564 | + if ($p1) { |
|
| 565 | + ecrire_fichier($htpasswd, $p1); |
|
| 566 | + ecrire_fichier($htpasswd . '-admin', $p2); |
|
| 567 | + spip_log("Ecriture de $htpasswd et $htpasswd-admin"); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | 570 | } |
@@ -11,77 +11,77 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | # Les information d'une rubrique selectionnee dans le mini navigateur |
| 18 | 18 | |
| 19 | 19 | function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff') { |
| 20 | - include_spip('inc/texte'); |
|
| 21 | - $titre = $descriptif = ''; |
|
| 22 | - if ($type === 'rubrique') { |
|
| 23 | - $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id)); |
|
| 24 | - if ($row) { |
|
| 25 | - $titre = typo($row['titre']); |
|
| 26 | - $descriptif = propre($row['descriptif']); |
|
| 27 | - } else { |
|
| 28 | - $titre = _T('info_racine_site'); |
|
| 29 | - } |
|
| 30 | - } |
|
| 20 | + include_spip('inc/texte'); |
|
| 21 | + $titre = $descriptif = ''; |
|
| 22 | + if ($type === 'rubrique') { |
|
| 23 | + $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id)); |
|
| 24 | + if ($row) { |
|
| 25 | + $titre = typo($row['titre']); |
|
| 26 | + $descriptif = propre($row['descriptif']); |
|
| 27 | + } else { |
|
| 28 | + $titre = _T('info_racine_site'); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - $res = ''; |
|
| 33 | - if ( |
|
| 34 | - $type === 'rubrique' |
|
| 35 | - and intval($GLOBALS['visiteur_session']['prefs']['display'] ?? 0) !== 1 |
|
| 36 | - and isset($GLOBALS['meta']['image_process']) |
|
| 37 | - ) { |
|
| 38 | - if ($GLOBALS['meta']['image_process'] !== 'non') { |
|
| 39 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | - if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 41 | - [$fid, $dir, $nom, $format] = $res; |
|
| 42 | - include_spip('inc/filtres_images_mini'); |
|
| 43 | - $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 44 | - if ($res) { |
|
| 45 | - $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 32 | + $res = ''; |
|
| 33 | + if ( |
|
| 34 | + $type === 'rubrique' |
|
| 35 | + and intval($GLOBALS['visiteur_session']['prefs']['display'] ?? 0) !== 1 |
|
| 36 | + and isset($GLOBALS['meta']['image_process']) |
|
| 37 | + ) { |
|
| 38 | + if ($GLOBALS['meta']['image_process'] !== 'non') { |
|
| 39 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | + if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 41 | + [$fid, $dir, $nom, $format] = $res; |
|
| 42 | + include_spip('inc/filtres_images_mini'); |
|
| 43 | + $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 44 | + if ($res) { |
|
| 45 | + $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 52 | - $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 53 | - $id = intval($id); |
|
| 51 | + $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 52 | + $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 53 | + $id = intval($id); |
|
| 54 | 54 | |
| 55 | 55 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 56 | 56 | # et l'affichage de son titre dans le bandeau |
| 57 | - $titre = strtr( |
|
| 58 | - str_replace( |
|
| 59 | - "'", |
|
| 60 | - '’', |
|
| 61 | - str_replace('"', '"', textebrut($titre)) |
|
| 62 | - ), |
|
| 63 | - "\n\r", |
|
| 64 | - ' ' |
|
| 65 | - ); |
|
| 57 | + $titre = strtr( |
|
| 58 | + str_replace( |
|
| 59 | + "'", |
|
| 60 | + '’', |
|
| 61 | + str_replace('"', '"', textebrut($titre)) |
|
| 62 | + ), |
|
| 63 | + "\n\r", |
|
| 64 | + ' ' |
|
| 65 | + ); |
|
| 66 | 66 | |
| 67 | - $js_func = $do . '_selection_titre'; |
|
| 67 | + $js_func = $do . '_selection_titre'; |
|
| 68 | 68 | |
| 69 | - return "<div style='display: none;'>" |
|
| 70 | - . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 71 | - . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 72 | - . entites_html($titre) |
|
| 73 | - . '" />' |
|
| 74 | - . '</div>' |
|
| 75 | - . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 76 | - . '<div class="informer__item">' |
|
| 77 | - . (!$res ? '' : $res) |
|
| 78 | - . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>' |
|
| 79 | - . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>') |
|
| 80 | - . '</div>' |
|
| 81 | - . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 82 | - . "<input type='submit' class='fondo btn submit' value='" |
|
| 83 | - . _T('bouton_choisir') |
|
| 84 | - . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 85 | - . '</div>' |
|
| 86 | - . '</div>'; |
|
| 69 | + return "<div style='display: none;'>" |
|
| 70 | + . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 71 | + . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 72 | + . entites_html($titre) |
|
| 73 | + . '" />' |
|
| 74 | + . '</div>' |
|
| 75 | + . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 76 | + . '<div class="informer__item">' |
|
| 77 | + . (!$res ? '' : $res) |
|
| 78 | + . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>' |
|
| 79 | + . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>') |
|
| 80 | + . '</div>' |
|
| 81 | + . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 82 | + . "<input type='submit' class='fondo btn submit' value='" |
|
| 83 | + . _T('bouton_choisir') |
|
| 84 | + . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 85 | + . '</div>' |
|
| 86 | + . '</div>'; |
|
| 87 | 87 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | include_spip('inc/texte'); |
| 21 | 21 | $titre = $descriptif = ''; |
| 22 | 22 | if ($type === 'rubrique') { |
| 23 | - $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id)); |
|
| 23 | + $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = '.intval($id)); |
|
| 24 | 24 | if ($row) { |
| 25 | 25 | $titre = typo($row['titre']); |
| 26 | 26 | $descriptif = propre($row['descriptif']); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | include_spip('inc/filtres_images_mini'); |
| 43 | 43 | $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
| 44 | 44 | if ($res) { |
| 45 | - $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 45 | + $res = "<div class='informer__media' style='float: ".$GLOBALS['spip_lang_right'].'; margin-'.$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>"; |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -64,21 +64,21 @@ discard block |
||
| 64 | 64 | ' ' |
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | - $js_func = $do . '_selection_titre'; |
|
| 67 | + $js_func = $do.'_selection_titre'; |
|
| 68 | 68 | |
| 69 | 69 | return "<div style='display: none;'>" |
| 70 | - . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 71 | - . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 70 | + . "<input type='text' id='".$rac."_sel' value='$id' />" |
|
| 71 | + . "<input type='text' id='".$rac."_sel2' value=\"" |
|
| 72 | 72 | . entites_html($titre) |
| 73 | 73 | . '" />' |
| 74 | 74 | . '</div>' |
| 75 | 75 | . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
| 76 | 76 | . '<div class="informer__item">' |
| 77 | 77 | . (!$res ? '' : $res) |
| 78 | - . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>' |
|
| 79 | - . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>') |
|
| 78 | + . "<p class='informer__titre'><b>".safehtml($titre).'</b></p>' |
|
| 79 | + . (!$descriptif ? '' : "<div class='informer__descriptif'>".safehtml($descriptif).'</div>') |
|
| 80 | 80 | . '</div>' |
| 81 | - . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 81 | + . "<div class='informer__action' style='clear:both; text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 82 | 82 | . "<input type='submit' class='fondo btn submit' value='" |
| 83 | 83 | . _T('bouton_choisir') |
| 84 | 84 | . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
@@ -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 | /** |
@@ -43,25 +43,25 @@ discard block |
||
| 43 | 43 | * @return string Code HTML |
| 44 | 44 | **/ |
| 45 | 45 | function inc_commencer_page_dist( |
| 46 | - $titre = '', |
|
| 47 | - $rubrique = 'accueil', |
|
| 48 | - $sous_rubrique = 'accueil', |
|
| 49 | - $id_rubrique = '', |
|
| 50 | - $menu = true, |
|
| 51 | - $minipres = false, |
|
| 52 | - $alertes = true |
|
| 46 | + $titre = '', |
|
| 47 | + $rubrique = 'accueil', |
|
| 48 | + $sous_rubrique = 'accueil', |
|
| 49 | + $id_rubrique = '', |
|
| 50 | + $menu = true, |
|
| 51 | + $minipres = false, |
|
| 52 | + $alertes = true |
|
| 53 | 53 | ) { |
| 54 | 54 | |
| 55 | - include_spip('inc/headers'); |
|
| 55 | + include_spip('inc/headers'); |
|
| 56 | 56 | |
| 57 | - http_no_cache(); |
|
| 57 | + http_no_cache(); |
|
| 58 | 58 | |
| 59 | - return init_entete($titre, $id_rubrique, $minipres) |
|
| 60 | - . init_body($rubrique, $sous_rubrique, $id_rubrique, $menu) |
|
| 61 | - . "<div id='page'>" |
|
| 62 | - . auteurs_recemment_connectes($GLOBALS['connect_id_auteur']) |
|
| 63 | - . ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '') |
|
| 64 | - . '<div class="largeur">'; |
|
| 59 | + return init_entete($titre, $id_rubrique, $minipres) |
|
| 60 | + . init_body($rubrique, $sous_rubrique, $id_rubrique, $menu) |
|
| 61 | + . "<div id='page'>" |
|
| 62 | + . auteurs_recemment_connectes($GLOBALS['connect_id_auteur']) |
|
| 63 | + . ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '') |
|
| 64 | + . '<div class="largeur">'; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | * Entête du fichier HTML avec le DOCTYPE |
| 83 | 83 | */ |
| 84 | 84 | function init_entete($titre = '', $dummy = 0, $minipres = false) { |
| 85 | - include_spip('inc/texte'); |
|
| 86 | - if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 87 | - $nom_site_spip = _T('info_mon_site_spip'); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - $titre = '[' |
|
| 91 | - . $nom_site_spip |
|
| 92 | - . ']' |
|
| 93 | - . ($titre ? ' ' . textebrut(typo($titre)) : ''); |
|
| 94 | - |
|
| 95 | - return _DOCTYPE_ECRIRE |
|
| 96 | - . html_lang_attributes() |
|
| 97 | - . "<head>\n" |
|
| 98 | - . init_head($titre, $dummy, $minipres) |
|
| 99 | - . "</head>\n"; |
|
| 85 | + include_spip('inc/texte'); |
|
| 86 | + if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 87 | + $nom_site_spip = _T('info_mon_site_spip'); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + $titre = '[' |
|
| 91 | + . $nom_site_spip |
|
| 92 | + . ']' |
|
| 93 | + . ($titre ? ' ' . textebrut(typo($titre)) : ''); |
|
| 94 | + |
|
| 95 | + return _DOCTYPE_ECRIRE |
|
| 96 | + . html_lang_attributes() |
|
| 97 | + . "<head>\n" |
|
| 98 | + . init_head($titre, $dummy, $minipres) |
|
| 99 | + . "</head>\n"; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | 112 | function init_head($titre = '', $dummy = 0, $minipres = false) { |
| 113 | - return recuperer_fond('prive/squelettes/head/dist', ['titre' => $titre, 'minipres' => $minipres ? ' ' : '']); |
|
| 113 | + return recuperer_fond('prive/squelettes/head/dist', ['titre' => $titre, 'minipres' => $minipres ? ' ' : '']); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -132,20 +132,20 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) { |
| 134 | 134 | |
| 135 | - $res = pipeline('body_prive', "<body class='" |
|
| 136 | - . init_body_class() . ' ' . _request('exec') . "'" |
|
| 137 | - . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '') |
|
| 138 | - . '>'); |
|
| 135 | + $res = pipeline('body_prive', "<body class='" |
|
| 136 | + . init_body_class() . ' ' . _request('exec') . "'" |
|
| 137 | + . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '') |
|
| 138 | + . '>'); |
|
| 139 | 139 | |
| 140 | - if (!$menu) { |
|
| 141 | - return $res; |
|
| 142 | - } |
|
| 140 | + if (!$menu) { |
|
| 141 | + return $res; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | |
| 145 | - $bandeau = charger_fonction('bandeau', 'inc'); |
|
| 145 | + $bandeau = charger_fonction('bandeau', 'inc'); |
|
| 146 | 146 | |
| 147 | - return $res |
|
| 148 | - . $bandeau(); |
|
| 147 | + return $res |
|
| 148 | + . $bandeau(); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -157,23 +157,23 @@ discard block |
||
| 157 | 157 | * @return string Classes CSS (séparées par des espaces) |
| 158 | 158 | */ |
| 159 | 159 | function init_body_class() { |
| 160 | - $display_modes = [ |
|
| 161 | - 0 => 'icones_img_texte' // défaut. |
|
| 162 | - /*init*/, |
|
| 163 | - 1 => 'icones_texte', |
|
| 164 | - 2 => 'icones_img_texte', |
|
| 165 | - 3 => 'icones_img' |
|
| 166 | - ]; |
|
| 160 | + $display_modes = [ |
|
| 161 | + 0 => 'icones_img_texte' // défaut. |
|
| 162 | + /*init*/, |
|
| 163 | + 1 => 'icones_texte', |
|
| 164 | + 2 => 'icones_img_texte', |
|
| 165 | + 3 => 'icones_img' |
|
| 166 | + ]; |
|
| 167 | 167 | |
| 168 | - $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 168 | + $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 169 | 169 | |
| 170 | - $display_mode = $display_modes[intval($prefs['display'] ?? 0)] ?? $display_modes[0]; |
|
| 171 | - $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones'; |
|
| 170 | + $display_mode = $display_modes[intval($prefs['display'] ?? 0)] ?? $display_modes[0]; |
|
| 171 | + $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones'; |
|
| 172 | 172 | |
| 173 | - $couleur = intval($prefs['couleur'] ?? 2); |
|
| 173 | + $couleur = intval($prefs['couleur'] ?? 2); |
|
| 174 | 174 | |
| 175 | - $classes = "spip-theme-colors-$couleur $spip_display_navigation $display_mode"; |
|
| 176 | - return spip_sanitize_classname($classes); |
|
| 175 | + $classes = "spip-theme-colors-$couleur $spip_display_navigation $display_mode"; |
|
| 176 | + return spip_sanitize_classname($classes); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
@@ -184,5 +184,5 @@ discard block |
||
| 184 | 184 | * @return string |
| 185 | 185 | */ |
| 186 | 186 | function auteurs_recemment_connectes($id_auteur) { |
| 187 | - return recuperer_fond('prive/objets/liste/auteurs_enligne'); |
|
| 187 | + return recuperer_fond('prive/objets/liste/auteurs_enligne'); |
|
| 188 | 188 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $titre = '[' |
| 91 | 91 | . $nom_site_spip |
| 92 | 92 | . ']' |
| 93 | - . ($titre ? ' ' . textebrut(typo($titre)) : ''); |
|
| 93 | + . ($titre ? ' '.textebrut(typo($titre)) : ''); |
|
| 94 | 94 | |
| 95 | 95 | return _DOCTYPE_ECRIRE |
| 96 | 96 | . html_lang_attributes() |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) { |
| 134 | 134 | |
| 135 | 135 | $res = pipeline('body_prive', "<body class='" |
| 136 | - . init_body_class() . ' ' . _request('exec') . "'" |
|
| 136 | + . init_body_class().' '._request('exec')."'" |
|
| 137 | 137 | . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '') |
| 138 | 138 | . '>'); |
| 139 | 139 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** Drapeau indiquant que l'on est dans l'espace privé */ |
| 20 | 20 | define('_ESPACE_PRIVE', true); |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - include 'inc_version.php'; |
|
| 22 | + include 'inc_version.php'; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | include_spip('inc/cookie'); |
@@ -35,18 +35,18 @@ discard block |
||
| 35 | 35 | // alors il faut blinder les variables d'URL |
| 36 | 36 | // |
| 37 | 37 | if (autoriser_sans_cookie($exec, false)) { |
| 38 | - if (!isset($reinstall)) { |
|
| 39 | - $reinstall = 'non'; |
|
| 40 | - } |
|
| 41 | - $var_auth = true; |
|
| 38 | + if (!isset($reinstall)) { |
|
| 39 | + $reinstall = 'non'; |
|
| 40 | + } |
|
| 41 | + $var_auth = true; |
|
| 42 | 42 | } else { |
| 43 | - // Authentification, redefinissable |
|
| 44 | - $auth = charger_fonction('auth', 'inc'); |
|
| 45 | - $var_auth = $auth(); |
|
| 46 | - if ($var_auth) { |
|
| 47 | - echo auth_echec($var_auth); |
|
| 48 | - exit; |
|
| 49 | - } |
|
| 43 | + // Authentification, redefinissable |
|
| 44 | + $auth = charger_fonction('auth', 'inc'); |
|
| 45 | + $var_auth = $auth(); |
|
| 46 | + if ($var_auth) { |
|
| 47 | + echo auth_echec($var_auth); |
|
| 48 | + exit; |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // initialiser a la langue par defaut |
@@ -57,29 +57,29 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | if (_request('action') or _request('var_ajax') or _request('formulaire_action')) { |
| 60 | - if (!autoriser_sans_cookie($exec)) { |
|
| 61 | - // Charger l'aiguilleur qui va mettre sur la bonne voie les traitements derogatoires |
|
| 62 | - include_spip('public/aiguiller'); |
|
| 63 | - if ( |
|
| 64 | - // cas des appels actions ?action=xxx |
|
| 65 | - traiter_appels_actions() |
|
| 66 | - or |
|
| 67 | - // cas des hits ajax sur les inclusions ajax |
|
| 68 | - traiter_appels_inclusions_ajax() |
|
| 69 | - or |
|
| 70 | - // cas des formulaires charger/verifier/traiter |
|
| 71 | - traiter_formulaires_dynamiques() |
|
| 72 | - ) { |
|
| 73 | - exit; |
|
| 74 | - } // le hit est fini ! |
|
| 75 | - } |
|
| 60 | + if (!autoriser_sans_cookie($exec)) { |
|
| 61 | + // Charger l'aiguilleur qui va mettre sur la bonne voie les traitements derogatoires |
|
| 62 | + include_spip('public/aiguiller'); |
|
| 63 | + if ( |
|
| 64 | + // cas des appels actions ?action=xxx |
|
| 65 | + traiter_appels_actions() |
|
| 66 | + or |
|
| 67 | + // cas des hits ajax sur les inclusions ajax |
|
| 68 | + traiter_appels_inclusions_ajax() |
|
| 69 | + or |
|
| 70 | + // cas des formulaires charger/verifier/traiter |
|
| 71 | + traiter_formulaires_dynamiques() |
|
| 72 | + ) { |
|
| 73 | + exit; |
|
| 74 | + } // le hit est fini ! |
|
| 75 | + } |
|
| 76 | 76 | } |
| 77 | 77 | // securiser les redirect du back-office |
| 78 | 78 | if (_request('redirect')) { |
| 79 | - if (!function_exists('securiser_redirect_action')) { |
|
| 80 | - include_spip('public/aiguiller'); |
|
| 81 | - } |
|
| 82 | - set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 79 | + if (!function_exists('securiser_redirect_action')) { |
|
| 80 | + include_spip('public/aiguiller'); |
|
| 81 | + } |
|
| 82 | + set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
@@ -89,12 +89,12 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | // Controle de la version, sauf si on est deja en train de s'en occuper |
| 91 | 91 | if ( |
| 92 | - !$reinstall == 'oui' |
|
| 93 | - and !_AJAX |
|
| 94 | - and isset($GLOBALS['meta']['version_installee']) |
|
| 95 | - and ($GLOBALS['spip_version_base'] != (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 92 | + !$reinstall == 'oui' |
|
| 93 | + and !_AJAX |
|
| 94 | + and isset($GLOBALS['meta']['version_installee']) |
|
| 95 | + and ($GLOBALS['spip_version_base'] != (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 96 | 96 | ) { |
| 97 | - $exec = 'demande_mise_a_jour'; |
|
| 97 | + $exec = 'demande_mise_a_jour'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Quand une action d'administration est en cours (meta "admin"), |
@@ -104,39 +104,39 @@ discard block |
||
| 104 | 104 | // sinon c'est qu'elle a ete interrompue et il faut la reprendre |
| 105 | 105 | |
| 106 | 106 | elseif (isset($GLOBALS['meta']['admin'])) { |
| 107 | - if (preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)) { |
|
| 108 | - [, $var_f, $n] = $l; |
|
| 109 | - } |
|
| 110 | - if ( |
|
| 111 | - _AJAX |
|
| 112 | - or !( |
|
| 113 | - isset($_COOKIE['spip_admin']) |
|
| 114 | - or (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']['statut'] == '0minirezo') |
|
| 115 | - ) |
|
| 116 | - ) { |
|
| 117 | - spip_log('Quand la meta admin vaut ' . |
|
| 118 | - $GLOBALS['meta']['admin'] . |
|
| 119 | - ' seul un admin peut se connecter et sans AJAX.' . |
|
| 120 | - ' En cas de probleme, detruire cette meta.'); |
|
| 121 | - die(_T('info_travaux_texte')); |
|
| 122 | - } |
|
| 123 | - if ($n) { |
|
| 124 | - [, $var_f, $n] = $l; |
|
| 125 | - if (tester_url_ecrire("base_$var_f")) { |
|
| 126 | - $var_f = "base_$var_f"; |
|
| 127 | - } |
|
| 128 | - if ($var_f != $exec) { |
|
| 129 | - spip_log("Le script $var_f lance par auteur$n se substitue a l'exec $exec"); |
|
| 130 | - $exec = $var_f; |
|
| 131 | - set_request('exec', $exec); |
|
| 132 | - } |
|
| 133 | - } |
|
| 107 | + if (preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)) { |
|
| 108 | + [, $var_f, $n] = $l; |
|
| 109 | + } |
|
| 110 | + if ( |
|
| 111 | + _AJAX |
|
| 112 | + or !( |
|
| 113 | + isset($_COOKIE['spip_admin']) |
|
| 114 | + or (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']['statut'] == '0minirezo') |
|
| 115 | + ) |
|
| 116 | + ) { |
|
| 117 | + spip_log('Quand la meta admin vaut ' . |
|
| 118 | + $GLOBALS['meta']['admin'] . |
|
| 119 | + ' seul un admin peut se connecter et sans AJAX.' . |
|
| 120 | + ' En cas de probleme, detruire cette meta.'); |
|
| 121 | + die(_T('info_travaux_texte')); |
|
| 122 | + } |
|
| 123 | + if ($n) { |
|
| 124 | + [, $var_f, $n] = $l; |
|
| 125 | + if (tester_url_ecrire("base_$var_f")) { |
|
| 126 | + $var_f = "base_$var_f"; |
|
| 127 | + } |
|
| 128 | + if ($var_f != $exec) { |
|
| 129 | + spip_log("Le script $var_f lance par auteur$n se substitue a l'exec $exec"); |
|
| 130 | + $exec = $var_f; |
|
| 131 | + set_request('exec', $exec); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | // si nom pas plausible, prendre le script par defaut |
| 136 | 136 | // attention aux deux cas 404/403 qui commencent par un 4 ! |
| 137 | 137 | elseif (!preg_match(',^[a-z4_][0-9a-z_-]*$,i', $exec)) { |
| 138 | - $exec = 'accueil'; |
|
| 139 | - set_request('exec', $exec); |
|
| 138 | + $exec = 'accueil'; |
|
| 139 | + set_request('exec', $exec); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // si la langue est specifiee par cookie et ne correspond pas |
@@ -144,19 +144,19 @@ discard block |
||
| 144 | 144 | // on appelle directement la fonction, car un appel d'action peut conduire a une boucle infinie |
| 145 | 145 | // si le cookie n'est pas pose correctement dans l'action |
| 146 | 146 | if ( |
| 147 | - !$var_auth and isset($_COOKIE['spip_lang_ecrire']) |
|
| 148 | - and $_COOKIE['spip_lang_ecrire'] <> $GLOBALS['visiteur_session']['lang'] |
|
| 147 | + !$var_auth and isset($_COOKIE['spip_lang_ecrire']) |
|
| 148 | + and $_COOKIE['spip_lang_ecrire'] <> $GLOBALS['visiteur_session']['lang'] |
|
| 149 | 149 | ) { |
| 150 | - include_spip('action/converser'); |
|
| 151 | - action_converser_post($GLOBALS['visiteur_session']['lang'], true); |
|
| 150 | + include_spip('action/converser'); |
|
| 151 | + action_converser_post($GLOBALS['visiteur_session']['lang'], true); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | if ($var_f = tester_url_ecrire($exec)) { |
| 155 | - $var_f = charger_fonction($var_f); |
|
| 156 | - $var_f(); // at last |
|
| 155 | + $var_f = charger_fonction($var_f); |
|
| 156 | + $var_f(); // at last |
|
| 157 | 157 | } else { |
| 158 | - // Rien de connu: rerouter vers exec=404 au lieu d'echouer |
|
| 159 | - // ce qui permet de laisser la main a un plugin |
|
| 160 | - $var_f = charger_fonction('404'); |
|
| 161 | - $var_f($exec); |
|
| 158 | + // Rien de connu: rerouter vers exec=404 au lieu d'echouer |
|
| 159 | + // ce qui permet de laisser la main a un plugin |
|
| 160 | + $var_f = charger_fonction('404'); |
|
| 161 | + $var_f($exec); |
|
| 162 | 162 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * Ce programme est un logiciel libre distribué sous licence GNU/GPL. * |
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 12 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Fichier d'exécution de l'interface privée |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | // Determiner l'action demandee |
| 30 | 30 | // |
| 31 | 31 | |
| 32 | -$exec = (string)_request('exec'); |
|
| 32 | +$exec = (string) _request('exec'); |
|
| 33 | 33 | $reinstall = (!is_null(_request('reinstall'))) ? _request('reinstall') : ($exec == 'install' ? 'oui' : null); |
| 34 | 34 | // |
| 35 | 35 | // Les scripts d'insallation n'authentifient pas, forcement, |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | or (isset($GLOBALS['visiteur_session']) and $GLOBALS['visiteur_session']['statut'] == '0minirezo') |
| 116 | 116 | ) |
| 117 | 117 | ) { |
| 118 | - spip_log('Quand la meta admin vaut ' . |
|
| 119 | - $GLOBALS['meta']['admin'] . |
|
| 120 | - ' seul un admin peut se connecter et sans AJAX.' . |
|
| 118 | + spip_log('Quand la meta admin vaut '. |
|
| 119 | + $GLOBALS['meta']['admin']. |
|
| 120 | + ' seul un admin peut se connecter et sans AJAX.'. |
|
| 121 | 121 | ' En cas de probleme, detruire cette meta.'); |
| 122 | 122 | die(_T('info_travaux_texte')); |
| 123 | 123 | } |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | function objet_modifier($objet, $id, $set = null) { |
| 78 | 78 | if (($t = objet_type($objet)) !== $objet) { |
| 79 | - spip_log("objet_modifier: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 79 | + spip_log("objet_modifier: appel avec type $objet invalide au lieu de $t", 'editer'._LOG_INFO_IMPORTANTE); |
|
| 80 | 80 | $objet = $t; |
| 81 | 81 | } |
| 82 | 82 | if ( |
| 83 | - include_spip('action/editer_' . $objet) |
|
| 84 | - and function_exists($modifier = $objet . '_modifier') |
|
| 83 | + include_spip('action/editer_'.$objet) |
|
| 84 | + and function_exists($modifier = $objet.'_modifier') |
|
| 85 | 85 | ) { |
| 86 | 86 | return $modifier($id, $set); |
| 87 | 87 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 91 | 91 | $desc = $trouver_table($table_sql); |
| 92 | 92 | if (!$desc or !isset($desc['field'])) { |
| 93 | - spip_log("Objet $objet inconnu dans objet_modifier", 'editer' . _LOG_ERREUR); |
|
| 93 | + spip_log("Objet $objet inconnu dans objet_modifier", 'editer'._LOG_ERREUR); |
|
| 94 | 94 | |
| 95 | 95 | return _L("Erreur objet $objet inconnu"); |
| 96 | 96 | } |
@@ -170,12 +170,12 @@ discard block |
||
| 170 | 170 | function objet_inserer($objet, $id_parent = null, $set = null) { |
| 171 | 171 | $d = null; |
| 172 | 172 | if (($t = objet_type($objet)) !== $objet) { |
| 173 | - spip_log("objet_inserer: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 173 | + spip_log("objet_inserer: appel avec type $objet invalide au lieu de $t", 'editer'._LOG_INFO_IMPORTANTE); |
|
| 174 | 174 | $objet = $t; |
| 175 | 175 | } |
| 176 | 176 | if ( |
| 177 | - include_spip('action/editer_' . $objet) |
|
| 178 | - and function_exists($inserer = $objet . '_inserer') |
|
| 177 | + include_spip('action/editer_'.$objet) |
|
| 178 | + and function_exists($inserer = $objet.'_inserer') |
|
| 179 | 179 | ) { |
| 180 | 180 | return $inserer($id_parent, $set); |
| 181 | 181 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
| 197 | 197 | $id_rubrique = $row['id_rubrique']; |
| 198 | 198 | } else { |
| 199 | - $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 199 | + $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $champs['id_rubrique'] = $id_rubrique; |
@@ -314,12 +314,12 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | function objet_instituer($objet, $id, $c, $calcul_rub = true) { |
| 316 | 316 | if (($t = objet_type($objet)) !== $objet) { |
| 317 | - spip_log("objet_instituer: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 317 | + spip_log("objet_instituer: appel avec type $objet invalide au lieu de $t", 'editer'._LOG_INFO_IMPORTANTE); |
|
| 318 | 318 | $objet = $t; |
| 319 | 319 | } |
| 320 | 320 | if ( |
| 321 | - include_spip('action/editer_' . $objet) |
|
| 322 | - and function_exists($instituer = $objet . '_instituer') |
|
| 321 | + include_spip('action/editer_'.$objet) |
|
| 322 | + and function_exists($instituer = $objet.'_instituer') |
|
| 323 | 323 | ) { |
| 324 | 324 | return $instituer($id, $c, $calcul_rub); |
| 325 | 325 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
| 349 | 349 | $sel[] = (isset($desc['field']['id_rubrique']) ? 'id_rubrique' : '0 as id_rubrique'); |
| 350 | 350 | |
| 351 | - $row = sql_fetsel($sel, $table_sql, id_table_objet($objet) . '=' . intval($id)); |
|
| 351 | + $row = sql_fetsel($sel, $table_sql, id_table_objet($objet).'='.intval($id)); |
|
| 352 | 352 | |
| 353 | 353 | $id_rubrique = $row['id_rubrique']; |
| 354 | 354 | $statut_ancien = $statut = $row['statut']; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | if ($s != 'publie' and autoriser('modifier', $objet, $id)) { |
| 372 | 372 | $statut = $champs['statut'] = $s; |
| 373 | 373 | } else { |
| 374 | - spip_log("editer_objet $objet #$id refus " . json_encode($c, JSON_THROW_ON_ERROR), 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 374 | + spip_log("editer_objet $objet #$id refus ".json_encode($c, JSON_THROW_ON_ERROR), 'editer'._LOG_INFO_IMPORTANTE); |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | and isset($c['id_parent']) |
| 402 | 402 | and $id_parent = $c['id_parent'] |
| 403 | 403 | and $id_parent != $id_rubrique |
| 404 | - and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent))) |
|
| 404 | + and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique='.intval($id_parent))) |
|
| 405 | 405 | ) { |
| 406 | 406 | $champs['id_rubrique'] = $id_parent; |
| 407 | 407 | |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | // Si on deplace l'objet |
| 501 | 501 | // changer aussi son secteur et sa langue (si heritee) |
| 502 | 502 | if (isset($champs['id_rubrique'])) { |
| 503 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 503 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique='.sql_quote($champs['id_rubrique'])); |
|
| 504 | 504 | $langue = $row_rub['lang']; |
| 505 | 505 | |
| 506 | 506 | if (isset($desc['field']['id_secteur'])) { |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | sql_fetsel( |
| 513 | 513 | '1', |
| 514 | 514 | $table_sql, |
| 515 | - id_table_objet($objet) . '=' . intval($id) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 515 | + id_table_objet($objet).'='.intval($id)." AND langue_choisie<>'oui' AND lang<>".sql_quote($langue) |
|
| 516 | 516 | ) |
| 517 | 517 | ) { |
| 518 | 518 | $champs['lang'] = $langue; |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | if (!$champs) { |
| 524 | 524 | return; |
| 525 | 525 | } |
| 526 | - sql_updateq($table_sql, $champs, id_table_objet($objet) . '=' . intval($id)); |
|
| 526 | + sql_updateq($table_sql, $champs, id_table_objet($objet).'='.intval($id)); |
|
| 527 | 527 | |
| 528 | 528 | // Changer le statut des rubriques concernees |
| 529 | 529 | if ($cond) { |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | */ |
| 568 | 568 | function objet_lire($objet, $valeur_id, $options = []) { |
| 569 | 569 | if (($t = objet_type($objet)) !== $objet) { |
| 570 | - spip_log("objet_lire: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 570 | + spip_log("objet_lire: appel avec type $objet invalide au lieu de $t", 'editer'._LOG_INFO_IMPORTANTE); |
|
| 571 | 571 | $objet = $t; |
| 572 | 572 | } |
| 573 | 573 | |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | ) { |
| 590 | 590 | // Il est possible pour un type d'objet de fournir une fonction de lecture de tous les champs d'un objet. |
| 591 | 591 | if ( |
| 592 | - include_spip('action/editer_' . $objet) |
|
| 592 | + include_spip('action/editer_'.$objet) |
|
| 593 | 593 | and function_exists($lire = "{$objet}_lire_champs") |
| 594 | 594 | ) { |
| 595 | 595 | $valeurs = $lire($objet, $valeur_id, $champ_id); |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | |
| 600 | 600 | // La condition est appliquée sur le champ désigné par l'utilisateur. |
| 601 | 601 | $where = [ |
| 602 | - $champ_id . '=' . sql_quote($valeur_id) |
|
| 602 | + $champ_id.'='.sql_quote($valeur_id) |
|
| 603 | 603 | ]; |
| 604 | 604 | |
| 605 | 605 | // Acquisition de tous les champs de l'objet : si l'accès SQL retourne une erreur on renvoie un tableau vide. |
@@ -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 | /** |
@@ -33,36 +33,36 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function action_editer_objet_dist($id = null, $objet = null, $set = null) { |
| 35 | 35 | |
| 36 | - // appel direct depuis une url avec arg = "objet/id" |
|
| 37 | - if (is_null($id) or is_null($objet)) { |
|
| 38 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 39 | - $arg = $securiser_action(); |
|
| 40 | - [$objet, $id] = array_pad(explode('/', $arg, 2), 2, null); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - // appel incorrect ou depuis une url erronnée interdit |
|
| 44 | - if (is_null($id) or is_null($objet)) { |
|
| 45 | - include_spip('inc/minipres'); |
|
| 46 | - echo minipres(_T('info_acces_interdit')); |
|
| 47 | - die(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // si id n'est pas un nombre, c'est une creation |
|
| 51 | - // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 52 | - if (!$id = intval($id)) { |
|
| 53 | - // on ne sait pas si un parent existe mais on essaye |
|
| 54 | - $id_parent = _request('id_parent'); |
|
| 55 | - $id = objet_inserer($objet, $id_parent); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - if (!($id = intval($id)) > 0) { |
|
| 59 | - return [$id, _L('echec enregistrement en base')]; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // Enregistre l'envoi dans la BD |
|
| 63 | - $err = objet_modifier($objet, $id, $set); |
|
| 64 | - |
|
| 65 | - return [$id, $err]; |
|
| 36 | + // appel direct depuis une url avec arg = "objet/id" |
|
| 37 | + if (is_null($id) or is_null($objet)) { |
|
| 38 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 39 | + $arg = $securiser_action(); |
|
| 40 | + [$objet, $id] = array_pad(explode('/', $arg, 2), 2, null); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + // appel incorrect ou depuis une url erronnée interdit |
|
| 44 | + if (is_null($id) or is_null($objet)) { |
|
| 45 | + include_spip('inc/minipres'); |
|
| 46 | + echo minipres(_T('info_acces_interdit')); |
|
| 47 | + die(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // si id n'est pas un nombre, c'est une creation |
|
| 51 | + // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 52 | + if (!$id = intval($id)) { |
|
| 53 | + // on ne sait pas si un parent existe mais on essaye |
|
| 54 | + $id_parent = _request('id_parent'); |
|
| 55 | + $id = objet_inserer($objet, $id_parent); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + if (!($id = intval($id)) > 0) { |
|
| 59 | + return [$id, _L('echec enregistrement en base')]; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // Enregistre l'envoi dans la BD |
|
| 63 | + $err = objet_modifier($objet, $id, $set); |
|
| 64 | + |
|
| 65 | + return [$id, $err]; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -75,85 +75,85 @@ discard block |
||
| 75 | 75 | * @return mixed|string |
| 76 | 76 | */ |
| 77 | 77 | function objet_modifier($objet, $id, $set = null) { |
| 78 | - if (($t = objet_type($objet)) !== $objet) { |
|
| 79 | - spip_log("objet_modifier: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 80 | - $objet = $t; |
|
| 81 | - } |
|
| 82 | - if ( |
|
| 83 | - include_spip('action/editer_' . $objet) |
|
| 84 | - and function_exists($modifier = $objet . '_modifier') |
|
| 85 | - ) { |
|
| 86 | - return $modifier($id, $set); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $table_sql = table_objet_sql($objet); |
|
| 90 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 91 | - $desc = $trouver_table($table_sql); |
|
| 92 | - if (!$desc or !isset($desc['field'])) { |
|
| 93 | - spip_log("Objet $objet inconnu dans objet_modifier", 'editer' . _LOG_ERREUR); |
|
| 94 | - |
|
| 95 | - return _L("Erreur objet $objet inconnu"); |
|
| 96 | - } |
|
| 97 | - include_spip('inc/modifier'); |
|
| 98 | - |
|
| 99 | - $champ_date = ''; |
|
| 100 | - if (isset($desc['date']) and $desc['date']) { |
|
| 101 | - $champ_date = $desc['date']; |
|
| 102 | - } elseif (isset($desc['field']['date'])) { |
|
| 103 | - $champ_date = 'date'; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $include_list = array_keys($desc['field']); |
|
| 107 | - // on ne traite pas la cle primaire par defaut, notamment car |
|
| 108 | - // sur une creation, id_x vaut 'oui', et serait enregistre en id_x=0 dans la base |
|
| 109 | - $include_list = array_diff($include_list, [$desc['key']['PRIMARY KEY']]); |
|
| 110 | - |
|
| 111 | - if (isset($desc['champs_editables']) and is_array($desc['champs_editables'])) { |
|
| 112 | - $include_list = $desc['champs_editables']; |
|
| 113 | - } |
|
| 114 | - $c = collecter_requests( |
|
| 115 | - // include list |
|
| 116 | - $include_list, |
|
| 117 | - // exclude list |
|
| 118 | - [$champ_date, 'statut', 'id_parent', 'id_secteur'], |
|
| 119 | - // donnees eventuellement fournies |
|
| 120 | - $set |
|
| 121 | - ); |
|
| 122 | - |
|
| 123 | - // Si l'objet est publie, invalider les caches et demander sa reindexation |
|
| 124 | - if (objet_test_si_publie($objet, $id)) { |
|
| 125 | - $invalideur = "id='$objet/$id'"; |
|
| 126 | - $indexation = true; |
|
| 127 | - } else { |
|
| 128 | - $invalideur = ''; |
|
| 129 | - $indexation = false; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - if ( |
|
| 133 | - $err = objet_modifier_champs( |
|
| 134 | - $objet, |
|
| 135 | - $id, |
|
| 136 | - [ |
|
| 137 | - 'data' => $set, |
|
| 138 | - 'nonvide' => '', |
|
| 139 | - 'invalideur' => $invalideur, |
|
| 140 | - 'indexation' => $indexation, |
|
| 141 | - // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 142 | - 'date_modif' => (isset($desc['field']['date_modif']) ? 'date_modif' : '') |
|
| 143 | - ], |
|
| 144 | - $c |
|
| 145 | - ) |
|
| 146 | - ) { |
|
| 147 | - return $err; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - // Modification de statut, changement de rubrique ? |
|
| 151 | - // FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout |
|
| 152 | - // le tableau $set hors liste d’exclusion, mais du coup on a possiblement des champs en trop. |
|
| 153 | - $c = collecter_requests([$champ_date, 'statut', 'id_parent'], [], $set); |
|
| 154 | - $err = objet_instituer($objet, $id, $c); |
|
| 155 | - |
|
| 156 | - return $err; |
|
| 78 | + if (($t = objet_type($objet)) !== $objet) { |
|
| 79 | + spip_log("objet_modifier: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 80 | + $objet = $t; |
|
| 81 | + } |
|
| 82 | + if ( |
|
| 83 | + include_spip('action/editer_' . $objet) |
|
| 84 | + and function_exists($modifier = $objet . '_modifier') |
|
| 85 | + ) { |
|
| 86 | + return $modifier($id, $set); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $table_sql = table_objet_sql($objet); |
|
| 90 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 91 | + $desc = $trouver_table($table_sql); |
|
| 92 | + if (!$desc or !isset($desc['field'])) { |
|
| 93 | + spip_log("Objet $objet inconnu dans objet_modifier", 'editer' . _LOG_ERREUR); |
|
| 94 | + |
|
| 95 | + return _L("Erreur objet $objet inconnu"); |
|
| 96 | + } |
|
| 97 | + include_spip('inc/modifier'); |
|
| 98 | + |
|
| 99 | + $champ_date = ''; |
|
| 100 | + if (isset($desc['date']) and $desc['date']) { |
|
| 101 | + $champ_date = $desc['date']; |
|
| 102 | + } elseif (isset($desc['field']['date'])) { |
|
| 103 | + $champ_date = 'date'; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $include_list = array_keys($desc['field']); |
|
| 107 | + // on ne traite pas la cle primaire par defaut, notamment car |
|
| 108 | + // sur une creation, id_x vaut 'oui', et serait enregistre en id_x=0 dans la base |
|
| 109 | + $include_list = array_diff($include_list, [$desc['key']['PRIMARY KEY']]); |
|
| 110 | + |
|
| 111 | + if (isset($desc['champs_editables']) and is_array($desc['champs_editables'])) { |
|
| 112 | + $include_list = $desc['champs_editables']; |
|
| 113 | + } |
|
| 114 | + $c = collecter_requests( |
|
| 115 | + // include list |
|
| 116 | + $include_list, |
|
| 117 | + // exclude list |
|
| 118 | + [$champ_date, 'statut', 'id_parent', 'id_secteur'], |
|
| 119 | + // donnees eventuellement fournies |
|
| 120 | + $set |
|
| 121 | + ); |
|
| 122 | + |
|
| 123 | + // Si l'objet est publie, invalider les caches et demander sa reindexation |
|
| 124 | + if (objet_test_si_publie($objet, $id)) { |
|
| 125 | + $invalideur = "id='$objet/$id'"; |
|
| 126 | + $indexation = true; |
|
| 127 | + } else { |
|
| 128 | + $invalideur = ''; |
|
| 129 | + $indexation = false; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + if ( |
|
| 133 | + $err = objet_modifier_champs( |
|
| 134 | + $objet, |
|
| 135 | + $id, |
|
| 136 | + [ |
|
| 137 | + 'data' => $set, |
|
| 138 | + 'nonvide' => '', |
|
| 139 | + 'invalideur' => $invalideur, |
|
| 140 | + 'indexation' => $indexation, |
|
| 141 | + // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 142 | + 'date_modif' => (isset($desc['field']['date_modif']) ? 'date_modif' : '') |
|
| 143 | + ], |
|
| 144 | + $c |
|
| 145 | + ) |
|
| 146 | + ) { |
|
| 147 | + return $err; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + // Modification de statut, changement de rubrique ? |
|
| 151 | + // FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout |
|
| 152 | + // le tableau $set hors liste d’exclusion, mais du coup on a possiblement des champs en trop. |
|
| 153 | + $c = collecter_requests([$champ_date, 'statut', 'id_parent'], [], $set); |
|
| 154 | + $err = objet_instituer($objet, $id, $c); |
|
| 155 | + |
|
| 156 | + return $err; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -168,157 +168,157 @@ discard block |
||
| 168 | 168 | * @return bool|int |
| 169 | 169 | */ |
| 170 | 170 | function objet_inserer($objet, $id_parent = null, $set = null) { |
| 171 | - $d = null; |
|
| 172 | - if (($t = objet_type($objet)) !== $objet) { |
|
| 173 | - spip_log("objet_inserer: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 174 | - $objet = $t; |
|
| 175 | - } |
|
| 176 | - if ( |
|
| 177 | - include_spip('action/editer_' . $objet) |
|
| 178 | - and function_exists($inserer = $objet . '_inserer') |
|
| 179 | - ) { |
|
| 180 | - return $inserer($id_parent, $set); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - $table_sql = table_objet_sql($objet); |
|
| 184 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 185 | - $desc = $trouver_table($table_sql); |
|
| 186 | - if (!$desc or !isset($desc['field'])) { |
|
| 187 | - return 0; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $lang_rub = ''; |
|
| 191 | - $champs = []; |
|
| 192 | - if (isset($desc['field']['id_rubrique'])) { |
|
| 193 | - // Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet |
|
| 194 | - // dans la premiere rubrique racine |
|
| 195 | - if (!$id_rubrique = intval($id_parent)) { |
|
| 196 | - $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 197 | - $id_rubrique = $row['id_rubrique']; |
|
| 198 | - } else { |
|
| 199 | - $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - $champs['id_rubrique'] = $id_rubrique; |
|
| 203 | - if (isset($desc['field']['id_secteur'])) { |
|
| 204 | - $champs['id_secteur'] = $row['id_secteur']; |
|
| 205 | - } |
|
| 206 | - $lang_rub = $row['lang']; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - // La langue a la creation : si les liens de traduction sont autorises |
|
| 210 | - // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 211 | - // ou a defaut celle de la rubrique |
|
| 212 | - // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 213 | - if ( |
|
| 214 | - isset($desc['field']['lang']) and !empty($GLOBALS['meta']['multi_objets']) and in_array( |
|
| 215 | - $table_sql, |
|
| 216 | - explode(',', $GLOBALS['meta']['multi_objets']) |
|
| 217 | - ) |
|
| 218 | - ) { |
|
| 219 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 220 | - if ( |
|
| 221 | - in_array( |
|
| 222 | - $GLOBALS['spip_lang'], |
|
| 223 | - explode(',', $GLOBALS['meta']['langues_multilingue']) |
|
| 224 | - ) |
|
| 225 | - ) { |
|
| 226 | - $champs['lang'] = $GLOBALS['spip_lang']; |
|
| 227 | - if (isset($desc['field']['langue_choisie'])) { |
|
| 228 | - $champs['langue_choisie'] = 'oui'; |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - } elseif (isset($desc['field']['lang']) and isset($desc['field']['langue_choisie'])) { |
|
| 232 | - $champs['lang'] = ($lang_rub ?: $GLOBALS['meta']['langue_site']); |
|
| 233 | - $champs['langue_choisie'] = 'non'; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - if (isset($desc['field']['statut'])) { |
|
| 237 | - if (isset($desc['statut_textes_instituer'])) { |
|
| 238 | - $cles_statut = array_keys($desc['statut_textes_instituer']); |
|
| 239 | - $champs['statut'] = reset($cles_statut); |
|
| 240 | - } else { |
|
| 241 | - $champs['statut'] = 'prepa'; |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - |
|
| 246 | - if ((isset($desc['date']) and $d = $desc['date']) or isset($desc['field'][$d = 'date'])) { |
|
| 247 | - $champs[$d] = date('Y-m-d H:i:s'); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - if ($set) { |
|
| 251 | - $champs = array_merge($champs, $set); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - // Envoyer aux plugins |
|
| 255 | - $champs = pipeline( |
|
| 256 | - 'pre_insertion', |
|
| 257 | - [ |
|
| 258 | - 'args' => [ |
|
| 259 | - 'table' => $table_sql, |
|
| 260 | - 'id_parent' => $id_parent, |
|
| 261 | - ], |
|
| 262 | - 'data' => $champs |
|
| 263 | - ] |
|
| 264 | - ); |
|
| 265 | - |
|
| 266 | - $id = sql_insertq($table_sql, $champs); |
|
| 267 | - |
|
| 268 | - if ($id) { |
|
| 269 | - // controler si le serveur n'a pas renvoye une erreur |
|
| 270 | - // et associer l'auteur sinon |
|
| 271 | - // si la table n'a pas deja un champ id_auteur |
|
| 272 | - // et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association) |
|
| 273 | - if ( |
|
| 274 | - $id > 0 |
|
| 275 | - and !isset($desc['field']['id_auteur']) |
|
| 276 | - ) { |
|
| 277 | - $id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 278 | - $GLOBALS['visiteur_session']['id_auteur'] |
|
| 279 | - : _request('id_auteur')); |
|
| 280 | - if ($id_auteur) { |
|
| 281 | - include_spip('action/editer_auteur'); |
|
| 282 | - auteur_associer($id_auteur, [$objet => $id]); |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - pipeline( |
|
| 287 | - 'post_insertion', |
|
| 288 | - [ |
|
| 289 | - 'args' => [ |
|
| 290 | - 'table' => $table_sql, |
|
| 291 | - 'id_parent' => $id_parent, |
|
| 292 | - 'id_objet' => $id, |
|
| 293 | - ], |
|
| 294 | - 'data' => $champs |
|
| 295 | - ] |
|
| 296 | - ); |
|
| 297 | - } |
|
| 171 | + $d = null; |
|
| 172 | + if (($t = objet_type($objet)) !== $objet) { |
|
| 173 | + spip_log("objet_inserer: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 174 | + $objet = $t; |
|
| 175 | + } |
|
| 176 | + if ( |
|
| 177 | + include_spip('action/editer_' . $objet) |
|
| 178 | + and function_exists($inserer = $objet . '_inserer') |
|
| 179 | + ) { |
|
| 180 | + return $inserer($id_parent, $set); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + $table_sql = table_objet_sql($objet); |
|
| 184 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 185 | + $desc = $trouver_table($table_sql); |
|
| 186 | + if (!$desc or !isset($desc['field'])) { |
|
| 187 | + return 0; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $lang_rub = ''; |
|
| 191 | + $champs = []; |
|
| 192 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 193 | + // Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet |
|
| 194 | + // dans la premiere rubrique racine |
|
| 195 | + if (!$id_rubrique = intval($id_parent)) { |
|
| 196 | + $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 197 | + $id_rubrique = $row['id_rubrique']; |
|
| 198 | + } else { |
|
| 199 | + $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + $champs['id_rubrique'] = $id_rubrique; |
|
| 203 | + if (isset($desc['field']['id_secteur'])) { |
|
| 204 | + $champs['id_secteur'] = $row['id_secteur']; |
|
| 205 | + } |
|
| 206 | + $lang_rub = $row['lang']; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + // La langue a la creation : si les liens de traduction sont autorises |
|
| 210 | + // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 211 | + // ou a defaut celle de la rubrique |
|
| 212 | + // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 213 | + if ( |
|
| 214 | + isset($desc['field']['lang']) and !empty($GLOBALS['meta']['multi_objets']) and in_array( |
|
| 215 | + $table_sql, |
|
| 216 | + explode(',', $GLOBALS['meta']['multi_objets']) |
|
| 217 | + ) |
|
| 218 | + ) { |
|
| 219 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 220 | + if ( |
|
| 221 | + in_array( |
|
| 222 | + $GLOBALS['spip_lang'], |
|
| 223 | + explode(',', $GLOBALS['meta']['langues_multilingue']) |
|
| 224 | + ) |
|
| 225 | + ) { |
|
| 226 | + $champs['lang'] = $GLOBALS['spip_lang']; |
|
| 227 | + if (isset($desc['field']['langue_choisie'])) { |
|
| 228 | + $champs['langue_choisie'] = 'oui'; |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + } elseif (isset($desc['field']['lang']) and isset($desc['field']['langue_choisie'])) { |
|
| 232 | + $champs['lang'] = ($lang_rub ?: $GLOBALS['meta']['langue_site']); |
|
| 233 | + $champs['langue_choisie'] = 'non'; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + if (isset($desc['field']['statut'])) { |
|
| 237 | + if (isset($desc['statut_textes_instituer'])) { |
|
| 238 | + $cles_statut = array_keys($desc['statut_textes_instituer']); |
|
| 239 | + $champs['statut'] = reset($cles_statut); |
|
| 240 | + } else { |
|
| 241 | + $champs['statut'] = 'prepa'; |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + |
|
| 246 | + if ((isset($desc['date']) and $d = $desc['date']) or isset($desc['field'][$d = 'date'])) { |
|
| 247 | + $champs[$d] = date('Y-m-d H:i:s'); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + if ($set) { |
|
| 251 | + $champs = array_merge($champs, $set); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + // Envoyer aux plugins |
|
| 255 | + $champs = pipeline( |
|
| 256 | + 'pre_insertion', |
|
| 257 | + [ |
|
| 258 | + 'args' => [ |
|
| 259 | + 'table' => $table_sql, |
|
| 260 | + 'id_parent' => $id_parent, |
|
| 261 | + ], |
|
| 262 | + 'data' => $champs |
|
| 263 | + ] |
|
| 264 | + ); |
|
| 265 | + |
|
| 266 | + $id = sql_insertq($table_sql, $champs); |
|
| 267 | + |
|
| 268 | + if ($id) { |
|
| 269 | + // controler si le serveur n'a pas renvoye une erreur |
|
| 270 | + // et associer l'auteur sinon |
|
| 271 | + // si la table n'a pas deja un champ id_auteur |
|
| 272 | + // et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association) |
|
| 273 | + if ( |
|
| 274 | + $id > 0 |
|
| 275 | + and !isset($desc['field']['id_auteur']) |
|
| 276 | + ) { |
|
| 277 | + $id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 278 | + $GLOBALS['visiteur_session']['id_auteur'] |
|
| 279 | + : _request('id_auteur')); |
|
| 280 | + if ($id_auteur) { |
|
| 281 | + include_spip('action/editer_auteur'); |
|
| 282 | + auteur_associer($id_auteur, [$objet => $id]); |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + pipeline( |
|
| 287 | + 'post_insertion', |
|
| 288 | + [ |
|
| 289 | + 'args' => [ |
|
| 290 | + 'table' => $table_sql, |
|
| 291 | + 'id_parent' => $id_parent, |
|
| 292 | + 'id_objet' => $id, |
|
| 293 | + ], |
|
| 294 | + 'data' => $champs |
|
| 295 | + ] |
|
| 296 | + ); |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - // Appeler une notification |
|
| 300 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 301 | - $notifications( |
|
| 302 | - "{$objet}_inserer", |
|
| 303 | - $id, |
|
| 304 | - [ |
|
| 305 | - 'id_parent' => $id_parent, |
|
| 306 | - 'champs' => $champs, |
|
| 307 | - ] |
|
| 308 | - ); |
|
| 309 | - $notifications( |
|
| 310 | - 'objet_inserer', |
|
| 311 | - $id, |
|
| 312 | - [ |
|
| 313 | - 'objet' => $objet, |
|
| 314 | - 'id_objet' => $id, |
|
| 315 | - 'id_parent' => $id_parent, |
|
| 316 | - 'champs' => $champs, |
|
| 317 | - ] |
|
| 318 | - ); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - return $id; |
|
| 299 | + // Appeler une notification |
|
| 300 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 301 | + $notifications( |
|
| 302 | + "{$objet}_inserer", |
|
| 303 | + $id, |
|
| 304 | + [ |
|
| 305 | + 'id_parent' => $id_parent, |
|
| 306 | + 'champs' => $champs, |
|
| 307 | + ] |
|
| 308 | + ); |
|
| 309 | + $notifications( |
|
| 310 | + 'objet_inserer', |
|
| 311 | + $id, |
|
| 312 | + [ |
|
| 313 | + 'objet' => $objet, |
|
| 314 | + 'id_objet' => $id, |
|
| 315 | + 'id_parent' => $id_parent, |
|
| 316 | + 'champs' => $champs, |
|
| 317 | + ] |
|
| 318 | + ); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + return $id; |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | |
@@ -335,138 +335,138 @@ discard block |
||
| 335 | 335 | * @return string |
| 336 | 336 | */ |
| 337 | 337 | function objet_instituer($objet, $id, $c, $calcul_rub = true) { |
| 338 | - if (($t = objet_type($objet)) !== $objet) { |
|
| 339 | - spip_log("objet_instituer: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 340 | - $objet = $t; |
|
| 341 | - } |
|
| 342 | - if ( |
|
| 343 | - include_spip('action/editer_' . $objet) |
|
| 344 | - and function_exists($instituer = $objet . '_instituer') |
|
| 345 | - ) { |
|
| 346 | - return $instituer($id, $c, $calcul_rub); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - $table_sql = table_objet_sql($objet); |
|
| 350 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 351 | - $desc = $trouver_table($table_sql); |
|
| 352 | - if (!$desc or !isset($desc['field'])) { |
|
| 353 | - return _L("Impossible d'instituer $objet : non connu en base"); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - include_spip('inc/autoriser'); |
|
| 357 | - include_spip('inc/rubriques'); |
|
| 358 | - include_spip('inc/modifier'); |
|
| 359 | - |
|
| 360 | - $sel = []; |
|
| 361 | - $sel[] = (isset($desc['field']['statut']) ? 'statut' : "'' as statut"); |
|
| 362 | - |
|
| 363 | - $champ_date = ''; |
|
| 364 | - if (isset($desc['date']) and $desc['date']) { |
|
| 365 | - $champ_date = $desc['date']; |
|
| 366 | - } elseif (isset($desc['field']['date'])) { |
|
| 367 | - $champ_date = 'date'; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
|
| 371 | - $sel[] = (isset($desc['field']['id_rubrique']) ? 'id_rubrique' : '0 as id_rubrique'); |
|
| 372 | - |
|
| 373 | - $row = sql_fetsel($sel, $table_sql, id_table_objet($objet) . '=' . intval($id)); |
|
| 374 | - |
|
| 375 | - $id_rubrique = $row['id_rubrique']; |
|
| 376 | - $statut_ancien = $statut = $row['statut']; |
|
| 377 | - $date_ancienne = $date = $row['date']; |
|
| 378 | - $champs = []; |
|
| 379 | - |
|
| 380 | - $d = ($date and isset($c[$champ_date])) ? $c[$champ_date] : null; |
|
| 381 | - $s = (isset($desc['field']['statut']) and isset($c['statut'])) ? $c['statut'] : $statut; |
|
| 382 | - |
|
| 383 | - // cf autorisations dans inc/instituer_objet |
|
| 384 | - if ($s != $statut or ($d and $d != $date)) { |
|
| 385 | - if ( |
|
| 386 | - $id_rubrique ? |
|
| 387 | - autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 388 | - : |
|
| 389 | - autoriser('instituer', $objet, $id, null, ['statut' => $s]) |
|
| 390 | - ) { |
|
| 391 | - $statut = $champs['statut'] = $s; |
|
| 392 | - } else { |
|
| 393 | - if ($s != 'publie' and autoriser('modifier', $objet, $id)) { |
|
| 394 | - $statut = $champs['statut'] = $s; |
|
| 395 | - } else { |
|
| 396 | - spip_log("editer_objet $objet #$id refus " . json_encode($c, JSON_THROW_ON_ERROR), 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - // En cas de publication, fixer la date a "maintenant" |
|
| 401 | - // sauf si $c commande autre chose |
|
| 402 | - // ou si l'objet est deja date dans le futur |
|
| 403 | - // En cas de proposition d'un objet (mais pas depublication), idem |
|
| 404 | - if ($champ_date) { |
|
| 405 | - if ( |
|
| 406 | - $champs['statut'] == 'publie' |
|
| 407 | - or ($champs['statut'] == 'prop' and !in_array($statut_ancien, ['publie', 'prop'])) |
|
| 408 | - or $d |
|
| 409 | - ) { |
|
| 410 | - if ($d or strtotime($d = $date) > time()) { |
|
| 411 | - $champs[$champ_date] = $date = $d; |
|
| 412 | - } else { |
|
| 413 | - $champs[$champ_date] = $date = date('Y-m-d H:i:s'); |
|
| 414 | - } |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - // Verifier que la rubrique demandee existe et est differente |
|
| 420 | - // de la rubrique actuelle |
|
| 421 | - if ( |
|
| 422 | - $id_rubrique |
|
| 423 | - and isset($c['id_parent']) |
|
| 424 | - and $id_parent = $c['id_parent'] |
|
| 425 | - and $id_parent != $id_rubrique |
|
| 426 | - and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent))) |
|
| 427 | - ) { |
|
| 428 | - $champs['id_rubrique'] = $id_parent; |
|
| 429 | - |
|
| 430 | - // si l'objet etait publie |
|
| 431 | - // et que le demandeur n'est pas admin de la rubrique |
|
| 432 | - // repasser l'objet en statut 'propose'. |
|
| 433 | - if ( |
|
| 434 | - $statut == 'publie' |
|
| 435 | - and !autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 436 | - ) { |
|
| 437 | - $champs['statut'] = 'prop'; |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - |
|
| 442 | - // Envoyer aux plugins |
|
| 443 | - $champs = pipeline( |
|
| 444 | - 'pre_edition', |
|
| 445 | - [ |
|
| 446 | - 'args' => [ |
|
| 447 | - 'table' => $table_sql, |
|
| 448 | - 'id_objet' => $id, |
|
| 449 | - 'action' => 'instituer', |
|
| 450 | - 'statut_ancien' => $statut_ancien, |
|
| 451 | - 'date_ancienne' => $date_ancienne, |
|
| 452 | - 'id_parent_ancien' => $id_rubrique, |
|
| 453 | - ], |
|
| 454 | - 'data' => $champs |
|
| 455 | - ] |
|
| 456 | - ); |
|
| 457 | - |
|
| 458 | - if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 459 | - return ''; |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - // Envoyer les modifs. |
|
| 463 | - objet_editer_heritage($objet, $id, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 464 | - |
|
| 465 | - // Invalider les caches |
|
| 466 | - include_spip('inc/invalideur'); |
|
| 467 | - suivre_invalideur("id='$objet/$id'"); |
|
| 468 | - |
|
| 469 | - /* |
|
| 338 | + if (($t = objet_type($objet)) !== $objet) { |
|
| 339 | + spip_log("objet_instituer: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 340 | + $objet = $t; |
|
| 341 | + } |
|
| 342 | + if ( |
|
| 343 | + include_spip('action/editer_' . $objet) |
|
| 344 | + and function_exists($instituer = $objet . '_instituer') |
|
| 345 | + ) { |
|
| 346 | + return $instituer($id, $c, $calcul_rub); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + $table_sql = table_objet_sql($objet); |
|
| 350 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 351 | + $desc = $trouver_table($table_sql); |
|
| 352 | + if (!$desc or !isset($desc['field'])) { |
|
| 353 | + return _L("Impossible d'instituer $objet : non connu en base"); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + include_spip('inc/autoriser'); |
|
| 357 | + include_spip('inc/rubriques'); |
|
| 358 | + include_spip('inc/modifier'); |
|
| 359 | + |
|
| 360 | + $sel = []; |
|
| 361 | + $sel[] = (isset($desc['field']['statut']) ? 'statut' : "'' as statut"); |
|
| 362 | + |
|
| 363 | + $champ_date = ''; |
|
| 364 | + if (isset($desc['date']) and $desc['date']) { |
|
| 365 | + $champ_date = $desc['date']; |
|
| 366 | + } elseif (isset($desc['field']['date'])) { |
|
| 367 | + $champ_date = 'date'; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
|
| 371 | + $sel[] = (isset($desc['field']['id_rubrique']) ? 'id_rubrique' : '0 as id_rubrique'); |
|
| 372 | + |
|
| 373 | + $row = sql_fetsel($sel, $table_sql, id_table_objet($objet) . '=' . intval($id)); |
|
| 374 | + |
|
| 375 | + $id_rubrique = $row['id_rubrique']; |
|
| 376 | + $statut_ancien = $statut = $row['statut']; |
|
| 377 | + $date_ancienne = $date = $row['date']; |
|
| 378 | + $champs = []; |
|
| 379 | + |
|
| 380 | + $d = ($date and isset($c[$champ_date])) ? $c[$champ_date] : null; |
|
| 381 | + $s = (isset($desc['field']['statut']) and isset($c['statut'])) ? $c['statut'] : $statut; |
|
| 382 | + |
|
| 383 | + // cf autorisations dans inc/instituer_objet |
|
| 384 | + if ($s != $statut or ($d and $d != $date)) { |
|
| 385 | + if ( |
|
| 386 | + $id_rubrique ? |
|
| 387 | + autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 388 | + : |
|
| 389 | + autoriser('instituer', $objet, $id, null, ['statut' => $s]) |
|
| 390 | + ) { |
|
| 391 | + $statut = $champs['statut'] = $s; |
|
| 392 | + } else { |
|
| 393 | + if ($s != 'publie' and autoriser('modifier', $objet, $id)) { |
|
| 394 | + $statut = $champs['statut'] = $s; |
|
| 395 | + } else { |
|
| 396 | + spip_log("editer_objet $objet #$id refus " . json_encode($c, JSON_THROW_ON_ERROR), 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + // En cas de publication, fixer la date a "maintenant" |
|
| 401 | + // sauf si $c commande autre chose |
|
| 402 | + // ou si l'objet est deja date dans le futur |
|
| 403 | + // En cas de proposition d'un objet (mais pas depublication), idem |
|
| 404 | + if ($champ_date) { |
|
| 405 | + if ( |
|
| 406 | + $champs['statut'] == 'publie' |
|
| 407 | + or ($champs['statut'] == 'prop' and !in_array($statut_ancien, ['publie', 'prop'])) |
|
| 408 | + or $d |
|
| 409 | + ) { |
|
| 410 | + if ($d or strtotime($d = $date) > time()) { |
|
| 411 | + $champs[$champ_date] = $date = $d; |
|
| 412 | + } else { |
|
| 413 | + $champs[$champ_date] = $date = date('Y-m-d H:i:s'); |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + // Verifier que la rubrique demandee existe et est differente |
|
| 420 | + // de la rubrique actuelle |
|
| 421 | + if ( |
|
| 422 | + $id_rubrique |
|
| 423 | + and isset($c['id_parent']) |
|
| 424 | + and $id_parent = $c['id_parent'] |
|
| 425 | + and $id_parent != $id_rubrique |
|
| 426 | + and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent))) |
|
| 427 | + ) { |
|
| 428 | + $champs['id_rubrique'] = $id_parent; |
|
| 429 | + |
|
| 430 | + // si l'objet etait publie |
|
| 431 | + // et que le demandeur n'est pas admin de la rubrique |
|
| 432 | + // repasser l'objet en statut 'propose'. |
|
| 433 | + if ( |
|
| 434 | + $statut == 'publie' |
|
| 435 | + and !autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 436 | + ) { |
|
| 437 | + $champs['statut'] = 'prop'; |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + |
|
| 442 | + // Envoyer aux plugins |
|
| 443 | + $champs = pipeline( |
|
| 444 | + 'pre_edition', |
|
| 445 | + [ |
|
| 446 | + 'args' => [ |
|
| 447 | + 'table' => $table_sql, |
|
| 448 | + 'id_objet' => $id, |
|
| 449 | + 'action' => 'instituer', |
|
| 450 | + 'statut_ancien' => $statut_ancien, |
|
| 451 | + 'date_ancienne' => $date_ancienne, |
|
| 452 | + 'id_parent_ancien' => $id_rubrique, |
|
| 453 | + ], |
|
| 454 | + 'data' => $champs |
|
| 455 | + ] |
|
| 456 | + ); |
|
| 457 | + |
|
| 458 | + if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 459 | + return ''; |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + // Envoyer les modifs. |
|
| 463 | + objet_editer_heritage($objet, $id, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 464 | + |
|
| 465 | + // Invalider les caches |
|
| 466 | + include_spip('inc/invalideur'); |
|
| 467 | + suivre_invalideur("id='$objet/$id'"); |
|
| 468 | + |
|
| 469 | + /* |
|
| 470 | 470 | if ($date) { |
| 471 | 471 | $t = strtotime($date); |
| 472 | 472 | $p = @$GLOBALS['meta']['date_prochain_postdate']; |
@@ -475,60 +475,60 @@ discard block |
||
| 475 | 475 | } |
| 476 | 476 | }*/ |
| 477 | 477 | |
| 478 | - // Pipeline |
|
| 479 | - pipeline( |
|
| 480 | - 'post_edition', |
|
| 481 | - [ |
|
| 482 | - 'args' => [ |
|
| 483 | - 'table' => $table_sql, |
|
| 484 | - 'id_objet' => $id, |
|
| 485 | - 'action' => 'instituer', |
|
| 486 | - 'statut_ancien' => $statut_ancien, |
|
| 487 | - 'date_ancienne' => $date_ancienne, |
|
| 488 | - 'id_parent_ancien' => $id_rubrique, |
|
| 489 | - ], |
|
| 490 | - 'data' => $champs |
|
| 491 | - ] |
|
| 492 | - ); |
|
| 493 | - |
|
| 494 | - // Notifications |
|
| 495 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 496 | - $notifications( |
|
| 497 | - "{$objet}_instituer", |
|
| 498 | - $id, |
|
| 499 | - [ |
|
| 500 | - 'statut' => $statut, |
|
| 501 | - 'statut_ancien' => $statut_ancien, |
|
| 502 | - 'date' => $date, |
|
| 503 | - 'date_ancienne' => $date_ancienne, |
|
| 504 | - 'id_parent_ancien' => $id_rubrique, |
|
| 505 | - 'champs' => $champs, |
|
| 506 | - ] |
|
| 507 | - ); |
|
| 508 | - $notifications( |
|
| 509 | - 'objet_instituer', |
|
| 510 | - $id, |
|
| 511 | - [ |
|
| 512 | - 'objet' => $objet, |
|
| 513 | - 'id_objet' => $id, |
|
| 514 | - 'statut' => $statut, |
|
| 515 | - 'statut_ancien' => $statut_ancien, |
|
| 516 | - 'date' => $date, |
|
| 517 | - 'date_ancienne' => $date_ancienne, |
|
| 518 | - 'id_parent_ancien' => $id_rubrique, |
|
| 519 | - 'champs' => $champs, |
|
| 520 | - ] |
|
| 521 | - ); |
|
| 478 | + // Pipeline |
|
| 479 | + pipeline( |
|
| 480 | + 'post_edition', |
|
| 481 | + [ |
|
| 482 | + 'args' => [ |
|
| 483 | + 'table' => $table_sql, |
|
| 484 | + 'id_objet' => $id, |
|
| 485 | + 'action' => 'instituer', |
|
| 486 | + 'statut_ancien' => $statut_ancien, |
|
| 487 | + 'date_ancienne' => $date_ancienne, |
|
| 488 | + 'id_parent_ancien' => $id_rubrique, |
|
| 489 | + ], |
|
| 490 | + 'data' => $champs |
|
| 491 | + ] |
|
| 492 | + ); |
|
| 493 | + |
|
| 494 | + // Notifications |
|
| 495 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 496 | + $notifications( |
|
| 497 | + "{$objet}_instituer", |
|
| 498 | + $id, |
|
| 499 | + [ |
|
| 500 | + 'statut' => $statut, |
|
| 501 | + 'statut_ancien' => $statut_ancien, |
|
| 502 | + 'date' => $date, |
|
| 503 | + 'date_ancienne' => $date_ancienne, |
|
| 504 | + 'id_parent_ancien' => $id_rubrique, |
|
| 505 | + 'champs' => $champs, |
|
| 506 | + ] |
|
| 507 | + ); |
|
| 508 | + $notifications( |
|
| 509 | + 'objet_instituer', |
|
| 510 | + $id, |
|
| 511 | + [ |
|
| 512 | + 'objet' => $objet, |
|
| 513 | + 'id_objet' => $id, |
|
| 514 | + 'statut' => $statut, |
|
| 515 | + 'statut_ancien' => $statut_ancien, |
|
| 516 | + 'date' => $date, |
|
| 517 | + 'date_ancienne' => $date_ancienne, |
|
| 518 | + 'id_parent_ancien' => $id_rubrique, |
|
| 519 | + 'champs' => $champs, |
|
| 520 | + ] |
|
| 521 | + ); |
|
| 522 | 522 | |
| 523 | - // Rétro-compat |
|
| 524 | - $notifications( |
|
| 525 | - "instituer$objet", |
|
| 526 | - $id, |
|
| 527 | - ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 528 | - ); |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - return ''; // pas d'erreur |
|
| 523 | + // Rétro-compat |
|
| 524 | + $notifications( |
|
| 525 | + "instituer$objet", |
|
| 526 | + $id, |
|
| 527 | + ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 528 | + ); |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + return ''; // pas d'erreur |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
@@ -543,51 +543,51 @@ discard block |
||
| 543 | 543 | * @return void |
| 544 | 544 | */ |
| 545 | 545 | function objet_editer_heritage($objet, $id, $id_rubrique, $statut, $champs, $cond = true) { |
| 546 | - $table_sql = table_objet_sql($objet); |
|
| 547 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 548 | - $desc = $trouver_table($table_sql); |
|
| 549 | - |
|
| 550 | - // Si on deplace l'objet |
|
| 551 | - // changer aussi son secteur et sa langue (si heritee) |
|
| 552 | - if (isset($champs['id_rubrique'])) { |
|
| 553 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 554 | - $langue = $row_rub['lang']; |
|
| 555 | - |
|
| 556 | - if (isset($desc['field']['id_secteur'])) { |
|
| 557 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - if (isset($desc['field']['lang']) and isset($desc['field']['langue_choisie'])) { |
|
| 561 | - if ( |
|
| 562 | - sql_fetsel( |
|
| 563 | - '1', |
|
| 564 | - $table_sql, |
|
| 565 | - id_table_objet($objet) . '=' . intval($id) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 566 | - ) |
|
| 567 | - ) { |
|
| 568 | - $champs['lang'] = $langue; |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - if (!$champs) { |
|
| 574 | - return; |
|
| 575 | - } |
|
| 576 | - sql_updateq($table_sql, $champs, id_table_objet($objet) . '=' . intval($id)); |
|
| 577 | - |
|
| 578 | - // Changer le statut des rubriques concernees |
|
| 579 | - if ($cond) { |
|
| 580 | - include_spip('inc/rubriques'); |
|
| 581 | - //$postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 582 | - $postdate = false; |
|
| 583 | - // On rajoute les infos de l'objet |
|
| 584 | - $infos = [ |
|
| 585 | - 'objet' => $objet, |
|
| 586 | - 'id_objet' => $id, |
|
| 587 | - 'statut_ancien' => $statut, |
|
| 588 | - ]; |
|
| 589 | - calculer_rubriques_if($id_rubrique, $champs, $infos, $postdate); |
|
| 590 | - } |
|
| 546 | + $table_sql = table_objet_sql($objet); |
|
| 547 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 548 | + $desc = $trouver_table($table_sql); |
|
| 549 | + |
|
| 550 | + // Si on deplace l'objet |
|
| 551 | + // changer aussi son secteur et sa langue (si heritee) |
|
| 552 | + if (isset($champs['id_rubrique'])) { |
|
| 553 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 554 | + $langue = $row_rub['lang']; |
|
| 555 | + |
|
| 556 | + if (isset($desc['field']['id_secteur'])) { |
|
| 557 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + if (isset($desc['field']['lang']) and isset($desc['field']['langue_choisie'])) { |
|
| 561 | + if ( |
|
| 562 | + sql_fetsel( |
|
| 563 | + '1', |
|
| 564 | + $table_sql, |
|
| 565 | + id_table_objet($objet) . '=' . intval($id) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 566 | + ) |
|
| 567 | + ) { |
|
| 568 | + $champs['lang'] = $langue; |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + if (!$champs) { |
|
| 574 | + return; |
|
| 575 | + } |
|
| 576 | + sql_updateq($table_sql, $champs, id_table_objet($objet) . '=' . intval($id)); |
|
| 577 | + |
|
| 578 | + // Changer le statut des rubriques concernees |
|
| 579 | + if ($cond) { |
|
| 580 | + include_spip('inc/rubriques'); |
|
| 581 | + //$postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 582 | + $postdate = false; |
|
| 583 | + // On rajoute les infos de l'objet |
|
| 584 | + $infos = [ |
|
| 585 | + 'objet' => $objet, |
|
| 586 | + 'id_objet' => $id, |
|
| 587 | + 'statut_ancien' => $statut, |
|
| 588 | + ]; |
|
| 589 | + calculer_rubriques_if($id_rubrique, $champs, $infos, $postdate); |
|
| 590 | + } |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | |
@@ -616,75 +616,75 @@ discard block |
||
| 616 | 616 | * string|int : valeur du champ demande pour l'objet demande |
| 617 | 617 | */ |
| 618 | 618 | function objet_lire($objet, $valeur_id, $options = []) { |
| 619 | - if (($t = objet_type($objet)) !== $objet) { |
|
| 620 | - spip_log("objet_lire: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 621 | - $objet = $t; |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - // tableau du cache des descriptions et des id d'objet (au sens id_xxx). |
|
| 625 | - // Les tableaux sont toujours indexés par le trio [objet][cle][valeur_cle] |
|
| 626 | - static $descriptions = []; |
|
| 627 | - |
|
| 628 | - // On détermine le nom du champ id de la table. |
|
| 629 | - include_spip('base/objets'); |
|
| 630 | - $primary = id_table_objet($objet); |
|
| 631 | - |
|
| 632 | - // On détermine l'id à utiliser. |
|
| 633 | - $champ_id = (!empty($options['champ_id']) ? $options['champ_id'] : $primary); |
|
| 634 | - |
|
| 635 | - // Si l'objet n'a pas encore été stocké, il faut récupérer sa description complète. |
|
| 636 | - if ( |
|
| 637 | - !isset($descriptions[$objet][$champ_id][$valeur_id]) |
|
| 638 | - or (isset($options['force']) and $options['force']) |
|
| 639 | - ) { |
|
| 640 | - // Il est possible pour un type d'objet de fournir une fonction de lecture de tous les champs d'un objet. |
|
| 641 | - if ( |
|
| 642 | - include_spip('action/editer_' . $objet) |
|
| 643 | - and function_exists($lire = "{$objet}_lire_champs") |
|
| 644 | - ) { |
|
| 645 | - $valeurs = $lire($objet, $valeur_id, $champ_id); |
|
| 646 | - } else { |
|
| 647 | - // On récupère la table SQL à partir du type d'objet. |
|
| 648 | - $table = table_objet_sql($objet); |
|
| 649 | - |
|
| 650 | - // La condition est appliquée sur le champ désigné par l'utilisateur. |
|
| 651 | - $where = [ |
|
| 652 | - $champ_id . '=' . sql_quote($valeur_id) |
|
| 653 | - ]; |
|
| 654 | - |
|
| 655 | - // Acquisition de tous les champs de l'objet : si l'accès SQL retourne une erreur on renvoie un tableau vide. |
|
| 656 | - $valeurs = sql_fetsel('*', $table, $where); |
|
| 657 | - } |
|
| 658 | - |
|
| 659 | - if (!$valeurs) { |
|
| 660 | - $valeurs = false; |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - $descriptions[$objet][$champ_id][$valeur_id] = $valeurs; |
|
| 664 | - |
|
| 665 | - if ($champ_id !== $primary and isset($valeurs[$primary])) { |
|
| 666 | - $descriptions[$objet][$primary][$valeurs[$primary]] = $valeurs; |
|
| 667 | - $descriptions[$objet][$champ_id][$valeur_id] = &$descriptions[$objet][$primary][$valeurs[$primary]]; |
|
| 668 | - } |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - $retour = $descriptions[$objet][$champ_id][$valeur_id]; |
|
| 672 | - |
|
| 673 | - // On ne retourne maintenant que les champs demandés. |
|
| 674 | - // - on détermine les informations à renvoyer. |
|
| 675 | - if ($retour and !empty($options['champs'])) { |
|
| 676 | - $champs = $options['champs']; |
|
| 677 | - // Extraction des seules informations demandées. |
|
| 678 | - // -- si on demande une information unique on renvoie la valeur simple, sinon on renvoie un tableau. |
|
| 679 | - // -- si une information n'est pas un champ valide elle n'est pas renvoyée sans renvoyer d'erreur. |
|
| 680 | - if (is_array($champs)) { |
|
| 681 | - // Tableau des informations valides |
|
| 682 | - $retour = array_intersect_key($retour, array_flip($champs)); |
|
| 683 | - } else { |
|
| 684 | - // Valeur unique demandée. |
|
| 685 | - $retour = ($retour[$champs] ?? false); |
|
| 686 | - } |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - return $retour; |
|
| 619 | + if (($t = objet_type($objet)) !== $objet) { |
|
| 620 | + spip_log("objet_lire: appel avec type $objet invalide au lieu de $t", 'editer' . _LOG_INFO_IMPORTANTE); |
|
| 621 | + $objet = $t; |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + // tableau du cache des descriptions et des id d'objet (au sens id_xxx). |
|
| 625 | + // Les tableaux sont toujours indexés par le trio [objet][cle][valeur_cle] |
|
| 626 | + static $descriptions = []; |
|
| 627 | + |
|
| 628 | + // On détermine le nom du champ id de la table. |
|
| 629 | + include_spip('base/objets'); |
|
| 630 | + $primary = id_table_objet($objet); |
|
| 631 | + |
|
| 632 | + // On détermine l'id à utiliser. |
|
| 633 | + $champ_id = (!empty($options['champ_id']) ? $options['champ_id'] : $primary); |
|
| 634 | + |
|
| 635 | + // Si l'objet n'a pas encore été stocké, il faut récupérer sa description complète. |
|
| 636 | + if ( |
|
| 637 | + !isset($descriptions[$objet][$champ_id][$valeur_id]) |
|
| 638 | + or (isset($options['force']) and $options['force']) |
|
| 639 | + ) { |
|
| 640 | + // Il est possible pour un type d'objet de fournir une fonction de lecture de tous les champs d'un objet. |
|
| 641 | + if ( |
|
| 642 | + include_spip('action/editer_' . $objet) |
|
| 643 | + and function_exists($lire = "{$objet}_lire_champs") |
|
| 644 | + ) { |
|
| 645 | + $valeurs = $lire($objet, $valeur_id, $champ_id); |
|
| 646 | + } else { |
|
| 647 | + // On récupère la table SQL à partir du type d'objet. |
|
| 648 | + $table = table_objet_sql($objet); |
|
| 649 | + |
|
| 650 | + // La condition est appliquée sur le champ désigné par l'utilisateur. |
|
| 651 | + $where = [ |
|
| 652 | + $champ_id . '=' . sql_quote($valeur_id) |
|
| 653 | + ]; |
|
| 654 | + |
|
| 655 | + // Acquisition de tous les champs de l'objet : si l'accès SQL retourne une erreur on renvoie un tableau vide. |
|
| 656 | + $valeurs = sql_fetsel('*', $table, $where); |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + if (!$valeurs) { |
|
| 660 | + $valeurs = false; |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + $descriptions[$objet][$champ_id][$valeur_id] = $valeurs; |
|
| 664 | + |
|
| 665 | + if ($champ_id !== $primary and isset($valeurs[$primary])) { |
|
| 666 | + $descriptions[$objet][$primary][$valeurs[$primary]] = $valeurs; |
|
| 667 | + $descriptions[$objet][$champ_id][$valeur_id] = &$descriptions[$objet][$primary][$valeurs[$primary]]; |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + $retour = $descriptions[$objet][$champ_id][$valeur_id]; |
|
| 672 | + |
|
| 673 | + // On ne retourne maintenant que les champs demandés. |
|
| 674 | + // - on détermine les informations à renvoyer. |
|
| 675 | + if ($retour and !empty($options['champs'])) { |
|
| 676 | + $champs = $options['champs']; |
|
| 677 | + // Extraction des seules informations demandées. |
|
| 678 | + // -- si on demande une information unique on renvoie la valeur simple, sinon on renvoie un tableau. |
|
| 679 | + // -- si une information n'est pas un champ valide elle n'est pas renvoyée sans renvoyer d'erreur. |
|
| 680 | + if (is_array($champs)) { |
|
| 681 | + // Tableau des informations valides |
|
| 682 | + $retour = array_intersect_key($retour, array_flip($champs)); |
|
| 683 | + } else { |
|
| 684 | + // Valeur unique demandée. |
|
| 685 | + $retour = ($retour[$champs] ?? false); |
|
| 686 | + } |
|
| 687 | + } |
|
| 688 | + |
|
| 689 | + return $retour; |
|
| 690 | 690 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $_id = $e['id_table_objet']; |
| 51 | 51 | if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
| 52 | 52 | $table = $e['table_objet_sql']; |
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=".intval($id)); |
|
| 54 | 54 | if (isset($row['id_rubrique'])) { |
| 55 | 55 | $contexte['id_rubrique'] = $row['id_rubrique']; |
| 56 | 56 | if (isset($row['id_secteur'])) { |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
| 115 | 115 | + [ |
| 116 | 116 | $id => new Bouton( |
| 117 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 118 | - $infos['titre'], // titre |
|
| 117 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 118 | + $infos['titre'], // titre |
|
| 119 | 119 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 120 | 120 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 121 | 121 | ) |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | $boutons_admin = array_slice($boutons_admin, 0, $position) |
| 133 | 133 | + [ |
| 134 | 134 | $id => new Bouton( |
| 135 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 136 | - $infos['titre'], // titre |
|
| 135 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 136 | + $infos['titre'], // titre |
|
| 137 | 137 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 138 | 138 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 139 | 139 | ) |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $url = str_replace('&', '&', $url); |
| 221 | 221 | while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
| 222 | 222 | if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
| 223 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 223 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($contexte['id_rubrique'])); |
|
| 224 | 224 | } |
| 225 | 225 | $val = _request($matches[2], $contexte); |
| 226 | 226 | $url = parametre_url($url, $matches[1], $val ?: '', '&'); |
@@ -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 | include_spip('inc/boutons'); |
@@ -39,33 +39,33 @@ discard block |
||
| 39 | 39 | * contexte |
| 40 | 40 | **/ |
| 41 | 41 | function definir_barre_contexte($contexte = null) { |
| 42 | - if (is_null($contexte)) { |
|
| 43 | - $contexte = $_GET; |
|
| 44 | - } elseif (is_string($contexte)) { |
|
| 45 | - $contexte = unserialize($contexte); |
|
| 46 | - } |
|
| 47 | - if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 48 | - if (!function_exists('trouver_objet_exec')) { |
|
| 49 | - include_spip('inc/pipelines_ecrire'); |
|
| 50 | - } |
|
| 51 | - if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 52 | - $_id = $e['id_table_objet']; |
|
| 53 | - if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 54 | - $table = $e['table_objet_sql']; |
|
| 55 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 56 | - if (isset($row['id_rubrique'])) { |
|
| 57 | - $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 58 | - if (isset($row['id_secteur'])) { |
|
| 59 | - $contexte['id_secteur'] = $row['id_secteur']; |
|
| 60 | - } |
|
| 61 | - } elseif (isset($row['id_groupe'])) { |
|
| 62 | - // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 63 | - $contexte['id_groupe'] = $row['id_groupe']; |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - return $contexte; |
|
| 42 | + if (is_null($contexte)) { |
|
| 43 | + $contexte = $_GET; |
|
| 44 | + } elseif (is_string($contexte)) { |
|
| 45 | + $contexte = unserialize($contexte); |
|
| 46 | + } |
|
| 47 | + if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 48 | + if (!function_exists('trouver_objet_exec')) { |
|
| 49 | + include_spip('inc/pipelines_ecrire'); |
|
| 50 | + } |
|
| 51 | + if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 52 | + $_id = $e['id_table_objet']; |
|
| 53 | + if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 54 | + $table = $e['table_objet_sql']; |
|
| 55 | + $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 56 | + if (isset($row['id_rubrique'])) { |
|
| 57 | + $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 58 | + if (isset($row['id_secteur'])) { |
|
| 59 | + $contexte['id_secteur'] = $row['id_secteur']; |
|
| 60 | + } |
|
| 61 | + } elseif (isset($row['id_groupe'])) { |
|
| 62 | + // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 63 | + $contexte['id_groupe'] = $row['id_groupe']; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + return $contexte; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -81,89 +81,89 @@ discard block |
||
| 81 | 81 | * @return array |
| 82 | 82 | */ |
| 83 | 83 | function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) { |
| 84 | - include_spip('inc/autoriser'); |
|
| 85 | - $boutons_admin = []; |
|
| 84 | + include_spip('inc/autoriser'); |
|
| 85 | + $boutons_admin = []; |
|
| 86 | 86 | |
| 87 | - // les boutons du core, issus de ecrire/paquet.xml |
|
| 88 | - $liste_boutons = []; |
|
| 87 | + // les boutons du core, issus de ecrire/paquet.xml |
|
| 88 | + $liste_boutons = []; |
|
| 89 | 89 | |
| 90 | - // ajouter les boutons issus des plugin via paquet.xml |
|
| 91 | - if ( |
|
| 92 | - function_exists('boutons_plugins') |
|
| 93 | - and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 94 | - ) { |
|
| 95 | - $liste_boutons = &$liste_boutons_plugins; |
|
| 96 | - } |
|
| 90 | + // ajouter les boutons issus des plugin via paquet.xml |
|
| 91 | + if ( |
|
| 92 | + function_exists('boutons_plugins') |
|
| 93 | + and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 94 | + ) { |
|
| 95 | + $liste_boutons = &$liste_boutons_plugins; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - foreach ($liste_boutons as $id => $infos) { |
|
| 99 | - $parent = ''; |
|
| 100 | - // les boutons principaux ne sont pas soumis a autorisation |
|
| 101 | - if ( |
|
| 102 | - !isset($infos['parent']) |
|
| 103 | - or !($parent = $infos['parent']) |
|
| 104 | - or !$autorise |
|
| 105 | - or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte]) |
|
| 106 | - ) { |
|
| 107 | - if ( |
|
| 108 | - $parent |
|
| 109 | - and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 110 | - and isset($boutons_admin[$parent]) |
|
| 111 | - ) { |
|
| 112 | - $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 113 | - if ($position < 0) { |
|
| 114 | - $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 115 | - } |
|
| 116 | - $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 117 | - + [ |
|
| 118 | - $id => new Bouton( |
|
| 119 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 120 | - $infos['titre'], // titre |
|
| 121 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 122 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 123 | - ) |
|
| 124 | - ] |
|
| 125 | - + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 126 | - } |
|
| 127 | - if ( |
|
| 128 | - !$parent |
|
| 129 | - // provisoire, eviter les vieux boutons |
|
| 130 | - and (!in_array($id, ['forum', 'statistiques_visites'])) |
|
| 131 | - and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte])) |
|
| 132 | - ) { |
|
| 133 | - $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 134 | - $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 135 | - + [ |
|
| 136 | - $id => new Bouton( |
|
| 137 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 138 | - $infos['titre'], // titre |
|
| 139 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 140 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 141 | - ) |
|
| 142 | - ] |
|
| 143 | - + array_slice($boutons_admin, $position, 100); |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 98 | + foreach ($liste_boutons as $id => $infos) { |
|
| 99 | + $parent = ''; |
|
| 100 | + // les boutons principaux ne sont pas soumis a autorisation |
|
| 101 | + if ( |
|
| 102 | + !isset($infos['parent']) |
|
| 103 | + or !($parent = $infos['parent']) |
|
| 104 | + or !$autorise |
|
| 105 | + or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte]) |
|
| 106 | + ) { |
|
| 107 | + if ( |
|
| 108 | + $parent |
|
| 109 | + and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 110 | + and isset($boutons_admin[$parent]) |
|
| 111 | + ) { |
|
| 112 | + $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 113 | + if ($position < 0) { |
|
| 114 | + $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 115 | + } |
|
| 116 | + $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 117 | + + [ |
|
| 118 | + $id => new Bouton( |
|
| 119 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 120 | + $infos['titre'], // titre |
|
| 121 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 122 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 123 | + ) |
|
| 124 | + ] |
|
| 125 | + + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 126 | + } |
|
| 127 | + if ( |
|
| 128 | + !$parent |
|
| 129 | + // provisoire, eviter les vieux boutons |
|
| 130 | + and (!in_array($id, ['forum', 'statistiques_visites'])) |
|
| 131 | + and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte])) |
|
| 132 | + ) { |
|
| 133 | + $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 134 | + $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 135 | + + [ |
|
| 136 | + $id => new Bouton( |
|
| 137 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 138 | + $infos['titre'], // titre |
|
| 139 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 140 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 141 | + ) |
|
| 142 | + ] |
|
| 143 | + + array_slice($boutons_admin, $position, 100); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 148 | 148 | |
| 149 | - // définir les favoris et positions d’origine |
|
| 150 | - if ($boutons_admin) { |
|
| 151 | - $menus_favoris = obtenir_menus_favoris(); |
|
| 152 | - $i = 1; |
|
| 153 | - foreach ($boutons_admin as $key => $menu) { |
|
| 154 | - $menu->favori = (int) table_valeur($menus_favoris, $key, false); |
|
| 155 | - $menu->position = $i++; |
|
| 156 | - if ($menu->sousmenu) { |
|
| 157 | - $j = 1; |
|
| 158 | - foreach ($menu->sousmenu as $key => $bouton) { |
|
| 159 | - $bouton->favori = (int) table_valeur($menus_favoris, $key, false); |
|
| 160 | - $bouton->position = $j++; |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 149 | + // définir les favoris et positions d’origine |
|
| 150 | + if ($boutons_admin) { |
|
| 151 | + $menus_favoris = obtenir_menus_favoris(); |
|
| 152 | + $i = 1; |
|
| 153 | + foreach ($boutons_admin as $key => $menu) { |
|
| 154 | + $menu->favori = (int) table_valeur($menus_favoris, $key, false); |
|
| 155 | + $menu->position = $i++; |
|
| 156 | + if ($menu->sousmenu) { |
|
| 157 | + $j = 1; |
|
| 158 | + foreach ($menu->sousmenu as $key => $bouton) { |
|
| 159 | + $bouton->favori = (int) table_valeur($menus_favoris, $key, false); |
|
| 160 | + $bouton->position = $j++; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - return $boutons_admin; |
|
| 166 | + return $boutons_admin; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -175,22 +175,22 @@ discard block |
||
| 175 | 175 | * @return Bouton[] |
| 176 | 176 | */ |
| 177 | 177 | function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) { |
| 178 | - foreach ($menus as $menu) { |
|
| 179 | - if ($menu->sousmenu) { |
|
| 180 | - $libelles = $isfavoris = $favoris = []; |
|
| 181 | - foreach ($menu->sousmenu as $key => $item) { |
|
| 182 | - $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 183 | - $isfavoris[$key] = (bool) $item->favori; |
|
| 184 | - $favoris[$key] = $item->favori; |
|
| 185 | - } |
|
| 186 | - if ($avec_favoris) { |
|
| 187 | - array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 188 | - } else { |
|
| 189 | - array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - return $menus; |
|
| 178 | + foreach ($menus as $menu) { |
|
| 179 | + if ($menu->sousmenu) { |
|
| 180 | + $libelles = $isfavoris = $favoris = []; |
|
| 181 | + foreach ($menu->sousmenu as $key => $item) { |
|
| 182 | + $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 183 | + $isfavoris[$key] = (bool) $item->favori; |
|
| 184 | + $favoris[$key] = $item->favori; |
|
| 185 | + } |
|
| 186 | + if ($avec_favoris) { |
|
| 187 | + array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 188 | + } else { |
|
| 189 | + array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + return $menus; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @return Bouton[] |
| 202 | 202 | */ |
| 203 | 203 | function trier_boutons_enfants_par_favoris_alpha($menus) { |
| 204 | - return trier_boutons_enfants_par_alpha($menus, true); |
|
| 204 | + return trier_boutons_enfants_par_alpha($menus, true); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | |
@@ -214,23 +214,23 @@ discard block |
||
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | 216 | function bandeau_creer_url($url, $args = '', $contexte = null) { |
| 217 | - if (!preg_match(',[\/\?],', $url)) { |
|
| 218 | - $url = generer_url_ecrire($url, $args, true); |
|
| 219 | - // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 220 | - // &truc=@machin@ |
|
| 221 | - // @machin@ etant remplace par _request('machin') |
|
| 222 | - $url = str_replace('&', '&', $url); |
|
| 223 | - while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 224 | - if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 225 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 226 | - } |
|
| 227 | - $val = _request($matches[2], $contexte); |
|
| 228 | - $url = parametre_url($url, $matches[1], $val ?: '', '&'); |
|
| 229 | - } |
|
| 230 | - $url = str_replace('&', '&', $url); |
|
| 231 | - } |
|
| 217 | + if (!preg_match(',[\/\?],', $url)) { |
|
| 218 | + $url = generer_url_ecrire($url, $args, true); |
|
| 219 | + // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 220 | + // &truc=@machin@ |
|
| 221 | + // @machin@ etant remplace par _request('machin') |
|
| 222 | + $url = str_replace('&', '&', $url); |
|
| 223 | + while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 224 | + if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 225 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 226 | + } |
|
| 227 | + $val = _request($matches[2], $contexte); |
|
| 228 | + $url = parametre_url($url, $matches[1], $val ?: '', '&'); |
|
| 229 | + } |
|
| 230 | + $url = str_replace('&', '&', $url); |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - return $url; |
|
| 233 | + return $url; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * Code HTML du bandeau |
| 241 | 241 | */ |
| 242 | 242 | function inc_bandeau_dist() { |
| 243 | - return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 243 | + return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | |
@@ -249,13 +249,13 @@ discard block |
||
| 249 | 249 | * @return array |
| 250 | 250 | */ |
| 251 | 251 | function obtenir_menus_favoris() { |
| 252 | - if ( |
|
| 253 | - isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 254 | - and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 255 | - and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 256 | - ) { |
|
| 257 | - return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 258 | - } |
|
| 259 | - $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 260 | - return $definir_menus_favoris(); |
|
| 252 | + if ( |
|
| 253 | + isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 254 | + and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 255 | + and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 256 | + ) { |
|
| 257 | + return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 258 | + } |
|
| 259 | + $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 260 | + return $definir_menus_favoris(); |
|
| 261 | 261 | } |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | function changer_langue($lang, $liste_langues = null) { |
| 41 | 41 | |
| 42 | 42 | if (is_null($liste_langues)) { |
| 43 | - $liste_langues = ($GLOBALS['meta']['langues_proposees'] ?? '') . ',' . ($GLOBALS['meta']['langues_multilingue'] ?? ''); |
|
| 43 | + $liste_langues = ($GLOBALS['meta']['langues_proposees'] ?? '').','.($GLOBALS['meta']['langues_multilingue'] ?? ''); |
|
| 44 | 44 | } else { |
| 45 | 45 | if (is_array($liste_langues)) { |
| 46 | 46 | $liste_langues = implode(',', $liste_langues); |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | - $liste_langues = ',' . $liste_langues . ','; |
|
| 49 | + $liste_langues = ','.$liste_langues.','; |
|
| 50 | 50 | |
| 51 | 51 | // Si la langue demandee n'existe pas, on essaie d'autres variantes |
| 52 | 52 | // Exemple : 'pt-br' => 'pt_br' => 'pt' |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | foreach ($langues as $l) { |
| 194 | 194 | $selected = ($l == $default) ? ' selected=\'selected\'' : ''; |
| 195 | - $ret .= "<option value='$l'$selected>[" . $l . '] ' . traduire_nom_langue($l) . "</option>\n"; |
|
| 195 | + $ret .= "<option value='$l'$selected>[".$l.'] '.traduire_nom_langue($l)."</option>\n"; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | if (!test_espace_prive()) { |
@@ -210,23 +210,21 @@ discard block |
||
| 210 | 210 | $base, |
| 211 | 211 | $cible, |
| 212 | 212 | (select_langues($nom_select, $change, $ret) |
| 213 | - . "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"), |
|
| 213 | + . "<noscript><div style='display:inline'><input type='submit' class='fondo' value='"._T('bouton_changer')."' /></div></noscript>"), |
|
| 214 | 214 | " method='post'" |
| 215 | 215 | ); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | function select_langues($nom_select, $change, $options, $label = '') { |
| 219 | 219 | static $cpt = 0; |
| 220 | - $id = 'menu_langues' . $cpt++; |
|
| 220 | + $id = 'menu_langues'.$cpt++; |
|
| 221 | 221 | |
| 222 | 222 | return |
| 223 | - "<label for='$id'>" . ($label ?: _T('info_langues')) . '</label> ' . |
|
| 223 | + "<label for='$id'>".($label ?: _T('info_langues')).'</label> '. |
|
| 224 | 224 | "<select name='$nom_select' id='$id' " |
| 225 | 225 | . ((!test_espace_prive()) ? |
| 226 | - ("class='forml menu_langues'") : |
|
| 227 | - (($nom_select == 'var_lang_ecrire') ? |
|
| 228 | - ("class='lang_ecrire'") : |
|
| 229 | - "class='fondl'")) |
|
| 226 | + ("class='forml menu_langues'") : (($nom_select == 'var_lang_ecrire') ? |
|
| 227 | + ("class='lang_ecrire'") : "class='fondl'")) |
|
| 230 | 228 | . $change |
| 231 | 229 | . ">\n" |
| 232 | 230 | . $options |
@@ -352,7 +350,7 @@ discard block |
||
| 352 | 350 | and (!isset($GLOBALS['spip_lang']) |
| 353 | 351 | or $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) |
| 354 | 352 | ) { |
| 355 | - return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues);//@:install |
|
| 353 | + return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues); //@:install |
|
| 356 | 354 | } |
| 357 | 355 | // en theorie là, la globale est définie, sinon c'est un problème. |
| 358 | 356 | if (!isset($GLOBALS['spip_lang'])) { |
@@ -455,7 +453,7 @@ discard block |
||
| 455 | 453 | if (!isset($GLOBALS['meta']['langue_site'])) { |
| 456 | 454 | // Initialisation : le francais si dispo, sinon la premiere langue trouvee |
| 457 | 455 | $GLOBALS['meta']['langue_site'] = $tout = |
| 458 | - (!$all_langs or (strpos(',' . _LANGUE_PAR_DEFAUT . ',', (string) ",$all_langs,") !== false)) |
|
| 456 | + (!$all_langs or (strpos(','._LANGUE_PAR_DEFAUT.',', (string) ",$all_langs,") !== false)) |
|
| 459 | 457 | ? _LANGUE_PAR_DEFAUT : substr($all_langs, 0, strpos($all_langs, ',')); |
| 460 | 458 | ecrire_meta('langue_site', $tout); |
| 461 | 459 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Langue |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
@@ -38,35 +38,35 @@ discard block |
||
| 38 | 38 | **/ |
| 39 | 39 | function changer_langue($lang, $liste_langues = null) { |
| 40 | 40 | |
| 41 | - if (is_null($liste_langues)) { |
|
| 42 | - $liste_langues = ($GLOBALS['meta']['langues_proposees'] ?? '') . ',' . ($GLOBALS['meta']['langues_multilingue'] ?? ''); |
|
| 43 | - } else { |
|
| 44 | - if (is_array($liste_langues)) { |
|
| 45 | - $liste_langues = implode(',', $liste_langues); |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - $liste_langues = ',' . $liste_langues . ','; |
|
| 49 | - |
|
| 50 | - // Si la langue demandee n'existe pas, on essaie d'autres variantes |
|
| 51 | - // Exemple : 'pt-br' => 'pt_br' => 'pt' |
|
| 52 | - $lang = str_replace('-', '_', trim($lang)); |
|
| 53 | - if (!$lang) { |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if ( |
|
| 58 | - strpos($liste_langues, (string) ",$lang,") !== false |
|
| 59 | - or ($lang = preg_replace(',_.*,', '', $lang) |
|
| 60 | - and str_contains($liste_langues, (string) ",$lang,")) |
|
| 61 | - ) { |
|
| 62 | - $GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl'); |
|
| 63 | - $GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right'; |
|
| 64 | - $GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left'; |
|
| 65 | - |
|
| 66 | - return $GLOBALS['spip_lang'] = $lang; |
|
| 67 | - } else { |
|
| 68 | - return false; |
|
| 69 | - } |
|
| 41 | + if (is_null($liste_langues)) { |
|
| 42 | + $liste_langues = ($GLOBALS['meta']['langues_proposees'] ?? '') . ',' . ($GLOBALS['meta']['langues_multilingue'] ?? ''); |
|
| 43 | + } else { |
|
| 44 | + if (is_array($liste_langues)) { |
|
| 45 | + $liste_langues = implode(',', $liste_langues); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + $liste_langues = ',' . $liste_langues . ','; |
|
| 49 | + |
|
| 50 | + // Si la langue demandee n'existe pas, on essaie d'autres variantes |
|
| 51 | + // Exemple : 'pt-br' => 'pt_br' => 'pt' |
|
| 52 | + $lang = str_replace('-', '_', trim($lang)); |
|
| 53 | + if (!$lang) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if ( |
|
| 58 | + strpos($liste_langues, (string) ",$lang,") !== false |
|
| 59 | + or ($lang = preg_replace(',_.*,', '', $lang) |
|
| 60 | + and str_contains($liste_langues, (string) ",$lang,")) |
|
| 61 | + ) { |
|
| 62 | + $GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl'); |
|
| 63 | + $GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right'; |
|
| 64 | + $GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left'; |
|
| 65 | + |
|
| 66 | + return $GLOBALS['spip_lang'] = $lang; |
|
| 67 | + } else { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | // par exemple le francais pour l'espagnol, l'anglais pour l'allemand, etc. |
| 80 | 80 | |
| 81 | 81 | function choisir_traduction($trads, $lang = '') { |
| 82 | - $k = approcher_langue($trads, $lang); |
|
| 82 | + $k = approcher_langue($trads, $lang); |
|
| 83 | 83 | |
| 84 | - return $k ? $trads[$k] : array_shift($trads); |
|
| 84 | + return $k ? $trads[$k] : array_shift($trads); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // retourne son 2e argument si c'est un index du premier |
@@ -89,21 +89,21 @@ discard block |
||
| 89 | 89 | // la langue X etant consideree comme une approche de X_Y |
| 90 | 90 | function approcher_langue($trads, $lang = '') { |
| 91 | 91 | |
| 92 | - if (!$lang) { |
|
| 93 | - $lang = $GLOBALS['spip_lang']; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if (isset($trads[$lang])) { |
|
| 97 | - return $lang; |
|
| 98 | - } // cas des langues xx_yy |
|
| 99 | - else { |
|
| 100 | - $r = explode('_', $lang); |
|
| 101 | - if (isset($trads[$r[0]])) { |
|
| 102 | - return $r[0]; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return ''; |
|
| 92 | + if (!$lang) { |
|
| 93 | + $lang = $GLOBALS['spip_lang']; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if (isset($trads[$lang])) { |
|
| 97 | + return $lang; |
|
| 98 | + } // cas des langues xx_yy |
|
| 99 | + else { |
|
| 100 | + $r = explode('_', $lang); |
|
| 101 | + if (isset($trads[$r[0]])) { |
|
| 102 | + return $r[0]; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return ''; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | * Nom de la langue, sinon son code. |
| 119 | 119 | **/ |
| 120 | 120 | function traduire_nom_langue($lang) { |
| 121 | - include_spip('inc/lang_liste'); |
|
| 122 | - include_spip('inc/charsets'); |
|
| 121 | + include_spip('inc/lang_liste'); |
|
| 122 | + include_spip('inc/charsets'); |
|
| 123 | 123 | |
| 124 | - return html2unicode($GLOBALS['codes_langues'][$lang] ?? $lang); |
|
| 124 | + return html2unicode($GLOBALS['codes_langues'][$lang] ?? $lang); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | // hebreu a priori), 'droitier' sinon. |
| 135 | 135 | // C'est utilise par #LANG_DIR, #LANG_LEFT, #LANG_RIGHT. |
| 136 | 136 | function lang_dir($lang = '', $droitier = 'ltr', $gaucher = 'rtl') { |
| 137 | - static $lang_rtl = ['ar', 'fa', 'ku', 'prs', 'ps', 'ur', 'he', 'heb', 'hbo', 'yi']; |
|
| 137 | + static $lang_rtl = ['ar', 'fa', 'ku', 'prs', 'ps', 'ur', 'he', 'heb', 'hbo', 'yi']; |
|
| 138 | 138 | |
| 139 | - return in_array(($lang ?: $GLOBALS['spip_lang']), $lang_rtl) ? |
|
| 140 | - $gaucher : $droitier; |
|
| 139 | + return in_array(($lang ?: $GLOBALS['spip_lang']), $lang_rtl) ? |
|
| 140 | + $gaucher : $droitier; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // typo francaise ou anglaise ? |
@@ -146,29 +146,29 @@ discard block |
||
| 146 | 146 | // sinon determiner la typo en fonction de la langue courante |
| 147 | 147 | |
| 148 | 148 | function lang_typo($lang = '') { |
| 149 | - if (!$lang) { |
|
| 150 | - $lang = $GLOBALS['lang_objet'] ?? $GLOBALS['spip_lang']; |
|
| 151 | - } |
|
| 152 | - if ( |
|
| 153 | - $lang == 'eo' |
|
| 154 | - or $lang == 'fr' |
|
| 155 | - or strncmp($lang, 'fr_', 3) == 0 |
|
| 156 | - or $lang == 'cpf' |
|
| 157 | - ) { |
|
| 158 | - return 'fr'; |
|
| 159 | - } else { |
|
| 160 | - return 'en'; |
|
| 161 | - } |
|
| 149 | + if (!$lang) { |
|
| 150 | + $lang = $GLOBALS['lang_objet'] ?? $GLOBALS['spip_lang']; |
|
| 151 | + } |
|
| 152 | + if ( |
|
| 153 | + $lang == 'eo' |
|
| 154 | + or $lang == 'fr' |
|
| 155 | + or strncmp($lang, 'fr_', 3) == 0 |
|
| 156 | + or $lang == 'cpf' |
|
| 157 | + ) { |
|
| 158 | + return 'fr'; |
|
| 159 | + } else { |
|
| 160 | + return 'en'; |
|
| 161 | + } |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // gestion de la globale $lang_objet pour que les textes soient affiches |
| 165 | 165 | // avec les memes typo et direction dans l'espace prive que dans le public |
| 166 | 166 | function changer_typo($lang = '') { |
| 167 | - if ($lang) { |
|
| 168 | - $GLOBALS['lang_objet'] = $lang; |
|
| 169 | - } else { |
|
| 170 | - unset($GLOBALS['lang_objet']); |
|
| 171 | - } |
|
| 167 | + if ($lang) { |
|
| 168 | + $GLOBALS['lang_objet'] = $lang; |
|
| 169 | + } else { |
|
| 170 | + unset($GLOBALS['lang_objet']); |
|
| 171 | + } |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // |
@@ -178,58 +178,58 @@ discard block |
||
| 178 | 178 | // pour 'changer_lang' (langue de l'article, espace prive), c'est en Ajax |
| 179 | 179 | // |
| 180 | 180 | function menu_langues($nom_select, $default = '') { |
| 181 | - include_spip('inc/actions'); |
|
| 182 | - |
|
| 183 | - $langues = liste_options_langues($nom_select); |
|
| 184 | - $ret = ''; |
|
| 185 | - if (!count($langues)) { |
|
| 186 | - return ''; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - if (!$default) { |
|
| 190 | - $default = $GLOBALS['spip_lang']; |
|
| 191 | - } |
|
| 192 | - foreach ($langues as $l) { |
|
| 193 | - $selected = ($l == $default) ? ' selected=\'selected\'' : ''; |
|
| 194 | - $ret .= "<option value='$l'$selected>[" . $l . '] ' . traduire_nom_langue($l) . "</option>\n"; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - if (!test_espace_prive()) { |
|
| 198 | - $cible = self(); |
|
| 199 | - $base = ''; |
|
| 200 | - } else { |
|
| 201 | - $cible = self(); |
|
| 202 | - $base = spip_connect() ? 'base' : ''; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - $change = ' onchange="this.parentNode.parentNode.submit()"'; |
|
| 206 | - |
|
| 207 | - return generer_action_auteur( |
|
| 208 | - 'converser', |
|
| 209 | - $base, |
|
| 210 | - $cible, |
|
| 211 | - (select_langues($nom_select, $change, $ret) |
|
| 212 | - . "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"), |
|
| 213 | - " method='post'" |
|
| 214 | - ); |
|
| 181 | + include_spip('inc/actions'); |
|
| 182 | + |
|
| 183 | + $langues = liste_options_langues($nom_select); |
|
| 184 | + $ret = ''; |
|
| 185 | + if (!count($langues)) { |
|
| 186 | + return ''; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + if (!$default) { |
|
| 190 | + $default = $GLOBALS['spip_lang']; |
|
| 191 | + } |
|
| 192 | + foreach ($langues as $l) { |
|
| 193 | + $selected = ($l == $default) ? ' selected=\'selected\'' : ''; |
|
| 194 | + $ret .= "<option value='$l'$selected>[" . $l . '] ' . traduire_nom_langue($l) . "</option>\n"; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + if (!test_espace_prive()) { |
|
| 198 | + $cible = self(); |
|
| 199 | + $base = ''; |
|
| 200 | + } else { |
|
| 201 | + $cible = self(); |
|
| 202 | + $base = spip_connect() ? 'base' : ''; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + $change = ' onchange="this.parentNode.parentNode.submit()"'; |
|
| 206 | + |
|
| 207 | + return generer_action_auteur( |
|
| 208 | + 'converser', |
|
| 209 | + $base, |
|
| 210 | + $cible, |
|
| 211 | + (select_langues($nom_select, $change, $ret) |
|
| 212 | + . "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"), |
|
| 213 | + " method='post'" |
|
| 214 | + ); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | function select_langues($nom_select, $change, $options, $label = '') { |
| 218 | - static $cpt = 0; |
|
| 219 | - $id = 'menu_langues' . $cpt++; |
|
| 220 | - |
|
| 221 | - return |
|
| 222 | - "<label for='$id'>" . ($label ?: _T('info_langues')) . '</label> ' . |
|
| 223 | - "<select name='$nom_select' id='$id' " |
|
| 224 | - . ((!test_espace_prive()) ? |
|
| 225 | - ("class='forml menu_langues'") : |
|
| 226 | - (($nom_select == 'var_lang_ecrire') ? |
|
| 227 | - ("class='lang_ecrire'") : |
|
| 228 | - "class='fondl'")) |
|
| 229 | - . $change |
|
| 230 | - . ">\n" |
|
| 231 | - . $options |
|
| 232 | - . '</select>'; |
|
| 218 | + static $cpt = 0; |
|
| 219 | + $id = 'menu_langues' . $cpt++; |
|
| 220 | + |
|
| 221 | + return |
|
| 222 | + "<label for='$id'>" . ($label ?: _T('info_langues')) . '</label> ' . |
|
| 223 | + "<select name='$nom_select' id='$id' " |
|
| 224 | + . ((!test_espace_prive()) ? |
|
| 225 | + ("class='forml menu_langues'") : |
|
| 226 | + (($nom_select == 'var_lang_ecrire') ? |
|
| 227 | + ("class='lang_ecrire'") : |
|
| 228 | + "class='fondl'")) |
|
| 229 | + . $change |
|
| 230 | + . ">\n" |
|
| 231 | + . $options |
|
| 232 | + . '</select>'; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -251,34 +251,34 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | function liste_options_langues($nom_select) { |
| 253 | 253 | |
| 254 | - switch ($nom_select) { |
|
| 255 | - # #MENU_LANG |
|
| 256 | - case 'var_lang': |
|
| 257 | - # menu de changement de la langue d'un article |
|
| 258 | - # les langues selectionnees dans la configuration "multilinguisme" |
|
| 259 | - case 'changer_lang': |
|
| 260 | - $langues = explode(',', $GLOBALS['meta']['langues_multilingue']); |
|
| 261 | - break; |
|
| 262 | - # menu de l'interface (privee, installation et panneau de login) |
|
| 263 | - # les langues presentes sous forme de fichiers de langue |
|
| 264 | - # on force la relecture du repertoire des langues pour etre synchrone. |
|
| 265 | - case 'var_lang_ecrire': |
|
| 266 | - default: |
|
| 267 | - $GLOBALS['meta']['langues_proposees'] = ''; |
|
| 268 | - init_langues(); |
|
| 269 | - $langues = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 270 | - break; |
|
| 254 | + switch ($nom_select) { |
|
| 255 | + # #MENU_LANG |
|
| 256 | + case 'var_lang': |
|
| 257 | + # menu de changement de la langue d'un article |
|
| 258 | + # les langues selectionnees dans la configuration "multilinguisme" |
|
| 259 | + case 'changer_lang': |
|
| 260 | + $langues = explode(',', $GLOBALS['meta']['langues_multilingue']); |
|
| 261 | + break; |
|
| 262 | + # menu de l'interface (privee, installation et panneau de login) |
|
| 263 | + # les langues presentes sous forme de fichiers de langue |
|
| 264 | + # on force la relecture du repertoire des langues pour etre synchrone. |
|
| 265 | + case 'var_lang_ecrire': |
|
| 266 | + default: |
|
| 267 | + $GLOBALS['meta']['langues_proposees'] = ''; |
|
| 268 | + init_langues(); |
|
| 269 | + $langues = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 270 | + break; |
|
| 271 | 271 | |
| 272 | 272 | # dernier choix possible : toutes les langues = langues_proposees |
| 273 | 273 | # + langues_multilingues ; mais, ne sert pas |
| 274 | 274 | # $langues = explode(',', $GLOBALS['all_langs']); |
| 275 | - } |
|
| 276 | - if (count($langues) <= 1) { |
|
| 277 | - return []; |
|
| 278 | - } |
|
| 279 | - sort($langues); |
|
| 275 | + } |
|
| 276 | + if (count($langues) <= 1) { |
|
| 277 | + return []; |
|
| 278 | + } |
|
| 279 | + sort($langues); |
|
| 280 | 280 | |
| 281 | - return $langues; |
|
| 281 | + return $langues; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -293,39 +293,39 @@ discard block |
||
| 293 | 293 | **/ |
| 294 | 294 | function verifier_lang_url() { |
| 295 | 295 | |
| 296 | - // quelle langue est demandee ? |
|
| 297 | - $lang_demandee = (test_espace_prive() ? $GLOBALS['spip_lang'] : $GLOBALS['meta']['langue_site']); |
|
| 298 | - if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 299 | - $lang_demandee = $_COOKIE['spip_lang_ecrire']; |
|
| 300 | - } |
|
| 301 | - if (!test_espace_prive() and isset($_COOKIE['spip_lang'])) { |
|
| 302 | - $lang_demandee = $_COOKIE['spip_lang']; |
|
| 303 | - } |
|
| 304 | - if (isset($_GET['lang'])) { |
|
| 305 | - $lang_demandee = $_GET['lang']; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - // Renvoyer si besoin (et si la langue demandee existe) |
|
| 309 | - if ( |
|
| 310 | - $GLOBALS['spip_lang'] != $lang_demandee |
|
| 311 | - and changer_langue($lang_demandee) |
|
| 312 | - and $lang_demandee != @$_GET['lang'] |
|
| 313 | - ) { |
|
| 314 | - $destination = parametre_url(self(), 'lang', $lang_demandee, '&'); |
|
| 315 | - // ici on a besoin des var_truc |
|
| 316 | - foreach ($_GET as $var => $val) { |
|
| 317 | - if (!strncmp('var_', $var, 4)) { |
|
| 318 | - $destination = parametre_url($destination, $var, $val, '&'); |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - include_spip('inc/headers'); |
|
| 322 | - redirige_par_entete($destination); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - // Subtilite : si la langue demandee par cookie est la bonne |
|
| 326 | - // alors on fait comme si $lang etait passee dans l'URL |
|
| 327 | - // (pour criteres {lang}). |
|
| 328 | - $GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang']; |
|
| 296 | + // quelle langue est demandee ? |
|
| 297 | + $lang_demandee = (test_espace_prive() ? $GLOBALS['spip_lang'] : $GLOBALS['meta']['langue_site']); |
|
| 298 | + if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 299 | + $lang_demandee = $_COOKIE['spip_lang_ecrire']; |
|
| 300 | + } |
|
| 301 | + if (!test_espace_prive() and isset($_COOKIE['spip_lang'])) { |
|
| 302 | + $lang_demandee = $_COOKIE['spip_lang']; |
|
| 303 | + } |
|
| 304 | + if (isset($_GET['lang'])) { |
|
| 305 | + $lang_demandee = $_GET['lang']; |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + // Renvoyer si besoin (et si la langue demandee existe) |
|
| 309 | + if ( |
|
| 310 | + $GLOBALS['spip_lang'] != $lang_demandee |
|
| 311 | + and changer_langue($lang_demandee) |
|
| 312 | + and $lang_demandee != @$_GET['lang'] |
|
| 313 | + ) { |
|
| 314 | + $destination = parametre_url(self(), 'lang', $lang_demandee, '&'); |
|
| 315 | + // ici on a besoin des var_truc |
|
| 316 | + foreach ($_GET as $var => $val) { |
|
| 317 | + if (!strncmp('var_', $var, 4)) { |
|
| 318 | + $destination = parametre_url($destination, $var, $val, '&'); |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + include_spip('inc/headers'); |
|
| 322 | + redirige_par_entete($destination); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + // Subtilite : si la langue demandee par cookie est la bonne |
|
| 326 | + // alors on fait comme si $lang etait passee dans l'URL |
|
| 327 | + // (pour criteres {lang}). |
|
| 328 | + $GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang']; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -343,22 +343,22 @@ discard block |
||
| 343 | 343 | * La langue sélectionnée |
| 344 | 344 | **/ |
| 345 | 345 | function utiliser_langue_site($liste_langues = null) { |
| 346 | - // s'il existe une langue du site (en gros tout le temps en théorie) |
|
| 347 | - if ( |
|
| 348 | - isset($GLOBALS['meta']['langue_site']) |
|
| 349 | - // et si spip_langue est pas encore définie (ce que va faire changer_langue()) |
|
| 350 | - // ou qu'elle n'est pas identique à la langue du site |
|
| 351 | - and (!isset($GLOBALS['spip_lang']) |
|
| 352 | - or $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) |
|
| 353 | - ) { |
|
| 354 | - return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues);//@:install |
|
| 355 | - } |
|
| 356 | - // en theorie là, la globale est définie, sinon c'est un problème. |
|
| 357 | - if (!isset($GLOBALS['spip_lang'])) { |
|
| 358 | - spip_log('La globale spip_lang est indéfinie dans utiliser_langue_site() !', _LOG_ERREUR); |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - return $GLOBALS['spip_lang']; |
|
| 346 | + // s'il existe une langue du site (en gros tout le temps en théorie) |
|
| 347 | + if ( |
|
| 348 | + isset($GLOBALS['meta']['langue_site']) |
|
| 349 | + // et si spip_langue est pas encore définie (ce que va faire changer_langue()) |
|
| 350 | + // ou qu'elle n'est pas identique à la langue du site |
|
| 351 | + and (!isset($GLOBALS['spip_lang']) |
|
| 352 | + or $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) |
|
| 353 | + ) { |
|
| 354 | + return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues);//@:install |
|
| 355 | + } |
|
| 356 | + // en theorie là, la globale est définie, sinon c'est un problème. |
|
| 357 | + if (!isset($GLOBALS['spip_lang'])) { |
|
| 358 | + spip_log('La globale spip_lang est indéfinie dans utiliser_langue_site() !', _LOG_ERREUR); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + return $GLOBALS['spip_lang']; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -377,35 +377,35 @@ discard block |
||
| 377 | 377 | **/ |
| 378 | 378 | function utiliser_langue_visiteur($liste_langues = null) { |
| 379 | 379 | |
| 380 | - // si on est dans l'espace public et pas de $liste_langues : se limiter a la config langues_multilingue si définie |
|
| 381 | - if (is_null($liste_langues) and !test_espace_prive() and !empty($GLOBALS['meta']['langues_multilingue'])) { |
|
| 382 | - $liste_langues = $GLOBALS['meta']['langues_multilingue']; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - $l = (!test_espace_prive() ? 'spip_lang' : 'spip_lang_ecrire'); |
|
| 386 | - if (isset($_COOKIE[$l])) { |
|
| 387 | - if (changer_langue($l = $_COOKIE[$l], $liste_langues)) { |
|
| 388 | - return $l; |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - if (isset($GLOBALS['visiteur_session']['lang'])) { |
|
| 393 | - if (changer_langue($l = $GLOBALS['visiteur_session']['lang'], $liste_langues)) { |
|
| 394 | - return $l; |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 399 | - foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) { |
|
| 400 | - if (preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#i', trim($s), $r)) { |
|
| 401 | - if (changer_langue($l = strtolower($r[1]), $liste_langues)) { |
|
| 402 | - return $l; |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - return utiliser_langue_site($liste_langues); |
|
| 380 | + // si on est dans l'espace public et pas de $liste_langues : se limiter a la config langues_multilingue si définie |
|
| 381 | + if (is_null($liste_langues) and !test_espace_prive() and !empty($GLOBALS['meta']['langues_multilingue'])) { |
|
| 382 | + $liste_langues = $GLOBALS['meta']['langues_multilingue']; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + $l = (!test_espace_prive() ? 'spip_lang' : 'spip_lang_ecrire'); |
|
| 386 | + if (isset($_COOKIE[$l])) { |
|
| 387 | + if (changer_langue($l = $_COOKIE[$l], $liste_langues)) { |
|
| 388 | + return $l; |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + if (isset($GLOBALS['visiteur_session']['lang'])) { |
|
| 393 | + if (changer_langue($l = $GLOBALS['visiteur_session']['lang'], $liste_langues)) { |
|
| 394 | + return $l; |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 399 | + foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) { |
|
| 400 | + if (preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#i', trim($s), $r)) { |
|
| 401 | + if (changer_langue($l = strtolower($r[1]), $liste_langues)) { |
|
| 402 | + return $l; |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + return utiliser_langue_site($liste_langues); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | * @return int |
| 416 | 416 | */ |
| 417 | 417 | function match_langue($chaine) { |
| 418 | - return preg_match('/^[a-z]{2,3}(_[a-z]{2,3}){0,2}$/', $chaine); |
|
| 418 | + return preg_match('/^[a-z]{2,3}(_[a-z]{2,3}){0,2}$/', $chaine); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -433,36 +433,36 @@ discard block |
||
| 433 | 433 | **/ |
| 434 | 434 | function init_langues() { |
| 435 | 435 | |
| 436 | - // liste des langues dans les meta, sauf a l'install |
|
| 437 | - $all_langs = $GLOBALS['meta']['langues_proposees'] ?? ''; |
|
| 438 | - |
|
| 439 | - $tout = []; |
|
| 440 | - if (!$all_langs) { |
|
| 441 | - // trouver tous les modules lang/spip_xx.php |
|
| 442 | - $modules = find_all_in_path('lang/', '/spip_([a-z_]+)\.php$'); |
|
| 443 | - foreach ($modules as $name => $path) { |
|
| 444 | - if (preg_match(',^spip_([a-z_]+)\.php$,', $name, $regs)) { |
|
| 445 | - if (match_langue($regs[1])) { |
|
| 446 | - $tout[] = $regs[1]; |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - sort($tout); |
|
| 451 | - $tout = join(',', $tout); |
|
| 452 | - // Si les langues n'ont pas change, ne rien faire |
|
| 453 | - if ($tout != $all_langs) { |
|
| 454 | - $GLOBALS['meta']['langues_proposees'] = $tout; |
|
| 455 | - include_spip('inc/meta'); |
|
| 456 | - ecrire_meta('langues_proposees', $tout); |
|
| 457 | - } |
|
| 458 | - } |
|
| 459 | - if (!isset($GLOBALS['meta']['langue_site'])) { |
|
| 460 | - // Initialisation : le francais si dispo, sinon la premiere langue trouvee |
|
| 461 | - $GLOBALS['meta']['langue_site'] = $tout = |
|
| 462 | - (!$all_langs or (strpos(',' . _LANGUE_PAR_DEFAUT . ',', (string) ",$all_langs,") !== false)) |
|
| 463 | - ? _LANGUE_PAR_DEFAUT : substr($all_langs, 0, strpos($all_langs, ',')); |
|
| 464 | - ecrire_meta('langue_site', $tout); |
|
| 465 | - } |
|
| 436 | + // liste des langues dans les meta, sauf a l'install |
|
| 437 | + $all_langs = $GLOBALS['meta']['langues_proposees'] ?? ''; |
|
| 438 | + |
|
| 439 | + $tout = []; |
|
| 440 | + if (!$all_langs) { |
|
| 441 | + // trouver tous les modules lang/spip_xx.php |
|
| 442 | + $modules = find_all_in_path('lang/', '/spip_([a-z_]+)\.php$'); |
|
| 443 | + foreach ($modules as $name => $path) { |
|
| 444 | + if (preg_match(',^spip_([a-z_]+)\.php$,', $name, $regs)) { |
|
| 445 | + if (match_langue($regs[1])) { |
|
| 446 | + $tout[] = $regs[1]; |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + sort($tout); |
|
| 451 | + $tout = join(',', $tout); |
|
| 452 | + // Si les langues n'ont pas change, ne rien faire |
|
| 453 | + if ($tout != $all_langs) { |
|
| 454 | + $GLOBALS['meta']['langues_proposees'] = $tout; |
|
| 455 | + include_spip('inc/meta'); |
|
| 456 | + ecrire_meta('langues_proposees', $tout); |
|
| 457 | + } |
|
| 458 | + } |
|
| 459 | + if (!isset($GLOBALS['meta']['langue_site'])) { |
|
| 460 | + // Initialisation : le francais si dispo, sinon la premiere langue trouvee |
|
| 461 | + $GLOBALS['meta']['langue_site'] = $tout = |
|
| 462 | + (!$all_langs or (strpos(',' . _LANGUE_PAR_DEFAUT . ',', (string) ",$all_langs,") !== false)) |
|
| 463 | + ? _LANGUE_PAR_DEFAUT : substr($all_langs, 0, strpos($all_langs, ',')); |
|
| 464 | + ecrire_meta('langue_site', $tout); |
|
| 465 | + } |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
@@ -476,10 +476,10 @@ discard block |
||
| 476 | 476 | * Code html de la balise <html> |
| 477 | 477 | **/ |
| 478 | 478 | function html_lang_attributes() { |
| 479 | - $lang = $GLOBALS['spip_lang']; |
|
| 480 | - $dir = lang_dir($lang); |
|
| 479 | + $lang = $GLOBALS['spip_lang']; |
|
| 480 | + $dir = lang_dir($lang); |
|
| 481 | 481 | |
| 482 | - return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n"; |
|
| 482 | + return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n"; |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @return string |
| 494 | 494 | */ |
| 495 | 495 | function aide_lang_dir($spip_lang, $spip_lang_rtl) { |
| 496 | - return ($spip_lang <> 'he') ? $spip_lang_rtl : ''; |
|
| 496 | + return ($spip_lang <> 'he') ? $spip_lang_rtl : ''; |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | |
@@ -381,8 +381,7 @@ |
||
| 381 | 381 | function executer_balise_dynamique_dans_un_modele(...$args) { |
| 382 | 382 | if (test_espace_prive()) { |
| 383 | 383 | return executer_balise_dynamique(...$args); |
| 384 | - } |
|
| 385 | - else { |
|
| 384 | + } else { |
|
| 386 | 385 | $str_args = base64_encode(serialize($args)); |
| 387 | 386 | return "<?" . "php \$_zargs=unserialize(base64_decode('$str_args'));echo executer_balise_dynamique(...\$_zargs); ?".">\n"; |
| 388 | 387 | } |
@@ -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 | include_spip('inc/texte'); |
@@ -41,234 +41,234 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | function public_composer_dist($squelette, $mime_type, $gram, $source, string $connect = '') { |
| 43 | 43 | |
| 44 | - $skel = null; |
|
| 45 | - $boucle = null; |
|
| 46 | - $nom = calculer_nom_fonction_squel($squelette, $mime_type, $connect); |
|
| 47 | - |
|
| 48 | - // si deja en memoire (INCLURE a repetition) c'est bon. |
|
| 49 | - if (function_exists($nom)) { |
|
| 50 | - return $nom; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 54 | - $GLOBALS['debug_objets']['courant'] = $nom; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $phpfile = sous_repertoire(_DIR_SKELS, '', false, true) . $nom . '.php'; |
|
| 58 | - |
|
| 59 | - // si squelette est deja compile et perenne, le charger |
|
| 60 | - if (!squelette_obsolete($phpfile, $source)) { |
|
| 61 | - include_once $phpfile; |
|
| 62 | - #if (!squelette_obsolete($phpfile, $source) |
|
| 63 | - # AND lire_fichier ($phpfile, $skel_code, |
|
| 64 | - # array('critique' => 'oui', 'phpcheck' => 'oui'))){ |
|
| 65 | - ## eval('?'.'>'.$skel_code); |
|
| 66 | - # spip_log($skel_code, 'comp') |
|
| 67 | - #} |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if (file_exists($lib = $squelette . '_fonctions' . '.php')) { |
|
| 71 | - include_once $lib; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - // tester si le eval ci-dessus a mis le squelette en memoire |
|
| 75 | - |
|
| 76 | - if (function_exists($nom)) { |
|
| 77 | - return $nom; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // charger le source, si possible, et compiler |
|
| 81 | - $skel_code = ''; |
|
| 82 | - if (lire_fichier($source, $skel)) { |
|
| 83 | - $compiler = charger_fonction('compiler', 'public'); |
|
| 84 | - $skel_code = $compiler($skel, $nom, $gram, $source, $connect); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // Ne plus rien faire si le compilateur n'a pas pu operer. |
|
| 88 | - if (!$skel_code) { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - foreach ($skel_code as $id => $boucle) { |
|
| 93 | - $f = $boucle->return; |
|
| 94 | - try { |
|
| 95 | - eval("return true; $f ;"); |
|
| 96 | - } catch (\ParseError $e) { |
|
| 97 | - // Code syntaxiquement faux (critere etc mal programme') |
|
| 98 | - $msg = _T('zbug_erreur_compilation') . ' | Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 99 | - erreur_squelette($msg, $boucle); |
|
| 100 | - // continuer pour trouver d'autres fautes eventuelles |
|
| 101 | - // mais prevenir que c'est mort |
|
| 102 | - $nom = ''; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - // contexte de compil inutile a present |
|
| 106 | - // (mais la derniere valeur de $boucle est utilisee ci-dessous) |
|
| 107 | - $skel_code[$id] = $f; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $code = ''; |
|
| 111 | - if ($nom) { |
|
| 112 | - // Si le code est bon, concatener et mettre en cache |
|
| 113 | - if (function_exists($nom)) { |
|
| 114 | - $code = squelette_traduit($skel, $source, $phpfile, $skel_code); |
|
| 115 | - } else { |
|
| 116 | - // code semantiquement faux: bug du compilateur |
|
| 117 | - // $boucle est en fait ici la fct principale du squelette |
|
| 118 | - $msg = _T('zbug_erreur_compilation'); |
|
| 119 | - erreur_squelette($msg, $boucle); |
|
| 120 | - $nom = ''; |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 125 | - // Tracer ce qui vient d'etre compile |
|
| 126 | - $GLOBALS['debug_objets']['code'][$nom . 'tout'] = $code; |
|
| 127 | - |
|
| 128 | - // si c'est ce que demande le debusqueur, lui passer la main |
|
| 129 | - if ( |
|
| 130 | - $GLOBALS['debug_objets']['sourcefile'] |
|
| 131 | - and (_request('var_mode_objet') == $nom) |
|
| 132 | - and (_request('var_mode_affiche') == 'code') |
|
| 133 | - ) { |
|
| 134 | - erreur_squelette(); |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $nom ?: false; |
|
| 44 | + $skel = null; |
|
| 45 | + $boucle = null; |
|
| 46 | + $nom = calculer_nom_fonction_squel($squelette, $mime_type, $connect); |
|
| 47 | + |
|
| 48 | + // si deja en memoire (INCLURE a repetition) c'est bon. |
|
| 49 | + if (function_exists($nom)) { |
|
| 50 | + return $nom; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 54 | + $GLOBALS['debug_objets']['courant'] = $nom; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $phpfile = sous_repertoire(_DIR_SKELS, '', false, true) . $nom . '.php'; |
|
| 58 | + |
|
| 59 | + // si squelette est deja compile et perenne, le charger |
|
| 60 | + if (!squelette_obsolete($phpfile, $source)) { |
|
| 61 | + include_once $phpfile; |
|
| 62 | + #if (!squelette_obsolete($phpfile, $source) |
|
| 63 | + # AND lire_fichier ($phpfile, $skel_code, |
|
| 64 | + # array('critique' => 'oui', 'phpcheck' => 'oui'))){ |
|
| 65 | + ## eval('?'.'>'.$skel_code); |
|
| 66 | + # spip_log($skel_code, 'comp') |
|
| 67 | + #} |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if (file_exists($lib = $squelette . '_fonctions' . '.php')) { |
|
| 71 | + include_once $lib; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + // tester si le eval ci-dessus a mis le squelette en memoire |
|
| 75 | + |
|
| 76 | + if (function_exists($nom)) { |
|
| 77 | + return $nom; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // charger le source, si possible, et compiler |
|
| 81 | + $skel_code = ''; |
|
| 82 | + if (lire_fichier($source, $skel)) { |
|
| 83 | + $compiler = charger_fonction('compiler', 'public'); |
|
| 84 | + $skel_code = $compiler($skel, $nom, $gram, $source, $connect); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // Ne plus rien faire si le compilateur n'a pas pu operer. |
|
| 88 | + if (!$skel_code) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + foreach ($skel_code as $id => $boucle) { |
|
| 93 | + $f = $boucle->return; |
|
| 94 | + try { |
|
| 95 | + eval("return true; $f ;"); |
|
| 96 | + } catch (\ParseError $e) { |
|
| 97 | + // Code syntaxiquement faux (critere etc mal programme') |
|
| 98 | + $msg = _T('zbug_erreur_compilation') . ' | Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 99 | + erreur_squelette($msg, $boucle); |
|
| 100 | + // continuer pour trouver d'autres fautes eventuelles |
|
| 101 | + // mais prevenir que c'est mort |
|
| 102 | + $nom = ''; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + // contexte de compil inutile a present |
|
| 106 | + // (mais la derniere valeur de $boucle est utilisee ci-dessous) |
|
| 107 | + $skel_code[$id] = $f; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $code = ''; |
|
| 111 | + if ($nom) { |
|
| 112 | + // Si le code est bon, concatener et mettre en cache |
|
| 113 | + if (function_exists($nom)) { |
|
| 114 | + $code = squelette_traduit($skel, $source, $phpfile, $skel_code); |
|
| 115 | + } else { |
|
| 116 | + // code semantiquement faux: bug du compilateur |
|
| 117 | + // $boucle est en fait ici la fct principale du squelette |
|
| 118 | + $msg = _T('zbug_erreur_compilation'); |
|
| 119 | + erreur_squelette($msg, $boucle); |
|
| 120 | + $nom = ''; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 125 | + // Tracer ce qui vient d'etre compile |
|
| 126 | + $GLOBALS['debug_objets']['code'][$nom . 'tout'] = $code; |
|
| 127 | + |
|
| 128 | + // si c'est ce que demande le debusqueur, lui passer la main |
|
| 129 | + if ( |
|
| 130 | + $GLOBALS['debug_objets']['sourcefile'] |
|
| 131 | + and (_request('var_mode_objet') == $nom) |
|
| 132 | + and (_request('var_mode_affiche') == 'code') |
|
| 133 | + ) { |
|
| 134 | + erreur_squelette(); |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $nom ?: false; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | function squelette_traduit($squelette, $sourcefile, $phpfile, $boucles) { |
| 142 | 142 | |
| 143 | - $code = null; |
|
| 144 | - // Le dernier index est '' (fonction principale) |
|
| 145 | - $noms = substr(join(', ', array_keys($boucles)), 0, -2); |
|
| 146 | - if (CODE_COMMENTE) { |
|
| 147 | - $code = " |
|
| 143 | + $code = null; |
|
| 144 | + // Le dernier index est '' (fonction principale) |
|
| 145 | + $noms = substr(join(', ', array_keys($boucles)), 0, -2); |
|
| 146 | + if (CODE_COMMENTE) { |
|
| 147 | + $code = " |
|
| 148 | 148 | /* |
| 149 | 149 | * Squelette : $sourcefile |
| 150 | 150 | * Date : " . gmdate('D, d M Y H:i:s', @filemtime($sourcefile)) . ' GMT |
| 151 | 151 | * Compile : ' . gmdate('D, d M Y H:i:s', time()) . ' GMT |
| 152 | 152 | * ' . (!$boucles ? 'Pas de boucle' : ('Boucles : ' . $noms)) . ' |
| 153 | 153 | */ '; |
| 154 | - } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - $code = '<' . "?php\n" . $code . join('', $boucles) . "\n"; |
|
| 157 | - if (!defined('_VAR_NOCACHE') or !_VAR_NOCACHE) { |
|
| 158 | - ecrire_fichier($phpfile, $code); |
|
| 159 | - } |
|
| 156 | + $code = '<' . "?php\n" . $code . join('', $boucles) . "\n"; |
|
| 157 | + if (!defined('_VAR_NOCACHE') or !_VAR_NOCACHE) { |
|
| 158 | + ecrire_fichier($phpfile, $code); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - return $code; |
|
| 161 | + return $code; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // Le squelette compile est-il trop vieux ? |
| 165 | 165 | function squelette_obsolete($skel, $squelette) { |
| 166 | - static $date_change = null; |
|
| 167 | - // ne verifier la date de mes_fonctions et mes_options qu'une seule fois |
|
| 168 | - // par hit |
|
| 169 | - if (is_null($date_change)) { |
|
| 170 | - if (@file_exists($fonc = 'mes_fonctions.php')) { |
|
| 171 | - $date_change = @filemtime($fonc); |
|
| 172 | - } # compatibilite |
|
| 173 | - if (defined('_FILE_OPTIONS')) { |
|
| 174 | - $date_change = max($date_change, @filemtime(_FILE_OPTIONS)); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - return ( |
|
| 179 | - (defined('_VAR_MODE') and in_array(_VAR_MODE, ['recalcul', 'preview', 'debug'])) |
|
| 180 | - or !@file_exists($skel) |
|
| 181 | - or ((@file_exists($squelette) ? @filemtime($squelette) : 0) |
|
| 182 | - > ($date = @filemtime($skel))) |
|
| 183 | - or ($date_change > $date) |
|
| 184 | - ); |
|
| 166 | + static $date_change = null; |
|
| 167 | + // ne verifier la date de mes_fonctions et mes_options qu'une seule fois |
|
| 168 | + // par hit |
|
| 169 | + if (is_null($date_change)) { |
|
| 170 | + if (@file_exists($fonc = 'mes_fonctions.php')) { |
|
| 171 | + $date_change = @filemtime($fonc); |
|
| 172 | + } # compatibilite |
|
| 173 | + if (defined('_FILE_OPTIONS')) { |
|
| 174 | + $date_change = max($date_change, @filemtime(_FILE_OPTIONS)); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + return ( |
|
| 179 | + (defined('_VAR_MODE') and in_array(_VAR_MODE, ['recalcul', 'preview', 'debug'])) |
|
| 180 | + or !@file_exists($skel) |
|
| 181 | + or ((@file_exists($squelette) ? @filemtime($squelette) : 0) |
|
| 182 | + > ($date = @filemtime($skel))) |
|
| 183 | + or ($date_change > $date) |
|
| 184 | + ); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // Activer l'invalideur de session |
| 188 | 188 | function invalideur_session(&$Cache, $code = null) { |
| 189 | - $Cache['session'] = spip_session(); |
|
| 189 | + $Cache['session'] = spip_session(); |
|
| 190 | 190 | |
| 191 | - return $code; |
|
| 191 | + return $code; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | |
| 195 | 195 | function analyse_resultat_skel($nom, $cache, $corps, $source = '') { |
| 196 | - static $filtres = []; |
|
| 197 | - $headers = []; |
|
| 198 | - $corps ??= ''; |
|
| 199 | - |
|
| 200 | - // Recupere les < ?php header('Xx: y'); ? > pour $page['headers'] |
|
| 201 | - // note: on essaie d'attrapper aussi certains de ces entetes codes |
|
| 202 | - // "a la main" dans les squelettes, mais evidemment sans exhaustivite |
|
| 203 | - if ( |
|
| 204 | - stripos($corps, 'header') !== false |
|
| 205 | - and preg_match_all( |
|
| 206 | - '/(<[?]php\s+)@?header\s*\(\s*.([^:\'"]*):?\s*([^)]*)[^)]\s*\)\s*[;]?\s*[?]>/ims', |
|
| 207 | - $corps, |
|
| 208 | - $regs, |
|
| 209 | - PREG_SET_ORDER |
|
| 210 | - ) |
|
| 211 | - ) { |
|
| 212 | - foreach ($regs as $r) { |
|
| 213 | - $corps = str_replace($r[0], '', $corps); |
|
| 214 | - # $j = Content-Type, et pas content-TYPE. |
|
| 215 | - $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); |
|
| 216 | - |
|
| 217 | - if ($j == 'X-Spip-Filtre' and isset($headers[$j])) { |
|
| 218 | - $headers[$j] .= '|' . $r[3]; |
|
| 219 | - } else { |
|
| 220 | - $headers[$j] = str_replace(['\\\\',"\\'",'\\"'], ['\\',"'",'"'], $r[3]); |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - // S'agit-il d'un resultat constant ou contenant du code php |
|
| 225 | - $process_ins = ( |
|
| 226 | - strpos($corps, '<' . '?') === false |
|
| 227 | - or |
|
| 228 | - (strpos($corps, '<' . '?xml') !== false and |
|
| 229 | - strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 230 | - ) |
|
| 231 | - ? 'html' |
|
| 232 | - : 'php'; |
|
| 233 | - |
|
| 234 | - $skel = [ |
|
| 235 | - 'squelette' => $nom, |
|
| 236 | - 'source' => $source, |
|
| 237 | - 'process_ins' => $process_ins, |
|
| 238 | - 'invalideurs' => $cache, |
|
| 239 | - 'entetes' => $headers, |
|
| 240 | - 'duree' => isset($headers['X-Spip-Cache']) ? intval($headers['X-Spip-Cache']) : 0 |
|
| 241 | - ]; |
|
| 242 | - |
|
| 243 | - // traiter #FILTRE{} et filtres |
|
| 244 | - if (!isset($filtres[$nom])) { |
|
| 245 | - $filtres[$nom] = pipeline('declarer_filtres_squelettes', ['args' => $skel, 'data' => []]); |
|
| 246 | - } |
|
| 247 | - $filtres_headers = []; |
|
| 248 | - if (isset($headers['X-Spip-Filtre']) and strlen($headers['X-Spip-Filtre'])) { |
|
| 249 | - $filtres_headers = array_filter(explode('|', $headers['X-Spip-Filtre'])); |
|
| 250 | - unset($headers['X-Spip-Filtre']); |
|
| 251 | - } |
|
| 252 | - if (is_array($filtres[$nom]) || $filtres[$nom] instanceof \Countable ? count($filtres[$nom]) : 0 or count($filtres_headers)) { |
|
| 253 | - include_spip('public/sandbox'); |
|
| 254 | - $corps = sandbox_filtrer_squelette($skel, $corps, $filtres_headers, $filtres[$nom]); |
|
| 255 | - |
|
| 256 | - if ($process_ins == 'html') { |
|
| 257 | - $skel['process_ins'] = ( |
|
| 258 | - strpos($corps, '<' . '?') === false |
|
| 259 | - or |
|
| 260 | - (strpos($corps, '<' . '?xml') !== false and |
|
| 261 | - strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 262 | - ) |
|
| 263 | - ? 'html' |
|
| 264 | - : 'php'; |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - $skel['entetes'] = $headers; |
|
| 269 | - $skel['texte'] = $corps; |
|
| 270 | - |
|
| 271 | - return $skel; |
|
| 196 | + static $filtres = []; |
|
| 197 | + $headers = []; |
|
| 198 | + $corps ??= ''; |
|
| 199 | + |
|
| 200 | + // Recupere les < ?php header('Xx: y'); ? > pour $page['headers'] |
|
| 201 | + // note: on essaie d'attrapper aussi certains de ces entetes codes |
|
| 202 | + // "a la main" dans les squelettes, mais evidemment sans exhaustivite |
|
| 203 | + if ( |
|
| 204 | + stripos($corps, 'header') !== false |
|
| 205 | + and preg_match_all( |
|
| 206 | + '/(<[?]php\s+)@?header\s*\(\s*.([^:\'"]*):?\s*([^)]*)[^)]\s*\)\s*[;]?\s*[?]>/ims', |
|
| 207 | + $corps, |
|
| 208 | + $regs, |
|
| 209 | + PREG_SET_ORDER |
|
| 210 | + ) |
|
| 211 | + ) { |
|
| 212 | + foreach ($regs as $r) { |
|
| 213 | + $corps = str_replace($r[0], '', $corps); |
|
| 214 | + # $j = Content-Type, et pas content-TYPE. |
|
| 215 | + $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); |
|
| 216 | + |
|
| 217 | + if ($j == 'X-Spip-Filtre' and isset($headers[$j])) { |
|
| 218 | + $headers[$j] .= '|' . $r[3]; |
|
| 219 | + } else { |
|
| 220 | + $headers[$j] = str_replace(['\\\\',"\\'",'\\"'], ['\\',"'",'"'], $r[3]); |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + // S'agit-il d'un resultat constant ou contenant du code php |
|
| 225 | + $process_ins = ( |
|
| 226 | + strpos($corps, '<' . '?') === false |
|
| 227 | + or |
|
| 228 | + (strpos($corps, '<' . '?xml') !== false and |
|
| 229 | + strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 230 | + ) |
|
| 231 | + ? 'html' |
|
| 232 | + : 'php'; |
|
| 233 | + |
|
| 234 | + $skel = [ |
|
| 235 | + 'squelette' => $nom, |
|
| 236 | + 'source' => $source, |
|
| 237 | + 'process_ins' => $process_ins, |
|
| 238 | + 'invalideurs' => $cache, |
|
| 239 | + 'entetes' => $headers, |
|
| 240 | + 'duree' => isset($headers['X-Spip-Cache']) ? intval($headers['X-Spip-Cache']) : 0 |
|
| 241 | + ]; |
|
| 242 | + |
|
| 243 | + // traiter #FILTRE{} et filtres |
|
| 244 | + if (!isset($filtres[$nom])) { |
|
| 245 | + $filtres[$nom] = pipeline('declarer_filtres_squelettes', ['args' => $skel, 'data' => []]); |
|
| 246 | + } |
|
| 247 | + $filtres_headers = []; |
|
| 248 | + if (isset($headers['X-Spip-Filtre']) and strlen($headers['X-Spip-Filtre'])) { |
|
| 249 | + $filtres_headers = array_filter(explode('|', $headers['X-Spip-Filtre'])); |
|
| 250 | + unset($headers['X-Spip-Filtre']); |
|
| 251 | + } |
|
| 252 | + if (is_array($filtres[$nom]) || $filtres[$nom] instanceof \Countable ? count($filtres[$nom]) : 0 or count($filtres_headers)) { |
|
| 253 | + include_spip('public/sandbox'); |
|
| 254 | + $corps = sandbox_filtrer_squelette($skel, $corps, $filtres_headers, $filtres[$nom]); |
|
| 255 | + |
|
| 256 | + if ($process_ins == 'html') { |
|
| 257 | + $skel['process_ins'] = ( |
|
| 258 | + strpos($corps, '<' . '?') === false |
|
| 259 | + or |
|
| 260 | + (strpos($corps, '<' . '?xml') !== false and |
|
| 261 | + strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 262 | + ) |
|
| 263 | + ? 'html' |
|
| 264 | + : 'php'; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + $skel['entetes'] = $headers; |
|
| 269 | + $skel['texte'] = $corps; |
|
| 270 | + |
|
| 271 | + return $skel; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | inserer_balise_dynamique(balise_%s_dyn(%s), array(%s)); |
| 283 | 283 | if ($lang_select) lang_select(); |
| 284 | 284 | ?' |
| 285 | - . '>'); |
|
| 285 | + . '>'); |
|
| 286 | 286 | |
| 287 | 287 | /** |
| 288 | 288 | * Synthétise une balise dynamique : crée l'appel à l'inclusion |
@@ -302,35 +302,35 @@ discard block |
||
| 302 | 302 | * Code PHP pour inclure le squelette de la balise dynamique |
| 303 | 303 | **/ |
| 304 | 304 | function synthetiser_balise_dynamique($nom, $args, $file, $context_compil) { |
| 305 | - if ( |
|
| 306 | - strncmp($file, '/', 1) !== 0 |
|
| 307 | - // pas de lien symbolique sous Windows |
|
| 308 | - and !(stristr(PHP_OS, 'WIN') and str_contains($file, ':')) |
|
| 309 | - ) { |
|
| 310 | - $file = './" . _DIR_RACINE . "' . $file; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - $lang = $context_compil[4]; |
|
| 314 | - if (preg_match(',\W,', $lang)) { |
|
| 315 | - $lang = ''; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $args = array_map('argumenter_squelette', $args); |
|
| 319 | - if (!empty($context_compil['appel_php_depuis_modele'])) { |
|
| 320 | - $args[0] = 'arguments_balise_dyn_depuis_modele(' . $args[0] . ')'; |
|
| 321 | - } |
|
| 322 | - $args = join(', ', $args); |
|
| 323 | - |
|
| 324 | - $r = sprintf( |
|
| 325 | - CODE_INCLURE_BALISE, |
|
| 326 | - $file, |
|
| 327 | - $lang, |
|
| 328 | - $nom, |
|
| 329 | - $args, |
|
| 330 | - join(', ', array_map('_q', $context_compil)) |
|
| 331 | - ); |
|
| 332 | - |
|
| 333 | - return $r; |
|
| 305 | + if ( |
|
| 306 | + strncmp($file, '/', 1) !== 0 |
|
| 307 | + // pas de lien symbolique sous Windows |
|
| 308 | + and !(stristr(PHP_OS, 'WIN') and str_contains($file, ':')) |
|
| 309 | + ) { |
|
| 310 | + $file = './" . _DIR_RACINE . "' . $file; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + $lang = $context_compil[4]; |
|
| 314 | + if (preg_match(',\W,', $lang)) { |
|
| 315 | + $lang = ''; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $args = array_map('argumenter_squelette', $args); |
|
| 319 | + if (!empty($context_compil['appel_php_depuis_modele'])) { |
|
| 320 | + $args[0] = 'arguments_balise_dyn_depuis_modele(' . $args[0] . ')'; |
|
| 321 | + } |
|
| 322 | + $args = join(', ', $args); |
|
| 323 | + |
|
| 324 | + $r = sprintf( |
|
| 325 | + CODE_INCLURE_BALISE, |
|
| 326 | + $file, |
|
| 327 | + $lang, |
|
| 328 | + $nom, |
|
| 329 | + $args, |
|
| 330 | + join(', ', array_map('_q', $context_compil)) |
|
| 331 | + ); |
|
| 332 | + |
|
| 333 | + return $r; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -348,18 +348,18 @@ discard block |
||
| 348 | 348 | **/ |
| 349 | 349 | function argumenter_squelette($v) { |
| 350 | 350 | |
| 351 | - if (is_object($v)) { |
|
| 352 | - return var_export($v, true); |
|
| 353 | - } elseif (!is_array($v)) { |
|
| 354 | - return "'" . texte_script((string) $v) . "'"; |
|
| 355 | - } else { |
|
| 356 | - $out = []; |
|
| 357 | - foreach ($v as $k => $val) { |
|
| 358 | - $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - return 'array(' . join(', ', $out) . ')'; |
|
| 362 | - } |
|
| 351 | + if (is_object($v)) { |
|
| 352 | + return var_export($v, true); |
|
| 353 | + } elseif (!is_array($v)) { |
|
| 354 | + return "'" . texte_script((string) $v) . "'"; |
|
| 355 | + } else { |
|
| 356 | + $out = []; |
|
| 357 | + foreach ($v as $k => $val) { |
|
| 358 | + $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + return 'array(' . join(', ', $out) . ')'; |
|
| 362 | + } |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | * @return string |
| 379 | 379 | */ |
| 380 | 380 | function executer_balise_dynamique_dans_un_modele(...$args) { |
| 381 | - if (test_espace_prive()) { |
|
| 382 | - return executer_balise_dynamique(...$args); |
|
| 383 | - } |
|
| 384 | - else { |
|
| 385 | - $str_args = base64_encode(serialize($args)); |
|
| 386 | - return "<?" . "php \$_zargs=unserialize(base64_decode('$str_args'));echo executer_balise_dynamique(...\$_zargs); ?".">\n"; |
|
| 387 | - } |
|
| 381 | + if (test_espace_prive()) { |
|
| 382 | + return executer_balise_dynamique(...$args); |
|
| 383 | + } |
|
| 384 | + else { |
|
| 385 | + $str_args = base64_encode(serialize($args)); |
|
| 386 | + return "<?" . "php \$_zargs=unserialize(base64_decode('$str_args'));echo executer_balise_dynamique(...\$_zargs); ?".">\n"; |
|
| 387 | + } |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | |
@@ -415,87 +415,87 @@ discard block |
||
| 415 | 415 | * Code PHP d'exécutant l'inclusion du squelette (ou texte) de la balise dynamique |
| 416 | 416 | **/ |
| 417 | 417 | function executer_balise_dynamique($nom, $args, $context_compil) { |
| 418 | - /** @var string Nom de la balise à charger (balise demandée ou balise générique) */ |
|
| 419 | - $nom_balise = $nom; |
|
| 420 | - /** @var string Nom de la balise générique (si utilisée) */ |
|
| 421 | - $nom_balise_generique = ''; |
|
| 422 | - |
|
| 423 | - $appel_php_depuis_modele = false; |
|
| 424 | - if ( |
|
| 425 | - is_array($context_compil) |
|
| 426 | - and !is_numeric($context_compil[3]) |
|
| 427 | - and empty($context_compil[0]) |
|
| 428 | - and empty($context_compil[1]) |
|
| 429 | - and empty($context_compil[2]) |
|
| 430 | - and empty($context_compil[3]) |
|
| 431 | - ) { |
|
| 432 | - $appel_php_depuis_modele = true; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - if (!$fonction_balise = charger_fonction($nom_balise, 'balise', true)) { |
|
| 436 | - // Calculer un nom générique (ie. 'formulaire_' dans 'formulaire_editer_article') |
|
| 437 | - if ($balise_generique = chercher_balise_generique($nom)) { |
|
| 438 | - // injecter en premier arg le nom de la balise |
|
| 439 | - array_unshift($args, $nom); |
|
| 440 | - $nom_balise_generique = $balise_generique['nom_generique']; |
|
| 441 | - $fonction_balise = $balise_generique['fonction_generique']; |
|
| 442 | - $nom_balise = $nom_balise_generique; |
|
| 443 | - } |
|
| 444 | - unset($balise_generique); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - if (!$fonction_balise) { |
|
| 448 | - $msg = ['zbug_balise_inexistante', ['from' => 'CVT', 'balise' => $nom]]; |
|
| 449 | - erreur_squelette($msg, $context_compil); |
|
| 450 | - |
|
| 451 | - return ''; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - // retrouver le fichier qui a déclaré la fonction |
|
| 455 | - // même si la fonction dynamique est déclarée dans un fichier de fonctions. |
|
| 456 | - // Attention sous windows, getFileName() retourne un antislash. |
|
| 457 | - $reflector = new ReflectionFunction($fonction_balise); |
|
| 458 | - $file = str_replace('\\', '/', $reflector->getFileName()); |
|
| 459 | - if (strncmp($file, str_replace('\\', '/', _ROOT_RACINE), strlen(_ROOT_RACINE)) === 0) { |
|
| 460 | - $file = substr($file, strlen(_ROOT_RACINE)); |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - // Y a-t-il une fonction de traitement des arguments ? |
|
| 464 | - $f = 'balise_' . $nom_balise . '_stat'; |
|
| 465 | - |
|
| 466 | - $r = !function_exists($f) ? $args : $f($args, $context_compil); |
|
| 467 | - |
|
| 468 | - if (!is_array($r)) { |
|
| 469 | - return $r; |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - // verifier que la fonction dyn est la, |
|
| 473 | - // sinon se replier sur la generique si elle existe |
|
| 474 | - if (!function_exists('balise_' . $nom_balise . '_dyn')) { |
|
| 475 | - if ( |
|
| 476 | - $balise_generique = chercher_balise_generique($nom) |
|
| 477 | - and $nom_balise_generique = $balise_generique['nom_generique'] |
|
| 478 | - and $file = include_spip('balise/' . strtolower($nom_balise_generique)) |
|
| 479 | - and function_exists('balise_' . $nom_balise_generique . '_dyn') |
|
| 480 | - ) { |
|
| 481 | - // et lui injecter en premier arg le nom de la balise |
|
| 482 | - array_unshift($r, $nom); |
|
| 483 | - $nom_balise = $nom_balise_generique; |
|
| 484 | - if (!_DIR_RESTREINT) { |
|
| 485 | - $file = _DIR_RESTREINT_ABS . $file; |
|
| 486 | - } |
|
| 487 | - } else { |
|
| 488 | - $msg = ['zbug_balise_inexistante', ['from' => 'CVT', 'balise' => $nom]]; |
|
| 489 | - erreur_squelette($msg, $context_compil); |
|
| 490 | - |
|
| 491 | - return ''; |
|
| 492 | - } |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - if ($appel_php_depuis_modele) { |
|
| 496 | - $context_compil['appel_php_depuis_modele'] = true; |
|
| 497 | - } |
|
| 498 | - return synthetiser_balise_dynamique($nom_balise, $r, $file, $context_compil); |
|
| 418 | + /** @var string Nom de la balise à charger (balise demandée ou balise générique) */ |
|
| 419 | + $nom_balise = $nom; |
|
| 420 | + /** @var string Nom de la balise générique (si utilisée) */ |
|
| 421 | + $nom_balise_generique = ''; |
|
| 422 | + |
|
| 423 | + $appel_php_depuis_modele = false; |
|
| 424 | + if ( |
|
| 425 | + is_array($context_compil) |
|
| 426 | + and !is_numeric($context_compil[3]) |
|
| 427 | + and empty($context_compil[0]) |
|
| 428 | + and empty($context_compil[1]) |
|
| 429 | + and empty($context_compil[2]) |
|
| 430 | + and empty($context_compil[3]) |
|
| 431 | + ) { |
|
| 432 | + $appel_php_depuis_modele = true; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + if (!$fonction_balise = charger_fonction($nom_balise, 'balise', true)) { |
|
| 436 | + // Calculer un nom générique (ie. 'formulaire_' dans 'formulaire_editer_article') |
|
| 437 | + if ($balise_generique = chercher_balise_generique($nom)) { |
|
| 438 | + // injecter en premier arg le nom de la balise |
|
| 439 | + array_unshift($args, $nom); |
|
| 440 | + $nom_balise_generique = $balise_generique['nom_generique']; |
|
| 441 | + $fonction_balise = $balise_generique['fonction_generique']; |
|
| 442 | + $nom_balise = $nom_balise_generique; |
|
| 443 | + } |
|
| 444 | + unset($balise_generique); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + if (!$fonction_balise) { |
|
| 448 | + $msg = ['zbug_balise_inexistante', ['from' => 'CVT', 'balise' => $nom]]; |
|
| 449 | + erreur_squelette($msg, $context_compil); |
|
| 450 | + |
|
| 451 | + return ''; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + // retrouver le fichier qui a déclaré la fonction |
|
| 455 | + // même si la fonction dynamique est déclarée dans un fichier de fonctions. |
|
| 456 | + // Attention sous windows, getFileName() retourne un antislash. |
|
| 457 | + $reflector = new ReflectionFunction($fonction_balise); |
|
| 458 | + $file = str_replace('\\', '/', $reflector->getFileName()); |
|
| 459 | + if (strncmp($file, str_replace('\\', '/', _ROOT_RACINE), strlen(_ROOT_RACINE)) === 0) { |
|
| 460 | + $file = substr($file, strlen(_ROOT_RACINE)); |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + // Y a-t-il une fonction de traitement des arguments ? |
|
| 464 | + $f = 'balise_' . $nom_balise . '_stat'; |
|
| 465 | + |
|
| 466 | + $r = !function_exists($f) ? $args : $f($args, $context_compil); |
|
| 467 | + |
|
| 468 | + if (!is_array($r)) { |
|
| 469 | + return $r; |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + // verifier que la fonction dyn est la, |
|
| 473 | + // sinon se replier sur la generique si elle existe |
|
| 474 | + if (!function_exists('balise_' . $nom_balise . '_dyn')) { |
|
| 475 | + if ( |
|
| 476 | + $balise_generique = chercher_balise_generique($nom) |
|
| 477 | + and $nom_balise_generique = $balise_generique['nom_generique'] |
|
| 478 | + and $file = include_spip('balise/' . strtolower($nom_balise_generique)) |
|
| 479 | + and function_exists('balise_' . $nom_balise_generique . '_dyn') |
|
| 480 | + ) { |
|
| 481 | + // et lui injecter en premier arg le nom de la balise |
|
| 482 | + array_unshift($r, $nom); |
|
| 483 | + $nom_balise = $nom_balise_generique; |
|
| 484 | + if (!_DIR_RESTREINT) { |
|
| 485 | + $file = _DIR_RESTREINT_ABS . $file; |
|
| 486 | + } |
|
| 487 | + } else { |
|
| 488 | + $msg = ['zbug_balise_inexistante', ['from' => 'CVT', 'balise' => $nom]]; |
|
| 489 | + erreur_squelette($msg, $context_compil); |
|
| 490 | + |
|
| 491 | + return ''; |
|
| 492 | + } |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + if ($appel_php_depuis_modele) { |
|
| 496 | + $context_compil['appel_php_depuis_modele'] = true; |
|
| 497 | + } |
|
| 498 | + return synthetiser_balise_dynamique($nom_balise, $r, $file, $context_compil); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | /** |
@@ -510,23 +510,23 @@ discard block |
||
| 510 | 510 | * @return array|null |
| 511 | 511 | */ |
| 512 | 512 | function chercher_balise_generique($nom) { |
| 513 | - if (!str_contains($nom, '_')) { |
|
| 514 | - return null; |
|
| 515 | - } |
|
| 516 | - $nom_generique = $nom; |
|
| 517 | - while (false !== ($p = strrpos($nom_generique, '_'))) { |
|
| 518 | - $nom_generique = substr($nom_generique, 0, $p + 1); |
|
| 519 | - $fonction_generique = charger_fonction($nom_generique, 'balise', true); |
|
| 520 | - if ($fonction_generique) { |
|
| 521 | - return [ |
|
| 522 | - 'nom' => $nom, |
|
| 523 | - 'nom_generique' => $nom_generique, |
|
| 524 | - 'fonction_generique' => $fonction_generique, |
|
| 525 | - ]; |
|
| 526 | - } |
|
| 527 | - $nom_generique = substr($nom_generique, 0, -1); |
|
| 528 | - } |
|
| 529 | - return null; |
|
| 513 | + if (!str_contains($nom, '_')) { |
|
| 514 | + return null; |
|
| 515 | + } |
|
| 516 | + $nom_generique = $nom; |
|
| 517 | + while (false !== ($p = strrpos($nom_generique, '_'))) { |
|
| 518 | + $nom_generique = substr($nom_generique, 0, $p + 1); |
|
| 519 | + $fonction_generique = charger_fonction($nom_generique, 'balise', true); |
|
| 520 | + if ($fonction_generique) { |
|
| 521 | + return [ |
|
| 522 | + 'nom' => $nom, |
|
| 523 | + 'nom_generique' => $nom_generique, |
|
| 524 | + 'fonction_generique' => $fonction_generique, |
|
| 525 | + ]; |
|
| 526 | + } |
|
| 527 | + $nom_generique = substr($nom_generique, 0, -1); |
|
| 528 | + } |
|
| 529 | + return null; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | |
@@ -550,50 +550,50 @@ discard block |
||
| 550 | 550 | * @return null; |
| 551 | 551 | **/ |
| 552 | 552 | function lang_select_public($lang, $lang_select, $titre = null) { |
| 553 | - // Cas 1. forcer_lang = true et pas de critere {lang_select} |
|
| 554 | - if ( |
|
| 555 | - isset($GLOBALS['forcer_lang']) and $GLOBALS['forcer_lang'] |
|
| 556 | - and $lang_select !== 'oui' |
|
| 557 | - ) { |
|
| 558 | - $lang = $GLOBALS['spip_lang']; |
|
| 559 | - } // Cas 2. l'objet n'a pas de langue definie (ou definie a '') |
|
| 560 | - elseif (!strlen($lang)) { |
|
| 561 | - $lang = $GLOBALS['spip_lang']; |
|
| 562 | - } // Cas 3. l'objet est multilingue ! |
|
| 563 | - elseif ( |
|
| 564 | - $lang_select !== 'oui' |
|
| 565 | - and strlen($titre) > 10 |
|
| 566 | - and str_contains($titre, '<multi>') |
|
| 567 | - and str_contains(echappe_html($titre), '<multi>') |
|
| 568 | - ) { |
|
| 569 | - $lang = $GLOBALS['spip_lang']; |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - // faire un lang_select() eventuellement sur la langue inchangee |
|
| 573 | - lang_select($lang); |
|
| 574 | - |
|
| 575 | - return; |
|
| 553 | + // Cas 1. forcer_lang = true et pas de critere {lang_select} |
|
| 554 | + if ( |
|
| 555 | + isset($GLOBALS['forcer_lang']) and $GLOBALS['forcer_lang'] |
|
| 556 | + and $lang_select !== 'oui' |
|
| 557 | + ) { |
|
| 558 | + $lang = $GLOBALS['spip_lang']; |
|
| 559 | + } // Cas 2. l'objet n'a pas de langue definie (ou definie a '') |
|
| 560 | + elseif (!strlen($lang)) { |
|
| 561 | + $lang = $GLOBALS['spip_lang']; |
|
| 562 | + } // Cas 3. l'objet est multilingue ! |
|
| 563 | + elseif ( |
|
| 564 | + $lang_select !== 'oui' |
|
| 565 | + and strlen($titre) > 10 |
|
| 566 | + and str_contains($titre, '<multi>') |
|
| 567 | + and str_contains(echappe_html($titre), '<multi>') |
|
| 568 | + ) { |
|
| 569 | + $lang = $GLOBALS['spip_lang']; |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + // faire un lang_select() eventuellement sur la langue inchangee |
|
| 573 | + lang_select($lang); |
|
| 574 | + |
|
| 575 | + return; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | |
| 579 | 579 | // Si un tableau &doublons[articles] est passe en parametre, |
| 580 | 580 | // il faut le nettoyer car il pourrait etre injecte en SQL |
| 581 | 581 | function nettoyer_env_doublons($envd) { |
| 582 | - foreach ($envd as $table => $liste) { |
|
| 583 | - $n = ''; |
|
| 584 | - foreach (explode(',', $liste) as $val) { |
|
| 585 | - if ($a = intval($val) and $val === strval($a)) { |
|
| 586 | - $n .= ',' . $val; |
|
| 587 | - } |
|
| 588 | - } |
|
| 589 | - if (strlen($n)) { |
|
| 590 | - $envd[$table] = $n; |
|
| 591 | - } else { |
|
| 592 | - unset($envd[$table]); |
|
| 593 | - } |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - return $envd; |
|
| 582 | + foreach ($envd as $table => $liste) { |
|
| 583 | + $n = ''; |
|
| 584 | + foreach (explode(',', $liste) as $val) { |
|
| 585 | + if ($a = intval($val) and $val === strval($a)) { |
|
| 586 | + $n .= ',' . $val; |
|
| 587 | + } |
|
| 588 | + } |
|
| 589 | + if (strlen($n)) { |
|
| 590 | + $envd[$table] = $n; |
|
| 591 | + } else { |
|
| 592 | + unset($envd[$table]); |
|
| 593 | + } |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + return $envd; |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /** |
@@ -612,21 +612,21 @@ discard block |
||
| 612 | 612 | * Opérateur trouvé (SELF ou SUBSELECT) sinon false. |
| 613 | 613 | **/ |
| 614 | 614 | function match_self($w) { |
| 615 | - if (is_string($w)) { |
|
| 616 | - return false; |
|
| 617 | - } |
|
| 618 | - if (is_array($w)) { |
|
| 619 | - if (in_array(reset($w), ['SELF', 'SUBSELECT'])) { |
|
| 620 | - return $w; |
|
| 621 | - } |
|
| 622 | - foreach (array_filter($w, 'is_array') as $sw) { |
|
| 623 | - if ($m = match_self($sw)) { |
|
| 624 | - return $m; |
|
| 625 | - } |
|
| 626 | - } |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - return false; |
|
| 615 | + if (is_string($w)) { |
|
| 616 | + return false; |
|
| 617 | + } |
|
| 618 | + if (is_array($w)) { |
|
| 619 | + if (in_array(reset($w), ['SELF', 'SUBSELECT'])) { |
|
| 620 | + return $w; |
|
| 621 | + } |
|
| 622 | + foreach (array_filter($w, 'is_array') as $sw) { |
|
| 623 | + if ($m = match_self($sw)) { |
|
| 624 | + return $m; |
|
| 625 | + } |
|
| 626 | + } |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + return false; |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | /** |
@@ -642,16 +642,16 @@ discard block |
||
| 642 | 642 | * est remplacée par son code. |
| 643 | 643 | **/ |
| 644 | 644 | function remplace_sous_requete($w, $sousrequete) { |
| 645 | - if (is_array($w)) { |
|
| 646 | - if (in_array(reset($w), ['SELF', 'SUBSELECT'])) { |
|
| 647 | - return $sousrequete; |
|
| 648 | - } |
|
| 649 | - foreach ($w as $k => $sw) { |
|
| 650 | - $w[$k] = remplace_sous_requete($sw, $sousrequete); |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - return $w; |
|
| 645 | + if (is_array($w)) { |
|
| 646 | + if (in_array(reset($w), ['SELF', 'SUBSELECT'])) { |
|
| 647 | + return $sousrequete; |
|
| 648 | + } |
|
| 649 | + foreach ($w as $k => $sw) { |
|
| 650 | + $w[$k] = remplace_sous_requete($sw, $sousrequete); |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + return $w; |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
@@ -665,17 +665,17 @@ discard block |
||
| 665 | 665 | * - Conditions avec des sous requêtes |
| 666 | 666 | **/ |
| 667 | 667 | function trouver_sous_requetes($where) { |
| 668 | - $where_simples = []; |
|
| 669 | - $where_sous = []; |
|
| 670 | - foreach ($where as $k => $w) { |
|
| 671 | - if (match_self($w)) { |
|
| 672 | - $where_sous[$k] = $w; |
|
| 673 | - } else { |
|
| 674 | - $where_simples[$k] = $w; |
|
| 675 | - } |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - return [$where_simples, $where_sous]; |
|
| 668 | + $where_simples = []; |
|
| 669 | + $where_sous = []; |
|
| 670 | + foreach ($where as $k => $w) { |
|
| 671 | + if (match_self($w)) { |
|
| 672 | + $where_sous[$k] = $w; |
|
| 673 | + } else { |
|
| 674 | + $where_simples[$k] = $w; |
|
| 675 | + } |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + return [$where_simples, $where_sous]; |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | |
@@ -701,292 +701,292 @@ discard block |
||
| 701 | 701 | * @return resource |
| 702 | 702 | */ |
| 703 | 703 | function calculer_select( |
| 704 | - $select = [], |
|
| 705 | - $from = [], |
|
| 706 | - $from_type = [], |
|
| 707 | - $where = [], |
|
| 708 | - $join = [], |
|
| 709 | - $groupby = [], |
|
| 710 | - $orderby = [], |
|
| 711 | - $limit = '', |
|
| 712 | - $having = [], |
|
| 713 | - $table = '', |
|
| 714 | - $id = '', |
|
| 715 | - $serveur = '', |
|
| 716 | - $requeter = true |
|
| 704 | + $select = [], |
|
| 705 | + $from = [], |
|
| 706 | + $from_type = [], |
|
| 707 | + $where = [], |
|
| 708 | + $join = [], |
|
| 709 | + $groupby = [], |
|
| 710 | + $orderby = [], |
|
| 711 | + $limit = '', |
|
| 712 | + $having = [], |
|
| 713 | + $table = '', |
|
| 714 | + $id = '', |
|
| 715 | + $serveur = '', |
|
| 716 | + $requeter = true |
|
| 717 | 717 | ) { |
| 718 | 718 | |
| 719 | - // retirer les criteres vides: |
|
| 720 | - // {X ?} avec X absent de l'URL |
|
| 721 | - // {par #ENV{X}} avec X absent de l'URL |
|
| 722 | - // IN sur collection vide (ce dernier devrait pouvoir etre fait a la compil) |
|
| 723 | - $menage = false; |
|
| 724 | - foreach ($where as $k => $v) { |
|
| 725 | - if (is_array($v) and count($v)) { |
|
| 726 | - if ((count($v) >= 2) && ($v[0] == 'REGEXP') && ($v[2] == "'.*'")) { |
|
| 727 | - $op = false; |
|
| 728 | - } elseif ((count($v) >= 2) && ($v[0] == 'LIKE') && ($v[2] == "'%'")) { |
|
| 729 | - $op = false; |
|
| 730 | - } else { |
|
| 731 | - $op = $v[0] ?: $v; |
|
| 732 | - } |
|
| 733 | - } else { |
|
| 734 | - $op = $v; |
|
| 735 | - } |
|
| 736 | - if ((!$op) or ($op == 1) or ($op == '0=0')) { |
|
| 737 | - unset($where[$k]); |
|
| 738 | - $menage = true; |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - // evacuer les eventuels groupby vide issus d'un calcul dynamique |
|
| 743 | - $groupby = array_diff($groupby, ['']); |
|
| 744 | - |
|
| 745 | - // remplacer les sous requetes recursives au calcul |
|
| 746 | - [$where_simples, $where_sous] = trouver_sous_requetes($where); |
|
| 747 | - foreach ($where_sous as $k => $w) { |
|
| 748 | - $menage = true; |
|
| 749 | - // on recupere la sous requete |
|
| 750 | - $sous = match_self($w); |
|
| 751 | - if ($sous[0] == 'SELF') { |
|
| 752 | - // c'est une sous requete identique a elle meme sous la forme (SELF,$select,$where) |
|
| 753 | - array_push($where_simples, $sous[2]); |
|
| 754 | - $wheresub = [ |
|
| 755 | - $sous[2], |
|
| 756 | - '0=0' |
|
| 757 | - ]; // pour accepter une string et forcer a faire le menage car on a surement simplifie select et where |
|
| 758 | - $jsub = $join; |
|
| 759 | - // trouver les jointures utiles a |
|
| 760 | - // reinjecter dans le where de la sous requete les conditions supplementaires des jointures qui y sont mentionnees |
|
| 761 | - // ie L1.objet='article' |
|
| 762 | - // on construit le where une fois, puis on ajoute les where complentaires si besoin, et on reconstruit le where en fonction |
|
| 763 | - $i = 0; |
|
| 764 | - do { |
|
| 765 | - $where[$k] = remplace_sous_requete($w, '(' . calculer_select( |
|
| 766 | - [$sous[1] . ' AS id'], |
|
| 767 | - $from, |
|
| 768 | - $from_type, |
|
| 769 | - $wheresub, |
|
| 770 | - $jsub, |
|
| 771 | - [], |
|
| 772 | - [], |
|
| 773 | - '', |
|
| 774 | - $having, |
|
| 775 | - $table, |
|
| 776 | - $id, |
|
| 777 | - $serveur, |
|
| 778 | - false |
|
| 779 | - ) . ')'); |
|
| 780 | - if (!$i) { |
|
| 781 | - $i = 1; |
|
| 782 | - $wherestring = calculer_where_to_string($where[$k]); |
|
| 783 | - foreach ($join as $cle => $wj) { |
|
| 784 | - if ( |
|
| 785 | - (is_countable($wj) ? count($wj) : 0) == 4 |
|
| 786 | - and str_contains($wherestring, (string) "{$cle}.") |
|
| 787 | - ) { |
|
| 788 | - $i = 0; |
|
| 789 | - $wheresub[] = $wj[3]; |
|
| 790 | - unset($jsub[$cle][3]); |
|
| 791 | - } |
|
| 792 | - } |
|
| 793 | - } |
|
| 794 | - } while ($i++ < 1); |
|
| 795 | - } |
|
| 796 | - if ($sous[0] == 'SUBSELECT') { |
|
| 797 | - // c'est une sous requete explicite sous la forme identique a sql_select : (SUBSELECT,$select,$from,$where,$groupby,$orderby,$limit,$having) |
|
| 798 | - array_push($where_simples, $sous[3]); // est-ce utile dans ce cas ? |
|
| 799 | - $where[$k] = remplace_sous_requete($w, '(' . calculer_select( |
|
| 800 | - $sous[1], # select |
|
| 801 | - $sous[2], #from |
|
| 802 | - [], #from_type |
|
| 803 | - $sous[3] ? (is_array($sous[3]) ? $sous[3] : [$sous[3]]) : [], |
|
| 804 | - #where, qui peut etre de la forme string comme dans sql_select |
|
| 805 | - [], #join |
|
| 806 | - $sous[4] ?: [], #groupby |
|
| 807 | - $sous[5] ?: [], #orderby |
|
| 808 | - $sous[6], #limit |
|
| 809 | - $sous[7] ?: [], #having |
|
| 810 | - $table, |
|
| 811 | - $id, |
|
| 812 | - $serveur, |
|
| 813 | - false |
|
| 814 | - ) . ')'); |
|
| 815 | - } |
|
| 816 | - array_pop($where_simples); |
|
| 817 | - } |
|
| 818 | - |
|
| 819 | - foreach ($having as $k => $v) { |
|
| 820 | - if ((!$v) or ($v == 1) or ($v == '0=0')) { |
|
| 821 | - unset($having[$k]); |
|
| 822 | - } |
|
| 823 | - } |
|
| 824 | - |
|
| 825 | - // Installer les jointures. |
|
| 826 | - // Retirer celles seulement utiles aux criteres finalement absents mais |
|
| 827 | - // parcourir de la plus recente a la moins recente pour pouvoir eliminer Ln |
|
| 828 | - // si elle est seulement utile a Ln+1 elle meme inutile |
|
| 829 | - |
|
| 830 | - $afrom = []; |
|
| 831 | - $equiv = []; |
|
| 832 | - $k = count($join); |
|
| 833 | - foreach (array_reverse($join, true) as $cledef => $j) { |
|
| 834 | - $cle = $cledef; |
|
| 835 | - // le format de join est : |
|
| 836 | - // array(table depart, cle depart [,cle arrivee[,condition optionnelle and ...]]) |
|
| 837 | - $join[$cle] = array_values($join[$cle]); // recalculer les cles car des unset ont pu perturber |
|
| 838 | - if (count($join[$cle]) == 2) { |
|
| 839 | - $join[$cle][] = $join[$cle][1]; |
|
| 840 | - } |
|
| 841 | - if ((is_array($join[$cle]) || $join[$cle] instanceof \Countable ? count($join[$cle]) : 0) == 3) { |
|
| 842 | - $join[$cle][] = ''; |
|
| 843 | - } |
|
| 844 | - [$t, $c, $carr, $and] = $join[$cle]; |
|
| 845 | - // si le nom de la jointure n'a pas ete specifiee, on prend Lx avec x sont rang dans la liste |
|
| 846 | - // pour compat avec ancienne convention |
|
| 847 | - if (is_numeric($cle)) { |
|
| 848 | - $cle = "L$k"; |
|
| 849 | - } |
|
| 850 | - $cle_where_lie = "JOIN-$cle"; |
|
| 851 | - if ( |
|
| 852 | - !$menage |
|
| 853 | - or isset($afrom[$cle]) |
|
| 854 | - or calculer_jointnul($cle, $select) |
|
| 855 | - or calculer_jointnul($cle, array_diff_key($join, [$cle => $join[$cle]])) |
|
| 856 | - or calculer_jointnul($cle, $having) |
|
| 857 | - or calculer_jointnul($cle, array_diff_key($where_simples, [$cle_where_lie => ''])) |
|
| 858 | - ) { |
|
| 859 | - // corriger les references non explicites dans select |
|
| 860 | - // ou groupby |
|
| 861 | - foreach ($select as $i => $s) { |
|
| 862 | - if ($s == $c) { |
|
| 863 | - $select[$i] = "$cle.$c AS $c"; |
|
| 864 | - break; |
|
| 865 | - } |
|
| 866 | - } |
|
| 867 | - foreach ($groupby as $i => $g) { |
|
| 868 | - if ($g == $c) { |
|
| 869 | - $groupby[$i] = "$cle.$c"; |
|
| 870 | - break; |
|
| 871 | - } |
|
| 872 | - } |
|
| 873 | - // on garde une ecriture decomposee pour permettre une simplification ulterieure si besoin |
|
| 874 | - // sans recours a preg_match |
|
| 875 | - // un implode(' ',..) est fait dans reinjecte_joint un peu plus bas |
|
| 876 | - $afrom[$t][$cle] = [ |
|
| 877 | - "\n" . |
|
| 878 | - ($from_type[$cle] ?? 'INNER') . ' JOIN', |
|
| 879 | - $from[$cle], |
|
| 880 | - "AS $cle", |
|
| 881 | - 'ON (', |
|
| 882 | - "$cle.$c", |
|
| 883 | - '=', |
|
| 884 | - "$t.$carr", |
|
| 885 | - ($and ? 'AND ' . $and : '') . |
|
| 886 | - ')' |
|
| 887 | - ]; |
|
| 888 | - if (isset($afrom[$cle])) { |
|
| 889 | - $afrom[$t] = $afrom[$t] + $afrom[$cle]; |
|
| 890 | - unset($afrom[$cle]); |
|
| 891 | - } |
|
| 892 | - $equiv[] = $carr; |
|
| 893 | - } else { |
|
| 894 | - unset($join[$cledef]); |
|
| 895 | - if (isset($where_simples[$cle_where_lie])) { |
|
| 896 | - unset($where_simples[$cle_where_lie]); |
|
| 897 | - unset($where[$cle_where_lie]); |
|
| 898 | - } |
|
| 899 | - } |
|
| 900 | - unset($from[$cle]); |
|
| 901 | - $k--; |
|
| 902 | - } |
|
| 903 | - |
|
| 904 | - if (count($afrom)) { |
|
| 905 | - // Regarder si la table principale ne sert finalement a rien comme dans |
|
| 906 | - //<BOUCLE3(MOTS){id_article}{id_mot}> class='on'</BOUCLE3> |
|
| 907 | - //<BOUCLE2(MOTS){id_article} />#TOTAL_BOUCLE<//B2> |
|
| 908 | - //<BOUCLE5(RUBRIQUES){id_mot}{tout} />#TOTAL_BOUCLE<//B5> |
|
| 909 | - // ou dans |
|
| 910 | - //<BOUCLE8(HIERARCHIE){id_rubrique}{tout}{type='Squelette'}{inverse}{0,1}{lang_select=non} />#TOTAL_BOUCLE<//B8> |
|
| 911 | - // qui comporte plusieurs jointures |
|
| 912 | - // ou dans |
|
| 913 | - // <BOUCLE6(ARTICLES){id_mot=2}{statut==.*} />#TOTAL_BOUCLE<//B6> |
|
| 914 | - // <BOUCLE7(ARTICLES){id_mot>0}{statut?} />#TOTAL_BOUCLE<//B7> |
|
| 915 | - // penser a regarder aussi la clause orderby pour ne pas simplifier abusivement |
|
| 916 | - // <BOUCLE9(ARTICLES){recherche truc}{par titre}>#ID_ARTICLE</BOUCLE9> |
|
| 917 | - // penser a regarder aussi la clause groubpy pour ne pas simplifier abusivement |
|
| 918 | - // <BOUCLE10(EVENEMENTS){id_rubrique} />#TOTAL_BOUCLE<//B10> |
|
| 919 | - |
|
| 920 | - $t = key($from); |
|
| 921 | - $c = current($from); |
|
| 922 | - reset($from); |
|
| 923 | - $e = '/\b(' . "$t\\." . join('|' . $t . '\.', $equiv) . ')\b/'; |
|
| 924 | - if ( |
|
| 925 | - !(strpos($t, ' ') or // jointure des le depart cf boucle_doc |
|
| 926 | - calculer_jointnul($t, $select, $e) or |
|
| 927 | - calculer_jointnul($t, $join, $e) or |
|
| 928 | - calculer_jointnul($t, $where, $e) or |
|
| 929 | - calculer_jointnul($t, $orderby, $e) or |
|
| 930 | - calculer_jointnul($t, $groupby, $e) or |
|
| 931 | - calculer_jointnul($t, $having, $e)) |
|
| 932 | - && count($afrom[$t]) |
|
| 933 | - ) { |
|
| 934 | - $nfrom = reset($afrom[$t]); |
|
| 935 | - $nt = array_key_first($afrom[$t]); |
|
| 936 | - unset($from[$t]); |
|
| 937 | - $from[$nt] = $nfrom[1]; |
|
| 938 | - unset($afrom[$t][$nt]); |
|
| 939 | - $afrom[$nt] = $afrom[$t]; |
|
| 940 | - unset($afrom[$t]); |
|
| 941 | - $e = '/\b' . preg_quote($nfrom[6]) . '\b/'; |
|
| 942 | - $t = $nfrom[4]; |
|
| 943 | - $alias = ''; |
|
| 944 | - // verifier que les deux cles sont homonymes, sinon installer un alias dans le select |
|
| 945 | - $oldcle = explode('.', $nfrom[6]); |
|
| 946 | - $oldcle = end($oldcle); |
|
| 947 | - $newcle = explode('.', $nfrom[4]); |
|
| 948 | - $newcle = end($newcle); |
|
| 949 | - if ($newcle != $oldcle) { |
|
| 950 | - // si l'ancienne cle etait deja dans le select avec un AS |
|
| 951 | - // reprendre simplement ce AS |
|
| 952 | - $as = '/\b' . preg_quote($nfrom[6]) . '\s+(AS\s+\w+)\b/'; |
|
| 953 | - if (preg_match($as, implode(',', $select), $m)) { |
|
| 954 | - $alias = ''; |
|
| 955 | - } else { |
|
| 956 | - $alias = ', ' . $nfrom[4] . " AS $oldcle"; |
|
| 957 | - } |
|
| 958 | - } |
|
| 959 | - $select = remplacer_jointnul($t . $alias, $select, $e); |
|
| 960 | - $join = remplacer_jointnul($t, $join, $e); |
|
| 961 | - $where = remplacer_jointnul($t, $where, $e); |
|
| 962 | - $having = remplacer_jointnul($t, $having, $e); |
|
| 963 | - $groupby = remplacer_jointnul($t, $groupby, $e); |
|
| 964 | - $orderby = remplacer_jointnul($t, $orderby, $e); |
|
| 965 | - } |
|
| 966 | - $from = reinjecte_joint($afrom, $from); |
|
| 967 | - } |
|
| 968 | - if (empty($GLOBALS['debug']) or !is_array($GLOBALS['debug'])) { |
|
| 969 | - $wasdebug = empty($GLOBALS['debug']) ? false : $GLOBALS['debug']; |
|
| 970 | - $GLOBALS['debug'] = []; |
|
| 971 | - if ($wasdebug) { |
|
| 972 | - $GLOBALS['debug']['debug'] = true; |
|
| 973 | - } |
|
| 974 | - } |
|
| 975 | - $GLOBALS['debug']['aucasou'] = [$table, $id, $serveur, $requeter]; |
|
| 976 | - $r = sql_select( |
|
| 977 | - $select, |
|
| 978 | - $from, |
|
| 979 | - $where, |
|
| 980 | - $groupby, |
|
| 981 | - array_filter($orderby), |
|
| 982 | - $limit, |
|
| 983 | - $having, |
|
| 984 | - $serveur, |
|
| 985 | - $requeter |
|
| 986 | - ); |
|
| 987 | - unset($GLOBALS['debug']['aucasou']); |
|
| 988 | - |
|
| 989 | - return $r; |
|
| 719 | + // retirer les criteres vides: |
|
| 720 | + // {X ?} avec X absent de l'URL |
|
| 721 | + // {par #ENV{X}} avec X absent de l'URL |
|
| 722 | + // IN sur collection vide (ce dernier devrait pouvoir etre fait a la compil) |
|
| 723 | + $menage = false; |
|
| 724 | + foreach ($where as $k => $v) { |
|
| 725 | + if (is_array($v) and count($v)) { |
|
| 726 | + if ((count($v) >= 2) && ($v[0] == 'REGEXP') && ($v[2] == "'.*'")) { |
|
| 727 | + $op = false; |
|
| 728 | + } elseif ((count($v) >= 2) && ($v[0] == 'LIKE') && ($v[2] == "'%'")) { |
|
| 729 | + $op = false; |
|
| 730 | + } else { |
|
| 731 | + $op = $v[0] ?: $v; |
|
| 732 | + } |
|
| 733 | + } else { |
|
| 734 | + $op = $v; |
|
| 735 | + } |
|
| 736 | + if ((!$op) or ($op == 1) or ($op == '0=0')) { |
|
| 737 | + unset($where[$k]); |
|
| 738 | + $menage = true; |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + // evacuer les eventuels groupby vide issus d'un calcul dynamique |
|
| 743 | + $groupby = array_diff($groupby, ['']); |
|
| 744 | + |
|
| 745 | + // remplacer les sous requetes recursives au calcul |
|
| 746 | + [$where_simples, $where_sous] = trouver_sous_requetes($where); |
|
| 747 | + foreach ($where_sous as $k => $w) { |
|
| 748 | + $menage = true; |
|
| 749 | + // on recupere la sous requete |
|
| 750 | + $sous = match_self($w); |
|
| 751 | + if ($sous[0] == 'SELF') { |
|
| 752 | + // c'est une sous requete identique a elle meme sous la forme (SELF,$select,$where) |
|
| 753 | + array_push($where_simples, $sous[2]); |
|
| 754 | + $wheresub = [ |
|
| 755 | + $sous[2], |
|
| 756 | + '0=0' |
|
| 757 | + ]; // pour accepter une string et forcer a faire le menage car on a surement simplifie select et where |
|
| 758 | + $jsub = $join; |
|
| 759 | + // trouver les jointures utiles a |
|
| 760 | + // reinjecter dans le where de la sous requete les conditions supplementaires des jointures qui y sont mentionnees |
|
| 761 | + // ie L1.objet='article' |
|
| 762 | + // on construit le where une fois, puis on ajoute les where complentaires si besoin, et on reconstruit le where en fonction |
|
| 763 | + $i = 0; |
|
| 764 | + do { |
|
| 765 | + $where[$k] = remplace_sous_requete($w, '(' . calculer_select( |
|
| 766 | + [$sous[1] . ' AS id'], |
|
| 767 | + $from, |
|
| 768 | + $from_type, |
|
| 769 | + $wheresub, |
|
| 770 | + $jsub, |
|
| 771 | + [], |
|
| 772 | + [], |
|
| 773 | + '', |
|
| 774 | + $having, |
|
| 775 | + $table, |
|
| 776 | + $id, |
|
| 777 | + $serveur, |
|
| 778 | + false |
|
| 779 | + ) . ')'); |
|
| 780 | + if (!$i) { |
|
| 781 | + $i = 1; |
|
| 782 | + $wherestring = calculer_where_to_string($where[$k]); |
|
| 783 | + foreach ($join as $cle => $wj) { |
|
| 784 | + if ( |
|
| 785 | + (is_countable($wj) ? count($wj) : 0) == 4 |
|
| 786 | + and str_contains($wherestring, (string) "{$cle}.") |
|
| 787 | + ) { |
|
| 788 | + $i = 0; |
|
| 789 | + $wheresub[] = $wj[3]; |
|
| 790 | + unset($jsub[$cle][3]); |
|
| 791 | + } |
|
| 792 | + } |
|
| 793 | + } |
|
| 794 | + } while ($i++ < 1); |
|
| 795 | + } |
|
| 796 | + if ($sous[0] == 'SUBSELECT') { |
|
| 797 | + // c'est une sous requete explicite sous la forme identique a sql_select : (SUBSELECT,$select,$from,$where,$groupby,$orderby,$limit,$having) |
|
| 798 | + array_push($where_simples, $sous[3]); // est-ce utile dans ce cas ? |
|
| 799 | + $where[$k] = remplace_sous_requete($w, '(' . calculer_select( |
|
| 800 | + $sous[1], # select |
|
| 801 | + $sous[2], #from |
|
| 802 | + [], #from_type |
|
| 803 | + $sous[3] ? (is_array($sous[3]) ? $sous[3] : [$sous[3]]) : [], |
|
| 804 | + #where, qui peut etre de la forme string comme dans sql_select |
|
| 805 | + [], #join |
|
| 806 | + $sous[4] ?: [], #groupby |
|
| 807 | + $sous[5] ?: [], #orderby |
|
| 808 | + $sous[6], #limit |
|
| 809 | + $sous[7] ?: [], #having |
|
| 810 | + $table, |
|
| 811 | + $id, |
|
| 812 | + $serveur, |
|
| 813 | + false |
|
| 814 | + ) . ')'); |
|
| 815 | + } |
|
| 816 | + array_pop($where_simples); |
|
| 817 | + } |
|
| 818 | + |
|
| 819 | + foreach ($having as $k => $v) { |
|
| 820 | + if ((!$v) or ($v == 1) or ($v == '0=0')) { |
|
| 821 | + unset($having[$k]); |
|
| 822 | + } |
|
| 823 | + } |
|
| 824 | + |
|
| 825 | + // Installer les jointures. |
|
| 826 | + // Retirer celles seulement utiles aux criteres finalement absents mais |
|
| 827 | + // parcourir de la plus recente a la moins recente pour pouvoir eliminer Ln |
|
| 828 | + // si elle est seulement utile a Ln+1 elle meme inutile |
|
| 829 | + |
|
| 830 | + $afrom = []; |
|
| 831 | + $equiv = []; |
|
| 832 | + $k = count($join); |
|
| 833 | + foreach (array_reverse($join, true) as $cledef => $j) { |
|
| 834 | + $cle = $cledef; |
|
| 835 | + // le format de join est : |
|
| 836 | + // array(table depart, cle depart [,cle arrivee[,condition optionnelle and ...]]) |
|
| 837 | + $join[$cle] = array_values($join[$cle]); // recalculer les cles car des unset ont pu perturber |
|
| 838 | + if (count($join[$cle]) == 2) { |
|
| 839 | + $join[$cle][] = $join[$cle][1]; |
|
| 840 | + } |
|
| 841 | + if ((is_array($join[$cle]) || $join[$cle] instanceof \Countable ? count($join[$cle]) : 0) == 3) { |
|
| 842 | + $join[$cle][] = ''; |
|
| 843 | + } |
|
| 844 | + [$t, $c, $carr, $and] = $join[$cle]; |
|
| 845 | + // si le nom de la jointure n'a pas ete specifiee, on prend Lx avec x sont rang dans la liste |
|
| 846 | + // pour compat avec ancienne convention |
|
| 847 | + if (is_numeric($cle)) { |
|
| 848 | + $cle = "L$k"; |
|
| 849 | + } |
|
| 850 | + $cle_where_lie = "JOIN-$cle"; |
|
| 851 | + if ( |
|
| 852 | + !$menage |
|
| 853 | + or isset($afrom[$cle]) |
|
| 854 | + or calculer_jointnul($cle, $select) |
|
| 855 | + or calculer_jointnul($cle, array_diff_key($join, [$cle => $join[$cle]])) |
|
| 856 | + or calculer_jointnul($cle, $having) |
|
| 857 | + or calculer_jointnul($cle, array_diff_key($where_simples, [$cle_where_lie => ''])) |
|
| 858 | + ) { |
|
| 859 | + // corriger les references non explicites dans select |
|
| 860 | + // ou groupby |
|
| 861 | + foreach ($select as $i => $s) { |
|
| 862 | + if ($s == $c) { |
|
| 863 | + $select[$i] = "$cle.$c AS $c"; |
|
| 864 | + break; |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + foreach ($groupby as $i => $g) { |
|
| 868 | + if ($g == $c) { |
|
| 869 | + $groupby[$i] = "$cle.$c"; |
|
| 870 | + break; |
|
| 871 | + } |
|
| 872 | + } |
|
| 873 | + // on garde une ecriture decomposee pour permettre une simplification ulterieure si besoin |
|
| 874 | + // sans recours a preg_match |
|
| 875 | + // un implode(' ',..) est fait dans reinjecte_joint un peu plus bas |
|
| 876 | + $afrom[$t][$cle] = [ |
|
| 877 | + "\n" . |
|
| 878 | + ($from_type[$cle] ?? 'INNER') . ' JOIN', |
|
| 879 | + $from[$cle], |
|
| 880 | + "AS $cle", |
|
| 881 | + 'ON (', |
|
| 882 | + "$cle.$c", |
|
| 883 | + '=', |
|
| 884 | + "$t.$carr", |
|
| 885 | + ($and ? 'AND ' . $and : '') . |
|
| 886 | + ')' |
|
| 887 | + ]; |
|
| 888 | + if (isset($afrom[$cle])) { |
|
| 889 | + $afrom[$t] = $afrom[$t] + $afrom[$cle]; |
|
| 890 | + unset($afrom[$cle]); |
|
| 891 | + } |
|
| 892 | + $equiv[] = $carr; |
|
| 893 | + } else { |
|
| 894 | + unset($join[$cledef]); |
|
| 895 | + if (isset($where_simples[$cle_where_lie])) { |
|
| 896 | + unset($where_simples[$cle_where_lie]); |
|
| 897 | + unset($where[$cle_where_lie]); |
|
| 898 | + } |
|
| 899 | + } |
|
| 900 | + unset($from[$cle]); |
|
| 901 | + $k--; |
|
| 902 | + } |
|
| 903 | + |
|
| 904 | + if (count($afrom)) { |
|
| 905 | + // Regarder si la table principale ne sert finalement a rien comme dans |
|
| 906 | + //<BOUCLE3(MOTS){id_article}{id_mot}> class='on'</BOUCLE3> |
|
| 907 | + //<BOUCLE2(MOTS){id_article} />#TOTAL_BOUCLE<//B2> |
|
| 908 | + //<BOUCLE5(RUBRIQUES){id_mot}{tout} />#TOTAL_BOUCLE<//B5> |
|
| 909 | + // ou dans |
|
| 910 | + //<BOUCLE8(HIERARCHIE){id_rubrique}{tout}{type='Squelette'}{inverse}{0,1}{lang_select=non} />#TOTAL_BOUCLE<//B8> |
|
| 911 | + // qui comporte plusieurs jointures |
|
| 912 | + // ou dans |
|
| 913 | + // <BOUCLE6(ARTICLES){id_mot=2}{statut==.*} />#TOTAL_BOUCLE<//B6> |
|
| 914 | + // <BOUCLE7(ARTICLES){id_mot>0}{statut?} />#TOTAL_BOUCLE<//B7> |
|
| 915 | + // penser a regarder aussi la clause orderby pour ne pas simplifier abusivement |
|
| 916 | + // <BOUCLE9(ARTICLES){recherche truc}{par titre}>#ID_ARTICLE</BOUCLE9> |
|
| 917 | + // penser a regarder aussi la clause groubpy pour ne pas simplifier abusivement |
|
| 918 | + // <BOUCLE10(EVENEMENTS){id_rubrique} />#TOTAL_BOUCLE<//B10> |
|
| 919 | + |
|
| 920 | + $t = key($from); |
|
| 921 | + $c = current($from); |
|
| 922 | + reset($from); |
|
| 923 | + $e = '/\b(' . "$t\\." . join('|' . $t . '\.', $equiv) . ')\b/'; |
|
| 924 | + if ( |
|
| 925 | + !(strpos($t, ' ') or // jointure des le depart cf boucle_doc |
|
| 926 | + calculer_jointnul($t, $select, $e) or |
|
| 927 | + calculer_jointnul($t, $join, $e) or |
|
| 928 | + calculer_jointnul($t, $where, $e) or |
|
| 929 | + calculer_jointnul($t, $orderby, $e) or |
|
| 930 | + calculer_jointnul($t, $groupby, $e) or |
|
| 931 | + calculer_jointnul($t, $having, $e)) |
|
| 932 | + && count($afrom[$t]) |
|
| 933 | + ) { |
|
| 934 | + $nfrom = reset($afrom[$t]); |
|
| 935 | + $nt = array_key_first($afrom[$t]); |
|
| 936 | + unset($from[$t]); |
|
| 937 | + $from[$nt] = $nfrom[1]; |
|
| 938 | + unset($afrom[$t][$nt]); |
|
| 939 | + $afrom[$nt] = $afrom[$t]; |
|
| 940 | + unset($afrom[$t]); |
|
| 941 | + $e = '/\b' . preg_quote($nfrom[6]) . '\b/'; |
|
| 942 | + $t = $nfrom[4]; |
|
| 943 | + $alias = ''; |
|
| 944 | + // verifier que les deux cles sont homonymes, sinon installer un alias dans le select |
|
| 945 | + $oldcle = explode('.', $nfrom[6]); |
|
| 946 | + $oldcle = end($oldcle); |
|
| 947 | + $newcle = explode('.', $nfrom[4]); |
|
| 948 | + $newcle = end($newcle); |
|
| 949 | + if ($newcle != $oldcle) { |
|
| 950 | + // si l'ancienne cle etait deja dans le select avec un AS |
|
| 951 | + // reprendre simplement ce AS |
|
| 952 | + $as = '/\b' . preg_quote($nfrom[6]) . '\s+(AS\s+\w+)\b/'; |
|
| 953 | + if (preg_match($as, implode(',', $select), $m)) { |
|
| 954 | + $alias = ''; |
|
| 955 | + } else { |
|
| 956 | + $alias = ', ' . $nfrom[4] . " AS $oldcle"; |
|
| 957 | + } |
|
| 958 | + } |
|
| 959 | + $select = remplacer_jointnul($t . $alias, $select, $e); |
|
| 960 | + $join = remplacer_jointnul($t, $join, $e); |
|
| 961 | + $where = remplacer_jointnul($t, $where, $e); |
|
| 962 | + $having = remplacer_jointnul($t, $having, $e); |
|
| 963 | + $groupby = remplacer_jointnul($t, $groupby, $e); |
|
| 964 | + $orderby = remplacer_jointnul($t, $orderby, $e); |
|
| 965 | + } |
|
| 966 | + $from = reinjecte_joint($afrom, $from); |
|
| 967 | + } |
|
| 968 | + if (empty($GLOBALS['debug']) or !is_array($GLOBALS['debug'])) { |
|
| 969 | + $wasdebug = empty($GLOBALS['debug']) ? false : $GLOBALS['debug']; |
|
| 970 | + $GLOBALS['debug'] = []; |
|
| 971 | + if ($wasdebug) { |
|
| 972 | + $GLOBALS['debug']['debug'] = true; |
|
| 973 | + } |
|
| 974 | + } |
|
| 975 | + $GLOBALS['debug']['aucasou'] = [$table, $id, $serveur, $requeter]; |
|
| 976 | + $r = sql_select( |
|
| 977 | + $select, |
|
| 978 | + $from, |
|
| 979 | + $where, |
|
| 980 | + $groupby, |
|
| 981 | + array_filter($orderby), |
|
| 982 | + $limit, |
|
| 983 | + $having, |
|
| 984 | + $serveur, |
|
| 985 | + $requeter |
|
| 986 | + ); |
|
| 987 | + unset($GLOBALS['debug']['aucasou']); |
|
| 988 | + |
|
| 989 | + return $r; |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | /** |
@@ -997,79 +997,79 @@ discard block |
||
| 997 | 997 | * @return string |
| 998 | 998 | */ |
| 999 | 999 | function calculer_where_to_string($v, $join = 'AND') { |
| 1000 | - if (empty($v)) { |
|
| 1001 | - return ''; |
|
| 1002 | - } |
|
| 1003 | - |
|
| 1004 | - if (!is_array($v)) { |
|
| 1005 | - return $v; |
|
| 1006 | - } else { |
|
| 1007 | - $exp = ''; |
|
| 1008 | - if (strtoupper($join) === 'AND') { |
|
| 1009 | - return $exp . join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 1010 | - } else { |
|
| 1011 | - return $exp . join($join, $v); |
|
| 1012 | - } |
|
| 1013 | - } |
|
| 1000 | + if (empty($v)) { |
|
| 1001 | + return ''; |
|
| 1002 | + } |
|
| 1003 | + |
|
| 1004 | + if (!is_array($v)) { |
|
| 1005 | + return $v; |
|
| 1006 | + } else { |
|
| 1007 | + $exp = ''; |
|
| 1008 | + if (strtoupper($join) === 'AND') { |
|
| 1009 | + return $exp . join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 1010 | + } else { |
|
| 1011 | + return $exp . join($join, $v); |
|
| 1012 | + } |
|
| 1013 | + } |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | |
| 1017 | 1017 | //condition suffisante (mais non necessaire) pour qu'une table soit utile |
| 1018 | 1018 | |
| 1019 | 1019 | function calculer_jointnul($cle, $exp, $equiv = '') { |
| 1020 | - if (!is_array($exp)) { |
|
| 1021 | - if ($equiv) { |
|
| 1022 | - $exp = preg_replace($equiv, '', $exp); |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - return preg_match("/\\b$cle\\./", $exp); |
|
| 1026 | - } else { |
|
| 1027 | - foreach ($exp as $v) { |
|
| 1028 | - if (calculer_jointnul($cle, $v, $equiv)) { |
|
| 1029 | - return true; |
|
| 1030 | - } |
|
| 1031 | - } |
|
| 1032 | - |
|
| 1033 | - return false; |
|
| 1034 | - } |
|
| 1020 | + if (!is_array($exp)) { |
|
| 1021 | + if ($equiv) { |
|
| 1022 | + $exp = preg_replace($equiv, '', $exp); |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + return preg_match("/\\b$cle\\./", $exp); |
|
| 1026 | + } else { |
|
| 1027 | + foreach ($exp as $v) { |
|
| 1028 | + if (calculer_jointnul($cle, $v, $equiv)) { |
|
| 1029 | + return true; |
|
| 1030 | + } |
|
| 1031 | + } |
|
| 1032 | + |
|
| 1033 | + return false; |
|
| 1034 | + } |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | function reinjecte_joint($afrom, $from) { |
| 1038 | - $from_synth = []; |
|
| 1039 | - foreach ($from as $k => $v) { |
|
| 1040 | - $from_synth[$k] = $from[$k]; |
|
| 1041 | - if (isset($afrom[$k])) { |
|
| 1042 | - foreach ($afrom[$k] as $kk => $vv) { |
|
| 1043 | - $afrom[$k][$kk] = implode(' ', $afrom[$k][$kk]); |
|
| 1044 | - } |
|
| 1045 | - $from_synth["$k@"] = implode(' ', $afrom[$k]); |
|
| 1046 | - unset($afrom[$k]); |
|
| 1047 | - } |
|
| 1048 | - } |
|
| 1049 | - |
|
| 1050 | - return $from_synth; |
|
| 1038 | + $from_synth = []; |
|
| 1039 | + foreach ($from as $k => $v) { |
|
| 1040 | + $from_synth[$k] = $from[$k]; |
|
| 1041 | + if (isset($afrom[$k])) { |
|
| 1042 | + foreach ($afrom[$k] as $kk => $vv) { |
|
| 1043 | + $afrom[$k][$kk] = implode(' ', $afrom[$k][$kk]); |
|
| 1044 | + } |
|
| 1045 | + $from_synth["$k@"] = implode(' ', $afrom[$k]); |
|
| 1046 | + unset($afrom[$k]); |
|
| 1047 | + } |
|
| 1048 | + } |
|
| 1049 | + |
|
| 1050 | + return $from_synth; |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | function remplacer_jointnul($cle, $exp, $equiv = '') { |
| 1054 | - if (!is_array($exp)) { |
|
| 1055 | - return preg_replace($equiv, $cle, $exp); |
|
| 1056 | - } else { |
|
| 1057 | - foreach ($exp as $k => $v) { |
|
| 1058 | - $exp[$k] = remplacer_jointnul($cle, $v, $equiv); |
|
| 1059 | - } |
|
| 1060 | - |
|
| 1061 | - return $exp; |
|
| 1062 | - } |
|
| 1054 | + if (!is_array($exp)) { |
|
| 1055 | + return preg_replace($equiv, $cle, $exp); |
|
| 1056 | + } else { |
|
| 1057 | + foreach ($exp as $k => $v) { |
|
| 1058 | + $exp[$k] = remplacer_jointnul($cle, $v, $equiv); |
|
| 1059 | + } |
|
| 1060 | + |
|
| 1061 | + return $exp; |
|
| 1062 | + } |
|
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | // calcul du nom du squelette |
| 1066 | 1066 | function calculer_nom_fonction_squel($skel, $mime_type = 'html', string $connect = '') { |
| 1067 | - // ne pas doublonner les squelette selon qu'ils sont calcules depuis ecrire/ ou depuis la racine |
|
| 1068 | - if ($l = strlen(_DIR_RACINE) and strncmp($skel, _DIR_RACINE, $l) == 0) { |
|
| 1069 | - $skel = substr($skel, strlen(_DIR_RACINE)); |
|
| 1070 | - } |
|
| 1071 | - |
|
| 1072 | - return $mime_type |
|
| 1073 | - . (!$connect ? '' : preg_replace('/\W/', '_', $connect)) . '_' |
|
| 1074 | - . md5($GLOBALS['spip_version_code'] . ' * ' . $skel . (isset($GLOBALS['marqueur_skel']) ? '*' . $GLOBALS['marqueur_skel'] : '')); |
|
| 1067 | + // ne pas doublonner les squelette selon qu'ils sont calcules depuis ecrire/ ou depuis la racine |
|
| 1068 | + if ($l = strlen(_DIR_RACINE) and strncmp($skel, _DIR_RACINE, $l) == 0) { |
|
| 1069 | + $skel = substr($skel, strlen(_DIR_RACINE)); |
|
| 1070 | + } |
|
| 1071 | + |
|
| 1072 | + return $mime_type |
|
| 1073 | + . (!$connect ? '' : preg_replace('/\W/', '_', $connect)) . '_' |
|
| 1074 | + . md5($GLOBALS['spip_version_code'] . ' * ' . $skel . (isset($GLOBALS['marqueur_skel']) ? '*' . $GLOBALS['marqueur_skel'] : '')); |
|
| 1075 | 1075 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $GLOBALS['debug_objets']['courant'] = $nom; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $phpfile = sous_repertoire(_DIR_SKELS, '', false, true) . $nom . '.php'; |
|
| 57 | + $phpfile = sous_repertoire(_DIR_SKELS, '', false, true).$nom.'.php'; |
|
| 58 | 58 | |
| 59 | 59 | // si squelette est deja compile et perenne, le charger |
| 60 | 60 | if (!squelette_obsolete($phpfile, $source)) { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | #} |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if (file_exists($lib = $squelette . '_fonctions' . '.php')) { |
|
| 70 | + if (file_exists($lib = $squelette.'_fonctions'.'.php')) { |
|
| 71 | 71 | include_once $lib; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | eval("return true; $f ;"); |
| 96 | 96 | } catch (\ParseError $e) { |
| 97 | 97 | // Code syntaxiquement faux (critere etc mal programme') |
| 98 | - $msg = _T('zbug_erreur_compilation') . ' | Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 98 | + $msg = _T('zbug_erreur_compilation').' | Line '.$e->getLine().' : '.$e->getMessage(); |
|
| 99 | 99 | erreur_squelette($msg, $boucle); |
| 100 | 100 | // continuer pour trouver d'autres fautes eventuelles |
| 101 | 101 | // mais prevenir que c'est mort |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
| 125 | 125 | // Tracer ce qui vient d'etre compile |
| 126 | - $GLOBALS['debug_objets']['code'][$nom . 'tout'] = $code; |
|
| 126 | + $GLOBALS['debug_objets']['code'][$nom.'tout'] = $code; |
|
| 127 | 127 | |
| 128 | 128 | // si c'est ce que demande le debusqueur, lui passer la main |
| 129 | 129 | if ( |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | $code = " |
| 148 | 148 | /* |
| 149 | 149 | * Squelette : $sourcefile |
| 150 | - * Date : " . gmdate('D, d M Y H:i:s', @filemtime($sourcefile)) . ' GMT |
|
| 151 | - * Compile : ' . gmdate('D, d M Y H:i:s', time()) . ' GMT |
|
| 152 | - * ' . (!$boucles ? 'Pas de boucle' : ('Boucles : ' . $noms)) . ' |
|
| 150 | + * Date : ".gmdate('D, d M Y H:i:s', @filemtime($sourcefile)).' GMT |
|
| 151 | + * Compile : ' . gmdate('D, d M Y H:i:s', time()).' GMT |
|
| 152 | + * ' . (!$boucles ? 'Pas de boucle' : ('Boucles : '.$noms)).' |
|
| 153 | 153 | */ '; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $code = '<' . "?php\n" . $code . join('', $boucles) . "\n"; |
|
| 156 | + $code = '<'."?php\n".$code.join('', $boucles)."\n"; |
|
| 157 | 157 | if (!defined('_VAR_NOCACHE') or !_VAR_NOCACHE) { |
| 158 | 158 | ecrire_fichier($phpfile, $code); |
| 159 | 159 | } |
@@ -215,18 +215,18 @@ discard block |
||
| 215 | 215 | $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); |
| 216 | 216 | |
| 217 | 217 | if ($j == 'X-Spip-Filtre' and isset($headers[$j])) { |
| 218 | - $headers[$j] .= '|' . $r[3]; |
|
| 218 | + $headers[$j] .= '|'.$r[3]; |
|
| 219 | 219 | } else { |
| 220 | - $headers[$j] = str_replace(['\\\\',"\\'",'\\"'], ['\\',"'",'"'], $r[3]); |
|
| 220 | + $headers[$j] = str_replace(['\\\\', "\\'", '\\"'], ['\\', "'", '"'], $r[3]); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | // S'agit-il d'un resultat constant ou contenant du code php |
| 225 | 225 | $process_ins = ( |
| 226 | - strpos($corps, '<' . '?') === false |
|
| 226 | + strpos($corps, '<'.'?') === false |
|
| 227 | 227 | or |
| 228 | - (strpos($corps, '<' . '?xml') !== false and |
|
| 229 | - strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 228 | + (strpos($corps, '<'.'?xml') !== false and |
|
| 229 | + strpos(str_replace('<'.'?xml', '', $corps), '<'.'?') === false) |
|
| 230 | 230 | ) |
| 231 | 231 | ? 'html' |
| 232 | 232 | : 'php'; |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | if ($process_ins == 'html') { |
| 257 | 257 | $skel['process_ins'] = ( |
| 258 | - strpos($corps, '<' . '?') === false |
|
| 258 | + strpos($corps, '<'.'?') === false |
|
| 259 | 259 | or |
| 260 | - (strpos($corps, '<' . '?xml') !== false and |
|
| 261 | - strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 260 | + (strpos($corps, '<'.'?xml') !== false and |
|
| 261 | + strpos(str_replace('<'.'?xml', '', $corps), '<'.'?') === false) |
|
| 262 | 262 | ) |
| 263 | 263 | ? 'html' |
| 264 | 264 | : 'php'; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | // |
| 277 | 277 | |
| 278 | 278 | /** Code PHP pour inclure une balise dynamique à l'exécution d'une page */ |
| 279 | -define('CODE_INCLURE_BALISE', '<' . '?php |
|
| 279 | +define('CODE_INCLURE_BALISE', '<'.'?php |
|
| 280 | 280 | include_once("%s"); |
| 281 | 281 | if ($lang_select = "%s") $lang_select = lang_select($lang_select); |
| 282 | 282 | inserer_balise_dynamique(balise_%s_dyn(%s), array(%s)); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | // pas de lien symbolique sous Windows |
| 308 | 308 | and !(stristr(PHP_OS, 'WIN') and str_contains($file, ':')) |
| 309 | 309 | ) { |
| 310 | - $file = './" . _DIR_RACINE . "' . $file; |
|
| 310 | + $file = './" . _DIR_RACINE . "'.$file; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | $lang = $context_compil[4]; |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | $args = array_map('argumenter_squelette', $args); |
| 319 | 319 | if (!empty($context_compil['appel_php_depuis_modele'])) { |
| 320 | - $args[0] = 'arguments_balise_dyn_depuis_modele(' . $args[0] . ')'; |
|
| 320 | + $args[0] = 'arguments_balise_dyn_depuis_modele('.$args[0].')'; |
|
| 321 | 321 | } |
| 322 | 322 | $args = join(', ', $args); |
| 323 | 323 | |
@@ -351,14 +351,14 @@ discard block |
||
| 351 | 351 | if (is_object($v)) { |
| 352 | 352 | return var_export($v, true); |
| 353 | 353 | } elseif (!is_array($v)) { |
| 354 | - return "'" . texte_script((string) $v) . "'"; |
|
| 354 | + return "'".texte_script((string) $v)."'"; |
|
| 355 | 355 | } else { |
| 356 | 356 | $out = []; |
| 357 | 357 | foreach ($v as $k => $val) { |
| 358 | - $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); |
|
| 358 | + $out [] = argumenter_squelette($k).'=>'.argumenter_squelette($val); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - return 'array(' . join(', ', $out) . ')'; |
|
| 361 | + return 'array('.join(', ', $out).')'; |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | else { |
| 385 | 385 | $str_args = base64_encode(serialize($args)); |
| 386 | - return "<?" . "php \$_zargs=unserialize(base64_decode('$str_args'));echo executer_balise_dynamique(...\$_zargs); ?".">\n"; |
|
| 386 | + return "<?"."php \$_zargs=unserialize(base64_decode('$str_args'));echo executer_balise_dynamique(...\$_zargs); ?".">\n"; |
|
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | 389 | |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | // Y a-t-il une fonction de traitement des arguments ? |
| 464 | - $f = 'balise_' . $nom_balise . '_stat'; |
|
| 464 | + $f = 'balise_'.$nom_balise.'_stat'; |
|
| 465 | 465 | |
| 466 | 466 | $r = !function_exists($f) ? $args : $f($args, $context_compil); |
| 467 | 467 | |
@@ -471,18 +471,18 @@ discard block |
||
| 471 | 471 | |
| 472 | 472 | // verifier que la fonction dyn est la, |
| 473 | 473 | // sinon se replier sur la generique si elle existe |
| 474 | - if (!function_exists('balise_' . $nom_balise . '_dyn')) { |
|
| 474 | + if (!function_exists('balise_'.$nom_balise.'_dyn')) { |
|
| 475 | 475 | if ( |
| 476 | 476 | $balise_generique = chercher_balise_generique($nom) |
| 477 | 477 | and $nom_balise_generique = $balise_generique['nom_generique'] |
| 478 | - and $file = include_spip('balise/' . strtolower($nom_balise_generique)) |
|
| 479 | - and function_exists('balise_' . $nom_balise_generique . '_dyn') |
|
| 478 | + and $file = include_spip('balise/'.strtolower($nom_balise_generique)) |
|
| 479 | + and function_exists('balise_'.$nom_balise_generique.'_dyn') |
|
| 480 | 480 | ) { |
| 481 | 481 | // et lui injecter en premier arg le nom de la balise |
| 482 | 482 | array_unshift($r, $nom); |
| 483 | 483 | $nom_balise = $nom_balise_generique; |
| 484 | 484 | if (!_DIR_RESTREINT) { |
| 485 | - $file = _DIR_RESTREINT_ABS . $file; |
|
| 485 | + $file = _DIR_RESTREINT_ABS.$file; |
|
| 486 | 486 | } |
| 487 | 487 | } else { |
| 488 | 488 | $msg = ['zbug_balise_inexistante', ['from' => 'CVT', 'balise' => $nom]]; |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | $n = ''; |
| 584 | 584 | foreach (explode(',', $liste) as $val) { |
| 585 | 585 | if ($a = intval($val) and $val === strval($a)) { |
| 586 | - $n .= ',' . $val; |
|
| 586 | + $n .= ','.$val; |
|
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | if (strlen($n)) { |
@@ -762,8 +762,8 @@ discard block |
||
| 762 | 762 | // on construit le where une fois, puis on ajoute les where complentaires si besoin, et on reconstruit le where en fonction |
| 763 | 763 | $i = 0; |
| 764 | 764 | do { |
| 765 | - $where[$k] = remplace_sous_requete($w, '(' . calculer_select( |
|
| 766 | - [$sous[1] . ' AS id'], |
|
| 765 | + $where[$k] = remplace_sous_requete($w, '('.calculer_select( |
|
| 766 | + [$sous[1].' AS id'], |
|
| 767 | 767 | $from, |
| 768 | 768 | $from_type, |
| 769 | 769 | $wheresub, |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | $id, |
| 777 | 777 | $serveur, |
| 778 | 778 | false |
| 779 | - ) . ')'); |
|
| 779 | + ).')'); |
|
| 780 | 780 | if (!$i) { |
| 781 | 781 | $i = 1; |
| 782 | 782 | $wherestring = calculer_where_to_string($where[$k]); |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | if ($sous[0] == 'SUBSELECT') { |
| 797 | 797 | // c'est une sous requete explicite sous la forme identique a sql_select : (SUBSELECT,$select,$from,$where,$groupby,$orderby,$limit,$having) |
| 798 | 798 | array_push($where_simples, $sous[3]); // est-ce utile dans ce cas ? |
| 799 | - $where[$k] = remplace_sous_requete($w, '(' . calculer_select( |
|
| 799 | + $where[$k] = remplace_sous_requete($w, '('.calculer_select( |
|
| 800 | 800 | $sous[1], # select |
| 801 | 801 | $sous[2], #from |
| 802 | 802 | [], #from_type |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | $id, |
| 812 | 812 | $serveur, |
| 813 | 813 | false |
| 814 | - ) . ')'); |
|
| 814 | + ).')'); |
|
| 815 | 815 | } |
| 816 | 816 | array_pop($where_simples); |
| 817 | 817 | } |
@@ -874,15 +874,15 @@ discard block |
||
| 874 | 874 | // sans recours a preg_match |
| 875 | 875 | // un implode(' ',..) est fait dans reinjecte_joint un peu plus bas |
| 876 | 876 | $afrom[$t][$cle] = [ |
| 877 | - "\n" . |
|
| 878 | - ($from_type[$cle] ?? 'INNER') . ' JOIN', |
|
| 877 | + "\n". |
|
| 878 | + ($from_type[$cle] ?? 'INNER').' JOIN', |
|
| 879 | 879 | $from[$cle], |
| 880 | 880 | "AS $cle", |
| 881 | 881 | 'ON (', |
| 882 | 882 | "$cle.$c", |
| 883 | 883 | '=', |
| 884 | 884 | "$t.$carr", |
| 885 | - ($and ? 'AND ' . $and : '') . |
|
| 885 | + ($and ? 'AND '.$and : ''). |
|
| 886 | 886 | ')' |
| 887 | 887 | ]; |
| 888 | 888 | if (isset($afrom[$cle])) { |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | $t = key($from); |
| 921 | 921 | $c = current($from); |
| 922 | 922 | reset($from); |
| 923 | - $e = '/\b(' . "$t\\." . join('|' . $t . '\.', $equiv) . ')\b/'; |
|
| 923 | + $e = '/\b('."$t\\.".join('|'.$t.'\.', $equiv).')\b/'; |
|
| 924 | 924 | if ( |
| 925 | 925 | !(strpos($t, ' ') or // jointure des le depart cf boucle_doc |
| 926 | 926 | calculer_jointnul($t, $select, $e) or |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | unset($afrom[$t][$nt]); |
| 939 | 939 | $afrom[$nt] = $afrom[$t]; |
| 940 | 940 | unset($afrom[$t]); |
| 941 | - $e = '/\b' . preg_quote($nfrom[6]) . '\b/'; |
|
| 941 | + $e = '/\b'.preg_quote($nfrom[6]).'\b/'; |
|
| 942 | 942 | $t = $nfrom[4]; |
| 943 | 943 | $alias = ''; |
| 944 | 944 | // verifier que les deux cles sont homonymes, sinon installer un alias dans le select |
@@ -949,14 +949,14 @@ discard block |
||
| 949 | 949 | if ($newcle != $oldcle) { |
| 950 | 950 | // si l'ancienne cle etait deja dans le select avec un AS |
| 951 | 951 | // reprendre simplement ce AS |
| 952 | - $as = '/\b' . preg_quote($nfrom[6]) . '\s+(AS\s+\w+)\b/'; |
|
| 952 | + $as = '/\b'.preg_quote($nfrom[6]).'\s+(AS\s+\w+)\b/'; |
|
| 953 | 953 | if (preg_match($as, implode(',', $select), $m)) { |
| 954 | 954 | $alias = ''; |
| 955 | 955 | } else { |
| 956 | - $alias = ', ' . $nfrom[4] . " AS $oldcle"; |
|
| 956 | + $alias = ', '.$nfrom[4]." AS $oldcle"; |
|
| 957 | 957 | } |
| 958 | 958 | } |
| 959 | - $select = remplacer_jointnul($t . $alias, $select, $e); |
|
| 959 | + $select = remplacer_jointnul($t.$alias, $select, $e); |
|
| 960 | 960 | $join = remplacer_jointnul($t, $join, $e); |
| 961 | 961 | $where = remplacer_jointnul($t, $where, $e); |
| 962 | 962 | $having = remplacer_jointnul($t, $having, $e); |
@@ -1006,9 +1006,9 @@ discard block |
||
| 1006 | 1006 | } else { |
| 1007 | 1007 | $exp = ''; |
| 1008 | 1008 | if (strtoupper($join) === 'AND') { |
| 1009 | - return $exp . join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 1009 | + return $exp.join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 1010 | 1010 | } else { |
| 1011 | - return $exp . join($join, $v); |
|
| 1011 | + return $exp.join($join, $v); |
|
| 1012 | 1012 | } |
| 1013 | 1013 | } |
| 1014 | 1014 | } |
@@ -1070,6 +1070,6 @@ discard block |
||
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | return $mime_type |
| 1073 | - . (!$connect ? '' : preg_replace('/\W/', '_', $connect)) . '_' |
|
| 1074 | - . md5($GLOBALS['spip_version_code'] . ' * ' . $skel . (isset($GLOBALS['marqueur_skel']) ? '*' . $GLOBALS['marqueur_skel'] : '')); |
|
| 1073 | + . (!$connect ? '' : preg_replace('/\W/', '_', $connect)).'_' |
|
| 1074 | + . md5($GLOBALS['spip_version_code'].' * '.$skel.(isset($GLOBALS['marqueur_skel']) ? '*'.$GLOBALS['marqueur_skel'] : '')); |
|
| 1075 | 1075 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | if (!$fonc) { |
| 148 | 148 | $fonc = $GLOBALS['debug_objets']['principal']; |
| 149 | 149 | } |
| 150 | - $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 150 | + $titre = !$mode ? $fonc : ($mode.(isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' '.$GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 151 | 151 | } |
| 152 | 152 | if ($message === false) { |
| 153 | 153 | lang_select(); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $fond = $GLOBALS['fond'] ?? ''; |
| 177 | 177 | // une erreur critique sort $message en array |
| 178 | 178 | $debug = is_array($msg) ? $msg[1] : $msg; |
| 179 | - spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 179 | + spip_log('Debug: '.$debug.' ('.$fond.')'); |
|
| 180 | 180 | |
| 181 | 181 | return $msg; |
| 182 | 182 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | function debusquer_bandeau($erreurs) { |
| 185 | 185 | |
| 186 | 186 | if (!empty($erreurs)) { |
| 187 | - $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 187 | + $n = [(is_countable($erreurs) ? count($erreurs) : 0).' '._T('zbug_erreur_squelette')]; |
|
| 188 | 188 | |
| 189 | 189 | return debusquer_navigation($erreurs, $n); |
| 190 | 190 | } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
@@ -217,25 +217,25 @@ discard block |
||
| 217 | 217 | $valeur_simple = []; |
| 218 | 218 | foreach ($valeur as $v) { |
| 219 | 219 | if (is_array($v)) { |
| 220 | - $valeur_simple[] = 'array:' . count($v); |
|
| 220 | + $valeur_simple[] = 'array:'.count($v); |
|
| 221 | 221 | } elseif (is_object($v)) { |
| 222 | 222 | $valeur_simple[] = get_class($v); |
| 223 | 223 | } elseif (is_string($v)) { |
| 224 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 224 | + $valeur_simple[] = "'".$v."'"; |
|
| 225 | 225 | } else { |
| 226 | 226 | $valeur_simple[] = $v; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | $n = count($valeur); |
| 230 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 231 | - $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 230 | + $valeur = (($n > 3) ? 'array:'.$n.' ' : ''); |
|
| 231 | + $valeur .= '['.join(', ', $valeur_simple).']'; |
|
| 232 | 232 | } elseif (is_object($valeur)) { |
| 233 | 233 | $valeur = get_class($valeur); |
| 234 | 234 | } elseif (is_string($valeur)) { |
| 235 | - $valeur = "'" . $valeur . "'"; |
|
| 235 | + $valeur = "'".$valeur."'"; |
|
| 236 | 236 | } |
| 237 | - $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 238 | - . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 237 | + $res .= "\n<tr><td><strong>".nl2br((string) entites_html($nom)) |
|
| 238 | + . '</strong></td><td>: '.nl2br((string) entites_html($valeur)) |
|
| 239 | 239 | . "</td></tr>\n"; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | if ($ligne) { |
| 261 | 261 | $msg .= " L$ligne"; |
| 262 | 262 | } |
| 263 | - spip_log($msg, "debusquer" . _LOG_ERREUR); |
|
| 263 | + spip_log($msg, "debusquer"._LOG_ERREUR); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | $nom_code = $lieu->descr['nom']; |
| 286 | 286 | $skel = $lieu->descr['sourcefile']; |
| 287 | 287 | $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
| 288 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 288 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette').'#L'.$ligne; |
|
| 289 | 289 | $skel = "<a href='$h3'><b>$skel</b></a>"; |
| 290 | 290 | if ($boucle) { |
| 291 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 291 | + $h3 = parametre_url($h2.$boucle, 'var_mode_affiche', 'boucle'); |
|
| 292 | 292 | $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
| 293 | 293 | } |
| 294 | 294 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Requete erronee |
| 380 | - $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 380 | + $err = '<b>'._T('avis_erreur_mysql')." $errno</b><br /><tt>\n" |
|
| 381 | 381 | . spip_htmlspecialchars($msg) |
| 382 | 382 | . "\n<br /><span style='color: red'><b>" |
| 383 | 383 | . spip_htmlspecialchars($query) |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') { |
| 393 | 393 | |
| 394 | - $id = $nom . $boucle; |
|
| 394 | + $id = $nom.$boucle; |
|
| 395 | 395 | if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
| 396 | 396 | foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
| 397 | 397 | if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 440 | + $incl = ','.$reg[1].'[.]\w$,'; |
|
| 441 | 441 | |
| 442 | 442 | foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
| 443 | 443 | if (preg_match($incl, $v)) { |
@@ -452,16 +452,13 @@ discard block |
||
| 452 | 452 | [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
| 453 | 453 | |
| 454 | 454 | if (!$boucle) { |
| 455 | - return !$ligne ? '' : |
|
| 456 | - (' (' . |
|
| 457 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 458 | - _T('squelette_ligne')) . |
|
| 455 | + return !$ligne ? '' : (' ('. |
|
| 456 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')). |
|
| 459 | 457 | " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
| 460 | 458 | } else { |
| 461 | 459 | $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
| 462 | 460 | |
| 463 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 464 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 461 | + return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 465 | 462 | } |
| 466 | 463 | } |
| 467 | 464 | |
@@ -483,14 +480,14 @@ discard block |
||
| 483 | 480 | |
| 484 | 481 | $s = preg_replace( |
| 485 | 482 | ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
| 486 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 483 | + '<\1>\2</\1><br />'."\n".'<\1>\3</\1>', |
|
| 487 | 484 | $s |
| 488 | 485 | ); |
| 489 | 486 | |
| 490 | 487 | |
| 491 | 488 | $tableau = explode('<br />', $s); |
| 492 | 489 | |
| 493 | - $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" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n"; |
|
| 490 | + $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".strval(@strlen(count($tableau)))."d</a></span> %s<br />\n"; |
|
| 494 | 491 | |
| 495 | 492 | $format10 = str_replace('white', 'lightgrey', $format); |
| 496 | 493 | $formaterr = 'color: red;'; |
@@ -534,7 +531,7 @@ discard block |
||
| 534 | 531 | . '" style="cursor: pointer;">' |
| 535 | 532 | . ($nocpt ? '' : _T('info_numero_abbreviation')) |
| 536 | 533 | . '</div> |
| 537 | - ' . $res . "</div>\n"; |
|
| 534 | + ' . $res."</div>\n"; |
|
| 538 | 535 | } |
| 539 | 536 | |
| 540 | 537 | // l'environnement graphique du debuggueur |
@@ -556,14 +553,14 @@ discard block |
||
| 556 | 553 | if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
| 557 | 554 | [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
| 558 | 555 | $texte .= $res2; |
| 559 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 560 | - $legend = _T('zbug_' . $mode); |
|
| 561 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 556 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc.'tout'])) { |
|
| 557 | + $legend = _T('zbug_'.$mode); |
|
| 558 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc.'tout']; |
|
| 562 | 559 | $texte = ancre_texte($texte, ['', '']); |
| 563 | 560 | } |
| 564 | 561 | } else { |
| 565 | 562 | if (strlen(trim($res))) { |
| 566 | - 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>"; |
|
| 563 | + 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>"; |
|
| 567 | 564 | } else { |
| 568 | 565 | // cas de l'appel sur erreur: montre la page |
| 569 | 566 | return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
@@ -571,7 +568,7 @@ discard block |
||
| 571 | 568 | } |
| 572 | 569 | } else { |
| 573 | 570 | $valider = charger_fonction('valider', 'xml'); |
| 574 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 571 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc.'tout']); |
|
| 575 | 572 | // Si erreur, signaler leur nombre dans le formulaire admin |
| 576 | 573 | $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
| 577 | 574 | [$texte, $err] = emboite_texte($val, $fonc, $self); |
@@ -582,14 +579,14 @@ discard block |
||
| 582 | 579 | } else { |
| 583 | 580 | $err = ": $err"; |
| 584 | 581 | } |
| 585 | - $legend = _T('validation') . ' ' . $err; |
|
| 582 | + $legend = _T('validation').' '.$err; |
|
| 586 | 583 | $res = $id = ''; |
| 587 | 584 | } |
| 588 | 585 | |
| 589 | 586 | return !trim($texte) ? '' : ( |
| 590 | - "<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" |
|
| 587 | + "<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" |
|
| 591 | 588 | . "<div id='debug_boucle'><fieldset$id><legend>" |
| 592 | - . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 589 | + . "<a href='".$self.'#f_'.substr($fonc, 0, 37)."'> ↑ " |
|
| 593 | 590 | . ($legend ?: $mode) |
| 594 | 591 | . '</a></legend>' |
| 595 | 592 | . $texte |
@@ -600,7 +597,7 @@ discard block |
||
| 600 | 597 | |
| 601 | 598 | function emboite_texte($res, $fonc = '', $self = '') { |
| 602 | 599 | $errs = $res->err; |
| 603 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 600 | + $texte = $res->entete.($errs ? '' : $res->page); |
|
| 604 | 601 | |
| 605 | 602 | if (!$texte and !$errs) { |
| 606 | 603 | return [ancre_texte('', ['', '']), false]; |
@@ -656,7 +653,7 @@ discard block |
||
| 656 | 653 | $err = "<h2 style='text-align: center'>" |
| 657 | 654 | . $i |
| 658 | 655 | . "<a href='#fin_err'>" |
| 659 | - . ' ' . _T('erreur_texte') |
|
| 656 | + . ' '._T('erreur_texte') |
|
| 660 | 657 | . "</a></h2><table id='debut_err' style='width: 100%'>" |
| 661 | 658 | . $err |
| 662 | 659 | . " </table><a id='fin_err'></a>"; |
@@ -666,9 +663,9 @@ discard block |
||
| 666 | 663 | [$msg, $fermant, $ouvrant] = $errs[0]; |
| 667 | 664 | $rf = reference_boucle_debug($fermant, $fonc, $self); |
| 668 | 665 | $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
| 669 | - $err = $msg . |
|
| 670 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 671 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 666 | + $err = $msg. |
|
| 667 | + "<a href='#L".$fermant."'>$fermant</a>$rf<br />". |
|
| 668 | + "<a href='#L".$ouvrant."'>$ouvrant</a>$ro"; |
|
| 672 | 669 | |
| 673 | 670 | return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
| 674 | 671 | } |
@@ -701,7 +698,7 @@ discard block |
||
| 701 | 698 | ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
| 702 | 699 | ); |
| 703 | 700 | |
| 704 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 701 | + $res .= "<fieldset id='f_".$nom."'><legend>" |
|
| 705 | 702 | . $t_skel |
| 706 | 703 | . ' ' |
| 707 | 704 | . $sourcefile |
@@ -716,7 +713,7 @@ discard block |
||
| 716 | 713 | . "'>" |
| 717 | 714 | . _T('zbug_calcul') |
| 718 | 715 | . '</a></legend>' |
| 719 | - . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 716 | + . (!$temps ? '' : ("\n<span style='display:block;float:".$GLOBALS['spip_lang_right']."'>$temps</span><br />")) |
|
| 720 | 717 | . debusquer_contexte($contexte[$sourcefile]) |
| 721 | 718 | . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
| 722 | 719 | . "</fieldset>\n"; |
@@ -737,33 +734,33 @@ discard block |
||
| 737 | 734 | $nom = $boucle->id_boucle; |
| 738 | 735 | $req = $boucle->type_requete; |
| 739 | 736 | $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
| 740 | - $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 741 | - |
|
| 742 | - $res .= "\n<tr style='background-color: " . |
|
| 743 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 744 | - "'><td align='right'>$i</td><td>\n" . |
|
| 745 | - "<a class='debug_link_boucle' href='" . |
|
| 746 | - $self2 . |
|
| 747 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 748 | - _T('zbug_boucle') . |
|
| 749 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 750 | - $self2 . |
|
| 751 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 752 | - _T('zbug_resultat') . |
|
| 753 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 754 | - $self2 . |
|
| 755 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 756 | - _T('zbug_code') . |
|
| 757 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 758 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 759 | - "'>" . |
|
| 760 | - _T('zbug_calcul') . |
|
| 761 | - "</a></td><td>\n" . |
|
| 762 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 763 | - "</td><td>\n" . |
|
| 764 | - $req . |
|
| 765 | - "</td><td>\n" . |
|
| 766 | - spip_htmlspecialchars($crit) . |
|
| 737 | + $self2 = $self.'&var_mode_objet='.$objet; |
|
| 738 | + |
|
| 739 | + $res .= "\n<tr style='background-color: ". |
|
| 740 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff'). |
|
| 741 | + "'><td align='right'>$i</td><td>\n". |
|
| 742 | + "<a class='debug_link_boucle' href='". |
|
| 743 | + $self2. |
|
| 744 | + "&var_mode_affiche=boucle#f_$nom_skel'>". |
|
| 745 | + _T('zbug_boucle'). |
|
| 746 | + "</a></td><td>\n<a class='debug_link_boucle' href='". |
|
| 747 | + $self2. |
|
| 748 | + "&var_mode_affiche=resultat#f_$nom_skel'>". |
|
| 749 | + _T('zbug_resultat'). |
|
| 750 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 751 | + $self2. |
|
| 752 | + "&var_mode_affiche=code#f_$nom_skel'>". |
|
| 753 | + _T('zbug_code'). |
|
| 754 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 755 | + str_replace('var_mode=', 'var_profile=', $self2). |
|
| 756 | + "'>". |
|
| 757 | + _T('zbug_calcul'). |
|
| 758 | + "</a></td><td>\n". |
|
| 759 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom). |
|
| 760 | + "</td><td>\n". |
|
| 761 | + $req. |
|
| 762 | + "</td><td>\n". |
|
| 763 | + spip_htmlspecialchars($crit). |
|
| 767 | 764 | '</td></tr>'; |
| 768 | 765 | } |
| 769 | 766 | } |
@@ -790,7 +787,7 @@ discard block |
||
| 790 | 787 | } |
| 791 | 788 | // permettre le copier/coller facile |
| 792 | 789 | // $res = ancre_texte($req, array(), true); |
| 793 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 790 | + $res = "<div id='T".md5($req)."'>\n<pre>\n".$req."</pre>\n</div>\n"; |
|
| 794 | 791 | // formatage et affichage des resultats bruts de la requete |
| 795 | 792 | $ress_req = spip_query($req); |
| 796 | 793 | $brut_sql = ''; |
@@ -800,10 +797,10 @@ discard block |
||
| 800 | 797 | $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
| 801 | 798 | while ($retours_sql = sql_fetch($ress_req)) { |
| 802 | 799 | if ($num <= $max_aff) { |
| 803 | - $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 800 | + $brut_sql .= '<h3>'.($num == 1 ? $num.' sur '.sql_count($ress_req) : $num).'</h3>'; |
|
| 804 | 801 | $brut_sql .= '<p>'; |
| 805 | 802 | foreach ($retours_sql as $key => $val) { |
| 806 | - $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 803 | + $brut_sql .= '<strong>'.$key.'</strong> => '.spip_htmlspecialchars(couper($val, 150))."<br />\n"; |
|
| 807 | 804 | } |
| 808 | 805 | $brut_sql .= '</p>'; |
| 809 | 806 | } |
@@ -814,14 +811,14 @@ discard block |
||
| 814 | 811 | // ne pas afficher les $contexte_inclus |
| 815 | 812 | $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
| 816 | 813 | if ($view) { |
| 817 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 814 | + $res2 .= "\n<br /><fieldset>".interdire_scripts($view).'</fieldset>'; |
|
| 818 | 815 | } |
| 819 | 816 | } |
| 820 | 817 | } elseif ($affiche == 'code') { |
| 821 | 818 | $legend = $nom; |
| 822 | - $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 819 | + $res = ancre_texte('<'."?php\n".$quoi."\n?".'>'); |
|
| 823 | 820 | } elseif ($affiche == 'boucle') { |
| 824 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 821 | + $legend = _T('zbug_boucle').' '.$nom; |
|
| 825 | 822 | // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
| 826 | 823 | $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
| 827 | 824 | $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
@@ -839,23 +836,23 @@ discard block |
||
| 839 | 836 | include_spip('public/assembler'); // pour inclure_balise_dynamique |
| 840 | 837 | include_spip('inc/texte'); // pour corriger_typo |
| 841 | 838 | |
| 842 | - return _DOCTYPE_ECRIRE . |
|
| 843 | - html_lang_attributes() . |
|
| 844 | - "<head>\n<title>" . |
|
| 845 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 846 | - _T('admin_debug') . ' ' . spip_htmlspecialchars($titre) . ' (' . |
|
| 847 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 848 | - ")</title>\n" . |
|
| 849 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 850 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 851 | - "' />\n" . |
|
| 839 | + return _DOCTYPE_ECRIRE. |
|
| 840 | + html_lang_attributes(). |
|
| 841 | + "<head>\n<title>". |
|
| 842 | + ('SPIP '.$GLOBALS['spip_version_affichee'].' '. |
|
| 843 | + _T('admin_debug').' '.spip_htmlspecialchars($titre).' ('. |
|
| 844 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))). |
|
| 845 | + ")</title>\n". |
|
| 846 | + "<meta http-equiv='Content-Type' content='text/html". |
|
| 847 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : ''). |
|
| 848 | + "' />\n". |
|
| 852 | 849 | http_script('', 'jquery.js') |
| 853 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 854 | - . "' type='text/css' />" . |
|
| 855 | - "</head>\n" . |
|
| 856 | - "<body style='margin:0 10px;'>\n" . |
|
| 857 | - "<div id='spip-debug-header'>" . |
|
| 858 | - $corps . |
|
| 859 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 850 | + . "<link rel='stylesheet' href='".url_absolue(find_in_path('spip_admin.css')) |
|
| 851 | + . "' type='text/css' />". |
|
| 852 | + "</head>\n". |
|
| 853 | + "<body style='margin:0 10px;'>\n". |
|
| 854 | + "<div id='spip-debug-header'>". |
|
| 855 | + $corps. |
|
| 856 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false). |
|
| 860 | 857 | '</div></body></html>'; |
| 861 | 858 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('public/decompiler'); |
@@ -68,133 +68,133 @@ discard block |
||
| 68 | 68 | * - true si $opt 'erreurs' = 'reset' |
| 69 | 69 | **/ |
| 70 | 70 | function public_debusquer_dist($message = '', $lieu = '', $opt = []) { |
| 71 | - static $should_log; |
|
| 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 | - if (is_null($should_log)) { |
|
| 87 | - $should_log = (empty($GLOBALS['visiteur_session']) || !include_spip('inc/autoriser') || !autoriser('debug')); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - // Erreur ou appel final ? |
|
| 91 | - if ($message) { |
|
| 92 | - $message = debusquer_compose_message($message); |
|
| 93 | - $tableau_des_erreurs[] = [$message, $lieu]; |
|
| 94 | - set_request('var_mode', 'debug'); |
|
| 95 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 96 | - // Permettre a la compil de continuer |
|
| 97 | - if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) { |
|
| 98 | - $lieu->code = "''"; |
|
| 99 | - } |
|
| 100 | - // loger si personne ne verra l'erreur |
|
| 101 | - if ($should_log) { |
|
| 102 | - debusquer_loger_erreur($message, $lieu); |
|
| 103 | - } |
|
| 104 | - // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 105 | - $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 106 | - if (!$urgence) { |
|
| 107 | - return; |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - if (empty($GLOBALS['debug_objets']['principal'])) { |
|
| 111 | - // espace public ? |
|
| 112 | - if (isset($GLOBALS['fond'])) { |
|
| 113 | - $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - include_spip('inc/autoriser'); |
|
| 118 | - if (!autoriser('debug')) { |
|
| 119 | - return; |
|
| 120 | - } |
|
| 121 | - include_spip('inc/headers'); |
|
| 122 | - include_spip('inc/filtres'); |
|
| 123 | - |
|
| 124 | - lang_select($GLOBALS['visiteur_session']['lang'] ?? null); |
|
| 125 | - $fonc = preg_replace(',\W,', '_', _request('var_mode_objet') ?? ''); |
|
| 126 | - $mode = preg_replace(',\W,', '_', _request('var_mode_affiche') ?? ''); |
|
| 127 | - |
|
| 128 | - $self = str_replace("\\'", ''', self()); |
|
| 129 | - $self = parametre_url($self, 'var_mode', 'debug'); |
|
| 130 | - |
|
| 131 | - $res = debusquer_bandeau($tableau_des_erreurs) |
|
| 132 | - . '<br />' |
|
| 133 | - . debusquer_squelette($fonc, $mode, $self); |
|
| 134 | - |
|
| 135 | - if (!_DIR_RESTREINT or headers_sent()) { |
|
| 136 | - return $res; |
|
| 137 | - } |
|
| 138 | - if ($tableau_des_erreurs) { |
|
| 139 | - http_response_code(503); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - http_no_cache(); |
|
| 143 | - if (isset($_GET['var_profile'])) { |
|
| 144 | - $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
|
| 145 | - $titre = parametre_url($titre, 'var_mode', ''); |
|
| 146 | - } else { |
|
| 147 | - if (!$fonc) { |
|
| 148 | - $fonc = $GLOBALS['debug_objets']['principal']; |
|
| 149 | - } |
|
| 150 | - $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 151 | - } |
|
| 152 | - if ($message === false) { |
|
| 153 | - lang_select(); |
|
| 154 | - |
|
| 155 | - return debusquer_entete($titre, $res); |
|
| 156 | - } else { |
|
| 157 | - echo debusquer_entete($titre, $res); |
|
| 158 | - } |
|
| 159 | - exit; |
|
| 71 | + static $should_log; |
|
| 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 | + if (is_null($should_log)) { |
|
| 87 | + $should_log = (empty($GLOBALS['visiteur_session']) || !include_spip('inc/autoriser') || !autoriser('debug')); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + // Erreur ou appel final ? |
|
| 91 | + if ($message) { |
|
| 92 | + $message = debusquer_compose_message($message); |
|
| 93 | + $tableau_des_erreurs[] = [$message, $lieu]; |
|
| 94 | + set_request('var_mode', 'debug'); |
|
| 95 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 96 | + // Permettre a la compil de continuer |
|
| 97 | + if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) { |
|
| 98 | + $lieu->code = "''"; |
|
| 99 | + } |
|
| 100 | + // loger si personne ne verra l'erreur |
|
| 101 | + if ($should_log) { |
|
| 102 | + debusquer_loger_erreur($message, $lieu); |
|
| 103 | + } |
|
| 104 | + // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 105 | + $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 106 | + if (!$urgence) { |
|
| 107 | + return; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + if (empty($GLOBALS['debug_objets']['principal'])) { |
|
| 111 | + // espace public ? |
|
| 112 | + if (isset($GLOBALS['fond'])) { |
|
| 113 | + $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + include_spip('inc/autoriser'); |
|
| 118 | + if (!autoriser('debug')) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 121 | + include_spip('inc/headers'); |
|
| 122 | + include_spip('inc/filtres'); |
|
| 123 | + |
|
| 124 | + lang_select($GLOBALS['visiteur_session']['lang'] ?? null); |
|
| 125 | + $fonc = preg_replace(',\W,', '_', _request('var_mode_objet') ?? ''); |
|
| 126 | + $mode = preg_replace(',\W,', '_', _request('var_mode_affiche') ?? ''); |
|
| 127 | + |
|
| 128 | + $self = str_replace("\\'", ''', self()); |
|
| 129 | + $self = parametre_url($self, 'var_mode', 'debug'); |
|
| 130 | + |
|
| 131 | + $res = debusquer_bandeau($tableau_des_erreurs) |
|
| 132 | + . '<br />' |
|
| 133 | + . debusquer_squelette($fonc, $mode, $self); |
|
| 134 | + |
|
| 135 | + if (!_DIR_RESTREINT or headers_sent()) { |
|
| 136 | + return $res; |
|
| 137 | + } |
|
| 138 | + if ($tableau_des_erreurs) { |
|
| 139 | + http_response_code(503); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + http_no_cache(); |
|
| 143 | + if (isset($_GET['var_profile'])) { |
|
| 144 | + $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
|
| 145 | + $titre = parametre_url($titre, 'var_mode', ''); |
|
| 146 | + } else { |
|
| 147 | + if (!$fonc) { |
|
| 148 | + $fonc = $GLOBALS['debug_objets']['principal']; |
|
| 149 | + } |
|
| 150 | + $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 151 | + } |
|
| 152 | + if ($message === false) { |
|
| 153 | + lang_select(); |
|
| 154 | + |
|
| 155 | + return debusquer_entete($titre, $res); |
|
| 156 | + } else { |
|
| 157 | + echo debusquer_entete($titre, $res); |
|
| 158 | + } |
|
| 159 | + exit; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | function debusquer_compose_message($msg) { |
| 163 | - if (is_array($msg)) { |
|
| 164 | - // si c'est un texte, c'est une traduction a faire, mais |
|
| 165 | - // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
|
| 166 | - if (!is_numeric($msg[0]) and count($msg) == 2) { |
|
| 167 | - // message avec argument: instancier |
|
| 168 | - $msg = _T($msg[0], $msg[1], 'spip-debug-arg'); |
|
| 169 | - } else { |
|
| 170 | - // message SQL: interpreter |
|
| 171 | - $msg = debusquer_requete($msg); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
|
| 175 | - // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
|
| 176 | - $fond = $GLOBALS['fond'] ?? ''; |
|
| 177 | - // une erreur critique sort $message en array |
|
| 178 | - $debug = is_array($msg) ? $msg[1] : $msg; |
|
| 179 | - spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 180 | - |
|
| 181 | - return $msg; |
|
| 163 | + if (is_array($msg)) { |
|
| 164 | + // si c'est un texte, c'est une traduction a faire, mais |
|
| 165 | + // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
|
| 166 | + if (!is_numeric($msg[0]) and count($msg) == 2) { |
|
| 167 | + // message avec argument: instancier |
|
| 168 | + $msg = _T($msg[0], $msg[1], 'spip-debug-arg'); |
|
| 169 | + } else { |
|
| 170 | + // message SQL: interpreter |
|
| 171 | + $msg = debusquer_requete($msg); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
|
| 175 | + // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
|
| 176 | + $fond = $GLOBALS['fond'] ?? ''; |
|
| 177 | + // une erreur critique sort $message en array |
|
| 178 | + $debug = is_array($msg) ? $msg[1] : $msg; |
|
| 179 | + spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 180 | + |
|
| 181 | + return $msg; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | function debusquer_bandeau($erreurs) { |
| 185 | 185 | |
| 186 | - if (!empty($erreurs)) { |
|
| 187 | - $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 186 | + if (!empty($erreurs)) { |
|
| 187 | + $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 188 | 188 | |
| 189 | - return debusquer_navigation($erreurs, $n); |
|
| 190 | - } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
|
| 191 | - include_spip('public/tracer'); |
|
| 192 | - [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']); |
|
| 189 | + return debusquer_navigation($erreurs, $n); |
|
| 190 | + } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
|
| 191 | + include_spip('public/tracer'); |
|
| 192 | + [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']); |
|
| 193 | 193 | |
| 194 | - return debusquer_navigation($temps, $nav, 'debug-profile'); |
|
| 195 | - } else { |
|
| 196 | - return ''; |
|
| 197 | - } |
|
| 194 | + return debusquer_navigation($temps, $nav, 'debug-profile'); |
|
| 195 | + } else { |
|
| 196 | + return ''; |
|
| 197 | + } |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -204,63 +204,63 @@ discard block |
||
| 204 | 204 | * @return string Code HTML |
| 205 | 205 | **/ |
| 206 | 206 | function debusquer_contexte($env) { |
| 207 | - if (is_string($env) and is_array($env_tab = @unserialize($env))) { |
|
| 208 | - $env = $env_tab; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - if (!$env) { |
|
| 212 | - return ''; |
|
| 213 | - } |
|
| 214 | - $res = ''; |
|
| 215 | - foreach ($env as $nom => $valeur) { |
|
| 216 | - if (is_array($valeur)) { |
|
| 217 | - $valeur_simple = []; |
|
| 218 | - foreach ($valeur as $v) { |
|
| 219 | - if (is_array($v)) { |
|
| 220 | - $valeur_simple[] = 'array:' . count($v); |
|
| 221 | - } elseif (is_object($v)) { |
|
| 222 | - $valeur_simple[] = get_class($v); |
|
| 223 | - } elseif (is_string($v)) { |
|
| 224 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 225 | - } else { |
|
| 226 | - $valeur_simple[] = $v; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - $n = count($valeur); |
|
| 230 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 231 | - $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 232 | - } elseif (is_object($valeur)) { |
|
| 233 | - $valeur = get_class($valeur); |
|
| 234 | - } elseif (is_string($valeur)) { |
|
| 235 | - $valeur = "'" . $valeur . "'"; |
|
| 236 | - } |
|
| 237 | - $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 238 | - . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 239 | - . "</td></tr>\n"; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 207 | + if (is_string($env) and is_array($env_tab = @unserialize($env))) { |
|
| 208 | + $env = $env_tab; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + if (!$env) { |
|
| 212 | + return ''; |
|
| 213 | + } |
|
| 214 | + $res = ''; |
|
| 215 | + foreach ($env as $nom => $valeur) { |
|
| 216 | + if (is_array($valeur)) { |
|
| 217 | + $valeur_simple = []; |
|
| 218 | + foreach ($valeur as $v) { |
|
| 219 | + if (is_array($v)) { |
|
| 220 | + $valeur_simple[] = 'array:' . count($v); |
|
| 221 | + } elseif (is_object($v)) { |
|
| 222 | + $valeur_simple[] = get_class($v); |
|
| 223 | + } elseif (is_string($v)) { |
|
| 224 | + $valeur_simple[] = "'" . $v . "'"; |
|
| 225 | + } else { |
|
| 226 | + $valeur_simple[] = $v; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + $n = count($valeur); |
|
| 230 | + $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 231 | + $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 232 | + } elseif (is_object($valeur)) { |
|
| 233 | + $valeur = get_class($valeur); |
|
| 234 | + } elseif (is_string($valeur)) { |
|
| 235 | + $valeur = "'" . $valeur . "'"; |
|
| 236 | + } |
|
| 237 | + $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 238 | + . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 239 | + . "</td></tr>\n"; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | function debusquer_loger_erreur($msg, $lieu) { |
| 247 | - $boucle = $ligne = $skel = ''; |
|
| 248 | - if (is_object($lieu)) { |
|
| 249 | - $ligne = ($lieu->ligne ?? ''); |
|
| 250 | - $boucle = ($lieu->id_boucle ?? ''); |
|
| 251 | - $skel = ($lieu->descr['sourcefile'] ?? ''); |
|
| 252 | - } |
|
| 253 | - $msg = (is_array($msg) ? implode('', $msg) : $msg); |
|
| 254 | - if ($skel) { |
|
| 255 | - $msg .= " Squelette $skel"; |
|
| 256 | - } |
|
| 257 | - if ($boucle) { |
|
| 258 | - $msg .= " Boucle $boucle"; |
|
| 259 | - } |
|
| 260 | - if ($ligne) { |
|
| 261 | - $msg .= " L$ligne"; |
|
| 262 | - } |
|
| 263 | - spip_log($msg, "debusquer" . _LOG_ERREUR); |
|
| 247 | + $boucle = $ligne = $skel = ''; |
|
| 248 | + if (is_object($lieu)) { |
|
| 249 | + $ligne = ($lieu->ligne ?? ''); |
|
| 250 | + $boucle = ($lieu->id_boucle ?? ''); |
|
| 251 | + $skel = ($lieu->descr['sourcefile'] ?? ''); |
|
| 252 | + } |
|
| 253 | + $msg = (is_array($msg) ? implode('', $msg) : $msg); |
|
| 254 | + if ($skel) { |
|
| 255 | + $msg .= " Squelette $skel"; |
|
| 256 | + } |
|
| 257 | + if ($boucle) { |
|
| 258 | + $msg .= " Boucle $boucle"; |
|
| 259 | + } |
|
| 260 | + if ($ligne) { |
|
| 261 | + $msg .= " L$ligne"; |
|
| 262 | + } |
|
| 263 | + spip_log($msg, "debusquer" . _LOG_ERREUR); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
@@ -269,66 +269,66 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | function debusquer_navigation($tableau, $caption = [], $id = 'debug-nav') { |
| 271 | 271 | |
| 272 | - if (_request('exec') == 'valider_xml') { |
|
| 273 | - return ''; |
|
| 274 | - } |
|
| 275 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 276 | - $res = ''; |
|
| 277 | - $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 278 | - foreach ($tableau as $i => $err) { |
|
| 279 | - $boucle = $ligne = $skel = ''; |
|
| 280 | - [$msg, $lieu] = $err; |
|
| 281 | - if (is_object($lieu)) { |
|
| 282 | - $ligne = $lieu->ligne; |
|
| 283 | - $boucle = !empty($lieu->id_boucle) ? $lieu->id_boucle : ''; |
|
| 284 | - if (isset($lieu->descr['nom'])) { |
|
| 285 | - $nom_code = $lieu->descr['nom']; |
|
| 286 | - $skel = $lieu->descr['sourcefile']; |
|
| 287 | - $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 288 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 289 | - $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 290 | - if ($boucle) { |
|
| 291 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 292 | - $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - $j = ($i + 1); |
|
| 298 | - $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 299 | - . $j |
|
| 300 | - . " </td><td style='text-align: left'>" |
|
| 301 | - . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 302 | - . "</td><td style='text-align: left'>" |
|
| 303 | - . ($skel ?: ' / ') |
|
| 304 | - . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 305 | - . ($boucle ?: ' / ') |
|
| 306 | - . "</td><td style='text-align: right'>" |
|
| 307 | - . $ligne |
|
| 308 | - . "</td></tr>\n"; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - return "\n<table id='$id'>" |
|
| 312 | - . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 313 | - . $caption[0] |
|
| 272 | + if (_request('exec') == 'valider_xml') { |
|
| 273 | + return ''; |
|
| 274 | + } |
|
| 275 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 276 | + $res = ''; |
|
| 277 | + $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 278 | + foreach ($tableau as $i => $err) { |
|
| 279 | + $boucle = $ligne = $skel = ''; |
|
| 280 | + [$msg, $lieu] = $err; |
|
| 281 | + if (is_object($lieu)) { |
|
| 282 | + $ligne = $lieu->ligne; |
|
| 283 | + $boucle = !empty($lieu->id_boucle) ? $lieu->id_boucle : ''; |
|
| 284 | + if (isset($lieu->descr['nom'])) { |
|
| 285 | + $nom_code = $lieu->descr['nom']; |
|
| 286 | + $skel = $lieu->descr['sourcefile']; |
|
| 287 | + $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 288 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 289 | + $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 290 | + if ($boucle) { |
|
| 291 | + $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 292 | + $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + $j = ($i + 1); |
|
| 298 | + $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 299 | + . $j |
|
| 300 | + . " </td><td style='text-align: left'>" |
|
| 301 | + . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 302 | + . "</td><td style='text-align: left'>" |
|
| 303 | + . ($skel ?: ' / ') |
|
| 304 | + . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 305 | + . ($boucle ?: ' / ') |
|
| 306 | + . "</td><td style='text-align: right'>" |
|
| 307 | + . $ligne |
|
| 308 | + . "</td></tr>\n"; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + return "\n<table id='$id'>" |
|
| 312 | + . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 313 | + . $caption[0] |
|
| 314 | 314 | ## aide locale courte a ecrire, avec lien vers une grosse page de documentation |
| 315 | 315 | # aider('erreur_compilation'), |
| 316 | - . '</caption>' |
|
| 317 | - // fausse caption du chrono (mais vraie nav) |
|
| 318 | - . (!empty($caption[1]) ? $caption[1] : '') |
|
| 319 | - . '<tr><th>' |
|
| 320 | - . _T('numero') |
|
| 321 | - . '</th><th>' |
|
| 322 | - . _T('public:message') |
|
| 323 | - . '</th><th>' |
|
| 324 | - . _T('squelette') |
|
| 325 | - . '</th><th>' |
|
| 326 | - . _T('zbug_boucle') |
|
| 327 | - . '</th><th>' |
|
| 328 | - . _T('ligne') |
|
| 329 | - . '</th></tr>' |
|
| 330 | - . $res |
|
| 331 | - . '</table>'; |
|
| 316 | + . '</caption>' |
|
| 317 | + // fausse caption du chrono (mais vraie nav) |
|
| 318 | + . (!empty($caption[1]) ? $caption[1] : '') |
|
| 319 | + . '<tr><th>' |
|
| 320 | + . _T('numero') |
|
| 321 | + . '</th><th>' |
|
| 322 | + . _T('public:message') |
|
| 323 | + . '</th><th>' |
|
| 324 | + . _T('squelette') |
|
| 325 | + . '</th><th>' |
|
| 326 | + . _T('zbug_boucle') |
|
| 327 | + . '</th><th>' |
|
| 328 | + . _T('ligne') |
|
| 329 | + . '</th></tr>' |
|
| 330 | + . $res |
|
| 331 | + . '</table>'; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | |
@@ -348,514 +348,514 @@ discard block |
||
| 348 | 348 | * ou un tableau si l'erreur est critique |
| 349 | 349 | **/ |
| 350 | 350 | function debusquer_requete($message) { |
| 351 | - [$errno, $msg, $query] = $message; |
|
| 352 | - |
|
| 353 | - // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 354 | - // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 355 | - if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 356 | - $errno = $regs[2]; |
|
| 357 | - } elseif ( |
|
| 358 | - is_numeric($errno) and ($errno == 1030 or $errno <= 1026) |
|
| 359 | - and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
|
| 360 | - ) { |
|
| 361 | - $errno = $regs[1]; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - // Erreur systeme |
|
| 365 | - if (is_numeric($errno) and $errno > 0 and $errno < 200) { |
|
| 366 | - $retour = '<tt><br /><br /><blink>' |
|
| 367 | - . _T('info_erreur_systeme', ['errsys' => $errno]) |
|
| 368 | - . "</blink><br />\n<b>" |
|
| 369 | - . _T( |
|
| 370 | - 'info_erreur_systeme2', |
|
| 371 | - ['script' => generer_url_ecrire('base_repair')] |
|
| 372 | - ) |
|
| 373 | - . '</b><br />'; |
|
| 374 | - spip_log("Erreur systeme $errno"); |
|
| 375 | - |
|
| 376 | - return [$retour, '']; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - // Requete erronee |
|
| 380 | - $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 381 | - . spip_htmlspecialchars($msg) |
|
| 382 | - . "\n<br /><span style='color: red'><b>" |
|
| 383 | - . spip_htmlspecialchars($query) |
|
| 384 | - . '</b></span></tt><br />'; |
|
| 385 | - |
|
| 386 | - //. aider('erreur_mysql'); |
|
| 387 | - |
|
| 388 | - return $err; |
|
| 351 | + [$errno, $msg, $query] = $message; |
|
| 352 | + |
|
| 353 | + // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 354 | + // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 355 | + if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 356 | + $errno = $regs[2]; |
|
| 357 | + } elseif ( |
|
| 358 | + is_numeric($errno) and ($errno == 1030 or $errno <= 1026) |
|
| 359 | + and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
|
| 360 | + ) { |
|
| 361 | + $errno = $regs[1]; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + // Erreur systeme |
|
| 365 | + if (is_numeric($errno) and $errno > 0 and $errno < 200) { |
|
| 366 | + $retour = '<tt><br /><br /><blink>' |
|
| 367 | + . _T('info_erreur_systeme', ['errsys' => $errno]) |
|
| 368 | + . "</blink><br />\n<b>" |
|
| 369 | + . _T( |
|
| 370 | + 'info_erreur_systeme2', |
|
| 371 | + ['script' => generer_url_ecrire('base_repair')] |
|
| 372 | + ) |
|
| 373 | + . '</b><br />'; |
|
| 374 | + spip_log("Erreur systeme $errno"); |
|
| 375 | + |
|
| 376 | + return [$retour, '']; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + // Requete erronee |
|
| 380 | + $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 381 | + . spip_htmlspecialchars($msg) |
|
| 382 | + . "\n<br /><span style='color: red'><b>" |
|
| 383 | + . spip_htmlspecialchars($query) |
|
| 384 | + . '</b></span></tt><br />'; |
|
| 385 | + |
|
| 386 | + //. aider('erreur_mysql'); |
|
| 387 | + |
|
| 388 | + return $err; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | |
| 392 | 392 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') { |
| 393 | 393 | |
| 394 | - $id = $nom . $boucle; |
|
| 395 | - if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 396 | - foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 397 | - if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
|
| 398 | - $y = substr_count($v[0], "\n"); |
|
| 399 | - } else { |
|
| 400 | - if ($v[1][0] == '#') { // balise dynamique |
|
| 401 | - $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 402 | - } else // inclusion |
|
| 403 | - { |
|
| 404 | - $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 405 | - } |
|
| 406 | - $y = substr_count($incl, "\n") |
|
| 407 | - + substr_count($r[1], "\n") |
|
| 408 | - + substr_count($r[3], "\n"); |
|
| 409 | - } |
|
| 410 | - if ($n <= ($y + $debut)) { |
|
| 411 | - if ($v[1][0] == '?') { |
|
| 412 | - return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
|
| 413 | - } elseif ($v[1][0] == '!') { |
|
| 414 | - if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 415 | - return trouve_boucle_debug($n, $incl, $debut); |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - return [$nom, $boucle, $v[2] - 1 + $n - $debut]; |
|
| 420 | - } |
|
| 421 | - $debut += $y; |
|
| 422 | - } |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - return [$nom, $boucle, $n - $debut]; |
|
| 394 | + $id = $nom . $boucle; |
|
| 395 | + if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 396 | + foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 397 | + if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
|
| 398 | + $y = substr_count($v[0], "\n"); |
|
| 399 | + } else { |
|
| 400 | + if ($v[1][0] == '#') { // balise dynamique |
|
| 401 | + $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 402 | + } else // inclusion |
|
| 403 | + { |
|
| 404 | + $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 405 | + } |
|
| 406 | + $y = substr_count($incl, "\n") |
|
| 407 | + + substr_count($r[1], "\n") |
|
| 408 | + + substr_count($r[3], "\n"); |
|
| 409 | + } |
|
| 410 | + if ($n <= ($y + $debut)) { |
|
| 411 | + if ($v[1][0] == '?') { |
|
| 412 | + return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
|
| 413 | + } elseif ($v[1][0] == '!') { |
|
| 414 | + if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 415 | + return trouve_boucle_debug($n, $incl, $debut); |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + return [$nom, $boucle, $v[2] - 1 + $n - $debut]; |
|
| 420 | + } |
|
| 421 | + $debut += $y; |
|
| 422 | + } |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + return [$nom, $boucle, $n - $debut]; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | function trouve_squelette_inclus($script) { |
| 429 | 429 | |
| 430 | - preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
|
| 431 | - // si le script X.php n'est pas ecrire/public.php |
|
| 432 | - // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 433 | - if ($reg[1] == 'ecrire/public') { // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 434 | - if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) { // a defaut on cherche le param 'page' |
|
| 435 | - if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) { |
|
| 436 | - $reg[1] = 'inconnu'; |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 441 | - |
|
| 442 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 443 | - if (preg_match($incl, $v)) { |
|
| 444 | - return $k; |
|
| 445 | - } |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - return ''; |
|
| 430 | + preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
|
| 431 | + // si le script X.php n'est pas ecrire/public.php |
|
| 432 | + // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 433 | + if ($reg[1] == 'ecrire/public') { // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 434 | + if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) { // a defaut on cherche le param 'page' |
|
| 435 | + if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) { |
|
| 436 | + $reg[1] = 'inconnu'; |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 441 | + |
|
| 442 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 443 | + if (preg_match($incl, $v)) { |
|
| 444 | + return $k; |
|
| 445 | + } |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + return ''; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | function reference_boucle_debug($n, $nom, $self) { |
| 452 | - [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
|
| 453 | - |
|
| 454 | - if (!$boucle) { |
|
| 455 | - return !$ligne ? '' : |
|
| 456 | - (' (' . |
|
| 457 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 458 | - _T('squelette_ligne')) . |
|
| 459 | - " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
|
| 460 | - } else { |
|
| 461 | - $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 462 | - |
|
| 463 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 464 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 465 | - } |
|
| 452 | + [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
|
| 453 | + |
|
| 454 | + if (!$boucle) { |
|
| 455 | + return !$ligne ? '' : |
|
| 456 | + (' (' . |
|
| 457 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 458 | + _T('squelette_ligne')) . |
|
| 459 | + " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
|
| 460 | + } else { |
|
| 461 | + $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 462 | + |
|
| 463 | + return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 464 | + " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 465 | + } |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // affiche un texte avec numero de ligne et ancre. |
| 469 | 469 | |
| 470 | 470 | function ancre_texte($texte, $fautifs = [], $nocpt = false) { |
| 471 | 471 | |
| 472 | - $var_mode_ligne = _request('var_mode_ligne'); |
|
| 473 | - if ($var_mode_ligne) { |
|
| 474 | - $fautifs[] = [$var_mode_ligne]; |
|
| 475 | - } |
|
| 476 | - $res = ''; |
|
| 477 | - |
|
| 478 | - $s = highlight_string($texte, true); |
|
| 479 | - if (substr($s, 0, 6) == '<code>') { |
|
| 480 | - $s = substr($s, 6); |
|
| 481 | - $res = '<code>'; |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - $s = preg_replace( |
|
| 485 | - ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 486 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 487 | - $s |
|
| 488 | - ); |
|
| 489 | - |
|
| 490 | - |
|
| 491 | - $tableau = explode('<br />', $s); |
|
| 492 | - |
|
| 493 | - $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" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n"; |
|
| 494 | - |
|
| 495 | - $format10 = str_replace('white', 'lightgrey', $format); |
|
| 496 | - $formaterr = 'color: red;'; |
|
| 497 | - $i = 1; |
|
| 498 | - $flignes = []; |
|
| 499 | - $loc = [0, 0]; |
|
| 500 | - foreach ($fautifs as $lc) { |
|
| 501 | - if (is_array($lc)) { |
|
| 502 | - $l = array_shift($lc); |
|
| 503 | - $flignes[$l] = $lc; |
|
| 504 | - } else { |
|
| 505 | - $flignes[$lc] = $loc; |
|
| 506 | - } |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - $ancre = md5($texte); |
|
| 510 | - foreach ($tableau as $ligne) { |
|
| 511 | - if (isset($flignes[$i])) { |
|
| 512 | - $ligne = str_replace(' ', ' ', $ligne); |
|
| 513 | - $indexmesg = $flignes[$i][1]; |
|
| 514 | - $err = textebrut($flignes[$i][2]); |
|
| 515 | - // tentative de pointer sur la colonne fautive; |
|
| 516 | - // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 517 | - // $m = $flignes[$i][0]; |
|
| 518 | - // $ligne = substr($ligne, 0, $m-1) . |
|
| 519 | - // sprintf($formaterr, substr($ligne,$m)); |
|
| 520 | - $bg = $formaterr; |
|
| 521 | - } else { |
|
| 522 | - $indexmesg = $ancre; |
|
| 523 | - $err = $bg = ''; |
|
| 524 | - } |
|
| 525 | - $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 526 | - $i++; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return "<div id='T$ancre'>" |
|
| 530 | - . '<div onclick="' |
|
| 531 | - . "jQuery(this).parent().find('a').toggle();" |
|
| 532 | - . '" title="' |
|
| 533 | - . _T('masquer_colonne') |
|
| 534 | - . '" style="cursor: pointer;">' |
|
| 535 | - . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 536 | - . '</div> |
|
| 472 | + $var_mode_ligne = _request('var_mode_ligne'); |
|
| 473 | + if ($var_mode_ligne) { |
|
| 474 | + $fautifs[] = [$var_mode_ligne]; |
|
| 475 | + } |
|
| 476 | + $res = ''; |
|
| 477 | + |
|
| 478 | + $s = highlight_string($texte, true); |
|
| 479 | + if (substr($s, 0, 6) == '<code>') { |
|
| 480 | + $s = substr($s, 6); |
|
| 481 | + $res = '<code>'; |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + $s = preg_replace( |
|
| 485 | + ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 486 | + '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 487 | + $s |
|
| 488 | + ); |
|
| 489 | + |
|
| 490 | + |
|
| 491 | + $tableau = explode('<br />', $s); |
|
| 492 | + |
|
| 493 | + $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" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n"; |
|
| 494 | + |
|
| 495 | + $format10 = str_replace('white', 'lightgrey', $format); |
|
| 496 | + $formaterr = 'color: red;'; |
|
| 497 | + $i = 1; |
|
| 498 | + $flignes = []; |
|
| 499 | + $loc = [0, 0]; |
|
| 500 | + foreach ($fautifs as $lc) { |
|
| 501 | + if (is_array($lc)) { |
|
| 502 | + $l = array_shift($lc); |
|
| 503 | + $flignes[$l] = $lc; |
|
| 504 | + } else { |
|
| 505 | + $flignes[$lc] = $loc; |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + $ancre = md5($texte); |
|
| 510 | + foreach ($tableau as $ligne) { |
|
| 511 | + if (isset($flignes[$i])) { |
|
| 512 | + $ligne = str_replace(' ', ' ', $ligne); |
|
| 513 | + $indexmesg = $flignes[$i][1]; |
|
| 514 | + $err = textebrut($flignes[$i][2]); |
|
| 515 | + // tentative de pointer sur la colonne fautive; |
|
| 516 | + // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 517 | + // $m = $flignes[$i][0]; |
|
| 518 | + // $ligne = substr($ligne, 0, $m-1) . |
|
| 519 | + // sprintf($formaterr, substr($ligne,$m)); |
|
| 520 | + $bg = $formaterr; |
|
| 521 | + } else { |
|
| 522 | + $indexmesg = $ancre; |
|
| 523 | + $err = $bg = ''; |
|
| 524 | + } |
|
| 525 | + $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 526 | + $i++; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return "<div id='T$ancre'>" |
|
| 530 | + . '<div onclick="' |
|
| 531 | + . "jQuery(this).parent().find('a').toggle();" |
|
| 532 | + . '" title="' |
|
| 533 | + . _T('masquer_colonne') |
|
| 534 | + . '" style="cursor: pointer;">' |
|
| 535 | + . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 536 | + . '</div> |
|
| 537 | 537 | ' . $res . "</div>\n"; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | // l'environnement graphique du debuggueur |
| 541 | 541 | |
| 542 | 542 | function debusquer_squelette($fonc, $mode, $self) { |
| 543 | - $legend = null; |
|
| 544 | - $texte = ''; |
|
| 545 | - |
|
| 546 | - if ($mode !== 'validation') { |
|
| 547 | - if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) { |
|
| 548 | - $res = "<div id='spip-boucles'>\n" |
|
| 549 | - . debusquer_navigation_squelettes($self) |
|
| 550 | - . '</div>'; |
|
| 551 | - } else { |
|
| 552 | - $res = ''; |
|
| 553 | - } |
|
| 554 | - if ($fonc) { |
|
| 555 | - $id = " id='$fonc'"; |
|
| 556 | - if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 557 | - [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
|
| 558 | - $texte .= $res2; |
|
| 559 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 560 | - $legend = _T('zbug_' . $mode); |
|
| 561 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 562 | - $texte = ancre_texte($texte, ['', '']); |
|
| 563 | - } |
|
| 564 | - } else { |
|
| 565 | - if (strlen(trim($res))) { |
|
| 566 | - 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>"; |
|
| 567 | - } else { |
|
| 568 | - // cas de l'appel sur erreur: montre la page |
|
| 569 | - return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
|
| 570 | - } |
|
| 571 | - } |
|
| 572 | - } else { |
|
| 573 | - $valider = charger_fonction('valider', 'xml'); |
|
| 574 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 575 | - // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 576 | - $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 577 | - [$texte, $err] = emboite_texte($val, $fonc, $self); |
|
| 578 | - if ($err === false) { |
|
| 579 | - $err = _T('impossible'); |
|
| 580 | - } elseif ($err === true) { |
|
| 581 | - $err = _T('correcte'); |
|
| 582 | - } else { |
|
| 583 | - $err = ": $err"; |
|
| 584 | - } |
|
| 585 | - $legend = _T('validation') . ' ' . $err; |
|
| 586 | - $res = $id = ''; |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - return !trim($texte) ? '' : ( |
|
| 590 | - "<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" |
|
| 591 | - . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 592 | - . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 593 | - . ($legend ?: $mode) |
|
| 594 | - . '</a></legend>' |
|
| 595 | - . $texte |
|
| 596 | - . '</fieldset></div>' |
|
| 597 | - . '</div>'); |
|
| 543 | + $legend = null; |
|
| 544 | + $texte = ''; |
|
| 545 | + |
|
| 546 | + if ($mode !== 'validation') { |
|
| 547 | + if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) { |
|
| 548 | + $res = "<div id='spip-boucles'>\n" |
|
| 549 | + . debusquer_navigation_squelettes($self) |
|
| 550 | + . '</div>'; |
|
| 551 | + } else { |
|
| 552 | + $res = ''; |
|
| 553 | + } |
|
| 554 | + if ($fonc) { |
|
| 555 | + $id = " id='$fonc'"; |
|
| 556 | + if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 557 | + [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
|
| 558 | + $texte .= $res2; |
|
| 559 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 560 | + $legend = _T('zbug_' . $mode); |
|
| 561 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 562 | + $texte = ancre_texte($texte, ['', '']); |
|
| 563 | + } |
|
| 564 | + } else { |
|
| 565 | + if (strlen(trim($res))) { |
|
| 566 | + 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>"; |
|
| 567 | + } else { |
|
| 568 | + // cas de l'appel sur erreur: montre la page |
|
| 569 | + return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | + } else { |
|
| 573 | + $valider = charger_fonction('valider', 'xml'); |
|
| 574 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 575 | + // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 576 | + $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 577 | + [$texte, $err] = emboite_texte($val, $fonc, $self); |
|
| 578 | + if ($err === false) { |
|
| 579 | + $err = _T('impossible'); |
|
| 580 | + } elseif ($err === true) { |
|
| 581 | + $err = _T('correcte'); |
|
| 582 | + } else { |
|
| 583 | + $err = ": $err"; |
|
| 584 | + } |
|
| 585 | + $legend = _T('validation') . ' ' . $err; |
|
| 586 | + $res = $id = ''; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + return !trim($texte) ? '' : ( |
|
| 590 | + "<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" |
|
| 591 | + . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 592 | + . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 593 | + . ($legend ?: $mode) |
|
| 594 | + . '</a></legend>' |
|
| 595 | + . $texte |
|
| 596 | + . '</fieldset></div>' |
|
| 597 | + . '</div>'); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | |
| 601 | 601 | function emboite_texte($res, $fonc = '', $self = '') { |
| 602 | - $errs = $res->err; |
|
| 603 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 604 | - |
|
| 605 | - if (!$texte and !$errs) { |
|
| 606 | - return [ancre_texte('', ['', '']), false]; |
|
| 607 | - } |
|
| 608 | - if (!$errs) { |
|
| 609 | - return [ancre_texte($texte, ['', '']), true]; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - if (!isset($GLOBALS['debug_objets'])) { |
|
| 613 | - $colors = ['#e0e0f0', '#f8f8ff']; |
|
| 614 | - $encore = count_occ($errs); |
|
| 615 | - $encore2 = []; |
|
| 616 | - $fautifs = []; |
|
| 617 | - |
|
| 618 | - $err = '<tr><th>' |
|
| 619 | - . _T('numero') |
|
| 620 | - . '</th><th>' |
|
| 621 | - . _T('occurence') |
|
| 622 | - . '</th><th>' |
|
| 623 | - . _T('ligne') |
|
| 624 | - . '</th><th>' |
|
| 625 | - . _T('colonne') |
|
| 626 | - . '</th><th>' |
|
| 627 | - . _T('erreur') |
|
| 628 | - . '</th></tr>'; |
|
| 629 | - |
|
| 630 | - $i = 0; |
|
| 631 | - $style = "style='text-align: right; padding-right: 5px'"; |
|
| 632 | - foreach ($errs as $r) { |
|
| 633 | - $i++; |
|
| 634 | - [$msg, $ligne, $col] = $r; |
|
| 635 | - #spip_log("$r = list($msg, $ligne, $col"); |
|
| 636 | - if (isset($encore2[$msg])) { |
|
| 637 | - $ref = ++$encore2[$msg]; |
|
| 638 | - } else { |
|
| 639 | - $encore2[$msg] = $ref = 1; |
|
| 640 | - } |
|
| 641 | - $err .= "<tr style='background-color: " |
|
| 642 | - . $colors[$i % 2] |
|
| 643 | - . "'><td $style><a href='#debut_err'>" |
|
| 644 | - . $i |
|
| 645 | - . "</a></td><td $style>" |
|
| 646 | - . "$ref/$encore[$msg]</td>" |
|
| 647 | - . "<td $style><a href='#L" |
|
| 648 | - . $ligne |
|
| 649 | - . "' id='T$i'>" |
|
| 650 | - . $ligne |
|
| 651 | - . "</a></td><td $style>" |
|
| 652 | - . $col |
|
| 653 | - . "</td><td>$msg</td></tr>\n"; |
|
| 654 | - $fautifs[] = [$ligne, $col, $i, $msg]; |
|
| 655 | - } |
|
| 656 | - $err = "<h2 style='text-align: center'>" |
|
| 657 | - . $i |
|
| 658 | - . "<a href='#fin_err'>" |
|
| 659 | - . ' ' . _T('erreur_texte') |
|
| 660 | - . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 661 | - . $err |
|
| 662 | - . " </table><a id='fin_err'></a>"; |
|
| 663 | - |
|
| 664 | - return [ancre_texte($texte, $fautifs), $err]; |
|
| 665 | - } else { |
|
| 666 | - [$msg, $fermant, $ouvrant] = $errs[0]; |
|
| 667 | - $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 668 | - $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 669 | - $err = $msg . |
|
| 670 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 671 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 672 | - |
|
| 673 | - return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
|
| 674 | - } |
|
| 602 | + $errs = $res->err; |
|
| 603 | + $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 604 | + |
|
| 605 | + if (!$texte and !$errs) { |
|
| 606 | + return [ancre_texte('', ['', '']), false]; |
|
| 607 | + } |
|
| 608 | + if (!$errs) { |
|
| 609 | + return [ancre_texte($texte, ['', '']), true]; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + if (!isset($GLOBALS['debug_objets'])) { |
|
| 613 | + $colors = ['#e0e0f0', '#f8f8ff']; |
|
| 614 | + $encore = count_occ($errs); |
|
| 615 | + $encore2 = []; |
|
| 616 | + $fautifs = []; |
|
| 617 | + |
|
| 618 | + $err = '<tr><th>' |
|
| 619 | + . _T('numero') |
|
| 620 | + . '</th><th>' |
|
| 621 | + . _T('occurence') |
|
| 622 | + . '</th><th>' |
|
| 623 | + . _T('ligne') |
|
| 624 | + . '</th><th>' |
|
| 625 | + . _T('colonne') |
|
| 626 | + . '</th><th>' |
|
| 627 | + . _T('erreur') |
|
| 628 | + . '</th></tr>'; |
|
| 629 | + |
|
| 630 | + $i = 0; |
|
| 631 | + $style = "style='text-align: right; padding-right: 5px'"; |
|
| 632 | + foreach ($errs as $r) { |
|
| 633 | + $i++; |
|
| 634 | + [$msg, $ligne, $col] = $r; |
|
| 635 | + #spip_log("$r = list($msg, $ligne, $col"); |
|
| 636 | + if (isset($encore2[$msg])) { |
|
| 637 | + $ref = ++$encore2[$msg]; |
|
| 638 | + } else { |
|
| 639 | + $encore2[$msg] = $ref = 1; |
|
| 640 | + } |
|
| 641 | + $err .= "<tr style='background-color: " |
|
| 642 | + . $colors[$i % 2] |
|
| 643 | + . "'><td $style><a href='#debut_err'>" |
|
| 644 | + . $i |
|
| 645 | + . "</a></td><td $style>" |
|
| 646 | + . "$ref/$encore[$msg]</td>" |
|
| 647 | + . "<td $style><a href='#L" |
|
| 648 | + . $ligne |
|
| 649 | + . "' id='T$i'>" |
|
| 650 | + . $ligne |
|
| 651 | + . "</a></td><td $style>" |
|
| 652 | + . $col |
|
| 653 | + . "</td><td>$msg</td></tr>\n"; |
|
| 654 | + $fautifs[] = [$ligne, $col, $i, $msg]; |
|
| 655 | + } |
|
| 656 | + $err = "<h2 style='text-align: center'>" |
|
| 657 | + . $i |
|
| 658 | + . "<a href='#fin_err'>" |
|
| 659 | + . ' ' . _T('erreur_texte') |
|
| 660 | + . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 661 | + . $err |
|
| 662 | + . " </table><a id='fin_err'></a>"; |
|
| 663 | + |
|
| 664 | + return [ancre_texte($texte, $fautifs), $err]; |
|
| 665 | + } else { |
|
| 666 | + [$msg, $fermant, $ouvrant] = $errs[0]; |
|
| 667 | + $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 668 | + $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 669 | + $err = $msg . |
|
| 670 | + "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 671 | + "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 672 | + |
|
| 673 | + return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
|
| 674 | + } |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | function count_occ($regs) { |
| 678 | - $encore = []; |
|
| 679 | - foreach ($regs as $r) { |
|
| 680 | - if (isset($encore[$r[0]])) { |
|
| 681 | - $encore[$r[0]]++; |
|
| 682 | - } else { |
|
| 683 | - $encore[$r[0]] = 1; |
|
| 684 | - } |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - return $encore; |
|
| 678 | + $encore = []; |
|
| 679 | + foreach ($regs as $r) { |
|
| 680 | + if (isset($encore[$r[0]])) { |
|
| 681 | + $encore[$r[0]]++; |
|
| 682 | + } else { |
|
| 683 | + $encore[$r[0]] = 1; |
|
| 684 | + } |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + return $encore; |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | function debusquer_navigation_squelettes($self) { |
| 691 | 691 | |
| 692 | - $res = ''; |
|
| 693 | - $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : ''; |
|
| 694 | - $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 695 | - $t_skel = _T('squelette'); |
|
| 696 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 697 | - $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 698 | - $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
|
| 699 | - $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T( |
|
| 700 | - 'zbug_profile', |
|
| 701 | - ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
|
| 702 | - ); |
|
| 703 | - |
|
| 704 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 705 | - . $t_skel |
|
| 706 | - . ' ' |
|
| 707 | - . $sourcefile |
|
| 708 | - . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 709 | - . $t_skel |
|
| 710 | - . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 711 | - . _T('zbug_resultat') |
|
| 712 | - . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 713 | - . _T('zbug_code') |
|
| 714 | - . "</a>\n<a href='" |
|
| 715 | - . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', $self) |
|
| 716 | - . "'>" |
|
| 717 | - . _T('zbug_calcul') |
|
| 718 | - . '</a></legend>' |
|
| 719 | - . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 720 | - . debusquer_contexte($contexte[$sourcefile]) |
|
| 721 | - . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
|
| 722 | - . "</fieldset>\n"; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - return $res; |
|
| 692 | + $res = ''; |
|
| 693 | + $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : ''; |
|
| 694 | + $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 695 | + $t_skel = _T('squelette'); |
|
| 696 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 697 | + $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 698 | + $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
|
| 699 | + $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T( |
|
| 700 | + 'zbug_profile', |
|
| 701 | + ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
|
| 702 | + ); |
|
| 703 | + |
|
| 704 | + $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 705 | + . $t_skel |
|
| 706 | + . ' ' |
|
| 707 | + . $sourcefile |
|
| 708 | + . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 709 | + . $t_skel |
|
| 710 | + . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 711 | + . _T('zbug_resultat') |
|
| 712 | + . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 713 | + . _T('zbug_code') |
|
| 714 | + . "</a>\n<a href='" |
|
| 715 | + . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', $self) |
|
| 716 | + . "'>" |
|
| 717 | + . _T('zbug_calcul') |
|
| 718 | + . '</a></legend>' |
|
| 719 | + . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 720 | + . debusquer_contexte($contexte[$sourcefile]) |
|
| 721 | + . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
|
| 722 | + . "</fieldset>\n"; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + return $res; |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) { |
| 729 | - $i = 0; |
|
| 730 | - $res = ''; |
|
| 731 | - $var_mode_objet = _request('var_mode_objet'); |
|
| 732 | - $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
|
| 733 | - |
|
| 734 | - foreach ($boucles as $objet => $boucle) { |
|
| 735 | - if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 736 | - $i++; |
|
| 737 | - $nom = $boucle->id_boucle; |
|
| 738 | - $req = $boucle->type_requete; |
|
| 739 | - $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 740 | - $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 741 | - |
|
| 742 | - $res .= "\n<tr style='background-color: " . |
|
| 743 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 744 | - "'><td align='right'>$i</td><td>\n" . |
|
| 745 | - "<a class='debug_link_boucle' href='" . |
|
| 746 | - $self2 . |
|
| 747 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 748 | - _T('zbug_boucle') . |
|
| 749 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 750 | - $self2 . |
|
| 751 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 752 | - _T('zbug_resultat') . |
|
| 753 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 754 | - $self2 . |
|
| 755 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 756 | - _T('zbug_code') . |
|
| 757 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 758 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 759 | - "'>" . |
|
| 760 | - _T('zbug_calcul') . |
|
| 761 | - "</a></td><td>\n" . |
|
| 762 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 763 | - "</td><td>\n" . |
|
| 764 | - $req . |
|
| 765 | - "</td><td>\n" . |
|
| 766 | - spip_htmlspecialchars($crit) . |
|
| 767 | - '</td></tr>'; |
|
| 768 | - } |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - return $res; |
|
| 729 | + $i = 0; |
|
| 730 | + $res = ''; |
|
| 731 | + $var_mode_objet = _request('var_mode_objet'); |
|
| 732 | + $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
|
| 733 | + |
|
| 734 | + foreach ($boucles as $objet => $boucle) { |
|
| 735 | + if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 736 | + $i++; |
|
| 737 | + $nom = $boucle->id_boucle; |
|
| 738 | + $req = $boucle->type_requete; |
|
| 739 | + $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 740 | + $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 741 | + |
|
| 742 | + $res .= "\n<tr style='background-color: " . |
|
| 743 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 744 | + "'><td align='right'>$i</td><td>\n" . |
|
| 745 | + "<a class='debug_link_boucle' href='" . |
|
| 746 | + $self2 . |
|
| 747 | + "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 748 | + _T('zbug_boucle') . |
|
| 749 | + "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 750 | + $self2 . |
|
| 751 | + "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 752 | + _T('zbug_resultat') . |
|
| 753 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 754 | + $self2 . |
|
| 755 | + "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 756 | + _T('zbug_code') . |
|
| 757 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 758 | + str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 759 | + "'>" . |
|
| 760 | + _T('zbug_calcul') . |
|
| 761 | + "</a></td><td>\n" . |
|
| 762 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 763 | + "</td><td>\n" . |
|
| 764 | + $req . |
|
| 765 | + "</td><td>\n" . |
|
| 766 | + spip_htmlspecialchars($crit) . |
|
| 767 | + '</td></tr>'; |
|
| 768 | + } |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + return $res; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | function debusquer_source($objet, $affiche) { |
| 775 | - $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 776 | - if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 777 | - $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 778 | - } else { |
|
| 779 | - $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 780 | - } |
|
| 781 | - $res2 = ''; |
|
| 782 | - |
|
| 783 | - if ($affiche == 'resultat') { |
|
| 784 | - $legend = $nom; |
|
| 785 | - $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 786 | - if (function_exists('_mysql_traite_query')) { |
|
| 787 | - $c = strtolower(_request('connect') ?? ''); |
|
| 788 | - $c = $GLOBALS['connexions'][$c ?: 0]['prefixe']; |
|
| 789 | - $req = _mysql_traite_query($req, '', $c); |
|
| 790 | - } |
|
| 791 | - // permettre le copier/coller facile |
|
| 792 | - // $res = ancre_texte($req, array(), true); |
|
| 793 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 794 | - // formatage et affichage des resultats bruts de la requete |
|
| 795 | - $ress_req = spip_query($req); |
|
| 796 | - $brut_sql = ''; |
|
| 797 | - $num = 1; |
|
| 798 | - // eviter l'affichage de milliers de lignes |
|
| 799 | - // personnalisation possible dans mes_options |
|
| 800 | - $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 801 | - while ($retours_sql = sql_fetch($ress_req)) { |
|
| 802 | - if ($num <= $max_aff) { |
|
| 803 | - $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 804 | - $brut_sql .= '<p>'; |
|
| 805 | - foreach ($retours_sql as $key => $val) { |
|
| 806 | - $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 807 | - } |
|
| 808 | - $brut_sql .= '</p>'; |
|
| 809 | - } |
|
| 810 | - $num++; |
|
| 811 | - } |
|
| 812 | - $res2 = interdire_scripts($brut_sql); |
|
| 813 | - foreach ($quoi as $view) { |
|
| 814 | - // ne pas afficher les $contexte_inclus |
|
| 815 | - $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
|
| 816 | - if ($view) { |
|
| 817 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 818 | - } |
|
| 819 | - } |
|
| 820 | - } elseif ($affiche == 'code') { |
|
| 821 | - $legend = $nom; |
|
| 822 | - $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 823 | - } elseif ($affiche == 'boucle') { |
|
| 824 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 825 | - // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 826 | - $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
|
| 827 | - $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 828 | - } elseif ($affiche == 'squelette') { |
|
| 829 | - $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 830 | - $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - return [$legend, $res, $res2]; |
|
| 775 | + $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 776 | + if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 777 | + $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 778 | + } else { |
|
| 779 | + $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 780 | + } |
|
| 781 | + $res2 = ''; |
|
| 782 | + |
|
| 783 | + if ($affiche == 'resultat') { |
|
| 784 | + $legend = $nom; |
|
| 785 | + $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 786 | + if (function_exists('_mysql_traite_query')) { |
|
| 787 | + $c = strtolower(_request('connect') ?? ''); |
|
| 788 | + $c = $GLOBALS['connexions'][$c ?: 0]['prefixe']; |
|
| 789 | + $req = _mysql_traite_query($req, '', $c); |
|
| 790 | + } |
|
| 791 | + // permettre le copier/coller facile |
|
| 792 | + // $res = ancre_texte($req, array(), true); |
|
| 793 | + $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 794 | + // formatage et affichage des resultats bruts de la requete |
|
| 795 | + $ress_req = spip_query($req); |
|
| 796 | + $brut_sql = ''; |
|
| 797 | + $num = 1; |
|
| 798 | + // eviter l'affichage de milliers de lignes |
|
| 799 | + // personnalisation possible dans mes_options |
|
| 800 | + $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 801 | + while ($retours_sql = sql_fetch($ress_req)) { |
|
| 802 | + if ($num <= $max_aff) { |
|
| 803 | + $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 804 | + $brut_sql .= '<p>'; |
|
| 805 | + foreach ($retours_sql as $key => $val) { |
|
| 806 | + $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 807 | + } |
|
| 808 | + $brut_sql .= '</p>'; |
|
| 809 | + } |
|
| 810 | + $num++; |
|
| 811 | + } |
|
| 812 | + $res2 = interdire_scripts($brut_sql); |
|
| 813 | + foreach ($quoi as $view) { |
|
| 814 | + // ne pas afficher les $contexte_inclus |
|
| 815 | + $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
|
| 816 | + if ($view) { |
|
| 817 | + $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 818 | + } |
|
| 819 | + } |
|
| 820 | + } elseif ($affiche == 'code') { |
|
| 821 | + $legend = $nom; |
|
| 822 | + $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 823 | + } elseif ($affiche == 'boucle') { |
|
| 824 | + $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 825 | + // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 826 | + $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
|
| 827 | + $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 828 | + } elseif ($affiche == 'squelette') { |
|
| 829 | + $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 830 | + $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + return [$legend, $res, $res2]; |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | function debusquer_entete($titre, $corps) { |
| 837 | 837 | |
| 838 | - include_spip('balise/formulaire_admin'); |
|
| 839 | - include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 840 | - include_spip('inc/texte'); // pour corriger_typo |
|
| 841 | - |
|
| 842 | - return _DOCTYPE_ECRIRE . |
|
| 843 | - html_lang_attributes() . |
|
| 844 | - "<head>\n<title>" . |
|
| 845 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 846 | - _T('admin_debug') . ' ' . spip_htmlspecialchars($titre) . ' (' . |
|
| 847 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 848 | - ")</title>\n" . |
|
| 849 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 850 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 851 | - "' />\n" . |
|
| 852 | - http_script('', 'jquery.js') |
|
| 853 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 854 | - . "' type='text/css' />" . |
|
| 855 | - "</head>\n" . |
|
| 856 | - "<body style='margin:0 10px;'>\n" . |
|
| 857 | - "<div id='spip-debug-header'>" . |
|
| 858 | - $corps . |
|
| 859 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 860 | - '</div></body></html>'; |
|
| 838 | + include_spip('balise/formulaire_admin'); |
|
| 839 | + include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 840 | + include_spip('inc/texte'); // pour corriger_typo |
|
| 841 | + |
|
| 842 | + return _DOCTYPE_ECRIRE . |
|
| 843 | + html_lang_attributes() . |
|
| 844 | + "<head>\n<title>" . |
|
| 845 | + ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 846 | + _T('admin_debug') . ' ' . spip_htmlspecialchars($titre) . ' (' . |
|
| 847 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 848 | + ")</title>\n" . |
|
| 849 | + "<meta http-equiv='Content-Type' content='text/html" . |
|
| 850 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 851 | + "' />\n" . |
|
| 852 | + http_script('', 'jquery.js') |
|
| 853 | + . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 854 | + . "' type='text/css' />" . |
|
| 855 | + "</head>\n" . |
|
| 856 | + "<body style='margin:0 10px;'>\n" . |
|
| 857 | + "<div id='spip-debug-header'>" . |
|
| 858 | + $corps . |
|
| 859 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 860 | + '</div></body></html>'; |
|
| 861 | 861 | } |