@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | function action_debloquer_edition_dist() { |
| 32 | 32 | |
| 33 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 34 | - $arg = $securiser_action(); |
|
| 33 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 34 | + $arg = $securiser_action(); |
|
| 35 | 35 | |
| 36 | - if ($arg) { |
|
| 37 | - include_spip('inc/drapeau_edition'); |
|
| 38 | - if ($arg == 'tous') { |
|
| 39 | - debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 40 | - } else { |
|
| 41 | - $arg = explode('-', (string) $arg); |
|
| 42 | - [$objet, $id_objet] = $arg; |
|
| 43 | - debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 44 | - } |
|
| 45 | - } |
|
| 36 | + if ($arg) { |
|
| 37 | + include_spip('inc/drapeau_edition'); |
|
| 38 | + if ($arg == 'tous') { |
|
| 39 | + debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 40 | + } else { |
|
| 41 | + $arg = explode('-', (string) $arg); |
|
| 42 | + [$objet, $id_objet] = $arg; |
|
| 43 | + debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Cache |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
@@ -30,41 +30,41 @@ discard block |
||
| 30 | 30 | * de l'action sécurisée. |
| 31 | 31 | */ |
| 32 | 32 | function action_calculer_taille_cache_dist($arg = null) { |
| 33 | - if (is_null($arg)) { |
|
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $arg = $securiser_action(); |
|
| 36 | - } |
|
| 37 | - include_spip('inc/filtres'); |
|
| 33 | + if (is_null($arg)) { |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $arg = $securiser_action(); |
|
| 36 | + } |
|
| 37 | + include_spip('inc/filtres'); |
|
| 38 | 38 | |
| 39 | - if ($arg == 'images') { |
|
| 40 | - $taille = calculer_taille_dossier(_DIR_VAR); |
|
| 41 | - $res = _T( |
|
| 42 | - 'ecrire:taille_cache_image', |
|
| 43 | - [ |
|
| 44 | - 'dir' => joli_repertoire(_DIR_VAR), |
|
| 45 | - 'taille' => '<b>' . (taille_en_octets($taille) > 0 ? taille_en_octets($taille) : '0 octet') . '</b>' |
|
| 46 | - ] |
|
| 47 | - ); |
|
| 48 | - } else { |
|
| 49 | - include_spip('inc/invalideur'); |
|
| 50 | - $taille = |
|
| 51 | - calculer_taille_dossier(_DIR_CACHE_XML) |
|
| 52 | - + calculer_taille_dossier(_DIR_CACHE . 'skel/') |
|
| 53 | - + calculer_taille_dossier(_DIR_CACHE . 'wheels/') |
|
| 54 | - + calculer_taille_dossier(_DIR_CACHE . 'contextes/'); |
|
| 55 | - $taille += (int) taille_du_cache(); |
|
| 56 | - if ($taille <= 150000) { |
|
| 57 | - $res = _T('taille_cache_vide'); |
|
| 58 | - } elseif ($taille <= 1024 * 1024) { |
|
| 59 | - $res = _T('taille_cache_moins_de', ['octets' => taille_en_octets(1024 * 1024)]); |
|
| 60 | - } else { |
|
| 61 | - $res = _T('taille_cache_octets', ['octets' => taille_en_octets($taille)]); |
|
| 62 | - } |
|
| 63 | - $res = "<b>$res</b>"; |
|
| 64 | - } |
|
| 39 | + if ($arg == 'images') { |
|
| 40 | + $taille = calculer_taille_dossier(_DIR_VAR); |
|
| 41 | + $res = _T( |
|
| 42 | + 'ecrire:taille_cache_image', |
|
| 43 | + [ |
|
| 44 | + 'dir' => joli_repertoire(_DIR_VAR), |
|
| 45 | + 'taille' => '<b>' . (taille_en_octets($taille) > 0 ? taille_en_octets($taille) : '0 octet') . '</b>' |
|
| 46 | + ] |
|
| 47 | + ); |
|
| 48 | + } else { |
|
| 49 | + include_spip('inc/invalideur'); |
|
| 50 | + $taille = |
|
| 51 | + calculer_taille_dossier(_DIR_CACHE_XML) |
|
| 52 | + + calculer_taille_dossier(_DIR_CACHE . 'skel/') |
|
| 53 | + + calculer_taille_dossier(_DIR_CACHE . 'wheels/') |
|
| 54 | + + calculer_taille_dossier(_DIR_CACHE . 'contextes/'); |
|
| 55 | + $taille += (int) taille_du_cache(); |
|
| 56 | + if ($taille <= 150000) { |
|
| 57 | + $res = _T('taille_cache_vide'); |
|
| 58 | + } elseif ($taille <= 1024 * 1024) { |
|
| 59 | + $res = _T('taille_cache_moins_de', ['octets' => taille_en_octets(1024 * 1024)]); |
|
| 60 | + } else { |
|
| 61 | + $res = _T('taille_cache_octets', ['octets' => taille_en_octets($taille)]); |
|
| 62 | + } |
|
| 63 | + $res = "<b>$res</b>"; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $res = "<p>$res</p>"; |
|
| 67 | - ajax_retour($res); |
|
| 66 | + $res = "<p>$res</p>"; |
|
| 67 | + ajax_retour($res); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -75,28 +75,28 @@ discard block |
||
| 75 | 75 | * @return int Taille en octets |
| 76 | 76 | */ |
| 77 | 77 | function calculer_taille_dossier($dir) { |
| 78 | - if (!is_dir($dir) || !is_readable($dir)) { |
|
| 79 | - return 0; |
|
| 80 | - } |
|
| 81 | - $handle = opendir($dir); |
|
| 82 | - if (!$handle) { |
|
| 83 | - return 0; |
|
| 84 | - } |
|
| 85 | - $taille = 0; |
|
| 86 | - while (($fichier = @readdir($handle)) !== false) { |
|
| 87 | - // Eviter ".", "..", ".htaccess", etc. |
|
| 88 | - if ($fichier[0] == '.') { |
|
| 89 | - continue; |
|
| 90 | - } |
|
| 91 | - if (is_file($d = "$dir/$fichier")) { |
|
| 92 | - $taille += filesize($d); |
|
| 93 | - } else { |
|
| 94 | - if (is_dir($d)) { |
|
| 95 | - $taille += calculer_taille_dossier($d); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - closedir($handle); |
|
| 78 | + if (!is_dir($dir) || !is_readable($dir)) { |
|
| 79 | + return 0; |
|
| 80 | + } |
|
| 81 | + $handle = opendir($dir); |
|
| 82 | + if (!$handle) { |
|
| 83 | + return 0; |
|
| 84 | + } |
|
| 85 | + $taille = 0; |
|
| 86 | + while (($fichier = @readdir($handle)) !== false) { |
|
| 87 | + // Eviter ".", "..", ".htaccess", etc. |
|
| 88 | + if ($fichier[0] == '.') { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 91 | + if (is_file($d = "$dir/$fichier")) { |
|
| 92 | + $taille += filesize($d); |
|
| 93 | + } else { |
|
| 94 | + if (is_dir($d)) { |
|
| 95 | + $taille += calculer_taille_dossier($d); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + closedir($handle); |
|
| 100 | 100 | |
| 101 | - return $taille; |
|
| 101 | + return $taille; |
|
| 102 | 102 | } |
@@ -42,16 +42,16 @@ |
||
| 42 | 42 | 'ecrire:taille_cache_image', |
| 43 | 43 | [ |
| 44 | 44 | 'dir' => joli_repertoire(_DIR_VAR), |
| 45 | - 'taille' => '<b>' . (taille_en_octets($taille) > 0 ? taille_en_octets($taille) : '0 octet') . '</b>' |
|
| 45 | + 'taille' => '<b>'.(taille_en_octets($taille) > 0 ? taille_en_octets($taille) : '0 octet').'</b>' |
|
| 46 | 46 | ] |
| 47 | 47 | ); |
| 48 | 48 | } else { |
| 49 | 49 | include_spip('inc/invalideur'); |
| 50 | 50 | $taille = |
| 51 | 51 | calculer_taille_dossier(_DIR_CACHE_XML) |
| 52 | - + calculer_taille_dossier(_DIR_CACHE . 'skel/') |
|
| 53 | - + calculer_taille_dossier(_DIR_CACHE . 'wheels/') |
|
| 54 | - + calculer_taille_dossier(_DIR_CACHE . 'contextes/'); |
|
| 52 | + + calculer_taille_dossier(_DIR_CACHE.'skel/') |
|
| 53 | + + calculer_taille_dossier(_DIR_CACHE.'wheels/') |
|
| 54 | + + calculer_taille_dossier(_DIR_CACHE.'contextes/'); |
|
| 55 | 55 | $taille += (int) taille_du_cache(); |
| 56 | 56 | if ($taille <= 150000) { |
| 57 | 57 | $res = _T('taille_cache_vide'); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -27,51 +27,51 @@ discard block |
||
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | 29 | function action_confirmer_inscription_dist() { |
| 30 | - $jeton = _request('jeton'); |
|
| 31 | - $email = _request('email'); |
|
| 30 | + $jeton = _request('jeton'); |
|
| 31 | + $email = _request('email'); |
|
| 32 | 32 | |
| 33 | - include_spip('action/inscrire_auteur'); |
|
| 34 | - if ( |
|
| 35 | - ($auteur = auteur_verifier_jeton($jeton)) |
|
| 36 | - && $auteur['email'] == $email |
|
| 37 | - && $auteur['statut'] == 'nouveau' |
|
| 38 | - ) { |
|
| 39 | - // d'abord on confirme son statut |
|
| 40 | - $auteur = confirmer_statut_inscription($auteur); |
|
| 33 | + include_spip('action/inscrire_auteur'); |
|
| 34 | + if ( |
|
| 35 | + ($auteur = auteur_verifier_jeton($jeton)) |
|
| 36 | + && $auteur['email'] == $email |
|
| 37 | + && $auteur['statut'] == 'nouveau' |
|
| 38 | + ) { |
|
| 39 | + // d'abord on confirme son statut |
|
| 40 | + $auteur = confirmer_statut_inscription($auteur); |
|
| 41 | 41 | |
| 42 | - // OK c'est un nouvel inscrit qui confirme : |
|
| 43 | - // on le loge => ca va confirmer son statut et c'est plus sympa |
|
| 44 | - include_spip('inc/auth'); |
|
| 45 | - auth_loger($auteur); |
|
| 42 | + // OK c'est un nouvel inscrit qui confirme : |
|
| 43 | + // on le loge => ca va confirmer son statut et c'est plus sympa |
|
| 44 | + include_spip('inc/auth'); |
|
| 45 | + auth_loger($auteur); |
|
| 46 | 46 | |
| 47 | - // et on efface son jeton |
|
| 48 | - auteur_effacer_jeton($auteur['id_auteur']); |
|
| 47 | + // et on efface son jeton |
|
| 48 | + auteur_effacer_jeton($auteur['id_auteur']); |
|
| 49 | 49 | |
| 50 | - // si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur |
|
| 51 | - // TODO: ne semble pas marcher si inscrit non visiteur, a debug |
|
| 52 | - if (!_request('redirect')) { |
|
| 53 | - // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 54 | - if (autoriser('ecrire', '', '', $auteur['id_auteur'])) { |
|
| 55 | - // poser un cookie admin aussi |
|
| 56 | - $cookie = charger_fonction('cookie', 'action'); |
|
| 57 | - $cookie('@' . $GLOBALS['visiteur_session']['login']); |
|
| 58 | - $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 59 | - } else { |
|
| 60 | - $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } else { |
|
| 64 | - // lien perime : |
|
| 65 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 66 | - // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 67 | - if (autoriser('ecrire', '', '', $GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 68 | - $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 69 | - } else { |
|
| 70 | - $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 71 | - } |
|
| 72 | - } else { |
|
| 73 | - // rediriger vers la page de login si pas encore loge |
|
| 74 | - $GLOBALS['redirect'] = parametre_url(generer_url_public('login', '', false), 'url', _request('redirect')); |
|
| 75 | - } |
|
| 76 | - } |
|
| 50 | + // si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur |
|
| 51 | + // TODO: ne semble pas marcher si inscrit non visiteur, a debug |
|
| 52 | + if (!_request('redirect')) { |
|
| 53 | + // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 54 | + if (autoriser('ecrire', '', '', $auteur['id_auteur'])) { |
|
| 55 | + // poser un cookie admin aussi |
|
| 56 | + $cookie = charger_fonction('cookie', 'action'); |
|
| 57 | + $cookie('@' . $GLOBALS['visiteur_session']['login']); |
|
| 58 | + $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 59 | + } else { |
|
| 60 | + $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } else { |
|
| 64 | + // lien perime : |
|
| 65 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 66 | + // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 67 | + if (autoriser('ecrire', '', '', $GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 68 | + $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 69 | + } else { |
|
| 70 | + $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 71 | + } |
|
| 72 | + } else { |
|
| 73 | + // rediriger vers la page de login si pas encore loge |
|
| 74 | + $GLOBALS['redirect'] = parametre_url(generer_url_public('login', '', false), 'url', _request('redirect')); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/autoriser'); |
@@ -34,42 +34,42 @@ discard block |
||
| 34 | 34 | **/ |
| 35 | 35 | function action_menu_rubriques_dist() { |
| 36 | 36 | |
| 37 | - // si pas acces a ecrire, pas acces au menu |
|
| 38 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 39 | - if (!autoriser('ecrire')) { |
|
| 40 | - $retour = |
|
| 41 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 42 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 43 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 44 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 45 | - '</a>' . |
|
| 46 | - '</li>' . |
|
| 47 | - '</ul>'; |
|
| 48 | - include_spip('inc/actions'); |
|
| 49 | - ajax_retour($retour); |
|
| 50 | - exit; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if ($date = (int) _request('date')) { |
|
| 54 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $r = gen_liste_rubriques(); |
|
| 58 | - if ( |
|
| 59 | - !$r |
|
| 60 | - && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 61 | - && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 62 | - ) { |
|
| 63 | - include_spip('inc/headers'); |
|
| 64 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 65 | - http_response_code(304); |
|
| 66 | - exit; |
|
| 67 | - } else { |
|
| 68 | - include_spip('inc/actions'); |
|
| 69 | - $ret = menu_rubriques(); |
|
| 70 | - ajax_retour($ret); |
|
| 71 | - exit; |
|
| 72 | - } |
|
| 37 | + // si pas acces a ecrire, pas acces au menu |
|
| 38 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 39 | + if (!autoriser('ecrire')) { |
|
| 40 | + $retour = |
|
| 41 | + '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 42 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 43 | + '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 44 | + '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 45 | + '</a>' . |
|
| 46 | + '</li>' . |
|
| 47 | + '</ul>'; |
|
| 48 | + include_spip('inc/actions'); |
|
| 49 | + ajax_retour($retour); |
|
| 50 | + exit; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if ($date = (int) _request('date')) { |
|
| 54 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $r = gen_liste_rubriques(); |
|
| 58 | + if ( |
|
| 59 | + !$r |
|
| 60 | + && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 61 | + && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 62 | + ) { |
|
| 63 | + include_spip('inc/headers'); |
|
| 64 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 65 | + http_response_code(304); |
|
| 66 | + exit; |
|
| 67 | + } else { |
|
| 68 | + include_spip('inc/actions'); |
|
| 69 | + $ret = menu_rubriques(); |
|
| 70 | + ajax_retour($ret); |
|
| 71 | + exit; |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -83,44 +83,44 @@ discard block |
||
| 83 | 83 | * Code HTML présentant la liste des rubriques |
| 84 | 84 | **/ |
| 85 | 85 | function menu_rubriques($complet = true) { |
| 86 | - $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 87 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 88 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 89 | - . '</a>' |
|
| 90 | - . '</li>'; |
|
| 91 | - |
|
| 92 | - if (!$complet) { |
|
| 93 | - return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 97 | - gen_liste_rubriques(); |
|
| 98 | - } |
|
| 99 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 100 | - |
|
| 101 | - $total_lignes = $i = count($arr_low); |
|
| 102 | - |
|
| 103 | - if ($i > 0) { |
|
| 104 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 105 | - if ($nb_col <= 1) { |
|
| 106 | - $nb_col = ceil($total_lignes / 10); |
|
| 107 | - } |
|
| 108 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 109 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 110 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 111 | - $i++; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 116 | - $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 117 | - . $ret |
|
| 118 | - . "\n</ul>\n"; |
|
| 119 | - } else { |
|
| 120 | - $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - return $ret; |
|
| 86 | + $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 87 | + . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 88 | + . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 89 | + . '</a>' |
|
| 90 | + . '</li>'; |
|
| 91 | + |
|
| 92 | + if (!$complet) { |
|
| 93 | + return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 97 | + gen_liste_rubriques(); |
|
| 98 | + } |
|
| 99 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 100 | + |
|
| 101 | + $total_lignes = $i = count($arr_low); |
|
| 102 | + |
|
| 103 | + if ($i > 0) { |
|
| 104 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 105 | + if ($nb_col <= 1) { |
|
| 106 | + $nb_col = ceil($total_lignes / 10); |
|
| 107 | + } |
|
| 108 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 109 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 110 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 111 | + $i++; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 116 | + $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 117 | + . $ret |
|
| 118 | + . "\n</ul>\n"; |
|
| 119 | + } else { |
|
| 120 | + $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + return $ret; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -141,47 +141,47 @@ discard block |
||
| 141 | 141 | * Code HTML présentant la liste des rubriques |
| 142 | 142 | **/ |
| 143 | 143 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) { |
| 144 | - static $zmax = 6; |
|
| 145 | - $profondeur_next = $profondeur + 1; |
|
| 146 | - |
|
| 147 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 148 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 149 | - . "</a>\n"; |
|
| 150 | - |
|
| 151 | - // Limiter volontairement le nombre de sous-menus |
|
| 152 | - if (!(--$zmax)) { |
|
| 153 | - $zmax++; |
|
| 154 | - |
|
| 155 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 159 | - $i = count($arr_rub); |
|
| 160 | - if (!$i) { |
|
| 161 | - $zmax++; |
|
| 162 | - |
|
| 163 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - $nb_col = 1; |
|
| 168 | - if ($nb_rub = count($arr_rub)) { |
|
| 169 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 170 | - } |
|
| 171 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 172 | - $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 173 | - . $nav |
|
| 174 | - . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 175 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 176 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 177 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 178 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 179 | - $i++; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - $zmax++; |
|
| 183 | - |
|
| 184 | - return $ret . "</ul></li>\n"; |
|
| 144 | + static $zmax = 6; |
|
| 145 | + $profondeur_next = $profondeur + 1; |
|
| 146 | + |
|
| 147 | + $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 148 | + . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 149 | + . "</a>\n"; |
|
| 150 | + |
|
| 151 | + // Limiter volontairement le nombre de sous-menus |
|
| 152 | + if (!(--$zmax)) { |
|
| 153 | + $zmax++; |
|
| 154 | + |
|
| 155 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 159 | + $i = count($arr_rub); |
|
| 160 | + if (!$i) { |
|
| 161 | + $zmax++; |
|
| 162 | + |
|
| 163 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + $nb_col = 1; |
|
| 168 | + if ($nb_rub = count($arr_rub)) { |
|
| 169 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 170 | + } |
|
| 171 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 172 | + $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 173 | + . $nav |
|
| 174 | + . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 175 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 176 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 177 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 178 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 179 | + $i++; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + $zmax++; |
|
| 183 | + |
|
| 184 | + return $ret . "</ul></li>\n"; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 200 | 200 | **/ |
| 201 | 201 | function extraire_article($id_p, $t) { |
| 202 | - return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 202 | + return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -215,42 +215,42 @@ discard block |
||
| 215 | 215 | **/ |
| 216 | 216 | function gen_liste_rubriques() { |
| 217 | 217 | |
| 218 | - $cache = null; |
|
| 219 | - include_spip('inc/config'); |
|
| 220 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 221 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 222 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 223 | - [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 224 | - if ($date == $last) { |
|
| 225 | - return false; |
|
| 226 | - } // c'etait en cache :-) |
|
| 227 | - } |
|
| 228 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 229 | - |
|
| 230 | - $where = sql_in_select( |
|
| 231 | - 'id_rubrique', |
|
| 232 | - 'id_rubrique', |
|
| 233 | - 'spip_rubriques', |
|
| 234 | - '', |
|
| 235 | - '', |
|
| 236 | - 'id_parent=0 DESC, date DESC', |
|
| 237 | - _CACHE_RUBRIQUES_MAX |
|
| 238 | - ); |
|
| 239 | - |
|
| 240 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 241 | - |
|
| 242 | - $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 243 | - |
|
| 244 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 245 | - // car on met le resultat en cache, commun a tout le monde |
|
| 246 | - $GLOBALS['db_art_cache'] = []; |
|
| 247 | - while ($r = sql_fetch($res)) { |
|
| 248 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 249 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 253 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 254 | - |
|
| 255 | - return true; |
|
| 218 | + $cache = null; |
|
| 219 | + include_spip('inc/config'); |
|
| 220 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 221 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 222 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 223 | + [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 224 | + if ($date == $last) { |
|
| 225 | + return false; |
|
| 226 | + } // c'etait en cache :-) |
|
| 227 | + } |
|
| 228 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 229 | + |
|
| 230 | + $where = sql_in_select( |
|
| 231 | + 'id_rubrique', |
|
| 232 | + 'id_rubrique', |
|
| 233 | + 'spip_rubriques', |
|
| 234 | + '', |
|
| 235 | + '', |
|
| 236 | + 'id_parent=0 DESC, date DESC', |
|
| 237 | + _CACHE_RUBRIQUES_MAX |
|
| 238 | + ); |
|
| 239 | + |
|
| 240 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 241 | + |
|
| 242 | + $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 243 | + |
|
| 244 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 245 | + // car on met le resultat en cache, commun a tout le monde |
|
| 246 | + $GLOBALS['db_art_cache'] = []; |
|
| 247 | + while ($r = sql_fetch($res)) { |
|
| 248 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 249 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 253 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 254 | + |
|
| 255 | + return true; |
|
| 256 | 256 | } |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
| 39 | 39 | if (!autoriser('ecrire')) { |
| 40 | 40 | $retour = |
| 41 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 42 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 43 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 44 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 45 | - '</a>' . |
|
| 46 | - '</li>' . |
|
| 41 | + '<ul class="deroulant__sous-menu" data-profondeur="1">'. |
|
| 42 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">'. |
|
| 43 | + '<a class="deroulant__lien" href="'.generer_url_ecrire('accueil').'" data-profondeur="1">'. |
|
| 44 | + '<span class="libelle">'._T('public:lien_connecter').'</span>'. |
|
| 45 | + '</a>'. |
|
| 46 | + '</li>'. |
|
| 47 | 47 | '</ul>'; |
| 48 | 48 | include_spip('inc/actions'); |
| 49 | 49 | ajax_retour($retour); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | if ($date = (int) _request('date')) { |
| 54 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 54 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $date).' GMT'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $r = gen_liste_rubriques(); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/') |
| 62 | 62 | ) { |
| 63 | 63 | include_spip('inc/headers'); |
| 64 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 64 | + header('Content-Type: text/html; charset='.$GLOBALS['meta']['charset']); |
|
| 65 | 65 | http_response_code(304); |
| 66 | 66 | exit; |
| 67 | 67 | } else { |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | **/ |
| 85 | 85 | function menu_rubriques($complet = true) { |
| 86 | 86 | $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
| 87 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 88 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 87 | + . '<a class="deroulant__lien" href="'.generer_url_ecrire('plan').'" data-profondeur="1">' |
|
| 88 | + . '<span class="libelle">'._T('info_tout_site').'</span>' |
|
| 89 | 89 | . '</a>' |
| 90 | 90 | . '</li>'; |
| 91 | 91 | |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | static $zmax = 6; |
| 145 | 145 | $profondeur_next = $profondeur + 1; |
| 146 | 146 | |
| 147 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 148 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 147 | + $nav = '<a class="deroulant__lien" href="'.generer_objet_url($id_rubrique, 'rubrique', '', '', false)."\" data-profondeur=\"$profondeur\">" |
|
| 148 | + . '<span class="libelle">'.supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)).'</span>' |
|
| 149 | 149 | . "</a>\n"; |
| 150 | 150 | |
| 151 | 151 | // Limiter volontairement le nombre de sous-menus |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | $zmax++; |
| 183 | 183 | |
| 184 | - return $ret . "</ul></li>\n"; |
|
| 184 | + return $ret."</ul></li>\n"; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -24,25 +24,25 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function action_auth_dist() { |
| 26 | 26 | |
| 27 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 28 | - $arg = $securiser_action(); |
|
| 29 | - |
|
| 30 | - if (!preg_match(',^(\w+)[/](.+)$,', (string) $arg, $r)) { |
|
| 31 | - spip_log("action_auth_dist $arg pas compris"); |
|
| 32 | - } else { |
|
| 33 | - $auth_methode = $r[1]; |
|
| 34 | - $login = $r[2]; |
|
| 35 | - include_spip('inc/auth'); |
|
| 36 | - $res = auth_terminer_identifier_login($auth_methode, $login); |
|
| 37 | - |
|
| 38 | - if (is_string($res)) { // Erreur |
|
| 39 | - $redirect = _request('redirect'); |
|
| 40 | - $redirect = parametre_url($redirect, 'var_erreur', $res, '&'); |
|
| 41 | - include_spip('inc/headers'); |
|
| 42 | - redirige_par_entete($redirect); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - // sinon on loge l'auteur identifie, et on finit (redirection automatique) |
|
| 46 | - auth_loger($res); |
|
| 47 | - } |
|
| 27 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 28 | + $arg = $securiser_action(); |
|
| 29 | + |
|
| 30 | + if (!preg_match(',^(\w+)[/](.+)$,', (string) $arg, $r)) { |
|
| 31 | + spip_log("action_auth_dist $arg pas compris"); |
|
| 32 | + } else { |
|
| 33 | + $auth_methode = $r[1]; |
|
| 34 | + $login = $r[2]; |
|
| 35 | + include_spip('inc/auth'); |
|
| 36 | + $res = auth_terminer_identifier_login($auth_methode, $login); |
|
| 37 | + |
|
| 38 | + if (is_string($res)) { // Erreur |
|
| 39 | + $redirect = _request('redirect'); |
|
| 40 | + $redirect = parametre_url($redirect, 'var_erreur', $res, '&'); |
|
| 41 | + include_spip('inc/headers'); |
|
| 42 | + redirige_par_entete($redirect); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + // sinon on loge l'auteur identifie, et on finit (redirection automatique) |
|
| 46 | + auth_loger($res); |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Langue |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/cookie'); |
@@ -29,21 +29,21 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | function action_converser_dist() { |
| 32 | - $update_session = false; |
|
| 33 | - if (_request('arg') && spip_connect()) { |
|
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $securiser_action(); |
|
| 36 | - $update_session = true; |
|
| 37 | - } |
|
| 32 | + $update_session = false; |
|
| 33 | + if (_request('arg') && spip_connect()) { |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $securiser_action(); |
|
| 36 | + $update_session = true; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - $lang = action_converser_changer_langue($update_session); |
|
| 40 | - $redirect = rawurldecode((string) _request('redirect')); |
|
| 39 | + $lang = action_converser_changer_langue($update_session); |
|
| 40 | + $redirect = rawurldecode((string) _request('redirect')); |
|
| 41 | 41 | |
| 42 | - if (!$redirect) { |
|
| 43 | - $redirect = _DIR_RESTREINT_ABS; |
|
| 44 | - } |
|
| 45 | - $redirect = parametre_url($redirect, 'lang', $lang, '&'); |
|
| 46 | - redirige_par_entete($redirect, true); |
|
| 42 | + if (!$redirect) { |
|
| 43 | + $redirect = _DIR_RESTREINT_ABS; |
|
| 44 | + } |
|
| 45 | + $redirect = parametre_url($redirect, 'lang', $lang, '&'); |
|
| 46 | + redirige_par_entete($redirect, true); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | * @return string |
| 56 | 56 | */ |
| 57 | 57 | function action_converser_changer_langue($update_session) { |
| 58 | - if ($lang = _request('var_lang')) { |
|
| 59 | - action_converser_post($lang); |
|
| 60 | - } elseif ($lang = _request('var_lang_ecrire')) { |
|
| 61 | - if ($update_session) { |
|
| 62 | - sql_updateq('spip_auteurs', ['lang' => $lang], 'id_auteur = ' . $GLOBALS['visiteur_session']['id_auteur']); |
|
| 63 | - $GLOBALS['visiteur_session']['lang'] = $lang; |
|
| 64 | - $session = charger_fonction('session', 'inc'); |
|
| 65 | - if ($spip_session = $session($GLOBALS['visiteur_session'])) { |
|
| 66 | - spip_setcookie('spip_session', $spip_session, [ |
|
| 67 | - 'expires' => time() + 3600 * 24 * 14 |
|
| 68 | - ]); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - action_converser_post($lang, true); |
|
| 72 | - } |
|
| 58 | + if ($lang = _request('var_lang')) { |
|
| 59 | + action_converser_post($lang); |
|
| 60 | + } elseif ($lang = _request('var_lang_ecrire')) { |
|
| 61 | + if ($update_session) { |
|
| 62 | + sql_updateq('spip_auteurs', ['lang' => $lang], 'id_auteur = ' . $GLOBALS['visiteur_session']['id_auteur']); |
|
| 63 | + $GLOBALS['visiteur_session']['lang'] = $lang; |
|
| 64 | + $session = charger_fonction('session', 'inc'); |
|
| 65 | + if ($spip_session = $session($GLOBALS['visiteur_session'])) { |
|
| 66 | + spip_setcookie('spip_session', $spip_session, [ |
|
| 67 | + 'expires' => time() + 3600 * 24 * 14 |
|
| 68 | + ]); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + action_converser_post($lang, true); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - return $lang; |
|
| 74 | + return $lang; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | 84 | function action_converser_post($lang, $ecrire = false) { |
| 85 | - if ($lang) { |
|
| 86 | - include_spip('inc/lang'); |
|
| 87 | - if (changer_langue($lang)) { |
|
| 88 | - spip_setcookie('spip_lang', $_COOKIE['spip_lang'] = $lang, [ |
|
| 89 | - 'expires' => time() + 365 * 24 * 3600 |
|
| 90 | - ]); |
|
| 91 | - if ($ecrire) { |
|
| 92 | - spip_setcookie('spip_lang_ecrire', $_COOKIE['spip_lang_ecrire'] = $lang, [ |
|
| 93 | - 'expires' => time() + 365 * 24 * 3600 |
|
| 94 | - ]); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 85 | + if ($lang) { |
|
| 86 | + include_spip('inc/lang'); |
|
| 87 | + if (changer_langue($lang)) { |
|
| 88 | + spip_setcookie('spip_lang', $_COOKIE['spip_lang'] = $lang, [ |
|
| 89 | + 'expires' => time() + 365 * 24 * 3600 |
|
| 90 | + ]); |
|
| 91 | + if ($ecrire) { |
|
| 92 | + spip_setcookie('spip_lang_ecrire', $_COOKIE['spip_lang_ecrire'] = $lang, [ |
|
| 93 | + 'expires' => time() + 365 * 24 * 3600 |
|
| 94 | + ]); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -38,36 +38,36 @@ discard block |
||
| 38 | 38 | * Liste (identifiant de l'article, texte d'erreur éventuel) |
| 39 | 39 | */ |
| 40 | 40 | function action_editer_article_dist($arg = null) { |
| 41 | - include_spip('inc/autoriser'); |
|
| 42 | - $err = ''; |
|
| 43 | - if (is_null($arg)) { |
|
| 44 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 45 | - $arg = $securiser_action(); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - // si id_article n'est pas un nombre, c'est une creation |
|
| 49 | - // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 50 | - if (!$id_article = (int) $arg) { |
|
| 51 | - $id_parent = _request('id_parent'); |
|
| 52 | - if (!$id_parent) { |
|
| 53 | - $err = _L("creation interdite d'un article sans rubrique"); |
|
| 54 | - } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) { |
|
| 55 | - $err = _T('info_creerdansrubrique_non_autorise'); |
|
| 56 | - } else { |
|
| 57 | - $id_article = article_inserer($id_parent); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - // Enregistre l'envoi dans la BD |
|
| 62 | - if ($id_article > 0) { |
|
| 63 | - $err = article_modifier($id_article); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if ($err) { |
|
| 67 | - spip_log("echec editeur article: $err", _LOG_ERREUR); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return [$id_article, $err]; |
|
| 41 | + include_spip('inc/autoriser'); |
|
| 42 | + $err = ''; |
|
| 43 | + if (is_null($arg)) { |
|
| 44 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 45 | + $arg = $securiser_action(); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + // si id_article n'est pas un nombre, c'est une creation |
|
| 49 | + // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 50 | + if (!$id_article = (int) $arg) { |
|
| 51 | + $id_parent = _request('id_parent'); |
|
| 52 | + if (!$id_parent) { |
|
| 53 | + $err = _L("creation interdite d'un article sans rubrique"); |
|
| 54 | + } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) { |
|
| 55 | + $err = _T('info_creerdansrubrique_non_autorise'); |
|
| 56 | + } else { |
|
| 57 | + $id_article = article_inserer($id_parent); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + // Enregistre l'envoi dans la BD |
|
| 62 | + if ($id_article > 0) { |
|
| 63 | + $err = article_modifier($id_article); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if ($err) { |
|
| 67 | + spip_log("echec editeur article: $err", _LOG_ERREUR); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return [$id_article, $err]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -89,49 +89,49 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | function article_modifier($id_article, $set = null) { |
| 91 | 91 | |
| 92 | - // unifier $texte en cas de texte trop long |
|
| 93 | - trop_longs_articles(); |
|
| 94 | - |
|
| 95 | - include_spip('inc/modifier'); |
|
| 96 | - include_spip('inc/filtres'); |
|
| 97 | - $c = collecter_requests( |
|
| 98 | - // include list |
|
| 99 | - objet_info('article', 'champs_editables'), |
|
| 100 | - // exclude list |
|
| 101 | - ['date', 'statut', 'id_parent'], |
|
| 102 | - // donnees eventuellement fournies |
|
| 103 | - $set |
|
| 104 | - ); |
|
| 105 | - |
|
| 106 | - // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 107 | - $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id_article); |
|
| 108 | - $invalideur = $indexation = false; |
|
| 109 | - if ($t == 'publie') { |
|
| 110 | - $invalideur = "id='article/$id_article'"; |
|
| 111 | - $indexation = true; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - if ( |
|
| 115 | - $err = objet_modifier_champs( |
|
| 116 | - 'article', |
|
| 117 | - $id_article, |
|
| 118 | - [ |
|
| 119 | - 'data' => $set, |
|
| 120 | - 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 121 | - 'invalideur' => $invalideur, |
|
| 122 | - 'indexation' => $indexation, |
|
| 123 | - 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 124 | - ], |
|
| 125 | - $c |
|
| 126 | - ) |
|
| 127 | - ) { |
|
| 128 | - return $err; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - // Modification de statut, changement de rubrique ? |
|
| 132 | - $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set); |
|
| 133 | - |
|
| 134 | - return article_instituer($id_article, $c); |
|
| 92 | + // unifier $texte en cas de texte trop long |
|
| 93 | + trop_longs_articles(); |
|
| 94 | + |
|
| 95 | + include_spip('inc/modifier'); |
|
| 96 | + include_spip('inc/filtres'); |
|
| 97 | + $c = collecter_requests( |
|
| 98 | + // include list |
|
| 99 | + objet_info('article', 'champs_editables'), |
|
| 100 | + // exclude list |
|
| 101 | + ['date', 'statut', 'id_parent'], |
|
| 102 | + // donnees eventuellement fournies |
|
| 103 | + $set |
|
| 104 | + ); |
|
| 105 | + |
|
| 106 | + // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 107 | + $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id_article); |
|
| 108 | + $invalideur = $indexation = false; |
|
| 109 | + if ($t == 'publie') { |
|
| 110 | + $invalideur = "id='article/$id_article'"; |
|
| 111 | + $indexation = true; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + if ( |
|
| 115 | + $err = objet_modifier_champs( |
|
| 116 | + 'article', |
|
| 117 | + $id_article, |
|
| 118 | + [ |
|
| 119 | + 'data' => $set, |
|
| 120 | + 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 121 | + 'invalideur' => $invalideur, |
|
| 122 | + 'indexation' => $indexation, |
|
| 123 | + 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 124 | + ], |
|
| 125 | + $c |
|
| 126 | + ) |
|
| 127 | + ) { |
|
| 128 | + return $err; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + // Modification de statut, changement de rubrique ? |
|
| 132 | + $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set); |
|
| 133 | + |
|
| 134 | + return article_instituer($id_article, $c); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -167,120 +167,120 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | function article_inserer($id_rubrique, $set = null) { |
| 169 | 169 | |
| 170 | - // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 171 | - // dans la premiere rubrique racine |
|
| 172 | - if (!$id_rubrique = (int) $id_rubrique) { |
|
| 173 | - $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 174 | - $id_rubrique = $row['id_rubrique']; |
|
| 175 | - } else { |
|
| 176 | - $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 180 | - // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 181 | - $id_secteur = $row['id_secteur'] ?? 0; |
|
| 182 | - $lang_rub = $row['lang'] ?? ''; |
|
| 183 | - |
|
| 184 | - $lang = ''; |
|
| 185 | - $choisie = 'non'; |
|
| 186 | - // La langue a la creation : si les liens de traduction sont autorises |
|
| 187 | - // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 188 | - // ou a defaut celle de la rubrique |
|
| 189 | - // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 190 | - if ( |
|
| 191 | - !empty($GLOBALS['meta']['multi_objets']) && in_array( |
|
| 192 | - 'spip_articles', |
|
| 193 | - explode(',', (string) $GLOBALS['meta']['multi_objets']) |
|
| 194 | - ) |
|
| 195 | - ) { |
|
| 196 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 197 | - if ( |
|
| 198 | - in_array( |
|
| 199 | - $GLOBALS['spip_lang'], |
|
| 200 | - explode(',', (string) $GLOBALS['meta']['langues_multilingue']) |
|
| 201 | - ) |
|
| 202 | - ) { |
|
| 203 | - $lang = $GLOBALS['spip_lang']; |
|
| 204 | - $choisie = 'oui'; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - if (!$lang) { |
|
| 209 | - $choisie = 'non'; |
|
| 210 | - $lang = $lang_rub ?: $GLOBALS['meta']['langue_site']; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - $champs = [ |
|
| 214 | - 'id_rubrique' => $id_rubrique, |
|
| 215 | - 'id_secteur' => $id_secteur, |
|
| 216 | - 'statut' => 'prepa', |
|
| 217 | - 'date' => date('Y-m-d H:i:s'), |
|
| 218 | - 'lang' => $lang, |
|
| 219 | - 'langue_choisie' => $choisie |
|
| 220 | - ]; |
|
| 221 | - |
|
| 222 | - if ($set) { |
|
| 223 | - $champs = array_merge($champs, $set); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - // Envoyer aux plugins |
|
| 227 | - $champs = pipeline( |
|
| 228 | - 'pre_insertion', |
|
| 229 | - [ |
|
| 230 | - 'args' => [ |
|
| 231 | - 'table' => 'spip_articles', |
|
| 232 | - ], |
|
| 233 | - 'data' => $champs |
|
| 234 | - ] |
|
| 235 | - ); |
|
| 236 | - |
|
| 237 | - $id_article = sql_insertq('spip_articles', $champs); |
|
| 238 | - |
|
| 239 | - // controler si le serveur n'a pas renvoye une erreur |
|
| 240 | - if ($id_article > 0) { |
|
| 241 | - $id_auteur = ((is_null(_request('id_auteur')) && isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 242 | - $GLOBALS['visiteur_session']['id_auteur'] |
|
| 243 | - : _request('id_auteur')); |
|
| 244 | - if ($id_auteur) { |
|
| 245 | - include_spip('action/editer_auteur'); |
|
| 246 | - auteur_associer($id_auteur, ['article' => $id_article]); |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - pipeline( |
|
| 251 | - 'post_insertion', |
|
| 252 | - [ |
|
| 253 | - 'args' => [ |
|
| 254 | - 'table' => 'spip_articles', |
|
| 255 | - 'id_objet' => $id_article |
|
| 256 | - ], |
|
| 257 | - 'data' => $champs |
|
| 258 | - ] |
|
| 259 | - ); |
|
| 260 | - |
|
| 261 | - // Appeler une notification |
|
| 262 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 263 | - $notifications( |
|
| 264 | - 'article_inserer', |
|
| 265 | - $id_article, |
|
| 266 | - [ |
|
| 267 | - 'id_parent' => $id_rubrique, |
|
| 268 | - 'champs' => $champs, |
|
| 269 | - ] |
|
| 270 | - ); |
|
| 271 | - $notifications( |
|
| 272 | - 'objet_inserer', |
|
| 273 | - $id_article, |
|
| 274 | - [ |
|
| 275 | - 'objet' => 'article', |
|
| 276 | - 'id_objet' => $id_article, |
|
| 277 | - 'id_parent' => $id_rubrique, |
|
| 278 | - 'champs' => $champs, |
|
| 279 | - ] |
|
| 280 | - ); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - return $id_article; |
|
| 170 | + // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 171 | + // dans la premiere rubrique racine |
|
| 172 | + if (!$id_rubrique = (int) $id_rubrique) { |
|
| 173 | + $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 174 | + $id_rubrique = $row['id_rubrique']; |
|
| 175 | + } else { |
|
| 176 | + $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 180 | + // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 181 | + $id_secteur = $row['id_secteur'] ?? 0; |
|
| 182 | + $lang_rub = $row['lang'] ?? ''; |
|
| 183 | + |
|
| 184 | + $lang = ''; |
|
| 185 | + $choisie = 'non'; |
|
| 186 | + // La langue a la creation : si les liens de traduction sont autorises |
|
| 187 | + // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 188 | + // ou a defaut celle de la rubrique |
|
| 189 | + // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 190 | + if ( |
|
| 191 | + !empty($GLOBALS['meta']['multi_objets']) && in_array( |
|
| 192 | + 'spip_articles', |
|
| 193 | + explode(',', (string) $GLOBALS['meta']['multi_objets']) |
|
| 194 | + ) |
|
| 195 | + ) { |
|
| 196 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 197 | + if ( |
|
| 198 | + in_array( |
|
| 199 | + $GLOBALS['spip_lang'], |
|
| 200 | + explode(',', (string) $GLOBALS['meta']['langues_multilingue']) |
|
| 201 | + ) |
|
| 202 | + ) { |
|
| 203 | + $lang = $GLOBALS['spip_lang']; |
|
| 204 | + $choisie = 'oui'; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + if (!$lang) { |
|
| 209 | + $choisie = 'non'; |
|
| 210 | + $lang = $lang_rub ?: $GLOBALS['meta']['langue_site']; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + $champs = [ |
|
| 214 | + 'id_rubrique' => $id_rubrique, |
|
| 215 | + 'id_secteur' => $id_secteur, |
|
| 216 | + 'statut' => 'prepa', |
|
| 217 | + 'date' => date('Y-m-d H:i:s'), |
|
| 218 | + 'lang' => $lang, |
|
| 219 | + 'langue_choisie' => $choisie |
|
| 220 | + ]; |
|
| 221 | + |
|
| 222 | + if ($set) { |
|
| 223 | + $champs = array_merge($champs, $set); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + // Envoyer aux plugins |
|
| 227 | + $champs = pipeline( |
|
| 228 | + 'pre_insertion', |
|
| 229 | + [ |
|
| 230 | + 'args' => [ |
|
| 231 | + 'table' => 'spip_articles', |
|
| 232 | + ], |
|
| 233 | + 'data' => $champs |
|
| 234 | + ] |
|
| 235 | + ); |
|
| 236 | + |
|
| 237 | + $id_article = sql_insertq('spip_articles', $champs); |
|
| 238 | + |
|
| 239 | + // controler si le serveur n'a pas renvoye une erreur |
|
| 240 | + if ($id_article > 0) { |
|
| 241 | + $id_auteur = ((is_null(_request('id_auteur')) && isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 242 | + $GLOBALS['visiteur_session']['id_auteur'] |
|
| 243 | + : _request('id_auteur')); |
|
| 244 | + if ($id_auteur) { |
|
| 245 | + include_spip('action/editer_auteur'); |
|
| 246 | + auteur_associer($id_auteur, ['article' => $id_article]); |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + pipeline( |
|
| 251 | + 'post_insertion', |
|
| 252 | + [ |
|
| 253 | + 'args' => [ |
|
| 254 | + 'table' => 'spip_articles', |
|
| 255 | + 'id_objet' => $id_article |
|
| 256 | + ], |
|
| 257 | + 'data' => $champs |
|
| 258 | + ] |
|
| 259 | + ); |
|
| 260 | + |
|
| 261 | + // Appeler une notification |
|
| 262 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 263 | + $notifications( |
|
| 264 | + 'article_inserer', |
|
| 265 | + $id_article, |
|
| 266 | + [ |
|
| 267 | + 'id_parent' => $id_rubrique, |
|
| 268 | + 'champs' => $champs, |
|
| 269 | + ] |
|
| 270 | + ); |
|
| 271 | + $notifications( |
|
| 272 | + 'objet_inserer', |
|
| 273 | + $id_article, |
|
| 274 | + [ |
|
| 275 | + 'objet' => 'article', |
|
| 276 | + 'id_objet' => $id_article, |
|
| 277 | + 'id_parent' => $id_rubrique, |
|
| 278 | + 'champs' => $champs, |
|
| 279 | + ] |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + return $id_article; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
@@ -308,151 +308,151 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | function article_instituer($id_article, $c, $calcul_rub = true) { |
| 310 | 310 | |
| 311 | - include_spip('inc/autoriser'); |
|
| 312 | - include_spip('inc/rubriques'); |
|
| 313 | - include_spip('inc/modifier'); |
|
| 314 | - |
|
| 315 | - $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article"); |
|
| 316 | - $id_rubrique = $row['id_rubrique']; |
|
| 317 | - $statut_ancien = $statut = $row['statut']; |
|
| 318 | - $date_ancienne = $date = $row['date']; |
|
| 319 | - $champs = []; |
|
| 320 | - |
|
| 321 | - $d = $c['date'] ?? null; |
|
| 322 | - $s = $c['statut'] ?? $statut; |
|
| 323 | - |
|
| 324 | - // cf autorisations dans inc/instituer_article |
|
| 325 | - if ($s != $statut || $d && $d != $date) { |
|
| 326 | - if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 327 | - $statut = $champs['statut'] = $s; |
|
| 328 | - } elseif (autoriser('modifier', 'article', $id_article) && $s != 'publie') { |
|
| 329 | - $statut = $champs['statut'] = $s; |
|
| 330 | - } else { |
|
| 331 | - spip_log("editer_article $id_article refus " . implode(' ', $c)); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - // En cas de publication, fixer la date a "maintenant" |
|
| 335 | - // sauf si $c commande autre chose |
|
| 336 | - // ou si l'article est deja date dans le futur |
|
| 337 | - // En cas de proposition d'un article (mais pas depublication), idem |
|
| 338 | - if ( |
|
| 339 | - $champs['statut'] == 'publie' |
|
| 340 | - || $champs['statut'] == 'prop' && ($d || !in_array($statut_ancien, ['publie', 'prop'])) |
|
| 341 | - ) { |
|
| 342 | - $champs['date'] = $d || strtotime((string) ($d = $date)) > time() |
|
| 343 | - ? $date = $d |
|
| 344 | - : ($date = date('Y-m-d H:i:s')); |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - // Verifier que la rubrique demandee existe et est differente |
|
| 349 | - // de la rubrique actuelle |
|
| 350 | - if ( |
|
| 351 | - isset($c['id_parent']) |
|
| 352 | - && ($id_parent = $c['id_parent']) |
|
| 353 | - && $id_parent != $id_rubrique |
|
| 354 | - && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 355 | - ) { |
|
| 356 | - $champs['id_rubrique'] = $id_parent; |
|
| 357 | - |
|
| 358 | - // si l'article etait publie |
|
| 359 | - // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 360 | - // repasser l'article en statut 'propose'. |
|
| 361 | - if ( |
|
| 362 | - $statut == 'publie' |
|
| 363 | - && !autoriser('publierdans', 'rubrique', $id_parent) |
|
| 364 | - ) { |
|
| 365 | - $champs['statut'] = 'prop'; |
|
| 366 | - } |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - // Envoyer aux plugins |
|
| 370 | - $champs = pipeline( |
|
| 371 | - 'pre_edition', |
|
| 372 | - [ |
|
| 373 | - 'args' => [ |
|
| 374 | - 'table' => 'spip_articles', |
|
| 375 | - 'id_objet' => $id_article, |
|
| 376 | - 'action' => 'instituer', |
|
| 377 | - 'statut_ancien' => $statut_ancien, |
|
| 378 | - 'date_ancienne' => $date_ancienne, |
|
| 379 | - ], |
|
| 380 | - 'data' => $champs |
|
| 381 | - ] |
|
| 382 | - ); |
|
| 383 | - |
|
| 384 | - if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 385 | - return ''; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - // Envoyer les modifs. |
|
| 389 | - editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 390 | - |
|
| 391 | - // Invalider les caches |
|
| 392 | - include_spip('inc/invalideur'); |
|
| 393 | - suivre_invalideur("id='article/$id_article'"); |
|
| 394 | - |
|
| 395 | - if ($date) { |
|
| 396 | - $t = strtotime((string) $date); |
|
| 397 | - $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 398 | - if ($t > time() && (!$p || $t < $p)) { |
|
| 399 | - ecrire_meta('date_prochain_postdate', $t); |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - // Pipeline |
|
| 404 | - pipeline( |
|
| 405 | - 'post_edition', |
|
| 406 | - [ |
|
| 407 | - 'args' => [ |
|
| 408 | - 'table' => 'spip_articles', |
|
| 409 | - 'id_objet' => $id_article, |
|
| 410 | - 'action' => 'instituer', |
|
| 411 | - 'statut_ancien' => $statut_ancien, |
|
| 412 | - 'date_ancienne' => $date_ancienne, |
|
| 413 | - ], |
|
| 414 | - 'data' => $champs |
|
| 415 | - ] |
|
| 416 | - ); |
|
| 417 | - |
|
| 418 | - // Notifications |
|
| 419 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 420 | - $notifications( |
|
| 421 | - 'article_instituer', |
|
| 422 | - $id_article, |
|
| 423 | - [ |
|
| 424 | - 'statut' => $statut, |
|
| 425 | - 'statut_ancien' => $statut_ancien, |
|
| 426 | - 'date' => $date, |
|
| 427 | - 'date_ancienne' => $date_ancienne, |
|
| 428 | - 'id_parent_ancien' => $id_rubrique, |
|
| 429 | - 'champs' => $champs, |
|
| 430 | - ] |
|
| 431 | - ); |
|
| 432 | - $notifications( |
|
| 433 | - 'objet_instituer', |
|
| 434 | - $id_article, |
|
| 435 | - [ |
|
| 436 | - 'objet' => 'article', |
|
| 437 | - 'id_objet' => $id_article, |
|
| 438 | - 'statut' => $statut, |
|
| 439 | - 'statut_ancien' => $statut_ancien, |
|
| 440 | - 'date' => $date, |
|
| 441 | - 'date_ancienne' => $date_ancienne, |
|
| 442 | - 'id_parent_ancien' => $id_rubrique, |
|
| 443 | - 'champs' => $champs, |
|
| 444 | - ] |
|
| 445 | - ); |
|
| 446 | - |
|
| 447 | - // Rétro-compat |
|
| 448 | - $notifications( |
|
| 449 | - 'instituerarticle', |
|
| 450 | - $id_article, |
|
| 451 | - ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 452 | - ); |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - return ''; // pas d'erreur |
|
| 311 | + include_spip('inc/autoriser'); |
|
| 312 | + include_spip('inc/rubriques'); |
|
| 313 | + include_spip('inc/modifier'); |
|
| 314 | + |
|
| 315 | + $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article"); |
|
| 316 | + $id_rubrique = $row['id_rubrique']; |
|
| 317 | + $statut_ancien = $statut = $row['statut']; |
|
| 318 | + $date_ancienne = $date = $row['date']; |
|
| 319 | + $champs = []; |
|
| 320 | + |
|
| 321 | + $d = $c['date'] ?? null; |
|
| 322 | + $s = $c['statut'] ?? $statut; |
|
| 323 | + |
|
| 324 | + // cf autorisations dans inc/instituer_article |
|
| 325 | + if ($s != $statut || $d && $d != $date) { |
|
| 326 | + if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 327 | + $statut = $champs['statut'] = $s; |
|
| 328 | + } elseif (autoriser('modifier', 'article', $id_article) && $s != 'publie') { |
|
| 329 | + $statut = $champs['statut'] = $s; |
|
| 330 | + } else { |
|
| 331 | + spip_log("editer_article $id_article refus " . implode(' ', $c)); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + // En cas de publication, fixer la date a "maintenant" |
|
| 335 | + // sauf si $c commande autre chose |
|
| 336 | + // ou si l'article est deja date dans le futur |
|
| 337 | + // En cas de proposition d'un article (mais pas depublication), idem |
|
| 338 | + if ( |
|
| 339 | + $champs['statut'] == 'publie' |
|
| 340 | + || $champs['statut'] == 'prop' && ($d || !in_array($statut_ancien, ['publie', 'prop'])) |
|
| 341 | + ) { |
|
| 342 | + $champs['date'] = $d || strtotime((string) ($d = $date)) > time() |
|
| 343 | + ? $date = $d |
|
| 344 | + : ($date = date('Y-m-d H:i:s')); |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + // Verifier que la rubrique demandee existe et est differente |
|
| 349 | + // de la rubrique actuelle |
|
| 350 | + if ( |
|
| 351 | + isset($c['id_parent']) |
|
| 352 | + && ($id_parent = $c['id_parent']) |
|
| 353 | + && $id_parent != $id_rubrique |
|
| 354 | + && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 355 | + ) { |
|
| 356 | + $champs['id_rubrique'] = $id_parent; |
|
| 357 | + |
|
| 358 | + // si l'article etait publie |
|
| 359 | + // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 360 | + // repasser l'article en statut 'propose'. |
|
| 361 | + if ( |
|
| 362 | + $statut == 'publie' |
|
| 363 | + && !autoriser('publierdans', 'rubrique', $id_parent) |
|
| 364 | + ) { |
|
| 365 | + $champs['statut'] = 'prop'; |
|
| 366 | + } |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + // Envoyer aux plugins |
|
| 370 | + $champs = pipeline( |
|
| 371 | + 'pre_edition', |
|
| 372 | + [ |
|
| 373 | + 'args' => [ |
|
| 374 | + 'table' => 'spip_articles', |
|
| 375 | + 'id_objet' => $id_article, |
|
| 376 | + 'action' => 'instituer', |
|
| 377 | + 'statut_ancien' => $statut_ancien, |
|
| 378 | + 'date_ancienne' => $date_ancienne, |
|
| 379 | + ], |
|
| 380 | + 'data' => $champs |
|
| 381 | + ] |
|
| 382 | + ); |
|
| 383 | + |
|
| 384 | + if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 385 | + return ''; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + // Envoyer les modifs. |
|
| 389 | + editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 390 | + |
|
| 391 | + // Invalider les caches |
|
| 392 | + include_spip('inc/invalideur'); |
|
| 393 | + suivre_invalideur("id='article/$id_article'"); |
|
| 394 | + |
|
| 395 | + if ($date) { |
|
| 396 | + $t = strtotime((string) $date); |
|
| 397 | + $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 398 | + if ($t > time() && (!$p || $t < $p)) { |
|
| 399 | + ecrire_meta('date_prochain_postdate', $t); |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + // Pipeline |
|
| 404 | + pipeline( |
|
| 405 | + 'post_edition', |
|
| 406 | + [ |
|
| 407 | + 'args' => [ |
|
| 408 | + 'table' => 'spip_articles', |
|
| 409 | + 'id_objet' => $id_article, |
|
| 410 | + 'action' => 'instituer', |
|
| 411 | + 'statut_ancien' => $statut_ancien, |
|
| 412 | + 'date_ancienne' => $date_ancienne, |
|
| 413 | + ], |
|
| 414 | + 'data' => $champs |
|
| 415 | + ] |
|
| 416 | + ); |
|
| 417 | + |
|
| 418 | + // Notifications |
|
| 419 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 420 | + $notifications( |
|
| 421 | + 'article_instituer', |
|
| 422 | + $id_article, |
|
| 423 | + [ |
|
| 424 | + 'statut' => $statut, |
|
| 425 | + 'statut_ancien' => $statut_ancien, |
|
| 426 | + 'date' => $date, |
|
| 427 | + 'date_ancienne' => $date_ancienne, |
|
| 428 | + 'id_parent_ancien' => $id_rubrique, |
|
| 429 | + 'champs' => $champs, |
|
| 430 | + ] |
|
| 431 | + ); |
|
| 432 | + $notifications( |
|
| 433 | + 'objet_instituer', |
|
| 434 | + $id_article, |
|
| 435 | + [ |
|
| 436 | + 'objet' => 'article', |
|
| 437 | + 'id_objet' => $id_article, |
|
| 438 | + 'statut' => $statut, |
|
| 439 | + 'statut_ancien' => $statut_ancien, |
|
| 440 | + 'date' => $date, |
|
| 441 | + 'date_ancienne' => $date_ancienne, |
|
| 442 | + 'id_parent_ancien' => $id_rubrique, |
|
| 443 | + 'champs' => $champs, |
|
| 444 | + ] |
|
| 445 | + ); |
|
| 446 | + |
|
| 447 | + // Rétro-compat |
|
| 448 | + $notifications( |
|
| 449 | + 'instituerarticle', |
|
| 450 | + $id_article, |
|
| 451 | + ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 452 | + ); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + return ''; // pas d'erreur |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -477,37 +477,37 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond = true) { |
| 479 | 479 | |
| 480 | - // Si on deplace l'article |
|
| 481 | - // changer aussi son secteur et sa langue (si heritee) |
|
| 482 | - if (isset($champs['id_rubrique'])) { |
|
| 483 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 484 | - |
|
| 485 | - $langue = $row_rub['lang']; |
|
| 486 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 487 | - if ( |
|
| 488 | - sql_fetsel( |
|
| 489 | - '1', |
|
| 490 | - 'spip_articles', |
|
| 491 | - 'id_article=' . (int) $id_article . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 492 | - ) |
|
| 493 | - ) { |
|
| 494 | - $champs['lang'] = $langue; |
|
| 495 | - } |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - if (!$champs) { |
|
| 499 | - return; |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - sql_updateq('spip_articles', $champs, 'id_article=' . (int) $id_article); |
|
| 503 | - |
|
| 504 | - // Changer le statut des rubriques concernees |
|
| 505 | - |
|
| 506 | - if ($cond) { |
|
| 507 | - include_spip('inc/rubriques'); |
|
| 508 | - $postdate = ($GLOBALS['meta']['post_dates'] == 'non' && isset($champs['date']) && strtotime((string) $champs['date']) < time()) ? $champs['date'] : false; |
|
| 509 | - calculer_rubriques_if($id_rubrique, $champs, ['statut_ancien' => $statut], $postdate); |
|
| 510 | - } |
|
| 480 | + // Si on deplace l'article |
|
| 481 | + // changer aussi son secteur et sa langue (si heritee) |
|
| 482 | + if (isset($champs['id_rubrique'])) { |
|
| 483 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 484 | + |
|
| 485 | + $langue = $row_rub['lang']; |
|
| 486 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 487 | + if ( |
|
| 488 | + sql_fetsel( |
|
| 489 | + '1', |
|
| 490 | + 'spip_articles', |
|
| 491 | + 'id_article=' . (int) $id_article . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 492 | + ) |
|
| 493 | + ) { |
|
| 494 | + $champs['lang'] = $langue; |
|
| 495 | + } |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + if (!$champs) { |
|
| 499 | + return; |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + sql_updateq('spip_articles', $champs, 'id_article=' . (int) $id_article); |
|
| 503 | + |
|
| 504 | + // Changer le statut des rubriques concernees |
|
| 505 | + |
|
| 506 | + if ($cond) { |
|
| 507 | + include_spip('inc/rubriques'); |
|
| 508 | + $postdate = ($GLOBALS['meta']['post_dates'] == 'non' && isset($champs['date']) && strtotime((string) $champs['date']) < time()) ? $champs['date'] : false; |
|
| 509 | + calculer_rubriques_if($id_rubrique, $champs, ['statut_ancien' => $statut], $postdate); |
|
| 510 | + } |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | /** |
@@ -516,10 +516,10 @@ discard block |
||
| 516 | 516 | * @return void |
| 517 | 517 | */ |
| 518 | 518 | function trop_longs_articles() { |
| 519 | - if (is_array($plus = _request('texte_plus'))) { |
|
| 520 | - foreach ($plus as $n => $t) { |
|
| 521 | - $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', (string) $t); |
|
| 522 | - } |
|
| 523 | - set_request('texte', implode('', $plus) . _request('texte')); |
|
| 524 | - } |
|
| 519 | + if (is_array($plus = _request('texte_plus'))) { |
|
| 520 | + foreach ($plus as $n => $t) { |
|
| 521 | + $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', (string) $t); |
|
| 522 | + } |
|
| 523 | + set_request('texte', implode('', $plus) . _request('texte')); |
|
| 524 | + } |
|
| 525 | 525 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | 106 | // Si l'article est publie, invalider les caches et demander sa reindexation |
| 107 | - $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id_article); |
|
| 107 | + $t = sql_getfetsel('statut', 'spip_articles', 'id_article='.(int) $id_article); |
|
| 108 | 108 | $invalideur = $indexation = false; |
| 109 | 109 | if ($t == 'publie') { |
| 110 | 110 | $invalideur = "id='article/$id_article'"; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $id_article, |
| 118 | 118 | [ |
| 119 | 119 | 'data' => $set, |
| 120 | - 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 120 | + 'nonvide' => ['titre' => _T('info_nouvel_article').' '._T('info_numero_abbreviation').$id_article], |
|
| 121 | 121 | 'invalideur' => $invalideur, |
| 122 | 122 | 'indexation' => $indexation, |
| 123 | 123 | 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | } elseif (autoriser('modifier', 'article', $id_article) && $s != 'publie') { |
| 329 | 329 | $statut = $champs['statut'] = $s; |
| 330 | 330 | } else { |
| 331 | - spip_log("editer_article $id_article refus " . implode(' ', $c)); |
|
| 331 | + spip_log("editer_article $id_article refus ".implode(' ', $c)); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // En cas de publication, fixer la date a "maintenant" |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | isset($c['id_parent']) |
| 352 | 352 | && ($id_parent = $c['id_parent']) |
| 353 | 353 | && $id_parent != $id_rubrique |
| 354 | - && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 354 | + && sql_fetsel('1', 'spip_rubriques', 'id_rubrique='.(int) $id_parent) |
|
| 355 | 355 | ) { |
| 356 | 356 | $champs['id_rubrique'] = $id_parent; |
| 357 | 357 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | // Si on deplace l'article |
| 481 | 481 | // changer aussi son secteur et sa langue (si heritee) |
| 482 | 482 | if (isset($champs['id_rubrique'])) { |
| 483 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 483 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique='.sql_quote($champs['id_rubrique'])); |
|
| 484 | 484 | |
| 485 | 485 | $langue = $row_rub['lang']; |
| 486 | 486 | $champs['id_secteur'] = $row_rub['id_secteur']; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | sql_fetsel( |
| 489 | 489 | '1', |
| 490 | 490 | 'spip_articles', |
| 491 | - 'id_article=' . (int) $id_article . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 491 | + 'id_article='.(int) $id_article." AND langue_choisie<>'oui' AND lang<>".sql_quote($langue) |
|
| 492 | 492 | ) |
| 493 | 493 | ) { |
| 494 | 494 | $champs['lang'] = $langue; |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | return; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - sql_updateq('spip_articles', $champs, 'id_article=' . (int) $id_article); |
|
| 502 | + sql_updateq('spip_articles', $champs, 'id_article='.(int) $id_article); |
|
| 503 | 503 | |
| 504 | 504 | // Changer le statut des rubriques concernees |
| 505 | 505 | |
@@ -520,6 +520,6 @@ discard block |
||
| 520 | 520 | foreach ($plus as $n => $t) { |
| 521 | 521 | $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', (string) $t); |
| 522 | 522 | } |
| 523 | - set_request('texte', implode('', $plus) . _request('texte')); |
|
| 523 | + set_request('texte', implode('', $plus)._request('texte')); |
|
| 524 | 524 | } |
| 525 | 525 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/cookie'); |
@@ -33,72 +33,72 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | */ |
| 35 | 35 | function action_logout_dist() { |
| 36 | - $logout = _request('logout'); |
|
| 37 | - $url = securiser_redirect_action(_request('url')); |
|
| 38 | - // cas particulier, logout dans l'espace public |
|
| 39 | - if ($logout == 'public' && !$url) { |
|
| 40 | - $url = url_de_base(); |
|
| 41 | - } |
|
| 36 | + $logout = _request('logout'); |
|
| 37 | + $url = securiser_redirect_action(_request('url')); |
|
| 38 | + // cas particulier, logout dans l'espace public |
|
| 39 | + if ($logout == 'public' && !$url) { |
|
| 40 | + $url = url_de_base(); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee) |
|
| 44 | - if ( |
|
| 45 | - isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 46 | - && is_numeric($GLOBALS['visiteur_session']['id_auteur']) |
|
| 47 | - && isset($GLOBALS['visiteur_session']['statut']) |
|
| 48 | - ) { |
|
| 49 | - // il faut un jeton pour fermer la session (eviter les CSRF) |
|
| 50 | - if ( |
|
| 51 | - !($jeton = _request('jeton')) |
|
| 52 | - || !verifier_jeton_logout($jeton, $GLOBALS['visiteur_session']) |
|
| 53 | - ) { |
|
| 54 | - $jeton = generer_jeton_logout($GLOBALS['visiteur_session']); |
|
| 55 | - $action = generer_url_action('logout', "jeton=$jeton"); |
|
| 56 | - $action = parametre_url($action, 'logout', _request('logout')); |
|
| 57 | - $action = parametre_url($action, 'url', _request('url')); |
|
| 58 | - include_spip('inc/minipres'); |
|
| 59 | - include_spip('inc/filtres'); |
|
| 60 | - $texte = bouton_action(_T('spip:icone_deconnecter'), $action); |
|
| 61 | - $texte = "<div class='boutons'>$texte</div>"; |
|
| 62 | - $texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>'; |
|
| 63 | - $res = minipres(_T('spip:icone_deconnecter'), $texte, ['all_inline' => true]); |
|
| 64 | - echo $res; |
|
| 43 | + // seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee) |
|
| 44 | + if ( |
|
| 45 | + isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 46 | + && is_numeric($GLOBALS['visiteur_session']['id_auteur']) |
|
| 47 | + && isset($GLOBALS['visiteur_session']['statut']) |
|
| 48 | + ) { |
|
| 49 | + // il faut un jeton pour fermer la session (eviter les CSRF) |
|
| 50 | + if ( |
|
| 51 | + !($jeton = _request('jeton')) |
|
| 52 | + || !verifier_jeton_logout($jeton, $GLOBALS['visiteur_session']) |
|
| 53 | + ) { |
|
| 54 | + $jeton = generer_jeton_logout($GLOBALS['visiteur_session']); |
|
| 55 | + $action = generer_url_action('logout', "jeton=$jeton"); |
|
| 56 | + $action = parametre_url($action, 'logout', _request('logout')); |
|
| 57 | + $action = parametre_url($action, 'url', _request('url')); |
|
| 58 | + include_spip('inc/minipres'); |
|
| 59 | + include_spip('inc/filtres'); |
|
| 60 | + $texte = bouton_action(_T('spip:icone_deconnecter'), $action); |
|
| 61 | + $texte = "<div class='boutons'>$texte</div>"; |
|
| 62 | + $texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>'; |
|
| 63 | + $res = minipres(_T('spip:icone_deconnecter'), $texte, ['all_inline' => true]); |
|
| 64 | + echo $res; |
|
| 65 | 65 | |
| 66 | - return; |
|
| 67 | - } |
|
| 66 | + return; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - include_spip('inc/auth'); |
|
| 70 | - auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00'); |
|
| 71 | - // le logout explicite vaut destruction de toutes les sessions |
|
| 72 | - if (isset($_COOKIE['spip_session'])) { |
|
| 73 | - $session = charger_fonction('session', 'inc'); |
|
| 74 | - $session($GLOBALS['visiteur_session']['id_auteur']); |
|
| 75 | - spip_setcookie('spip_session', $_COOKIE['spip_session'], [ |
|
| 76 | - 'expires' => time() - 3600 |
|
| 77 | - ]); |
|
| 78 | - } |
|
| 79 | - // si authentification http, et que la personne est loge, |
|
| 80 | - // pour se deconnecter, il faut proposer un nouveau formulaire de connexion http |
|
| 81 | - if ( |
|
| 82 | - isset($_SERVER['PHP_AUTH_USER']) |
|
| 83 | - && !$GLOBALS['ignore_auth_http'] |
|
| 84 | - && $GLOBALS['auth_can_disconnect'] |
|
| 85 | - ) { |
|
| 86 | - ask_php_auth( |
|
| 87 | - _T('login_deconnexion_ok'), |
|
| 88 | - _T('login_verifiez_navigateur'), |
|
| 89 | - _T('login_retour_public'), |
|
| 90 | - 'redirect=' . _DIR_RESTREINT_ABS, |
|
| 91 | - _T('login_test_navigateur'), |
|
| 92 | - true |
|
| 93 | - ); |
|
| 94 | - } |
|
| 95 | - } |
|
| 69 | + include_spip('inc/auth'); |
|
| 70 | + auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00'); |
|
| 71 | + // le logout explicite vaut destruction de toutes les sessions |
|
| 72 | + if (isset($_COOKIE['spip_session'])) { |
|
| 73 | + $session = charger_fonction('session', 'inc'); |
|
| 74 | + $session($GLOBALS['visiteur_session']['id_auteur']); |
|
| 75 | + spip_setcookie('spip_session', $_COOKIE['spip_session'], [ |
|
| 76 | + 'expires' => time() - 3600 |
|
| 77 | + ]); |
|
| 78 | + } |
|
| 79 | + // si authentification http, et que la personne est loge, |
|
| 80 | + // pour se deconnecter, il faut proposer un nouveau formulaire de connexion http |
|
| 81 | + if ( |
|
| 82 | + isset($_SERVER['PHP_AUTH_USER']) |
|
| 83 | + && !$GLOBALS['ignore_auth_http'] |
|
| 84 | + && $GLOBALS['auth_can_disconnect'] |
|
| 85 | + ) { |
|
| 86 | + ask_php_auth( |
|
| 87 | + _T('login_deconnexion_ok'), |
|
| 88 | + _T('login_verifiez_navigateur'), |
|
| 89 | + _T('login_retour_public'), |
|
| 90 | + 'redirect=' . _DIR_RESTREINT_ABS, |
|
| 91 | + _T('login_test_navigateur'), |
|
| 92 | + true |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - // Rediriger en contrant le cache navigateur (Safari3) |
|
| 98 | - include_spip('inc/headers'); |
|
| 99 | - redirige_par_entete($url |
|
| 100 | - ? parametre_url($url, 'var_hasard', uniqid(random_int(0, mt_getrandmax())), '&') |
|
| 101 | - : generer_url_public('login')); |
|
| 97 | + // Rediriger en contrant le cache navigateur (Safari3) |
|
| 98 | + include_spip('inc/headers'); |
|
| 99 | + redirige_par_entete($url |
|
| 100 | + ? parametre_url($url, 'var_hasard', uniqid(random_int(0, mt_getrandmax())), '&') |
|
| 101 | + : generer_url_public('login')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | 111 | function generer_jeton_logout($session, $alea = null) { |
| 112 | - if (is_null($alea)) { |
|
| 113 | - include_spip('inc/acces'); |
|
| 114 | - $alea = charger_aleas(); |
|
| 115 | - } |
|
| 112 | + if (is_null($alea)) { |
|
| 113 | + include_spip('inc/acces'); |
|
| 114 | + $alea = charger_aleas(); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - return md5($session['date_session'] |
|
| 118 | - . $session['id_auteur'] |
|
| 119 | - . $session['statut'] |
|
| 120 | - . $alea); |
|
| 117 | + return md5($session['date_session'] |
|
| 118 | + . $session['id_auteur'] |
|
| 119 | + . $session['statut'] |
|
| 120 | + . $alea); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * @return bool |
| 132 | 132 | */ |
| 133 | 133 | function verifier_jeton_logout($jeton, $session) { |
| 134 | - if (generer_jeton_logout($session) === $jeton) { |
|
| 135 | - return true; |
|
| 136 | - } |
|
| 137 | - return generer_jeton_logout($session, $GLOBALS['meta']['alea_ephemere_ancien']) === $jeton; |
|
| 134 | + if (generer_jeton_logout($session) === $jeton) { |
|
| 135 | + return true; |
|
| 136 | + } |
|
| 137 | + return generer_jeton_logout($session, $GLOBALS['meta']['alea_ephemere_ancien']) === $jeton; |
|
| 138 | 138 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -31,28 +31,28 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function action_desinstaller_plugin_dist() { |
| 33 | 33 | |
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $arg = $securiser_action(); |
|
| 36 | - [$dir_plugins, $plugin] = explode('::', (string) $arg); |
|
| 37 | - $dir_type = '_DIR_PLUGINS'; |
|
| 38 | - if (defined('_DIR_PLUGINS_SUPPL') && $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 39 | - $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 40 | - } |
|
| 41 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 42 | - $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 43 | - if ($infos && !$infos['install_test'][0]) { |
|
| 44 | - include_spip('inc/plugin'); |
|
| 45 | - ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 46 | - $erreur = ''; |
|
| 47 | - } else { |
|
| 48 | - $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 49 | - } |
|
| 50 | - if ($redirect = _request('redirect')) { |
|
| 51 | - include_spip('inc/headers'); |
|
| 52 | - if ($erreur) { |
|
| 53 | - $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 54 | - } |
|
| 55 | - $redirect = str_replace('&', '&', (string) $redirect); |
|
| 56 | - redirige_par_entete($redirect); |
|
| 57 | - } |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $arg = $securiser_action(); |
|
| 36 | + [$dir_plugins, $plugin] = explode('::', (string) $arg); |
|
| 37 | + $dir_type = '_DIR_PLUGINS'; |
|
| 38 | + if (defined('_DIR_PLUGINS_SUPPL') && $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 39 | + $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 40 | + } |
|
| 41 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 42 | + $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 43 | + if ($infos && !$infos['install_test'][0]) { |
|
| 44 | + include_spip('inc/plugin'); |
|
| 45 | + ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 46 | + $erreur = ''; |
|
| 47 | + } else { |
|
| 48 | + $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 49 | + } |
|
| 50 | + if ($redirect = _request('redirect')) { |
|
| 51 | + include_spip('inc/headers'); |
|
| 52 | + if ($erreur) { |
|
| 53 | + $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 54 | + } |
|
| 55 | + $redirect = str_replace('&', '&', (string) $redirect); |
|
| 56 | + redirige_par_entete($redirect); |
|
| 57 | + } |
|
| 58 | 58 | } |