@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 4 | - return; |
|
| 4 | + return; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function trier_rss($texte) { |
| 8 | - if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | - $placeholder = '<!--REINSERT-->'; |
|
| 10 | - $items = []; |
|
| 11 | - foreach ($matches as $match) { |
|
| 12 | - if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | - $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | - $texte = str_replace($match[0], unique($placeholder), $texte); |
|
| 15 | - } |
|
| 16 | - } |
|
| 17 | - krsort($items); |
|
| 18 | - $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 19 | - } |
|
| 8 | + if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | + $placeholder = '<!--REINSERT-->'; |
|
| 10 | + $items = []; |
|
| 11 | + foreach ($matches as $match) { |
|
| 12 | + if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | + $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | + $texte = str_replace($match[0], unique($placeholder), $texte); |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | + krsort($items); |
|
| 18 | + $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - return $texte; |
|
| 21 | + return $texte; |
|
| 22 | 22 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | krsort($items); |
| 18 | - $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 18 | + $texte = str_replace($placeholder, implode("\n\t", $items)."\n", $texte); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | return $texte; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -31,43 +31,43 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function action_instituer_langue_objet_dist($objet, $id, $id_rubrique, $changer_lang, $serveur = '') { |
| 34 | - if ($changer_lang) { |
|
| 35 | - $table_objet_sql = table_objet_sql($objet); |
|
| 36 | - $id_table_objet = id_table_objet($objet); |
|
| 37 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 38 | - $desc = $trouver_table($table_objet_sql, $serveur); |
|
| 34 | + if ($changer_lang) { |
|
| 35 | + $table_objet_sql = table_objet_sql($objet); |
|
| 36 | + $id_table_objet = id_table_objet($objet); |
|
| 37 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 38 | + $desc = $trouver_table($table_objet_sql, $serveur); |
|
| 39 | 39 | |
| 40 | - $set = []; |
|
| 41 | - if (isset($desc['field']['langue_choisie'])) { |
|
| 42 | - $set['langue_choisie'] = 'oui'; |
|
| 43 | - } |
|
| 40 | + $set = []; |
|
| 41 | + if (isset($desc['field']['langue_choisie'])) { |
|
| 42 | + $set['langue_choisie'] = 'oui'; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - if ($changer_lang != 'herit') { |
|
| 46 | - $set['lang'] = $changer_lang; |
|
| 47 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 48 | - include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
|
| 49 | - if ($table_objet_sql == 'spip_rubriques') { |
|
| 50 | - calculer_langues_rubriques(); |
|
| 51 | - } |
|
| 52 | - $langues = calculer_langues_utilisees($serveur); |
|
| 53 | - ecrire_meta('langues_utilisees', $langues); |
|
| 54 | - } else { |
|
| 55 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 56 | - if (!$langue_parent) { |
|
| 57 | - $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 58 | - } |
|
| 59 | - $changer_lang = $langue_parent; |
|
| 60 | - $set['lang'] = $changer_lang; |
|
| 61 | - if (isset($set['langue_choisie'])) { |
|
| 62 | - $set['langue_choisie'] = 'non'; |
|
| 63 | - } |
|
| 64 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 65 | - if ($table_objet_sql == 'spip_rubriques') { |
|
| 66 | - include_spip('inc/rubriques'); |
|
| 67 | - calculer_langues_rubriques(); |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - } |
|
| 45 | + if ($changer_lang != 'herit') { |
|
| 46 | + $set['lang'] = $changer_lang; |
|
| 47 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 48 | + include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
|
| 49 | + if ($table_objet_sql == 'spip_rubriques') { |
|
| 50 | + calculer_langues_rubriques(); |
|
| 51 | + } |
|
| 52 | + $langues = calculer_langues_utilisees($serveur); |
|
| 53 | + ecrire_meta('langues_utilisees', $langues); |
|
| 54 | + } else { |
|
| 55 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 56 | + if (!$langue_parent) { |
|
| 57 | + $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 58 | + } |
|
| 59 | + $changer_lang = $langue_parent; |
|
| 60 | + $set['lang'] = $changer_lang; |
|
| 61 | + if (isset($set['langue_choisie'])) { |
|
| 62 | + $set['langue_choisie'] = 'non'; |
|
| 63 | + } |
|
| 64 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 65 | + if ($table_objet_sql == 'spip_rubriques') { |
|
| 66 | + include_spip('inc/rubriques'); |
|
| 67 | + calculer_langues_rubriques(); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $changer_lang; |
|
| 72 | + return $changer_lang; |
|
| 73 | 73 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | if ($changer_lang != 'herit') { |
| 46 | 46 | $set['lang'] = $changer_lang; |
| 47 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 47 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=".intval($id), [], $serveur); |
|
| 48 | 48 | include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
| 49 | 49 | if ($table_objet_sql == 'spip_rubriques') { |
| 50 | 50 | calculer_langues_rubriques(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $langues = calculer_langues_utilisees($serveur); |
| 53 | 53 | ecrire_meta('langues_utilisees', $langues); |
| 54 | 54 | } else { |
| 55 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 55 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 56 | 56 | if (!$langue_parent) { |
| 57 | 57 | $langue_parent = $GLOBALS['meta']['langue_site']; |
| 58 | 58 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if (isset($set['langue_choisie'])) { |
| 62 | 62 | $set['langue_choisie'] = 'non'; |
| 63 | 63 | } |
| 64 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 64 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=".intval($id), [], $serveur); |
|
| 65 | 65 | if ($table_objet_sql == 'spip_rubriques') { |
| 66 | 66 | include_spip('inc/rubriques'); |
| 67 | 67 | calculer_langues_rubriques(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
| 57 | 57 | if (!is_numeric(_request('reinstall'))) { |
| 58 | 58 | include_spip('base/create'); |
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 60 | 60 | creer_base(); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | exit; |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 73 | 73 | |
| 74 | 74 | // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
| 75 | 75 | @spip_unlink(_CACHE_RUBRIQUES); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | @spip_unlink(_CACHE_PLUGINS_OPT); |
| 79 | 79 | @spip_unlink(_CACHE_PLUGINS_FCT); |
| 80 | 80 | @spip_unlink(_CACHE_CHEMIN); |
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 81 | + @spip_unlink(_DIR_TMP.'plugin_xml_cache.gz'); |
|
| 82 | 82 | |
| 83 | 83 | include_spip('inc/auth'); |
| 84 | 84 | auth_synchroniser_distant(); |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
| 118 | 118 | |
| 119 | 119 | spip_log( |
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 120 | + "Version anterieure: $version_installee. Courante: ".$GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 122 | 122 | ); |
| 123 | 123 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 124 | 124 | sql_replace( |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
| 152 | 152 | if ($res) { |
| 153 | 153 | if (!is_array($res)) { |
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_ERREUR); |
|
| 155 | 155 | } else { |
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 156 | + echo _T('avis_operation_echec').' '.join(' ', $res); |
|
| 157 | 157 | echo install_fin_html(); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
| 242 | 242 | if ($res) { |
| 243 | 243 | if (!is_array($res)) { |
| 244 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 244 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_ERREUR); |
|
| 245 | 245 | } else { |
| 246 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 246 | + echo '<p>'._T('avis_operation_echec').' '.join(' ', $res).'</p>'; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | echo(install_debut_html($titre)); |
| 300 | 300 | // script de rechargement auto sur timeout |
| 301 | 301 | $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
| 302 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 302 | + echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout * 1000).')'); |
|
| 303 | 303 | echo "<div style='text-align: left'>\n"; |
| 304 | 304 | if (ob_get_level()) { |
| 305 | 305 | ob_flush(); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | return [$v, $etape]; |
| 389 | 389 | } |
| 390 | 390 | $n = time() - $time; |
| 391 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 391 | + spip_log("$table $meta: $v en $n secondes", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 392 | 392 | if ($meta) { |
| 393 | 393 | ecrire_meta($meta, $installee = $v, 'oui', $table); |
| 394 | 394 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if ($meta) { |
| 405 | 405 | ecrire_meta($meta, $cible, 'oui', $table); |
| 406 | 406 | } |
| 407 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 407 | + spip_log("MAJ terminee. $meta: $installee", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 408 | 408 | |
| 409 | 409 | return []; |
| 410 | 410 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * @return int |
| 430 | 430 | */ |
| 431 | 431 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 432 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 432 | + $meta2 = $meta.'_maj_'.$serie; |
|
| 433 | 433 | $etape = 0; |
| 434 | 434 | if (isset($GLOBALS[$table][$meta2])) { |
| 435 | 435 | $etape = intval($GLOBALS[$table][$meta2]); |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | and function_exists($f = array_shift($r)) |
| 443 | 443 | ) { |
| 444 | 444 | // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
| 445 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 445 | + spip_log("$msg: $f ".@join(',', $r), 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 446 | 446 | // pour les fonctions atomiques sql_xx |
| 447 | 447 | // on enregistre le meta avant de lancer la fonction, |
| 448 | 448 | // de maniere a eviter de boucler sur timeout |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | relance_maj($meta, $table, $redirect); |
| 461 | 461 | } |
| 462 | 462 | ecrire_meta($meta2, $i + 1, 'non', $table); |
| 463 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 463 | + spip_log("$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 464 | 464 | } else { |
| 465 | 465 | if (!is_array($r)) { |
| 466 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 466 | + spip_log("maj $i format incorrect", 'maj.'._LOG_ERREUR); |
|
| 467 | 467 | } else { |
| 468 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 468 | + spip_log("maj $i fonction $f non definie", 'maj.'._LOG_ERREUR); |
|
| 469 | 469 | } |
| 470 | 470 | // en cas d'erreur serieuse, on s'arrete |
| 471 | 471 | // mais on permet de passer par dessus en rechargeant la page. |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!defined('_UPGRADE_TIME_OUT')) { |
| 24 | - /** |
|
| 25 | - * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | - * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | - * |
|
| 28 | - * @var int |
|
| 29 | - **/ |
|
| 30 | - define('_UPGRADE_TIME_OUT', 20); |
|
| 24 | + /** |
|
| 25 | + * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | + * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | + * |
|
| 28 | + * @var int |
|
| 29 | + **/ |
|
| 30 | + define('_UPGRADE_TIME_OUT', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -50,40 +50,40 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function base_upgrade_dist($titre = '', $reprise = '') { |
| 53 | - if (!$titre) { |
|
| 54 | - return; |
|
| 55 | - } // anti-testeur automatique |
|
| 56 | - if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | - if (!is_numeric(_request('reinstall'))) { |
|
| 58 | - include_spip('base/create'); |
|
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | - creer_base(); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | - // lancement de l'upgrade SPIP |
|
| 65 | - $res = maj_base(); |
|
| 66 | - |
|
| 67 | - if ($res) { |
|
| 68 | - // on arrete tout ici ! |
|
| 69 | - exit; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | - |
|
| 74 | - // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | - @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | - @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | - @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | - @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | - @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | - @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | - |
|
| 83 | - include_spip('inc/auth'); |
|
| 84 | - auth_synchroniser_distant(); |
|
| 85 | - $config = charger_fonction('config', 'inc'); |
|
| 86 | - $config(); |
|
| 53 | + if (!$titre) { |
|
| 54 | + return; |
|
| 55 | + } // anti-testeur automatique |
|
| 56 | + if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | + if (!is_numeric(_request('reinstall'))) { |
|
| 58 | + include_spip('base/create'); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | + creer_base(); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | + // lancement de l'upgrade SPIP |
|
| 65 | + $res = maj_base(); |
|
| 66 | + |
|
| 67 | + if ($res) { |
|
| 68 | + // on arrete tout ici ! |
|
| 69 | + exit; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | + |
|
| 74 | + // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | + @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | + @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | + @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | + @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | + @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | + @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | + @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | + |
|
| 83 | + include_spip('inc/auth'); |
|
| 84 | + auth_synchroniser_distant(); |
|
| 85 | + $config = charger_fonction('config', 'inc'); |
|
| 86 | + $config(); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -114,51 +114,51 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function maj_base($version_cible = 0, $redirect = '', $debut_page = true) { |
| 116 | 116 | |
| 117 | - $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | - |
|
| 119 | - spip_log( |
|
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | - ); |
|
| 123 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | - sql_replace( |
|
| 125 | - 'spip_meta', |
|
| 126 | - [ |
|
| 127 | - 'nom' => 'version_installee', |
|
| 128 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | - 'impt' => 'non' |
|
| 130 | - ] |
|
| 131 | - ); |
|
| 132 | - return false; |
|
| 133 | - } |
|
| 134 | - if (!upgrade_test()) { |
|
| 135 | - return true; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $cible = ($version_cible ?: $GLOBALS['spip_version_base']); |
|
| 139 | - |
|
| 140 | - if ($version_installee < 2021_01_01_00) { |
|
| 141 | - include_spip('maj/legacy/v21'); |
|
| 142 | - include_spip('maj/legacy/v30'); |
|
| 143 | - include_spip('maj/legacy/v31'); |
|
| 144 | - include_spip('maj/legacy/v32'); |
|
| 145 | - include_spip('maj/legacy/v40'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - include_spip('maj/2021'); |
|
| 149 | - |
|
| 150 | - ksort($GLOBALS['maj']); |
|
| 151 | - $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | - if ($res) { |
|
| 153 | - if (!is_array($res)) { |
|
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 155 | - } else { |
|
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | - echo install_fin_html(); |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $res; |
|
| 117 | + $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | + |
|
| 119 | + spip_log( |
|
| 120 | + "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | + ); |
|
| 123 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | + sql_replace( |
|
| 125 | + 'spip_meta', |
|
| 126 | + [ |
|
| 127 | + 'nom' => 'version_installee', |
|
| 128 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | + 'impt' => 'non' |
|
| 130 | + ] |
|
| 131 | + ); |
|
| 132 | + return false; |
|
| 133 | + } |
|
| 134 | + if (!upgrade_test()) { |
|
| 135 | + return true; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $cible = ($version_cible ?: $GLOBALS['spip_version_base']); |
|
| 139 | + |
|
| 140 | + if ($version_installee < 2021_01_01_00) { |
|
| 141 | + include_spip('maj/legacy/v21'); |
|
| 142 | + include_spip('maj/legacy/v30'); |
|
| 143 | + include_spip('maj/legacy/v31'); |
|
| 144 | + include_spip('maj/legacy/v32'); |
|
| 145 | + include_spip('maj/legacy/v40'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + include_spip('maj/2021'); |
|
| 149 | + |
|
| 150 | + ksort($GLOBALS['maj']); |
|
| 151 | + $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | + if ($res) { |
|
| 153 | + if (!is_array($res)) { |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 155 | + } else { |
|
| 156 | + echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | + echo install_fin_html(); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $res; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -200,53 +200,53 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') { |
| 202 | 202 | |
| 203 | - if ($table_meta !== 'meta') { |
|
| 204 | - installer_table_meta($table_meta); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - $current_version = null; |
|
| 208 | - |
|
| 209 | - if ( |
|
| 210 | - (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 211 | - || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 212 | - ) { |
|
| 213 | - // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 214 | - // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 215 | - if (isset($maj['create'])) { |
|
| 216 | - if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 217 | - // installation : on ne fait que l'operation create |
|
| 218 | - $maj = ['init' => $maj['create']]; |
|
| 219 | - // et on lui ajoute un appel a inc/config |
|
| 220 | - // pour creer les metas par defaut |
|
| 221 | - $config = charger_fonction('config', 'inc'); |
|
| 222 | - $maj[$version_cible] = [[$config]]; |
|
| 223 | - } |
|
| 224 | - // dans tous les cas enlever cet index du tableau |
|
| 225 | - unset($maj['create']); |
|
| 226 | - } |
|
| 227 | - // si init, deja dans le bon ordre |
|
| 228 | - if (!isset($maj['init'])) { |
|
| 229 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 230 | - uksort($maj, 'spip_version_compare'); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 234 | - // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 235 | - // ou define _REDIRECT_MAJ_PLUGIN |
|
| 236 | - $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 237 | - if (defined('_ECRIRE_INSTALL')) { |
|
| 238 | - $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 242 | - if ($res) { |
|
| 243 | - if (!is_array($res)) { |
|
| 244 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 245 | - } else { |
|
| 246 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } |
|
| 203 | + if ($table_meta !== 'meta') { |
|
| 204 | + installer_table_meta($table_meta); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + $current_version = null; |
|
| 208 | + |
|
| 209 | + if ( |
|
| 210 | + (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 211 | + || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 212 | + ) { |
|
| 213 | + // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 214 | + // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 215 | + if (isset($maj['create'])) { |
|
| 216 | + if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 217 | + // installation : on ne fait que l'operation create |
|
| 218 | + $maj = ['init' => $maj['create']]; |
|
| 219 | + // et on lui ajoute un appel a inc/config |
|
| 220 | + // pour creer les metas par defaut |
|
| 221 | + $config = charger_fonction('config', 'inc'); |
|
| 222 | + $maj[$version_cible] = [[$config]]; |
|
| 223 | + } |
|
| 224 | + // dans tous les cas enlever cet index du tableau |
|
| 225 | + unset($maj['create']); |
|
| 226 | + } |
|
| 227 | + // si init, deja dans le bon ordre |
|
| 228 | + if (!isset($maj['init'])) { |
|
| 229 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 230 | + uksort($maj, 'spip_version_compare'); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 234 | + // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 235 | + // ou define _REDIRECT_MAJ_PLUGIN |
|
| 236 | + $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 237 | + if (defined('_ECRIRE_INSTALL')) { |
|
| 238 | + $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 242 | + if ($res) { |
|
| 243 | + if (!is_array($res)) { |
|
| 244 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 245 | + } else { |
|
| 246 | + echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -263,17 +263,17 @@ discard block |
||
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | 265 | function relance_maj($meta, $table, $redirect = '') { |
| 266 | - include_spip('inc/headers'); |
|
| 267 | - if (!$redirect) { |
|
| 268 | - // recuperer la valeur installee en cours |
|
| 269 | - // on la tronque numeriquement, elle ne sert pas reellement |
|
| 270 | - // sauf pour verifier que ce n'est pas oui ou non |
|
| 271 | - // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 272 | - $installee = intval($GLOBALS[$table][$meta]); |
|
| 273 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 274 | - } |
|
| 275 | - echo redirige_formulaire($redirect); |
|
| 276 | - exit(); |
|
| 266 | + include_spip('inc/headers'); |
|
| 267 | + if (!$redirect) { |
|
| 268 | + // recuperer la valeur installee en cours |
|
| 269 | + // on la tronque numeriquement, elle ne sert pas reellement |
|
| 270 | + // sauf pour verifier que ce n'est pas oui ou non |
|
| 271 | + // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 272 | + $installee = intval($GLOBALS[$table][$meta]); |
|
| 273 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 274 | + } |
|
| 275 | + echo redirige_formulaire($redirect); |
|
| 276 | + exit(); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -286,28 +286,28 @@ discard block |
||
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | 288 | function maj_debut_page($installee, $meta, $table) { |
| 289 | - static $done = false; |
|
| 290 | - if ($done) { |
|
| 291 | - return; |
|
| 292 | - } |
|
| 293 | - include_spip('inc/minipres'); |
|
| 294 | - if (function_exists('ini_set')) { |
|
| 295 | - @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 296 | - } |
|
| 297 | - $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 298 | - $titre = _T('titre_page_upgrade'); |
|
| 299 | - $balise_img = charger_filtre('balise_img'); |
|
| 300 | - $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader'); |
|
| 301 | - echo(install_debut_html($titre)); |
|
| 302 | - // script de rechargement auto sur timeout |
|
| 303 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 304 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 305 | - echo "<div style='text-align: left'>\n"; |
|
| 306 | - if (ob_get_level()) { |
|
| 307 | - ob_flush(); |
|
| 308 | - } |
|
| 309 | - flush(); |
|
| 310 | - $done = true; |
|
| 289 | + static $done = false; |
|
| 290 | + if ($done) { |
|
| 291 | + return; |
|
| 292 | + } |
|
| 293 | + include_spip('inc/minipres'); |
|
| 294 | + if (function_exists('ini_set')) { |
|
| 295 | + @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 296 | + } |
|
| 297 | + $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 298 | + $titre = _T('titre_page_upgrade'); |
|
| 299 | + $balise_img = charger_filtre('balise_img'); |
|
| 300 | + $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader'); |
|
| 301 | + echo(install_debut_html($titre)); |
|
| 302 | + // script de rechargement auto sur timeout |
|
| 303 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 304 | + echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 305 | + echo "<div style='text-align: left'>\n"; |
|
| 306 | + if (ob_get_level()) { |
|
| 307 | + ob_flush(); |
|
| 308 | + } |
|
| 309 | + flush(); |
|
| 310 | + $done = true; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | |
@@ -351,64 +351,64 @@ discard block |
||
| 351 | 351 | * - tableau vide sinon. |
| 352 | 352 | */ |
| 353 | 353 | function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false) { |
| 354 | - # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 355 | - include_spip('base/create'); |
|
| 356 | - include_spip('base/abstract_sql'); |
|
| 357 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 358 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 359 | - $n = 0; |
|
| 360 | - $time = time(); |
|
| 361 | - |
|
| 362 | - if (!defined('_TIME_OUT')) { |
|
| 363 | - /** |
|
| 364 | - * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 365 | - * de mises à jour qui durent trop longtemps |
|
| 366 | - * |
|
| 367 | - * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 368 | - * |
|
| 369 | - * @var int |
|
| 370 | - */ |
|
| 371 | - define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - foreach ($maj as $v => $operations) { |
|
| 375 | - // si une maj pour cette version |
|
| 376 | - if ( |
|
| 377 | - $v == 'init' or |
|
| 378 | - (spip_version_compare($v, $installee, '>') |
|
| 379 | - and spip_version_compare($v, $cible, '<=')) |
|
| 380 | - ) { |
|
| 381 | - if ($debut_page) { |
|
| 382 | - maj_debut_page($v, $meta, $table); |
|
| 383 | - } |
|
| 384 | - echo "MAJ $v"; |
|
| 385 | - $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 386 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 387 | - # echec sur une etape en cours ? |
|
| 388 | - # on sort |
|
| 389 | - if ($etape) { |
|
| 390 | - return [$v, $etape]; |
|
| 391 | - } |
|
| 392 | - $n = time() - $time; |
|
| 393 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 394 | - if ($meta) { |
|
| 395 | - ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 396 | - } |
|
| 397 | - echo (_IS_CLI ? "\n" : '<br />'); |
|
| 398 | - } |
|
| 399 | - if (time() >= _TIME_OUT) { |
|
| 400 | - relance_maj($meta, $table, $redirect); |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 404 | - // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 405 | - // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 406 | - if ($meta) { |
|
| 407 | - ecrire_meta($meta, $cible, 'oui', $table); |
|
| 408 | - } |
|
| 409 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 410 | - |
|
| 411 | - return []; |
|
| 354 | + # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 355 | + include_spip('base/create'); |
|
| 356 | + include_spip('base/abstract_sql'); |
|
| 357 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 358 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 359 | + $n = 0; |
|
| 360 | + $time = time(); |
|
| 361 | + |
|
| 362 | + if (!defined('_TIME_OUT')) { |
|
| 363 | + /** |
|
| 364 | + * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 365 | + * de mises à jour qui durent trop longtemps |
|
| 366 | + * |
|
| 367 | + * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 368 | + * |
|
| 369 | + * @var int |
|
| 370 | + */ |
|
| 371 | + define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + foreach ($maj as $v => $operations) { |
|
| 375 | + // si une maj pour cette version |
|
| 376 | + if ( |
|
| 377 | + $v == 'init' or |
|
| 378 | + (spip_version_compare($v, $installee, '>') |
|
| 379 | + and spip_version_compare($v, $cible, '<=')) |
|
| 380 | + ) { |
|
| 381 | + if ($debut_page) { |
|
| 382 | + maj_debut_page($v, $meta, $table); |
|
| 383 | + } |
|
| 384 | + echo "MAJ $v"; |
|
| 385 | + $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 386 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 387 | + # echec sur une etape en cours ? |
|
| 388 | + # on sort |
|
| 389 | + if ($etape) { |
|
| 390 | + return [$v, $etape]; |
|
| 391 | + } |
|
| 392 | + $n = time() - $time; |
|
| 393 | + spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 394 | + if ($meta) { |
|
| 395 | + ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 396 | + } |
|
| 397 | + echo (_IS_CLI ? "\n" : '<br />'); |
|
| 398 | + } |
|
| 399 | + if (time() >= _TIME_OUT) { |
|
| 400 | + relance_maj($meta, $table, $redirect); |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 404 | + // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 405 | + // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 406 | + if ($meta) { |
|
| 407 | + ecrire_meta($meta, $cible, 'oui', $table); |
|
| 408 | + } |
|
| 409 | + spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 410 | + |
|
| 411 | + return []; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -431,53 +431,53 @@ discard block |
||
| 431 | 431 | * @return int |
| 432 | 432 | */ |
| 433 | 433 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 434 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 435 | - $etape = 0; |
|
| 436 | - if (isset($GLOBALS[$table][$meta2])) { |
|
| 437 | - $etape = intval($GLOBALS[$table][$meta2]); |
|
| 438 | - } |
|
| 439 | - foreach ($q as $i => $r) { |
|
| 440 | - if ($i >= $etape) { |
|
| 441 | - $msg = "maj $table $meta2 etape $i"; |
|
| 442 | - if ( |
|
| 443 | - is_array($r) |
|
| 444 | - and function_exists($f = array_shift($r)) |
|
| 445 | - ) { |
|
| 446 | - // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 447 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 448 | - // pour les fonctions atomiques sql_xx |
|
| 449 | - // on enregistre le meta avant de lancer la fonction, |
|
| 450 | - // de maniere a eviter de boucler sur timeout |
|
| 451 | - // mais pour les fonctions complexes, |
|
| 452 | - // il faut les rejouer jusqu'a achevement. |
|
| 453 | - // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 454 | - if (strncmp($f, 'sql_', 4) == 0) { |
|
| 455 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 456 | - } |
|
| 457 | - echo (_IS_CLI ? '.' : " <span title='$i'>.</span>"); |
|
| 458 | - $f(...$r); |
|
| 459 | - // si temps imparti depasse, on relance sans ecrire en meta |
|
| 460 | - // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 461 | - if (time() >= _TIME_OUT) { |
|
| 462 | - relance_maj($meta, $table, $redirect); |
|
| 463 | - } |
|
| 464 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 465 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 466 | - } else { |
|
| 467 | - if (!is_array($r)) { |
|
| 468 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 469 | - } else { |
|
| 470 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 471 | - } |
|
| 472 | - // en cas d'erreur serieuse, on s'arrete |
|
| 473 | - // mais on permet de passer par dessus en rechargeant la page. |
|
| 474 | - return $i + 1; |
|
| 475 | - } |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - effacer_meta($meta2, $table); |
|
| 479 | - |
|
| 480 | - return 0; |
|
| 434 | + $meta2 = $meta . '_maj_' . $serie; |
|
| 435 | + $etape = 0; |
|
| 436 | + if (isset($GLOBALS[$table][$meta2])) { |
|
| 437 | + $etape = intval($GLOBALS[$table][$meta2]); |
|
| 438 | + } |
|
| 439 | + foreach ($q as $i => $r) { |
|
| 440 | + if ($i >= $etape) { |
|
| 441 | + $msg = "maj $table $meta2 etape $i"; |
|
| 442 | + if ( |
|
| 443 | + is_array($r) |
|
| 444 | + and function_exists($f = array_shift($r)) |
|
| 445 | + ) { |
|
| 446 | + // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 447 | + spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 448 | + // pour les fonctions atomiques sql_xx |
|
| 449 | + // on enregistre le meta avant de lancer la fonction, |
|
| 450 | + // de maniere a eviter de boucler sur timeout |
|
| 451 | + // mais pour les fonctions complexes, |
|
| 452 | + // il faut les rejouer jusqu'a achevement. |
|
| 453 | + // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 454 | + if (strncmp($f, 'sql_', 4) == 0) { |
|
| 455 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 456 | + } |
|
| 457 | + echo (_IS_CLI ? '.' : " <span title='$i'>.</span>"); |
|
| 458 | + $f(...$r); |
|
| 459 | + // si temps imparti depasse, on relance sans ecrire en meta |
|
| 460 | + // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 461 | + if (time() >= _TIME_OUT) { |
|
| 462 | + relance_maj($meta, $table, $redirect); |
|
| 463 | + } |
|
| 464 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 465 | + spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 466 | + } else { |
|
| 467 | + if (!is_array($r)) { |
|
| 468 | + spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 469 | + } else { |
|
| 470 | + spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 471 | + } |
|
| 472 | + // en cas d'erreur serieuse, on s'arrete |
|
| 473 | + // mais on permet de passer par dessus en rechargeant la page. |
|
| 474 | + return $i + 1; |
|
| 475 | + } |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + effacer_meta($meta2, $table); |
|
| 479 | + |
|
| 480 | + return 0; |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -486,16 +486,16 @@ discard block |
||
| 486 | 486 | * @return bool True si possible. |
| 487 | 487 | **/ |
| 488 | 488 | function upgrade_test() { |
| 489 | - sql_drop_table('spip_test', true); |
|
| 490 | - sql_create('spip_test', ['a' => 'int']); |
|
| 491 | - sql_alter('TABLE spip_test ADD b INT'); |
|
| 492 | - sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]); |
|
| 493 | - $result = sql_select('b', 'spip_test'); |
|
| 494 | - // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 495 | - // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 496 | - // car cette table serait alors 'verouillee' |
|
| 497 | - $result = $result ? true : false; |
|
| 498 | - sql_alter('TABLE spip_test DROP b'); |
|
| 499 | - |
|
| 500 | - return $result; |
|
| 489 | + sql_drop_table('spip_test', true); |
|
| 490 | + sql_create('spip_test', ['a' => 'int']); |
|
| 491 | + sql_alter('TABLE spip_test ADD b INT'); |
|
| 492 | + sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]); |
|
| 493 | + $result = sql_select('b', 'spip_test'); |
|
| 494 | + // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 495 | + // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 496 | + // car cette table serait alors 'verouillee' |
|
| 497 | + $result = $result ? true : false; |
|
| 498 | + sql_alter('TABLE spip_test DROP b'); |
|
| 499 | + |
|
| 500 | + return $result; |
|
| 501 | 501 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | include_spip('inc/lang'); |
| 100 | 100 | |
| 101 | 101 | if ($GLOBALS['spip_lang'] <> $default) { |
| 102 | - $opt = lang_select($default); # et remplace |
|
| 102 | + $opt = lang_select($default); # et remplace |
|
| 103 | 103 | if ($GLOBALS['spip_lang'] <> $default) { |
| 104 | - $default = ''; # annule tout choix par defaut |
|
| 104 | + $default = ''; # annule tout choix par defaut |
|
| 105 | 105 | if ($opt) { |
| 106 | 106 | lang_select(); |
| 107 | 107 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | # lien a partir de / |
| 112 | 112 | $cible = parametre_url(self(), 'lang', '', '&'); |
| 113 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 113 | + $post = generer_url_action('converser', 'redirect='.rawurlencode($cible), true); |
|
| 114 | 114 | |
| 115 | 115 | return [ |
| 116 | 116 | 'formulaires/menu_lang', |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG_ECRIRE($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | * - string: Si pas de multilinguisme |
| 57 | 57 | */ |
| 58 | 58 | function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) { |
| 59 | - include_spip('inc/lang'); |
|
| 60 | - if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 61 | - return ''; |
|
| 62 | - } |
|
| 59 | + include_spip('inc/lang'); |
|
| 60 | + if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 61 | + return ''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $args; |
|
| 64 | + return $args; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * Liste : Chemin du squelette, durée du cache, contexte |
| 78 | 78 | **/ |
| 79 | 79 | function balise_MENU_LANG_ECRIRE_dyn($opt) { |
| 80 | - return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 80 | + return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -97,30 +97,30 @@ discard block |
||
| 97 | 97 | * Liste : Chemin du squelette, durée du cache, contexte |
| 98 | 98 | **/ |
| 99 | 99 | function menu_lang_pour_tous($nom, $default) { |
| 100 | - include_spip('inc/lang'); |
|
| 100 | + include_spip('inc/lang'); |
|
| 101 | 101 | |
| 102 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 103 | - $opt = lang_select($default); # et remplace |
|
| 104 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 105 | - $default = ''; # annule tout choix par defaut |
|
| 106 | - if ($opt) { |
|
| 107 | - lang_select(); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - } |
|
| 102 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 103 | + $opt = lang_select($default); # et remplace |
|
| 104 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 105 | + $default = ''; # annule tout choix par defaut |
|
| 106 | + if ($opt) { |
|
| 107 | + lang_select(); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - # lien a partir de / |
|
| 113 | - $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 114 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 112 | + # lien a partir de / |
|
| 113 | + $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 114 | + $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 115 | 115 | |
| 116 | - return [ |
|
| 117 | - 'formulaires/menu_lang', |
|
| 118 | - 3600, |
|
| 119 | - [ |
|
| 120 | - 'nom' => $nom, |
|
| 121 | - 'url' => $post, |
|
| 122 | - 'name' => $nom, |
|
| 123 | - 'default' => $default, |
|
| 124 | - ] |
|
| 125 | - ]; |
|
| 116 | + return [ |
|
| 117 | + 'formulaires/menu_lang', |
|
| 118 | + 3600, |
|
| 119 | + [ |
|
| 120 | + 'nom' => $nom, |
|
| 121 | + 'url' => $post, |
|
| 122 | + 'name' => $nom, |
|
| 123 | + 'default' => $default, |
|
| 124 | + ] |
|
| 125 | + ]; |
|
| 126 | 126 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | * string: (vide) si pas de multilinguisme |
| 57 | 57 | */ |
| 58 | 58 | function balise_MENU_LANG_stat($args, $context_compil) { |
| 59 | - if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 59 | + if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return $args; |
|
| 63 | + return $args; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * Liste : Chemin du squelette, durée du cache, contexte |
| 77 | 77 | **/ |
| 78 | 78 | function balise_MENU_LANG_dyn($opt) { |
| 79 | - include_spip('balise/menu_lang_ecrire'); |
|
| 79 | + include_spip('balise/menu_lang_ecrire'); |
|
| 80 | 80 | |
| 81 | - return menu_lang_pour_tous('var_lang', $opt); |
|
| 81 | + return menu_lang_pour_tous('var_lang', $opt); |
|
| 82 | 82 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | **/ |
| 23 | 23 | |
| 24 | 24 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 25 | - return; |
|
| 25 | + return; |
|
| 26 | 26 | } |
| 27 | 27 | include_spip('inc/filtres'); |
| 28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @return string Rien. |
| 40 | 40 | **/ |
| 41 | 41 | function filtre_image_dist($t) { |
| 42 | - return ''; |
|
| 42 | + return ''; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return string Rien. |
| 53 | 53 | **/ |
| 54 | 54 | function filtre_audio_dist($t) { |
| 55 | - return ''; |
|
| 55 | + return ''; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @return string Rien. |
| 66 | 66 | **/ |
| 67 | 67 | function filtre_video_dist($t) { |
| 68 | - return ''; |
|
| 68 | + return ''; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return string Rien. |
| 79 | 79 | **/ |
| 80 | 80 | function filtre_application_dist($t) { |
| 81 | - return ''; |
|
| 81 | + return ''; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return string Rien. |
| 92 | 92 | **/ |
| 93 | 93 | function filtre_message_dist($t) { |
| 94 | - return ''; |
|
| 94 | + return ''; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return string Rien. |
| 105 | 105 | **/ |
| 106 | 106 | function filtre_multipart_dist($t) { |
| 107 | - return ''; |
|
| 107 | + return ''; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | * @return string Contenu échappé. |
| 118 | 118 | **/ |
| 119 | 119 | function filtre_text_dist($t) { |
| 120 | - static $t1 = ['&', '<', '>']; |
|
| 121 | - static $t2 = ['&', '<', '>']; |
|
| 120 | + static $t1 = ['&', '<', '>']; |
|
| 121 | + static $t2 = ['&', '<', '>']; |
|
| 122 | 122 | |
| 123 | - return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 123 | + return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -135,21 +135,21 @@ discard block |
||
| 135 | 135 | * Tableau (formaté en SPIP) |
| 136 | 136 | **/ |
| 137 | 137 | function filtre_text_csv_dist($t) { |
| 138 | - include_spip('inc/csv'); |
|
| 139 | - [$entete, $lignes, $caption] = analyse_csv($t); |
|
| 140 | - foreach ($lignes as &$l) { |
|
| 141 | - $l = join('|', $l); |
|
| 142 | - } |
|
| 143 | - $corps = join("\n", $lignes) . "\n"; |
|
| 144 | - $corps = $caption . |
|
| 145 | - "\n|{{" . |
|
| 146 | - join('}}|{{', $entete) . |
|
| 147 | - '}}|' . |
|
| 148 | - "\n|" . |
|
| 149 | - str_replace("\n", "|\n|", $corps); |
|
| 150 | - include_spip('inc/texte'); |
|
| 151 | - |
|
| 152 | - return propre($corps); |
|
| 138 | + include_spip('inc/csv'); |
|
| 139 | + [$entete, $lignes, $caption] = analyse_csv($t); |
|
| 140 | + foreach ($lignes as &$l) { |
|
| 141 | + $l = join('|', $l); |
|
| 142 | + } |
|
| 143 | + $corps = join("\n", $lignes) . "\n"; |
|
| 144 | + $corps = $caption . |
|
| 145 | + "\n|{{" . |
|
| 146 | + join('}}|{{', $entete) . |
|
| 147 | + '}}|' . |
|
| 148 | + "\n|" . |
|
| 149 | + str_replace("\n", "|\n|", $corps); |
|
| 150 | + include_spip('inc/texte'); |
|
| 151 | + |
|
| 152 | + return propre($corps); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -163,33 +163,33 @@ discard block |
||
| 163 | 163 | * @return string Code html sécurisé ou texte échappé |
| 164 | 164 | **/ |
| 165 | 165 | function filtre_text_html_dist($t) { |
| 166 | - if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 167 | - return appliquer_filtre($t, 'text/plain'); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - [, $h, $t] = $r; |
|
| 171 | - |
|
| 172 | - $style = ''; |
|
| 173 | - // recuperer les styles internes |
|
| 174 | - if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 175 | - $style = join("\n", $r[1]); |
|
| 176 | - } |
|
| 177 | - // ... et externes |
|
| 178 | - |
|
| 179 | - include_spip('inc/distant'); |
|
| 180 | - if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 181 | - foreach ($r[0] as $l) { |
|
| 182 | - preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 183 | - $page = recuperer_url($m[1]); |
|
| 184 | - $page = $page['page'] ?? ''; |
|
| 185 | - $style .= "\n/* $l */\n" |
|
| 186 | - . str_replace('<', '', $page); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 190 | - $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 191 | - |
|
| 192 | - return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 166 | + if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 167 | + return appliquer_filtre($t, 'text/plain'); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + [, $h, $t] = $r; |
|
| 171 | + |
|
| 172 | + $style = ''; |
|
| 173 | + // recuperer les styles internes |
|
| 174 | + if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 175 | + $style = join("\n", $r[1]); |
|
| 176 | + } |
|
| 177 | + // ... et externes |
|
| 178 | + |
|
| 179 | + include_spip('inc/distant'); |
|
| 180 | + if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 181 | + foreach ($r[0] as $l) { |
|
| 182 | + preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 183 | + $page = recuperer_url($m[1]); |
|
| 184 | + $page = $page['page'] ?? ''; |
|
| 185 | + $style .= "\n/* $l */\n" |
|
| 186 | + . str_replace('<', '', $page); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 190 | + $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 191 | + |
|
| 192 | + return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return string Code HTML des balises `<param>` |
| 203 | 203 | **/ |
| 204 | 204 | function filtre_audio_x_pn_realaudio($id) { |
| 205 | - return " |
|
| 205 | + return " |
|
| 206 | 206 | <param name='controls' value='PositionSlider' /> |
| 207 | 207 | <param name='controls' value='ImageWindow' /> |
| 208 | 208 | <param name='controls' value='PlayButton' /> |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | static $t1 = ['&', '<', '>']; |
| 121 | 121 | static $t2 = ['&', '<', '>']; |
| 122 | 122 | |
| 123 | - return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 123 | + return '<pre>'.str_replace($t1, $t2, (string) $t).'</pre>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | foreach ($lignes as &$l) { |
| 141 | 141 | $l = join('|', $l); |
| 142 | 142 | } |
| 143 | - $corps = join("\n", $lignes) . "\n"; |
|
| 144 | - $corps = $caption . |
|
| 145 | - "\n|{{" . |
|
| 146 | - join('}}|{{', $entete) . |
|
| 147 | - '}}|' . |
|
| 148 | - "\n|" . |
|
| 143 | + $corps = join("\n", $lignes)."\n"; |
|
| 144 | + $corps = $caption. |
|
| 145 | + "\n|{{". |
|
| 146 | + join('}}|{{', $entete). |
|
| 147 | + '}}|'. |
|
| 148 | + "\n|". |
|
| 149 | 149 | str_replace("\n", "|\n|", $corps); |
| 150 | 150 | include_spip('inc/texte'); |
| 151 | 151 | |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
| 190 | - $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 190 | + $t = safehtml(preg_replace(',<script'.'.*?</script>,is', '', $t)); |
|
| 191 | 191 | |
| 192 | - return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 192 | + return (!$style ? '' : "\n<style>".$style.'</style>').$t; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -2868,8 +2868,7 @@ |
||
| 2868 | 2868 | $_const = interprete_argument_balise(1, $p); |
| 2869 | 2869 | if (!strlen($_const ?? '')) { |
| 2870 | 2870 | $p->code = "''"; |
| 2871 | - } |
|
| 2872 | - else { |
|
| 2871 | + } else { |
|
| 2873 | 2872 | $p->code = "(defined($_const)?constant($_const):'')"; |
| 2874 | 2873 | } |
| 2875 | 2874 | $p->interdire_scripts = false; |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | function balise_DOSSIER_SQUELETTE_dist($p) { |
| 360 | 360 | $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
| 361 | - $p->code = "_DIR_RACINE . '$code'" . |
|
| 361 | + $p->code = "_DIR_RACINE . '$code'". |
|
| 362 | 362 | $p->interdire_scripts = false; |
| 363 | 363 | |
| 364 | 364 | return $p; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | function balise_SQUELETTE_dist($p) { |
| 379 | 379 | $code = addslashes($p->descr['sourcefile']); |
| 380 | - $p->code = "'$code'" . |
|
| 380 | + $p->code = "'$code'". |
|
| 381 | 381 | $p->interdire_scripts = false; |
| 382 | 382 | |
| 383 | 383 | return $p; |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | **/ |
| 430 | 430 | function balise_NOM_SITE_dist($p) { |
| 431 | 431 | if (!$p->etoile) { |
| 432 | - $p->code = 'supprimer_numero(calculer_url(' . |
|
| 433 | - champ_sql('url_site', $p) . ',' . |
|
| 434 | - champ_sql('nom_site', $p) . |
|
| 432 | + $p->code = 'supprimer_numero(calculer_url('. |
|
| 433 | + champ_sql('url_site', $p).','. |
|
| 434 | + champ_sql('nom_site', $p). |
|
| 435 | 435 | ", 'titre', \$connect, false))"; |
| 436 | 436 | } else { |
| 437 | 437 | $p->code = champ_sql('nom_site', $p); |
@@ -582,8 +582,8 @@ discard block |
||
| 582 | 582 | * Pile complétée par le code à générer |
| 583 | 583 | **/ |
| 584 | 584 | function balise_POPULARITE_ABSOLUE_dist($p) { |
| 585 | - $p->code = 'ceil(' . |
|
| 586 | - champ_sql('popularite', $p) . |
|
| 585 | + $p->code = 'ceil('. |
|
| 586 | + champ_sql('popularite', $p). |
|
| 587 | 587 | ')'; |
| 588 | 588 | $p->interdire_scripts = false; |
| 589 | 589 | |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); |
| 665 | 665 | ; |
| 666 | 666 | if (($v = interprete_argument_balise(1, $p)) !== null) { |
| 667 | - $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 667 | + $p->code = 'table_valeur('.$p->code.', '.$v.')'; |
|
| 668 | 668 | } |
| 669 | 669 | $p->interdire_scripts = true; |
| 670 | 670 | |
@@ -804,16 +804,16 @@ discard block |
||
| 804 | 804 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 805 | 805 | if ($desc = $trouver_table(table_objet_sql($type_objet))) { |
| 806 | 806 | if (isset($desc['field']['descriptif'])) { |
| 807 | - $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ','; |
|
| 807 | + $_ligne .= "'descriptif' => ".champ_sql('descriptif', $p).','; |
|
| 808 | 808 | } |
| 809 | 809 | if (isset($desc['field']['texte'])) { |
| 810 | - $_ligne .= "'texte' => " . champ_sql('texte', $p) . ','; |
|
| 810 | + $_ligne .= "'texte' => ".champ_sql('texte', $p).','; |
|
| 811 | 811 | } |
| 812 | 812 | if (isset($desc['field']['chapo'])) { |
| 813 | - $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ','; |
|
| 813 | + $_ligne .= "'chapo' => ".champ_sql('chapo', $p).','; |
|
| 814 | 814 | } |
| 815 | 815 | if (isset($desc['introduction_longueur'])) { |
| 816 | - $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'"; |
|
| 816 | + $_introduction_longueur = "'".$desc['introduction_longueur']."'"; |
|
| 817 | 817 | } |
| 818 | 818 | } |
| 819 | 819 | $_ligne .= ')'; |
@@ -909,10 +909,10 @@ discard block |
||
| 909 | 909 | $p->code = sprintf( |
| 910 | 910 | CODE_RECUPERER_FOND, |
| 911 | 911 | "'modeles/lesauteurs'", |
| 912 | - "array('objet'=>'" . $objet . |
|
| 913 | - "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 914 | - ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 915 | - ($objet == 'article' ? '' : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 912 | + "array('objet'=>'".$objet. |
|
| 913 | + "','id_objet' => ".champ_sql($id_table_objet, $p). |
|
| 914 | + ",'$id_table_objet' => ".champ_sql($id_table_objet, $p). |
|
| 915 | + ($objet == 'article' ? '' : ",'id_article' => ".champ_sql('id_article', $p)). |
|
| 916 | 916 | ')', |
| 917 | 917 | "'trim'=>true, 'compil'=>array($c)", |
| 918 | 918 | _q($connect) |
@@ -981,7 +981,7 @@ discard block |
||
| 981 | 981 | $m = trim($m); |
| 982 | 982 | if ($m != "''") { |
| 983 | 983 | if (!preg_match(',\W,', $m)) { |
| 984 | - $m = $boucle->id_table . ".$m"; |
|
| 984 | + $m = $boucle->id_table.".$m"; |
|
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | $m .= ' AS titre_rang'; |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | $f_pagination = chercher_filtre('pagination'); |
| 1143 | 1143 | $type = $p->boucles[$b]->modificateur['debut_nom']; |
| 1144 | 1144 | $modif = ($type[0] !== "'") ? "'debut'.$type" |
| 1145 | - : ("'debut" . substr($type, 1)); |
|
| 1145 | + : ("'debut".substr($type, 1)); |
|
| 1146 | 1146 | |
| 1147 | 1147 | $p->code = sprintf( |
| 1148 | 1148 | CODE_PAGINATION, |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN']]; |
| 1286 | 1286 | erreur_squelette($msg, $p); |
| 1287 | 1287 | } else { |
| 1288 | - $p->code = 'find_in_path((string)' . $arg . ')'; |
|
| 1288 | + $p->code = 'find_in_path((string)'.$arg.')'; |
|
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | $p->interdire_scripts = false; |
@@ -1320,7 +1320,7 @@ discard block |
||
| 1320 | 1320 | $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN_IMAGE']]; |
| 1321 | 1321 | erreur_squelette($msg, $p); |
| 1322 | 1322 | } else { |
| 1323 | - $p->code = 'chemin_image((string)' . $arg . ')'; |
|
| 1323 | + $p->code = 'chemin_image((string)'.$arg.')'; |
|
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | $p->interdire_scripts = false; |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | // cas de #ENV sans argument : on retourne le serialize() du tableau |
| 1375 | 1375 | // une belle fonction [(#ENV|affiche_env)] serait pratique |
| 1376 | 1376 | if ($src) { |
| 1377 | - $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1377 | + $p->code = '(is_array($a = ('.$src.')) ? serialize($a) : "")'; |
|
| 1378 | 1378 | } else { |
| 1379 | 1379 | $p->code = 'serialize($Pile[0]??[])'; |
| 1380 | 1380 | } |
@@ -1427,8 +1427,8 @@ discard block |
||
| 1427 | 1427 | $_sinon = interprete_argument_balise(2, $p); |
| 1428 | 1428 | $_unserialize = sinon(interprete_argument_balise(3, $p), 'false'); |
| 1429 | 1429 | |
| 1430 | - $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1431 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1430 | + $p->code = '(include_spip(\'inc/config\')?lire_config('.$arg.','. |
|
| 1431 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null').','.$_unserialize."):'')"; |
|
| 1432 | 1432 | |
| 1433 | 1433 | return $p; |
| 1434 | 1434 | } |
@@ -1521,7 +1521,7 @@ discard block |
||
| 1521 | 1521 | $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SESSION_SET']]; |
| 1522 | 1522 | erreur_squelette($err_b_s_a, $p); |
| 1523 | 1523 | } else { |
| 1524 | - $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1524 | + $p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))'; |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | $p->interdire_scripts = false; |
@@ -1569,7 +1569,7 @@ discard block |
||
| 1569 | 1569 | ) |
| 1570 | 1570 | ) { |
| 1571 | 1571 | $p->code = /* $r[1]. */ |
| 1572 | - '(' . $r[2] . ')'; |
|
| 1572 | + '('.$r[2].')'; |
|
| 1573 | 1573 | } else { |
| 1574 | 1574 | $p->code = "eval('return '.$php.';')"; |
| 1575 | 1575 | } |
@@ -1813,9 +1813,9 @@ discard block |
||
| 1813 | 1813 | |
| 1814 | 1814 | // noter la duree du cache dans un entete proprietaire |
| 1815 | 1815 | |
| 1816 | - $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1816 | + $code = "'<'.'".'?php header("X-Spip-Cache: ' |
|
| 1817 | 1817 | . $duree |
| 1818 | - . '"); ?' . "'.'>'"; |
|
| 1818 | + . '"); ?'."'.'>'"; |
|
| 1819 | 1819 | |
| 1820 | 1820 | // Remplir le header Cache-Control |
| 1821 | 1821 | // cas #CACHE{0} |
@@ -1836,9 +1836,9 @@ discard block |
||
| 1836 | 1836 | $pa == 'cache-client' |
| 1837 | 1837 | and $duree > 0 |
| 1838 | 1838 | ) { |
| 1839 | - $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1839 | + $code .= ".'<'.'".'?php header("Cache-Control: max-age=' |
|
| 1840 | 1840 | . $duree |
| 1841 | - . '"); ?' . "'.'>'"; |
|
| 1841 | + . '"); ?'."'.'>'"; |
|
| 1842 | 1842 | // il semble logique, si on cache-client, de ne pas invalider |
| 1843 | 1843 | $pa = 'statique'; |
| 1844 | 1844 | } |
@@ -1847,7 +1847,7 @@ discard block |
||
| 1847 | 1847 | $pa == 'statique' |
| 1848 | 1848 | and $duree > 0 |
| 1849 | 1849 | ) { |
| 1850 | - $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1850 | + $code .= ".'<'.'".'?php header("X-Spip-Statique: oui"); ?'."'.'>'"; |
|
| 1851 | 1851 | } |
| 1852 | 1852 | } |
| 1853 | 1853 | } else { |
@@ -2011,9 +2011,9 @@ discard block |
||
| 2011 | 2011 | if ($p->etoile) { |
| 2012 | 2012 | $_options[] = "'etoile'=>true"; |
| 2013 | 2013 | } |
| 2014 | - $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ')'; |
|
| 2014 | + $_options[] = "'compil'=>array(".memoriser_contexte_compil($p).')'; |
|
| 2015 | 2015 | |
| 2016 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2016 | + $_l = 'array('.join(",\n\t", $_contexte).')'; |
|
| 2017 | 2017 | if ($flag_env) { |
| 2018 | 2018 | $_l = "array_merge(\$Pile[0],$_l)"; |
| 2019 | 2019 | } |
@@ -2023,7 +2023,7 @@ discard block |
||
| 2023 | 2023 | $msg = ['zbug_balise_sans_argument', ['balise' => ' INCLURE']]; |
| 2024 | 2024 | erreur_squelette($msg, $p); |
| 2025 | 2025 | } else { |
| 2026 | - $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2026 | + $p->code = 'charge_scripts('.$_contexte[1].',false)'; |
|
| 2027 | 2027 | } |
| 2028 | 2028 | |
| 2029 | 2029 | $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
@@ -2071,7 +2071,7 @@ discard block |
||
| 2071 | 2071 | unset($_contexte[1]); |
| 2072 | 2072 | |
| 2073 | 2073 | if (preg_match("/^\s*'[^']*'/s", $nom)) { |
| 2074 | - $nom = "'modeles/" . substr($nom, 1); |
|
| 2074 | + $nom = "'modeles/".substr($nom, 1); |
|
| 2075 | 2075 | } else { |
| 2076 | 2076 | $nom = "'modeles/' . $nom"; |
| 2077 | 2077 | } |
@@ -2088,8 +2088,8 @@ discard block |
||
| 2088 | 2088 | $primary = $p->boucles[$p->id_boucle]->primary; |
| 2089 | 2089 | if (!strpos($primary, ',')) { |
| 2090 | 2090 | $id = champ_sql($primary, $p); |
| 2091 | - $_contexte[] = "'$primary'=>" . $id; |
|
| 2092 | - $_contexte[] = "'id'=>" . $id; |
|
| 2091 | + $_contexte[] = "'$primary'=>".$id; |
|
| 2092 | + $_contexte[] = "'id'=>".$id; |
|
| 2093 | 2093 | } |
| 2094 | 2094 | } |
| 2095 | 2095 | $_contexte[] = "'recurs'=>(++\$recurs)"; |
@@ -2101,11 +2101,11 @@ discard block |
||
| 2101 | 2101 | $_options = memoriser_contexte_compil($p); |
| 2102 | 2102 | $_options = "'compil'=>array($_options), 'trim'=>true"; |
| 2103 | 2103 | if (isset($_contexte['ajax'])) { |
| 2104 | - $_options .= ', ' . preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2104 | + $_options .= ', '.preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2105 | 2105 | unset($_contexte['ajax']); |
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2108 | + $_l = 'array('.join(",\n\t", $_contexte).')'; |
|
| 2109 | 2109 | if ($flag_env) { |
| 2110 | 2110 | $_l = "array_merge(\$Pile[0],$_l)"; |
| 2111 | 2111 | } |
@@ -2215,12 +2215,12 @@ discard block |
||
| 2215 | 2215 | function balise_DOUBLONS_dist($p) { |
| 2216 | 2216 | if ($type = interprete_argument_balise(1, $p)) { |
| 2217 | 2217 | if ($famille = interprete_argument_balise(2, $p)) { |
| 2218 | - $type .= '.' . $famille; |
|
| 2218 | + $type .= '.'.$famille; |
|
| 2219 | 2219 | } |
| 2220 | - $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2220 | + $p->code = '(isset($doublons['.$type.']) ? $doublons['.$type.'] : "")'; |
|
| 2221 | 2221 | if (!$p->etoile) { |
| 2222 | 2222 | $p->code = 'array_filter(array_map("intval",explode(",",' |
| 2223 | - . $p->code . ')))'; |
|
| 2223 | + . $p->code.')))'; |
|
| 2224 | 2224 | } |
| 2225 | 2225 | } else { |
| 2226 | 2226 | $p->code = '$doublons'; |
@@ -2349,7 +2349,7 @@ discard block |
||
| 2349 | 2349 | $_code[] = "$_key => $_val"; |
| 2350 | 2350 | } |
| 2351 | 2351 | } while ($_key && $_val); |
| 2352 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2352 | + $p->code = 'array('.join(', ', $_code).')'; |
|
| 2353 | 2353 | $p->interdire_scripts = false; |
| 2354 | 2354 | |
| 2355 | 2355 | return $p; |
@@ -2376,7 +2376,7 @@ discard block |
||
| 2376 | 2376 | while ($_val = interprete_argument_balise($n++, $p)) { |
| 2377 | 2377 | $_code[] = $_val; |
| 2378 | 2378 | } |
| 2379 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2379 | + $p->code = 'array('.join(', ', $_code).')'; |
|
| 2380 | 2380 | $p->interdire_scripts = false; |
| 2381 | 2381 | |
| 2382 | 2382 | return $p; |
@@ -2421,10 +2421,10 @@ discard block |
||
| 2421 | 2421 | $_code[] = $_v; |
| 2422 | 2422 | } |
| 2423 | 2423 | |
| 2424 | - $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join( |
|
| 2424 | + $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('.join( |
|
| 2425 | 2425 | ', ', |
| 2426 | 2426 | $_code |
| 2427 | - ) . ')?" ":"")'; |
|
| 2427 | + ).')?" ":"")'; |
|
| 2428 | 2428 | $p->interdire_scripts = false; |
| 2429 | 2429 | |
| 2430 | 2430 | return $p; |
@@ -2457,7 +2457,7 @@ discard block |
||
| 2457 | 2457 | $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
| 2458 | 2458 | |
| 2459 | 2459 | $f = chercher_filtre('info_plugin'); |
| 2460 | - $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2460 | + $p->code = $f.'('.$plugin.', '.$type_info.')'; |
|
| 2461 | 2461 | |
| 2462 | 2462 | return $p; |
| 2463 | 2463 | } |
@@ -2689,7 +2689,7 @@ discard block |
||
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | // Différentes infos relatives au tri présentes dans les modificateurs |
| 2692 | - $_tri_nom = $boucle->modificateur['tri_nom'] ; // nom du paramètre définissant le tri |
|
| 2692 | + $_tri_nom = $boucle->modificateur['tri_nom']; // nom du paramètre définissant le tri |
|
| 2693 | 2693 | $_tri_champ = $boucle->modificateur['tri_champ']; // champ actuel utilisé le tri |
| 2694 | 2694 | $_tri_sens = $boucle->modificateur['tri_sens']; // sens de tri actuel |
| 2695 | 2695 | $_tri_liste_sens_defaut = $boucle->modificateur['tri_liste_sens_defaut']; // sens par défaut pour chaque champ |
@@ -2784,7 +2784,7 @@ discard block |
||
| 2784 | 2784 | $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
| 2785 | 2785 | } |
| 2786 | 2786 | |
| 2787 | - $p->code = '(objet_test_si_publie(' . $_type . ',intval(' . $_id . '),' . _q($connect) . ")?' ':'')"; |
|
| 2787 | + $p->code = '(objet_test_si_publie('.$_type.',intval('.$_id.'),'._q($connect).")?' ':'')"; |
|
| 2788 | 2788 | $p->interdire_scripts = false; |
| 2789 | 2789 | |
| 2790 | 2790 | return $p; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | **/ |
| 29 | 29 | |
| 30 | 30 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 31 | - return; |
|
| 31 | + return; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | * Code PHP si cet argument est présent, sinon null |
| 51 | 51 | **/ |
| 52 | 52 | function interprete_argument_balise(int $n, Champ $p): ?string { |
| 53 | - if (($p->param) && (!$p->param[0][0]) && ((is_countable($p->param[0]) ? count($p->param[0]) : 0) > $n)) { |
|
| 54 | - return calculer_liste( |
|
| 55 | - $p->param[0][$n], |
|
| 56 | - $p->descr, |
|
| 57 | - $p->boucles, |
|
| 58 | - $p->id_boucle |
|
| 59 | - ); |
|
| 60 | - } else { |
|
| 61 | - return null; |
|
| 62 | - } |
|
| 53 | + if (($p->param) && (!$p->param[0][0]) && ((is_countable($p->param[0]) ? count($p->param[0]) : 0) > $n)) { |
|
| 54 | + return calculer_liste( |
|
| 55 | + $p->param[0][$n], |
|
| 56 | + $p->descr, |
|
| 57 | + $p->boucles, |
|
| 58 | + $p->id_boucle |
|
| 59 | + ); |
|
| 60 | + } else { |
|
| 61 | + return null; |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | * Pile complétée par le code à générer |
| 80 | 80 | **/ |
| 81 | 81 | function balise_NOM_SITE_SPIP_dist($p) { |
| 82 | - $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 82 | + $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 83 | 83 | |
| 84 | - #$p->interdire_scripts = true; |
|
| 85 | - return $p; |
|
| 84 | + #$p->interdire_scripts = true; |
|
| 85 | + return $p; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -98,10 +98,10 @@ discard block |
||
| 98 | 98 | * Pile complétée par le code à générer |
| 99 | 99 | **/ |
| 100 | 100 | function balise_EMAIL_WEBMASTER_dist($p) { |
| 101 | - $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 101 | + $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 102 | 102 | |
| 103 | - #$p->interdire_scripts = true; |
|
| 104 | - return $p; |
|
| 103 | + #$p->interdire_scripts = true; |
|
| 104 | + return $p; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | * Pile complétée par le code à générer |
| 118 | 118 | **/ |
| 119 | 119 | function balise_DESCRIPTIF_SITE_SPIP_dist($p) { |
| 120 | - $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 120 | + $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 121 | 121 | |
| 122 | - #$p->interdire_scripts = true; |
|
| 123 | - return $p; |
|
| 122 | + #$p->interdire_scripts = true; |
|
| 123 | + return $p; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | * Pile complétée par le code à générer |
| 142 | 142 | **/ |
| 143 | 143 | function balise_CHARSET_dist($p) { |
| 144 | - $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 144 | + $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 145 | 145 | |
| 146 | - #$p->interdire_scripts = true; |
|
| 147 | - return $p; |
|
| 146 | + #$p->interdire_scripts = true; |
|
| 147 | + return $p; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | * Pile complétée par le code à générer |
| 170 | 170 | **/ |
| 171 | 171 | function balise_LANG_LEFT_dist($p) { |
| 172 | - $_lang = champ_sql('lang', $p); |
|
| 173 | - $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 174 | - $p->interdire_scripts = false; |
|
| 172 | + $_lang = champ_sql('lang', $p); |
|
| 173 | + $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 174 | + $p->interdire_scripts = false; |
|
| 175 | 175 | |
| 176 | - return $p; |
|
| 176 | + return $p; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | * Pile complétée par le code à générer |
| 194 | 194 | **/ |
| 195 | 195 | function balise_LANG_RIGHT_dist($p) { |
| 196 | - $_lang = champ_sql('lang', $p); |
|
| 197 | - $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 198 | - $p->interdire_scripts = false; |
|
| 196 | + $_lang = champ_sql('lang', $p); |
|
| 197 | + $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 198 | + $p->interdire_scripts = false; |
|
| 199 | 199 | |
| 200 | - return $p; |
|
| 200 | + return $p; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | * Pile complétée par le code à générer |
| 223 | 223 | **/ |
| 224 | 224 | function balise_LANG_DIR_dist($p) { |
| 225 | - $_lang = champ_sql('lang', $p); |
|
| 226 | - $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 227 | - $p->interdire_scripts = false; |
|
| 225 | + $_lang = champ_sql('lang', $p); |
|
| 226 | + $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 227 | + $p->interdire_scripts = false; |
|
| 228 | 228 | |
| 229 | - return $p; |
|
| 229 | + return $p; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | * Pile complétée par le code à générer |
| 244 | 244 | **/ |
| 245 | 245 | function balise_PUCE_dist($p) { |
| 246 | - $p->code = 'definir_puce()'; |
|
| 247 | - $p->interdire_scripts = false; |
|
| 246 | + $p->code = 'definir_puce()'; |
|
| 247 | + $p->interdire_scripts = false; |
|
| 248 | 248 | |
| 249 | - return $p; |
|
| 249 | + return $p; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | * Pile completée du code PHP d'exécution de la balise |
| 271 | 271 | */ |
| 272 | 272 | function balise_DATE_dist($p) { |
| 273 | - $p->code = champ_sql('date', $p); |
|
| 273 | + $p->code = champ_sql('date', $p); |
|
| 274 | 274 | |
| 275 | - return $p; |
|
| 275 | + return $p; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
@@ -292,10 +292,10 @@ discard block |
||
| 292 | 292 | * Pile completée du code PHP d'exécution de la balise |
| 293 | 293 | */ |
| 294 | 294 | function balise_DATE_REDAC_dist($p) { |
| 295 | - $p->code = champ_sql('date_redac', $p); |
|
| 296 | - $p->interdire_scripts = false; |
|
| 295 | + $p->code = champ_sql('date_redac', $p); |
|
| 296 | + $p->interdire_scripts = false; |
|
| 297 | 297 | |
| 298 | - return $p; |
|
| 298 | + return $p; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -314,10 +314,10 @@ discard block |
||
| 314 | 314 | * Pile completée du code PHP d'exécution de la balise |
| 315 | 315 | */ |
| 316 | 316 | function balise_DATE_MODIF_dist($p) { |
| 317 | - $p->code = champ_sql('date_modif', $p); |
|
| 318 | - $p->interdire_scripts = false; |
|
| 317 | + $p->code = champ_sql('date_modif', $p); |
|
| 318 | + $p->interdire_scripts = false; |
|
| 319 | 319 | |
| 320 | - return $p; |
|
| 320 | + return $p; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -335,13 +335,13 @@ discard block |
||
| 335 | 335 | * Pile completée du code PHP d'exécution de la balise |
| 336 | 336 | */ |
| 337 | 337 | function balise_DATE_NOUVEAUTES_dist($p) { |
| 338 | - $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 338 | + $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 339 | 339 | AND isset(\$GLOBALS['meta']['dernier_envoi_neuf'])) ? |
| 340 | 340 | \$GLOBALS['meta']['dernier_envoi_neuf'] : |
| 341 | 341 | \"'0000-00-00'\")"; |
| 342 | - $p->interdire_scripts = false; |
|
| 342 | + $p->interdire_scripts = false; |
|
| 343 | 343 | |
| 344 | - return $p; |
|
| 344 | + return $p; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | * Pile completée du code PHP d'exécution de la balise |
| 360 | 360 | */ |
| 361 | 361 | function balise_DOSSIER_SQUELETTE_dist($p) { |
| 362 | - $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 363 | - $p->code = "_DIR_RACINE . '$code'" . |
|
| 364 | - $p->interdire_scripts = false; |
|
| 362 | + $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 363 | + $p->code = "_DIR_RACINE . '$code'" . |
|
| 364 | + $p->interdire_scripts = false; |
|
| 365 | 365 | |
| 366 | - return $p; |
|
| 366 | + return $p; |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -378,11 +378,11 @@ discard block |
||
| 378 | 378 | * Pile completée du code PHP d'exécution de la balise |
| 379 | 379 | */ |
| 380 | 380 | function balise_SQUELETTE_dist($p) { |
| 381 | - $code = addslashes($p->descr['sourcefile']); |
|
| 382 | - $p->code = "'$code'" . |
|
| 383 | - $p->interdire_scripts = false; |
|
| 381 | + $code = addslashes($p->descr['sourcefile']); |
|
| 382 | + $p->code = "'$code'" . |
|
| 383 | + $p->interdire_scripts = false; |
|
| 384 | 384 | |
| 385 | - return $p; |
|
| 385 | + return $p; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -401,10 +401,10 @@ discard block |
||
| 401 | 401 | * Pile completée du code PHP d'exécution de la balise |
| 402 | 402 | */ |
| 403 | 403 | function balise_SPIP_VERSION_dist($p) { |
| 404 | - $p->code = 'spip_version()'; |
|
| 405 | - $p->interdire_scripts = false; |
|
| 404 | + $p->code = 'spip_version()'; |
|
| 405 | + $p->interdire_scripts = false; |
|
| 406 | 406 | |
| 407 | - return $p; |
|
| 407 | + return $p; |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | |
@@ -430,18 +430,18 @@ discard block |
||
| 430 | 430 | * Pile complétée par le code à générer |
| 431 | 431 | **/ |
| 432 | 432 | function balise_NOM_SITE_dist($p) { |
| 433 | - if (!$p->etoile) { |
|
| 434 | - $p->code = 'supprimer_numero(calculer_url(' . |
|
| 435 | - champ_sql('url_site', $p) . ',' . |
|
| 436 | - champ_sql('nom_site', $p) . |
|
| 437 | - ", 'titre', \$connect, false))"; |
|
| 438 | - } else { |
|
| 439 | - $p->code = champ_sql('nom_site', $p); |
|
| 440 | - } |
|
| 433 | + if (!$p->etoile) { |
|
| 434 | + $p->code = 'supprimer_numero(calculer_url(' . |
|
| 435 | + champ_sql('url_site', $p) . ',' . |
|
| 436 | + champ_sql('nom_site', $p) . |
|
| 437 | + ", 'titre', \$connect, false))"; |
|
| 438 | + } else { |
|
| 439 | + $p->code = champ_sql('nom_site', $p); |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - $p->interdire_scripts = true; |
|
| 442 | + $p->interdire_scripts = true; |
|
| 443 | 443 | |
| 444 | - return $p; |
|
| 444 | + return $p; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | |
@@ -458,11 +458,11 @@ discard block |
||
| 458 | 458 | * Pile complétée par le code à générer |
| 459 | 459 | **/ |
| 460 | 460 | function balise_NOTES_dist($p) { |
| 461 | - // Recuperer les notes |
|
| 462 | - $p->code = 'calculer_notes()'; |
|
| 461 | + // Recuperer les notes |
|
| 462 | + $p->code = 'calculer_notes()'; |
|
| 463 | 463 | |
| 464 | - #$p->interdire_scripts = true; |
|
| 465 | - return $p; |
|
| 464 | + #$p->interdire_scripts = true; |
|
| 465 | + return $p; |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | |
@@ -484,10 +484,10 @@ discard block |
||
| 484 | 484 | * Pile complétée par le code à générer |
| 485 | 485 | **/ |
| 486 | 486 | function balise_RECHERCHE_dist($p) { |
| 487 | - $p->code = 'entites_html(_request("recherche"))'; |
|
| 488 | - $p->interdire_scripts = false; |
|
| 487 | + $p->code = 'entites_html(_request("recherche"))'; |
|
| 488 | + $p->interdire_scripts = false; |
|
| 489 | 489 | |
| 490 | - return $p; |
|
| 490 | + return $p; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | |
@@ -505,18 +505,18 @@ discard block |
||
| 505 | 505 | * Pile complétée par le code à générer |
| 506 | 506 | **/ |
| 507 | 507 | function balise_COMPTEUR_BOUCLE_dist($p) { |
| 508 | - $b = index_boucle_mere($p); |
|
| 509 | - if ($b === '') { |
|
| 510 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 511 | - erreur_squelette($msg, $p); |
|
| 512 | - return null; |
|
| 513 | - } else { |
|
| 514 | - $p->code = "(\$Numrows['$b']['compteur_boucle'] ?? 0)"; |
|
| 515 | - $p->boucles[$b]->cptrows = true; |
|
| 516 | - $p->interdire_scripts = false; |
|
| 508 | + $b = index_boucle_mere($p); |
|
| 509 | + if ($b === '') { |
|
| 510 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 511 | + erreur_squelette($msg, $p); |
|
| 512 | + return null; |
|
| 513 | + } else { |
|
| 514 | + $p->code = "(\$Numrows['$b']['compteur_boucle'] ?? 0)"; |
|
| 515 | + $p->boucles[$b]->cptrows = true; |
|
| 516 | + $p->interdire_scripts = false; |
|
| 517 | 517 | |
| 518 | - return $p; |
|
| 519 | - } |
|
| 518 | + return $p; |
|
| 519 | + } |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -534,17 +534,17 @@ discard block |
||
| 534 | 534 | * Pile complétée par le code à générer |
| 535 | 535 | **/ |
| 536 | 536 | function balise_TOTAL_BOUCLE_dist($p) { |
| 537 | - $b = index_boucle_mere($p); |
|
| 538 | - if ($b === '') { |
|
| 539 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 540 | - erreur_squelette($msg, $p); |
|
| 541 | - } else { |
|
| 542 | - $p->code = "(\$Numrows['$b']['total'] ?? 0)"; |
|
| 543 | - $p->boucles[$b]->numrows = true; |
|
| 544 | - $p->interdire_scripts = false; |
|
| 545 | - } |
|
| 537 | + $b = index_boucle_mere($p); |
|
| 538 | + if ($b === '') { |
|
| 539 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 540 | + erreur_squelette($msg, $p); |
|
| 541 | + } else { |
|
| 542 | + $p->code = "(\$Numrows['$b']['total'] ?? 0)"; |
|
| 543 | + $p->boucles[$b]->numrows = true; |
|
| 544 | + $p->interdire_scripts = false; |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - return $p; |
|
| 547 | + return $p; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * Pile complétée par le code à générer |
| 565 | 565 | **/ |
| 566 | 566 | function balise_POINTS_dist($p) { |
| 567 | - return rindex_pile($p, 'points', 'recherche'); |
|
| 567 | + return rindex_pile($p, 'points', 'recherche'); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | |
@@ -585,12 +585,12 @@ discard block |
||
| 585 | 585 | * Pile complétée par le code à générer |
| 586 | 586 | **/ |
| 587 | 587 | function balise_POPULARITE_ABSOLUE_dist($p) { |
| 588 | - $p->code = 'ceil(' . |
|
| 589 | - champ_sql('popularite', $p) . |
|
| 590 | - ')'; |
|
| 591 | - $p->interdire_scripts = false; |
|
| 588 | + $p->code = 'ceil(' . |
|
| 589 | + champ_sql('popularite', $p) . |
|
| 590 | + ')'; |
|
| 591 | + $p->interdire_scripts = false; |
|
| 592 | 592 | |
| 593 | - return $p; |
|
| 593 | + return $p; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -610,10 +610,10 @@ discard block |
||
| 610 | 610 | * Pile complétée par le code à générer |
| 611 | 611 | **/ |
| 612 | 612 | function balise_POPULARITE_SITE_dist($p) { |
| 613 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 614 | - $p->interdire_scripts = false; |
|
| 613 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 614 | + $p->interdire_scripts = false; |
|
| 615 | 615 | |
| 616 | - return $p; |
|
| 616 | + return $p; |
|
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | /** |
@@ -634,10 +634,10 @@ discard block |
||
| 634 | 634 | * Pile complétée par le code à générer |
| 635 | 635 | **/ |
| 636 | 636 | function balise_POPULARITE_MAX_dist($p) { |
| 637 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 638 | - $p->interdire_scripts = false; |
|
| 637 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 638 | + $p->interdire_scripts = false; |
|
| 639 | 639 | |
| 640 | - return $p; |
|
| 640 | + return $p; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | |
@@ -663,15 +663,15 @@ discard block |
||
| 663 | 663 | * Pile complétée par le code à générer |
| 664 | 664 | **/ |
| 665 | 665 | function balise_VALEUR_dist($p) { |
| 666 | - $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 667 | - $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); |
|
| 666 | + $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 667 | + $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); |
|
| 668 | 668 | ; |
| 669 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 670 | - $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 671 | - } |
|
| 672 | - $p->interdire_scripts = true; |
|
| 669 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 670 | + $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 671 | + } |
|
| 672 | + $p->interdire_scripts = true; |
|
| 673 | 673 | |
| 674 | - return $p; |
|
| 674 | + return $p; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
@@ -700,16 +700,16 @@ discard block |
||
| 700 | 700 | * Pile complétée par le code à générer |
| 701 | 701 | **/ |
| 702 | 702 | function balise_EXPOSE_dist($p) { |
| 703 | - $on = "'on'"; |
|
| 704 | - $off = "''"; |
|
| 705 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 706 | - $on = $v; |
|
| 707 | - if (($v = interprete_argument_balise(2, $p)) !== null) { |
|
| 708 | - $off = $v; |
|
| 709 | - } |
|
| 710 | - } |
|
| 703 | + $on = "'on'"; |
|
| 704 | + $off = "''"; |
|
| 705 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 706 | + $on = $v; |
|
| 707 | + if (($v = interprete_argument_balise(2, $p)) !== null) { |
|
| 708 | + $off = $v; |
|
| 709 | + } |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | - return calculer_balise_expose($p, $on, $off); |
|
| 712 | + return calculer_balise_expose($p, $on, $off); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | /** |
@@ -727,35 +727,35 @@ discard block |
||
| 727 | 727 | * Pile complétée par le code à générer |
| 728 | 728 | **/ |
| 729 | 729 | function calculer_balise_expose($p, $on, $off) { |
| 730 | - $b = index_boucle($p); |
|
| 731 | - if (empty($p->boucles[$b]->primary)) { |
|
| 732 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 733 | - erreur_squelette($msg, $p); |
|
| 734 | - } else { |
|
| 735 | - $key = $p->boucles[$b]->primary; |
|
| 736 | - $type = $p->boucles[$p->id_boucle]->primary; |
|
| 737 | - $desc = $p->boucles[$b]->show; |
|
| 738 | - $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 730 | + $b = index_boucle($p); |
|
| 731 | + if (empty($p->boucles[$b]->primary)) { |
|
| 732 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 733 | + erreur_squelette($msg, $p); |
|
| 734 | + } else { |
|
| 735 | + $key = $p->boucles[$b]->primary; |
|
| 736 | + $type = $p->boucles[$p->id_boucle]->primary; |
|
| 737 | + $desc = $p->boucles[$b]->show; |
|
| 738 | + $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 739 | 739 | |
| 740 | - // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 741 | - $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 740 | + // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 741 | + $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 742 | 742 | |
| 743 | - if (isset($desc['field']['id_parent'])) { |
|
| 744 | - $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 745 | - } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 746 | - $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 747 | - } elseif (isset($desc['field']['id_groupe'])) { |
|
| 748 | - $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 749 | - } else { |
|
| 750 | - $parent = "''"; |
|
| 751 | - } |
|
| 743 | + if (isset($desc['field']['id_parent'])) { |
|
| 744 | + $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 745 | + } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 746 | + $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 747 | + } elseif (isset($desc['field']['id_groupe'])) { |
|
| 748 | + $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 749 | + } else { |
|
| 750 | + $parent = "''"; |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | - $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 754 | - } |
|
| 753 | + $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 754 | + } |
|
| 755 | 755 | |
| 756 | - $p->interdire_scripts = false; |
|
| 756 | + $p->interdire_scripts = false; |
|
| 757 | 757 | |
| 758 | - return $p; |
|
| 758 | + return $p; |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | |
@@ -796,46 +796,46 @@ discard block |
||
| 796 | 796 | **/ |
| 797 | 797 | function balise_INTRODUCTION_dist($p) { |
| 798 | 798 | |
| 799 | - $type_objet = $p->type_requete; |
|
| 800 | - $cle_objet = id_table_objet($type_objet); |
|
| 801 | - $_id_objet = champ_sql($cle_objet, $p); |
|
| 802 | - |
|
| 803 | - // Récupérer les valeurs sql nécessaires : descriptif, texte et chapo |
|
| 804 | - // ainsi que le longueur d'introduction donnée dans la description de l'objet. |
|
| 805 | - $_introduction_longueur = 'null'; |
|
| 806 | - $_ligne = 'array('; |
|
| 807 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 808 | - if ($desc = $trouver_table(table_objet_sql($type_objet))) { |
|
| 809 | - if (isset($desc['field']['descriptif'])) { |
|
| 810 | - $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ','; |
|
| 811 | - } |
|
| 812 | - if (isset($desc['field']['texte'])) { |
|
| 813 | - $_ligne .= "'texte' => " . champ_sql('texte', $p) . ','; |
|
| 814 | - } |
|
| 815 | - if (isset($desc['field']['chapo'])) { |
|
| 816 | - $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ','; |
|
| 817 | - } |
|
| 818 | - if (isset($desc['introduction_longueur'])) { |
|
| 819 | - $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'"; |
|
| 820 | - } |
|
| 821 | - } |
|
| 822 | - $_ligne .= ')'; |
|
| 823 | - |
|
| 824 | - // Récupérer la longueur et la suite passés en paramètres |
|
| 825 | - $_longueur_ou_suite = 'null'; |
|
| 826 | - if (($v1 = interprete_argument_balise(1, $p)) !== null) { |
|
| 827 | - $_longueur_ou_suite = $v1; |
|
| 828 | - } |
|
| 829 | - $_suite = 'null'; |
|
| 830 | - if (($v2 = interprete_argument_balise(2, $p)) !== null) { |
|
| 831 | - $_suite = $v2; |
|
| 832 | - } |
|
| 833 | - |
|
| 834 | - $p->code = "generer_objet_introduction($_id_objet, '$type_objet', $_ligne, $_introduction_longueur, $_longueur_ou_suite, $_suite, \$connect)"; |
|
| 835 | - |
|
| 836 | - #$p->interdire_scripts = true; |
|
| 837 | - $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 838 | - return $p; |
|
| 799 | + $type_objet = $p->type_requete; |
|
| 800 | + $cle_objet = id_table_objet($type_objet); |
|
| 801 | + $_id_objet = champ_sql($cle_objet, $p); |
|
| 802 | + |
|
| 803 | + // Récupérer les valeurs sql nécessaires : descriptif, texte et chapo |
|
| 804 | + // ainsi que le longueur d'introduction donnée dans la description de l'objet. |
|
| 805 | + $_introduction_longueur = 'null'; |
|
| 806 | + $_ligne = 'array('; |
|
| 807 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 808 | + if ($desc = $trouver_table(table_objet_sql($type_objet))) { |
|
| 809 | + if (isset($desc['field']['descriptif'])) { |
|
| 810 | + $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ','; |
|
| 811 | + } |
|
| 812 | + if (isset($desc['field']['texte'])) { |
|
| 813 | + $_ligne .= "'texte' => " . champ_sql('texte', $p) . ','; |
|
| 814 | + } |
|
| 815 | + if (isset($desc['field']['chapo'])) { |
|
| 816 | + $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ','; |
|
| 817 | + } |
|
| 818 | + if (isset($desc['introduction_longueur'])) { |
|
| 819 | + $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'"; |
|
| 820 | + } |
|
| 821 | + } |
|
| 822 | + $_ligne .= ')'; |
|
| 823 | + |
|
| 824 | + // Récupérer la longueur et la suite passés en paramètres |
|
| 825 | + $_longueur_ou_suite = 'null'; |
|
| 826 | + if (($v1 = interprete_argument_balise(1, $p)) !== null) { |
|
| 827 | + $_longueur_ou_suite = $v1; |
|
| 828 | + } |
|
| 829 | + $_suite = 'null'; |
|
| 830 | + if (($v2 = interprete_argument_balise(2, $p)) !== null) { |
|
| 831 | + $_suite = $v2; |
|
| 832 | + } |
|
| 833 | + |
|
| 834 | + $p->code = "generer_objet_introduction($_id_objet, '$type_objet', $_ligne, $_introduction_longueur, $_longueur_ou_suite, $_suite, \$connect)"; |
|
| 835 | + |
|
| 836 | + #$p->interdire_scripts = true; |
|
| 837 | + $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 838 | + return $p; |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | |
@@ -855,15 +855,15 @@ discard block |
||
| 855 | 855 | * Pile complétée par le code à générer |
| 856 | 856 | **/ |
| 857 | 857 | function balise_LANG_dist($p) { |
| 858 | - $_lang = champ_sql('lang', $p); |
|
| 859 | - if (!$p->etoile) { |
|
| 860 | - $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 861 | - } else { |
|
| 862 | - $p->code = "spip_htmlentities($_lang)"; |
|
| 863 | - } |
|
| 864 | - $p->interdire_scripts = false; |
|
| 858 | + $_lang = champ_sql('lang', $p); |
|
| 859 | + if (!$p->etoile) { |
|
| 860 | + $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 861 | + } else { |
|
| 862 | + $p->code = "spip_htmlentities($_lang)"; |
|
| 863 | + } |
|
| 864 | + $p->interdire_scripts = false; |
|
| 865 | 865 | |
| 866 | - return $p; |
|
| 866 | + return $p; |
|
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | /** |
@@ -885,45 +885,45 @@ discard block |
||
| 885 | 885 | * Pile complétée par le code à générer |
| 886 | 886 | */ |
| 887 | 887 | function balise_LESAUTEURS_dist($p) { |
| 888 | - // Cherche le champ 'lesauteurs' dans la pile |
|
| 889 | - $_lesauteurs = champ_sql('lesauteurs', $p, ''); |
|
| 890 | - |
|
| 891 | - // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 892 | - // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 893 | - // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 894 | - // (cf extension sites/) |
|
| 895 | - if ($_lesauteurs) { |
|
| 896 | - $p->code = "safehtml($_lesauteurs)"; |
|
| 897 | - // $p->interdire_scripts = true; |
|
| 898 | - } else { |
|
| 899 | - if (!$p->id_boucle) { |
|
| 900 | - $connect = ''; |
|
| 901 | - $objet = 'article'; |
|
| 902 | - $id_table_objet = 'id_article'; |
|
| 903 | - } else { |
|
| 904 | - $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 905 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 906 | - $type_boucle = $p->boucles[$b]->type_requete; |
|
| 907 | - $objet = objet_type($type_boucle); |
|
| 908 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 909 | - } |
|
| 910 | - $c = memoriser_contexte_compil($p); |
|
| 911 | - |
|
| 912 | - $p->code = sprintf( |
|
| 913 | - CODE_RECUPERER_FOND, |
|
| 914 | - "'modeles/lesauteurs'", |
|
| 915 | - "array('objet'=>'" . $objet . |
|
| 916 | - "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 917 | - ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 918 | - ($objet == 'article' ? '' : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 919 | - ')', |
|
| 920 | - "'trim'=>true, 'compil'=>array($c)", |
|
| 921 | - _q($connect) |
|
| 922 | - ); |
|
| 923 | - $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - return $p; |
|
| 888 | + // Cherche le champ 'lesauteurs' dans la pile |
|
| 889 | + $_lesauteurs = champ_sql('lesauteurs', $p, ''); |
|
| 890 | + |
|
| 891 | + // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 892 | + // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 893 | + // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 894 | + // (cf extension sites/) |
|
| 895 | + if ($_lesauteurs) { |
|
| 896 | + $p->code = "safehtml($_lesauteurs)"; |
|
| 897 | + // $p->interdire_scripts = true; |
|
| 898 | + } else { |
|
| 899 | + if (!$p->id_boucle) { |
|
| 900 | + $connect = ''; |
|
| 901 | + $objet = 'article'; |
|
| 902 | + $id_table_objet = 'id_article'; |
|
| 903 | + } else { |
|
| 904 | + $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 905 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 906 | + $type_boucle = $p->boucles[$b]->type_requete; |
|
| 907 | + $objet = objet_type($type_boucle); |
|
| 908 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 909 | + } |
|
| 910 | + $c = memoriser_contexte_compil($p); |
|
| 911 | + |
|
| 912 | + $p->code = sprintf( |
|
| 913 | + CODE_RECUPERER_FOND, |
|
| 914 | + "'modeles/lesauteurs'", |
|
| 915 | + "array('objet'=>'" . $objet . |
|
| 916 | + "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 917 | + ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 918 | + ($objet == 'article' ? '' : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 919 | + ')', |
|
| 920 | + "'trim'=>true, 'compil'=>array($c)", |
|
| 921 | + _q($connect) |
|
| 922 | + ); |
|
| 923 | + $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + return $p; |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | |
@@ -950,76 +950,76 @@ discard block |
||
| 950 | 950 | * Pile complétée par le code à générer |
| 951 | 951 | */ |
| 952 | 952 | function balise_RANG_dist($p) { |
| 953 | - $b = index_boucle($p); |
|
| 954 | - if ($b === '') { |
|
| 955 | - $msg = [ |
|
| 956 | - 'zbug_champ_hors_boucle', |
|
| 957 | - ['champ' => '#RANG'] |
|
| 958 | - ]; |
|
| 959 | - erreur_squelette($msg, $p); |
|
| 960 | - } else { |
|
| 961 | - // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 962 | - // dans la boucle immediatement englobante uniquement |
|
| 963 | - // sinon on compose le champ calcule |
|
| 964 | - $_rang = champ_sql('rang', $p, '', false); |
|
| 965 | - |
|
| 966 | - // si pas trouve de champ sql rang : |
|
| 967 | - if (!$_rang or $_rang == "''") { |
|
| 968 | - $boucle = &$p->boucles[$b]; |
|
| 969 | - |
|
| 970 | - // on gere le cas ou #RANG est une extraction du numero dans le titre |
|
| 971 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 972 | - $desc = $trouver_table($boucle->id_table); |
|
| 973 | - $_titre = ''; # où extraire le numero ? |
|
| 974 | - |
|
| 975 | - if (isset($desc['titre'])) { |
|
| 976 | - $t = $desc['titre']; |
|
| 977 | - if ( |
|
| 978 | - // Soit on trouve avec la déclaration de la lang AVANT |
|
| 979 | - preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 980 | - // Soit on prend depuis le début |
|
| 981 | - or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 982 | - ) { |
|
| 983 | - $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 984 | - $m = trim($m); |
|
| 985 | - if ($m != "''") { |
|
| 986 | - if (!preg_match(',\W,', $m)) { |
|
| 987 | - $m = $boucle->id_table . ".$m"; |
|
| 988 | - } |
|
| 989 | - |
|
| 990 | - $m .= ' AS titre_rang'; |
|
| 991 | - |
|
| 992 | - $boucle->select[] = $m; |
|
| 993 | - $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 994 | - } |
|
| 995 | - } |
|
| 996 | - } |
|
| 997 | - |
|
| 998 | - // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 999 | - if (!$_titre) { |
|
| 1000 | - $_titre = champ_sql('titre', $p); |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement |
|
| 1004 | - // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS |
|
| 1005 | - $type_boucle = $boucle->type_requete; |
|
| 1006 | - $objet = objet_type($type_boucle); |
|
| 1007 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 1008 | - $_primary = champ_sql($id_table_objet, $p, '', false); |
|
| 1009 | - $_env = '$Pile[0]'; |
|
| 1010 | - |
|
| 1011 | - if (!$_titre) {$_titre = "''"; |
|
| 1012 | - } |
|
| 1013 | - if (!$_primary) {$_primary = "''"; |
|
| 1014 | - } |
|
| 1015 | - $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)"; |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - $p->code = $_rang; |
|
| 1019 | - $p->interdire_scripts = false; |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - return $p; |
|
| 953 | + $b = index_boucle($p); |
|
| 954 | + if ($b === '') { |
|
| 955 | + $msg = [ |
|
| 956 | + 'zbug_champ_hors_boucle', |
|
| 957 | + ['champ' => '#RANG'] |
|
| 958 | + ]; |
|
| 959 | + erreur_squelette($msg, $p); |
|
| 960 | + } else { |
|
| 961 | + // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 962 | + // dans la boucle immediatement englobante uniquement |
|
| 963 | + // sinon on compose le champ calcule |
|
| 964 | + $_rang = champ_sql('rang', $p, '', false); |
|
| 965 | + |
|
| 966 | + // si pas trouve de champ sql rang : |
|
| 967 | + if (!$_rang or $_rang == "''") { |
|
| 968 | + $boucle = &$p->boucles[$b]; |
|
| 969 | + |
|
| 970 | + // on gere le cas ou #RANG est une extraction du numero dans le titre |
|
| 971 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 972 | + $desc = $trouver_table($boucle->id_table); |
|
| 973 | + $_titre = ''; # où extraire le numero ? |
|
| 974 | + |
|
| 975 | + if (isset($desc['titre'])) { |
|
| 976 | + $t = $desc['titre']; |
|
| 977 | + if ( |
|
| 978 | + // Soit on trouve avec la déclaration de la lang AVANT |
|
| 979 | + preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 980 | + // Soit on prend depuis le début |
|
| 981 | + or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 982 | + ) { |
|
| 983 | + $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 984 | + $m = trim($m); |
|
| 985 | + if ($m != "''") { |
|
| 986 | + if (!preg_match(',\W,', $m)) { |
|
| 987 | + $m = $boucle->id_table . ".$m"; |
|
| 988 | + } |
|
| 989 | + |
|
| 990 | + $m .= ' AS titre_rang'; |
|
| 991 | + |
|
| 992 | + $boucle->select[] = $m; |
|
| 993 | + $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 994 | + } |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | + |
|
| 998 | + // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 999 | + if (!$_titre) { |
|
| 1000 | + $_titre = champ_sql('titre', $p); |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement |
|
| 1004 | + // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS |
|
| 1005 | + $type_boucle = $boucle->type_requete; |
|
| 1006 | + $objet = objet_type($type_boucle); |
|
| 1007 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 1008 | + $_primary = champ_sql($id_table_objet, $p, '', false); |
|
| 1009 | + $_env = '$Pile[0]'; |
|
| 1010 | + |
|
| 1011 | + if (!$_titre) {$_titre = "''"; |
|
| 1012 | + } |
|
| 1013 | + if (!$_primary) {$_primary = "''"; |
|
| 1014 | + } |
|
| 1015 | + $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)"; |
|
| 1016 | + } |
|
| 1017 | + |
|
| 1018 | + $p->code = $_rang; |
|
| 1019 | + $p->interdire_scripts = false; |
|
| 1020 | + } |
|
| 1021 | + |
|
| 1022 | + return $p; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | |
@@ -1041,12 +1041,12 @@ discard block |
||
| 1041 | 1041 | * Pile complétée par le code à générer |
| 1042 | 1042 | **/ |
| 1043 | 1043 | function balise_POPULARITE_dist($p) { |
| 1044 | - $_popularite = champ_sql('popularite', $p); |
|
| 1045 | - $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 1044 | + $_popularite = champ_sql('popularite', $p); |
|
| 1045 | + $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 1046 | 1046 | / max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))"; |
| 1047 | - $p->interdire_scripts = false; |
|
| 1047 | + $p->interdire_scripts = false; |
|
| 1048 | 1048 | |
| 1049 | - return $p; |
|
| 1049 | + return $p; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | /** |
@@ -1057,8 +1057,8 @@ discard block |
||
| 1057 | 1057 | * l'absence peut-être due à une faute de frappe dans le contexte inclus. |
| 1058 | 1058 | */ |
| 1059 | 1059 | define( |
| 1060 | - 'CODE_PAGINATION', |
|
| 1061 | - '%s($Numrows["%s"]["grand_total"], |
|
| 1060 | + 'CODE_PAGINATION', |
|
| 1061 | + '%s($Numrows["%s"]["grand_total"], |
|
| 1062 | 1062 | %s, |
| 1063 | 1063 | isset($Pile[0][%4$s])?$Pile[0][%4$s]:intval(_request(%4$s)), |
| 1064 | 1064 | %5$s, %6$s, %7$s, %8$s, array(%9$s))' |
@@ -1095,75 +1095,75 @@ discard block |
||
| 1095 | 1095 | * Pile complétée par le code à générer |
| 1096 | 1096 | */ |
| 1097 | 1097 | function balise_PAGINATION_dist($p, $liste = 'true') { |
| 1098 | - $b = index_boucle_mere($p); |
|
| 1099 | - |
|
| 1100 | - // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 1101 | - if ($b === '') { |
|
| 1102 | - $msg = [ |
|
| 1103 | - 'zbug_champ_hors_boucle', |
|
| 1104 | - ['champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION'] |
|
| 1105 | - ]; |
|
| 1106 | - erreur_squelette($msg, $p); |
|
| 1107 | - |
|
| 1108 | - return $p; |
|
| 1109 | - } |
|
| 1110 | - |
|
| 1111 | - // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 1112 | - // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 1113 | - if (!$p->boucles[$b]->mode_partie) { |
|
| 1114 | - if (!$p->boucles[$b]->table_optionnelle) { |
|
| 1115 | - $msg = [ |
|
| 1116 | - 'zbug_pagination_sans_critere', |
|
| 1117 | - ['champ' => '#PAGINATION'] |
|
| 1118 | - ]; |
|
| 1119 | - erreur_squelette($msg, $p); |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - return $p; |
|
| 1123 | - } |
|
| 1124 | - |
|
| 1125 | - // a priori true |
|
| 1126 | - // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 1127 | - // si true, les arguments simples (sans truc=chose) vont degager |
|
| 1128 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 1129 | - if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1130 | - $key = key($_contexte); |
|
| 1131 | - if (is_numeric($key)) { |
|
| 1132 | - array_shift($_contexte); |
|
| 1133 | - $__modele = interprete_argument_balise(1, $p); |
|
| 1134 | - } |
|
| 1135 | - } |
|
| 1136 | - |
|
| 1137 | - if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1138 | - $code_contexte = implode(',', $_contexte); |
|
| 1139 | - } else { |
|
| 1140 | - $code_contexte = ''; |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 1144 | - $pas = $p->boucles[$b]->total_parties; |
|
| 1145 | - $f_pagination = chercher_filtre('pagination'); |
|
| 1146 | - $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 1147 | - $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 1148 | - : ("'debut" . substr($type, 1)); |
|
| 1149 | - |
|
| 1150 | - $p->code = sprintf( |
|
| 1151 | - CODE_PAGINATION, |
|
| 1152 | - $f_pagination, |
|
| 1153 | - $b, |
|
| 1154 | - $type, |
|
| 1155 | - $modif, |
|
| 1156 | - $pas, |
|
| 1157 | - $liste, |
|
| 1158 | - ((isset($__modele) and $__modele) ? $__modele : "''"), |
|
| 1159 | - _q($connect), |
|
| 1160 | - $code_contexte |
|
| 1161 | - ); |
|
| 1162 | - |
|
| 1163 | - $p->boucles[$b]->numrows = true; |
|
| 1164 | - $p->interdire_scripts = false; |
|
| 1165 | - |
|
| 1166 | - return $p; |
|
| 1098 | + $b = index_boucle_mere($p); |
|
| 1099 | + |
|
| 1100 | + // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 1101 | + if ($b === '') { |
|
| 1102 | + $msg = [ |
|
| 1103 | + 'zbug_champ_hors_boucle', |
|
| 1104 | + ['champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION'] |
|
| 1105 | + ]; |
|
| 1106 | + erreur_squelette($msg, $p); |
|
| 1107 | + |
|
| 1108 | + return $p; |
|
| 1109 | + } |
|
| 1110 | + |
|
| 1111 | + // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 1112 | + // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 1113 | + if (!$p->boucles[$b]->mode_partie) { |
|
| 1114 | + if (!$p->boucles[$b]->table_optionnelle) { |
|
| 1115 | + $msg = [ |
|
| 1116 | + 'zbug_pagination_sans_critere', |
|
| 1117 | + ['champ' => '#PAGINATION'] |
|
| 1118 | + ]; |
|
| 1119 | + erreur_squelette($msg, $p); |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + return $p; |
|
| 1123 | + } |
|
| 1124 | + |
|
| 1125 | + // a priori true |
|
| 1126 | + // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 1127 | + // si true, les arguments simples (sans truc=chose) vont degager |
|
| 1128 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 1129 | + if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1130 | + $key = key($_contexte); |
|
| 1131 | + if (is_numeric($key)) { |
|
| 1132 | + array_shift($_contexte); |
|
| 1133 | + $__modele = interprete_argument_balise(1, $p); |
|
| 1134 | + } |
|
| 1135 | + } |
|
| 1136 | + |
|
| 1137 | + if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1138 | + $code_contexte = implode(',', $_contexte); |
|
| 1139 | + } else { |
|
| 1140 | + $code_contexte = ''; |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 1144 | + $pas = $p->boucles[$b]->total_parties; |
|
| 1145 | + $f_pagination = chercher_filtre('pagination'); |
|
| 1146 | + $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 1147 | + $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 1148 | + : ("'debut" . substr($type, 1)); |
|
| 1149 | + |
|
| 1150 | + $p->code = sprintf( |
|
| 1151 | + CODE_PAGINATION, |
|
| 1152 | + $f_pagination, |
|
| 1153 | + $b, |
|
| 1154 | + $type, |
|
| 1155 | + $modif, |
|
| 1156 | + $pas, |
|
| 1157 | + $liste, |
|
| 1158 | + ((isset($__modele) and $__modele) ? $__modele : "''"), |
|
| 1159 | + _q($connect), |
|
| 1160 | + $code_contexte |
|
| 1161 | + ); |
|
| 1162 | + |
|
| 1163 | + $p->boucles[$b]->numrows = true; |
|
| 1164 | + $p->interdire_scripts = false; |
|
| 1165 | + |
|
| 1166 | + return $p; |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | 1169 | |
@@ -1190,11 +1190,11 @@ discard block |
||
| 1190 | 1190 | * Pile complétée par le code à générer |
| 1191 | 1191 | **/ |
| 1192 | 1192 | function balise_ANCRE_PAGINATION_dist($p) { |
| 1193 | - if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 1194 | - return $f($p, $liste = 'false'); |
|
| 1195 | - } else { |
|
| 1196 | - return null; |
|
| 1197 | - } // ou une erreur ? |
|
| 1193 | + if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 1194 | + return $f($p, $liste = 'false'); |
|
| 1195 | + } else { |
|
| 1196 | + return null; |
|
| 1197 | + } // ou une erreur ? |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | |
@@ -1215,17 +1215,17 @@ discard block |
||
| 1215 | 1215 | * Pile complétée par le code à générer |
| 1216 | 1216 | **/ |
| 1217 | 1217 | function balise_GRAND_TOTAL_dist($p) { |
| 1218 | - $b = index_boucle_mere($p); |
|
| 1219 | - if ($b === '') { |
|
| 1220 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 1221 | - erreur_squelette($msg, $p); |
|
| 1222 | - } else { |
|
| 1223 | - $p->code = "(\$Numrows['$b']['grand_total'] ?? \$Numrows['$b']['total'] ?? 0)"; |
|
| 1224 | - $p->boucles[$b]->numrows = true; |
|
| 1225 | - $p->interdire_scripts = false; |
|
| 1226 | - } |
|
| 1218 | + $b = index_boucle_mere($p); |
|
| 1219 | + if ($b === '') { |
|
| 1220 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 1221 | + erreur_squelette($msg, $p); |
|
| 1222 | + } else { |
|
| 1223 | + $p->code = "(\$Numrows['$b']['grand_total'] ?? \$Numrows['$b']['total'] ?? 0)"; |
|
| 1224 | + $p->boucles[$b]->numrows = true; |
|
| 1225 | + $p->interdire_scripts = false; |
|
| 1226 | + } |
|
| 1227 | 1227 | |
| 1228 | - return $p; |
|
| 1228 | + return $p; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | |
@@ -1253,10 +1253,10 @@ discard block |
||
| 1253 | 1253 | * Pile complétée par le code à générer |
| 1254 | 1254 | **/ |
| 1255 | 1255 | function balise_SELF_dist($p) { |
| 1256 | - $p->code = 'self()'; |
|
| 1257 | - $p->interdire_scripts = false; |
|
| 1256 | + $p->code = 'self()'; |
|
| 1257 | + $p->interdire_scripts = false; |
|
| 1258 | 1258 | |
| 1259 | - return $p; |
|
| 1259 | + return $p; |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | |
@@ -1283,17 +1283,17 @@ discard block |
||
| 1283 | 1283 | * Pile complétée par le code à générer |
| 1284 | 1284 | **/ |
| 1285 | 1285 | function balise_CHEMIN_dist($p) { |
| 1286 | - $arg = interprete_argument_balise(1, $p); |
|
| 1287 | - if (!$arg) { |
|
| 1288 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN']]; |
|
| 1289 | - erreur_squelette($msg, $p); |
|
| 1290 | - } else { |
|
| 1291 | - $p->code = 'find_in_path((string)' . $arg . ')'; |
|
| 1292 | - } |
|
| 1286 | + $arg = interprete_argument_balise(1, $p); |
|
| 1287 | + if (!$arg) { |
|
| 1288 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN']]; |
|
| 1289 | + erreur_squelette($msg, $p); |
|
| 1290 | + } else { |
|
| 1291 | + $p->code = 'find_in_path((string)' . $arg . ')'; |
|
| 1292 | + } |
|
| 1293 | 1293 | |
| 1294 | - $p->interdire_scripts = false; |
|
| 1294 | + $p->interdire_scripts = false; |
|
| 1295 | 1295 | |
| 1296 | - return $p; |
|
| 1296 | + return $p; |
|
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | 1299 | /** |
@@ -1318,16 +1318,16 @@ discard block |
||
| 1318 | 1318 | * Pile complétée par le code à générer |
| 1319 | 1319 | **/ |
| 1320 | 1320 | function balise_CHEMIN_IMAGE_dist($p) { |
| 1321 | - $arg = interprete_argument_balise(1, $p); |
|
| 1322 | - if (!$arg) { |
|
| 1323 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN_IMAGE']]; |
|
| 1324 | - erreur_squelette($msg, $p); |
|
| 1325 | - } else { |
|
| 1326 | - $p->code = 'chemin_image((string)' . $arg . ')'; |
|
| 1327 | - } |
|
| 1321 | + $arg = interprete_argument_balise(1, $p); |
|
| 1322 | + if (!$arg) { |
|
| 1323 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN_IMAGE']]; |
|
| 1324 | + erreur_squelette($msg, $p); |
|
| 1325 | + } else { |
|
| 1326 | + $p->code = 'chemin_image((string)' . $arg . ')'; |
|
| 1327 | + } |
|
| 1328 | 1328 | |
| 1329 | - $p->interdire_scripts = false; |
|
| 1330 | - return $p; |
|
| 1329 | + $p->interdire_scripts = false; |
|
| 1330 | + return $p; |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | |
@@ -1365,36 +1365,36 @@ discard block |
||
| 1365 | 1365 | **/ |
| 1366 | 1366 | function balise_ENV_dist($p, $src = null) { |
| 1367 | 1367 | |
| 1368 | - // cle du tableau desiree |
|
| 1369 | - $_nom = interprete_argument_balise(1, $p); |
|
| 1370 | - // valeur par defaut |
|
| 1371 | - $_sinon = interprete_argument_balise(2, $p); |
|
| 1368 | + // cle du tableau desiree |
|
| 1369 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1370 | + // valeur par defaut |
|
| 1371 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 1372 | 1372 | |
| 1373 | - // $src est un tableau de donnees sources eventuellement transmis |
|
| 1374 | - // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 1373 | + // $src est un tableau de donnees sources eventuellement transmis |
|
| 1374 | + // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 1375 | 1375 | |
| 1376 | - if (!$_nom) { |
|
| 1377 | - // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 1378 | - // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 1379 | - if ($src) { |
|
| 1380 | - $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1381 | - } else { |
|
| 1382 | - $p->code = 'serialize($Pile[0]??[])'; |
|
| 1383 | - } |
|
| 1384 | - } else { |
|
| 1385 | - if (!$src) { |
|
| 1386 | - $src = '$Pile[0]??[]'; |
|
| 1387 | - } |
|
| 1388 | - if ($_sinon) { |
|
| 1389 | - $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 1390 | - } else { |
|
| 1391 | - $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 1392 | - } |
|
| 1393 | - } |
|
| 1376 | + if (!$_nom) { |
|
| 1377 | + // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 1378 | + // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 1379 | + if ($src) { |
|
| 1380 | + $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1381 | + } else { |
|
| 1382 | + $p->code = 'serialize($Pile[0]??[])'; |
|
| 1383 | + } |
|
| 1384 | + } else { |
|
| 1385 | + if (!$src) { |
|
| 1386 | + $src = '$Pile[0]??[]'; |
|
| 1387 | + } |
|
| 1388 | + if ($_sinon) { |
|
| 1389 | + $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 1390 | + } else { |
|
| 1391 | + $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 1392 | + } |
|
| 1393 | + } |
|
| 1394 | 1394 | |
| 1395 | - #$p->interdire_scripts = true; |
|
| 1395 | + #$p->interdire_scripts = true; |
|
| 1396 | 1396 | |
| 1397 | - return $p; |
|
| 1397 | + return $p; |
|
| 1398 | 1398 | } |
| 1399 | 1399 | |
| 1400 | 1400 | /** |
@@ -1424,16 +1424,16 @@ discard block |
||
| 1424 | 1424 | * Pile completée du code PHP d'exécution de la balise |
| 1425 | 1425 | */ |
| 1426 | 1426 | function balise_CONFIG_dist($p) { |
| 1427 | - if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 1428 | - $arg = "''"; |
|
| 1429 | - } |
|
| 1430 | - $_sinon = interprete_argument_balise(2, $p); |
|
| 1431 | - $_unserialize = sinon(interprete_argument_balise(3, $p), 'false'); |
|
| 1427 | + if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 1428 | + $arg = "''"; |
|
| 1429 | + } |
|
| 1430 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 1431 | + $_unserialize = sinon(interprete_argument_balise(3, $p), 'false'); |
|
| 1432 | 1432 | |
| 1433 | - $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1434 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1433 | + $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1434 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1435 | 1435 | |
| 1436 | - return $p; |
|
| 1436 | + return $p; |
|
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | |
@@ -1456,10 +1456,10 @@ discard block |
||
| 1456 | 1456 | * Pile completée du code PHP d'exécution de la balise |
| 1457 | 1457 | */ |
| 1458 | 1458 | function balise_CONNECT_dist($p) { |
| 1459 | - $p->code = '($connect ? $connect : NULL)'; |
|
| 1460 | - $p->interdire_scripts = false; |
|
| 1459 | + $p->code = '($connect ? $connect : NULL)'; |
|
| 1460 | + $p->interdire_scripts = false; |
|
| 1461 | 1461 | |
| 1462 | - return $p; |
|
| 1462 | + return $p; |
|
| 1463 | 1463 | } |
| 1464 | 1464 | |
| 1465 | 1465 | |
@@ -1487,15 +1487,15 @@ discard block |
||
| 1487 | 1487 | * Pile completée du code PHP d'exécution de la balise |
| 1488 | 1488 | **/ |
| 1489 | 1489 | function balise_SESSION_dist($p) { |
| 1490 | - $p->descr['session'] = true; |
|
| 1490 | + $p->descr['session'] = true; |
|
| 1491 | 1491 | |
| 1492 | - $f = function_exists('balise_ENV') |
|
| 1493 | - ? 'balise_ENV' |
|
| 1494 | - : 'balise_ENV_dist'; |
|
| 1492 | + $f = function_exists('balise_ENV') |
|
| 1493 | + ? 'balise_ENV' |
|
| 1494 | + : 'balise_ENV_dist'; |
|
| 1495 | 1495 | |
| 1496 | - $p = $f($p, '$GLOBALS["visiteur_session"]??[]'); |
|
| 1496 | + $p = $f($p, '$GLOBALS["visiteur_session"]??[]'); |
|
| 1497 | 1497 | |
| 1498 | - return $p; |
|
| 1498 | + return $p; |
|
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | 1501 | |
@@ -1518,18 +1518,18 @@ discard block |
||
| 1518 | 1518 | * Pile completée du code PHP d'exécution de la balise |
| 1519 | 1519 | **/ |
| 1520 | 1520 | function balise_SESSION_SET_dist($p) { |
| 1521 | - $_nom = interprete_argument_balise(1, $p); |
|
| 1522 | - $_val = interprete_argument_balise(2, $p); |
|
| 1523 | - if (!$_nom or !$_val) { |
|
| 1524 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SESSION_SET']]; |
|
| 1525 | - erreur_squelette($err_b_s_a, $p); |
|
| 1526 | - } else { |
|
| 1527 | - $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1528 | - } |
|
| 1521 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1522 | + $_val = interprete_argument_balise(2, $p); |
|
| 1523 | + if (!$_nom or !$_val) { |
|
| 1524 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SESSION_SET']]; |
|
| 1525 | + erreur_squelette($err_b_s_a, $p); |
|
| 1526 | + } else { |
|
| 1527 | + $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1528 | + } |
|
| 1529 | 1529 | |
| 1530 | - $p->interdire_scripts = false; |
|
| 1530 | + $p->interdire_scripts = false; |
|
| 1531 | 1531 | |
| 1532 | - return $p; |
|
| 1532 | + return $p; |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | |
@@ -1560,30 +1560,30 @@ discard block |
||
| 1560 | 1560 | * Pile completée du code PHP d'exécution de la balise |
| 1561 | 1561 | **/ |
| 1562 | 1562 | function balise_EVAL_dist($p) { |
| 1563 | - $php = interprete_argument_balise(1, $p); |
|
| 1564 | - if ($php) { |
|
| 1565 | - # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 1566 | - # attention au commentaire "// x signes" qui precede |
|
| 1567 | - if ( |
|
| 1568 | - preg_match( |
|
| 1569 | - ",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 1570 | - $php, |
|
| 1571 | - $r |
|
| 1572 | - ) |
|
| 1573 | - ) { |
|
| 1574 | - $p->code = /* $r[1]. */ |
|
| 1575 | - '(' . $r[2] . ')'; |
|
| 1576 | - } else { |
|
| 1577 | - $p->code = "eval('return '.$php.';')"; |
|
| 1578 | - } |
|
| 1579 | - } else { |
|
| 1580 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' EVAL']]; |
|
| 1581 | - erreur_squelette($msg, $p); |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - #$p->interdire_scripts = true; |
|
| 1585 | - |
|
| 1586 | - return $p; |
|
| 1563 | + $php = interprete_argument_balise(1, $p); |
|
| 1564 | + if ($php) { |
|
| 1565 | + # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 1566 | + # attention au commentaire "// x signes" qui precede |
|
| 1567 | + if ( |
|
| 1568 | + preg_match( |
|
| 1569 | + ",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 1570 | + $php, |
|
| 1571 | + $r |
|
| 1572 | + ) |
|
| 1573 | + ) { |
|
| 1574 | + $p->code = /* $r[1]. */ |
|
| 1575 | + '(' . $r[2] . ')'; |
|
| 1576 | + } else { |
|
| 1577 | + $p->code = "eval('return '.$php.';')"; |
|
| 1578 | + } |
|
| 1579 | + } else { |
|
| 1580 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' EVAL']]; |
|
| 1581 | + erreur_squelette($msg, $p); |
|
| 1582 | + } |
|
| 1583 | + |
|
| 1584 | + #$p->interdire_scripts = true; |
|
| 1585 | + |
|
| 1586 | + return $p; |
|
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | 1589 | |
@@ -1613,19 +1613,19 @@ discard block |
||
| 1613 | 1613 | **/ |
| 1614 | 1614 | function balise_CHAMP_SQL_dist($p) { |
| 1615 | 1615 | |
| 1616 | - if ( |
|
| 1617 | - $p->param |
|
| 1618 | - and isset($p->param[0][1][0]) |
|
| 1619 | - and $champ = ($p->param[0][1][0]->texte) |
|
| 1620 | - ) { |
|
| 1621 | - $p->code = champ_sql($champ, $p); |
|
| 1622 | - } else { |
|
| 1623 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => ' CHAMP_SQL']]; |
|
| 1624 | - erreur_squelette($err_b_s_a, $p); |
|
| 1625 | - } |
|
| 1616 | + if ( |
|
| 1617 | + $p->param |
|
| 1618 | + and isset($p->param[0][1][0]) |
|
| 1619 | + and $champ = ($p->param[0][1][0]->texte) |
|
| 1620 | + ) { |
|
| 1621 | + $p->code = champ_sql($champ, $p); |
|
| 1622 | + } else { |
|
| 1623 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => ' CHAMP_SQL']]; |
|
| 1624 | + erreur_squelette($err_b_s_a, $p); |
|
| 1625 | + } |
|
| 1626 | 1626 | |
| 1627 | - #$p->interdire_scripts = true; |
|
| 1628 | - return $p; |
|
| 1627 | + #$p->interdire_scripts = true; |
|
| 1628 | + return $p; |
|
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | /** |
@@ -1651,13 +1651,13 @@ discard block |
||
| 1651 | 1651 | * Pile complétée par le code à générer |
| 1652 | 1652 | **/ |
| 1653 | 1653 | function balise_VAL_dist($p) { |
| 1654 | - $p->code = interprete_argument_balise(1, $p) ?? ''; |
|
| 1655 | - if (!strlen($p->code)) { |
|
| 1656 | - $p->code = "''"; |
|
| 1657 | - } |
|
| 1658 | - $p->interdire_scripts = false; |
|
| 1654 | + $p->code = interprete_argument_balise(1, $p) ?? ''; |
|
| 1655 | + if (!strlen($p->code)) { |
|
| 1656 | + $p->code = "''"; |
|
| 1657 | + } |
|
| 1658 | + $p->interdire_scripts = false; |
|
| 1659 | 1659 | |
| 1660 | - return $p; |
|
| 1660 | + return $p; |
|
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | /** |
@@ -1686,10 +1686,10 @@ discard block |
||
| 1686 | 1686 | * Pile complétée par le code à générer |
| 1687 | 1687 | **/ |
| 1688 | 1688 | function balise_REM_dist($p) { |
| 1689 | - $p->code = "''"; |
|
| 1690 | - $p->interdire_scripts = false; |
|
| 1689 | + $p->code = "''"; |
|
| 1690 | + $p->interdire_scripts = false; |
|
| 1691 | 1691 | |
| 1692 | - return $p; |
|
| 1692 | + return $p; |
|
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | 1695 | /** |
@@ -1699,10 +1699,10 @@ discard block |
||
| 1699 | 1699 | * @return mixed |
| 1700 | 1700 | */ |
| 1701 | 1701 | function balise_NULL_dist($p) { |
| 1702 | - $p->code = 'null'; |
|
| 1703 | - $p->interdire_scripts = false; |
|
| 1702 | + $p->code = 'null'; |
|
| 1703 | + $p->interdire_scripts = false; |
|
| 1704 | 1704 | |
| 1705 | - return $p; |
|
| 1705 | + return $p; |
|
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | 1708 | |
@@ -1726,18 +1726,18 @@ discard block |
||
| 1726 | 1726 | **/ |
| 1727 | 1727 | function balise_HTTP_HEADER_dist($p) { |
| 1728 | 1728 | |
| 1729 | - $header = interprete_argument_balise(1, $p); |
|
| 1730 | - if (!$header) { |
|
| 1731 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'HTTP_HEADER']]; |
|
| 1732 | - erreur_squelette($err_b_s_a, $p); |
|
| 1733 | - } else { |
|
| 1734 | - $p->code = "'<'.'?php header(' . _q(" |
|
| 1735 | - . $header |
|
| 1736 | - . ") . '); ?'.'>'"; |
|
| 1737 | - } |
|
| 1738 | - $p->interdire_scripts = false; |
|
| 1729 | + $header = interprete_argument_balise(1, $p); |
|
| 1730 | + if (!$header) { |
|
| 1731 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'HTTP_HEADER']]; |
|
| 1732 | + erreur_squelette($err_b_s_a, $p); |
|
| 1733 | + } else { |
|
| 1734 | + $p->code = "'<'.'?php header(' . _q(" |
|
| 1735 | + . $header |
|
| 1736 | + . ") . '); ?'.'>'"; |
|
| 1737 | + } |
|
| 1738 | + $p->interdire_scripts = false; |
|
| 1739 | 1739 | |
| 1740 | - return $p; |
|
| 1740 | + return $p; |
|
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | |
@@ -1762,22 +1762,22 @@ discard block |
||
| 1762 | 1762 | * Pile complétée par le code à générer |
| 1763 | 1763 | **/ |
| 1764 | 1764 | function balise_FILTRE_dist($p) { |
| 1765 | - if ($p->param) { |
|
| 1766 | - $args = []; |
|
| 1767 | - foreach ($p->param as $i => $ignore) { |
|
| 1768 | - $args[] = interprete_argument_balise($i + 1, $p); |
|
| 1769 | - } |
|
| 1770 | - $p->code = "'<' . '" |
|
| 1771 | - . '?php header("X-Spip-Filtre: \'.' |
|
| 1772 | - . join('.\'|\'.', $args) |
|
| 1773 | - . " . '\"); ?'.'>'"; |
|
| 1765 | + if ($p->param) { |
|
| 1766 | + $args = []; |
|
| 1767 | + foreach ($p->param as $i => $ignore) { |
|
| 1768 | + $args[] = interprete_argument_balise($i + 1, $p); |
|
| 1769 | + } |
|
| 1770 | + $p->code = "'<' . '" |
|
| 1771 | + . '?php header("X-Spip-Filtre: \'.' |
|
| 1772 | + . join('.\'|\'.', $args) |
|
| 1773 | + . " . '\"); ?'.'>'"; |
|
| 1774 | 1774 | |
| 1775 | - $p->interdire_scripts = false; |
|
| 1775 | + $p->interdire_scripts = false; |
|
| 1776 | 1776 | |
| 1777 | - return $p; |
|
| 1778 | - } |
|
| 1777 | + return $p; |
|
| 1778 | + } |
|
| 1779 | 1779 | |
| 1780 | - return null; |
|
| 1780 | + return null; |
|
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | 1783 | |
@@ -1813,55 +1813,55 @@ discard block |
||
| 1813 | 1813 | **/ |
| 1814 | 1814 | function balise_CACHE_dist($p) { |
| 1815 | 1815 | |
| 1816 | - if ($p->param) { |
|
| 1817 | - $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 1818 | - |
|
| 1819 | - // noter la duree du cache dans un entete proprietaire |
|
| 1820 | - |
|
| 1821 | - $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1822 | - . $duree |
|
| 1823 | - . '"); ?' . "'.'>'"; |
|
| 1824 | - |
|
| 1825 | - // Remplir le header Cache-Control |
|
| 1826 | - // cas #CACHE{0} |
|
| 1827 | - if ($duree == 0) { |
|
| 1828 | - $code .= ".'<'.'" |
|
| 1829 | - . '?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 1830 | - . "'.'><'.'" |
|
| 1831 | - . '?php header("Pragma: no-cache"); ?' |
|
| 1832 | - . "'.'>'"; |
|
| 1833 | - } |
|
| 1834 | - |
|
| 1835 | - // recuperer les parametres suivants |
|
| 1836 | - $i = 1; |
|
| 1837 | - while (isset($p->param[0][++$i])) { |
|
| 1838 | - $pa = ($p->param[0][$i][0]->texte); |
|
| 1839 | - |
|
| 1840 | - if ( |
|
| 1841 | - $pa == 'cache-client' |
|
| 1842 | - and $duree > 0 |
|
| 1843 | - ) { |
|
| 1844 | - $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1845 | - . $duree |
|
| 1846 | - . '"); ?' . "'.'>'"; |
|
| 1847 | - // il semble logique, si on cache-client, de ne pas invalider |
|
| 1848 | - $pa = 'statique'; |
|
| 1849 | - } |
|
| 1850 | - |
|
| 1851 | - if ( |
|
| 1852 | - $pa == 'statique' |
|
| 1853 | - and $duree > 0 |
|
| 1854 | - ) { |
|
| 1855 | - $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1856 | - } |
|
| 1857 | - } |
|
| 1858 | - } else { |
|
| 1859 | - $code = "''"; |
|
| 1860 | - } |
|
| 1861 | - $p->code = $code; |
|
| 1862 | - $p->interdire_scripts = false; |
|
| 1863 | - |
|
| 1864 | - return $p; |
|
| 1816 | + if ($p->param) { |
|
| 1817 | + $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 1818 | + |
|
| 1819 | + // noter la duree du cache dans un entete proprietaire |
|
| 1820 | + |
|
| 1821 | + $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1822 | + . $duree |
|
| 1823 | + . '"); ?' . "'.'>'"; |
|
| 1824 | + |
|
| 1825 | + // Remplir le header Cache-Control |
|
| 1826 | + // cas #CACHE{0} |
|
| 1827 | + if ($duree == 0) { |
|
| 1828 | + $code .= ".'<'.'" |
|
| 1829 | + . '?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 1830 | + . "'.'><'.'" |
|
| 1831 | + . '?php header("Pragma: no-cache"); ?' |
|
| 1832 | + . "'.'>'"; |
|
| 1833 | + } |
|
| 1834 | + |
|
| 1835 | + // recuperer les parametres suivants |
|
| 1836 | + $i = 1; |
|
| 1837 | + while (isset($p->param[0][++$i])) { |
|
| 1838 | + $pa = ($p->param[0][$i][0]->texte); |
|
| 1839 | + |
|
| 1840 | + if ( |
|
| 1841 | + $pa == 'cache-client' |
|
| 1842 | + and $duree > 0 |
|
| 1843 | + ) { |
|
| 1844 | + $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1845 | + . $duree |
|
| 1846 | + . '"); ?' . "'.'>'"; |
|
| 1847 | + // il semble logique, si on cache-client, de ne pas invalider |
|
| 1848 | + $pa = 'statique'; |
|
| 1849 | + } |
|
| 1850 | + |
|
| 1851 | + if ( |
|
| 1852 | + $pa == 'statique' |
|
| 1853 | + and $duree > 0 |
|
| 1854 | + ) { |
|
| 1855 | + $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1856 | + } |
|
| 1857 | + } |
|
| 1858 | + } else { |
|
| 1859 | + $code = "''"; |
|
| 1860 | + } |
|
| 1861 | + $p->code = $code; |
|
| 1862 | + $p->interdire_scripts = false; |
|
| 1863 | + |
|
| 1864 | + return $p; |
|
| 1865 | 1865 | } |
| 1866 | 1866 | |
| 1867 | 1867 | |
@@ -1893,13 +1893,13 @@ discard block |
||
| 1893 | 1893 | * Pile complétée par le code à générer |
| 1894 | 1894 | */ |
| 1895 | 1895 | function balise_INSERT_HEAD_dist($p) { |
| 1896 | - $p->code = "'<'.'" |
|
| 1897 | - . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' |
|
| 1898 | - . "'.'>'"; |
|
| 1899 | - $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1900 | - $p->interdire_scripts = false; |
|
| 1896 | + $p->code = "'<'.'" |
|
| 1897 | + . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' |
|
| 1898 | + . "'.'>'"; |
|
| 1899 | + $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1900 | + $p->interdire_scripts = false; |
|
| 1901 | 1901 | |
| 1902 | - return $p; |
|
| 1902 | + return $p; |
|
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | 1905 | /** |
@@ -1917,10 +1917,10 @@ discard block |
||
| 1917 | 1917 | * Pile complétée par le code à générer |
| 1918 | 1918 | */ |
| 1919 | 1919 | function balise_INSERT_HEAD_CSS_dist($p) { |
| 1920 | - $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1921 | - $p->interdire_scripts = false; |
|
| 1920 | + $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1921 | + $p->interdire_scripts = false; |
|
| 1922 | 1922 | |
| 1923 | - return $p; |
|
| 1923 | + return $p; |
|
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | 1926 | /** |
@@ -1935,11 +1935,11 @@ discard block |
||
| 1935 | 1935 | * Pile complétée par le code à générer |
| 1936 | 1936 | **/ |
| 1937 | 1937 | function balise_INCLUDE_dist($p) { |
| 1938 | - if (function_exists('balise_INCLURE')) { |
|
| 1939 | - return balise_INCLURE($p); |
|
| 1940 | - } else { |
|
| 1941 | - return balise_INCLURE_dist($p); |
|
| 1942 | - } |
|
| 1938 | + if (function_exists('balise_INCLURE')) { |
|
| 1939 | + return balise_INCLURE($p); |
|
| 1940 | + } else { |
|
| 1941 | + return balise_INCLURE_dist($p); |
|
| 1942 | + } |
|
| 1943 | 1943 | } |
| 1944 | 1944 | |
| 1945 | 1945 | /** |
@@ -1973,66 +1973,66 @@ discard block |
||
| 1973 | 1973 | * Pile complétée par le code à générer |
| 1974 | 1974 | **/ |
| 1975 | 1975 | function balise_INCLURE_dist($p) { |
| 1976 | - $id_boucle = $p->id_boucle; |
|
| 1977 | - // la lang n'est pas passe de facon automatique par argumenter |
|
| 1978 | - // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1979 | - // en option |
|
| 1980 | - |
|
| 1981 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1982 | - |
|
| 1983 | - // erreur de syntaxe = fond absent |
|
| 1984 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1985 | - if (!$_contexte) { |
|
| 1986 | - $_contexte = []; |
|
| 1987 | - } |
|
| 1988 | - |
|
| 1989 | - if (isset($_contexte['fond'])) { |
|
| 1990 | - $f = $_contexte['fond']; |
|
| 1991 | - // toujours vrai : |
|
| 1992 | - if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1993 | - $f = $r[1]; |
|
| 1994 | - unset($_contexte['fond']); |
|
| 1995 | - } else { |
|
| 1996 | - spip_log('compilation de #INCLURE a revoir'); |
|
| 1997 | - } |
|
| 1998 | - |
|
| 1999 | - // #INCLURE{doublons} |
|
| 2000 | - if (isset($_contexte['doublons'])) { |
|
| 2001 | - $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 2002 | - } |
|
| 2003 | - |
|
| 2004 | - // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 2005 | - $flag_env = false; |
|
| 2006 | - if (isset($_contexte['env']) or isset($_contexte['self'])) { |
|
| 2007 | - $flag_env = true; |
|
| 2008 | - unset($_contexte['env']); |
|
| 2009 | - } |
|
| 2010 | - |
|
| 2011 | - $_options = []; |
|
| 2012 | - if (isset($_contexte['ajax'])) { |
|
| 2013 | - $_options[] = preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2014 | - unset($_contexte['ajax']); |
|
| 2015 | - } |
|
| 2016 | - if ($p->etoile) { |
|
| 2017 | - $_options[] = "'etoile'=>true"; |
|
| 2018 | - } |
|
| 2019 | - $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ')'; |
|
| 2020 | - |
|
| 2021 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2022 | - if ($flag_env) { |
|
| 2023 | - $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2024 | - } |
|
| 2025 | - |
|
| 2026 | - $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect') ?? ''"); |
|
| 2027 | - } elseif (!isset($_contexte[1])) { |
|
| 2028 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' INCLURE']]; |
|
| 2029 | - erreur_squelette($msg, $p); |
|
| 2030 | - } else { |
|
| 2031 | - $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2032 | - } |
|
| 2033 | - |
|
| 2034 | - $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 2035 | - return $p; |
|
| 1976 | + $id_boucle = $p->id_boucle; |
|
| 1977 | + // la lang n'est pas passe de facon automatique par argumenter |
|
| 1978 | + // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1979 | + // en option |
|
| 1980 | + |
|
| 1981 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1982 | + |
|
| 1983 | + // erreur de syntaxe = fond absent |
|
| 1984 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1985 | + if (!$_contexte) { |
|
| 1986 | + $_contexte = []; |
|
| 1987 | + } |
|
| 1988 | + |
|
| 1989 | + if (isset($_contexte['fond'])) { |
|
| 1990 | + $f = $_contexte['fond']; |
|
| 1991 | + // toujours vrai : |
|
| 1992 | + if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1993 | + $f = $r[1]; |
|
| 1994 | + unset($_contexte['fond']); |
|
| 1995 | + } else { |
|
| 1996 | + spip_log('compilation de #INCLURE a revoir'); |
|
| 1997 | + } |
|
| 1998 | + |
|
| 1999 | + // #INCLURE{doublons} |
|
| 2000 | + if (isset($_contexte['doublons'])) { |
|
| 2001 | + $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 2002 | + } |
|
| 2003 | + |
|
| 2004 | + // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 2005 | + $flag_env = false; |
|
| 2006 | + if (isset($_contexte['env']) or isset($_contexte['self'])) { |
|
| 2007 | + $flag_env = true; |
|
| 2008 | + unset($_contexte['env']); |
|
| 2009 | + } |
|
| 2010 | + |
|
| 2011 | + $_options = []; |
|
| 2012 | + if (isset($_contexte['ajax'])) { |
|
| 2013 | + $_options[] = preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2014 | + unset($_contexte['ajax']); |
|
| 2015 | + } |
|
| 2016 | + if ($p->etoile) { |
|
| 2017 | + $_options[] = "'etoile'=>true"; |
|
| 2018 | + } |
|
| 2019 | + $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ')'; |
|
| 2020 | + |
|
| 2021 | + $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2022 | + if ($flag_env) { |
|
| 2023 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2024 | + } |
|
| 2025 | + |
|
| 2026 | + $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect') ?? ''"); |
|
| 2027 | + } elseif (!isset($_contexte[1])) { |
|
| 2028 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' INCLURE']]; |
|
| 2029 | + erreur_squelette($msg, $p); |
|
| 2030 | + } else { |
|
| 2031 | + $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2032 | + } |
|
| 2033 | + |
|
| 2034 | + $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 2035 | + return $p; |
|
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | 2038 | |
@@ -2060,69 +2060,69 @@ discard block |
||
| 2060 | 2060 | **/ |
| 2061 | 2061 | function balise_MODELE_dist($p) { |
| 2062 | 2062 | |
| 2063 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 2064 | - |
|
| 2065 | - // erreur de syntaxe = fond absent |
|
| 2066 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 2067 | - if (!$_contexte) { |
|
| 2068 | - $_contexte = []; |
|
| 2069 | - } |
|
| 2070 | - |
|
| 2071 | - if (!isset($_contexte[1])) { |
|
| 2072 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' MODELE']]; |
|
| 2073 | - erreur_squelette($msg, $p); |
|
| 2074 | - } else { |
|
| 2075 | - $nom = $_contexte[1]; |
|
| 2076 | - unset($_contexte[1]); |
|
| 2077 | - |
|
| 2078 | - if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 2079 | - $nom = "'modeles/" . substr($nom, 1); |
|
| 2080 | - } else { |
|
| 2081 | - $nom = "'modeles/' . $nom"; |
|
| 2082 | - } |
|
| 2083 | - |
|
| 2084 | - $flag_env = false; |
|
| 2085 | - if (isset($_contexte['env'])) { |
|
| 2086 | - $flag_env = true; |
|
| 2087 | - unset($_contexte['env']); |
|
| 2088 | - } |
|
| 2089 | - |
|
| 2090 | - // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 2091 | - // Reserver la cle primaire de la boucle courante si elle existe |
|
| 2092 | - if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 2093 | - $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 2094 | - if (!strpos($primary, ',')) { |
|
| 2095 | - $id = champ_sql($primary, $p); |
|
| 2096 | - $_contexte[] = "'$primary'=>" . $id; |
|
| 2097 | - $_contexte[] = "'id'=>" . $id; |
|
| 2098 | - } |
|
| 2099 | - } |
|
| 2100 | - $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 2101 | - $connect = ''; |
|
| 2102 | - if (isset($p->boucles[$p->id_boucle])) { |
|
| 2103 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2104 | - } |
|
| 2105 | - |
|
| 2106 | - $_options = memoriser_contexte_compil($p); |
|
| 2107 | - $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 2108 | - if (isset($_contexte['ajax'])) { |
|
| 2109 | - $_options .= ', ' . preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2110 | - unset($_contexte['ajax']); |
|
| 2111 | - } |
|
| 2112 | - |
|
| 2113 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2114 | - if ($flag_env) { |
|
| 2115 | - $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2116 | - } |
|
| 2117 | - |
|
| 2118 | - $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect)); |
|
| 2119 | - |
|
| 2120 | - $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 2121 | - |
|
| 2122 | - $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 2123 | - } |
|
| 2124 | - |
|
| 2125 | - return $p; |
|
| 2063 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 2064 | + |
|
| 2065 | + // erreur de syntaxe = fond absent |
|
| 2066 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 2067 | + if (!$_contexte) { |
|
| 2068 | + $_contexte = []; |
|
| 2069 | + } |
|
| 2070 | + |
|
| 2071 | + if (!isset($_contexte[1])) { |
|
| 2072 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' MODELE']]; |
|
| 2073 | + erreur_squelette($msg, $p); |
|
| 2074 | + } else { |
|
| 2075 | + $nom = $_contexte[1]; |
|
| 2076 | + unset($_contexte[1]); |
|
| 2077 | + |
|
| 2078 | + if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 2079 | + $nom = "'modeles/" . substr($nom, 1); |
|
| 2080 | + } else { |
|
| 2081 | + $nom = "'modeles/' . $nom"; |
|
| 2082 | + } |
|
| 2083 | + |
|
| 2084 | + $flag_env = false; |
|
| 2085 | + if (isset($_contexte['env'])) { |
|
| 2086 | + $flag_env = true; |
|
| 2087 | + unset($_contexte['env']); |
|
| 2088 | + } |
|
| 2089 | + |
|
| 2090 | + // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 2091 | + // Reserver la cle primaire de la boucle courante si elle existe |
|
| 2092 | + if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 2093 | + $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 2094 | + if (!strpos($primary, ',')) { |
|
| 2095 | + $id = champ_sql($primary, $p); |
|
| 2096 | + $_contexte[] = "'$primary'=>" . $id; |
|
| 2097 | + $_contexte[] = "'id'=>" . $id; |
|
| 2098 | + } |
|
| 2099 | + } |
|
| 2100 | + $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 2101 | + $connect = ''; |
|
| 2102 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 2103 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2104 | + } |
|
| 2105 | + |
|
| 2106 | + $_options = memoriser_contexte_compil($p); |
|
| 2107 | + $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 2108 | + if (isset($_contexte['ajax'])) { |
|
| 2109 | + $_options .= ', ' . preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2110 | + unset($_contexte['ajax']); |
|
| 2111 | + } |
|
| 2112 | + |
|
| 2113 | + $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2114 | + if ($flag_env) { |
|
| 2115 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2116 | + } |
|
| 2117 | + |
|
| 2118 | + $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect)); |
|
| 2119 | + |
|
| 2120 | + $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 2121 | + |
|
| 2122 | + $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 2123 | + } |
|
| 2124 | + |
|
| 2125 | + return $p; |
|
| 2126 | 2126 | } |
| 2127 | 2127 | |
| 2128 | 2128 | |
@@ -2146,21 +2146,21 @@ discard block |
||
| 2146 | 2146 | * Pile complétée par le code à générer |
| 2147 | 2147 | **/ |
| 2148 | 2148 | function balise_SET_dist($p) { |
| 2149 | - $_nom = interprete_argument_balise(1, $p); |
|
| 2150 | - $_val = interprete_argument_balise(2, $p); |
|
| 2149 | + $_nom = interprete_argument_balise(1, $p); |
|
| 2150 | + $_val = interprete_argument_balise(2, $p); |
|
| 2151 | 2151 | |
| 2152 | - if (!$_nom or !$_val) { |
|
| 2153 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SET']]; |
|
| 2154 | - erreur_squelette($err_b_s_a, $p); |
|
| 2155 | - } |
|
| 2156 | - // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 2157 | - // cf https://bugs.php.net/bug.php?id=65845 |
|
| 2158 | - else { |
|
| 2159 | - $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 2160 | - } |
|
| 2152 | + if (!$_nom or !$_val) { |
|
| 2153 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SET']]; |
|
| 2154 | + erreur_squelette($err_b_s_a, $p); |
|
| 2155 | + } |
|
| 2156 | + // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 2157 | + // cf https://bugs.php.net/bug.php?id=65845 |
|
| 2158 | + else { |
|
| 2159 | + $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 2160 | + } |
|
| 2161 | 2161 | |
| 2162 | - $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 2163 | - return $p; |
|
| 2162 | + $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 2163 | + return $p; |
|
| 2164 | 2164 | } |
| 2165 | 2165 | |
| 2166 | 2166 | |
@@ -2190,12 +2190,12 @@ discard block |
||
| 2190 | 2190 | * Pile complétée par le code à générer |
| 2191 | 2191 | **/ |
| 2192 | 2192 | function balise_GET_dist($p) { |
| 2193 | - $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 2194 | - if (function_exists('balise_ENV')) { |
|
| 2195 | - return balise_ENV($p, '$Pile["vars"]??[]'); |
|
| 2196 | - } else { |
|
| 2197 | - return balise_ENV_dist($p, '$Pile["vars"]??[]'); |
|
| 2198 | - } |
|
| 2193 | + $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 2194 | + if (function_exists('balise_ENV')) { |
|
| 2195 | + return balise_ENV($p, '$Pile["vars"]??[]'); |
|
| 2196 | + } else { |
|
| 2197 | + return balise_ENV_dist($p, '$Pile["vars"]??[]'); |
|
| 2198 | + } |
|
| 2199 | 2199 | } |
| 2200 | 2200 | |
| 2201 | 2201 | |
@@ -2218,22 +2218,22 @@ discard block |
||
| 2218 | 2218 | * Pile complétée par le code à générer |
| 2219 | 2219 | **/ |
| 2220 | 2220 | function balise_DOUBLONS_dist($p) { |
| 2221 | - if ($type = interprete_argument_balise(1, $p)) { |
|
| 2222 | - if ($famille = interprete_argument_balise(2, $p)) { |
|
| 2223 | - $type .= '.' . $famille; |
|
| 2224 | - } |
|
| 2225 | - $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2226 | - if (!$p->etoile) { |
|
| 2227 | - $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 2228 | - . $p->code . ')))'; |
|
| 2229 | - } |
|
| 2230 | - } else { |
|
| 2231 | - $p->code = '$doublons'; |
|
| 2232 | - } |
|
| 2221 | + if ($type = interprete_argument_balise(1, $p)) { |
|
| 2222 | + if ($famille = interprete_argument_balise(2, $p)) { |
|
| 2223 | + $type .= '.' . $famille; |
|
| 2224 | + } |
|
| 2225 | + $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2226 | + if (!$p->etoile) { |
|
| 2227 | + $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 2228 | + . $p->code . ')))'; |
|
| 2229 | + } |
|
| 2230 | + } else { |
|
| 2231 | + $p->code = '$doublons'; |
|
| 2232 | + } |
|
| 2233 | 2233 | |
| 2234 | - $p->interdire_scripts = false; |
|
| 2234 | + $p->interdire_scripts = false; |
|
| 2235 | 2235 | |
| 2236 | - return $p; |
|
| 2236 | + return $p; |
|
| 2237 | 2237 | } |
| 2238 | 2238 | |
| 2239 | 2239 | |
@@ -2256,18 +2256,18 @@ discard block |
||
| 2256 | 2256 | * Pile complétée par le code à générer |
| 2257 | 2257 | **/ |
| 2258 | 2258 | function balise_PIPELINE_dist($p) { |
| 2259 | - $_pipe = interprete_argument_balise(1, $p); |
|
| 2260 | - if (!$_pipe) { |
|
| 2261 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'PIPELINE']]; |
|
| 2262 | - erreur_squelette($err_b_s_a, $p); |
|
| 2263 | - } else { |
|
| 2264 | - $_flux = interprete_argument_balise(2, $p); |
|
| 2265 | - $_flux = $_flux ?: "''"; |
|
| 2266 | - $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 2267 | - $p->interdire_scripts = false; |
|
| 2268 | - } |
|
| 2259 | + $_pipe = interprete_argument_balise(1, $p); |
|
| 2260 | + if (!$_pipe) { |
|
| 2261 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'PIPELINE']]; |
|
| 2262 | + erreur_squelette($err_b_s_a, $p); |
|
| 2263 | + } else { |
|
| 2264 | + $_flux = interprete_argument_balise(2, $p); |
|
| 2265 | + $_flux = $_flux ?: "''"; |
|
| 2266 | + $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 2267 | + $p->interdire_scripts = false; |
|
| 2268 | + } |
|
| 2269 | 2269 | |
| 2270 | - return $p; |
|
| 2270 | + return $p; |
|
| 2271 | 2271 | } |
| 2272 | 2272 | |
| 2273 | 2273 | |
@@ -2292,10 +2292,10 @@ discard block |
||
| 2292 | 2292 | * Pile complétée par le code à générer |
| 2293 | 2293 | **/ |
| 2294 | 2294 | function balise_EDIT_dist($p) { |
| 2295 | - $p->code = "''"; |
|
| 2296 | - $p->interdire_scripts = false; |
|
| 2295 | + $p->code = "''"; |
|
| 2296 | + $p->interdire_scripts = false; |
|
| 2297 | 2297 | |
| 2298 | - return $p; |
|
| 2298 | + return $p; |
|
| 2299 | 2299 | } |
| 2300 | 2300 | |
| 2301 | 2301 | |
@@ -2318,11 +2318,11 @@ discard block |
||
| 2318 | 2318 | * Pile complétée par le code à générer |
| 2319 | 2319 | **/ |
| 2320 | 2320 | function balise_TOTAL_UNIQUE_dist($p) { |
| 2321 | - $_famille = interprete_argument_balise(1, $p); |
|
| 2322 | - $_famille = $_famille ?: "''"; |
|
| 2323 | - $p->code = "unique('', $_famille, true)"; |
|
| 2321 | + $_famille = interprete_argument_balise(1, $p); |
|
| 2322 | + $_famille = $_famille ?: "''"; |
|
| 2323 | + $p->code = "unique('', $_famille, true)"; |
|
| 2324 | 2324 | |
| 2325 | - return $p; |
|
| 2325 | + return $p; |
|
| 2326 | 2326 | } |
| 2327 | 2327 | |
| 2328 | 2328 | /** |
@@ -2345,19 +2345,19 @@ discard block |
||
| 2345 | 2345 | * Pile complétée par le code à générer |
| 2346 | 2346 | **/ |
| 2347 | 2347 | function balise_ARRAY_dist($p) { |
| 2348 | - $_code = []; |
|
| 2349 | - $n = 1; |
|
| 2350 | - do { |
|
| 2351 | - $_key = interprete_argument_balise($n++, $p); |
|
| 2352 | - $_val = interprete_argument_balise($n++, $p); |
|
| 2353 | - if ($_key and $_val) { |
|
| 2354 | - $_code[] = "$_key => $_val"; |
|
| 2355 | - } |
|
| 2356 | - } while ($_key && $_val); |
|
| 2357 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2358 | - $p->interdire_scripts = false; |
|
| 2348 | + $_code = []; |
|
| 2349 | + $n = 1; |
|
| 2350 | + do { |
|
| 2351 | + $_key = interprete_argument_balise($n++, $p); |
|
| 2352 | + $_val = interprete_argument_balise($n++, $p); |
|
| 2353 | + if ($_key and $_val) { |
|
| 2354 | + $_code[] = "$_key => $_val"; |
|
| 2355 | + } |
|
| 2356 | + } while ($_key && $_val); |
|
| 2357 | + $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2358 | + $p->interdire_scripts = false; |
|
| 2359 | 2359 | |
| 2360 | - return $p; |
|
| 2360 | + return $p; |
|
| 2361 | 2361 | } |
| 2362 | 2362 | |
| 2363 | 2363 | /** |
@@ -2376,15 +2376,15 @@ discard block |
||
| 2376 | 2376 | * Pile complétée par le code à générer |
| 2377 | 2377 | */ |
| 2378 | 2378 | function balise_LISTE_dist($p) { |
| 2379 | - $_code = []; |
|
| 2380 | - $n = 1; |
|
| 2381 | - while ($_val = interprete_argument_balise($n++, $p)) { |
|
| 2382 | - $_code[] = $_val; |
|
| 2383 | - } |
|
| 2384 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2385 | - $p->interdire_scripts = false; |
|
| 2379 | + $_code = []; |
|
| 2380 | + $n = 1; |
|
| 2381 | + while ($_val = interprete_argument_balise($n++, $p)) { |
|
| 2382 | + $_code[] = $_val; |
|
| 2383 | + } |
|
| 2384 | + $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2385 | + $p->interdire_scripts = false; |
|
| 2386 | 2386 | |
| 2387 | - return $p; |
|
| 2387 | + return $p; |
|
| 2388 | 2388 | } |
| 2389 | 2389 | |
| 2390 | 2390 | |
@@ -2418,21 +2418,21 @@ discard block |
||
| 2418 | 2418 | * Pile complétée par le code à générer |
| 2419 | 2419 | **/ |
| 2420 | 2420 | function balise_AUTORISER_dist($p) { |
| 2421 | - $_code = []; |
|
| 2422 | - $p->descr['session'] = true; // faire un cache par session |
|
| 2421 | + $_code = []; |
|
| 2422 | + $p->descr['session'] = true; // faire un cache par session |
|
| 2423 | 2423 | |
| 2424 | - $n = 1; |
|
| 2425 | - while ($_v = interprete_argument_balise($n++, $p)) { |
|
| 2426 | - $_code[] = $_v; |
|
| 2427 | - } |
|
| 2424 | + $n = 1; |
|
| 2425 | + while ($_v = interprete_argument_balise($n++, $p)) { |
|
| 2426 | + $_code[] = $_v; |
|
| 2427 | + } |
|
| 2428 | 2428 | |
| 2429 | - $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join( |
|
| 2430 | - ', ', |
|
| 2431 | - $_code |
|
| 2432 | - ) . ')?" ":"")'; |
|
| 2433 | - $p->interdire_scripts = false; |
|
| 2429 | + $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join( |
|
| 2430 | + ', ', |
|
| 2431 | + $_code |
|
| 2432 | + ) . ')?" ":"")'; |
|
| 2433 | + $p->interdire_scripts = false; |
|
| 2434 | 2434 | |
| 2435 | - return $p; |
|
| 2435 | + return $p; |
|
| 2436 | 2436 | } |
| 2437 | 2437 | |
| 2438 | 2438 | |
@@ -2456,15 +2456,15 @@ discard block |
||
| 2456 | 2456 | * Pile complétée par le code à générer |
| 2457 | 2457 | **/ |
| 2458 | 2458 | function balise_PLUGIN_dist($p) { |
| 2459 | - $plugin = interprete_argument_balise(1, $p); |
|
| 2460 | - $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 2461 | - $type_info = interprete_argument_balise(2, $p); |
|
| 2462 | - $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 2459 | + $plugin = interprete_argument_balise(1, $p); |
|
| 2460 | + $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 2461 | + $type_info = interprete_argument_balise(2, $p); |
|
| 2462 | + $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 2463 | 2463 | |
| 2464 | - $f = chercher_filtre('info_plugin'); |
|
| 2465 | - $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2464 | + $f = chercher_filtre('info_plugin'); |
|
| 2465 | + $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2466 | 2466 | |
| 2467 | - return $p; |
|
| 2467 | + return $p; |
|
| 2468 | 2468 | } |
| 2469 | 2469 | |
| 2470 | 2470 | /** |
@@ -2485,9 +2485,9 @@ discard block |
||
| 2485 | 2485 | * Pile complétée par le code à générer |
| 2486 | 2486 | **/ |
| 2487 | 2487 | function balise_AIDER_dist($p) { |
| 2488 | - $_motif = interprete_argument_balise(1, $p); |
|
| 2489 | - $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')"; |
|
| 2490 | - return $p; |
|
| 2488 | + $_motif = interprete_argument_balise(1, $p); |
|
| 2489 | + $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')"; |
|
| 2490 | + return $p; |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | /** |
@@ -2513,16 +2513,16 @@ discard block |
||
| 2513 | 2513 | * Pile complétée par le code à générer |
| 2514 | 2514 | **/ |
| 2515 | 2515 | function balise_ACTION_FORMULAIRE($p) { |
| 2516 | - if (!$_url = interprete_argument_balise(1, $p)) { |
|
| 2517 | - $_url = "(\$Pile[0]['action'] ?? '')"; |
|
| 2518 | - } |
|
| 2519 | - if (!$_form = interprete_argument_balise(2, $p)) { |
|
| 2520 | - $_form = "(\$Pile[0]['form'] ?? '')"; |
|
| 2521 | - } |
|
| 2522 | - |
|
| 2523 | - // envoyer le nom du formulaire que l'on traite |
|
| 2524 | - // transmettre les eventuels args de la balise formulaire |
|
| 2525 | - $p->code = " '<span class=\"form-hidden\">' . |
|
| 2516 | + if (!$_url = interprete_argument_balise(1, $p)) { |
|
| 2517 | + $_url = "(\$Pile[0]['action'] ?? '')"; |
|
| 2518 | + } |
|
| 2519 | + if (!$_form = interprete_argument_balise(2, $p)) { |
|
| 2520 | + $_form = "(\$Pile[0]['form'] ?? '')"; |
|
| 2521 | + } |
|
| 2522 | + |
|
| 2523 | + // envoyer le nom du formulaire que l'on traite |
|
| 2524 | + // transmettre les eventuels args de la balise formulaire |
|
| 2525 | + $p->code = " '<span class=\"form-hidden\">' . |
|
| 2526 | 2526 | form_hidden($_url) . |
| 2527 | 2527 | '<input name=\'formulaire_action\' type=\'hidden\' |
| 2528 | 2528 | value=\'' . $_form . '\' />' . |
@@ -2533,9 +2533,9 @@ discard block |
||
| 2533 | 2533 | (\$Pile[0]['_hidden'] ?? '') . |
| 2534 | 2534 | '</span>'"; |
| 2535 | 2535 | |
| 2536 | - $p->interdire_scripts = false; |
|
| 2536 | + $p->interdire_scripts = false; |
|
| 2537 | 2537 | |
| 2538 | - return $p; |
|
| 2538 | + return $p; |
|
| 2539 | 2539 | } |
| 2540 | 2540 | |
| 2541 | 2541 | |
@@ -2576,25 +2576,25 @@ discard block |
||
| 2576 | 2576 | */ |
| 2577 | 2577 | function balise_BOUTON_ACTION_dist($p) { |
| 2578 | 2578 | |
| 2579 | - $args = []; |
|
| 2580 | - for ($k = 1; $k <= 6; $k++) { |
|
| 2581 | - $_a = interprete_argument_balise($k, $p); |
|
| 2582 | - if (!$_a) { |
|
| 2583 | - $_a = "''"; |
|
| 2584 | - } |
|
| 2585 | - $args[] = $_a; |
|
| 2586 | - } |
|
| 2587 | - // supprimer les args vides |
|
| 2588 | - while (end($args) == "''" and count($args) > 2) { |
|
| 2589 | - array_pop($args); |
|
| 2590 | - } |
|
| 2591 | - $args = implode(',', $args); |
|
| 2579 | + $args = []; |
|
| 2580 | + for ($k = 1; $k <= 6; $k++) { |
|
| 2581 | + $_a = interprete_argument_balise($k, $p); |
|
| 2582 | + if (!$_a) { |
|
| 2583 | + $_a = "''"; |
|
| 2584 | + } |
|
| 2585 | + $args[] = $_a; |
|
| 2586 | + } |
|
| 2587 | + // supprimer les args vides |
|
| 2588 | + while (end($args) == "''" and count($args) > 2) { |
|
| 2589 | + array_pop($args); |
|
| 2590 | + } |
|
| 2591 | + $args = implode(',', $args); |
|
| 2592 | 2592 | |
| 2593 | - $bouton_action = chercher_filtre('bouton_action'); |
|
| 2594 | - $p->code = "$bouton_action($args)"; |
|
| 2595 | - $p->interdire_scripts = false; |
|
| 2593 | + $bouton_action = chercher_filtre('bouton_action'); |
|
| 2594 | + $p->code = "$bouton_action($args)"; |
|
| 2595 | + $p->interdire_scripts = false; |
|
| 2596 | 2596 | |
| 2597 | - return $p; |
|
| 2597 | + return $p; |
|
| 2598 | 2598 | } |
| 2599 | 2599 | |
| 2600 | 2600 | |
@@ -2613,10 +2613,10 @@ discard block |
||
| 2613 | 2613 | * Pile complétée par le code à générer |
| 2614 | 2614 | */ |
| 2615 | 2615 | function balise_SLOGAN_SITE_SPIP_dist($p) { |
| 2616 | - $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 2616 | + $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 2617 | 2617 | |
| 2618 | - #$p->interdire_scripts = true; |
|
| 2619 | - return $p; |
|
| 2618 | + #$p->interdire_scripts = true; |
|
| 2619 | + return $p; |
|
| 2620 | 2620 | } |
| 2621 | 2621 | |
| 2622 | 2622 | |
@@ -2640,10 +2640,10 @@ discard block |
||
| 2640 | 2640 | * Pile complétée par le code à générer |
| 2641 | 2641 | */ |
| 2642 | 2642 | function balise_HTML5_dist($p) { |
| 2643 | - $p->code = html5_permis() ? "' '" : "''"; |
|
| 2644 | - $p->interdire_scripts = false; |
|
| 2643 | + $p->code = html5_permis() ? "' '" : "''"; |
|
| 2644 | + $p->interdire_scripts = false; |
|
| 2645 | 2645 | |
| 2646 | - return $p; |
|
| 2646 | + return $p; |
|
| 2647 | 2647 | } |
| 2648 | 2648 | |
| 2649 | 2649 | |
@@ -2669,58 +2669,58 @@ discard block |
||
| 2669 | 2669 | * Pile complétée par le code à générer |
| 2670 | 2670 | */ |
| 2671 | 2671 | function balise_TRI_dist($p, $liste = 'true') { |
| 2672 | - $b = index_boucle_mere($p); |
|
| 2673 | - // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 2674 | - if ($b === '') { |
|
| 2675 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 2676 | - erreur_squelette($msg, $p); |
|
| 2677 | - $p->code = "''"; |
|
| 2672 | + $b = index_boucle_mere($p); |
|
| 2673 | + // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 2674 | + if ($b === '') { |
|
| 2675 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 2676 | + erreur_squelette($msg, $p); |
|
| 2677 | + $p->code = "''"; |
|
| 2678 | 2678 | |
| 2679 | - return $p; |
|
| 2680 | - } |
|
| 2681 | - $boucle = $p->boucles[$b]; |
|
| 2679 | + return $p; |
|
| 2680 | + } |
|
| 2681 | + $boucle = $p->boucles[$b]; |
|
| 2682 | 2682 | |
| 2683 | - // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 2684 | - // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 2685 | - if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 2686 | - $msg = ['zbug_champ_hors_critere', [ |
|
| 2687 | - 'champ' => zbug_presenter_champ($p), |
|
| 2688 | - 'critere' => 'tri' |
|
| 2689 | - ]]; |
|
| 2690 | - erreur_squelette($msg, $p); |
|
| 2691 | - $p->code = "''"; |
|
| 2683 | + // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 2684 | + // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 2685 | + if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 2686 | + $msg = ['zbug_champ_hors_critere', [ |
|
| 2687 | + 'champ' => zbug_presenter_champ($p), |
|
| 2688 | + 'critere' => 'tri' |
|
| 2689 | + ]]; |
|
| 2690 | + erreur_squelette($msg, $p); |
|
| 2691 | + $p->code = "''"; |
|
| 2692 | 2692 | |
| 2693 | - return $p; |
|
| 2694 | - } |
|
| 2693 | + return $p; |
|
| 2694 | + } |
|
| 2695 | 2695 | |
| 2696 | - // Différentes infos relatives au tri présentes dans les modificateurs |
|
| 2697 | - $_tri_nom = $boucle->modificateur['tri_nom'] ; // nom du paramètre définissant le tri |
|
| 2698 | - $_tri_champ = $boucle->modificateur['tri_champ']; // champ actuel utilisé le tri |
|
| 2699 | - $_tri_sens = $boucle->modificateur['tri_sens']; // sens de tri actuel |
|
| 2700 | - $_tri_liste_sens_defaut = $boucle->modificateur['tri_liste_sens_defaut']; // sens par défaut pour chaque champ |
|
| 2696 | + // Différentes infos relatives au tri présentes dans les modificateurs |
|
| 2697 | + $_tri_nom = $boucle->modificateur['tri_nom'] ; // nom du paramètre définissant le tri |
|
| 2698 | + $_tri_champ = $boucle->modificateur['tri_champ']; // champ actuel utilisé le tri |
|
| 2699 | + $_tri_sens = $boucle->modificateur['tri_sens']; // sens de tri actuel |
|
| 2700 | + $_tri_liste_sens_defaut = $boucle->modificateur['tri_liste_sens_defaut']; // sens par défaut pour chaque champ |
|
| 2701 | 2701 | |
| 2702 | - $_champ_ou_sens = interprete_argument_balise(1, $p); |
|
| 2703 | - // si pas de champ, renvoyer le critère de tri actuel |
|
| 2704 | - if (!$_champ_ou_sens) { |
|
| 2705 | - $p->code = $_tri_champ; |
|
| 2702 | + $_champ_ou_sens = interprete_argument_balise(1, $p); |
|
| 2703 | + // si pas de champ, renvoyer le critère de tri actuel |
|
| 2704 | + if (!$_champ_ou_sens) { |
|
| 2705 | + $p->code = $_tri_champ; |
|
| 2706 | 2706 | |
| 2707 | - return $p; |
|
| 2708 | - } |
|
| 2709 | - // forcer la jointure si besoin, et si le champ est statique |
|
| 2710 | - if (preg_match(",^'([\w.]+)'$,i", $_champ_ou_sens, $m)) { |
|
| 2711 | - index_pile($b, $m[1], $p->boucles, '', null, true, false); |
|
| 2712 | - } |
|
| 2707 | + return $p; |
|
| 2708 | + } |
|
| 2709 | + // forcer la jointure si besoin, et si le champ est statique |
|
| 2710 | + if (preg_match(",^'([\w.]+)'$,i", $_champ_ou_sens, $m)) { |
|
| 2711 | + index_pile($b, $m[1], $p->boucles, '', null, true, false); |
|
| 2712 | + } |
|
| 2713 | 2713 | |
| 2714 | - $_libelle = interprete_argument_balise(2, $p); |
|
| 2715 | - $_libelle = $_libelle ?: $_champ_ou_sens; |
|
| 2714 | + $_libelle = interprete_argument_balise(2, $p); |
|
| 2715 | + $_libelle = $_libelle ?: $_champ_ou_sens; |
|
| 2716 | 2716 | |
| 2717 | - $_class = interprete_argument_balise(3, $p) ?? "''"; |
|
| 2717 | + $_class = interprete_argument_balise(3, $p) ?? "''"; |
|
| 2718 | 2718 | |
| 2719 | - $p->code = "calculer_balise_tri($_champ_ou_sens, $_libelle, $_class, $_tri_nom, $_tri_champ, $_tri_sens, $_tri_liste_sens_defaut)"; |
|
| 2719 | + $p->code = "calculer_balise_tri($_champ_ou_sens, $_libelle, $_class, $_tri_nom, $_tri_champ, $_tri_sens, $_tri_liste_sens_defaut)"; |
|
| 2720 | 2720 | |
| 2721 | - $p->interdire_scripts = false; |
|
| 2721 | + $p->interdire_scripts = false; |
|
| 2722 | 2722 | |
| 2723 | - return $p; |
|
| 2723 | + return $p; |
|
| 2724 | 2724 | } |
| 2725 | 2725 | |
| 2726 | 2726 | |
@@ -2741,21 +2741,21 @@ discard block |
||
| 2741 | 2741 | * Pile complétée par le code à générer |
| 2742 | 2742 | */ |
| 2743 | 2743 | function balise_SAUTER_dist($p) { |
| 2744 | - $id_boucle = $p->id_boucle; |
|
| 2744 | + $id_boucle = $p->id_boucle; |
|
| 2745 | 2745 | |
| 2746 | - if (empty($p->boucles[$id_boucle])) { |
|
| 2747 | - $msg = ['zbug_champ_hors_boucle', ['champ' => '#SAUTER']]; |
|
| 2748 | - erreur_squelette($msg, $p); |
|
| 2749 | - } else { |
|
| 2750 | - $_saut = interprete_argument_balise(1, $p); |
|
| 2751 | - $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 2752 | - $_total = "(\$Numrows['$id_boucle']['total'] ?? null)"; |
|
| 2746 | + if (empty($p->boucles[$id_boucle])) { |
|
| 2747 | + $msg = ['zbug_champ_hors_boucle', ['champ' => '#SAUTER']]; |
|
| 2748 | + erreur_squelette($msg, $p); |
|
| 2749 | + } else { |
|
| 2750 | + $_saut = interprete_argument_balise(1, $p); |
|
| 2751 | + $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 2752 | + $_total = "(\$Numrows['$id_boucle']['total'] ?? null)"; |
|
| 2753 | 2753 | |
| 2754 | - $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 2755 | - } |
|
| 2756 | - $p->interdire_scripts = false; |
|
| 2754 | + $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 2755 | + } |
|
| 2756 | + $p->interdire_scripts = false; |
|
| 2757 | 2757 | |
| 2758 | - return $p; |
|
| 2758 | + return $p; |
|
| 2759 | 2759 | } |
| 2760 | 2760 | |
| 2761 | 2761 | |
@@ -2777,22 +2777,22 @@ discard block |
||
| 2777 | 2777 | * Pile complétée par le code à générer |
| 2778 | 2778 | */ |
| 2779 | 2779 | function balise_PUBLIE_dist($p) { |
| 2780 | - if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 2781 | - $_type = _q($p->type_requete); |
|
| 2782 | - $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 2783 | - } else { |
|
| 2784 | - $_id = interprete_argument_balise(2, $p); |
|
| 2785 | - } |
|
| 2780 | + if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 2781 | + $_type = _q($p->type_requete); |
|
| 2782 | + $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 2783 | + } else { |
|
| 2784 | + $_id = interprete_argument_balise(2, $p); |
|
| 2785 | + } |
|
| 2786 | 2786 | |
| 2787 | - $connect = ''; |
|
| 2788 | - if (isset($p->boucles[$p->id_boucle])) { |
|
| 2789 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2790 | - } |
|
| 2787 | + $connect = ''; |
|
| 2788 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 2789 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2790 | + } |
|
| 2791 | 2791 | |
| 2792 | - $p->code = '(objet_test_si_publie(' . $_type . ',intval(' . $_id . '),' . _q($connect) . ")?' ':'')"; |
|
| 2793 | - $p->interdire_scripts = false; |
|
| 2792 | + $p->code = '(objet_test_si_publie(' . $_type . ',intval(' . $_id . '),' . _q($connect) . ")?' ':'')"; |
|
| 2793 | + $p->interdire_scripts = false; |
|
| 2794 | 2794 | |
| 2795 | - return $p; |
|
| 2795 | + return $p; |
|
| 2796 | 2796 | } |
| 2797 | 2797 | |
| 2798 | 2798 | /** |
@@ -2821,12 +2821,12 @@ discard block |
||
| 2821 | 2821 | * Pile complétée par le code à générer |
| 2822 | 2822 | */ |
| 2823 | 2823 | function balise_PRODUIRE_dist($p) { |
| 2824 | - $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 2825 | - $p = $balise_inclure($p); |
|
| 2824 | + $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 2825 | + $p = $balise_inclure($p); |
|
| 2826 | 2826 | |
| 2827 | - $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 2827 | + $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 2828 | 2828 | |
| 2829 | - return $p; |
|
| 2829 | + return $p; |
|
| 2830 | 2830 | } |
| 2831 | 2831 | |
| 2832 | 2832 | /** |
@@ -2845,13 +2845,13 @@ discard block |
||
| 2845 | 2845 | * Pile complétée par le code à générer |
| 2846 | 2846 | */ |
| 2847 | 2847 | function balise_LARGEUR_ECRAN_dist($p) { |
| 2848 | - $_class = interprete_argument_balise(1, $p); |
|
| 2849 | - if (!$_class) { |
|
| 2850 | - $_class = 'null'; |
|
| 2851 | - } |
|
| 2852 | - $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 2848 | + $_class = interprete_argument_balise(1, $p); |
|
| 2849 | + if (!$_class) { |
|
| 2850 | + $_class = 'null'; |
|
| 2851 | + } |
|
| 2852 | + $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 2853 | 2853 | |
| 2854 | - return $p; |
|
| 2854 | + return $p; |
|
| 2855 | 2855 | } |
| 2856 | 2856 | |
| 2857 | 2857 | |
@@ -2867,14 +2867,14 @@ discard block |
||
| 2867 | 2867 | * Pile complétée par le code à générer |
| 2868 | 2868 | **/ |
| 2869 | 2869 | function balise_CONST_dist($p) { |
| 2870 | - $_const = interprete_argument_balise(1, $p); |
|
| 2871 | - if (!strlen($_const ?? '')) { |
|
| 2872 | - $p->code = "''"; |
|
| 2873 | - } |
|
| 2874 | - else { |
|
| 2875 | - $p->code = "(defined($_const)?constant($_const):'')"; |
|
| 2876 | - } |
|
| 2877 | - $p->interdire_scripts = false; |
|
| 2878 | - |
|
| 2879 | - return $p; |
|
| 2870 | + $_const = interprete_argument_balise(1, $p); |
|
| 2871 | + if (!strlen($_const ?? '')) { |
|
| 2872 | + $p->code = "''"; |
|
| 2873 | + } |
|
| 2874 | + else { |
|
| 2875 | + $p->code = "(defined($_const)?constant($_const):'')"; |
|
| 2876 | + } |
|
| 2877 | + $p->interdire_scripts = false; |
|
| 2878 | + |
|
| 2879 | + return $p; |
|
| 2880 | 2880 | } |
@@ -267,8 +267,7 @@ discard block |
||
| 267 | 267 | if ($id === '*') { |
| 268 | 268 | unset($GLOBALS['autoriser_exception'][$faire][$type]); |
| 269 | 269 | unset($autorisation[$faire][$type]); |
| 270 | - } |
|
| 271 | - else { |
|
| 270 | + } else { |
|
| 272 | 271 | unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
| 273 | 272 | unset($autorisation[$faire][$type][$id]); |
| 274 | 273 | } |
@@ -652,8 +651,7 @@ discard block |
||
| 652 | 651 | function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 653 | 652 | if (!empty($opt['id_parent'])) { |
| 654 | 653 | return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
| 655 | - } |
|
| 656 | - else { |
|
| 654 | + } else { |
|
| 657 | 655 | return autoriser('defaut', null, 0, $qui, $opt); |
| 658 | 656 | } |
| 659 | 657 | } |
@@ -814,8 +812,7 @@ discard block |
||
| 814 | 812 | if (!empty($opt['id_parent'])) { |
| 815 | 813 | // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
| 816 | 814 | return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
| 817 | - } |
|
| 818 | - else { |
|
| 815 | + } else { |
|
| 819 | 816 | return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
| 820 | 817 | } |
| 821 | 818 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | // mais apres la fonction autoriser() |
| 121 | 121 | if ($f = find_in_path('mes_fonctions.php')) { |
| 122 | 122 | global $dossier_squelettes; |
| 123 | - include_once(_ROOT_CWD . $f); |
|
| 123 | + include_once(_ROOT_CWD.$f); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | $qui = $GLOBALS['visiteur_session'] ?: []; |
| 163 | 163 | $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
| 164 | 164 | } elseif (is_numeric($qui)) { |
| 165 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 165 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$qui); |
|
| 166 | 166 | if (!$qui) { |
| 167 | 167 | return false; |
| 168 | 168 | } |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | spip_log( |
| 178 | - "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 179 | - 'autoriser' . _LOG_DEBUG |
|
| 178 | + "autoriser $faire $type $id (".($qui['nom'] ?? '').') ?', |
|
| 179 | + 'autoriser'._LOG_DEBUG |
|
| 180 | 180 | ); |
| 181 | 181 | |
| 182 | 182 | // passer par objet_type pour avoir les alias |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
| 193 | 193 | or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
| 194 | 194 | ) { |
| 195 | - spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 195 | + spip_log("autoriser ($faire, $type, $id, ".($qui['nom'] ?? '').') : OK Exception', 'autoriser'._LOG_DEBUG); |
|
| 196 | 196 | return true; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -201,18 +201,18 @@ discard block |
||
| 201 | 201 | // autoriser_faire[_dist], autoriser_defaut[_dist] |
| 202 | 202 | $fonctions = $type |
| 203 | 203 | ? [ |
| 204 | - 'autoriser_' . $type . '_' . $faire, |
|
| 205 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 206 | - 'autoriser_' . $type, |
|
| 207 | - 'autoriser_' . $type . '_dist', |
|
| 208 | - 'autoriser_' . $faire, |
|
| 209 | - 'autoriser_' . $faire . '_dist', |
|
| 204 | + 'autoriser_'.$type.'_'.$faire, |
|
| 205 | + 'autoriser_'.$type.'_'.$faire.'_dist', |
|
| 206 | + 'autoriser_'.$type, |
|
| 207 | + 'autoriser_'.$type.'_dist', |
|
| 208 | + 'autoriser_'.$faire, |
|
| 209 | + 'autoriser_'.$faire.'_dist', |
|
| 210 | 210 | 'autoriser_defaut', |
| 211 | 211 | 'autoriser_defaut_dist' |
| 212 | 212 | ] |
| 213 | 213 | : [ |
| 214 | - 'autoriser_' . $faire, |
|
| 215 | - 'autoriser_' . $faire . '_dist', |
|
| 214 | + 'autoriser_'.$faire, |
|
| 215 | + 'autoriser_'.$faire.'_dist', |
|
| 216 | 216 | 'autoriser_defaut', |
| 217 | 217 | 'autoriser_defaut_dist' |
| 218 | 218 | ]; |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | spip_log( |
| 228 | - "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 229 | - 'autoriser' . _LOG_DEBUG |
|
| 228 | + "$f($faire, $type, $id, ".($qui['nom'] ?? '').') : '.($a ? 'OK' : 'niet'), |
|
| 229 | + 'autoriser'._LOG_DEBUG |
|
| 230 | 230 | ); |
| 231 | 231 | |
| 232 | 232 | return $a; |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 376 | 376 | |
| 377 | 377 | // Le visiteur a-t-il un statut prevu par la config ? |
| 378 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 378 | + if (strpos($GLOBALS['meta']['preview'], ','.$qui['statut'].',') !== false) { |
|
| 379 | 379 | return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
| 380 | 380 | } |
| 381 | 381 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | } // pas de champ passe a la demande => NIET |
| 434 | 434 | $previsu = explode(',', $c['previsu']); |
| 435 | 435 | // regarder si ce statut est autorise pour l'auteur |
| 436 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 436 | + if (in_array($opt[$champ].'/auteur', $previsu)) { |
|
| 437 | 437 | // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
| 438 | 438 | // sinon l’auteur en session |
| 439 | 439 | include_spip('inc/securiser_action'); |
@@ -447,12 +447,12 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | if (!$id_auteur) { |
| 449 | 449 | return false; |
| 450 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 450 | + } elseif (autoriser('previsualiser'.$opt[$champ], $type, 0, $id_auteur)) { |
|
| 451 | 451 | // dans ce cas (admin en general), pas de filtrage sur ce statut |
| 452 | 452 | } elseif ( |
| 453 | 453 | !sql_countsel( |
| 454 | 454 | 'spip_auteurs_liens', |
| 455 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 455 | + 'id_auteur='.intval($id_auteur).' AND objet='.sql_quote($type).' AND id_objet='.intval($id) |
|
| 456 | 456 | ) |
| 457 | 457 | ) { |
| 458 | 458 | return false; |
@@ -497,16 +497,16 @@ discard block |
||
| 497 | 497 | // multilinguisme par secteur et objet rattaché à une rubrique |
| 498 | 498 | $primary = id_table_objet($type); |
| 499 | 499 | if ($table != 'spip_rubriques') { |
| 500 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 500 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=".intval($id)); |
|
| 501 | 501 | } else { |
| 502 | 502 | $id_rubrique = $id; |
| 503 | 503 | } |
| 504 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 504 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 505 | 505 | if (!$id_secteur > 0) { |
| 506 | 506 | $id_secteur = $id_rubrique; |
| 507 | 507 | } |
| 508 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 509 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 508 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_secteur)); |
|
| 509 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=".intval($id)); |
|
| 510 | 510 | if ($langue_secteur != $langue_objet) { |
| 511 | 511 | // configuration incohérente, on laisse l'utilisateur corriger la situation |
| 512 | 512 | return true; |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
| 515 | 515 | return false; |
| 516 | 516 | } else { |
| 517 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 517 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id)); |
|
| 518 | 518 | if ($id_parent != 0) { |
| 519 | 519 | // sous-rubriques : pas de choix de langue |
| 520 | 520 | return false; |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | |
| 567 | 567 | if (!isset($opt['statut'])) { |
| 568 | 568 | if (isset($desc['field']['statut'])) { |
| 569 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 569 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type).'='.intval($id)); |
|
| 570 | 570 | } else { |
| 571 | 571 | $statut = 'publie'; |
| 572 | 572 | } // pas de statut => publie |
@@ -740,11 +740,11 @@ discard block |
||
| 740 | 740 | return false; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 743 | + if (sql_countsel('spip_rubriques', 'id_parent='.intval($id))) { |
|
| 744 | 744 | return false; |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 747 | + if (sql_countsel('spip_articles', 'id_rubrique='.intval($id)." AND (statut<>'poubelle')")) { |
|
| 748 | 748 | return false; |
| 749 | 749 | } |
| 750 | 750 | |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | if (!$id) { |
| 782 | 782 | return false; |
| 783 | 783 | } |
| 784 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 784 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article='.sql_quote($id)); |
|
| 785 | 785 | |
| 786 | 786 | return |
| 787 | 787 | $r |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
| 793 | 793 | and in_array($qui['statut'], ['0minirezo', '1comite']) |
| 794 | 794 | and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
| 795 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 795 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur']) |
|
| 796 | 796 | ) |
| 797 | 797 | ); |
| 798 | 798 | } |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | if (!$id) { |
| 851 | 851 | return false; |
| 852 | 852 | } |
| 853 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 853 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article='.intval($id)); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | return |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | or |
| 862 | 862 | ($id |
| 863 | 863 | and $qui['id_auteur'] |
| 864 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 864 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur'])); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | |
@@ -882,8 +882,8 @@ discard block |
||
| 882 | 882 | function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 883 | 883 | # securite, mais on aurait pas du arriver ici ! |
| 884 | 884 | if ( |
| 885 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 886 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 885 | + function_exists($f = 'autoriser_'.$type.'_voir') |
|
| 886 | + or function_exists($f = 'autoriser_'.$type.'_voir_dist') |
|
| 887 | 887 | ) { |
| 888 | 888 | return $f($faire, $type, $id, $qui, $opt); |
| 889 | 889 | } |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | $n = sql_fetsel( |
| 1015 | 1015 | 'A.id_article', |
| 1016 | 1016 | 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
| 1017 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1017 | + "A.statut='publie' AND L.id_auteur=".sql_quote($id) |
|
| 1018 | 1018 | ); |
| 1019 | 1019 | |
| 1020 | 1020 | return $n ? true : false; |
@@ -1226,7 +1226,7 @@ discard block |
||
| 1226 | 1226 | and $r = sql_allfetsel( |
| 1227 | 1227 | 'id_objet', |
| 1228 | 1228 | 'spip_auteurs_liens', |
| 1229 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1229 | + 'id_auteur='.intval($id_auteur)." AND objet='rubrique' AND id_objet!=0" |
|
| 1230 | 1230 | ) |
| 1231 | 1231 | and is_countable($r) ? count($r) : 0 |
| 1232 | 1232 | ) { |
@@ -1911,8 +1911,8 @@ discard block |
||
| 1911 | 1911 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1912 | 1912 | $objet = objet_type($objet); |
| 1913 | 1913 | $where = [ |
| 1914 | - 'objet=' . sql_quote($objet), |
|
| 1915 | - 'id_objet=' . intval($id_objet) |
|
| 1914 | + 'objet='.sql_quote($objet), |
|
| 1915 | + 'id_objet='.intval($id_objet) |
|
| 1916 | 1916 | ]; |
| 1917 | 1917 | if (!empty($cond)) { |
| 1918 | 1918 | if (is_array($cond)) { |
@@ -1947,7 +1947,7 @@ discard block |
||
| 1947 | 1947 | return sql_allfetsel( |
| 1948 | 1948 | 'id_auteur', |
| 1949 | 1949 | 'spip_auteurs_liens', |
| 1950 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1950 | + "objet='article' AND id_objet=".intval($id_article).($cond ? " AND $cond" : '') |
|
| 1951 | 1951 | ); |
| 1952 | 1952 | } |
| 1953 | 1953 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Autorisations |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -38,89 +38,89 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | if (!function_exists('autoriser')) { |
| 41 | - /** |
|
| 42 | - * Autoriser une action |
|
| 43 | - * |
|
| 44 | - * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | - * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | - * les autorisations. |
|
| 47 | - * |
|
| 48 | - * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | - * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | - * dans cet ordre : |
|
| 51 | - * |
|
| 52 | - * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | - * - autoriser_{type}, sinon avec _dist |
|
| 54 | - * - autoriser_{faire}, sinon avec _dist |
|
| 55 | - * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | - * |
|
| 57 | - * Seul le premier argument est obligatoire. |
|
| 58 | - * |
|
| 59 | - * @note |
|
| 60 | - * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | - * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | - * cette valeur. |
|
| 63 | - * |
|
| 64 | - * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | - * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | - * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | - * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | - * |
|
| 69 | - * @note |
|
| 70 | - * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | - * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | - * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | - * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | - * quel serait le type, quel serait l'action ? |
|
| 75 | - * |
|
| 76 | - * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | - * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | - * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | - * |
|
| 80 | - * @api |
|
| 81 | - * @see autoriser_dist() |
|
| 82 | - * @see objet_type() |
|
| 83 | - * |
|
| 84 | - * @param string $faire |
|
| 85 | - * une action ('modifier', 'publier'...) |
|
| 86 | - * @param string|null $type |
|
| 87 | - * Type d’objet ou élément sur lequel appliquer l’action. |
|
| 88 | - * - null: indifférent à tout type d’élément ou objet éditorial |
|
| 89 | - * - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée) |
|
| 90 | - * - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()). |
|
| 91 | - * Les soulignés seront retirés (cf. la note). |
|
| 92 | - * @param string|int|null $id |
|
| 93 | - * id de l'objet ou élément sur lequel on veut agir, si pertinent. |
|
| 94 | - * - null: non utile pour l’autorisation |
|
| 95 | - * - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP) |
|
| 96 | - * - string: identifiant textuel |
|
| 97 | - * @param null|int|array $qui |
|
| 98 | - * - si null on prend alors visiteur_session |
|
| 99 | - * - un id_auteur (on regarde dans la base) |
|
| 100 | - * - un tableau auteur complet, y compris [restreint] |
|
| 101 | - * @param array $opt |
|
| 102 | - * options sous forme de tableau associatif |
|
| 103 | - * @return bool |
|
| 104 | - * true si la personne peut effectuer l'action |
|
| 105 | - */ |
|
| 106 | - function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
|
| 107 | - // Charger les fonctions d'autorisation supplementaires |
|
| 108 | - static $pipe; |
|
| 109 | - if (!isset($pipe)) { |
|
| 110 | - $pipe = 1; |
|
| 111 | - pipeline('autoriser'); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return autoriser_dist($faire, $type, $id, $qui, $opt); |
|
| 115 | - } |
|
| 41 | + /** |
|
| 42 | + * Autoriser une action |
|
| 43 | + * |
|
| 44 | + * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | + * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | + * les autorisations. |
|
| 47 | + * |
|
| 48 | + * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | + * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | + * dans cet ordre : |
|
| 51 | + * |
|
| 52 | + * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | + * - autoriser_{type}, sinon avec _dist |
|
| 54 | + * - autoriser_{faire}, sinon avec _dist |
|
| 55 | + * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | + * |
|
| 57 | + * Seul le premier argument est obligatoire. |
|
| 58 | + * |
|
| 59 | + * @note |
|
| 60 | + * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | + * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | + * cette valeur. |
|
| 63 | + * |
|
| 64 | + * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | + * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | + * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | + * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | + * |
|
| 69 | + * @note |
|
| 70 | + * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | + * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | + * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | + * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | + * quel serait le type, quel serait l'action ? |
|
| 75 | + * |
|
| 76 | + * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | + * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | + * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | + * |
|
| 80 | + * @api |
|
| 81 | + * @see autoriser_dist() |
|
| 82 | + * @see objet_type() |
|
| 83 | + * |
|
| 84 | + * @param string $faire |
|
| 85 | + * une action ('modifier', 'publier'...) |
|
| 86 | + * @param string|null $type |
|
| 87 | + * Type d’objet ou élément sur lequel appliquer l’action. |
|
| 88 | + * - null: indifférent à tout type d’élément ou objet éditorial |
|
| 89 | + * - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée) |
|
| 90 | + * - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()). |
|
| 91 | + * Les soulignés seront retirés (cf. la note). |
|
| 92 | + * @param string|int|null $id |
|
| 93 | + * id de l'objet ou élément sur lequel on veut agir, si pertinent. |
|
| 94 | + * - null: non utile pour l’autorisation |
|
| 95 | + * - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP) |
|
| 96 | + * - string: identifiant textuel |
|
| 97 | + * @param null|int|array $qui |
|
| 98 | + * - si null on prend alors visiteur_session |
|
| 99 | + * - un id_auteur (on regarde dans la base) |
|
| 100 | + * - un tableau auteur complet, y compris [restreint] |
|
| 101 | + * @param array $opt |
|
| 102 | + * options sous forme de tableau associatif |
|
| 103 | + * @return bool |
|
| 104 | + * true si la personne peut effectuer l'action |
|
| 105 | + */ |
|
| 106 | + function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
|
| 107 | + // Charger les fonctions d'autorisation supplementaires |
|
| 108 | + static $pipe; |
|
| 109 | + if (!isset($pipe)) { |
|
| 110 | + $pipe = 1; |
|
| 111 | + pipeline('autoriser'); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return autoriser_dist($faire, $type, $id, $qui, $opt); |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger |
| 120 | 120 | // mais apres la fonction autoriser() |
| 121 | 121 | if ($f = find_in_path('mes_fonctions.php')) { |
| 122 | - global $dossier_squelettes; |
|
| 123 | - include_once(_ROOT_CWD . $f); |
|
| 122 | + global $dossier_squelettes; |
|
| 123 | + include_once(_ROOT_CWD . $f); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -151,85 +151,85 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function autoriser_dist(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool { |
| 153 | 153 | |
| 154 | - if ($type === null) { |
|
| 155 | - $type = ''; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - // Qui ? visiteur_session ? |
|
| 159 | - // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 160 | - if ($qui === null or $qui === '') { |
|
| 161 | - $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 162 | - $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 163 | - } elseif (is_numeric($qui)) { |
|
| 164 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 165 | - if (!$qui) { |
|
| 166 | - return false; |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - // Admins restreints, on construit ici (pas generique mais...) |
|
| 171 | - // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 172 | - if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 173 | - $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - spip_log( |
|
| 177 | - "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 178 | - 'autoriser' . _LOG_DEBUG |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - // passer par objet_type pour avoir les alias |
|
| 182 | - // sauf si _ est le premier caractère. |
|
| 183 | - if ($type and $type[0] !== '_') { |
|
| 184 | - $type = objet_type($type, false); |
|
| 185 | - } |
|
| 186 | - // et supprimer les _ |
|
| 187 | - $type = str_replace('_', '', (string) $type); |
|
| 188 | - |
|
| 189 | - // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 190 | - if ( |
|
| 191 | - (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 192 | - or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 193 | - ) { |
|
| 194 | - spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 195 | - return true; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // Chercher une fonction d'autorisation |
|
| 199 | - // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 200 | - // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 201 | - $fonctions = $type |
|
| 202 | - ? [ |
|
| 203 | - 'autoriser_' . $type . '_' . $faire, |
|
| 204 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 205 | - 'autoriser_' . $type, |
|
| 206 | - 'autoriser_' . $type . '_dist', |
|
| 207 | - 'autoriser_' . $faire, |
|
| 208 | - 'autoriser_' . $faire . '_dist', |
|
| 209 | - 'autoriser_defaut', |
|
| 210 | - 'autoriser_defaut_dist' |
|
| 211 | - ] |
|
| 212 | - : [ |
|
| 213 | - 'autoriser_' . $faire, |
|
| 214 | - 'autoriser_' . $faire . '_dist', |
|
| 215 | - 'autoriser_defaut', |
|
| 216 | - 'autoriser_defaut_dist' |
|
| 217 | - ]; |
|
| 218 | - |
|
| 219 | - $a = false; |
|
| 220 | - foreach ($fonctions as $f) { |
|
| 221 | - if (function_exists($f)) { |
|
| 222 | - $a = $f($faire, $type, $id, $qui, $opt); |
|
| 223 | - break; |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - spip_log( |
|
| 228 | - "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 229 | - 'autoriser' . _LOG_DEBUG |
|
| 230 | - ); |
|
| 231 | - |
|
| 232 | - return $a; |
|
| 154 | + if ($type === null) { |
|
| 155 | + $type = ''; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + // Qui ? visiteur_session ? |
|
| 159 | + // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 160 | + if ($qui === null or $qui === '') { |
|
| 161 | + $qui = $GLOBALS['visiteur_session'] ?: []; |
|
| 162 | + $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 163 | + } elseif (is_numeric($qui)) { |
|
| 164 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 165 | + if (!$qui) { |
|
| 166 | + return false; |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + // Admins restreints, on construit ici (pas generique mais...) |
|
| 171 | + // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 172 | + if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 173 | + $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + spip_log( |
|
| 177 | + "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?', |
|
| 178 | + 'autoriser' . _LOG_DEBUG |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + // passer par objet_type pour avoir les alias |
|
| 182 | + // sauf si _ est le premier caractère. |
|
| 183 | + if ($type and $type[0] !== '_') { |
|
| 184 | + $type = objet_type($type, false); |
|
| 185 | + } |
|
| 186 | + // et supprimer les _ |
|
| 187 | + $type = str_replace('_', '', (string) $type); |
|
| 188 | + |
|
| 189 | + // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 190 | + if ( |
|
| 191 | + (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 192 | + or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 193 | + ) { |
|
| 194 | + spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 195 | + return true; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // Chercher une fonction d'autorisation |
|
| 199 | + // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 200 | + // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 201 | + $fonctions = $type |
|
| 202 | + ? [ |
|
| 203 | + 'autoriser_' . $type . '_' . $faire, |
|
| 204 | + 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 205 | + 'autoriser_' . $type, |
|
| 206 | + 'autoriser_' . $type . '_dist', |
|
| 207 | + 'autoriser_' . $faire, |
|
| 208 | + 'autoriser_' . $faire . '_dist', |
|
| 209 | + 'autoriser_defaut', |
|
| 210 | + 'autoriser_defaut_dist' |
|
| 211 | + ] |
|
| 212 | + : [ |
|
| 213 | + 'autoriser_' . $faire, |
|
| 214 | + 'autoriser_' . $faire . '_dist', |
|
| 215 | + 'autoriser_defaut', |
|
| 216 | + 'autoriser_defaut_dist' |
|
| 217 | + ]; |
|
| 218 | + |
|
| 219 | + $a = false; |
|
| 220 | + foreach ($fonctions as $f) { |
|
| 221 | + if (function_exists($f)) { |
|
| 222 | + $a = $f($faire, $type, $id, $qui, $opt); |
|
| 223 | + break; |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + spip_log( |
|
| 228 | + "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 229 | + 'autoriser' . _LOG_DEBUG |
|
| 230 | + ); |
|
| 231 | + |
|
| 232 | + return $a; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // une globale pour aller au plus vite dans la fonction generique ci dessus |
@@ -249,33 +249,33 @@ discard block |
||
| 249 | 249 | * @return bool |
| 250 | 250 | */ |
| 251 | 251 | function autoriser_exception(string $faire, ?string $type = '', $id = null, $autoriser = true): bool { |
| 252 | - // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 253 | - static $autorisation; |
|
| 254 | - // Tolérance avec certains appels |
|
| 255 | - if ($type === null) { |
|
| 256 | - $type = ''; |
|
| 257 | - } |
|
| 258 | - if ($id === null) { |
|
| 259 | - $id = 0; |
|
| 260 | - } |
|
| 261 | - if ($autoriser === 'verifier') { |
|
| 262 | - return isset($autorisation[$faire][$type][$id]); |
|
| 263 | - } |
|
| 264 | - if ($autoriser === true) { |
|
| 265 | - $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 266 | - } |
|
| 267 | - if ($autoriser === false) { |
|
| 268 | - if ($id === '*') { |
|
| 269 | - unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 270 | - unset($autorisation[$faire][$type]); |
|
| 271 | - } |
|
| 272 | - else { |
|
| 273 | - unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 274 | - unset($autorisation[$faire][$type][$id]); |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - return false; |
|
| 252 | + // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 253 | + static $autorisation; |
|
| 254 | + // Tolérance avec certains appels |
|
| 255 | + if ($type === null) { |
|
| 256 | + $type = ''; |
|
| 257 | + } |
|
| 258 | + if ($id === null) { |
|
| 259 | + $id = 0; |
|
| 260 | + } |
|
| 261 | + if ($autoriser === 'verifier') { |
|
| 262 | + return isset($autorisation[$faire][$type][$id]); |
|
| 263 | + } |
|
| 264 | + if ($autoriser === true) { |
|
| 265 | + $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 266 | + } |
|
| 267 | + if ($autoriser === false) { |
|
| 268 | + if ($id === '*') { |
|
| 269 | + unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 270 | + unset($autorisation[$faire][$type]); |
|
| 271 | + } |
|
| 272 | + else { |
|
| 273 | + unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 274 | + unset($autorisation[$faire][$type][$id]); |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + return false; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -294,9 +294,9 @@ discard block |
||
| 294 | 294 | * @return bool true s'il a le droit, false sinon |
| 295 | 295 | **/ |
| 296 | 296 | function autoriser_defaut_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 297 | - return |
|
| 298 | - $qui['statut'] === '0minirezo' |
|
| 299 | - and !$qui['restreint']; |
|
| 297 | + return |
|
| 298 | + $qui['statut'] === '0minirezo' |
|
| 299 | + and !$qui['restreint']; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | * @return bool true s'il a le droit, false sinon |
| 317 | 317 | */ |
| 318 | 318 | function autoriser_loger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 319 | - if ($qui['statut'] === '5poubelle') { |
|
| 320 | - return false; |
|
| 321 | - } |
|
| 322 | - return true; |
|
| 319 | + if ($qui['statut'] === '5poubelle') { |
|
| 320 | + return false; |
|
| 321 | + } |
|
| 322 | + return true; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @return bool true s'il a le droit, false sinon |
| 336 | 336 | **/ |
| 337 | 337 | function autoriser_ecrire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 338 | - return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 338 | + return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @return bool true s'il a le droit, false sinon |
| 355 | 355 | **/ |
| 356 | 356 | function autoriser_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 357 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 357 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -374,18 +374,18 @@ discard block |
||
| 374 | 374 | **/ |
| 375 | 375 | function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 376 | 376 | |
| 377 | - // Le visiteur a-t-il un statut prevu par la config ? |
|
| 378 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 379 | - return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 380 | - } |
|
| 377 | + // Le visiteur a-t-il un statut prevu par la config ? |
|
| 378 | + if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 379 | + return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - // A-t-on un token de prévisualisation valable ? |
|
| 383 | - include_spip('inc/securiser_action'); |
|
| 384 | - if (decrire_token_previsu()) { |
|
| 385 | - return true; |
|
| 386 | - } |
|
| 382 | + // A-t-on un token de prévisualisation valable ? |
|
| 383 | + include_spip('inc/securiser_action'); |
|
| 384 | + if (decrire_token_previsu()) { |
|
| 385 | + return true; |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - return false; |
|
| 388 | + return false; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -414,58 +414,58 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | function test_previsualiser_objet_champ(string $type = '', $id = null, array $qui = [], array $opt = []): bool { |
| 416 | 416 | |
| 417 | - // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 418 | - if (!$type) { |
|
| 419 | - return true; |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - include_spip('base/objets'); |
|
| 423 | - $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 424 | - if (isset($infos['statut'])) { |
|
| 425 | - foreach ($infos['statut'] as $c) { |
|
| 426 | - if (isset($c['publie'])) { |
|
| 427 | - if (!isset($c['previsu'])) { |
|
| 428 | - return false; |
|
| 429 | - } // pas de previsu definie => NIET |
|
| 430 | - $champ = $c['champ']; |
|
| 431 | - if (!isset($opt[$champ])) { |
|
| 432 | - return false; |
|
| 433 | - } // pas de champ passe a la demande => NIET |
|
| 434 | - $previsu = explode(',', $c['previsu']); |
|
| 435 | - // regarder si ce statut est autorise pour l'auteur |
|
| 436 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 437 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 438 | - // sinon l’auteur en session |
|
| 439 | - include_spip('inc/securiser_action'); |
|
| 440 | - if ($desc = decrire_token_previsu()) { |
|
| 441 | - $id_auteur = $desc['id_auteur']; |
|
| 442 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 443 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 444 | - } else { |
|
| 445 | - $id_auteur = null; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - if (!$id_auteur) { |
|
| 449 | - return false; |
|
| 450 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 451 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 452 | - } elseif ( |
|
| 453 | - !sql_countsel( |
|
| 454 | - 'spip_auteurs_liens', |
|
| 455 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 456 | - ) |
|
| 457 | - ) { |
|
| 458 | - return false; |
|
| 459 | - } // pas auteur de cet objet => NIET |
|
| 460 | - } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 461 | - // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 462 | - return false; |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - return true; |
|
| 417 | + // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 418 | + if (!$type) { |
|
| 419 | + return true; |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + include_spip('base/objets'); |
|
| 423 | + $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 424 | + if (isset($infos['statut'])) { |
|
| 425 | + foreach ($infos['statut'] as $c) { |
|
| 426 | + if (isset($c['publie'])) { |
|
| 427 | + if (!isset($c['previsu'])) { |
|
| 428 | + return false; |
|
| 429 | + } // pas de previsu definie => NIET |
|
| 430 | + $champ = $c['champ']; |
|
| 431 | + if (!isset($opt[$champ])) { |
|
| 432 | + return false; |
|
| 433 | + } // pas de champ passe a la demande => NIET |
|
| 434 | + $previsu = explode(',', $c['previsu']); |
|
| 435 | + // regarder si ce statut est autorise pour l'auteur |
|
| 436 | + if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 437 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 438 | + // sinon l’auteur en session |
|
| 439 | + include_spip('inc/securiser_action'); |
|
| 440 | + if ($desc = decrire_token_previsu()) { |
|
| 441 | + $id_auteur = $desc['id_auteur']; |
|
| 442 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 443 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 444 | + } else { |
|
| 445 | + $id_auteur = null; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + if (!$id_auteur) { |
|
| 449 | + return false; |
|
| 450 | + } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) { |
|
| 451 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 452 | + } elseif ( |
|
| 453 | + !sql_countsel( |
|
| 454 | + 'spip_auteurs_liens', |
|
| 455 | + 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 456 | + ) |
|
| 457 | + ) { |
|
| 458 | + return false; |
|
| 459 | + } // pas auteur de cet objet => NIET |
|
| 460 | + } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 461 | + // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 462 | + return false; |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + return true; |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -481,51 +481,51 @@ discard block |
||
| 481 | 481 | * @return bool true s'il a le droit, false sinon |
| 482 | 482 | **/ |
| 483 | 483 | function autoriser_changerlangue_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 484 | - $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 485 | - $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 486 | - $table = table_objet_sql($type); |
|
| 487 | - if ( |
|
| 488 | - in_array($table, $multi_objets) |
|
| 489 | - or in_array($table, $gerer_trad_objets) |
|
| 490 | - ) { // affichage du formulaire si la configuration l'accepte |
|
| 491 | - $multi_secteurs = lire_config('multi_secteurs'); |
|
| 492 | - $champs = objet_info($type, 'field'); |
|
| 493 | - if ( |
|
| 494 | - $multi_secteurs === 'oui' |
|
| 495 | - and array_key_exists('id_rubrique', $champs) |
|
| 496 | - ) { |
|
| 497 | - // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 498 | - $primary = id_table_objet($type); |
|
| 499 | - if ($table != 'spip_rubriques') { |
|
| 500 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 501 | - } else { |
|
| 502 | - $id_rubrique = $id; |
|
| 503 | - } |
|
| 504 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 505 | - if (!$id_secteur > 0) { |
|
| 506 | - $id_secteur = $id_rubrique; |
|
| 507 | - } |
|
| 508 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 509 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 510 | - if ($langue_secteur != $langue_objet) { |
|
| 511 | - // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 512 | - return true; |
|
| 513 | - } |
|
| 514 | - if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 515 | - return false; |
|
| 516 | - } else { |
|
| 517 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 518 | - if ($id_parent != 0) { |
|
| 519 | - // sous-rubriques : pas de choix de langue |
|
| 520 | - return false; |
|
| 521 | - } |
|
| 522 | - } |
|
| 523 | - } |
|
| 524 | - } else { |
|
| 525 | - return false; |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 484 | + $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 485 | + $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 486 | + $table = table_objet_sql($type); |
|
| 487 | + if ( |
|
| 488 | + in_array($table, $multi_objets) |
|
| 489 | + or in_array($table, $gerer_trad_objets) |
|
| 490 | + ) { // affichage du formulaire si la configuration l'accepte |
|
| 491 | + $multi_secteurs = lire_config('multi_secteurs'); |
|
| 492 | + $champs = objet_info($type, 'field'); |
|
| 493 | + if ( |
|
| 494 | + $multi_secteurs === 'oui' |
|
| 495 | + and array_key_exists('id_rubrique', $champs) |
|
| 496 | + ) { |
|
| 497 | + // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 498 | + $primary = id_table_objet($type); |
|
| 499 | + if ($table != 'spip_rubriques') { |
|
| 500 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 501 | + } else { |
|
| 502 | + $id_rubrique = $id; |
|
| 503 | + } |
|
| 504 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 505 | + if (!$id_secteur > 0) { |
|
| 506 | + $id_secteur = $id_rubrique; |
|
| 507 | + } |
|
| 508 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 509 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 510 | + if ($langue_secteur != $langue_objet) { |
|
| 511 | + // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 512 | + return true; |
|
| 513 | + } |
|
| 514 | + if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 515 | + return false; |
|
| 516 | + } else { |
|
| 517 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 518 | + if ($id_parent != 0) { |
|
| 519 | + // sous-rubriques : pas de choix de langue |
|
| 520 | + return false; |
|
| 521 | + } |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + } else { |
|
| 525 | + return false; |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | * @return bool true s'il a le droit, false sinon |
| 542 | 542 | **/ |
| 543 | 543 | function autoriser_changertraduction_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 544 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 544 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -557,41 +557,41 @@ discard block |
||
| 557 | 557 | * @return bool true s'il a le droit, false sinon |
| 558 | 558 | **/ |
| 559 | 559 | function autoriser_dater_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 560 | - $table = table_objet($type); |
|
| 561 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 562 | - $desc = $trouver_table($table); |
|
| 563 | - if (!$desc) { |
|
| 564 | - return false; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - if (!isset($opt['statut'])) { |
|
| 568 | - if (isset($desc['field']['statut'])) { |
|
| 569 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 570 | - } else { |
|
| 571 | - $statut = 'publie'; |
|
| 572 | - } // pas de statut => publie |
|
| 573 | - } else { |
|
| 574 | - $statut = $opt['statut']; |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - // Liste des statuts publiés pour cet objet |
|
| 578 | - if (isset($desc['statut'][0]['publie'])) { |
|
| 579 | - $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 580 | - } |
|
| 581 | - // Sinon en dur le statut "publie" |
|
| 582 | - else { |
|
| 583 | - $statuts_publies = ['publie']; |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - if ( |
|
| 587 | - in_array($statut, $statuts_publies) |
|
| 588 | - // Ou cas particulier géré en dur ici pour les articles |
|
| 589 | - or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 590 | - ) { |
|
| 591 | - return autoriser('modifier', $type, $id); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - return false; |
|
| 560 | + $table = table_objet($type); |
|
| 561 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 562 | + $desc = $trouver_table($table); |
|
| 563 | + if (!$desc) { |
|
| 564 | + return false; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + if (!isset($opt['statut'])) { |
|
| 568 | + if (isset($desc['field']['statut'])) { |
|
| 569 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 570 | + } else { |
|
| 571 | + $statut = 'publie'; |
|
| 572 | + } // pas de statut => publie |
|
| 573 | + } else { |
|
| 574 | + $statut = $opt['statut']; |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + // Liste des statuts publiés pour cet objet |
|
| 578 | + if (isset($desc['statut'][0]['publie'])) { |
|
| 579 | + $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 580 | + } |
|
| 581 | + // Sinon en dur le statut "publie" |
|
| 582 | + else { |
|
| 583 | + $statuts_publies = ['publie']; |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + if ( |
|
| 587 | + in_array($statut, $statuts_publies) |
|
| 588 | + // Ou cas particulier géré en dur ici pour les articles |
|
| 589 | + or ($statut === 'prop' and $type === 'article' and $GLOBALS['meta']['post_dates'] === 'non') |
|
| 590 | + ) { |
|
| 591 | + return autoriser('modifier', $type, $id); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + return false; |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * @return bool true s'il a le droit, false sinon |
| 611 | 611 | **/ |
| 612 | 612 | function autoriser_instituer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 613 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 613 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
@@ -628,12 +628,12 @@ discard block |
||
| 628 | 628 | * @return bool true s'il a le droit, false sinon |
| 629 | 629 | **/ |
| 630 | 630 | function autoriser_rubrique_publierdans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 631 | - return |
|
| 632 | - ($qui['statut'] === '0minirezo') |
|
| 633 | - and ( |
|
| 634 | - !$qui['restreint'] or !$id |
|
| 635 | - or in_array($id, $qui['restreint']) |
|
| 636 | - ); |
|
| 631 | + return |
|
| 632 | + ($qui['statut'] === '0minirezo') |
|
| 633 | + and ( |
|
| 634 | + !$qui['restreint'] or !$id |
|
| 635 | + or in_array($id, $qui['restreint']) |
|
| 636 | + ); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /** |
@@ -651,12 +651,12 @@ discard block |
||
| 651 | 651 | * @return bool true s'il a le droit, false sinon |
| 652 | 652 | **/ |
| 653 | 653 | function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 654 | - if (!empty($opt['id_parent'])) { |
|
| 655 | - return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 656 | - } |
|
| 657 | - else { |
|
| 658 | - return autoriser('defaut', null, 0, $qui, $opt); |
|
| 659 | - } |
|
| 654 | + if (!empty($opt['id_parent'])) { |
|
| 655 | + return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 656 | + } |
|
| 657 | + else { |
|
| 658 | + return autoriser('defaut', null, 0, $qui, $opt); |
|
| 659 | + } |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | /** |
@@ -674,10 +674,10 @@ discard block |
||
| 674 | 674 | * @return bool true s'il a le droit, false sinon |
| 675 | 675 | **/ |
| 676 | 676 | function autoriser_rubrique_creerrubriquedans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 677 | - return |
|
| 678 | - ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 679 | - and autoriser('voir', 'rubrique', $id) |
|
| 680 | - and autoriser('publierdans', 'rubrique', $id); |
|
| 677 | + return |
|
| 678 | + ($id or ($qui['statut'] === '0minirezo' and !$qui['restreint'])) |
|
| 679 | + and autoriser('voir', 'rubrique', $id) |
|
| 680 | + and autoriser('publierdans', 'rubrique', $id); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -695,10 +695,10 @@ discard block |
||
| 695 | 695 | * @return bool true s'il a le droit, false sinon |
| 696 | 696 | **/ |
| 697 | 697 | function autoriser_rubrique_creerarticledans_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 698 | - return |
|
| 699 | - $id |
|
| 700 | - and autoriser('voir', 'rubrique', $id) |
|
| 701 | - and autoriser('creer', 'article'); |
|
| 698 | + return |
|
| 699 | + $id |
|
| 700 | + and autoriser('voir', 'rubrique', $id) |
|
| 701 | + and autoriser('creer', 'article'); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | |
@@ -717,8 +717,8 @@ discard block |
||
| 717 | 717 | * @return bool true s'il a le droit, false sinon |
| 718 | 718 | **/ |
| 719 | 719 | function autoriser_rubrique_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 720 | - return |
|
| 721 | - autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 720 | + return |
|
| 721 | + autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -736,29 +736,29 @@ discard block |
||
| 736 | 736 | * @return bool true s'il a le droit, false sinon |
| 737 | 737 | **/ |
| 738 | 738 | function autoriser_rubrique_supprimer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 739 | - if (!$id = intval($id)) { |
|
| 740 | - return false; |
|
| 741 | - } |
|
| 739 | + if (!$id = intval($id)) { |
|
| 740 | + return false; |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 744 | - return false; |
|
| 745 | - } |
|
| 743 | + if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 744 | + return false; |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 748 | - return false; |
|
| 749 | - } |
|
| 747 | + if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 748 | + return false; |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | - $compte = pipeline( |
|
| 752 | - 'objet_compte_enfants', |
|
| 753 | - ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 754 | - ); |
|
| 755 | - foreach ($compte as $objet => $n) { |
|
| 756 | - if ($n) { |
|
| 757 | - return false; |
|
| 758 | - } |
|
| 759 | - } |
|
| 751 | + $compte = pipeline( |
|
| 752 | + 'objet_compte_enfants', |
|
| 753 | + ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 754 | + ); |
|
| 755 | + foreach ($compte as $objet => $n) { |
|
| 756 | + if ($n) { |
|
| 757 | + return false; |
|
| 758 | + } |
|
| 759 | + } |
|
| 760 | 760 | |
| 761 | - return autoriser('modifier', 'rubrique', $id); |
|
| 761 | + return autoriser('modifier', 'rubrique', $id); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | |
@@ -778,23 +778,23 @@ discard block |
||
| 778 | 778 | * @return bool true s'il a le droit, false sinon |
| 779 | 779 | **/ |
| 780 | 780 | function autoriser_article_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 781 | - if (!$id) { |
|
| 782 | - return false; |
|
| 783 | - } |
|
| 784 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 785 | - |
|
| 786 | - return |
|
| 787 | - $r |
|
| 788 | - and |
|
| 789 | - ( |
|
| 790 | - autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 791 | - or ( |
|
| 792 | - (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
|
| 793 | - and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 794 | - and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 795 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 796 | - ) |
|
| 797 | - ); |
|
| 781 | + if (!$id) { |
|
| 782 | + return false; |
|
| 783 | + } |
|
| 784 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 785 | + |
|
| 786 | + return |
|
| 787 | + $r |
|
| 788 | + and |
|
| 789 | + ( |
|
| 790 | + autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 791 | + or ( |
|
| 792 | + (!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true)) |
|
| 793 | + and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 794 | + and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 795 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 796 | + ) |
|
| 797 | + ); |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
@@ -812,13 +812,13 @@ discard block |
||
| 812 | 812 | * @return bool true s'il a le droit, false sinon |
| 813 | 813 | **/ |
| 814 | 814 | function autoriser_article_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 815 | - if (!empty($opt['id_parent'])) { |
|
| 816 | - // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 817 | - return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 818 | - } |
|
| 819 | - else { |
|
| 820 | - return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 821 | - } |
|
| 815 | + if (!empty($opt['id_parent'])) { |
|
| 816 | + // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 817 | + return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 818 | + } |
|
| 819 | + else { |
|
| 820 | + return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 821 | + } |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
@@ -840,28 +840,28 @@ discard block |
||
| 840 | 840 | * @return bool true s'il a le droit, false sinon |
| 841 | 841 | */ |
| 842 | 842 | function autoriser_article_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 843 | - if ($qui['statut'] === '0minirezo') { |
|
| 844 | - return true; |
|
| 845 | - } |
|
| 846 | - // cas des articles : depend du statut de l'article et de l'auteur |
|
| 847 | - if (isset($opt['statut'])) { |
|
| 848 | - $statut = $opt['statut']; |
|
| 849 | - } else { |
|
| 850 | - if (!$id) { |
|
| 851 | - return false; |
|
| 852 | - } |
|
| 853 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - return |
|
| 857 | - // si on est pas auteur de l'article, |
|
| 858 | - // seuls les propose et publies sont visibles |
|
| 859 | - in_array($statut, ['prop', 'publie']) |
|
| 860 | - // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 861 | - or |
|
| 862 | - ($id |
|
| 863 | - and $qui['id_auteur'] |
|
| 864 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 843 | + if ($qui['statut'] === '0minirezo') { |
|
| 844 | + return true; |
|
| 845 | + } |
|
| 846 | + // cas des articles : depend du statut de l'article et de l'auteur |
|
| 847 | + if (isset($opt['statut'])) { |
|
| 848 | + $statut = $opt['statut']; |
|
| 849 | + } else { |
|
| 850 | + if (!$id) { |
|
| 851 | + return false; |
|
| 852 | + } |
|
| 853 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + return |
|
| 857 | + // si on est pas auteur de l'article, |
|
| 858 | + // seuls les propose et publies sont visibles |
|
| 859 | + in_array($statut, ['prop', 'publie']) |
|
| 860 | + // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 861 | + or |
|
| 862 | + ($id |
|
| 863 | + and $qui['id_auteur'] |
|
| 864 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | |
@@ -880,24 +880,24 @@ discard block |
||
| 880 | 880 | * @return bool true s'il a le droit, false sinon |
| 881 | 881 | **/ |
| 882 | 882 | function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 883 | - # securite, mais on aurait pas du arriver ici ! |
|
| 884 | - if ( |
|
| 885 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 886 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 887 | - ) { |
|
| 888 | - return $f($faire, $type, $id, $qui, $opt); |
|
| 889 | - } |
|
| 883 | + # securite, mais on aurait pas du arriver ici ! |
|
| 884 | + if ( |
|
| 885 | + function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 886 | + or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 887 | + ) { |
|
| 888 | + return $f($faire, $type, $id, $qui, $opt); |
|
| 889 | + } |
|
| 890 | 890 | |
| 891 | - if ($qui['statut'] === '0minirezo') { |
|
| 892 | - return true; |
|
| 893 | - } |
|
| 894 | - // admins et redacteurs peuvent voir un auteur |
|
| 895 | - if ($type === 'auteur') { |
|
| 896 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 897 | - } |
|
| 898 | - // sinon par defaut tout est visible |
|
| 899 | - // sauf cas particuliers traites separemment (ie article) |
|
| 900 | - return true; |
|
| 891 | + if ($qui['statut'] === '0minirezo') { |
|
| 892 | + return true; |
|
| 893 | + } |
|
| 894 | + // admins et redacteurs peuvent voir un auteur |
|
| 895 | + if ($type === 'auteur') { |
|
| 896 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 897 | + } |
|
| 898 | + // sinon par defaut tout est visible |
|
| 899 | + // sauf cas particuliers traites separemment (ie article) |
|
| 900 | + return true; |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | |
@@ -920,12 +920,12 @@ discard block |
||
| 920 | 920 | * @return bool true s'il a le droit, false sinon |
| 921 | 921 | **/ |
| 922 | 922 | function autoriser_webmestre_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 923 | - return |
|
| 924 | - (defined('_ID_WEBMESTRES') ? |
|
| 925 | - in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 926 | - : $qui['webmestre'] === 'oui') |
|
| 927 | - and $qui['statut'] === '0minirezo' |
|
| 928 | - and !$qui['restreint']; |
|
| 923 | + return |
|
| 924 | + (defined('_ID_WEBMESTRES') ? |
|
| 925 | + in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 926 | + : $qui['webmestre'] === 'oui') |
|
| 927 | + and $qui['statut'] === '0minirezo' |
|
| 928 | + and !$qui['restreint']; |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | /** |
@@ -943,9 +943,9 @@ discard block |
||
| 943 | 943 | * @return bool true s'il a le droit, false sinon |
| 944 | 944 | **/ |
| 945 | 945 | function autoriser_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 946 | - return |
|
| 947 | - $qui['statut'] === '0minirezo' |
|
| 948 | - and !$qui['restreint']; |
|
| 946 | + return |
|
| 947 | + $qui['statut'] === '0minirezo' |
|
| 948 | + and !$qui['restreint']; |
|
| 949 | 949 | } |
| 950 | 950 | |
| 951 | 951 | /** |
@@ -963,8 +963,8 @@ discard block |
||
| 963 | 963 | * @return bool true s'il a le droit, false sinon |
| 964 | 964 | **/ |
| 965 | 965 | function autoriser_sauvegarder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 966 | - return |
|
| 967 | - $qui['statut'] === '0minirezo'; |
|
| 966 | + return |
|
| 967 | + $qui['statut'] === '0minirezo'; |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | /** |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | * @return bool true s'il a le droit, false sinon |
| 983 | 983 | **/ |
| 984 | 984 | function autoriser_detruire_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 985 | - return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 985 | + return autoriser('webmestre', null, 0, $qui, $opt); |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | /** |
@@ -1001,23 +1001,23 @@ discard block |
||
| 1001 | 1001 | * @return bool true s'il a le droit, false sinon |
| 1002 | 1002 | **/ |
| 1003 | 1003 | function autoriser_auteur_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1004 | - // les admins peuvent "previsualiser" une page auteur |
|
| 1005 | - if ( |
|
| 1006 | - $qui['statut'] === '0minirezo' |
|
| 1007 | - and !$qui['restreint'] |
|
| 1008 | - ) { |
|
| 1009 | - return true; |
|
| 1010 | - } elseif ($id === 0) { |
|
| 1011 | - return false; |
|
| 1012 | - } |
|
| 1013 | - // "Voir en ligne" si l'auteur a un article publie |
|
| 1014 | - $n = sql_fetsel( |
|
| 1015 | - 'A.id_article', |
|
| 1016 | - 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1017 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1018 | - ); |
|
| 1004 | + // les admins peuvent "previsualiser" une page auteur |
|
| 1005 | + if ( |
|
| 1006 | + $qui['statut'] === '0minirezo' |
|
| 1007 | + and !$qui['restreint'] |
|
| 1008 | + ) { |
|
| 1009 | + return true; |
|
| 1010 | + } elseif ($id === 0) { |
|
| 1011 | + return false; |
|
| 1012 | + } |
|
| 1013 | + // "Voir en ligne" si l'auteur a un article publie |
|
| 1014 | + $n = sql_fetsel( |
|
| 1015 | + 'A.id_article', |
|
| 1016 | + 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 1017 | + "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 1018 | + ); |
|
| 1019 | 1019 | |
| 1020 | - return $n ? true : false; |
|
| 1020 | + return $n ? true : false; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * @return bool true s'il a le droit, false sinon |
| 1047 | 1047 | **/ |
| 1048 | 1048 | function autoriser_auteur_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1049 | - return ($qui['statut'] === '0minirezo'); |
|
| 1049 | + return ($qui['statut'] === '0minirezo'); |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | |
@@ -1067,75 +1067,75 @@ discard block |
||
| 1067 | 1067 | * @return bool true s'il a le droit, false sinon |
| 1068 | 1068 | **/ |
| 1069 | 1069 | function autoriser_auteur_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1070 | - $id = intval($id); |
|
| 1071 | - |
|
| 1072 | - // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1073 | - // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1074 | - if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1075 | - if ( |
|
| 1076 | - $id == $qui['id_auteur'] |
|
| 1077 | - && empty($opt['statut']) |
|
| 1078 | - && empty($opt['webmestre']) |
|
| 1079 | - && empty($opt['restreintes']) |
|
| 1080 | - && empty($opt['login']) |
|
| 1081 | - ) { |
|
| 1082 | - return true; |
|
| 1083 | - } |
|
| 1084 | - return false; |
|
| 1085 | - } |
|
| 1086 | - |
|
| 1087 | - // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1088 | - // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1089 | - if ($qui['restreint']) { |
|
| 1090 | - if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1091 | - return false; |
|
| 1092 | - } elseif ( |
|
| 1093 | - (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1094 | - or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1095 | - ) { |
|
| 1096 | - return false; |
|
| 1097 | - } else { |
|
| 1098 | - if ($id == $qui['id_auteur']) { |
|
| 1099 | - if (isset($opt['statut']) and $opt['statut']) { |
|
| 1100 | - return false; |
|
| 1101 | - } else { |
|
| 1102 | - return true; |
|
| 1103 | - } |
|
| 1104 | - } else { |
|
| 1105 | - if ($id_auteur = intval($id)) { |
|
| 1106 | - $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1107 | - if ($t and $t['statut'] != '0minirezo') { |
|
| 1108 | - return true; |
|
| 1109 | - } else { |
|
| 1110 | - return false; |
|
| 1111 | - } |
|
| 1112 | - } // id = 0 => creation |
|
| 1113 | - else { |
|
| 1114 | - return true; |
|
| 1115 | - } |
|
| 1116 | - } |
|
| 1117 | - } |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - // Un admin complet fait ce qu'il veut |
|
| 1121 | - // sauf se degrader |
|
| 1122 | - if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1123 | - return false; |
|
| 1124 | - } elseif ( |
|
| 1125 | - isset($opt['webmestre']) |
|
| 1126 | - and $opt['webmestre'] |
|
| 1127 | - and (defined('_ID_WEBMESTRES') |
|
| 1128 | - or !autoriser('webmestre')) |
|
| 1129 | - ) { |
|
| 1130 | - // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1131 | - // ou si les webmestres sont fixes par constante (securite) |
|
| 1132 | - return false; |
|
| 1133 | - } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1134 | - elseif (intval($id) and !autoriser('webmestre') and autoriser('webmestre', '', 0, $id)) { |
|
| 1135 | - return false; |
|
| 1136 | - } else { |
|
| 1137 | - return true; |
|
| 1138 | - } |
|
| 1070 | + $id = intval($id); |
|
| 1071 | + |
|
| 1072 | + // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 1073 | + // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 1074 | + if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 1075 | + if ( |
|
| 1076 | + $id == $qui['id_auteur'] |
|
| 1077 | + && empty($opt['statut']) |
|
| 1078 | + && empty($opt['webmestre']) |
|
| 1079 | + && empty($opt['restreintes']) |
|
| 1080 | + && empty($opt['login']) |
|
| 1081 | + ) { |
|
| 1082 | + return true; |
|
| 1083 | + } |
|
| 1084 | + return false; |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 1088 | + // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1089 | + if ($qui['restreint']) { |
|
| 1090 | + if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1091 | + return false; |
|
| 1092 | + } elseif ( |
|
| 1093 | + (isset($opt['statut']) and ($opt['statut'] === '0minirezo')) |
|
| 1094 | + or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1095 | + ) { |
|
| 1096 | + return false; |
|
| 1097 | + } else { |
|
| 1098 | + if ($id == $qui['id_auteur']) { |
|
| 1099 | + if (isset($opt['statut']) and $opt['statut']) { |
|
| 1100 | + return false; |
|
| 1101 | + } else { |
|
| 1102 | + return true; |
|
| 1103 | + } |
|
| 1104 | + } else { |
|
| 1105 | + if ($id_auteur = intval($id)) { |
|
| 1106 | + $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1107 | + if ($t and $t['statut'] != '0minirezo') { |
|
| 1108 | + return true; |
|
| 1109 | + } else { |
|
| 1110 | + return false; |
|
| 1111 | + } |
|
| 1112 | + } // id = 0 => creation |
|
| 1113 | + else { |
|
| 1114 | + return true; |
|
| 1115 | + } |
|
| 1116 | + } |
|
| 1117 | + } |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + // Un admin complet fait ce qu'il veut |
|
| 1121 | + // sauf se degrader |
|
| 1122 | + if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1123 | + return false; |
|
| 1124 | + } elseif ( |
|
| 1125 | + isset($opt['webmestre']) |
|
| 1126 | + and $opt['webmestre'] |
|
| 1127 | + and (defined('_ID_WEBMESTRES') |
|
| 1128 | + or !autoriser('webmestre')) |
|
| 1129 | + ) { |
|
| 1130 | + // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1131 | + // ou si les webmestres sont fixes par constante (securite) |
|
| 1132 | + return false; |
|
| 1133 | + } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1134 | + elseif (intval($id) and !autoriser('webmestre') and autoriser('webmestre', '', 0, $id)) { |
|
| 1135 | + return false; |
|
| 1136 | + } else { |
|
| 1137 | + return true; |
|
| 1138 | + } |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | |
@@ -1154,7 +1154,7 @@ discard block |
||
| 1154 | 1154 | * @return bool true s'il a le droit, false sinon |
| 1155 | 1155 | **/ |
| 1156 | 1156 | function autoriser_associerauteurs_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1157 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1157 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | * @return bool true s'il a le droit, false sinon |
| 1174 | 1174 | **/ |
| 1175 | 1175 | function autoriser_chargerftp_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1176 | - return $qui['statut'] === '0minirezo'; |
|
| 1176 | + return $qui['statut'] === '0minirezo'; |
|
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | /** |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | * @return bool true s'il a le droit, false sinon |
| 1192 | 1192 | **/ |
| 1193 | 1193 | function autoriser_debug_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1194 | - return $qui['statut'] === '0minirezo'; |
|
| 1194 | + return $qui['statut'] === '0minirezo'; |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | /** |
@@ -1208,54 +1208,54 @@ discard block |
||
| 1208 | 1208 | * @return array Liste des rubriques |
| 1209 | 1209 | **/ |
| 1210 | 1210 | function liste_rubriques_auteur($id_auteur, $raz = false) { |
| 1211 | - static $restreint = []; |
|
| 1212 | - |
|
| 1213 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 1214 | - return []; |
|
| 1215 | - } |
|
| 1216 | - if ($raz) { |
|
| 1217 | - unset($restreint[$id_auteur]); |
|
| 1218 | - } elseif (isset($restreint[$id_auteur])) { |
|
| 1219 | - return $restreint[$id_auteur]; |
|
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - $rubriques = []; |
|
| 1223 | - if ( |
|
| 1224 | - (!isset($GLOBALS['meta']['version_installee']) |
|
| 1225 | - or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1226 | - and $r = sql_allfetsel( |
|
| 1227 | - 'id_objet', |
|
| 1228 | - 'spip_auteurs_liens', |
|
| 1229 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1230 | - ) |
|
| 1231 | - and is_countable($r) ? count($r) : 0 |
|
| 1232 | - ) { |
|
| 1233 | - $r = array_column($r, 'id_objet'); |
|
| 1234 | - |
|
| 1235 | - // recuperer toute la branche, au format chaine enumeration |
|
| 1236 | - include_spip('inc/rubriques'); |
|
| 1237 | - $r = calcul_branche_in($r); |
|
| 1238 | - $r = explode(',', $r); |
|
| 1239 | - |
|
| 1240 | - // passer les rubriques en index, elimine les doublons |
|
| 1241 | - $r = array_flip($r); |
|
| 1242 | - // recuperer les index seuls |
|
| 1243 | - $r = array_keys($r); |
|
| 1244 | - // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1245 | - // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1246 | - $rubriques = array_combine($r, $r); |
|
| 1247 | - } |
|
| 1248 | - |
|
| 1249 | - // Affecter l'auteur session le cas echeant |
|
| 1250 | - if ( |
|
| 1251 | - isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1252 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1253 | - ) { |
|
| 1254 | - $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - |
|
| 1258 | - return $restreint[$id_auteur] = $rubriques; |
|
| 1211 | + static $restreint = []; |
|
| 1212 | + |
|
| 1213 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 1214 | + return []; |
|
| 1215 | + } |
|
| 1216 | + if ($raz) { |
|
| 1217 | + unset($restreint[$id_auteur]); |
|
| 1218 | + } elseif (isset($restreint[$id_auteur])) { |
|
| 1219 | + return $restreint[$id_auteur]; |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + $rubriques = []; |
|
| 1223 | + if ( |
|
| 1224 | + (!isset($GLOBALS['meta']['version_installee']) |
|
| 1225 | + or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1226 | + and $r = sql_allfetsel( |
|
| 1227 | + 'id_objet', |
|
| 1228 | + 'spip_auteurs_liens', |
|
| 1229 | + 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1230 | + ) |
|
| 1231 | + and is_countable($r) ? count($r) : 0 |
|
| 1232 | + ) { |
|
| 1233 | + $r = array_column($r, 'id_objet'); |
|
| 1234 | + |
|
| 1235 | + // recuperer toute la branche, au format chaine enumeration |
|
| 1236 | + include_spip('inc/rubriques'); |
|
| 1237 | + $r = calcul_branche_in($r); |
|
| 1238 | + $r = explode(',', $r); |
|
| 1239 | + |
|
| 1240 | + // passer les rubriques en index, elimine les doublons |
|
| 1241 | + $r = array_flip($r); |
|
| 1242 | + // recuperer les index seuls |
|
| 1243 | + $r = array_keys($r); |
|
| 1244 | + // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1245 | + // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1246 | + $rubriques = array_combine($r, $r); |
|
| 1247 | + } |
|
| 1248 | + |
|
| 1249 | + // Affecter l'auteur session le cas echeant |
|
| 1250 | + if ( |
|
| 1251 | + isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1252 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1253 | + ) { |
|
| 1254 | + $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + |
|
| 1258 | + return $restreint[$id_auteur] = $rubriques; |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | /** |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | * @return bool true s'il a le droit, false sinon |
| 1274 | 1274 | **/ |
| 1275 | 1275 | function autoriser_rubrique_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1276 | - return autoriser('previsualiser'); |
|
| 1276 | + return autoriser('previsualiser'); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | 1279 | /** |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | * @return bool true s'il a le droit, false sinon |
| 1292 | 1292 | **/ |
| 1293 | 1293 | function autoriser_rubrique_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1294 | - return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1294 | + return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | /** |
@@ -1309,9 +1309,9 @@ discard block |
||
| 1309 | 1309 | * @return bool true s'il a le droit, false sinon |
| 1310 | 1310 | **/ |
| 1311 | 1311 | function autoriser_auteur_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1312 | - $id = intval($id); |
|
| 1313 | - return (($id == $qui['id_auteur']) or |
|
| 1314 | - (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1312 | + $id = intval($id); |
|
| 1313 | + return (($id == $qui['id_auteur']) or |
|
| 1314 | + (($qui['statut'] === '0minirezo') and !$qui['restreint'])); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | /** |
@@ -1329,8 +1329,8 @@ discard block |
||
| 1329 | 1329 | * @return bool true s'il a le droit, false sinon |
| 1330 | 1330 | **/ |
| 1331 | 1331 | function autoriser_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1332 | - // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1333 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1332 | + // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1333 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | * @return true |
| 1351 | 1351 | **/ |
| 1352 | 1352 | function autoriser_ok_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1353 | - return true; |
|
| 1353 | + return true; |
|
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | 1356 | /** |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | * @return false |
| 1370 | 1370 | **/ |
| 1371 | 1371 | function autoriser_niet_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1372 | - return false; |
|
| 1372 | + return false; |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | /** |
@@ -1387,11 +1387,11 @@ discard block |
||
| 1387 | 1387 | * @return bool true s'il a le droit, false sinon |
| 1388 | 1388 | **/ |
| 1389 | 1389 | function autoriser_base_reparer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1390 | - if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1391 | - return false; |
|
| 1392 | - } |
|
| 1390 | + if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1391 | + return false; |
|
| 1392 | + } |
|
| 1393 | 1393 | |
| 1394 | - return true; |
|
| 1394 | + return true; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
@@ -1409,7 +1409,7 @@ discard block |
||
| 1409 | 1409 | * @return true |
| 1410 | 1410 | **/ |
| 1411 | 1411 | function autoriser_infosperso_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1412 | - return true; |
|
| 1412 | + return true; |
|
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | 1415 | /** |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | * @return true |
| 1428 | 1428 | **/ |
| 1429 | 1429 | function autoriser_langage_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1430 | - return true; |
|
| 1430 | + return true; |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | /** |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | * @return bool true s'il a le droit, false sinon |
| 1446 | 1446 | **/ |
| 1447 | 1447 | function autoriser_configurerlangage_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1448 | - return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1448 | + return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | 1451 | /** |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | * @return true |
| 1464 | 1464 | **/ |
| 1465 | 1465 | function autoriser_preferences_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1466 | - return true; |
|
| 1466 | + return true; |
|
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | 1469 | /** |
@@ -1481,7 +1481,7 @@ discard block |
||
| 1481 | 1481 | * @return bool true s'il a le droit, false sinon |
| 1482 | 1482 | **/ |
| 1483 | 1483 | function autoriser_configurerpreferences_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1484 | - return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1484 | + return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | /** |
@@ -1499,8 +1499,8 @@ discard block |
||
| 1499 | 1499 | * @return bool true s'il a le droit, false sinon |
| 1500 | 1500 | **/ |
| 1501 | 1501 | function autoriser_menudeveloppement_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1502 | - return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1503 | - and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1502 | + return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1503 | + and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui'); |
|
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | 1506 | /** |
@@ -1519,7 +1519,7 @@ discard block |
||
| 1519 | 1519 | * @return true |
| 1520 | 1520 | **/ |
| 1521 | 1521 | function autoriser_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1522 | - return true; |
|
| 1522 | + return true; |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | /** |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | * @return true |
| 1538 | 1538 | **/ |
| 1539 | 1539 | function autoriser_auteurs_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1540 | - return true; |
|
| 1540 | + return true; |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | /** |
@@ -1555,7 +1555,7 @@ discard block |
||
| 1555 | 1555 | * @return bool true s'il a le droit, false sinon |
| 1556 | 1556 | **/ |
| 1557 | 1557 | function autoriser_auteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1558 | - return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1558 | + return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | /** |
@@ -1573,7 +1573,7 @@ discard block |
||
| 1573 | 1573 | * @return true |
| 1574 | 1574 | **/ |
| 1575 | 1575 | function autoriser_articles_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1576 | - return true; |
|
| 1576 | + return true; |
|
| 1577 | 1577 | } |
| 1578 | 1578 | |
| 1579 | 1579 | /** |
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | * @return bool true s'il a le droit, false sinon |
| 1592 | 1592 | **/ |
| 1593 | 1593 | function autoriser_articles_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1594 | - return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1594 | + return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | /** |
@@ -1609,7 +1609,7 @@ discard block |
||
| 1609 | 1609 | * @return true |
| 1610 | 1610 | **/ |
| 1611 | 1611 | function autoriser_rubriques_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1612 | - return true; |
|
| 1612 | + return true; |
|
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | /** |
@@ -1627,7 +1627,7 @@ discard block |
||
| 1627 | 1627 | * @return bool true s'il a le droit, false sinon |
| 1628 | 1628 | **/ |
| 1629 | 1629 | function autoriser_rubriques_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1630 | - return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1630 | + return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | /** |
@@ -1645,7 +1645,7 @@ discard block |
||
| 1645 | 1645 | * @return bool true s'il a le droit, false sinon |
| 1646 | 1646 | **/ |
| 1647 | 1647 | function autoriser_articlecreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1648 | - return verifier_table_non_vide(); |
|
| 1648 | + return verifier_table_non_vide(); |
|
| 1649 | 1649 | } |
| 1650 | 1650 | |
| 1651 | 1651 | |
@@ -1666,7 +1666,7 @@ discard block |
||
| 1666 | 1666 | * @return bool true s'il a le droit, false sinon |
| 1667 | 1667 | **/ |
| 1668 | 1668 | function autoriser_auteurcreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1669 | - return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1669 | + return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | 1672 | /** |
@@ -1684,13 +1684,13 @@ discard block |
||
| 1684 | 1684 | * @return bool true s'il a le droit, false sinon |
| 1685 | 1685 | **/ |
| 1686 | 1686 | function autoriser_visiteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1687 | - include_spip('base/abstract_sql'); |
|
| 1688 | - return |
|
| 1689 | - $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1690 | - and ( |
|
| 1691 | - $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1692 | - or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1693 | - ); |
|
| 1687 | + include_spip('base/abstract_sql'); |
|
| 1688 | + return |
|
| 1689 | + $qui['statut'] === '0minirezo' and !$qui['restreint'] |
|
| 1690 | + and ( |
|
| 1691 | + $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1692 | + or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1693 | + ); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | /** |
@@ -1708,7 +1708,7 @@ discard block |
||
| 1708 | 1708 | * @return bool true s'il a le droit, false sinon |
| 1709 | 1709 | **/ |
| 1710 | 1710 | function autoriser_suiviedito_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1711 | - return $qui['statut'] === '0minirezo'; |
|
| 1711 | + return $qui['statut'] === '0minirezo'; |
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | /** |
@@ -1726,7 +1726,7 @@ discard block |
||
| 1726 | 1726 | * @return bool true s'il a le droit, false sinon |
| 1727 | 1727 | **/ |
| 1728 | 1728 | function autoriser_synchro_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1729 | - return $qui['statut'] === '0minirezo'; |
|
| 1729 | + return $qui['statut'] === '0minirezo'; |
|
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | 1732 | /** |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | * @return bool true s'il a le droit, false sinon |
| 1745 | 1745 | **/ |
| 1746 | 1746 | function autoriser_configurerinteractions_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1747 | - return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1747 | + return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | /** |
@@ -1762,7 +1762,7 @@ discard block |
||
| 1762 | 1762 | * @return bool true s'il a le droit, false sinon |
| 1763 | 1763 | **/ |
| 1764 | 1764 | function autoriser_configurerlangue_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1765 | - return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1765 | + return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | 1768 | /** |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | * @return bool true s'il a le droit, false sinon |
| 1781 | 1781 | **/ |
| 1782 | 1782 | function autoriser_configurermultilinguisme_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1783 | - return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1783 | + return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | 1786 | /** |
@@ -1798,7 +1798,7 @@ discard block |
||
| 1798 | 1798 | * @return bool true s'il a le droit, false sinon |
| 1799 | 1799 | **/ |
| 1800 | 1800 | function autoriser_configurercontenu_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1801 | - return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1801 | + return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | /** |
@@ -1816,7 +1816,7 @@ discard block |
||
| 1816 | 1816 | * @return bool true s'il a le droit, false sinon |
| 1817 | 1817 | **/ |
| 1818 | 1818 | function autoriser_configureravancees_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1819 | - return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1819 | + return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | 1822 | /** |
@@ -1834,7 +1834,7 @@ discard block |
||
| 1834 | 1834 | * @return bool true s'il a le droit, false sinon |
| 1835 | 1835 | **/ |
| 1836 | 1836 | function autoriser_adminplugin_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1837 | - return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1837 | + return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | 1840 | /** |
@@ -1852,7 +1852,7 @@ discard block |
||
| 1852 | 1852 | * @return bool true s'il a le droit, false sinon |
| 1853 | 1853 | **/ |
| 1854 | 1854 | function autoriser_admintech_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1855 | - return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1855 | + return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | 1858 | /** |
@@ -1870,7 +1870,7 @@ discard block |
||
| 1870 | 1870 | * @return bool true s'il a le droit, false sinon |
| 1871 | 1871 | **/ |
| 1872 | 1872 | function autoriser_queue_purger_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1873 | - return autoriser('webmestre'); |
|
| 1873 | + return autoriser('webmestre'); |
|
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | |
@@ -1890,11 +1890,11 @@ discard block |
||
| 1890 | 1890 | * @return bool true s'il a le droit, false sinon |
| 1891 | 1891 | **/ |
| 1892 | 1892 | function autoriser_echafauder_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 1893 | - if (test_espace_prive()) { |
|
| 1894 | - return intval($qui['id_auteur']) ? true : false; |
|
| 1895 | - } else { |
|
| 1896 | - return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1897 | - } |
|
| 1893 | + if (test_espace_prive()) { |
|
| 1894 | + return intval($qui['id_auteur']) ? true : false; |
|
| 1895 | + } else { |
|
| 1896 | + return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1897 | + } |
|
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | |
@@ -1909,27 +1909,27 @@ discard block |
||
| 1909 | 1909 | * Identifiants d'auteurs |
| 1910 | 1910 | */ |
| 1911 | 1911 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1912 | - $objet = objet_type($objet); |
|
| 1913 | - $where = [ |
|
| 1914 | - 'objet=' . sql_quote($objet), |
|
| 1915 | - 'id_objet=' . intval($id_objet) |
|
| 1916 | - ]; |
|
| 1917 | - if (!empty($cond)) { |
|
| 1918 | - if (is_array($cond)) { |
|
| 1919 | - $where = array_merge($where, $cond); |
|
| 1920 | - } else { |
|
| 1921 | - $where[] = $cond; |
|
| 1922 | - } |
|
| 1923 | - } |
|
| 1924 | - $auteurs = sql_allfetsel( |
|
| 1925 | - 'id_auteur', |
|
| 1926 | - 'spip_auteurs_liens', |
|
| 1927 | - $where |
|
| 1928 | - ); |
|
| 1929 | - if (is_array($auteurs)) { |
|
| 1930 | - return array_column($auteurs, 'id_auteur'); |
|
| 1931 | - } |
|
| 1932 | - return []; |
|
| 1912 | + $objet = objet_type($objet); |
|
| 1913 | + $where = [ |
|
| 1914 | + 'objet=' . sql_quote($objet), |
|
| 1915 | + 'id_objet=' . intval($id_objet) |
|
| 1916 | + ]; |
|
| 1917 | + if (!empty($cond)) { |
|
| 1918 | + if (is_array($cond)) { |
|
| 1919 | + $where = array_merge($where, $cond); |
|
| 1920 | + } else { |
|
| 1921 | + $where[] = $cond; |
|
| 1922 | + } |
|
| 1923 | + } |
|
| 1924 | + $auteurs = sql_allfetsel( |
|
| 1925 | + 'id_auteur', |
|
| 1926 | + 'spip_auteurs_liens', |
|
| 1927 | + $where |
|
| 1928 | + ); |
|
| 1929 | + if (is_array($auteurs)) { |
|
| 1930 | + return array_column($auteurs, 'id_auteur'); |
|
| 1931 | + } |
|
| 1932 | + return []; |
|
| 1933 | 1933 | } |
| 1934 | 1934 | |
| 1935 | 1935 | /** |
@@ -1944,11 +1944,11 @@ discard block |
||
| 1944 | 1944 | * - false : serveur SQL indisponible |
| 1945 | 1945 | */ |
| 1946 | 1946 | function auteurs_article($id_article, $cond = '') { |
| 1947 | - return sql_allfetsel( |
|
| 1948 | - 'id_auteur', |
|
| 1949 | - 'spip_auteurs_liens', |
|
| 1950 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1951 | - ); |
|
| 1947 | + return sql_allfetsel( |
|
| 1948 | + 'id_auteur', |
|
| 1949 | + 'spip_auteurs_liens', |
|
| 1950 | + "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1951 | + ); |
|
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | 1954 | |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | */ |
| 1963 | 1963 | function acces_restreint_rubrique($id_rubrique) { |
| 1964 | 1964 | |
| 1965 | - return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1965 | + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | |
@@ -1975,12 +1975,12 @@ discard block |
||
| 1975 | 1975 | * @return bool true si un parent existe |
| 1976 | 1976 | */ |
| 1977 | 1977 | function verifier_table_non_vide($table = 'spip_rubriques') { |
| 1978 | - static $done = []; |
|
| 1979 | - if (!isset($done[$table])) { |
|
| 1980 | - $done[$table] = sql_countsel($table) > 0; |
|
| 1981 | - } |
|
| 1978 | + static $done = []; |
|
| 1979 | + if (!isset($done[$table])) { |
|
| 1980 | + $done[$table] = sql_countsel($table) > 0; |
|
| 1981 | + } |
|
| 1982 | 1982 | |
| 1983 | - return $done[$table]; |
|
| 1983 | + return $done[$table]; |
|
| 1984 | 1984 | } |
| 1985 | 1985 | |
| 1986 | 1986 | /** |
@@ -2007,15 +2007,15 @@ discard block |
||
| 2007 | 2007 | */ |
| 2008 | 2008 | function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) { |
| 2009 | 2009 | |
| 2010 | - $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2011 | - switch ($s) { |
|
| 2012 | - case 'info_redacteurs': |
|
| 2013 | - return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2014 | - case 'info_visiteurs': |
|
| 2015 | - return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2016 | - } |
|
| 2010 | + $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 2011 | + switch ($s) { |
|
| 2012 | + case 'info_redacteurs': |
|
| 2013 | + return ($GLOBALS['meta']['accepter_inscriptions'] === 'oui'); |
|
| 2014 | + case 'info_visiteurs': |
|
| 2015 | + return ($GLOBALS['meta']['accepter_visiteurs'] === 'oui' or $GLOBALS['meta']['forums_publics'] === 'abo'); |
|
| 2016 | + } |
|
| 2017 | 2017 | |
| 2018 | - return false; |
|
| 2018 | + return false; |
|
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | /** |
@@ -2033,7 +2033,7 @@ discard block |
||
| 2033 | 2033 | * @return bool true s'il a le droit, false sinon |
| 2034 | 2034 | **/ |
| 2035 | 2035 | function autoriser_inscription_relancer_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2036 | - return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2036 | + return $qui['statut'] === '0minirezo' and !$qui['restreint']; |
|
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | /** |
@@ -2051,5 +2051,5 @@ discard block |
||
| 2051 | 2051 | * @return bool true s'il a le droit, false sinon |
| 2052 | 2052 | **/ |
| 2053 | 2053 | function autoriser_phpinfos_dist(string $faire, string $type, $id, array $qui, array $opt): bool { |
| 2054 | - return autoriser('webmestre'); |
|
| 2054 | + return autoriser('webmestre'); |
|
| 2055 | 2055 | } |
@@ -93,7 +93,7 @@ |
||
| 93 | 93 | |
| 94 | 94 | $res = ltrim($res['texte']); |
| 95 | 95 | if (empty($res)) { |
| 96 | - spip_log("$arg $qs resultat vide", 'transmettre' . _LOG_INFO_IMPORTANTE); |
|
| 96 | + spip_log("$arg $qs resultat vide", 'transmettre'._LOG_INFO_IMPORTANTE); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | echo $res; |
@@ -17,92 +17,92 @@ |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | function action_api_transmettre_dist($arg = null) { |
| 25 | 25 | |
| 26 | - // Obtenir l'argument 'id_auteur/cle/format/fond' |
|
| 27 | - if (is_null($arg)) { |
|
| 28 | - $arg = _request('arg'); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - $args = explode('/', $arg); |
|
| 32 | - |
|
| 33 | - if (count($args) !== 4) { |
|
| 34 | - action_api_transmettre_fail($arg); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - [$id_auteur, $cle, $format, $fond] = $args; |
|
| 38 | - $id_auteur = intval($id_auteur); |
|
| 39 | - |
|
| 40 | - if (preg_match(',[^\w\\.-],', $format)) { |
|
| 41 | - action_api_transmettre_fail("format $format ??"); |
|
| 42 | - } |
|
| 43 | - if (preg_match(',[^\w\\.-],', $fond)) { |
|
| 44 | - action_api_transmettre_fail("fond $fond ??"); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - // verifier la cle |
|
| 48 | - //[(#ENV{id,0}|securiser_acces{#ENV{cle}, voirstats, #ENV{op}, #ENV{args}}|?{1,0})] |
|
| 49 | - //[(#ENV{id,0}|securiser_acces{#ENV{cle}, voirstats, #ENV{op}, #ENV{args}}|?{1,0})] |
|
| 50 | - |
|
| 51 | - $qs = $_SERVER['QUERY_STRING']; |
|
| 52 | - // retirer action et arg de la qs |
|
| 53 | - $contexte = []; |
|
| 54 | - parse_str($qs, $contexte); |
|
| 55 | - foreach ($contexte as $k => $v) { |
|
| 56 | - if (in_array($k, ['action', 'arg', 'var_mode'])) { |
|
| 57 | - unset($contexte[$k]); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - $qs = http_build_query($contexte); |
|
| 61 | - include_spip('inc/acces'); |
|
| 62 | - if (!securiser_acces_low_sec(intval($id_auteur), $cle, "transmettre/$format", $fond, $qs)) { |
|
| 63 | - // si le autoriser low_sec n'est pas bon, on peut valider l'appel si l'auteur est identifie |
|
| 64 | - include_spip('inc/autoriser'); |
|
| 65 | - $autoriser_type = preg_replace(',\W+,', '', "_{$format}{$fond}"); |
|
| 66 | - if ( |
|
| 67 | - !$id_auteur |
|
| 68 | - or empty($GLOBALS['visiteur_session']['id_auteur']) |
|
| 69 | - or $GLOBALS['visiteur_session']['id_auteur'] != $id_auteur |
|
| 70 | - or !autoriser('transmettre', $autoriser_type, $id_auteur) |
|
| 71 | - ) { |
|
| 72 | - action_api_transmettre_fail("auth QS $qs ??"); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $contexte['id_auteur'] = $id_auteur; |
|
| 77 | - |
|
| 78 | - $fond = "transmettre/$format/$fond"; |
|
| 79 | - |
|
| 80 | - if (!trouver_fond($fond)) { |
|
| 81 | - $fond = "prive/$fond"; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if (!trouver_fond($fond)) { |
|
| 85 | - action_api_transmettre_fail("fond $fond ??"); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - $res = recuperer_fond($fond, $contexte, ['raw' => true]); |
|
| 89 | - if (!empty($res['entetes'])) { |
|
| 90 | - foreach ($res['entetes'] as $h => $v) { |
|
| 91 | - header("$h: $v"); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - $res = ltrim($res['texte']); |
|
| 96 | - if (empty($res)) { |
|
| 97 | - spip_log("$arg $qs resultat vide", 'transmettre' . _LOG_INFO_IMPORTANTE); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - echo $res; |
|
| 101 | - exit(); |
|
| 26 | + // Obtenir l'argument 'id_auteur/cle/format/fond' |
|
| 27 | + if (is_null($arg)) { |
|
| 28 | + $arg = _request('arg'); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + $args = explode('/', $arg); |
|
| 32 | + |
|
| 33 | + if (count($args) !== 4) { |
|
| 34 | + action_api_transmettre_fail($arg); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + [$id_auteur, $cle, $format, $fond] = $args; |
|
| 38 | + $id_auteur = intval($id_auteur); |
|
| 39 | + |
|
| 40 | + if (preg_match(',[^\w\\.-],', $format)) { |
|
| 41 | + action_api_transmettre_fail("format $format ??"); |
|
| 42 | + } |
|
| 43 | + if (preg_match(',[^\w\\.-],', $fond)) { |
|
| 44 | + action_api_transmettre_fail("fond $fond ??"); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + // verifier la cle |
|
| 48 | + //[(#ENV{id,0}|securiser_acces{#ENV{cle}, voirstats, #ENV{op}, #ENV{args}}|?{1,0})] |
|
| 49 | + //[(#ENV{id,0}|securiser_acces{#ENV{cle}, voirstats, #ENV{op}, #ENV{args}}|?{1,0})] |
|
| 50 | + |
|
| 51 | + $qs = $_SERVER['QUERY_STRING']; |
|
| 52 | + // retirer action et arg de la qs |
|
| 53 | + $contexte = []; |
|
| 54 | + parse_str($qs, $contexte); |
|
| 55 | + foreach ($contexte as $k => $v) { |
|
| 56 | + if (in_array($k, ['action', 'arg', 'var_mode'])) { |
|
| 57 | + unset($contexte[$k]); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + $qs = http_build_query($contexte); |
|
| 61 | + include_spip('inc/acces'); |
|
| 62 | + if (!securiser_acces_low_sec(intval($id_auteur), $cle, "transmettre/$format", $fond, $qs)) { |
|
| 63 | + // si le autoriser low_sec n'est pas bon, on peut valider l'appel si l'auteur est identifie |
|
| 64 | + include_spip('inc/autoriser'); |
|
| 65 | + $autoriser_type = preg_replace(',\W+,', '', "_{$format}{$fond}"); |
|
| 66 | + if ( |
|
| 67 | + !$id_auteur |
|
| 68 | + or empty($GLOBALS['visiteur_session']['id_auteur']) |
|
| 69 | + or $GLOBALS['visiteur_session']['id_auteur'] != $id_auteur |
|
| 70 | + or !autoriser('transmettre', $autoriser_type, $id_auteur) |
|
| 71 | + ) { |
|
| 72 | + action_api_transmettre_fail("auth QS $qs ??"); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $contexte['id_auteur'] = $id_auteur; |
|
| 77 | + |
|
| 78 | + $fond = "transmettre/$format/$fond"; |
|
| 79 | + |
|
| 80 | + if (!trouver_fond($fond)) { |
|
| 81 | + $fond = "prive/$fond"; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if (!trouver_fond($fond)) { |
|
| 85 | + action_api_transmettre_fail("fond $fond ??"); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + $res = recuperer_fond($fond, $contexte, ['raw' => true]); |
|
| 89 | + if (!empty($res['entetes'])) { |
|
| 90 | + foreach ($res['entetes'] as $h => $v) { |
|
| 91 | + header("$h: $v"); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + $res = ltrim($res['texte']); |
|
| 96 | + if (empty($res)) { |
|
| 97 | + spip_log("$arg $qs resultat vide", 'transmettre' . _LOG_INFO_IMPORTANTE); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + echo $res; |
|
| 101 | + exit(); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | function action_api_transmettre_fail($arg) { |
| 105 | - include_spip('inc/minipres'); |
|
| 106 | - echo minipres(_T('info_acces_interdit'), $arg); |
|
| 107 | - exit; |
|
| 105 | + include_spip('inc/minipres'); |
|
| 106 | + echo minipres(_T('info_acces_interdit'), $arg); |
|
| 107 | + exit; |
|
| 108 | 108 | } |