@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function genie_maintenance_dist($t) { |
| 36 | 36 | |
| 37 | - // (re)mettre .htaccess avec deny from all |
|
| 38 | - // dans les deux repertoires dits inaccessibles par http |
|
| 39 | - include_spip('inc/acces'); |
|
| 40 | - verifier_htaccess(_DIR_ETC); |
|
| 41 | - verifier_htaccess(_DIR_TMP); |
|
| 42 | - verifier_htaccess(_DIR_VENDOR); |
|
| 37 | + // (re)mettre .htaccess avec deny from all |
|
| 38 | + // dans les deux repertoires dits inaccessibles par http |
|
| 39 | + include_spip('inc/acces'); |
|
| 40 | + verifier_htaccess(_DIR_ETC); |
|
| 41 | + verifier_htaccess(_DIR_TMP); |
|
| 42 | + verifier_htaccess(_DIR_VENDOR); |
|
| 43 | 43 | |
| 44 | - // Verifier qu'aucune table n'est crashee |
|
| 45 | - if (!_request('reinstall')) { |
|
| 46 | - verifier_crash_tables(); |
|
| 47 | - } |
|
| 44 | + // Verifier qu'aucune table n'est crashee |
|
| 45 | + if (!_request('reinstall')) { |
|
| 46 | + verifier_crash_tables(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return 1; |
|
| 49 | + return 1; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -63,33 +63,33 @@ discard block |
||
| 63 | 63 | * des tables qui ont crashé. |
| 64 | 64 | */ |
| 65 | 65 | function verifier_crash_tables() { |
| 66 | - if (spip_connect()) { |
|
| 67 | - include_spip('base/serial'); |
|
| 68 | - include_spip('base/auxiliaires'); |
|
| 69 | - $crash = []; |
|
| 70 | - foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 71 | - foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 72 | - if ( |
|
| 73 | - !sql_select('*', $table, '', '', '', 1) |
|
| 74 | - && !defined('spip_interdire_cache') |
|
| 75 | - ) { # cas "LOST CONNECTION" |
|
| 76 | - $crash[] = $table; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - #$crash[] = 'test'; |
|
| 81 | - if ($crash) { |
|
| 82 | - ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 83 | - spip_log('crash des tables', 'err'); |
|
| 84 | - spip_log($crash, 'err'); |
|
| 85 | - } else { |
|
| 86 | - effacer_meta('message_crash_tables'); |
|
| 87 | - } |
|
| 66 | + if (spip_connect()) { |
|
| 67 | + include_spip('base/serial'); |
|
| 68 | + include_spip('base/auxiliaires'); |
|
| 69 | + $crash = []; |
|
| 70 | + foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 71 | + foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 72 | + if ( |
|
| 73 | + !sql_select('*', $table, '', '', '', 1) |
|
| 74 | + && !defined('spip_interdire_cache') |
|
| 75 | + ) { # cas "LOST CONNECTION" |
|
| 76 | + $crash[] = $table; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + #$crash[] = 'test'; |
|
| 81 | + if ($crash) { |
|
| 82 | + ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 83 | + spip_log('crash des tables', 'err'); |
|
| 84 | + spip_log($crash, 'err'); |
|
| 85 | + } else { |
|
| 86 | + effacer_meta('message_crash_tables'); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - return $crash; |
|
| 90 | - } |
|
| 89 | + return $crash; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return false; |
|
| 92 | + return false; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -105,16 +105,16 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function message_crash_tables() { |
| 108 | - if ($crash = verifier_crash_tables()) { |
|
| 109 | - return |
|
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . implode(', ', $crash) . '</tt><br />' |
|
| 112 | - . generer_form_ecrire( |
|
| 113 | - 'base_repair', |
|
| 114 | - _T('texte_crash_base'), |
|
| 115 | - '', |
|
| 116 | - _T('bouton_tenter_recuperation') |
|
| 117 | - ); |
|
| 118 | - } |
|
| 119 | - return ''; |
|
| 108 | + if ($crash = verifier_crash_tables()) { |
|
| 109 | + return |
|
| 110 | + '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | + . ' <tt>' . implode(', ', $crash) . '</tt><br />' |
|
| 112 | + . generer_form_ecrire( |
|
| 113 | + 'base_repair', |
|
| 114 | + _T('texte_crash_base'), |
|
| 115 | + '', |
|
| 116 | + _T('bouton_tenter_recuperation') |
|
| 117 | + ); |
|
| 118 | + } |
|
| 119 | + return ''; |
|
| 120 | 120 | } |
@@ -107,8 +107,8 @@ |
||
| 107 | 107 | function message_crash_tables() { |
| 108 | 108 | if ($crash = verifier_crash_tables()) { |
| 109 | 109 | return |
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . implode(', ', $crash) . '</tt><br />' |
|
| 110 | + '<strong>'._T('texte_recuperer_base').'</strong><br />' |
|
| 111 | + . ' <tt>'.implode(', ', $crash).'</tt><br />' |
|
| 112 | 112 | . generer_form_ecrire( |
| 113 | 113 | 'base_repair', |
| 114 | 114 | _T('texte_crash_base'), |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -31,35 +31,35 @@ discard block |
||
| 31 | 31 | * @return int |
| 32 | 32 | */ |
| 33 | 33 | function genie_mail_dist($t) { |
| 34 | - $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 35 | - $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 34 | + $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 35 | + $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 36 | 36 | |
| 37 | - $now = time(); |
|
| 38 | - if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) { |
|
| 39 | - ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now - (3600 * 24 * $jours_neuf))); |
|
| 40 | - } |
|
| 37 | + $now = time(); |
|
| 38 | + if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) { |
|
| 39 | + ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now - (3600 * 24 * $jours_neuf))); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $page = recuperer_fond( |
|
| 43 | - 'nouveautes', |
|
| 44 | - ['date' => $GLOBALS['meta']['dernier_envoi_neuf'], 'jours_neuf' => $jours_neuf], |
|
| 45 | - ['raw' => true] |
|
| 46 | - ); |
|
| 42 | + $page = recuperer_fond( |
|
| 43 | + 'nouveautes', |
|
| 44 | + ['date' => $GLOBALS['meta']['dernier_envoi_neuf'], 'jours_neuf' => $jours_neuf], |
|
| 45 | + ['raw' => true] |
|
| 46 | + ); |
|
| 47 | 47 | |
| 48 | - if (strlen(trim((string) $page['texte']))) { |
|
| 49 | - // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 50 | - $headers = ''; |
|
| 51 | - if (isset($page['entetes']) && (is_countable($page['entetes']) ? count($page['entetes']) : 0)) { |
|
| 52 | - foreach ($page['entetes'] as $k => $v) { |
|
| 53 | - $headers .= (strlen((string) $v) ? "$k: $v" : $k) . "\n"; |
|
| 54 | - } |
|
| 55 | - } |
|
| 48 | + if (strlen(trim((string) $page['texte']))) { |
|
| 49 | + // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 50 | + $headers = ''; |
|
| 51 | + if (isset($page['entetes']) && (is_countable($page['entetes']) ? count($page['entetes']) : 0)) { |
|
| 52 | + foreach ($page['entetes'] as $k => $v) { |
|
| 53 | + $headers .= (strlen((string) $v) ? "$k: $v" : $k) . "\n"; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - include_spip('inc/notifications'); |
|
| 58 | - notifications_envoyer_mails($adresse_neuf, $page['texte'], '', '', $headers); |
|
| 59 | - ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now)); |
|
| 60 | - } else { |
|
| 61 | - spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 62 | - } |
|
| 57 | + include_spip('inc/notifications'); |
|
| 58 | + notifications_envoyer_mails($adresse_neuf, $page['texte'], '', '', $headers); |
|
| 59 | + ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now)); |
|
| 60 | + } else { |
|
| 61 | + spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return 1; |
|
| 64 | + return 1; |
|
| 65 | 65 | } |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | $headers = ''; |
| 51 | 51 | if (isset($page['entetes']) && (is_countable($page['entetes']) ? count($page['entetes']) : 0)) { |
| 52 | 52 | foreach ($page['entetes'] as $k => $v) { |
| 53 | - $headers .= (strlen((string) $v) ? "$k: $v" : $k) . "\n"; |
|
| 53 | + $headers .= (strlen((string) $v) ? "$k: $v" : $k)."\n"; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -20,188 +20,188 @@ |
||
| 20 | 20 | // par souci de compatiilite). |
| 21 | 21 | |
| 22 | 22 | if (isset($GLOBALS['_INC_PUBLIC']) && $GLOBALS['_INC_PUBLIC']) { |
| 23 | - echo recuperer_fond($fond, $contexte_inclus, [], _request('connect') ?? ''); |
|
| 23 | + echo recuperer_fond($fond, $contexte_inclus, [], _request('connect') ?? ''); |
|
| 24 | 24 | } else { |
| 25 | - $GLOBALS['_INC_PUBLIC'] = 1; |
|
| 26 | - define('_PIPELINE_SUFFIX', test_espace_prive() ? '_prive' : ''); |
|
| 27 | - |
|
| 28 | - // Faut-il initialiser SPIP ? (oui dans le cas general) |
|
| 29 | - if (!defined('_DIR_RESTREINT_ABS')) { |
|
| 30 | - if ( |
|
| 31 | - defined('_DIR_RESTREINT') |
|
| 32 | - && @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 33 | - ) { |
|
| 34 | - include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 35 | - } else { |
|
| 36 | - die('inc_version absent ?'); |
|
| 37 | - } |
|
| 38 | - } // $fond defini dans le fichier d'appel ? |
|
| 39 | - |
|
| 40 | - else { |
|
| 41 | - if (isset($fond) && !_request('fond')) { |
|
| 42 | - } // fond demande dans l'url par page=xxxx ? |
|
| 43 | - else { |
|
| 44 | - if (isset($_GET[_SPIP_PAGE])) { |
|
| 45 | - $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 46 | - |
|
| 47 | - // Securite |
|
| 48 | - if ( |
|
| 49 | - strstr($fond, '/') |
|
| 50 | - && !(isset($GLOBALS['visiteur_session']) && include_spip('inc/autoriser') && autoriser('webmestre')) |
|
| 51 | - ) { |
|
| 52 | - include_spip('inc/minipres'); |
|
| 53 | - echo minipres(); |
|
| 54 | - exit; |
|
| 55 | - } |
|
| 56 | - // l'argument Page a priorite sur l'argument action |
|
| 57 | - // le cas se presente a cause des RewriteRule d'Apache |
|
| 58 | - // qui permettent d'ajouter un argument dans la QueryString |
|
| 59 | - // mais pas d'en retirer un en conservant les autres. |
|
| 60 | - if (isset($_GET['action']) && $_GET['action'] === $fond) { |
|
| 61 | - unset($_GET['action']); |
|
| 62 | - } |
|
| 63 | - # sinon, fond par defaut |
|
| 64 | - } else { |
|
| 65 | - // sinon fond par defaut (cf. assembler.php) |
|
| 66 | - $fond = pipeline('detecter_fond_par_defaut', ''); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $tableau_des_temps = []; |
|
| 72 | - |
|
| 73 | - // Particularites de certains squelettes |
|
| 74 | - if ($fond == 'login') { |
|
| 75 | - $forcer_lang = true; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if ( |
|
| 79 | - isset($forcer_lang) && $forcer_lang && $forcer_lang !== 'non' |
|
| 80 | - && !_request('action') |
|
| 81 | - && $_SERVER['REQUEST_METHOD'] != 'POST' |
|
| 82 | - ) { |
|
| 83 | - include_spip('inc/lang'); |
|
| 84 | - verifier_lang_url(); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $lang = isset($_GET['lang']) ? lang_select($_GET['lang']) : ''; |
|
| 88 | - |
|
| 89 | - // Charger l'aiguilleur des traitements derogatoires |
|
| 90 | - // (action en base SQL, formulaires CVT, AJax) |
|
| 91 | - if (_request('action') || _request('var_ajax') || _request('formulaire_action')) { |
|
| 92 | - include_spip('public/aiguiller'); |
|
| 93 | - if ( |
|
| 94 | - // cas des appels actions ?action=xxx |
|
| 95 | - traiter_appels_actions() |
|
| 96 | - // cas des hits ajax sur les inclusions ajax |
|
| 97 | - || traiter_appels_inclusions_ajax() |
|
| 98 | - // cas des formulaires charger/verifier/traiter |
|
| 99 | - || traiter_formulaires_dynamiques() |
|
| 100 | - ) { |
|
| 101 | - // lancer les taches sur affichage final, comme le cron |
|
| 102 | - // mais sans rien afficher |
|
| 103 | - $GLOBALS['html'] = false; // ne rien afficher |
|
| 104 | - pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 105 | - exit; // le hit est fini ! |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // Il y a du texte a produire, charger le metteur en page |
|
| 110 | - include_spip('public/assembler'); |
|
| 111 | - $page = assembler($fond, _request('connect') ?? ''); |
|
| 112 | - |
|
| 113 | - if (isset($page['status'])) { |
|
| 114 | - include_spip('inc/headers'); |
|
| 115 | - http_response_code($page['status']); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // Content-Type ? |
|
| 119 | - if (!isset($page['entetes']['Content-Type'])) { |
|
| 120 | - $charset = $GLOBALS['meta']['charset'] ?? 'utf-8'; |
|
| 121 | - $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 122 | - $html = true; |
|
| 123 | - } else { |
|
| 124 | - $html = preg_match(',^\s*text/html,', (string) $page['entetes']['Content-Type']); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - // Tester si on est admin et il y a des choses supplementaires a dire |
|
| 128 | - // type tableau pour y mettre des choses au besoin. |
|
| 129 | - $debug = (_request('var_mode') == 'debug' || $tableau_des_temps) ? [1] : []; |
|
| 130 | - |
|
| 131 | - // affiche-t-on les boutons d'administration ? voir f_admin() |
|
| 132 | - $affiche_boutons_admin = ($html && ( |
|
| 133 | - isset($_COOKIE['spip_admin']) && (!isset($flag_preserver) || !$flag_preserver) |
|
| 134 | - || $debug && include_spip('inc/autoriser') && autoriser('debug') |
|
| 135 | - || defined('_VAR_PREVIEW') && _VAR_PREVIEW) |
|
| 136 | - ); |
|
| 137 | - |
|
| 138 | - if ($affiche_boutons_admin) { |
|
| 139 | - include_spip('balise/formulaire_admin'); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - // Execution de la page calculee |
|
| 144 | - |
|
| 145 | - // traitements sur les entetes avant envoi |
|
| 146 | - // peut servir pour le plugin de stats |
|
| 147 | - $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - // eval $page et affecte $res |
|
| 151 | - include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 152 | - envoyer_entetes($page['entetes']); |
|
| 153 | - if ($res === false) { |
|
| 154 | - include_spip('inc/autoriser'); |
|
| 155 | - $err = _T('zbug_erreur_execution_page'); |
|
| 156 | - if (autoriser('webmestre')) { |
|
| 157 | - $err .= "\n<hr />\n" |
|
| 158 | - . highlight_string($page['codephp'], true) |
|
| 159 | - . "\n<hr />\n"; |
|
| 160 | - } |
|
| 161 | - $msg = [$err]; |
|
| 162 | - erreur_squelette($msg); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // |
|
| 166 | - // Envoyer le resultat apres post-traitements |
|
| 167 | - // |
|
| 168 | - // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
|
| 169 | - // cf. public/assembler.php) |
|
| 170 | - echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 171 | - |
|
| 172 | - if ($lang) { |
|
| 173 | - lang_select(); |
|
| 174 | - } |
|
| 175 | - // l'affichage de la page a pu lever des erreurs (inclusion manquante) |
|
| 176 | - // il faut tester a nouveau |
|
| 177 | - $debug = (_request('var_mode') == 'debug' || $tableau_des_temps) ? [1] : []; |
|
| 178 | - |
|
| 179 | - // Appel au debusqueur en cas d'erreurs ou de demande de trace |
|
| 180 | - // at last |
|
| 181 | - if ($debug) { |
|
| 182 | - // en cas d'erreur, retester l'affichage |
|
| 183 | - if ($html && ($affiche_boutons_admin || $debug)) { |
|
| 184 | - $var_mode_affiche = _request('var_mode_affiche'); |
|
| 185 | - $var_mode_objet = _request('var_mode_objet'); |
|
| 186 | - $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ''); |
|
| 187 | - echo erreur_squelette(false); |
|
| 188 | - } |
|
| 189 | - } else { |
|
| 190 | - if ( |
|
| 191 | - isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 192 | - && $GLOBALS['meta']['date_prochain_postdate'] <= time() |
|
| 193 | - ) { |
|
| 194 | - include_spip('inc/rubriques'); |
|
| 195 | - calculer_prochain_postdate(true); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // Effectuer une tache de fond ? |
|
| 199 | - // si _DIRECT_CRON_FORCE est present, on force l'appel |
|
| 200 | - if (defined('_DIRECT_CRON_FORCE')) { |
|
| 201 | - cron(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - // sauver le cache chemin si necessaire |
|
| 205 | - save_path_cache(); |
|
| 206 | - } |
|
| 25 | + $GLOBALS['_INC_PUBLIC'] = 1; |
|
| 26 | + define('_PIPELINE_SUFFIX', test_espace_prive() ? '_prive' : ''); |
|
| 27 | + |
|
| 28 | + // Faut-il initialiser SPIP ? (oui dans le cas general) |
|
| 29 | + if (!defined('_DIR_RESTREINT_ABS')) { |
|
| 30 | + if ( |
|
| 31 | + defined('_DIR_RESTREINT') |
|
| 32 | + && @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 33 | + ) { |
|
| 34 | + include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 35 | + } else { |
|
| 36 | + die('inc_version absent ?'); |
|
| 37 | + } |
|
| 38 | + } // $fond defini dans le fichier d'appel ? |
|
| 39 | + |
|
| 40 | + else { |
|
| 41 | + if (isset($fond) && !_request('fond')) { |
|
| 42 | + } // fond demande dans l'url par page=xxxx ? |
|
| 43 | + else { |
|
| 44 | + if (isset($_GET[_SPIP_PAGE])) { |
|
| 45 | + $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 46 | + |
|
| 47 | + // Securite |
|
| 48 | + if ( |
|
| 49 | + strstr($fond, '/') |
|
| 50 | + && !(isset($GLOBALS['visiteur_session']) && include_spip('inc/autoriser') && autoriser('webmestre')) |
|
| 51 | + ) { |
|
| 52 | + include_spip('inc/minipres'); |
|
| 53 | + echo minipres(); |
|
| 54 | + exit; |
|
| 55 | + } |
|
| 56 | + // l'argument Page a priorite sur l'argument action |
|
| 57 | + // le cas se presente a cause des RewriteRule d'Apache |
|
| 58 | + // qui permettent d'ajouter un argument dans la QueryString |
|
| 59 | + // mais pas d'en retirer un en conservant les autres. |
|
| 60 | + if (isset($_GET['action']) && $_GET['action'] === $fond) { |
|
| 61 | + unset($_GET['action']); |
|
| 62 | + } |
|
| 63 | + # sinon, fond par defaut |
|
| 64 | + } else { |
|
| 65 | + // sinon fond par defaut (cf. assembler.php) |
|
| 66 | + $fond = pipeline('detecter_fond_par_defaut', ''); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $tableau_des_temps = []; |
|
| 72 | + |
|
| 73 | + // Particularites de certains squelettes |
|
| 74 | + if ($fond == 'login') { |
|
| 75 | + $forcer_lang = true; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if ( |
|
| 79 | + isset($forcer_lang) && $forcer_lang && $forcer_lang !== 'non' |
|
| 80 | + && !_request('action') |
|
| 81 | + && $_SERVER['REQUEST_METHOD'] != 'POST' |
|
| 82 | + ) { |
|
| 83 | + include_spip('inc/lang'); |
|
| 84 | + verifier_lang_url(); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $lang = isset($_GET['lang']) ? lang_select($_GET['lang']) : ''; |
|
| 88 | + |
|
| 89 | + // Charger l'aiguilleur des traitements derogatoires |
|
| 90 | + // (action en base SQL, formulaires CVT, AJax) |
|
| 91 | + if (_request('action') || _request('var_ajax') || _request('formulaire_action')) { |
|
| 92 | + include_spip('public/aiguiller'); |
|
| 93 | + if ( |
|
| 94 | + // cas des appels actions ?action=xxx |
|
| 95 | + traiter_appels_actions() |
|
| 96 | + // cas des hits ajax sur les inclusions ajax |
|
| 97 | + || traiter_appels_inclusions_ajax() |
|
| 98 | + // cas des formulaires charger/verifier/traiter |
|
| 99 | + || traiter_formulaires_dynamiques() |
|
| 100 | + ) { |
|
| 101 | + // lancer les taches sur affichage final, comme le cron |
|
| 102 | + // mais sans rien afficher |
|
| 103 | + $GLOBALS['html'] = false; // ne rien afficher |
|
| 104 | + pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 105 | + exit; // le hit est fini ! |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // Il y a du texte a produire, charger le metteur en page |
|
| 110 | + include_spip('public/assembler'); |
|
| 111 | + $page = assembler($fond, _request('connect') ?? ''); |
|
| 112 | + |
|
| 113 | + if (isset($page['status'])) { |
|
| 114 | + include_spip('inc/headers'); |
|
| 115 | + http_response_code($page['status']); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // Content-Type ? |
|
| 119 | + if (!isset($page['entetes']['Content-Type'])) { |
|
| 120 | + $charset = $GLOBALS['meta']['charset'] ?? 'utf-8'; |
|
| 121 | + $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 122 | + $html = true; |
|
| 123 | + } else { |
|
| 124 | + $html = preg_match(',^\s*text/html,', (string) $page['entetes']['Content-Type']); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + // Tester si on est admin et il y a des choses supplementaires a dire |
|
| 128 | + // type tableau pour y mettre des choses au besoin. |
|
| 129 | + $debug = (_request('var_mode') == 'debug' || $tableau_des_temps) ? [1] : []; |
|
| 130 | + |
|
| 131 | + // affiche-t-on les boutons d'administration ? voir f_admin() |
|
| 132 | + $affiche_boutons_admin = ($html && ( |
|
| 133 | + isset($_COOKIE['spip_admin']) && (!isset($flag_preserver) || !$flag_preserver) |
|
| 134 | + || $debug && include_spip('inc/autoriser') && autoriser('debug') |
|
| 135 | + || defined('_VAR_PREVIEW') && _VAR_PREVIEW) |
|
| 136 | + ); |
|
| 137 | + |
|
| 138 | + if ($affiche_boutons_admin) { |
|
| 139 | + include_spip('balise/formulaire_admin'); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + // Execution de la page calculee |
|
| 144 | + |
|
| 145 | + // traitements sur les entetes avant envoi |
|
| 146 | + // peut servir pour le plugin de stats |
|
| 147 | + $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + // eval $page et affecte $res |
|
| 151 | + include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 152 | + envoyer_entetes($page['entetes']); |
|
| 153 | + if ($res === false) { |
|
| 154 | + include_spip('inc/autoriser'); |
|
| 155 | + $err = _T('zbug_erreur_execution_page'); |
|
| 156 | + if (autoriser('webmestre')) { |
|
| 157 | + $err .= "\n<hr />\n" |
|
| 158 | + . highlight_string($page['codephp'], true) |
|
| 159 | + . "\n<hr />\n"; |
|
| 160 | + } |
|
| 161 | + $msg = [$err]; |
|
| 162 | + erreur_squelette($msg); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // |
|
| 166 | + // Envoyer le resultat apres post-traitements |
|
| 167 | + // |
|
| 168 | + // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
|
| 169 | + // cf. public/assembler.php) |
|
| 170 | + echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 171 | + |
|
| 172 | + if ($lang) { |
|
| 173 | + lang_select(); |
|
| 174 | + } |
|
| 175 | + // l'affichage de la page a pu lever des erreurs (inclusion manquante) |
|
| 176 | + // il faut tester a nouveau |
|
| 177 | + $debug = (_request('var_mode') == 'debug' || $tableau_des_temps) ? [1] : []; |
|
| 178 | + |
|
| 179 | + // Appel au debusqueur en cas d'erreurs ou de demande de trace |
|
| 180 | + // at last |
|
| 181 | + if ($debug) { |
|
| 182 | + // en cas d'erreur, retester l'affichage |
|
| 183 | + if ($html && ($affiche_boutons_admin || $debug)) { |
|
| 184 | + $var_mode_affiche = _request('var_mode_affiche'); |
|
| 185 | + $var_mode_objet = _request('var_mode_objet'); |
|
| 186 | + $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ''); |
|
| 187 | + echo erreur_squelette(false); |
|
| 188 | + } |
|
| 189 | + } else { |
|
| 190 | + if ( |
|
| 191 | + isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 192 | + && $GLOBALS['meta']['date_prochain_postdate'] <= time() |
|
| 193 | + ) { |
|
| 194 | + include_spip('inc/rubriques'); |
|
| 195 | + calculer_prochain_postdate(true); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // Effectuer une tache de fond ? |
|
| 199 | + // si _DIRECT_CRON_FORCE est present, on force l'appel |
|
| 200 | + if (defined('_DIRECT_CRON_FORCE')) { |
|
| 201 | + cron(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + // sauver le cache chemin si necessaire |
|
| 205 | + save_path_cache(); |
|
| 206 | + } |
|
| 207 | 207 | } |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | if (!defined('_DIR_RESTREINT_ABS')) { |
| 30 | 30 | if ( |
| 31 | 31 | defined('_DIR_RESTREINT') |
| 32 | - && @file_exists(_ROOT_RESTREINT . 'inc_version.php') |
|
| 32 | + && @file_exists(_ROOT_RESTREINT.'inc_version.php') |
|
| 33 | 33 | ) { |
| 34 | - include_once _ROOT_RESTREINT . 'inc_version.php'; |
|
| 34 | + include_once _ROOT_RESTREINT.'inc_version.php'; |
|
| 35 | 35 | } else { |
| 36 | 36 | die('inc_version absent ?'); |
| 37 | 37 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } // fond demande dans l'url par page=xxxx ? |
| 43 | 43 | else { |
| 44 | 44 | if (isset($_GET[_SPIP_PAGE])) { |
| 45 | - $fond = (string)$_GET[_SPIP_PAGE]; |
|
| 45 | + $fond = (string) $_GET[_SPIP_PAGE]; |
|
| 46 | 46 | |
| 47 | 47 | // Securite |
| 48 | 48 | if ( |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | // lancer les taches sur affichage final, comme le cron |
| 102 | 102 | // mais sans rien afficher |
| 103 | 103 | $GLOBALS['html'] = false; // ne rien afficher |
| 104 | - pipeline('affichage_final' . _PIPELINE_SUFFIX, ''); |
|
| 104 | + pipeline('affichage_final'._PIPELINE_SUFFIX, ''); |
|
| 105 | 105 | exit; // le hit est fini ! |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | // Content-Type ? |
| 119 | 119 | if (!isset($page['entetes']['Content-Type'])) { |
| 120 | 120 | $charset = $GLOBALS['meta']['charset'] ?? 'utf-8'; |
| 121 | - $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset; |
|
| 121 | + $page['entetes']['Content-Type'] = 'text/html; charset='.$charset; |
|
| 122 | 122 | $html = true; |
| 123 | 123 | } else { |
| 124 | 124 | $html = preg_match(',^\s*text/html,', (string) $page['entetes']['Content-Type']); |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | // traitements sur les entetes avant envoi |
| 146 | 146 | // peut servir pour le plugin de stats |
| 147 | - $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']); |
|
| 147 | + $page['entetes'] = pipeline('affichage_entetes_final'._PIPELINE_SUFFIX, $page['entetes']); |
|
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | // eval $page et affecte $res |
| 151 | - include _ROOT_RESTREINT . 'public/evaluer_page.php'; |
|
| 151 | + include _ROOT_RESTREINT.'public/evaluer_page.php'; |
|
| 152 | 152 | envoyer_entetes($page['entetes']); |
| 153 | 153 | if ($res === false) { |
| 154 | 154 | include_spip('inc/autoriser'); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | // |
| 168 | 168 | // (c'est ici qu'on fait var_recherche, validation, boutons d'admin, |
| 169 | 169 | // cf. public/assembler.php) |
| 170 | - echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']); |
|
| 170 | + echo pipeline('affichage_final'._PIPELINE_SUFFIX, $page['texte']); |
|
| 171 | 171 | |
| 172 | 172 | if ($lang) { |
| 173 | 173 | lang_select(); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | if ($html && ($affiche_boutons_admin || $debug)) { |
| 184 | 184 | $var_mode_affiche = _request('var_mode_affiche'); |
| 185 | 185 | $var_mode_objet = _request('var_mode_objet'); |
| 186 | - $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ''); |
|
| 186 | + $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet.'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : ''); |
|
| 187 | 187 | echo erreur_squelette(false); |
| 188 | 188 | } |
| 189 | 189 | } else { |
@@ -311,7 +311,7 @@ |
||
| 311 | 311 | foreach ($erreurs as $k => $v) { |
| 312 | 312 | if (is_string($v) && strlen(trim($v)) && !str_starts_with((string) $k, '_')) { |
| 313 | 313 | // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
| 314 | - $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 314 | + $valeurs['erreurs'][$k] = "<span role='alert'>".$erreurs[$k].'</span>'; |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Formulaires |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/filtres'); |
@@ -34,26 +34,26 @@ discard block |
||
| 34 | 34 | * @see spip_htmlspecialchars() |
| 35 | 35 | */ |
| 36 | 36 | function protege_champ(mixed $valeur, $max_prof = 128) { |
| 37 | - if (is_array($valeur)) { |
|
| 38 | - if ($max_prof > 0) { |
|
| 39 | - return array_map( |
|
| 40 | - fn($v) => protege_champ($v, $max_prof - 1), |
|
| 41 | - $valeur |
|
| 42 | - ); |
|
| 43 | - } |
|
| 44 | - // si on dépasse la prof max on tronque |
|
| 45 | - return []; |
|
| 46 | - } elseif ($valeur === null) { |
|
| 47 | - return $valeur; |
|
| 48 | - } elseif (is_bool($valeur)) { |
|
| 49 | - return $valeur ? '1' : ''; |
|
| 50 | - } elseif (is_string($valeur) && $valeur) { |
|
| 51 | - if (strpbrk($valeur, "&\"'<>") !== false) { |
|
| 52 | - return spip_htmlspecialchars($valeur, ENT_QUOTES); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $valeur; |
|
| 37 | + if (is_array($valeur)) { |
|
| 38 | + if ($max_prof > 0) { |
|
| 39 | + return array_map( |
|
| 40 | + fn($v) => protege_champ($v, $max_prof - 1), |
|
| 41 | + $valeur |
|
| 42 | + ); |
|
| 43 | + } |
|
| 44 | + // si on dépasse la prof max on tronque |
|
| 45 | + return []; |
|
| 46 | + } elseif ($valeur === null) { |
|
| 47 | + return $valeur; |
|
| 48 | + } elseif (is_bool($valeur)) { |
|
| 49 | + return $valeur ? '1' : ''; |
|
| 50 | + } elseif (is_string($valeur) && $valeur) { |
|
| 51 | + if (strpbrk($valeur, "&\"'<>") !== false) { |
|
| 52 | + return spip_htmlspecialchars($valeur, ENT_QUOTES); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $valeur; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * - false : pas de squelette trouvé |
| 68 | 68 | **/ |
| 69 | 69 | function existe_formulaire($form) { |
| 70 | - $form = str_starts_with($form, 'FORMULAIRE_') ? strtolower(substr($form, 11)) : strtolower($form); |
|
| 70 | + $form = str_starts_with($form, 'FORMULAIRE_') ? strtolower(substr($form, 11)) : strtolower($form); |
|
| 71 | 71 | |
| 72 | - if (!$form) { |
|
| 73 | - return ''; |
|
| 74 | - } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 72 | + if (!$form) { |
|
| 73 | + return ''; |
|
| 74 | + } // on ne sait pas, le nom du formulaire n'est pas fourni ici |
|
| 75 | 75 | |
| 76 | - return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 76 | + return trouver_fond($form, 'formulaires/') ? $form : false; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -82,30 +82,30 @@ discard block |
||
| 82 | 82 | * @return false|array |
| 83 | 83 | */ |
| 84 | 84 | function test_formulaire_inclus_par_modele() { |
| 85 | - $trace = debug_backtrace(0, 20); |
|
| 86 | - $trace_fonctions = array_column($trace, 'function'); |
|
| 87 | - $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 88 | - |
|
| 89 | - // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 90 | - if ( |
|
| 91 | - function_exists('arguments_balise_dyn_depuis_modele') |
|
| 92 | - && ($form = arguments_balise_dyn_depuis_modele(null, 'read')) |
|
| 93 | - && in_array('balise_formulaire__dyn', $trace_fonctions) |
|
| 94 | - ) { |
|
| 95 | - $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 96 | - if ($trace[$k]['args'][0] === $form) { |
|
| 97 | - return $trace[$k]['args']; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 102 | - // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 103 | - if (in_array('eval', $trace_fonctions) && in_array('inclure_modele', $trace_fonctions)) { |
|
| 104 | - $k = array_search('inclure_modele', $trace_fonctions); |
|
| 105 | - // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 106 | - return $trace[$k - 1]['args'][1]['args']; |
|
| 107 | - } |
|
| 108 | - return false; |
|
| 85 | + $trace = debug_backtrace(0, 20); |
|
| 86 | + $trace_fonctions = array_column($trace, 'function'); |
|
| 87 | + $trace_fonctions = array_map('strtolower', $trace_fonctions); |
|
| 88 | + |
|
| 89 | + // regarder si un flag a ete leve juste avant l'appel de balise_FORMULAIRE_dyn |
|
| 90 | + if ( |
|
| 91 | + function_exists('arguments_balise_dyn_depuis_modele') |
|
| 92 | + && ($form = arguments_balise_dyn_depuis_modele(null, 'read')) |
|
| 93 | + && in_array('balise_formulaire__dyn', $trace_fonctions) |
|
| 94 | + ) { |
|
| 95 | + $k = array_search('balise_formulaire__dyn', $trace_fonctions); |
|
| 96 | + if ($trace[$k]['args'][0] === $form) { |
|
| 97 | + return $trace[$k]['args']; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // fallback qui ne repose pas sur le flag lie a l'analyse de contexte_compil, |
|
| 102 | + // mais ne marche pas si executer_balise_dynamique est appelee via du php dans le squelette |
|
| 103 | + if (in_array('eval', $trace_fonctions) && in_array('inclure_modele', $trace_fonctions)) { |
|
| 104 | + $k = array_search('inclure_modele', $trace_fonctions); |
|
| 105 | + // les arguments de recuperer_fond() passes par inclure_modele() |
|
| 106 | + return $trace[$k - 1]['args'][1]['args']; |
|
| 107 | + } |
|
| 108 | + return false; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -120,19 +120,19 @@ discard block |
||
| 120 | 120 | **/ |
| 121 | 121 | function balise_FORMULAIRE__dist($p) { |
| 122 | 122 | |
| 123 | - // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 124 | - // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 125 | - if (existe_formulaire($p->nom_champ) === false) { |
|
| 126 | - $p->code = "''"; |
|
| 127 | - $p->interdire_scripts = false; |
|
| 123 | + // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. |
|
| 124 | + // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer |
|
| 125 | + if (existe_formulaire($p->nom_champ) === false) { |
|
| 126 | + $p->code = "''"; |
|
| 127 | + $p->interdire_scripts = false; |
|
| 128 | 128 | |
| 129 | - return $p; |
|
| 130 | - } |
|
| 129 | + return $p; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - // sinon renvoyer un code php dynamique |
|
| 133 | - $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 132 | + // sinon renvoyer un code php dynamique |
|
| 133 | + $p = calculer_balise_dynamique($p, $p->nom_champ, []); |
|
| 134 | 134 | |
| 135 | - return $p; |
|
| 135 | + return $p; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -152,17 +152,17 @@ discard block |
||
| 152 | 152 | * - string : texte à afficher directement |
| 153 | 153 | */ |
| 154 | 154 | function balise_FORMULAIRE__dyn($form, ...$args) { |
| 155 | - $form = existe_formulaire($form); |
|
| 156 | - if (!$form) { |
|
| 157 | - return ''; |
|
| 158 | - } |
|
| 155 | + $form = existe_formulaire($form); |
|
| 156 | + if (!$form) { |
|
| 157 | + return ''; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 161 | - if (!is_array($contexte)) { |
|
| 162 | - return $contexte; |
|
| 163 | - } |
|
| 160 | + $contexte = balise_FORMULAIRE__contexte($form, $args); |
|
| 161 | + if (!is_array($contexte)) { |
|
| 162 | + return $contexte; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - return ["formulaires/$form", 3600, $contexte]; |
|
| 165 | + return ["formulaires/$form", 3600, $contexte]; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -177,134 +177,134 @@ discard block |
||
| 177 | 177 | * string: Formulaire non applicable (message d’explication) |
| 178 | 178 | **/ |
| 179 | 179 | function balise_FORMULAIRE__contexte($form, $args) { |
| 180 | - // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 181 | - // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 182 | - // si poste, on recupere les erreurs |
|
| 183 | - |
|
| 184 | - $je_suis_poste = false; |
|
| 185 | - if ( |
|
| 186 | - ($post_form = _request('formulaire_action')) |
|
| 187 | - && $post_form == $form |
|
| 188 | - && ($p = _request('formulaire_action_args')) |
|
| 189 | - && is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 190 | - ) { |
|
| 191 | - // enlever le faux attribut de langue masque |
|
| 192 | - array_shift($p); |
|
| 193 | - if (formulaire__identifier($form, $args, $p)) { |
|
| 194 | - $je_suis_poste = true; |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - $editable = true; |
|
| 199 | - $erreurs = $post = []; |
|
| 200 | - if ($je_suis_poste) { |
|
| 201 | - $post = traiter_formulaires_dynamiques(true); |
|
| 202 | - $e = "erreurs_$form"; |
|
| 203 | - $erreurs = $post[$e] ?? []; |
|
| 204 | - $editable = "editable_$form"; |
|
| 205 | - $editable = (!isset($post[$e])) |
|
| 206 | - || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 207 | - || (isset($post[$editable]) && $post[$editable]); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 211 | - |
|
| 212 | - // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 213 | - // C'est plus fort qu'editable qui est gere par le squelette |
|
| 214 | - // Idealement $valeur doit etre alors un message explicatif. |
|
| 215 | - if (!is_array($valeurs)) { |
|
| 216 | - return is_string($valeurs) ? $valeurs : ''; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 220 | - // ou une action vide si elle ne sert pas |
|
| 221 | - $action = $valeurs['action'] ?? self('&', true); |
|
| 222 | - // bug IEx : si action finit par / |
|
| 223 | - // IE croit que le <form ... action=../ > est autoferme |
|
| 224 | - if (str_ends_with((string) $action, '/')) { |
|
| 225 | - // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 226 | - $action .= '#'; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - // recuperer la saisie en cours si erreurs |
|
| 230 | - // seulement si c'est ce formulaire qui est poste |
|
| 231 | - // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 232 | - $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 233 | - foreach (array_keys($valeurs) as $champ) { |
|
| 234 | - $champ = (string) $champ; |
|
| 235 | - if ($champ[0] !== '_' && !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 236 | - if ($dispo && ($v = _request($champ)) !== null) { |
|
| 237 | - $valeurs[$champ] = $v; |
|
| 238 | - } |
|
| 239 | - // nettoyer l'url des champs qui vont etre saisis |
|
| 240 | - if ($action) { |
|
| 241 | - $action = parametre_url($action, $champ, ''); |
|
| 242 | - } |
|
| 243 | - // proteger les ' et les " dans les champs que l'on va injecter |
|
| 244 | - $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - if ($action) { |
|
| 249 | - // nettoyer l'url |
|
| 250 | - $action = parametre_url($action, 'formulaire_action', ''); |
|
| 251 | - $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 252 | - $action = parametre_url($action, 'formulaire_action_sign', ''); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - // empiler la lang en tant que premier argument implicite du CVT |
|
| 256 | - // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 257 | - array_unshift($args, $GLOBALS['spip_lang']); |
|
| 258 | - |
|
| 259 | - $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 260 | - $valeurs['erreurs'] = $erreurs; |
|
| 261 | - $valeurs['action'] = $action; |
|
| 262 | - $valeurs['form'] = $form; |
|
| 263 | - |
|
| 264 | - $valeurs['formulaire_sign'] = ''; |
|
| 265 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 266 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 267 | - $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 268 | - $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if (!isset($valeurs['id'])) { |
|
| 272 | - $valeurs['id'] = 'new'; |
|
| 273 | - } |
|
| 274 | - // editable peut venir de charger() ou de traiter() sinon |
|
| 275 | - if (!isset($valeurs['editable'])) { |
|
| 276 | - $valeurs['editable'] = $editable; |
|
| 277 | - } |
|
| 278 | - // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 279 | - $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 280 | - |
|
| 281 | - if ($je_suis_poste) { |
|
| 282 | - $valeurs['message_erreur'] = ''; |
|
| 283 | - if (isset($erreurs['message_erreur'])) { |
|
| 284 | - $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - $valeurs['message_ok'] = ''; |
|
| 288 | - if (isset($post["message_ok_$form"])) { |
|
| 289 | - $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 290 | - } elseif (isset($erreurs['message_ok'])) { |
|
| 291 | - $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 295 | - // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 296 | - // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 297 | - if (html5_permis()) { |
|
| 298 | - foreach ($erreurs as $k => $v) { |
|
| 299 | - if (is_string($v) && strlen(trim($v)) && !str_starts_with((string) $k, '_')) { |
|
| 300 | - // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 301 | - $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - return $valeurs; |
|
| 180 | + // tester si ce formulaire vient d'etre poste (memes arguments) |
|
| 181 | + // pour ne pas confondre 2 #FORMULAIRES_XX identiques sur une meme page |
|
| 182 | + // si poste, on recupere les erreurs |
|
| 183 | + |
|
| 184 | + $je_suis_poste = false; |
|
| 185 | + if ( |
|
| 186 | + ($post_form = _request('formulaire_action')) |
|
| 187 | + && $post_form == $form |
|
| 188 | + && ($p = _request('formulaire_action_args')) |
|
| 189 | + && is_array($p = decoder_contexte_ajax($p, $post_form)) |
|
| 190 | + ) { |
|
| 191 | + // enlever le faux attribut de langue masque |
|
| 192 | + array_shift($p); |
|
| 193 | + if (formulaire__identifier($form, $args, $p)) { |
|
| 194 | + $je_suis_poste = true; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + $editable = true; |
|
| 199 | + $erreurs = $post = []; |
|
| 200 | + if ($je_suis_poste) { |
|
| 201 | + $post = traiter_formulaires_dynamiques(true); |
|
| 202 | + $e = "erreurs_$form"; |
|
| 203 | + $erreurs = $post[$e] ?? []; |
|
| 204 | + $editable = "editable_$form"; |
|
| 205 | + $editable = (!isset($post[$e])) |
|
| 206 | + || (is_countable($erreurs) ? count($erreurs) : 0) |
|
| 207 | + || (isset($post[$editable]) && $post[$editable]); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $valeurs = formulaire__charger($form, $args, $je_suis_poste); |
|
| 211 | + |
|
| 212 | + // si $valeurs n'est pas un tableau, le formulaire n'est pas applicable |
|
| 213 | + // C'est plus fort qu'editable qui est gere par le squelette |
|
| 214 | + // Idealement $valeur doit etre alors un message explicatif. |
|
| 215 | + if (!is_array($valeurs)) { |
|
| 216 | + return is_string($valeurs) ? $valeurs : ''; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // charger peut passer une action si le formulaire ne tourne pas sur self() |
|
| 220 | + // ou une action vide si elle ne sert pas |
|
| 221 | + $action = $valeurs['action'] ?? self('&', true); |
|
| 222 | + // bug IEx : si action finit par / |
|
| 223 | + // IE croit que le <form ... action=../ > est autoferme |
|
| 224 | + if (str_ends_with((string) $action, '/')) { |
|
| 225 | + // on ajoute une ancre pour feinter IE, au pire ca tue l'ancre qui finit par un / |
|
| 226 | + $action .= '#'; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // recuperer la saisie en cours si erreurs |
|
| 230 | + // seulement si c'est ce formulaire qui est poste |
|
| 231 | + // ou si on le demande explicitement par le parametre _forcer_request = true |
|
| 232 | + $dispo = ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])); |
|
| 233 | + foreach (array_keys($valeurs) as $champ) { |
|
| 234 | + $champ = (string) $champ; |
|
| 235 | + if ($champ[0] !== '_' && !in_array($champ, ['message_ok', 'message_erreur', 'editable'])) { |
|
| 236 | + if ($dispo && ($v = _request($champ)) !== null) { |
|
| 237 | + $valeurs[$champ] = $v; |
|
| 238 | + } |
|
| 239 | + // nettoyer l'url des champs qui vont etre saisis |
|
| 240 | + if ($action) { |
|
| 241 | + $action = parametre_url($action, $champ, ''); |
|
| 242 | + } |
|
| 243 | + // proteger les ' et les " dans les champs que l'on va injecter |
|
| 244 | + $valeurs[$champ] = protege_champ($valeurs[$champ]); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + if ($action) { |
|
| 249 | + // nettoyer l'url |
|
| 250 | + $action = parametre_url($action, 'formulaire_action', ''); |
|
| 251 | + $action = parametre_url($action, 'formulaire_action_args', ''); |
|
| 252 | + $action = parametre_url($action, 'formulaire_action_sign', ''); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + // empiler la lang en tant que premier argument implicite du CVT |
|
| 256 | + // pour permettre de la restaurer au moment du Verifier et du Traiter |
|
| 257 | + array_unshift($args, $GLOBALS['spip_lang']); |
|
| 258 | + |
|
| 259 | + $valeurs['formulaire_args'] = encoder_contexte_ajax($args, $form); |
|
| 260 | + $valeurs['erreurs'] = $erreurs; |
|
| 261 | + $valeurs['action'] = $action; |
|
| 262 | + $valeurs['form'] = $form; |
|
| 263 | + |
|
| 264 | + $valeurs['formulaire_sign'] = ''; |
|
| 265 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 266 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 267 | + $secu = $securiser_action($valeurs['form'], $valeurs['formulaire_args'], '', -1); |
|
| 268 | + $valeurs['formulaire_sign'] = $secu['hash']; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if (!isset($valeurs['id'])) { |
|
| 272 | + $valeurs['id'] = 'new'; |
|
| 273 | + } |
|
| 274 | + // editable peut venir de charger() ou de traiter() sinon |
|
| 275 | + if (!isset($valeurs['editable'])) { |
|
| 276 | + $valeurs['editable'] = $editable; |
|
| 277 | + } |
|
| 278 | + // dans tous les cas, renvoyer un espace ou vide (et pas un booleen) |
|
| 279 | + $valeurs['editable'] = ($valeurs['editable'] ? ' ' : ''); |
|
| 280 | + |
|
| 281 | + if ($je_suis_poste) { |
|
| 282 | + $valeurs['message_erreur'] = ''; |
|
| 283 | + if (isset($erreurs['message_erreur'])) { |
|
| 284 | + $valeurs['message_erreur'] = $erreurs['message_erreur']; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + $valeurs['message_ok'] = ''; |
|
| 288 | + if (isset($post["message_ok_$form"])) { |
|
| 289 | + $valeurs['message_ok'] = $post["message_ok_$form"]; |
|
| 290 | + } elseif (isset($erreurs['message_ok'])) { |
|
| 291 | + $valeurs['message_ok'] = $erreurs['message_ok']; |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + // accessibilite : encapsuler toutes les erreurs dans un role='alert' |
|
| 295 | + // uniquement si c'est une string et au premier niveau (on ne touche pas au tableaux) |
|
| 296 | + // et si $k ne commence pas par un _ (c'est bien une vrai erreur sur un vrai champ) |
|
| 297 | + if (html5_permis()) { |
|
| 298 | + foreach ($erreurs as $k => $v) { |
|
| 299 | + if (is_string($v) && strlen(trim($v)) && !str_starts_with((string) $k, '_')) { |
|
| 300 | + // on encapsule dans un span car ces messages sont en general simple, juste du texte, et deja dans un span dans le form |
|
| 301 | + $valeurs['erreurs'][$k] = "<span role='alert'>" . $erreurs[$k] . '</span>'; |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + return $valeurs; |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -316,51 +316,51 @@ discard block |
||
| 316 | 316 | * @return array |
| 317 | 317 | */ |
| 318 | 318 | function formulaire__charger($form, $args, $poste) { |
| 319 | - if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 320 | - $valeurs = $charger_valeurs(...$args); |
|
| 321 | - } else { |
|
| 322 | - $valeurs = []; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - $valeurs = pipeline( |
|
| 326 | - 'formulaire_charger', |
|
| 327 | - [ |
|
| 328 | - 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 329 | - 'data' => $valeurs |
|
| 330 | - ] |
|
| 331 | - ); |
|
| 332 | - |
|
| 333 | - // prise en charge CVT multi etape |
|
| 334 | - if (is_array($valeurs) && isset($valeurs['_etapes'])) { |
|
| 335 | - include_spip('inc/cvt_multietapes'); |
|
| 336 | - $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 337 | - ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 338 | - $valeurs |
|
| 339 | - ); |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 343 | - if (is_array($valeurs)) { |
|
| 344 | - if (!isset($valeurs['_pipelines'])) { |
|
| 345 | - $valeurs['_pipelines'] = []; |
|
| 346 | - } |
|
| 347 | - // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 348 | - // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 349 | - if (isset($valeurs['_pipeline'])) { |
|
| 350 | - $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 351 | - $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 352 | - |
|
| 353 | - $pipelines = [$pipe => $args]; |
|
| 354 | - $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 358 | - // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 359 | - // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 360 | - $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - return $valeurs; |
|
| 319 | + if ($charger_valeurs = charger_fonction('charger', "formulaires/$form", true)) { |
|
| 320 | + $valeurs = $charger_valeurs(...$args); |
|
| 321 | + } else { |
|
| 322 | + $valeurs = []; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + $valeurs = pipeline( |
|
| 326 | + 'formulaire_charger', |
|
| 327 | + [ |
|
| 328 | + 'args' => ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 329 | + 'data' => $valeurs |
|
| 330 | + ] |
|
| 331 | + ); |
|
| 332 | + |
|
| 333 | + // prise en charge CVT multi etape |
|
| 334 | + if (is_array($valeurs) && isset($valeurs['_etapes'])) { |
|
| 335 | + include_spip('inc/cvt_multietapes'); |
|
| 336 | + $valeurs = cvtmulti_formulaire_charger_etapes( |
|
| 337 | + ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste], |
|
| 338 | + $valeurs |
|
| 339 | + ); |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + // si $valeurs et false ou une chaine, pas de formulaire, donc pas de pipeline ! |
|
| 343 | + if (is_array($valeurs)) { |
|
| 344 | + if (!isset($valeurs['_pipelines'])) { |
|
| 345 | + $valeurs['_pipelines'] = []; |
|
| 346 | + } |
|
| 347 | + // l'ancien argument _pipeline devient maintenant _pipelines |
|
| 348 | + // reinjectons le vieux _pipeline au debut de _pipelines |
|
| 349 | + if (isset($valeurs['_pipeline'])) { |
|
| 350 | + $pipe = is_array($valeurs['_pipeline']) ? reset($valeurs['_pipeline']) : $valeurs['_pipeline']; |
|
| 351 | + $args = is_array($valeurs['_pipeline']) ? end($valeurs['_pipeline']) : []; |
|
| 352 | + |
|
| 353 | + $pipelines = [$pipe => $args]; |
|
| 354 | + $valeurs['_pipelines'] = array_merge($pipelines, $valeurs['_pipelines']); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + // et enfin, ajoutons systematiquement un pipeline sur le squelette du formulaire |
|
| 358 | + // qui constitue le cas le plus courant d'utilisation du pipeline recuperer_fond |
|
| 359 | + // (performance, cela evite de s'injecter dans recuperer_fond utilise pour *tous* les squelettes) |
|
| 360 | + $valeurs['_pipelines']['formulaire_fond'] = ['form' => $form, 'args' => $args, 'je_suis_poste' => $poste]; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + return $valeurs; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | /** |
@@ -379,9 +379,9 @@ discard block |
||
| 379 | 379 | * @return bool |
| 380 | 380 | */ |
| 381 | 381 | function formulaire__identifier($form, $args, $p) { |
| 382 | - if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 383 | - return $identifier_args(...$args) === $identifier_args(...$p); |
|
| 384 | - } |
|
| 382 | + if ($identifier_args = charger_fonction('identifier', "formulaires/$form", true)) { |
|
| 383 | + return $identifier_args(...$args) === $identifier_args(...$p); |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - return $args === $p; |
|
| 386 | + return $args === $p; |
|
| 387 | 387 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -39,29 +39,29 @@ discard block |
||
| 39 | 39 | * Pile complétée par le code à générer |
| 40 | 40 | */ |
| 41 | 41 | function balise_INFO__dist($p) { |
| 42 | - $info = $p->nom_champ; |
|
| 43 | - $type_objet = interprete_argument_balise(1, $p); |
|
| 44 | - $id_objet = interprete_argument_balise(2, $p); |
|
| 45 | - if ($info === 'INFO_' || !$type_objet || !$id_objet) { |
|
| 46 | - $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 47 | - erreur_squelette($msg, $p); |
|
| 48 | - $p->interdire_scripts = true; |
|
| 42 | + $info = $p->nom_champ; |
|
| 43 | + $type_objet = interprete_argument_balise(1, $p); |
|
| 44 | + $id_objet = interprete_argument_balise(2, $p); |
|
| 45 | + if ($info === 'INFO_' || !$type_objet || !$id_objet) { |
|
| 46 | + $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 47 | + erreur_squelette($msg, $p); |
|
| 48 | + $p->interdire_scripts = true; |
|
| 49 | 49 | |
| 50 | - return $p; |
|
| 51 | - } else { |
|
| 52 | - // Récupérer tous les params à la suite de objet et id_objet |
|
| 53 | - $_params = '['; |
|
| 54 | - $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 55 | - for ($i = 3; $i < $nb_params; $i++) { |
|
| 56 | - $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 57 | - } |
|
| 58 | - $_params .= ']'; |
|
| 50 | + return $p; |
|
| 51 | + } else { |
|
| 52 | + // Récupérer tous les params à la suite de objet et id_objet |
|
| 53 | + $_params = '['; |
|
| 54 | + $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 55 | + for ($i = 3; $i < $nb_params; $i++) { |
|
| 56 | + $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 57 | + } |
|
| 58 | + $_params .= ']'; |
|
| 59 | 59 | |
| 60 | - $info_sql = strtolower(substr((string) $info, 5)); |
|
| 61 | - $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 62 | - $p->code = champ_sql($info, $p, $code); |
|
| 63 | - $p->interdire_scripts = true; |
|
| 60 | + $info_sql = strtolower(substr((string) $info, 5)); |
|
| 61 | + $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 62 | + $p->code = champ_sql($info, $p, $code); |
|
| 63 | + $p->interdire_scripts = true; |
|
| 64 | 64 | |
| 65 | - return $p; |
|
| 66 | - } |
|
| 65 | + return $p; |
|
| 66 | + } |
|
| 67 | 67 | } |
@@ -53,12 +53,12 @@ |
||
| 53 | 53 | $_params = '['; |
| 54 | 54 | $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
| 55 | 55 | for ($i = 3; $i < $nb_params; $i++) { |
| 56 | - $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 56 | + $_params .= interprete_argument_balise($i, $p).','; |
|
| 57 | 57 | } |
| 58 | 58 | $_params .= ']'; |
| 59 | 59 | |
| 60 | 60 | $info_sql = strtolower(substr((string) $info, 5)); |
| 61 | - $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 61 | + $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', ".($p->etoile ? _q($p->etoile) : "''").", $_params)"; |
|
| 62 | 62 | $p->code = champ_sql($info, $p, $code); |
| 63 | 63 | $p->interdire_scripts = true; |
| 64 | 64 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * Pile complétée du code compilé |
| 36 | 36 | **/ |
| 37 | 37 | function balise_URL_LOGOUT($p) { |
| 38 | - return calculer_balise_dynamique($p, 'URL_LOGOUT', []); |
|
| 38 | + return calculer_balise_dynamique($p, 'URL_LOGOUT', []); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * Liste (url) des arguments collectés. |
| 52 | 52 | */ |
| 53 | 53 | function balise_URL_LOGOUT_stat($args, $context_compil) { |
| 54 | - $url = $args[0] ?? ''; |
|
| 54 | + $url = $args[0] ?? ''; |
|
| 55 | 55 | |
| 56 | - return [$url]; |
|
| 56 | + return [$url]; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | **/ |
| 69 | 69 | function balise_URL_LOGOUT_dyn($cible) { |
| 70 | 70 | |
| 71 | - if (empty($GLOBALS['visiteur_session']['login']) && empty($GLOBALS['visiteur_session']['statut'])) { |
|
| 72 | - return ''; |
|
| 73 | - } |
|
| 71 | + if (empty($GLOBALS['visiteur_session']['login']) && empty($GLOBALS['visiteur_session']['statut'])) { |
|
| 72 | + return ''; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return generer_url_action('logout', 'logout=public&url=' . rawurlencode((string) ($cible ?: self('&')))); |
|
| 75 | + return generer_url_action('logout', 'logout=public&url=' . rawurlencode((string) ($cible ?: self('&')))); |
|
| 76 | 76 | } |
@@ -72,5 +72,5 @@ |
||
| 72 | 72 | return ''; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - return generer_url_action('logout', 'logout=public&url=' . rawurlencode((string) ($cible ?: self('&')))); |
|
| 75 | + return generer_url_action('logout', 'logout=public&url='.rawurlencode((string) ($cible ?: self('&')))); |
|
| 76 | 76 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * Pile complétée du code compilé |
| 37 | 37 | **/ |
| 38 | 38 | function balise_MENU_LANG($p) { |
| 39 | - return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 39 | + return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * string: (vide) si pas de multilinguisme |
| 56 | 56 | */ |
| 57 | 57 | function balise_MENU_LANG_stat($args, $context_compil) { |
| 58 | - if (!str_contains((string) $GLOBALS['meta']['langues_multilingue'], ',')) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 58 | + if (!str_contains((string) $GLOBALS['meta']['langues_multilingue'], ',')) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $args; |
|
| 62 | + return $args; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * Liste : Chemin du squelette, durée du cache, contexte |
| 76 | 76 | **/ |
| 77 | 77 | function balise_MENU_LANG_dyn($opt) { |
| 78 | - include_spip('balise/menu_lang_ecrire'); |
|
| 78 | + include_spip('balise/menu_lang_ecrire'); |
|
| 79 | 79 | |
| 80 | - return menu_lang_pour_tous('var_lang', $opt); |
|
| 80 | + return menu_lang_pour_tous('var_lang', $opt); |
|
| 81 | 81 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | * Code compilé |
| 37 | 37 | **/ |
| 38 | 38 | function generer_generer_url($type, $p) { |
| 39 | - $_id = interprete_argument_balise(1, $p); |
|
| 39 | + $_id = interprete_argument_balise(1, $p); |
|
| 40 | 40 | |
| 41 | - if (!$_id) { |
|
| 42 | - $primary = id_table_objet($type); |
|
| 43 | - $_id = champ_sql($primary, $p); |
|
| 44 | - } |
|
| 41 | + if (!$_id) { |
|
| 42 | + $primary = id_table_objet($type); |
|
| 43 | + $_id = champ_sql($primary, $p); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - return generer_generer_url_arg($type, $p, $_id); |
|
| 46 | + return generer_generer_url_arg($type, $p, $_id); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -72,28 +72,28 @@ discard block |
||
| 72 | 72 | * Code compilé |
| 73 | 73 | **/ |
| 74 | 74 | function generer_generer_url_arg($type, $p, $_id) { |
| 75 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 76 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 77 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 78 | - return $f($type, $_id, $s); |
|
| 79 | - } |
|
| 80 | - if (!$GLOBALS['connexions'][strtolower((string) $s)]['spip_connect_version']) { |
|
| 81 | - return null; |
|
| 82 | - } |
|
| 83 | - $s = _q($s); |
|
| 84 | - # exception des urls de documents sur un serveur distant... |
|
| 85 | - if ($type == 'document') { |
|
| 86 | - return |
|
| 87 | - "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 88 | - "quete_meta('dir_img', $s) . \n\t" . |
|
| 89 | - "quete_fichier($_id,$s)"; |
|
| 90 | - } |
|
| 91 | - $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 92 | - } else { |
|
| 93 | - $s = ", '', '', true"; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 75 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 76 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 77 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 78 | + return $f($type, $_id, $s); |
|
| 79 | + } |
|
| 80 | + if (!$GLOBALS['connexions'][strtolower((string) $s)]['spip_connect_version']) { |
|
| 81 | + return null; |
|
| 82 | + } |
|
| 83 | + $s = _q($s); |
|
| 84 | + # exception des urls de documents sur un serveur distant... |
|
| 85 | + if ($type == 'document') { |
|
| 86 | + return |
|
| 87 | + "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 88 | + "quete_meta('dir_img', $s) . \n\t" . |
|
| 89 | + "quete_fichier($_id,$s)"; |
|
| 90 | + } |
|
| 91 | + $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 92 | + } else { |
|
| 93 | + $s = ", '', '', true"; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
@@ -118,27 +118,27 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | function balise_URL__dist($p) { |
| 120 | 120 | |
| 121 | - $nom = $p->nom_champ; |
|
| 122 | - if ($nom === 'URL_') { |
|
| 123 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 124 | - erreur_squelette($msg, $p); |
|
| 125 | - $p->interdire_scripts = false; |
|
| 126 | - |
|
| 127 | - return $p; |
|
| 128 | - } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 129 | - return $f($p); |
|
| 130 | - } else { |
|
| 131 | - $nom = strtolower((string) $nom); |
|
| 132 | - $code = generer_generer_url(substr($nom, 4), $p); |
|
| 133 | - $code = champ_sql($nom, $p, $code); |
|
| 134 | - $p->code = $code; |
|
| 135 | - if (!$p->etoile) { |
|
| 136 | - $p->code = "vider_url($code)"; |
|
| 137 | - } |
|
| 138 | - $p->interdire_scripts = false; |
|
| 139 | - |
|
| 140 | - return $p; |
|
| 141 | - } |
|
| 121 | + $nom = $p->nom_champ; |
|
| 122 | + if ($nom === 'URL_') { |
|
| 123 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 124 | + erreur_squelette($msg, $p); |
|
| 125 | + $p->interdire_scripts = false; |
|
| 126 | + |
|
| 127 | + return $p; |
|
| 128 | + } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 129 | + return $f($p); |
|
| 130 | + } else { |
|
| 131 | + $nom = strtolower((string) $nom); |
|
| 132 | + $code = generer_generer_url(substr($nom, 4), $p); |
|
| 133 | + $code = champ_sql($nom, $p, $code); |
|
| 134 | + $p->code = $code; |
|
| 135 | + if (!$p->etoile) { |
|
| 136 | + $p->code = "vider_url($code)"; |
|
| 137 | + } |
|
| 138 | + $p->interdire_scripts = false; |
|
| 139 | + |
|
| 140 | + return $p; |
|
| 141 | + } |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -162,16 +162,16 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | function balise_URL_ARTICLE_dist($p) { |
| 164 | 164 | |
| 165 | - // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 166 | - $code = $p->type_requete == 'syndic_articles' ? champ_sql('url', $p) : generer_generer_url('article', $p); |
|
| 165 | + // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 166 | + $code = $p->type_requete == 'syndic_articles' ? champ_sql('url', $p) : generer_generer_url('article', $p); |
|
| 167 | 167 | |
| 168 | - $p->code = $code; |
|
| 169 | - if (!$p->etoile) { |
|
| 170 | - $p->code = "vider_url($code)"; |
|
| 171 | - } |
|
| 172 | - $p->interdire_scripts = false; |
|
| 168 | + $p->code = $code; |
|
| 169 | + if (!$p->etoile) { |
|
| 170 | + $p->code = "vider_url($code)"; |
|
| 171 | + } |
|
| 172 | + $p->interdire_scripts = false; |
|
| 173 | 173 | |
| 174 | - return $p; |
|
| 174 | + return $p; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -191,21 +191,21 @@ discard block |
||
| 191 | 191 | * Pile complétée par le code à générer |
| 192 | 192 | */ |
| 193 | 193 | function balise_URL_SITE_dist($p) { |
| 194 | - $code = champ_sql('url_site', $p, ''); |
|
| 195 | - if (!$code) { |
|
| 196 | - $code = generer_generer_url('site', $p); |
|
| 197 | - if ($code === null) { |
|
| 198 | - return null; |
|
| 199 | - } |
|
| 200 | - } else { |
|
| 201 | - if (!$p->etoile) { |
|
| 202 | - $code = "calculer_url($code,'','url', \$connect)"; |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - $p->code = $code; |
|
| 206 | - $p->interdire_scripts = false; |
|
| 207 | - |
|
| 208 | - return $p; |
|
| 194 | + $code = champ_sql('url_site', $p, ''); |
|
| 195 | + if (!$code) { |
|
| 196 | + $code = generer_generer_url('site', $p); |
|
| 197 | + if ($code === null) { |
|
| 198 | + return null; |
|
| 199 | + } |
|
| 200 | + } else { |
|
| 201 | + if (!$p->etoile) { |
|
| 202 | + $code = "calculer_url($code,'','url', \$connect)"; |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + $p->code = $code; |
|
| 206 | + $p->interdire_scripts = false; |
|
| 207 | + |
|
| 208 | + return $p; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // Autres balises URL_*, qui ne concernent pas une table |
@@ -224,11 +224,11 @@ discard block |
||
| 224 | 224 | * Pile complétée par le code à générer |
| 225 | 225 | */ |
| 226 | 226 | function balise_URL_SITE_SPIP_dist($p) { |
| 227 | - $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 228 | - $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 229 | - $p->interdire_scripts = false; |
|
| 227 | + $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 228 | + $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 229 | + $p->interdire_scripts = false; |
|
| 230 | 230 | |
| 231 | - return $p; |
|
| 231 | + return $p; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | |
@@ -257,42 +257,42 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | function balise_URL_PAGE_dist($p) { |
| 259 | 259 | |
| 260 | - $code = interprete_argument_balise(1, $p); |
|
| 261 | - $args = interprete_argument_balise(2, $p); |
|
| 262 | - if ($args == null) { |
|
| 263 | - $args = "''"; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 267 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 268 | - // elle devra aussi traiter le cas derogatoire type=page |
|
| 269 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 270 | - if ($args && $args !== "''") { |
|
| 271 | - $code .= ", $args"; |
|
| 272 | - } |
|
| 273 | - $code = $f('page', $code, $s); |
|
| 274 | - $p->code = $code; |
|
| 275 | - return $p; |
|
| 276 | - } |
|
| 277 | - $s = 'connect=' . addslashes((string) $s); |
|
| 278 | - $args = (($args && $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - if (!$code) { |
|
| 282 | - $noentities = $p->etoile ? "'&'" : ''; |
|
| 283 | - $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 284 | - } else { |
|
| 285 | - if (!$args) { |
|
| 286 | - $args = "''"; |
|
| 287 | - } |
|
| 288 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 289 | - $code = "generer_url_public($code, $args$noentities)"; |
|
| 290 | - } |
|
| 291 | - $p->code = $code; |
|
| 292 | - spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 293 | - |
|
| 294 | - #$p->interdire_scripts = true; |
|
| 295 | - return $p; |
|
| 260 | + $code = interprete_argument_balise(1, $p); |
|
| 261 | + $args = interprete_argument_balise(2, $p); |
|
| 262 | + if ($args == null) { |
|
| 263 | + $args = "''"; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 267 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 268 | + // elle devra aussi traiter le cas derogatoire type=page |
|
| 269 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 270 | + if ($args && $args !== "''") { |
|
| 271 | + $code .= ", $args"; |
|
| 272 | + } |
|
| 273 | + $code = $f('page', $code, $s); |
|
| 274 | + $p->code = $code; |
|
| 275 | + return $p; |
|
| 276 | + } |
|
| 277 | + $s = 'connect=' . addslashes((string) $s); |
|
| 278 | + $args = (($args && $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + if (!$code) { |
|
| 282 | + $noentities = $p->etoile ? "'&'" : ''; |
|
| 283 | + $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 284 | + } else { |
|
| 285 | + if (!$args) { |
|
| 286 | + $args = "''"; |
|
| 287 | + } |
|
| 288 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 289 | + $code = "generer_url_public($code, $args$noentities)"; |
|
| 290 | + } |
|
| 291 | + $p->code = $code; |
|
| 292 | + spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 293 | + |
|
| 294 | + #$p->interdire_scripts = true; |
|
| 295 | + return $p; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
@@ -319,24 +319,24 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | function balise_URL_ECRIRE_dist($p) { |
| 321 | 321 | |
| 322 | - $code = interprete_argument_balise(1, $p); |
|
| 323 | - if (!$code) { |
|
| 324 | - $fonc = "''"; |
|
| 325 | - } else { |
|
| 326 | - $fonc = $code; |
|
| 327 | - $args = interprete_argument_balise(2, $p); |
|
| 328 | - if ($args === null) { |
|
| 329 | - $args = "''"; |
|
| 330 | - } |
|
| 331 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 332 | - if ($args != "''" || $noentities) { |
|
| 333 | - $fonc .= ",$args$noentities"; |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 337 | - $p->interdire_scripts = false; |
|
| 338 | - |
|
| 339 | - return $p; |
|
| 322 | + $code = interprete_argument_balise(1, $p); |
|
| 323 | + if (!$code) { |
|
| 324 | + $fonc = "''"; |
|
| 325 | + } else { |
|
| 326 | + $fonc = $code; |
|
| 327 | + $args = interprete_argument_balise(2, $p); |
|
| 328 | + if ($args === null) { |
|
| 329 | + $args = "''"; |
|
| 330 | + } |
|
| 331 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 332 | + if ($args != "''" || $noentities) { |
|
| 333 | + $fonc .= ",$args$noentities"; |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 337 | + $p->interdire_scripts = false; |
|
| 338 | + |
|
| 339 | + return $p; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | |
@@ -362,24 +362,24 @@ discard block |
||
| 362 | 362 | * Pile complétée par le code à générer |
| 363 | 363 | */ |
| 364 | 364 | function balise_URL_ACTION_AUTEUR_dist($p) { |
| 365 | - $p->descr['session'] = true; |
|
| 366 | - |
|
| 367 | - $p->code = interprete_argument_balise(1, $p); |
|
| 368 | - |
|
| 369 | - $args = interprete_argument_balise(2, $p); |
|
| 370 | - if ($args != "''" && $args !== null) { |
|
| 371 | - $p->code .= ',' . $args; |
|
| 372 | - } |
|
| 373 | - $redirect = interprete_argument_balise(3, $p); |
|
| 374 | - if ($redirect != "''" && $redirect !== null) { |
|
| 375 | - if ($args == "''" || $args === null) { |
|
| 376 | - $p->code .= ",''"; |
|
| 377 | - } |
|
| 378 | - $p->code .= ',' . $redirect; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 382 | - $p->interdire_scripts = false; |
|
| 383 | - |
|
| 384 | - return $p; |
|
| 365 | + $p->descr['session'] = true; |
|
| 366 | + |
|
| 367 | + $p->code = interprete_argument_balise(1, $p); |
|
| 368 | + |
|
| 369 | + $args = interprete_argument_balise(2, $p); |
|
| 370 | + if ($args != "''" && $args !== null) { |
|
| 371 | + $p->code .= ',' . $args; |
|
| 372 | + } |
|
| 373 | + $redirect = interprete_argument_balise(3, $p); |
|
| 374 | + if ($redirect != "''" && $redirect !== null) { |
|
| 375 | + if ($args == "''" || $args === null) { |
|
| 376 | + $p->code .= ",''"; |
|
| 377 | + } |
|
| 378 | + $p->code .= ',' . $redirect; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 382 | + $p->interdire_scripts = false; |
|
| 383 | + |
|
| 384 | + return $p; |
|
| 385 | 385 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | function generer_generer_url_arg($type, $p, $_id) { |
| 75 | 75 | if ($s = trouver_nom_serveur_distant($p)) { |
| 76 | 76 | // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
| 77 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 77 | + if (function_exists($f = 'generer_generer_url_'.$s)) { |
|
| 78 | 78 | return $f($type, $_id, $s); |
| 79 | 79 | } |
| 80 | 80 | if (!$GLOBALS['connexions'][strtolower((string) $s)]['spip_connect_version']) { |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | # exception des urls de documents sur un serveur distant... |
| 85 | 85 | if ($type == 'document') { |
| 86 | 86 | return |
| 87 | - "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 88 | - "quete_meta('dir_img', $s) . \n\t" . |
|
| 87 | + "quete_meta('adresse_site', $s) . '/' .\n\t". |
|
| 88 | + "quete_meta('dir_img', $s) . \n\t". |
|
| 89 | 89 | "quete_fichier($_id,$s)"; |
| 90 | 90 | } |
| 91 | 91 | $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | function balise_URL_SITE_SPIP_dist($p) { |
| 227 | 227 | $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
| 228 | - $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 228 | + $p->code = 'spip_htmlspecialchars('.$p->code.')'; |
|
| 229 | 229 | $p->interdire_scripts = false; |
| 230 | 230 | |
| 231 | 231 | return $p; |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | if ($s = trouver_nom_serveur_distant($p)) { |
| 267 | 267 | // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
| 268 | 268 | // elle devra aussi traiter le cas derogatoire type=page |
| 269 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 269 | + if (function_exists($f = 'generer_generer_url_'.$s)) { |
|
| 270 | 270 | if ($args && $args !== "''") { |
| 271 | 271 | $code .= ", $args"; |
| 272 | 272 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $p->code = $code; |
| 275 | 275 | return $p; |
| 276 | 276 | } |
| 277 | - $s = 'connect=' . addslashes((string) $s); |
|
| 277 | + $s = 'connect='.addslashes((string) $s); |
|
| 278 | 278 | $args = (($args && $args !== "''") ? "$args . '&$s'" : "'$s'"); |
| 279 | 279 | } |
| 280 | 280 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $code = "generer_url_public($code, $args$noentities)"; |
| 290 | 290 | } |
| 291 | 291 | $p->code = $code; |
| 292 | - spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 292 | + spip_log("Calcul url page : connect vaut $s ca donne :".$p->code." args $args", _LOG_INFO); |
|
| 293 | 293 | |
| 294 | 294 | #$p->interdire_scripts = true; |
| 295 | 295 | return $p; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $fonc .= ",$args$noentities"; |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | - $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 336 | + $p->code = 'generer_url_ecrire('.$fonc.')'; |
|
| 337 | 337 | $p->interdire_scripts = false; |
| 338 | 338 | |
| 339 | 339 | return $p; |
@@ -368,17 +368,17 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | $args = interprete_argument_balise(2, $p); |
| 370 | 370 | if ($args != "''" && $args !== null) { |
| 371 | - $p->code .= ',' . $args; |
|
| 371 | + $p->code .= ','.$args; |
|
| 372 | 372 | } |
| 373 | 373 | $redirect = interprete_argument_balise(3, $p); |
| 374 | 374 | if ($redirect != "''" && $redirect !== null) { |
| 375 | 375 | if ($args == "''" || $args === null) { |
| 376 | 376 | $p->code .= ",''"; |
| 377 | 377 | } |
| 378 | - $p->code .= ',' . $redirect; |
|
| 378 | + $p->code .= ','.$redirect; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 381 | + $p->code = 'generer_action_auteur('.$p->code.')'; |
|
| 382 | 382 | $p->interdire_scripts = false; |
| 383 | 383 | |
| 384 | 384 | return $p; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -55,88 +55,88 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function balise_LOGO__dist($p) { |
| 57 | 57 | |
| 58 | - preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 59 | - $type = strtolower($regs[1]); |
|
| 60 | - $suite_logo = $regs[2]; |
|
| 61 | - |
|
| 62 | - // cas de #LOGO_SITE_SPIP |
|
| 63 | - if ($type == 'site_spip') { |
|
| 64 | - $type = 'site'; |
|
| 65 | - $_id_objet = "\"'0'\""; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $id_objet = id_table_objet($type); |
|
| 69 | - if (!isset($_id_objet)) { |
|
| 70 | - $_id_objet = champ_sql($id_objet, $p); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - $fichier = ($p->etoile === '**') ? -1 : 0; |
|
| 74 | - $coord = []; |
|
| 75 | - $align = $lien = ''; |
|
| 76 | - $mode_logo = ''; |
|
| 77 | - |
|
| 78 | - if ($p->param && !$p->param[0][0]) { |
|
| 79 | - $params = $p->param[0]; |
|
| 80 | - array_shift($params); |
|
| 81 | - foreach ($params as $a) { |
|
| 82 | - if ($a[0]->type === 'texte') { |
|
| 83 | - $n = $a[0]->texte; |
|
| 84 | - if (is_numeric($n)) { |
|
| 85 | - $coord[] = $n; |
|
| 86 | - } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) { |
|
| 87 | - $align = $n; |
|
| 88 | - } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) { |
|
| 89 | - $mode_logo = $n; |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - $coord_x = $coord ? (int) array_shift($coord) : 0; |
|
| 98 | - $coord_y = $coord ? (int) array_shift($coord) : 0; |
|
| 99 | - |
|
| 100 | - if ($p->etoile === '*') { |
|
| 101 | - include_spip('balise/url_'); |
|
| 102 | - $lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 106 | - if ($type == 'document') { |
|
| 107 | - $qconnect = _q($connect); |
|
| 108 | - $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 109 | - if ($fichier) { |
|
| 110 | - $code = "quete_logo_file($doc, $qconnect)"; |
|
| 111 | - } else { |
|
| 112 | - $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 113 | - } |
|
| 114 | - // (x=non-faux ? y : '') pour affecter x en retournant y |
|
| 115 | - if ($p->descr['documents']) { |
|
| 116 | - $code = '(($doublons["documents"] .= ",". ' |
|
| 117 | - . $_id_objet |
|
| 118 | - . ") ? $code : '')"; |
|
| 119 | - } |
|
| 120 | - } elseif ($connect) { |
|
| 121 | - $code = "''"; |
|
| 122 | - spip_log('Les logos distants ne sont pas prevus'); |
|
| 123 | - } else { |
|
| 124 | - // pour generer_code_logo |
|
| 125 | - include_spip('balise/id_logo_'); |
|
| 126 | - $champ_logo = ''; |
|
| 127 | - if ($fichier) { |
|
| 128 | - $champ_logo = 'fichier'; |
|
| 129 | - } |
|
| 130 | - $code = generer_code_logo($id_objet, $_id_objet, $type, $align, $lien, $p, $suite_logo, $champ_logo); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
| 134 | - if ($coord_x || $coord_y) { |
|
| 135 | - $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $p->code = $code; |
|
| 139 | - $p->interdire_scripts = false; |
|
| 140 | - |
|
| 141 | - return $p; |
|
| 58 | + preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 59 | + $type = strtolower($regs[1]); |
|
| 60 | + $suite_logo = $regs[2]; |
|
| 61 | + |
|
| 62 | + // cas de #LOGO_SITE_SPIP |
|
| 63 | + if ($type == 'site_spip') { |
|
| 64 | + $type = 'site'; |
|
| 65 | + $_id_objet = "\"'0'\""; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $id_objet = id_table_objet($type); |
|
| 69 | + if (!isset($_id_objet)) { |
|
| 70 | + $_id_objet = champ_sql($id_objet, $p); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + $fichier = ($p->etoile === '**') ? -1 : 0; |
|
| 74 | + $coord = []; |
|
| 75 | + $align = $lien = ''; |
|
| 76 | + $mode_logo = ''; |
|
| 77 | + |
|
| 78 | + if ($p->param && !$p->param[0][0]) { |
|
| 79 | + $params = $p->param[0]; |
|
| 80 | + array_shift($params); |
|
| 81 | + foreach ($params as $a) { |
|
| 82 | + if ($a[0]->type === 'texte') { |
|
| 83 | + $n = $a[0]->texte; |
|
| 84 | + if (is_numeric($n)) { |
|
| 85 | + $coord[] = $n; |
|
| 86 | + } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) { |
|
| 87 | + $align = $n; |
|
| 88 | + } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) { |
|
| 89 | + $mode_logo = $n; |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + $coord_x = $coord ? (int) array_shift($coord) : 0; |
|
| 98 | + $coord_y = $coord ? (int) array_shift($coord) : 0; |
|
| 99 | + |
|
| 100 | + if ($p->etoile === '*') { |
|
| 101 | + include_spip('balise/url_'); |
|
| 102 | + $lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 106 | + if ($type == 'document') { |
|
| 107 | + $qconnect = _q($connect); |
|
| 108 | + $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 109 | + if ($fichier) { |
|
| 110 | + $code = "quete_logo_file($doc, $qconnect)"; |
|
| 111 | + } else { |
|
| 112 | + $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 113 | + } |
|
| 114 | + // (x=non-faux ? y : '') pour affecter x en retournant y |
|
| 115 | + if ($p->descr['documents']) { |
|
| 116 | + $code = '(($doublons["documents"] .= ",". ' |
|
| 117 | + . $_id_objet |
|
| 118 | + . ") ? $code : '')"; |
|
| 119 | + } |
|
| 120 | + } elseif ($connect) { |
|
| 121 | + $code = "''"; |
|
| 122 | + spip_log('Les logos distants ne sont pas prevus'); |
|
| 123 | + } else { |
|
| 124 | + // pour generer_code_logo |
|
| 125 | + include_spip('balise/id_logo_'); |
|
| 126 | + $champ_logo = ''; |
|
| 127 | + if ($fichier) { |
|
| 128 | + $champ_logo = 'fichier'; |
|
| 129 | + } |
|
| 130 | + $code = generer_code_logo($id_objet, $_id_objet, $type, $align, $lien, $p, $suite_logo, $champ_logo); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
| 134 | + if ($coord_x || $coord_y) { |
|
| 135 | + $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $p->code = $code; |
|
| 139 | + $p->interdire_scripts = false; |
|
| 140 | + |
|
| 141 | + return $p; |
|
| 142 | 142 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if ($fichier) { |
| 110 | 110 | $code = "quete_logo_file($doc, $qconnect)"; |
| 111 | 111 | } else { |
| 112 | - $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 112 | + $code = "quete_logo_document($doc, ".($lien ?: "''").", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 113 | 113 | } |
| 114 | 114 | // (x=non-faux ? y : '') pour affecter x en retournant y |
| 115 | 115 | if ($p->descr['documents']) { |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
| 134 | 134 | if ($coord_x || $coord_y) { |
| 135 | - $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 135 | + $code = "filtrer('image_graver',filtrer('image_reduire',".$code.", '$coord_x', '$coord_y'))"; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $p->code = $code; |