@@ -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 | include_spip('base/abstract_sql'); |
@@ -34,26 +34,26 @@ discard block |
||
| 34 | 34 | **/ |
| 35 | 35 | function genie_optimiser_dist($t) { |
| 36 | 36 | |
| 37 | - optimiser_base_une_table(); |
|
| 38 | - optimiser_base(); |
|
| 39 | - optimiser_caches_contextes(); |
|
| 37 | + optimiser_base_une_table(); |
|
| 38 | + optimiser_base(); |
|
| 39 | + optimiser_caches_contextes(); |
|
| 40 | 40 | |
| 41 | - // la date souhaitee pour le tour suivant = apres-demain a 4h du mat ; |
|
| 42 | - // sachant qu'on a un delai de 48h, on renvoie aujourd'hui a 4h du mat |
|
| 43 | - // avec une periode de flou entre 2h et 6h pour ne pas saturer un hebergeur |
|
| 44 | - // qui aurait beaucoup de sites SPIP |
|
| 45 | - return -(mktime(2, 0, 0) + random_int(0, 3600 * 4)); |
|
| 41 | + // la date souhaitee pour le tour suivant = apres-demain a 4h du mat ; |
|
| 42 | + // sachant qu'on a un delai de 48h, on renvoie aujourd'hui a 4h du mat |
|
| 43 | + // avec une periode de flou entre 2h et 6h pour ne pas saturer un hebergeur |
|
| 44 | + // qui aurait beaucoup de sites SPIP |
|
| 45 | + return -(mktime(2, 0, 0) + random_int(0, 3600 * 4)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Vider les contextes ajax de plus de 48h |
| 50 | 50 | */ |
| 51 | 51 | function optimiser_caches_contextes() { |
| 52 | - sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 53 | - if (is_dir($d = _DIR_CACHE . 'contextes')) { |
|
| 54 | - include_spip('inc/invalideur'); |
|
| 55 | - purger_repertoire($d, ['mtime' => time() - 48 * 3600, 'limit' => 10000]); |
|
| 56 | - } |
|
| 52 | + sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 53 | + if (is_dir($d = _DIR_CACHE . 'contextes')) { |
|
| 54 | + include_spip('inc/invalideur'); |
|
| 55 | + purger_repertoire($d, ['mtime' => time() - 48 * 3600, 'limit' => 10000]); |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return void |
| 69 | 69 | **/ |
| 70 | 70 | function optimiser_base($attente = 86400) { |
| 71 | - optimiser_base_disparus($attente); |
|
| 71 | + optimiser_base_disparus($attente); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -85,28 +85,28 @@ discard block |
||
| 85 | 85 | **/ |
| 86 | 86 | function optimiser_base_une_table() { |
| 87 | 87 | |
| 88 | - $tables = []; |
|
| 89 | - $result = sql_showbase(); |
|
| 90 | - |
|
| 91 | - // on n'optimise qu'une seule table a chaque fois, |
|
| 92 | - // pour ne pas vautrer le systeme |
|
| 93 | - // lire http://dev.mysql.com/doc/refman/5.0/fr/optimize-table.html |
|
| 94 | - while ($row = sql_fetch($result)) { |
|
| 95 | - $tables[] = array_shift($row); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - spip_log('optimiser_base_une_table ' . json_encode($tables, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 99 | - if ($tables) { |
|
| 100 | - $table_op = (int) (lire_config('optimiser_table', 0) + 1) % count($tables); |
|
| 101 | - ecrire_config('optimiser_table', $table_op); |
|
| 102 | - $q = $tables[$table_op]; |
|
| 103 | - spip_log("optimiser_base_une_table : debut d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 104 | - if (sql_optimize($q)) { |
|
| 105 | - spip_log("optimiser_base_une_table : fin d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 106 | - } else { |
|
| 107 | - spip_log("optimiser_base_une_table : Pas d'optimiseur necessaire", 'genie' . _LOG_DEBUG); |
|
| 108 | - } |
|
| 109 | - } |
|
| 88 | + $tables = []; |
|
| 89 | + $result = sql_showbase(); |
|
| 90 | + |
|
| 91 | + // on n'optimise qu'une seule table a chaque fois, |
|
| 92 | + // pour ne pas vautrer le systeme |
|
| 93 | + // lire http://dev.mysql.com/doc/refman/5.0/fr/optimize-table.html |
|
| 94 | + while ($row = sql_fetch($result)) { |
|
| 95 | + $tables[] = array_shift($row); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + spip_log('optimiser_base_une_table ' . json_encode($tables, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 99 | + if ($tables) { |
|
| 100 | + $table_op = (int) (lire_config('optimiser_table', 0) + 1) % count($tables); |
|
| 101 | + ecrire_config('optimiser_table', $table_op); |
|
| 102 | + $q = $tables[$table_op]; |
|
| 103 | + spip_log("optimiser_base_une_table : debut d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 104 | + if (sql_optimize($q)) { |
|
| 105 | + spip_log("optimiser_base_une_table : fin d'optimisation de la table $q", 'genie' . _LOG_DEBUG); |
|
| 106 | + } else { |
|
| 107 | + spip_log("optimiser_base_une_table : Pas d'optimiseur necessaire", 'genie' . _LOG_DEBUG); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
@@ -132,18 +132,18 @@ discard block |
||
| 132 | 132 | * Nombre de suppressions |
| 133 | 133 | **/ |
| 134 | 134 | function optimiser_sansref($table, $id, $sel, $and = '') { |
| 135 | - $in = []; |
|
| 136 | - while ($row = sql_fetch($sel)) { |
|
| 137 | - $in[$row['id']] = true; |
|
| 138 | - } |
|
| 139 | - sql_free($sel); |
|
| 140 | - |
|
| 141 | - if ($in) { |
|
| 142 | - sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 143 | - spip_log("optimiser_sansref: Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in)), 'genie' . _LOG_DEBUG); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return count($in); |
|
| 135 | + $in = []; |
|
| 136 | + while ($row = sql_fetch($sel)) { |
|
| 137 | + $in[$row['id']] = true; |
|
| 138 | + } |
|
| 139 | + sql_free($sel); |
|
| 140 | + |
|
| 141 | + if ($in) { |
|
| 142 | + sql_delete($table, sql_in($id, array_keys($in)) . ($and ? " AND $and" : '')); |
|
| 143 | + spip_log("optimiser_sansref: Numeros des entrees $id supprimees dans la table $table: " . implode(', ', array_keys($in)), 'genie' . _LOG_DEBUG); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return count($in); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -165,81 +165,81 @@ discard block |
||
| 165 | 165 | **/ |
| 166 | 166 | function optimiser_base_disparus($attente = 86400) { |
| 167 | 167 | |
| 168 | - # format = 20060610110141, si on veut forcer une optimisation tout de suite |
|
| 169 | - $mydate = date('Y-m-d H:i:s', time() - $attente); |
|
| 170 | - $mydate_quote = sql_quote($mydate); |
|
| 168 | + # format = 20060610110141, si on veut forcer une optimisation tout de suite |
|
| 169 | + $mydate = date('Y-m-d H:i:s', time() - $attente); |
|
| 170 | + $mydate_quote = sql_quote($mydate); |
|
| 171 | 171 | |
| 172 | - $n = 0; |
|
| 172 | + $n = 0; |
|
| 173 | 173 | |
| 174 | - // |
|
| 175 | - // Rubriques |
|
| 176 | - // |
|
| 174 | + // |
|
| 175 | + // Rubriques |
|
| 176 | + // |
|
| 177 | 177 | |
| 178 | - # les articles qui sont dans une id_rubrique inexistante |
|
| 179 | - # attention on controle id_rubrique>0 pour ne pas tuer les articles |
|
| 180 | - # specialement affectes a une rubrique non-existante (plugin, |
|
| 181 | - # cf. https://core.spip.net/issues/1549 ) |
|
| 182 | - $res = sql_select( |
|
| 183 | - 'A.id_article AS id', |
|
| 184 | - 'spip_articles AS A |
|
| 178 | + # les articles qui sont dans une id_rubrique inexistante |
|
| 179 | + # attention on controle id_rubrique>0 pour ne pas tuer les articles |
|
| 180 | + # specialement affectes a une rubrique non-existante (plugin, |
|
| 181 | + # cf. https://core.spip.net/issues/1549 ) |
|
| 182 | + $res = sql_select( |
|
| 183 | + 'A.id_article AS id', |
|
| 184 | + 'spip_articles AS A |
|
| 185 | 185 | LEFT JOIN spip_rubriques AS R |
| 186 | 186 | ON A.id_rubrique=R.id_rubrique', |
| 187 | - "A.id_rubrique > 0 |
|
| 187 | + "A.id_rubrique > 0 |
|
| 188 | 188 | AND R.id_rubrique IS NULL |
| 189 | 189 | AND A.maj < $mydate_quote" |
| 190 | - ); |
|
| 190 | + ); |
|
| 191 | 191 | |
| 192 | - $n += optimiser_sansref('spip_articles', 'id_article', $res); |
|
| 192 | + $n += optimiser_sansref('spip_articles', 'id_article', $res); |
|
| 193 | 193 | |
| 194 | - // les articles a la poubelle |
|
| 195 | - sql_delete('spip_articles', "statut='poubelle' AND maj < $mydate_quote"); |
|
| 194 | + // les articles a la poubelle |
|
| 195 | + sql_delete('spip_articles', "statut='poubelle' AND maj < $mydate_quote"); |
|
| 196 | 196 | |
| 197 | - // |
|
| 198 | - // Auteurs |
|
| 199 | - // |
|
| 197 | + // |
|
| 198 | + // Auteurs |
|
| 199 | + // |
|
| 200 | 200 | |
| 201 | - include_spip('action/editer_liens'); |
|
| 202 | - // optimiser les liens de tous les auteurs vers des objets effaces |
|
| 203 | - // et depuis des auteurs effaces |
|
| 204 | - $n += objet_optimiser_liens(['auteur' => '*'], '*'); |
|
| 201 | + include_spip('action/editer_liens'); |
|
| 202 | + // optimiser les liens de tous les auteurs vers des objets effaces |
|
| 203 | + // et depuis des auteurs effaces |
|
| 204 | + $n += objet_optimiser_liens(['auteur' => '*'], '*'); |
|
| 205 | 205 | |
| 206 | - # effacer les auteurs poubelle qui ne sont lies a rien |
|
| 207 | - $res = sql_select( |
|
| 208 | - 'A.id_auteur AS id', |
|
| 209 | - 'spip_auteurs AS A |
|
| 206 | + # effacer les auteurs poubelle qui ne sont lies a rien |
|
| 207 | + $res = sql_select( |
|
| 208 | + 'A.id_auteur AS id', |
|
| 209 | + 'spip_auteurs AS A |
|
| 210 | 210 | LEFT JOIN spip_auteurs_liens AS L |
| 211 | 211 | ON L.id_auteur=A.id_auteur', |
| 212 | - "L.id_auteur IS NULL |
|
| 212 | + "L.id_auteur IS NULL |
|
| 213 | 213 | AND A.statut='5poubelle' AND A.maj < $mydate_quote" |
| 214 | - ); |
|
| 215 | - |
|
| 216 | - $n += optimiser_sansref('spip_auteurs', 'id_auteur', $res); |
|
| 217 | - |
|
| 218 | - # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
|
| 219 | - # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
|
| 220 | - if (!defined('_AUTEURS_DELAI_REJET_NOUVEAU')) { |
|
| 221 | - define('_AUTEURS_DELAI_REJET_NOUVEAU', 45 * 24 * 3600); |
|
| 222 | - } |
|
| 223 | - sql_delete('spip_auteurs', "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - (int) _AUTEURS_DELAI_REJET_NOUVEAU))); |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
|
| 227 | - * |
|
| 228 | - * L'index 'data' est un entier indiquant le nombre d'optimisations |
|
| 229 | - * qui ont été réalisées (par exemple le nombre de suppressions faites) |
|
| 230 | - * et qui doit être incrémenté par les fonctions |
|
| 231 | - * utilisant ce pipeline si elles suppriment des éléments. |
|
| 232 | - * |
|
| 233 | - * @pipeline_appel optimiser_base_disparus |
|
| 234 | - */ |
|
| 235 | - $n = pipeline('optimiser_base_disparus', [ |
|
| 236 | - 'args' => [ |
|
| 237 | - 'attente' => $attente, |
|
| 238 | - 'date' => $mydate |
|
| 239 | - ], |
|
| 240 | - 'data' => $n |
|
| 241 | - ]); |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - spip_log("optimiser_base_disparus : {$n} lien(s) mort(s)", 'genie' . _LOG_DEBUG); |
|
| 214 | + ); |
|
| 215 | + |
|
| 216 | + $n += optimiser_sansref('spip_auteurs', 'id_auteur', $res); |
|
| 217 | + |
|
| 218 | + # supprimer les auteurs 'nouveau' qui n'ont jamais donne suite |
|
| 219 | + # au mail de confirmation (45 jours pour repondre, ca devrait suffire) |
|
| 220 | + if (!defined('_AUTEURS_DELAI_REJET_NOUVEAU')) { |
|
| 221 | + define('_AUTEURS_DELAI_REJET_NOUVEAU', 45 * 24 * 3600); |
|
| 222 | + } |
|
| 223 | + sql_delete('spip_auteurs', "statut='nouveau' AND maj < " . sql_quote(date('Y-m-d', time() - (int) _AUTEURS_DELAI_REJET_NOUVEAU))); |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Permet aux plugins de compléter l'optimisation suite aux éléments disparus |
|
| 227 | + * |
|
| 228 | + * L'index 'data' est un entier indiquant le nombre d'optimisations |
|
| 229 | + * qui ont été réalisées (par exemple le nombre de suppressions faites) |
|
| 230 | + * et qui doit être incrémenté par les fonctions |
|
| 231 | + * utilisant ce pipeline si elles suppriment des éléments. |
|
| 232 | + * |
|
| 233 | + * @pipeline_appel optimiser_base_disparus |
|
| 234 | + */ |
|
| 235 | + $n = pipeline('optimiser_base_disparus', [ |
|
| 236 | + 'args' => [ |
|
| 237 | + 'attente' => $attente, |
|
| 238 | + 'date' => $mydate |
|
| 239 | + ], |
|
| 240 | + 'data' => $n |
|
| 241 | + ]); |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + spip_log("optimiser_base_disparus : {$n} lien(s) mort(s)", 'genie' . _LOG_DEBUG); |
|
| 245 | 245 | } |
@@ -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 | /** |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | * @return int |
| 27 | 27 | */ |
| 28 | 28 | function genie_mise_a_jour_dist($t) { |
| 29 | - include_spip('inc/meta'); |
|
| 30 | - $maj = info_maj($GLOBALS['spip_version_branche']); |
|
| 31 | - ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : '', 'non'); |
|
| 29 | + include_spip('inc/meta'); |
|
| 30 | + $maj = info_maj($GLOBALS['spip_version_branche']); |
|
| 31 | + ecrire_meta('info_maj_spip', $maj ? ($GLOBALS['spip_version_branche'] . "|$maj") : '', 'non'); |
|
| 32 | 32 | |
| 33 | - mise_a_jour_ecran_securite(); |
|
| 33 | + mise_a_jour_ecran_securite(); |
|
| 34 | 34 | |
| 35 | - spip_log('Verification version SPIP : ' . ($maj ?: 'version a jour'), 'verifie_maj'); |
|
| 35 | + spip_log('Verification version SPIP : ' . ($maj ?: 'version a jour'), 'verifie_maj'); |
|
| 36 | 36 | |
| 37 | - return 1; |
|
| 37 | + return 1; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // TODO : fournir une URL sur spip.net pour maitriser la diffusion d'une nouvelle version de l'ecran via l'update auto |
@@ -51,46 +51,46 @@ discard block |
||
| 51 | 51 | * ou de ne repondre une 304 que si le md5 est bon |
| 52 | 52 | */ |
| 53 | 53 | function mise_a_jour_ecran_securite() { |
| 54 | - // TODO : url https avec verification du certificat |
|
| 55 | - return; |
|
| 56 | - |
|
| 57 | - // si l'ecran n'est pas deja present ou pas updatable, sortir |
|
| 58 | - if ( |
|
| 59 | - !_URL_ECRAN_SECURITE |
|
| 60 | - || !file_exists($filename = _DIR_ETC . 'ecran_securite.php') |
|
| 61 | - || !is_writable($filename) |
|
| 62 | - || !($last_modified = filemtime($filename)) |
|
| 63 | - || !($md5 = md5_file($filename)) |
|
| 64 | - ) { |
|
| 65 | - return false; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - include_spip('inc/distant'); |
|
| 69 | - $tmp_file = _DIR_TMP . 'ecran_securite.php'; |
|
| 70 | - $url = parametre_url(_URL_ECRAN_SECURITE, 'md5', $md5); |
|
| 71 | - $url = parametre_url($url, 'vspip', $GLOBALS['spip_version_branche']); |
|
| 72 | - $res = recuperer_url($url, [ |
|
| 73 | - 'if_modified_since' => $last_modified, |
|
| 74 | - 'file' => $tmp_file |
|
| 75 | - ]); |
|
| 76 | - |
|
| 77 | - // si il y a une version plus recente que l'on a recu correctement |
|
| 78 | - if ( |
|
| 79 | - $res['status'] == 200 |
|
| 80 | - && $res['length'] |
|
| 81 | - && ($tmp_file = $res['file']) |
|
| 82 | - ) { |
|
| 83 | - if ($md5 !== md5_file($tmp_file)) { |
|
| 84 | - // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale |
|
| 85 | - include_once $tmp_file; |
|
| 86 | - // ok, on le copie a la place de l'ecran existant |
|
| 87 | - // en backupant l'ecran avant, au cas ou |
|
| 88 | - @copy($filename, $filename . '-bck-' . date('Y-m-d-His', $last_modified)); |
|
| 89 | - @rename($tmp_file, $filename); |
|
| 90 | - } else { |
|
| 91 | - @unlink($tmp_file); |
|
| 92 | - } |
|
| 93 | - } |
|
| 54 | + // TODO : url https avec verification du certificat |
|
| 55 | + return; |
|
| 56 | + |
|
| 57 | + // si l'ecran n'est pas deja present ou pas updatable, sortir |
|
| 58 | + if ( |
|
| 59 | + !_URL_ECRAN_SECURITE |
|
| 60 | + || !file_exists($filename = _DIR_ETC . 'ecran_securite.php') |
|
| 61 | + || !is_writable($filename) |
|
| 62 | + || !($last_modified = filemtime($filename)) |
|
| 63 | + || !($md5 = md5_file($filename)) |
|
| 64 | + ) { |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + include_spip('inc/distant'); |
|
| 69 | + $tmp_file = _DIR_TMP . 'ecran_securite.php'; |
|
| 70 | + $url = parametre_url(_URL_ECRAN_SECURITE, 'md5', $md5); |
|
| 71 | + $url = parametre_url($url, 'vspip', $GLOBALS['spip_version_branche']); |
|
| 72 | + $res = recuperer_url($url, [ |
|
| 73 | + 'if_modified_since' => $last_modified, |
|
| 74 | + 'file' => $tmp_file |
|
| 75 | + ]); |
|
| 76 | + |
|
| 77 | + // si il y a une version plus recente que l'on a recu correctement |
|
| 78 | + if ( |
|
| 79 | + $res['status'] == 200 |
|
| 80 | + && $res['length'] |
|
| 81 | + && ($tmp_file = $res['file']) |
|
| 82 | + ) { |
|
| 83 | + if ($md5 !== md5_file($tmp_file)) { |
|
| 84 | + // on essaye de l'inclure pour verifier que ca ne fait pas erreur fatale |
|
| 85 | + include_once $tmp_file; |
|
| 86 | + // ok, on le copie a la place de l'ecran existant |
|
| 87 | + // en backupant l'ecran avant, au cas ou |
|
| 88 | + @copy($filename, $filename . '-bck-' . date('Y-m-d-His', $last_modified)); |
|
| 89 | + @rename($tmp_file, $filename); |
|
| 90 | + } else { |
|
| 91 | + @unlink($tmp_file); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -106,28 +106,28 @@ discard block |
||
| 106 | 106 | * @return string |
| 107 | 107 | */ |
| 108 | 108 | function info_maj(string $version): string { |
| 109 | - include_spip('inc/plugin'); |
|
| 110 | - |
|
| 111 | - // API V1 |
|
| 112 | - $contenu = info_maj_cache(); |
|
| 113 | - if (!$contenu) { |
|
| 114 | - return ''; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - $maj = info_maj_versions($version, array_keys($contenu['versions'] ?? [])); |
|
| 118 | - if (!$maj['mineure'] && !$maj['majeure']) { |
|
| 119 | - return ''; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $message = []; |
|
| 123 | - if ($maj['mineure']) { |
|
| 124 | - $message[] = _T('nouvelle_version_spip', ['version' => $maj['mineure']]); |
|
| 125 | - } |
|
| 126 | - if ($maj['majeure']) { |
|
| 127 | - $message[] = _T('nouvelle_version_spip_majeure', ['version' => $maj['majeure']]); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return '<a class="info_maj_spip" href="https://www.spip.net/fr_update" title="' . $maj['mineure'] . '">' . implode(' | ', $message) . '</a>'; |
|
| 109 | + include_spip('inc/plugin'); |
|
| 110 | + |
|
| 111 | + // API V1 |
|
| 112 | + $contenu = info_maj_cache(); |
|
| 113 | + if (!$contenu) { |
|
| 114 | + return ''; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + $maj = info_maj_versions($version, array_keys($contenu['versions'] ?? [])); |
|
| 118 | + if (!$maj['mineure'] && !$maj['majeure']) { |
|
| 119 | + return ''; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $message = []; |
|
| 123 | + if ($maj['mineure']) { |
|
| 124 | + $message[] = _T('nouvelle_version_spip', ['version' => $maj['mineure']]); |
|
| 125 | + } |
|
| 126 | + if ($maj['majeure']) { |
|
| 127 | + $message[] = _T('nouvelle_version_spip_majeure', ['version' => $maj['majeure']]); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return '<a class="info_maj_spip" href="https://www.spip.net/fr_update" title="' . $maj['mineure'] . '">' . implode(' | ', $message) . '</a>'; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -142,34 +142,34 @@ discard block |
||
| 142 | 142 | * @return array|null Contenu du fichier de cache de l'info de maj de SPIP. |
| 143 | 143 | */ |
| 144 | 144 | function info_maj_cache(): ?array { |
| 145 | - $contenu = ''; |
|
| 146 | - $options = []; |
|
| 147 | - $nom = _DIR_CACHE . _VERSIONS_LISTE; |
|
| 148 | - if (file_exists($nom)) { |
|
| 149 | - $contenu = file_get_contents($nom); |
|
| 150 | - $options['if_modified_since'] = filemtime($nom); |
|
| 151 | - } |
|
| 152 | - include_spip('inc/distant'); |
|
| 153 | - $res = recuperer_url_cache(_VERSIONS_SERVEUR, $options); |
|
| 154 | - |
|
| 155 | - // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 156 | - if ($res && $res['page']) { |
|
| 157 | - $contenu = $res['page']; |
|
| 158 | - ecrire_fichier($nom, $contenu); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - if (!$contenu) { |
|
| 162 | - return null; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - try { |
|
| 166 | - $json = json_decode((string) $contenu, true, 512, JSON_THROW_ON_ERROR); |
|
| 167 | - } catch (JsonException $e) { |
|
| 168 | - spip_log('Failed to parse Json data : ' . $e->getMessage(), 'verifie_maj'); |
|
| 169 | - return null; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - return $json; |
|
| 145 | + $contenu = ''; |
|
| 146 | + $options = []; |
|
| 147 | + $nom = _DIR_CACHE . _VERSIONS_LISTE; |
|
| 148 | + if (file_exists($nom)) { |
|
| 149 | + $contenu = file_get_contents($nom); |
|
| 150 | + $options['if_modified_since'] = filemtime($nom); |
|
| 151 | + } |
|
| 152 | + include_spip('inc/distant'); |
|
| 153 | + $res = recuperer_url_cache(_VERSIONS_SERVEUR, $options); |
|
| 154 | + |
|
| 155 | + // Si rien de neuf (ou inaccessible), garder l'ancienne |
|
| 156 | + if ($res && $res['page']) { |
|
| 157 | + $contenu = $res['page']; |
|
| 158 | + ecrire_fichier($nom, $contenu); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + if (!$contenu) { |
|
| 162 | + return null; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + try { |
|
| 166 | + $json = json_decode((string) $contenu, true, 512, JSON_THROW_ON_ERROR); |
|
| 167 | + } catch (JsonException $e) { |
|
| 168 | + spip_log('Failed to parse Json data : ' . $e->getMessage(), 'verifie_maj'); |
|
| 169 | + return null; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + return $json; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -184,40 +184,40 @@ discard block |
||
| 184 | 184 | * @return array<string, string> Version mineure supérieure, version majeure supérieure |
| 185 | 185 | */ |
| 186 | 186 | function info_maj_versions(string $version, array $versions): array { |
| 187 | - $maj = ['mineure' => '', 'majeure' => '']; |
|
| 188 | - if (!$version) { |
|
| 189 | - return $maj; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - // pas de version dev |
|
| 193 | - $versions = array_diff($versions, ['dev']); |
|
| 194 | - |
|
| 195 | - // branche en cours d'utilisation |
|
| 196 | - $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2)); |
|
| 197 | - |
|
| 198 | - foreach ($versions as $v) { |
|
| 199 | - [$maj2, $min2, $rev2] = explode('.', $v); |
|
| 200 | - $branche_maj = $maj2 . '.' . $min2; |
|
| 201 | - $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 202 | - $is_version_stable = is_numeric($rev2); |
|
| 203 | - // d'abord les mises à jour de la même branche (version mineure) |
|
| 204 | - if ( |
|
| 205 | - spip_version_compare($version, $version_maj, '<') |
|
| 206 | - && spip_version_compare($maj['mineure'], $version_maj, '<') |
|
| 207 | - && spip_version_compare($branche, $branche_maj, '=') |
|
| 208 | - ) { |
|
| 209 | - $maj['mineure'] = $version_maj; |
|
| 210 | - } |
|
| 211 | - // puis les mises à jours majeures |
|
| 212 | - if ( |
|
| 213 | - $is_version_stable |
|
| 214 | - && spip_version_compare($version, $version_maj, '<') |
|
| 215 | - && spip_version_compare($maj['majeure'], $version_maj, '<') |
|
| 216 | - && spip_version_compare($branche, $branche_maj, '<') |
|
| 217 | - ) { |
|
| 218 | - $maj['majeure'] = $version_maj; |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - return $maj; |
|
| 187 | + $maj = ['mineure' => '', 'majeure' => '']; |
|
| 188 | + if (!$version) { |
|
| 189 | + return $maj; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + // pas de version dev |
|
| 193 | + $versions = array_diff($versions, ['dev']); |
|
| 194 | + |
|
| 195 | + // branche en cours d'utilisation |
|
| 196 | + $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2)); |
|
| 197 | + |
|
| 198 | + foreach ($versions as $v) { |
|
| 199 | + [$maj2, $min2, $rev2] = explode('.', $v); |
|
| 200 | + $branche_maj = $maj2 . '.' . $min2; |
|
| 201 | + $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
|
| 202 | + $is_version_stable = is_numeric($rev2); |
|
| 203 | + // d'abord les mises à jour de la même branche (version mineure) |
|
| 204 | + if ( |
|
| 205 | + spip_version_compare($version, $version_maj, '<') |
|
| 206 | + && spip_version_compare($maj['mineure'], $version_maj, '<') |
|
| 207 | + && spip_version_compare($branche, $branche_maj, '=') |
|
| 208 | + ) { |
|
| 209 | + $maj['mineure'] = $version_maj; |
|
| 210 | + } |
|
| 211 | + // puis les mises à jours majeures |
|
| 212 | + if ( |
|
| 213 | + $is_version_stable |
|
| 214 | + && spip_version_compare($version, $version_maj, '<') |
|
| 215 | + && spip_version_compare($maj['majeure'], $version_maj, '<') |
|
| 216 | + && spip_version_compare($branche, $branche_maj, '<') |
|
| 217 | + ) { |
|
| 218 | + $maj['majeure'] = $version_maj; |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + return $maj; |
|
| 223 | 223 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |