@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * Pile complétée du code compilé |
| 37 | 37 | **/ |
| 38 | 38 | function balise_MENU_LANG($p) { |
| 39 | - return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 39 | + return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * string: (vide) si pas de multilinguisme |
| 56 | 56 | */ |
| 57 | 57 | function balise_MENU_LANG_stat($args, $context_compil) { |
| 58 | - if (!str_contains((string) $GLOBALS['meta']['langues_multilingue'], ',')) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 58 | + if (!str_contains((string) $GLOBALS['meta']['langues_multilingue'], ',')) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $args; |
|
| 62 | + return $args; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * Liste : Chemin du squelette, durée du cache, contexte |
| 76 | 76 | **/ |
| 77 | 77 | function balise_MENU_LANG_dyn($opt) { |
| 78 | - include_spip('balise/menu_lang_ecrire'); |
|
| 78 | + include_spip('balise/menu_lang_ecrire'); |
|
| 79 | 79 | |
| 80 | - return menu_lang_pour_tous('var_lang', $opt); |
|
| 80 | + return menu_lang_pour_tous('var_lang', $opt); |
|
| 81 | 81 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if ($fichier) { |
| 110 | 110 | $code = "quete_logo_file($doc, $qconnect)"; |
| 111 | 111 | } else { |
| 112 | - $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 112 | + $code = "quete_logo_document($doc, ".($lien ?: "''").", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 113 | 113 | } |
| 114 | 114 | // (x=non-faux ? y : '') pour affecter x en retournant y |
| 115 | 115 | if ($p->descr['documents']) { |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
| 134 | 134 | if ($coord_x || $coord_y) { |
| 135 | - $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 135 | + $code = "filtrer('image_graver',filtrer('image_reduire',".$code.", '$coord_x', '$coord_y'))"; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $p->code = $code; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -55,88 +55,88 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function balise_LOGO__dist($p) { |
| 57 | 57 | |
| 58 | - preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 59 | - $type = strtolower($regs[1]); |
|
| 60 | - $suite_logo = $regs[2]; |
|
| 61 | - |
|
| 62 | - // cas de #LOGO_SITE_SPIP |
|
| 63 | - if ($type == 'site_spip') { |
|
| 64 | - $type = 'site'; |
|
| 65 | - $_id_objet = "\"'0'\""; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $id_objet = id_table_objet($type); |
|
| 69 | - if (!isset($_id_objet)) { |
|
| 70 | - $_id_objet = champ_sql($id_objet, $p); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - $fichier = ($p->etoile === '**') ? -1 : 0; |
|
| 74 | - $coord = []; |
|
| 75 | - $align = $lien = ''; |
|
| 76 | - $mode_logo = ''; |
|
| 77 | - |
|
| 78 | - if ($p->param && !$p->param[0][0]) { |
|
| 79 | - $params = $p->param[0]; |
|
| 80 | - array_shift($params); |
|
| 81 | - foreach ($params as $a) { |
|
| 82 | - if ($a[0]->type === 'texte') { |
|
| 83 | - $n = $a[0]->texte; |
|
| 84 | - if (is_numeric($n)) { |
|
| 85 | - $coord[] = $n; |
|
| 86 | - } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) { |
|
| 87 | - $align = $n; |
|
| 88 | - } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) { |
|
| 89 | - $mode_logo = $n; |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - $coord_x = $coord ? (int) array_shift($coord) : 0; |
|
| 98 | - $coord_y = $coord ? (int) array_shift($coord) : 0; |
|
| 99 | - |
|
| 100 | - if ($p->etoile === '*') { |
|
| 101 | - include_spip('balise/url_'); |
|
| 102 | - $lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 106 | - if ($type == 'document') { |
|
| 107 | - $qconnect = _q($connect); |
|
| 108 | - $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 109 | - if ($fichier) { |
|
| 110 | - $code = "quete_logo_file($doc, $qconnect)"; |
|
| 111 | - } else { |
|
| 112 | - $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 113 | - } |
|
| 114 | - // (x=non-faux ? y : '') pour affecter x en retournant y |
|
| 115 | - if ($p->descr['documents']) { |
|
| 116 | - $code = '(($doublons["documents"] .= ",". ' |
|
| 117 | - . $_id_objet |
|
| 118 | - . ") ? $code : '')"; |
|
| 119 | - } |
|
| 120 | - } elseif ($connect) { |
|
| 121 | - $code = "''"; |
|
| 122 | - spip_logger()->info('Les logos distants ne sont pas prevus'); |
|
| 123 | - } else { |
|
| 124 | - // pour generer_code_logo |
|
| 125 | - include_spip('balise/id_logo_'); |
|
| 126 | - $champ_logo = ''; |
|
| 127 | - if ($fichier) { |
|
| 128 | - $champ_logo = 'fichier'; |
|
| 129 | - } |
|
| 130 | - $code = generer_code_logo($id_objet, $_id_objet, $type, $align, $lien, $p, $suite_logo, $champ_logo); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
| 134 | - if ($coord_x || $coord_y) { |
|
| 135 | - $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $p->code = $code; |
|
| 139 | - $p->interdire_scripts = false; |
|
| 140 | - |
|
| 141 | - return $p; |
|
| 58 | + preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 59 | + $type = strtolower($regs[1]); |
|
| 60 | + $suite_logo = $regs[2]; |
|
| 61 | + |
|
| 62 | + // cas de #LOGO_SITE_SPIP |
|
| 63 | + if ($type == 'site_spip') { |
|
| 64 | + $type = 'site'; |
|
| 65 | + $_id_objet = "\"'0'\""; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $id_objet = id_table_objet($type); |
|
| 69 | + if (!isset($_id_objet)) { |
|
| 70 | + $_id_objet = champ_sql($id_objet, $p); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + $fichier = ($p->etoile === '**') ? -1 : 0; |
|
| 74 | + $coord = []; |
|
| 75 | + $align = $lien = ''; |
|
| 76 | + $mode_logo = ''; |
|
| 77 | + |
|
| 78 | + if ($p->param && !$p->param[0][0]) { |
|
| 79 | + $params = $p->param[0]; |
|
| 80 | + array_shift($params); |
|
| 81 | + foreach ($params as $a) { |
|
| 82 | + if ($a[0]->type === 'texte') { |
|
| 83 | + $n = $a[0]->texte; |
|
| 84 | + if (is_numeric($n)) { |
|
| 85 | + $coord[] = $n; |
|
| 86 | + } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) { |
|
| 87 | + $align = $n; |
|
| 88 | + } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) { |
|
| 89 | + $mode_logo = $n; |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + $coord_x = $coord ? (int) array_shift($coord) : 0; |
|
| 98 | + $coord_y = $coord ? (int) array_shift($coord) : 0; |
|
| 99 | + |
|
| 100 | + if ($p->etoile === '*') { |
|
| 101 | + include_spip('balise/url_'); |
|
| 102 | + $lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 106 | + if ($type == 'document') { |
|
| 107 | + $qconnect = _q($connect); |
|
| 108 | + $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 109 | + if ($fichier) { |
|
| 110 | + $code = "quete_logo_file($doc, $qconnect)"; |
|
| 111 | + } else { |
|
| 112 | + $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 113 | + } |
|
| 114 | + // (x=non-faux ? y : '') pour affecter x en retournant y |
|
| 115 | + if ($p->descr['documents']) { |
|
| 116 | + $code = '(($doublons["documents"] .= ",". ' |
|
| 117 | + . $_id_objet |
|
| 118 | + . ") ? $code : '')"; |
|
| 119 | + } |
|
| 120 | + } elseif ($connect) { |
|
| 121 | + $code = "''"; |
|
| 122 | + spip_logger()->info('Les logos distants ne sont pas prevus'); |
|
| 123 | + } else { |
|
| 124 | + // pour generer_code_logo |
|
| 125 | + include_spip('balise/id_logo_'); |
|
| 126 | + $champ_logo = ''; |
|
| 127 | + if ($fichier) { |
|
| 128 | + $champ_logo = 'fichier'; |
|
| 129 | + } |
|
| 130 | + $code = generer_code_logo($id_objet, $_id_objet, $type, $align, $lien, $p, $suite_logo, $champ_logo); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
| 134 | + if ($coord_x || $coord_y) { |
|
| 135 | + $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $p->code = $code; |
|
| 139 | + $p->interdire_scripts = false; |
|
| 140 | + |
|
| 141 | + return $p; |
|
| 142 | 142 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * Pile complétée du code compilé |
| 37 | 37 | **/ |
| 38 | 38 | function balise_MENU_LANG_ECRIRE($p) { |
| 39 | - return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 39 | + return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | * - string: Si pas de multilinguisme |
| 56 | 56 | */ |
| 57 | 57 | function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) { |
| 58 | - include_spip('inc/lang'); |
|
| 59 | - if (!str_contains((string) $GLOBALS['meta']['langues_proposees'], ',')) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 58 | + include_spip('inc/lang'); |
|
| 59 | + if (!str_contains((string) $GLOBALS['meta']['langues_proposees'], ',')) { |
|
| 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_ECRIRE_dyn($opt) { |
| 79 | - return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 79 | + return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -96,30 +96,30 @@ discard block |
||
| 96 | 96 | * Liste : Chemin du squelette, durée du cache, contexte |
| 97 | 97 | **/ |
| 98 | 98 | function menu_lang_pour_tous($nom, $default) { |
| 99 | - include_spip('inc/lang'); |
|
| 99 | + include_spip('inc/lang'); |
|
| 100 | 100 | |
| 101 | - if ($GLOBALS['spip_lang'] != $default) { |
|
| 102 | - $opt = lang_select($default); # et remplace |
|
| 103 | - if ($GLOBALS['spip_lang'] != $default) { |
|
| 104 | - $default = ''; # annule tout choix par defaut |
|
| 105 | - if ($opt) { |
|
| 106 | - lang_select(); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 101 | + if ($GLOBALS['spip_lang'] != $default) { |
|
| 102 | + $opt = lang_select($default); # et remplace |
|
| 103 | + if ($GLOBALS['spip_lang'] != $default) { |
|
| 104 | + $default = ''; # annule tout choix par defaut |
|
| 105 | + if ($opt) { |
|
| 106 | + lang_select(); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - # lien a partir de / |
|
| 112 | - $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 113 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode((string) $cible), true); |
|
| 111 | + # lien a partir de / |
|
| 112 | + $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 113 | + $post = generer_url_action('converser', 'redirect=' . rawurlencode((string) $cible), true); |
|
| 114 | 114 | |
| 115 | - return [ |
|
| 116 | - 'formulaires/menu_lang', |
|
| 117 | - 3600, |
|
| 118 | - [ |
|
| 119 | - 'nom' => $nom, |
|
| 120 | - 'url' => $post, |
|
| 121 | - 'name' => $nom, |
|
| 122 | - 'default' => $default, |
|
| 123 | - ] |
|
| 124 | - ]; |
|
| 115 | + return [ |
|
| 116 | + 'formulaires/menu_lang', |
|
| 117 | + 3600, |
|
| 118 | + [ |
|
| 119 | + 'nom' => $nom, |
|
| 120 | + 'url' => $post, |
|
| 121 | + 'name' => $nom, |
|
| 122 | + 'default' => $default, |
|
| 123 | + ] |
|
| 124 | + ]; |
|
| 125 | 125 | } |
@@ -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((string) $cible), true); |
|
| 113 | + $post = generer_url_action('converser', 'redirect='.rawurlencode((string) $cible), true); |
|
| 114 | 114 | |
| 115 | 115 | return [ |
| 116 | 116 | 'formulaires/menu_lang', |
@@ -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 | /** |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * Pile complétée du code compilé |
| 42 | 42 | **/ |
| 43 | 43 | function balise_FORMULAIRE_ADMIN($p) { |
| 44 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []); |
|
| 44 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * - chaîne vide sinon. |
| 59 | 59 | */ |
| 60 | 60 | function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) { |
| 61 | - return $args; |
|
| 61 | + return $args; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -83,64 +83,64 @@ discard block |
||
| 83 | 83 | **/ |
| 84 | 84 | function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') { |
| 85 | 85 | |
| 86 | - static $dejafait = false; |
|
| 86 | + static $dejafait = false; |
|
| 87 | 87 | |
| 88 | - if (empty($_COOKIE['spip_admin'])) { |
|
| 89 | - return ''; |
|
| 90 | - } |
|
| 88 | + if (empty($_COOKIE['spip_admin'])) { |
|
| 89 | + return ''; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - if (!is_array($debug)) { |
|
| 93 | - if ($dejafait) { |
|
| 94 | - return ''; |
|
| 95 | - } |
|
| 96 | - } else { |
|
| 97 | - if ($dejafait) { |
|
| 98 | - if (empty($debug['sourcefile'])) { |
|
| 99 | - return ''; |
|
| 100 | - } |
|
| 101 | - foreach ($debug['sourcefile'] as $k => $v) { |
|
| 102 | - if (str_contains((string) $v, 'administration.') && isset($debug['resultat'][$k . 'tout'])) { |
|
| 103 | - return $debug['resultat'][$k . 'tout']; |
|
| 104 | - } |
|
| 105 | - } |
|
| 92 | + if (!is_array($debug)) { |
|
| 93 | + if ($dejafait) { |
|
| 94 | + return ''; |
|
| 95 | + } |
|
| 96 | + } else { |
|
| 97 | + if ($dejafait) { |
|
| 98 | + if (empty($debug['sourcefile'])) { |
|
| 99 | + return ''; |
|
| 100 | + } |
|
| 101 | + foreach ($debug['sourcefile'] as $k => $v) { |
|
| 102 | + if (str_contains((string) $v, 'administration.') && isset($debug['resultat'][$k . 'tout'])) { |
|
| 103 | + return $debug['resultat'][$k . 'tout']; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - return ''; |
|
| 108 | - } |
|
| 109 | - } |
|
| 107 | + return ''; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - include_spip('inc/autoriser'); |
|
| 112 | - include_spip('base/abstract_sql'); |
|
| 111 | + include_spip('inc/autoriser'); |
|
| 112 | + include_spip('base/abstract_sql'); |
|
| 113 | 113 | |
| 114 | 114 | |
| 115 | - $dejafait = true; |
|
| 115 | + $dejafait = true; |
|
| 116 | 116 | |
| 117 | - // Preparer le #ENV des boutons |
|
| 117 | + // Preparer le #ENV des boutons |
|
| 118 | 118 | |
| 119 | - $env = admin_objet(); |
|
| 119 | + $env = admin_objet(); |
|
| 120 | 120 | |
| 121 | - // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
|
| 122 | - if (!$env) { |
|
| 123 | - $env['ecrire'] = _DIR_RESTREINT_ABS; |
|
| 124 | - } |
|
| 121 | + // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
|
| 122 | + if (!$env) { |
|
| 123 | + $env['ecrire'] = _DIR_RESTREINT_ABS; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $env['divclass'] = $float; |
|
| 127 | - $env['lang'] = admin_lang(); |
|
| 128 | - $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); |
|
| 129 | - $env['debug'] = ((defined('_VAR_PREVIEW') && _VAR_PREVIEW) ? '' : admin_debug()); |
|
| 130 | - $env['analyser'] = (!$env['debug'] && !$GLOBALS['xhtml']) ? '' : admin_valider(); |
|
| 131 | - $env['inclure'] = ((defined('_VAR_INCLURE') && _VAR_INCLURE) ? 'inclure' : ''); |
|
| 126 | + $env['divclass'] = $float; |
|
| 127 | + $env['lang'] = admin_lang(); |
|
| 128 | + $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); |
|
| 129 | + $env['debug'] = ((defined('_VAR_PREVIEW') && _VAR_PREVIEW) ? '' : admin_debug()); |
|
| 130 | + $env['analyser'] = (!$env['debug'] && !$GLOBALS['xhtml']) ? '' : admin_valider(); |
|
| 131 | + $env['inclure'] = ((defined('_VAR_INCLURE') && _VAR_INCLURE) ? 'inclure' : ''); |
|
| 132 | 132 | |
| 133 | - if (empty($GLOBALS['use_cache'])) { |
|
| 134 | - $env['use_cache'] = ' *'; |
|
| 135 | - } |
|
| 133 | + if (empty($GLOBALS['use_cache'])) { |
|
| 134 | + $env['use_cache'] = ' *'; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - if (isset($debug['validation'])) { |
|
| 138 | - $env['xhtml_error'] = $debug['validation']; |
|
| 139 | - } |
|
| 137 | + if (isset($debug['validation'])) { |
|
| 138 | + $env['xhtml_error'] = $debug['validation']; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - $env['_pipelines']['formulaire_admin'] = []; |
|
| 141 | + $env['_pipelines']['formulaire_admin'] = []; |
|
| 142 | 142 | |
| 143 | - return ['formulaires/administration', 0, $env]; |
|
| 143 | + return ['formulaires/administration', 0, $env]; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -158,46 +158,46 @@ discard block |
||
| 158 | 158 | * Tableau de l'environnement calculé |
| 159 | 159 | **/ |
| 160 | 160 | function admin_objet() { |
| 161 | - include_spip('inc/urls'); |
|
| 162 | - $env = []; |
|
| 163 | - |
|
| 164 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 165 | - $objets = urls_liste_objets(false); |
|
| 166 | - $objets = array_diff($objets, ['rubrique']); |
|
| 167 | - $objets = array_reverse($objets); |
|
| 168 | - array_unshift($objets, 'rubrique'); |
|
| 169 | - foreach ($objets as $obj) { |
|
| 170 | - $type = $obj; |
|
| 171 | - if ( |
|
| 172 | - $type == objet_type($type, false) |
|
| 173 | - && ($_id_type = id_table_objet($type)) |
|
| 174 | - && isset($GLOBALS['contexte'][$_id_type]) |
|
| 175 | - && ($id = $GLOBALS['contexte'][$_id_type]) |
|
| 176 | - && !is_array($id) |
|
| 177 | - && ($id = (int) $id) |
|
| 178 | - && ($desc = $trouver_table(table_objet_sql($type))) |
|
| 179 | - ) { |
|
| 180 | - $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . (int) $id); |
|
| 181 | - if ($id) { |
|
| 182 | - $env[$_id_type] = $id; |
|
| 183 | - $env['objet'] = $type; |
|
| 184 | - $env['id_objet'] = $id; |
|
| 185 | - $env['voir_' . $obj] = str_replace('&', '&', (string) generer_objet_url($id, $obj, '', '', false)); |
|
| 186 | - if ( |
|
| 187 | - isset($desc['field']['id_rubrique']) |
|
| 188 | - && $type != 'rubrique' |
|
| 189 | - ) { |
|
| 190 | - unset($env['id_rubrique']); |
|
| 191 | - unset($env['voir_rubrique']); |
|
| 192 | - if (admin_preview($type, $id, $desc)) { |
|
| 193 | - $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&'); |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - return $env; |
|
| 161 | + include_spip('inc/urls'); |
|
| 162 | + $env = []; |
|
| 163 | + |
|
| 164 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 165 | + $objets = urls_liste_objets(false); |
|
| 166 | + $objets = array_diff($objets, ['rubrique']); |
|
| 167 | + $objets = array_reverse($objets); |
|
| 168 | + array_unshift($objets, 'rubrique'); |
|
| 169 | + foreach ($objets as $obj) { |
|
| 170 | + $type = $obj; |
|
| 171 | + if ( |
|
| 172 | + $type == objet_type($type, false) |
|
| 173 | + && ($_id_type = id_table_objet($type)) |
|
| 174 | + && isset($GLOBALS['contexte'][$_id_type]) |
|
| 175 | + && ($id = $GLOBALS['contexte'][$_id_type]) |
|
| 176 | + && !is_array($id) |
|
| 177 | + && ($id = (int) $id) |
|
| 178 | + && ($desc = $trouver_table(table_objet_sql($type))) |
|
| 179 | + ) { |
|
| 180 | + $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . (int) $id); |
|
| 181 | + if ($id) { |
|
| 182 | + $env[$_id_type] = $id; |
|
| 183 | + $env['objet'] = $type; |
|
| 184 | + $env['id_objet'] = $id; |
|
| 185 | + $env['voir_' . $obj] = str_replace('&', '&', (string) generer_objet_url($id, $obj, '', '', false)); |
|
| 186 | + if ( |
|
| 187 | + isset($desc['field']['id_rubrique']) |
|
| 188 | + && $type != 'rubrique' |
|
| 189 | + ) { |
|
| 190 | + unset($env['id_rubrique']); |
|
| 191 | + unset($env['voir_rubrique']); |
|
| 192 | + if (admin_preview($type, $id, $desc)) { |
|
| 193 | + $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&'); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + return $env; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | |
@@ -215,30 +215,30 @@ discard block |
||
| 215 | 215 | * - Tableau d'un élément sinon. |
| 216 | 216 | **/ |
| 217 | 217 | function admin_preview($type, $id, $desc = null) { |
| 218 | - if (defined('_VAR_PREVIEW') && _VAR_PREVIEW) { |
|
| 219 | - return ''; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - if (!$desc) { |
|
| 223 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 224 | - $desc = $trouver_table(table_objet_sql($type)); |
|
| 225 | - } |
|
| 226 | - if (!$desc || !isset($desc['field']['statut'])) { |
|
| 227 | - return ''; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - include_spip('inc/autoriser'); |
|
| 231 | - if (!autoriser('previsualiser')) { |
|
| 232 | - return ''; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - $notpub = sql_in('statut', ['prop', 'prive']); |
|
| 236 | - |
|
| 237 | - if ($type == 'article' && $GLOBALS['meta']['post_dates'] != 'oui') { |
|
| 238 | - $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 218 | + if (defined('_VAR_PREVIEW') && _VAR_PREVIEW) { |
|
| 219 | + return ''; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + if (!$desc) { |
|
| 223 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 224 | + $desc = $trouver_table(table_objet_sql($type)); |
|
| 225 | + } |
|
| 226 | + if (!$desc || !isset($desc['field']['statut'])) { |
|
| 227 | + return ''; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + include_spip('inc/autoriser'); |
|
| 231 | + if (!autoriser('previsualiser')) { |
|
| 232 | + return ''; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + $notpub = sql_in('statut', ['prop', 'prive']); |
|
| 236 | + |
|
| 237 | + if ($type == 'article' && $GLOBALS['meta']['post_dates'] != 'oui') { |
|
| 238 | + $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | |
@@ -249,25 +249,25 @@ discard block |
||
| 249 | 249 | * Code de langue |
| 250 | 250 | **/ |
| 251 | 251 | function admin_lang() { |
| 252 | - $alang = ''; |
|
| 253 | - if (!empty($_COOKIE['spip_admin'])) { |
|
| 254 | - $email_or_login = preg_replace(',^@,', '', (string) $_COOKIE['spip_admin']); |
|
| 255 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 256 | - if (!$alang) { |
|
| 257 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - if (!$alang) { |
|
| 261 | - return ''; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - $l = lang_select($alang); |
|
| 265 | - $alang = $GLOBALS['spip_lang']; |
|
| 266 | - if ($l) { |
|
| 267 | - lang_select(); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - return $alang; |
|
| 252 | + $alang = ''; |
|
| 253 | + if (!empty($_COOKIE['spip_admin'])) { |
|
| 254 | + $email_or_login = preg_replace(',^@,', '', (string) $_COOKIE['spip_admin']); |
|
| 255 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 256 | + if (!$alang) { |
|
| 257 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + if (!$alang) { |
|
| 261 | + return ''; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + $l = lang_select($alang); |
|
| 265 | + $alang = $GLOBALS['spip_lang']; |
|
| 266 | + if ($l) { |
|
| 267 | + lang_select(); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + return $alang; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | **/ |
| 278 | 278 | function admin_valider() { |
| 279 | 279 | |
| 280 | - return ((!isset($GLOBALS['xhtml']) || $GLOBALS['xhtml'] !== 'true') ? |
|
| 281 | - (parametre_url(self(), 'var_mode', 'debug', '&') |
|
| 282 | - . '&var_mode_affiche=validation') : |
|
| 283 | - ('http://validator.w3.org/check?uri=' |
|
| 284 | - . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 280 | + return ((!isset($GLOBALS['xhtml']) || $GLOBALS['xhtml'] !== 'true') ? |
|
| 281 | + (parametre_url(self(), 'var_mode', 'debug', '&') |
|
| 282 | + . '&var_mode_affiche=validation') : |
|
| 283 | + ('http://validator.w3.org/check?uri=' |
|
| 284 | + . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -290,10 +290,10 @@ discard block |
||
| 290 | 290 | * @return string |
| 291 | 291 | **/ |
| 292 | 292 | function admin_debug() { |
| 293 | - return ( |
|
| 294 | - (isset($GLOBALS['forcer_debug']) && $GLOBALS['forcer_debug'] |
|
| 295 | - || isset($GLOBALS['bouton_admin_debug']) && $GLOBALS['bouton_admin_debug'] |
|
| 296 | - || defined('_VAR_MODE') && _VAR_MODE == 'debug' && isset($_COOKIE['spip_debug']) && $_COOKIE['spip_debug']) && autoriser('debug') |
|
| 297 | - ) |
|
| 298 | - ? parametre_url(self(), 'var_mode', 'debug', '&') : ''; |
|
| 293 | + return ( |
|
| 294 | + (isset($GLOBALS['forcer_debug']) && $GLOBALS['forcer_debug'] |
|
| 295 | + || isset($GLOBALS['bouton_admin_debug']) && $GLOBALS['bouton_admin_debug'] |
|
| 296 | + || defined('_VAR_MODE') && _VAR_MODE == 'debug' && isset($_COOKIE['spip_debug']) && $_COOKIE['spip_debug']) && autoriser('debug') |
|
| 297 | + ) |
|
| 298 | + ? parametre_url(self(), 'var_mode', 'debug', '&') : ''; |
|
| 299 | 299 | } |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | return ''; |
| 100 | 100 | } |
| 101 | 101 | foreach ($debug['sourcefile'] as $k => $v) { |
| 102 | - if (str_contains((string) $v, 'administration.') && isset($debug['resultat'][$k . 'tout'])) { |
|
| 103 | - return $debug['resultat'][$k . 'tout']; |
|
| 102 | + if (str_contains((string) $v, 'administration.') && isset($debug['resultat'][$k.'tout'])) { |
|
| 103 | + return $debug['resultat'][$k.'tout']; |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | && ($id = (int) $id) |
| 178 | 178 | && ($desc = $trouver_table(table_objet_sql($type))) |
| 179 | 179 | ) { |
| 180 | - $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . (int) $id); |
|
| 180 | + $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=".(int) $id); |
|
| 181 | 181 | if ($id) { |
| 182 | 182 | $env[$_id_type] = $id; |
| 183 | 183 | $env['objet'] = $type; |
| 184 | 184 | $env['id_objet'] = $id; |
| 185 | - $env['voir_' . $obj] = str_replace('&', '&', (string) generer_objet_url($id, $obj, '', '', false)); |
|
| 185 | + $env['voir_'.$obj] = str_replace('&', '&', (string) generer_objet_url($id, $obj, '', '', false)); |
|
| 186 | 186 | if ( |
| 187 | 187 | isset($desc['field']['id_rubrique']) |
| 188 | 188 | && $type != 'rubrique' |
@@ -235,10 +235,10 @@ discard block |
||
| 235 | 235 | $notpub = sql_in('statut', ['prop', 'prive']); |
| 236 | 236 | |
| 237 | 237 | if ($type == 'article' && $GLOBALS['meta']['post_dates'] != 'oui') { |
| 238 | - $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 238 | + $notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).')'; |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 241 | + return sql_fetsel('1', table_objet_sql($type), id_table_objet($type).'='.$id." AND ($notpub)"); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | $alang = ''; |
| 253 | 253 | if (!empty($_COOKIE['spip_admin'])) { |
| 254 | 254 | $email_or_login = preg_replace(',^@,', '', (string) $_COOKIE['spip_admin']); |
| 255 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 255 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'email='.sql_quote($email_or_login)); |
|
| 256 | 256 | if (!$alang) { |
| 257 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 257 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'login='.sql_quote($email_or_login)); |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | if (!$alang) { |
@@ -279,9 +279,8 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | return ((!isset($GLOBALS['xhtml']) || $GLOBALS['xhtml'] !== 'true') ? |
| 281 | 281 | (parametre_url(self(), 'var_mode', 'debug', '&') |
| 282 | - . '&var_mode_affiche=validation') : |
|
| 283 | - ('http://validator.w3.org/check?uri=' |
|
| 284 | - . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 282 | + . '&var_mode_affiche=validation') : ('http://validator.w3.org/check?uri=' |
|
| 283 | + . rawurlencode('http://'.$_SERVER['HTTP_HOST'].nettoyer_uri()))); |
|
| 285 | 284 | } |
| 286 | 285 | |
| 287 | 286 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass]; |
| 68 | 68 | |
| 69 | 69 | // Si l'utilisateur figure deja dans la base, y recuperer les infos |
| 70 | - $r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur); |
|
| 70 | + $r = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login)." AND source='ldap'", '', '', '', '', $serveur); |
|
| 71 | 71 | |
| 72 | 72 | if ($r) { |
| 73 | 73 | return array_merge($r, $credentials_ldap); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | if ($r) { |
| 91 | 91 | return array_merge( |
| 92 | 92 | $credentials_ldap, |
| 93 | - sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . (int) $r, '', '', '', '', $serveur) |
|
| 93 | + sql_fetsel('*', 'spip_auteurs', 'id_auteur='.(int) $r, '', '', '', '', $serveur) |
|
| 94 | 94 | ); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $connexion = spip_connect($serveur); |
| 120 | 120 | if (!is_array($connexion['ldap'])) { |
| 121 | 121 | if ($connexion['authentification']['ldap']) { |
| 122 | - $f = _DIR_CONNECT . $connexion['authentification']['ldap']; |
|
| 122 | + $f = _DIR_CONNECT.$connexion['authentification']['ldap']; |
|
| 123 | 123 | unset($GLOBALS['ldap_link']); |
| 124 | 124 | if (is_readable($f)) { |
| 125 | 125 | include_once($f); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | if (!ldap_bind($link, $dn, session_get('ldap_password'))) { |
| 333 | 333 | return false; |
| 334 | 334 | } |
| 335 | - $encoded_pass = '{MD5}' . base64_encode(pack('H*', md5((string) $new_pass))); |
|
| 335 | + $encoded_pass = '{MD5}'.base64_encode(pack('H*', md5((string) $new_pass))); |
|
| 336 | 336 | |
| 337 | 337 | return ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]); |
| 338 | 338 | } |
@@ -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 | // Authentifie via LDAP et retourne la ligne SQL decrivant l'utilisateur si ok |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | // Attributs LDAP correspondants a ceux de SPIP, notamment pour le login |
| 25 | 25 | // ne pas ecraser une definition perso dans mes_options |
| 26 | 26 | if (!isset($GLOBALS['ldap_attributes']) || !is_array($GLOBALS['ldap_attributes'])) { |
| 27 | - $GLOBALS['ldap_attributes'] = [ |
|
| 28 | - 'login' => ['sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'], |
|
| 29 | - 'nom' => 'cn', |
|
| 30 | - 'email' => 'mail', |
|
| 31 | - 'bio' => 'description' |
|
| 32 | - ]; |
|
| 27 | + $GLOBALS['ldap_attributes'] = [ |
|
| 28 | + 'login' => ['sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'], |
|
| 29 | + 'nom' => 'cn', |
|
| 30 | + 'email' => 'mail', |
|
| 31 | + 'bio' => 'description' |
|
| 32 | + ]; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -55,49 +55,49 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function auth_ldap_dist($login, #[\SensitiveParameter] $pass, $serveur = '', $phpauth = false) { |
| 57 | 57 | |
| 58 | - #spip_logger()->info("ldap $login " . ($pass ? "mdp fourni" : "mdp absent")); |
|
| 59 | - |
|
| 60 | - // Utilisateur connu ? |
|
| 61 | - // si http auth, inutile de reauthentifier: cela |
|
| 62 | - // ne marchera pas avec auth http autre que basic. |
|
| 63 | - $checkpass = !isset($_SERVER['REMOTE_USER']); |
|
| 64 | - if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) { |
|
| 65 | - return []; |
|
| 66 | - } |
|
| 67 | - $credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass]; |
|
| 68 | - |
|
| 69 | - // Si l'utilisateur figure deja dans la base, y recuperer les infos |
|
| 70 | - $r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur); |
|
| 71 | - |
|
| 72 | - if ($r) { |
|
| 73 | - return array_merge($r, $credentials_ldap); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // sinon importer les infos depuis LDAP, |
|
| 77 | - |
|
| 78 | - if ( |
|
| 79 | - $GLOBALS['meta']['ldap_statut_import'] && ($desc = auth_ldap_retrouver($dn, [], $serveur)) |
|
| 80 | - ) { |
|
| 81 | - // rajouter le statut indique a l'install |
|
| 82 | - $desc['statut'] = $GLOBALS['meta']['ldap_statut_import']; |
|
| 83 | - $desc['login'] = $login; |
|
| 84 | - $desc['source'] = 'ldap'; |
|
| 85 | - $desc['pass'] = ''; |
|
| 86 | - |
|
| 87 | - $r = sql_insertq('spip_auteurs', $desc, [], $serveur); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - if ($r) { |
|
| 91 | - return array_merge( |
|
| 92 | - $credentials_ldap, |
|
| 93 | - sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . (int) $r, '', '', '', '', $serveur) |
|
| 94 | - ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - // sinon echec |
|
| 98 | - spip_logger()->info("Creation de l'auteur '$login' impossible"); |
|
| 99 | - |
|
| 100 | - return []; |
|
| 58 | + #spip_logger()->info("ldap $login " . ($pass ? "mdp fourni" : "mdp absent")); |
|
| 59 | + |
|
| 60 | + // Utilisateur connu ? |
|
| 61 | + // si http auth, inutile de reauthentifier: cela |
|
| 62 | + // ne marchera pas avec auth http autre que basic. |
|
| 63 | + $checkpass = !isset($_SERVER['REMOTE_USER']); |
|
| 64 | + if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) { |
|
| 65 | + return []; |
|
| 66 | + } |
|
| 67 | + $credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass]; |
|
| 68 | + |
|
| 69 | + // Si l'utilisateur figure deja dans la base, y recuperer les infos |
|
| 70 | + $r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur); |
|
| 71 | + |
|
| 72 | + if ($r) { |
|
| 73 | + return array_merge($r, $credentials_ldap); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // sinon importer les infos depuis LDAP, |
|
| 77 | + |
|
| 78 | + if ( |
|
| 79 | + $GLOBALS['meta']['ldap_statut_import'] && ($desc = auth_ldap_retrouver($dn, [], $serveur)) |
|
| 80 | + ) { |
|
| 81 | + // rajouter le statut indique a l'install |
|
| 82 | + $desc['statut'] = $GLOBALS['meta']['ldap_statut_import']; |
|
| 83 | + $desc['login'] = $login; |
|
| 84 | + $desc['source'] = 'ldap'; |
|
| 85 | + $desc['pass'] = ''; |
|
| 86 | + |
|
| 87 | + $r = sql_insertq('spip_auteurs', $desc, [], $serveur); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + if ($r) { |
|
| 91 | + return array_merge( |
|
| 92 | + $credentials_ldap, |
|
| 93 | + sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . (int) $r, '', '', '', '', $serveur) |
|
| 94 | + ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + // sinon echec |
|
| 98 | + spip_logger()->info("Creation de l'auteur '$login' impossible"); |
|
| 99 | + |
|
| 100 | + return []; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -111,36 +111,36 @@ discard block |
||
| 111 | 111 | * @return array |
| 112 | 112 | */ |
| 113 | 113 | function auth_ldap_connect($serveur = '') { |
| 114 | - include_spip('base/connect_sql'); |
|
| 115 | - static $connexions_ldap = []; |
|
| 116 | - if (isset($connexions_ldap[$serveur])) { |
|
| 117 | - return $connexions_ldap[$serveur]; |
|
| 118 | - } |
|
| 119 | - $connexion = spip_connect($serveur); |
|
| 120 | - if (!is_array($connexion['ldap'])) { |
|
| 121 | - if ($connexion['authentification']['ldap']) { |
|
| 122 | - $f = _DIR_CONNECT . $connexion['authentification']['ldap']; |
|
| 123 | - unset($GLOBALS['ldap_link']); |
|
| 124 | - if (is_readable($f)) { |
|
| 125 | - include_once($f); |
|
| 126 | - }; |
|
| 127 | - if (isset($GLOBALS['ldap_link'])) { |
|
| 128 | - $connexion['ldap'] = [ |
|
| 129 | - 'link' => $GLOBALS['ldap_link'], |
|
| 130 | - 'base' => $GLOBALS['ldap_base'] |
|
| 131 | - ]; |
|
| 132 | - } else { |
|
| 133 | - spip_logger()->info("connection LDAP $serveur mal definie dans $f"); |
|
| 134 | - } |
|
| 135 | - if (isset($GLOBALS['ldap_champs'])) { |
|
| 136 | - $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs']; |
|
| 137 | - } |
|
| 138 | - } else { |
|
| 139 | - spip_logger()->info("connection LDAP $serveur inconnue"); |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - return $connexions_ldap[$serveur] = $connexion['ldap']; |
|
| 114 | + include_spip('base/connect_sql'); |
|
| 115 | + static $connexions_ldap = []; |
|
| 116 | + if (isset($connexions_ldap[$serveur])) { |
|
| 117 | + return $connexions_ldap[$serveur]; |
|
| 118 | + } |
|
| 119 | + $connexion = spip_connect($serveur); |
|
| 120 | + if (!is_array($connexion['ldap'])) { |
|
| 121 | + if ($connexion['authentification']['ldap']) { |
|
| 122 | + $f = _DIR_CONNECT . $connexion['authentification']['ldap']; |
|
| 123 | + unset($GLOBALS['ldap_link']); |
|
| 124 | + if (is_readable($f)) { |
|
| 125 | + include_once($f); |
|
| 126 | + }; |
|
| 127 | + if (isset($GLOBALS['ldap_link'])) { |
|
| 128 | + $connexion['ldap'] = [ |
|
| 129 | + 'link' => $GLOBALS['ldap_link'], |
|
| 130 | + 'base' => $GLOBALS['ldap_base'] |
|
| 131 | + ]; |
|
| 132 | + } else { |
|
| 133 | + spip_logger()->info("connection LDAP $serveur mal definie dans $f"); |
|
| 134 | + } |
|
| 135 | + if (isset($GLOBALS['ldap_champs'])) { |
|
| 136 | + $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs']; |
|
| 137 | + } |
|
| 138 | + } else { |
|
| 139 | + spip_logger()->info("connection LDAP $serveur inconnue"); |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + return $connexions_ldap[$serveur] = $connexion['ldap']; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -154,52 +154,52 @@ discard block |
||
| 154 | 154 | * Le login trouvé ou chaine vide si non trouvé |
| 155 | 155 | */ |
| 156 | 156 | function auth_ldap_search($login, #[\SensitiveParameter] $pass, $checkpass = true, $serveur = '') { |
| 157 | - // Securite anti-injection et contre un serveur LDAP laxiste |
|
| 158 | - $login_search = preg_replace('/[^-@.\s\w]/', '', $login); |
|
| 159 | - if (!strlen($login_search) || $checkpass && !strlen($pass)) { |
|
| 160 | - return ''; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // verifier la connexion |
|
| 164 | - if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 165 | - return ''; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - $ldap_link = $ldap['link'] ?? null; |
|
| 169 | - $ldap_base = $ldap['base'] ?? null; |
|
| 170 | - $desc = empty($ldap['attributes']) ? $GLOBALS['ldap_attributes'] : $ldap['attributes']; |
|
| 171 | - |
|
| 172 | - $logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']]; |
|
| 173 | - |
|
| 174 | - // Tenter une recherche pour essayer de retrouver le DN |
|
| 175 | - foreach ($logins as $att) { |
|
| 176 | - $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", ['dn']); |
|
| 177 | - $info = @ldap_get_entries($ldap_link, $result); |
|
| 178 | - // Ne pas accepter les resultats si plus d'une entree |
|
| 179 | - // (on veut un attribut unique) |
|
| 180 | - |
|
| 181 | - if (is_array($info) && $info['count'] == 1) { |
|
| 182 | - $dn = $info[0]['dn']; |
|
| 183 | - if (!$checkpass) { |
|
| 184 | - return $dn; |
|
| 185 | - } |
|
| 186 | - if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 187 | - return $dn; |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - if ($checkpass && !isset($dn)) { |
|
| 193 | - // Si echec, essayer de deviner le DN |
|
| 194 | - foreach ($logins as $att) { |
|
| 195 | - $dn = "$att=$login_search, $ldap_base"; |
|
| 196 | - if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 197 | - return "$att=$login_search, $ldap_base"; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - return ''; |
|
| 157 | + // Securite anti-injection et contre un serveur LDAP laxiste |
|
| 158 | + $login_search = preg_replace('/[^-@.\s\w]/', '', $login); |
|
| 159 | + if (!strlen($login_search) || $checkpass && !strlen($pass)) { |
|
| 160 | + return ''; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // verifier la connexion |
|
| 164 | + if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 165 | + return ''; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + $ldap_link = $ldap['link'] ?? null; |
|
| 169 | + $ldap_base = $ldap['base'] ?? null; |
|
| 170 | + $desc = empty($ldap['attributes']) ? $GLOBALS['ldap_attributes'] : $ldap['attributes']; |
|
| 171 | + |
|
| 172 | + $logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']]; |
|
| 173 | + |
|
| 174 | + // Tenter une recherche pour essayer de retrouver le DN |
|
| 175 | + foreach ($logins as $att) { |
|
| 176 | + $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", ['dn']); |
|
| 177 | + $info = @ldap_get_entries($ldap_link, $result); |
|
| 178 | + // Ne pas accepter les resultats si plus d'une entree |
|
| 179 | + // (on veut un attribut unique) |
|
| 180 | + |
|
| 181 | + if (is_array($info) && $info['count'] == 1) { |
|
| 182 | + $dn = $info[0]['dn']; |
|
| 183 | + if (!$checkpass) { |
|
| 184 | + return $dn; |
|
| 185 | + } |
|
| 186 | + if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 187 | + return $dn; |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + if ($checkpass && !isset($dn)) { |
|
| 193 | + // Si echec, essayer de deviner le DN |
|
| 194 | + foreach ($logins as $att) { |
|
| 195 | + $dn = "$att=$login_search, $ldap_base"; |
|
| 196 | + if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 197 | + return "$att=$login_search, $ldap_base"; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + return ''; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -211,40 +211,40 @@ discard block |
||
| 211 | 211 | * @return array |
| 212 | 212 | */ |
| 213 | 213 | function auth_ldap_retrouver($dn, $desc = [], $serveur = '') { |
| 214 | - // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP |
|
| 214 | + // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP |
|
| 215 | 215 | |
| 216 | - if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 217 | - spip_logger()->info("ldap $serveur injoignable"); |
|
| 216 | + if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 217 | + spip_logger()->info("ldap $serveur injoignable"); |
|
| 218 | 218 | |
| 219 | - return []; |
|
| 220 | - } |
|
| 219 | + return []; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - $ldap_link = $ldap['link']; |
|
| 223 | - if (!$desc) { |
|
| 224 | - $desc = $ldap['attributes'] ?: $GLOBALS['ldap_attributes']; |
|
| 225 | - unset($desc['login']); |
|
| 226 | - } |
|
| 227 | - $result = @ldap_read($ldap_link, $dn, 'objectClass=*', array_values($desc)); |
|
| 222 | + $ldap_link = $ldap['link']; |
|
| 223 | + if (!$desc) { |
|
| 224 | + $desc = $ldap['attributes'] ?: $GLOBALS['ldap_attributes']; |
|
| 225 | + unset($desc['login']); |
|
| 226 | + } |
|
| 227 | + $result = @ldap_read($ldap_link, $dn, 'objectClass=*', array_values($desc)); |
|
| 228 | 228 | |
| 229 | - if (!$result) { |
|
| 230 | - return []; |
|
| 231 | - } |
|
| 229 | + if (!$result) { |
|
| 230 | + return []; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - // Recuperer les donnees du premier (unique?) compte de l'auteur |
|
| 234 | - $val = @ldap_get_entries($ldap_link, $result); |
|
| 235 | - if (!is_array($val) || !is_array($val[0])) { |
|
| 236 | - return []; |
|
| 237 | - } |
|
| 238 | - $val = $val[0]; |
|
| 233 | + // Recuperer les donnees du premier (unique?) compte de l'auteur |
|
| 234 | + $val = @ldap_get_entries($ldap_link, $result); |
|
| 235 | + if (!is_array($val) || !is_array($val[0])) { |
|
| 236 | + return []; |
|
| 237 | + } |
|
| 238 | + $val = $val[0]; |
|
| 239 | 239 | |
| 240 | - // Convertir depuis UTF-8 (jeu de caracteres par defaut) |
|
| 241 | - include_spip('inc/charsets'); |
|
| 240 | + // Convertir depuis UTF-8 (jeu de caracteres par defaut) |
|
| 241 | + include_spip('inc/charsets'); |
|
| 242 | 242 | |
| 243 | - foreach ($desc as $k => $v) { |
|
| 244 | - $desc[$k] = importer_charset($val[strtolower((string) $v)][0], 'utf-8'); |
|
| 245 | - } |
|
| 243 | + foreach ($desc as $k => $v) { |
|
| 244 | + $desc[$k] = importer_charset($val[strtolower((string) $v)][0], 'utf-8'); |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - return $desc; |
|
| 247 | + return $desc; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @return string |
| 257 | 257 | */ |
| 258 | 258 | function auth_ldap_retrouver_login($login, $serveur = '') { |
| 259 | - return auth_ldap_search($login, '', false, $serveur) ? $login : ''; |
|
| 259 | + return auth_ldap_search($login, '', false, $serveur) ? $login : ''; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -276,9 +276,9 @@ discard block |
||
| 276 | 276 | * Message d'erreur si login non valide, chaîne vide sinon |
| 277 | 277 | */ |
| 278 | 278 | function auth_ldap_verifier_pass($login, #[\SensitiveParameter] $new_pass, $id_auteur = 0, $serveur = '') { |
| 279 | - include_spip('auth/spip'); |
|
| 279 | + include_spip('auth/spip'); |
|
| 280 | 280 | |
| 281 | - return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur); |
|
| 281 | + return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * ``` |
| 300 | 300 | */ |
| 301 | 301 | function auth_ldap_autoriser_modifier_pass($serveur = '') { |
| 302 | - return true; |
|
| 302 | + return true; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -317,22 +317,22 @@ discard block |
||
| 317 | 317 | * Informe du succès ou de l'echec du changement du mot de passe |
| 318 | 318 | */ |
| 319 | 319 | function auth_ldap_modifier_pass($login, #[\SensitiveParameter] $new_pass, $id_auteur, $serveur = '') { |
| 320 | - if (is_null($new_pass) || auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 321 | - return false; |
|
| 322 | - } |
|
| 323 | - if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 324 | - return false; |
|
| 325 | - } |
|
| 326 | - $link = $ldap['link']; |
|
| 327 | - include_spip('inc/session'); |
|
| 328 | - $dn = session_get('ldap_dn'); |
|
| 329 | - if ('' == $dn) { |
|
| 330 | - return false; |
|
| 331 | - } |
|
| 332 | - if (!ldap_bind($link, $dn, session_get('ldap_password'))) { |
|
| 333 | - return false; |
|
| 334 | - } |
|
| 335 | - $encoded_pass = '{MD5}' . base64_encode(pack('H*', md5((string) $new_pass))); |
|
| 336 | - |
|
| 337 | - return ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]); |
|
| 320 | + if (is_null($new_pass) || auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 323 | + if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 324 | + return false; |
|
| 325 | + } |
|
| 326 | + $link = $ldap['link']; |
|
| 327 | + include_spip('inc/session'); |
|
| 328 | + $dn = session_get('ldap_dn'); |
|
| 329 | + if ('' == $dn) { |
|
| 330 | + return false; |
|
| 331 | + } |
|
| 332 | + if (!ldap_bind($link, $dn, session_get('ldap_password'))) { |
|
| 333 | + return false; |
|
| 334 | + } |
|
| 335 | + $encoded_pass = '{MD5}' . base64_encode(pack('H*', md5((string) $new_pass))); |
|
| 336 | + |
|
| 337 | + return ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]); |
|
| 338 | 338 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $champ = preg_replace(',[\s]+,ms', ' ', $champ); |
| 38 | 38 | $champ = str_replace('"', '""', $champ); |
| 39 | 39 | |
| 40 | - return '"' . $champ . '"'; |
|
| 40 | + return '"'.$champ.'"'; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | if ($callback) { |
| 58 | 58 | $ligne = $callback($nb, $ligne, $delim, $importer_charset); |
| 59 | 59 | } |
| 60 | - $output = implode($delim, array_map('exporter_csv_champ', $ligne)) . "\r\n"; |
|
| 60 | + $output = implode($delim, array_map('exporter_csv_champ', $ligne))."\r\n"; |
|
| 61 | 61 | if ($importer_charset) { |
| 62 | 62 | $output = str_replace('’', '\'', $output); |
| 63 | 63 | $output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $fichier = 'php://output'; |
| 185 | 185 | } |
| 186 | 186 | else { |
| 187 | - $fichier = sous_repertoire(_DIR_CACHE, 'export') . $basename; |
|
| 187 | + $fichier = sous_repertoire(_DIR_CACHE, 'export').$basename; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $fp = fopen($fichier, 'w'); |
@@ -182,8 +182,7 @@ |
||
| 182 | 182 | // sinon on ecrit directement sur stdout |
| 183 | 183 | if ($options['envoyer'] && $options['envoyer'] !== 'attachment') { |
| 184 | 184 | $fichier = 'php://output'; |
| 185 | - } |
|
| 186 | - else { |
|
| 185 | + } else { |
|
| 187 | 186 | $fichier = sous_repertoire(_DIR_CACHE, 'export') . $basename; |
| 188 | 187 | } |
| 189 | 188 | |
@@ -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/charsets'); |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function exporter_csv_champ($champ) { |
| 34 | - #$champ = str_replace("\r", "\n", $champ); |
|
| 35 | - #$champ = preg_replace(",[\n]+,ms", "\n", $champ); |
|
| 36 | - #$champ = str_replace("\n", ", ", $champ); |
|
| 37 | - $champ = preg_replace(',[\s]+,ms', ' ', $champ); |
|
| 38 | - $champ = str_replace('"', '""', $champ); |
|
| 34 | + #$champ = str_replace("\r", "\n", $champ); |
|
| 35 | + #$champ = preg_replace(",[\n]+,ms", "\n", $champ); |
|
| 36 | + #$champ = str_replace("\n", ", ", $champ); |
|
| 37 | + $champ = preg_replace(',[\s]+,ms', ' ', $champ); |
|
| 38 | + $champ = str_replace('"', '""', $champ); |
|
| 39 | 39 | |
| 40 | - return '"' . $champ . '"'; |
|
| 40 | + return '"' . $champ . '"'; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -54,15 +54,15 @@ discard block |
||
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | 56 | function exporter_csv_ligne_numerotee($nb, $ligne, $delim = ',', $importer_charset = null, ?callable $callback = null) { |
| 57 | - if ($callback) { |
|
| 58 | - $ligne = $callback($nb, $ligne, $delim, $importer_charset); |
|
| 59 | - } |
|
| 60 | - $output = implode($delim, array_map('exporter_csv_champ', $ligne)) . "\r\n"; |
|
| 61 | - if ($importer_charset) { |
|
| 62 | - $output = str_replace('’', '\'', $output); |
|
| 63 | - $output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset); |
|
| 64 | - } |
|
| 65 | - return $output; |
|
| 57 | + if ($callback) { |
|
| 58 | + $ligne = $callback($nb, $ligne, $delim, $importer_charset); |
|
| 59 | + } |
|
| 60 | + $output = implode($delim, array_map('exporter_csv_champ', $ligne)) . "\r\n"; |
|
| 61 | + if ($importer_charset) { |
|
| 62 | + $output = str_replace('’', '\'', $output); |
|
| 63 | + $output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset); |
|
| 64 | + } |
|
| 65 | + return $output; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -90,107 +90,107 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | function inc_exporter_csv_dist($titre, $resource, $options = []) { |
| 92 | 92 | |
| 93 | - // support ancienne syntaxe |
|
| 94 | - // inc_exporter_csv_dist($titre, $resource, $delim = ', ', $entetes = null, $envoyer = true) |
|
| 95 | - if (is_string($options)) { |
|
| 96 | - $args = func_get_args(); |
|
| 97 | - $options = []; |
|
| 98 | - foreach ([2 => 'delim', 3 => 'entetes', 4 => 'envoyer'] as $k => $option) { |
|
| 99 | - if (!empty($args[$k])) { |
|
| 100 | - $options[$option] = $args[$k]; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $default_options = [ |
|
| 106 | - 'fichier' => null, // par défaut = $titre |
|
| 107 | - 'extension' => null, // par défaut = choix auto |
|
| 108 | - 'delim' => ',', |
|
| 109 | - 'entetes' => null, |
|
| 110 | - 'envoyer' => true, |
|
| 111 | - 'charset' => null, |
|
| 112 | - 'callback' => null, |
|
| 113 | - ]; |
|
| 114 | - $options = array_merge($default_options, $options); |
|
| 115 | - |
|
| 116 | - // Délimiteur |
|
| 117 | - if ($options['delim'] == 'TAB') { |
|
| 118 | - $options['delim'] = "\t"; |
|
| 119 | - } |
|
| 120 | - if (!in_array($options['delim'], [',', ';', "\t"])) { |
|
| 121 | - $options['delim'] = ','; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // Nom du fichier : celui indiqué dans les options, sinon le titre |
|
| 125 | - // Normalisation : uniquement les caractères non spéciaux, tirets, underscore et point + remplacer espaces par underscores |
|
| 126 | - $filename = $options['fichier'] ?? translitteration(textebrut(typo($titre))); |
|
| 127 | - $filename = preg_replace([',[^\w\-_\.\s]+,', ',\s+,'], ['', '_'], trim((string) $filename)); |
|
| 128 | - $filename = rtrim($filename, '.'); |
|
| 129 | - |
|
| 130 | - // Extension : celle indiquée en option, sinon choisie selon le délimiteur |
|
| 131 | - // Normalisation : uniquement les charactères non spéciaux |
|
| 132 | - if (!empty($options['extension'])) { |
|
| 133 | - $options['extension'] = preg_replace(',[^\w]+,', '', trim((string) $options['extension'])); |
|
| 134 | - } |
|
| 135 | - $extension = $options['extension'] ?? ($options['delim'] === ',' ? 'csv' : 'xls'); |
|
| 136 | - |
|
| 137 | - // Fichier |
|
| 138 | - $basename = "$filename.$extension"; |
|
| 139 | - |
|
| 140 | - // Charset : celui indiqué en option, sinon celui compatible excel si nécessaire, sinon celui du site |
|
| 141 | - // Excel n'accepte pas l'utf-8 ni les entites html... on transcode tout ce qu'on peut |
|
| 142 | - $charset_site = $GLOBALS['meta']['charset']; |
|
| 143 | - $charset_excel = ($extension === 'xls' ? 'iso-8859-1' : null); |
|
| 144 | - $charset = $options['charset'] ?? $charset_excel ?? $charset_site; |
|
| 145 | - $importer_charset = (($charset === $charset_site) ? null : $charset); |
|
| 146 | - |
|
| 147 | - $output = ''; |
|
| 148 | - $nb = 0; |
|
| 149 | - if (!empty($options['entetes']) && is_array($options['entetes'])) { |
|
| 150 | - $output = exporter_csv_ligne_numerotee($nb, $options['entetes'], $options['delim'], $importer_charset, $options['callback']); |
|
| 151 | - } |
|
| 152 | - // les donnees commencent toujours a la ligne 1, qu'il y ait ou non des entetes |
|
| 153 | - $nb++; |
|
| 154 | - |
|
| 155 | - if ($options['envoyer']) { |
|
| 156 | - $disposition = ($options['envoyer'] === 'attachment' ? 'attachment' : 'inline'); |
|
| 157 | - header("Content-Type: text/comma-separated-values; charset=$charset"); |
|
| 158 | - header("Content-Disposition: $disposition; filename=$basename"); |
|
| 159 | - |
|
| 160 | - // Vider tous les tampons |
|
| 161 | - $level = @ob_get_level(); |
|
| 162 | - while ($level--) { |
|
| 163 | - @ob_end_flush(); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // si envoyer=='attachment' on passe par un fichier temporaire |
|
| 168 | - // sinon on ecrit directement sur stdout |
|
| 169 | - if ($options['envoyer'] && $options['envoyer'] !== 'attachment') { |
|
| 170 | - $fichier = 'php://output'; |
|
| 171 | - } |
|
| 172 | - else { |
|
| 173 | - $fichier = sous_repertoire(_DIR_CACHE, 'export') . $basename; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - $fp = fopen($fichier, 'w'); |
|
| 177 | - $length = fwrite($fp, $output); |
|
| 178 | - |
|
| 179 | - while ($row = is_array($resource) ? array_shift($resource) : sql_fetch($resource)) { |
|
| 180 | - $output = exporter_csv_ligne_numerotee($nb, $row, $options['delim'], $importer_charset, $options['callback']); |
|
| 181 | - $length += fwrite($fp, $output); |
|
| 182 | - $nb++; |
|
| 183 | - } |
|
| 184 | - fclose($fp); |
|
| 185 | - |
|
| 186 | - if ($options['envoyer']) { |
|
| 187 | - if ($options['envoyer'] === 'attachment') { |
|
| 188 | - header("Content-Length: $length"); |
|
| 189 | - readfile($fichier); |
|
| 190 | - } |
|
| 191 | - // si on a envoye inline, c'est deja tout bon |
|
| 192 | - exit; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - return $fichier; |
|
| 93 | + // support ancienne syntaxe |
|
| 94 | + // inc_exporter_csv_dist($titre, $resource, $delim = ', ', $entetes = null, $envoyer = true) |
|
| 95 | + if (is_string($options)) { |
|
| 96 | + $args = func_get_args(); |
|
| 97 | + $options = []; |
|
| 98 | + foreach ([2 => 'delim', 3 => 'entetes', 4 => 'envoyer'] as $k => $option) { |
|
| 99 | + if (!empty($args[$k])) { |
|
| 100 | + $options[$option] = $args[$k]; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $default_options = [ |
|
| 106 | + 'fichier' => null, // par défaut = $titre |
|
| 107 | + 'extension' => null, // par défaut = choix auto |
|
| 108 | + 'delim' => ',', |
|
| 109 | + 'entetes' => null, |
|
| 110 | + 'envoyer' => true, |
|
| 111 | + 'charset' => null, |
|
| 112 | + 'callback' => null, |
|
| 113 | + ]; |
|
| 114 | + $options = array_merge($default_options, $options); |
|
| 115 | + |
|
| 116 | + // Délimiteur |
|
| 117 | + if ($options['delim'] == 'TAB') { |
|
| 118 | + $options['delim'] = "\t"; |
|
| 119 | + } |
|
| 120 | + if (!in_array($options['delim'], [',', ';', "\t"])) { |
|
| 121 | + $options['delim'] = ','; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // Nom du fichier : celui indiqué dans les options, sinon le titre |
|
| 125 | + // Normalisation : uniquement les caractères non spéciaux, tirets, underscore et point + remplacer espaces par underscores |
|
| 126 | + $filename = $options['fichier'] ?? translitteration(textebrut(typo($titre))); |
|
| 127 | + $filename = preg_replace([',[^\w\-_\.\s]+,', ',\s+,'], ['', '_'], trim((string) $filename)); |
|
| 128 | + $filename = rtrim($filename, '.'); |
|
| 129 | + |
|
| 130 | + // Extension : celle indiquée en option, sinon choisie selon le délimiteur |
|
| 131 | + // Normalisation : uniquement les charactères non spéciaux |
|
| 132 | + if (!empty($options['extension'])) { |
|
| 133 | + $options['extension'] = preg_replace(',[^\w]+,', '', trim((string) $options['extension'])); |
|
| 134 | + } |
|
| 135 | + $extension = $options['extension'] ?? ($options['delim'] === ',' ? 'csv' : 'xls'); |
|
| 136 | + |
|
| 137 | + // Fichier |
|
| 138 | + $basename = "$filename.$extension"; |
|
| 139 | + |
|
| 140 | + // Charset : celui indiqué en option, sinon celui compatible excel si nécessaire, sinon celui du site |
|
| 141 | + // Excel n'accepte pas l'utf-8 ni les entites html... on transcode tout ce qu'on peut |
|
| 142 | + $charset_site = $GLOBALS['meta']['charset']; |
|
| 143 | + $charset_excel = ($extension === 'xls' ? 'iso-8859-1' : null); |
|
| 144 | + $charset = $options['charset'] ?? $charset_excel ?? $charset_site; |
|
| 145 | + $importer_charset = (($charset === $charset_site) ? null : $charset); |
|
| 146 | + |
|
| 147 | + $output = ''; |
|
| 148 | + $nb = 0; |
|
| 149 | + if (!empty($options['entetes']) && is_array($options['entetes'])) { |
|
| 150 | + $output = exporter_csv_ligne_numerotee($nb, $options['entetes'], $options['delim'], $importer_charset, $options['callback']); |
|
| 151 | + } |
|
| 152 | + // les donnees commencent toujours a la ligne 1, qu'il y ait ou non des entetes |
|
| 153 | + $nb++; |
|
| 154 | + |
|
| 155 | + if ($options['envoyer']) { |
|
| 156 | + $disposition = ($options['envoyer'] === 'attachment' ? 'attachment' : 'inline'); |
|
| 157 | + header("Content-Type: text/comma-separated-values; charset=$charset"); |
|
| 158 | + header("Content-Disposition: $disposition; filename=$basename"); |
|
| 159 | + |
|
| 160 | + // Vider tous les tampons |
|
| 161 | + $level = @ob_get_level(); |
|
| 162 | + while ($level--) { |
|
| 163 | + @ob_end_flush(); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // si envoyer=='attachment' on passe par un fichier temporaire |
|
| 168 | + // sinon on ecrit directement sur stdout |
|
| 169 | + if ($options['envoyer'] && $options['envoyer'] !== 'attachment') { |
|
| 170 | + $fichier = 'php://output'; |
|
| 171 | + } |
|
| 172 | + else { |
|
| 173 | + $fichier = sous_repertoire(_DIR_CACHE, 'export') . $basename; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + $fp = fopen($fichier, 'w'); |
|
| 177 | + $length = fwrite($fp, $output); |
|
| 178 | + |
|
| 179 | + while ($row = is_array($resource) ? array_shift($resource) : sql_fetch($resource)) { |
|
| 180 | + $output = exporter_csv_ligne_numerotee($nb, $row, $options['delim'], $importer_charset, $options['callback']); |
|
| 181 | + $length += fwrite($fp, $output); |
|
| 182 | + $nb++; |
|
| 183 | + } |
|
| 184 | + fclose($fp); |
|
| 185 | + |
|
| 186 | + if ($options['envoyer']) { |
|
| 187 | + if ($options['envoyer'] === 'attachment') { |
|
| 188 | + header("Content-Length: $length"); |
|
| 189 | + readfile($fichier); |
|
| 190 | + } |
|
| 191 | + // si on a envoye inline, c'est deja tout bon |
|
| 192 | + exit; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + return $fichier; |
|
| 196 | 196 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @package SPIP\Core\Drapeaux\Edition |
| 30 | 30 | **/ |
| 31 | 31 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 32 | - return; |
|
| 32 | + return; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -44,46 +44,46 @@ discard block |
||
| 44 | 44 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 45 | 45 | **/ |
| 46 | 46 | function lire_tableau_edition() { |
| 47 | - $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 48 | - if (!$edition) { |
|
| 49 | - return []; |
|
| 50 | - } |
|
| 51 | - $changed = false; |
|
| 47 | + $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 48 | + if (!$edition) { |
|
| 49 | + return []; |
|
| 50 | + } |
|
| 51 | + $changed = false; |
|
| 52 | 52 | |
| 53 | - $bon_pour_le_service = time() - 3600; |
|
| 54 | - // parcourir le tableau et virer les vieux |
|
| 55 | - foreach ($edition as $objet => $data) { |
|
| 56 | - if (!is_array($data)) { |
|
| 57 | - unset($edition[$objet]); |
|
| 58 | - } // vieille version |
|
| 59 | - else { |
|
| 60 | - foreach ($data as $id => $tab) { |
|
| 61 | - if (!is_array($tab)) { |
|
| 62 | - unset($edition[$objet][$tab]); |
|
| 63 | - } // vieille version |
|
| 64 | - else { |
|
| 65 | - foreach ($tab as $n => $duo) { |
|
| 66 | - if (current($duo) < $bon_pour_le_service) { |
|
| 67 | - unset($edition[$objet][$id][$n]); |
|
| 68 | - $changed = true; |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - if (!$edition[$objet][$id]) { |
|
| 73 | - unset($edition[$objet][$id]); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - if (!$edition[$objet]) { |
|
| 78 | - unset($edition[$objet]); |
|
| 79 | - } |
|
| 80 | - } |
|
| 53 | + $bon_pour_le_service = time() - 3600; |
|
| 54 | + // parcourir le tableau et virer les vieux |
|
| 55 | + foreach ($edition as $objet => $data) { |
|
| 56 | + if (!is_array($data)) { |
|
| 57 | + unset($edition[$objet]); |
|
| 58 | + } // vieille version |
|
| 59 | + else { |
|
| 60 | + foreach ($data as $id => $tab) { |
|
| 61 | + if (!is_array($tab)) { |
|
| 62 | + unset($edition[$objet][$tab]); |
|
| 63 | + } // vieille version |
|
| 64 | + else { |
|
| 65 | + foreach ($tab as $n => $duo) { |
|
| 66 | + if (current($duo) < $bon_pour_le_service) { |
|
| 67 | + unset($edition[$objet][$id][$n]); |
|
| 68 | + $changed = true; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + if (!$edition[$objet][$id]) { |
|
| 73 | + unset($edition[$objet][$id]); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + if (!$edition[$objet]) { |
|
| 78 | + unset($edition[$objet]); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - if ($changed) { |
|
| 83 | - ecrire_tableau_edition($edition); |
|
| 84 | - } |
|
| 82 | + if ($changed) { |
|
| 83 | + ecrire_tableau_edition($edition); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return $edition; |
|
| 86 | + return $edition; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 97 | 97 | **/ |
| 98 | 98 | function ecrire_tableau_edition($edition) { |
| 99 | - ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 99 | + ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -116,22 +116,22 @@ discard block |
||
| 116 | 116 | * Type d'objet édité |
| 117 | 117 | */ |
| 118 | 118 | function signale_edition($id, $auteur, $type = 'article') { |
| 119 | - include_spip('base/objets'); |
|
| 120 | - include_spip('inc/filtres'); |
|
| 121 | - if (objet_info($type, 'editable') !== 'oui') { |
|
| 122 | - return; |
|
| 123 | - } |
|
| 119 | + include_spip('base/objets'); |
|
| 120 | + include_spip('inc/filtres'); |
|
| 121 | + if (objet_info($type, 'editable') !== 'oui') { |
|
| 122 | + return; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - $edition = lire_tableau_edition(); |
|
| 125 | + $edition = lire_tableau_edition(); |
|
| 126 | 126 | |
| 127 | - $nom = $auteur['nom'] ?? $GLOBALS['ip']; |
|
| 128 | - $id_a = $auteur['id_auteur'] ?? $GLOBALS['ip']; |
|
| 127 | + $nom = $auteur['nom'] ?? $GLOBALS['ip']; |
|
| 128 | + $id_a = $auteur['id_auteur'] ?? $GLOBALS['ip']; |
|
| 129 | 129 | |
| 130 | - if (!isset($edition[$type][$id]) || !is_array($edition[$type][$id])) { |
|
| 131 | - $edition[$type][$id] = []; |
|
| 132 | - } |
|
| 133 | - $edition[$type][$id][$id_a][$nom] = time(); |
|
| 134 | - ecrire_tableau_edition($edition); |
|
| 130 | + if (!isset($edition[$type][$id]) || !is_array($edition[$type][$id])) { |
|
| 131 | + $edition[$type][$id] = []; |
|
| 132 | + } |
|
| 133 | + $edition[$type][$id][$id_a][$nom] = time(); |
|
| 134 | + ecrire_tableau_edition($edition); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | function qui_edite($id, $type = 'article') { |
| 150 | 150 | |
| 151 | - $edition = lire_tableau_edition(); |
|
| 151 | + $edition = lire_tableau_edition(); |
|
| 152 | 152 | |
| 153 | - return empty($edition[$type][$id]) ? [] : $edition[$type][$id]; |
|
| 153 | + return empty($edition[$type][$id]) ? [] : $edition[$type][$id]; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -164,23 +164,23 @@ discard block |
||
| 164 | 164 | * Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]` |
| 165 | 165 | */ |
| 166 | 166 | function mention_qui_edite($id, $type = 'article'): array { |
| 167 | - $modif = qui_edite($id, $type); |
|
| 168 | - unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 167 | + $modif = qui_edite($id, $type); |
|
| 168 | + unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 169 | 169 | |
| 170 | - if ($modif) { |
|
| 171 | - $quand = 0; |
|
| 172 | - foreach ($modif as $duo) { |
|
| 173 | - $auteurs[] = typo(key($duo)); |
|
| 174 | - $quand = max($quand, current($duo)); |
|
| 175 | - } |
|
| 170 | + if ($modif) { |
|
| 171 | + $quand = 0; |
|
| 172 | + foreach ($modif as $duo) { |
|
| 173 | + $auteurs[] = typo(key($duo)); |
|
| 174 | + $quand = max($quand, current($duo)); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - // format lie a la chaine de langue 'avis_article_modifie' |
|
| 178 | - return [ |
|
| 179 | - 'nom_auteur_modif' => implode(' | ', $auteurs), |
|
| 180 | - 'date_diff' => ceil((time() - $quand) / 60) |
|
| 181 | - ]; |
|
| 182 | - } |
|
| 183 | - return []; |
|
| 177 | + // format lie a la chaine de langue 'avis_article_modifie' |
|
| 178 | + return [ |
|
| 179 | + 'nom_auteur_modif' => implode(' | ', $auteurs), |
|
| 180 | + 'date_diff' => ceil((time() - $quand) / 60) |
|
| 181 | + ]; |
|
| 182 | + } |
|
| 183 | + return []; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -194,25 +194,25 @@ discard block |
||
| 194 | 194 | * Liste de tableaux `['objet' => x, 'id_objet' => n]` |
| 195 | 195 | */ |
| 196 | 196 | function liste_drapeau_edition($id_auteur) { |
| 197 | - $edition = lire_tableau_edition(); |
|
| 198 | - $objets_ouverts = []; |
|
| 197 | + $edition = lire_tableau_edition(); |
|
| 198 | + $objets_ouverts = []; |
|
| 199 | 199 | |
| 200 | - foreach ($edition as $objet => $data) { |
|
| 201 | - foreach ($data as $id => $auteurs) { |
|
| 202 | - if ( |
|
| 203 | - isset($auteurs[$id_auteur]) |
|
| 204 | - && is_array($auteurs[$id_auteur]) |
|
| 205 | - && array_pop($auteurs[$id_auteur]) > time() - 3600 |
|
| 206 | - ) { |
|
| 207 | - $objets_ouverts[] = [ |
|
| 208 | - 'objet' => $objet, |
|
| 209 | - 'id_objet' => $id, |
|
| 210 | - ]; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 200 | + foreach ($edition as $objet => $data) { |
|
| 201 | + foreach ($data as $id => $auteurs) { |
|
| 202 | + if ( |
|
| 203 | + isset($auteurs[$id_auteur]) |
|
| 204 | + && is_array($auteurs[$id_auteur]) |
|
| 205 | + && array_pop($auteurs[$id_auteur]) > time() - 3600 |
|
| 206 | + ) { |
|
| 207 | + $objets_ouverts[] = [ |
|
| 208 | + 'objet' => $objet, |
|
| 209 | + 'id_objet' => $id, |
|
| 210 | + ]; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - return $objets_ouverts; |
|
| 215 | + return $objets_ouverts; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -225,15 +225,15 @@ discard block |
||
| 225 | 225 | * @return void |
| 226 | 226 | */ |
| 227 | 227 | function debloquer_tous($id_auteur) { |
| 228 | - $edition = lire_tableau_edition(); |
|
| 229 | - foreach ($edition as $objet => $data) { |
|
| 230 | - foreach ($data as $id => $auteurs) { |
|
| 231 | - if (isset($auteurs[$id_auteur])) { |
|
| 232 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 233 | - ecrire_tableau_edition($edition); |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - } |
|
| 228 | + $edition = lire_tableau_edition(); |
|
| 229 | + foreach ($edition as $objet => $data) { |
|
| 230 | + foreach ($data as $id => $auteurs) { |
|
| 231 | + if (isset($auteurs[$id_auteur])) { |
|
| 232 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 233 | + ecrire_tableau_edition($edition); |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -251,19 +251,19 @@ discard block |
||
| 251 | 251 | * @return void |
| 252 | 252 | */ |
| 253 | 253 | function debloquer_edition($id_auteur, $id_objet, $type = 'article') { |
| 254 | - $edition = lire_tableau_edition(); |
|
| 254 | + $edition = lire_tableau_edition(); |
|
| 255 | 255 | |
| 256 | - foreach ($edition as $objet => $data) { |
|
| 257 | - if ($objet == $type) { |
|
| 258 | - foreach ($data as $id => $auteurs) { |
|
| 259 | - if ( |
|
| 260 | - $id == $id_objet |
|
| 261 | - && isset($auteurs[$id_auteur]) |
|
| 262 | - ) { |
|
| 263 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 264 | - ecrire_tableau_edition($edition); |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - } |
|
| 256 | + foreach ($edition as $objet => $data) { |
|
| 257 | + if ($objet == $type) { |
|
| 258 | + foreach ($data as $id => $auteurs) { |
|
| 259 | + if ( |
|
| 260 | + $id == $id_objet |
|
| 261 | + && isset($auteurs[$id_auteur]) |
|
| 262 | + ) { |
|
| 263 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 264 | + ecrire_tableau_edition($edition); |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | 269 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if (!str_starts_with($fichier, (string) _DIR_IMG)) { |
| 64 | - $fichier = _DIR_IMG . $fichier; |
|
| 64 | + $fichier = _DIR_IMG.$fichier; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // fichier normal |
@@ -154,22 +154,22 @@ discard block |
||
| 154 | 154 | || !($r = verifier_upload_autorise($dest)) |
| 155 | 155 | || !empty($r['autozip']) |
| 156 | 156 | ) { |
| 157 | - $dest = substr($dest, 0, -strlen($m[0])) . '_' . $m[1]; |
|
| 157 | + $dest = substr($dest, 0, -strlen($m[0])).'_'.$m[1]; |
|
| 158 | 158 | break; |
| 159 | 159 | } else { |
| 160 | 160 | $dest = substr($dest, 0, -strlen($m[0])); |
| 161 | - $ext = $m[1] . '.' . $ext; |
|
| 161 | + $ext = $m[1].'.'.$ext; |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Si le document "source" est deja au bon endroit, ne rien faire |
| 166 | - if ($source == ($dir . $dest . '.' . $ext)) { |
|
| 166 | + if ($source == ($dir.$dest.'.'.$ext)) { |
|
| 167 | 167 | return $source; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // sinon tourner jusqu'a trouver un numero correct |
| 171 | 171 | $n = 0; |
| 172 | - while (@file_exists($newFile = $dir . $dest . ($n++ ? ('-' . $n) : '') . '.' . $ext)) { |
|
| 172 | + while (@file_exists($newFile = $dir.$dest.($n++ ? ('-'.$n) : '').'.'.$ext)) { |
|
| 173 | 173 | ; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | function deplacer_fichier_upload($source, $dest, $move = false) { |
| 231 | 231 | // Securite |
| 232 | 232 | if (str_starts_with($dest, (string) _DIR_RACINE)) { |
| 233 | - $dest = _DIR_RACINE . preg_replace(',\.\.+,', '.', substr($dest, strlen((string) _DIR_RACINE))); |
|
| 233 | + $dest = _DIR_RACINE.preg_replace(',\.\.+,', '.', substr($dest, strlen((string) _DIR_RACINE))); |
|
| 234 | 234 | } else { |
| 235 | 235 | $dest = preg_replace(',\.\.+,', '.', $dest); |
| 236 | 236 | } |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | default: /* autre */ |
| 310 | 310 | if (!$msg) { |
| 311 | - $msg = _T('pass_erreur') . ' ' . $error |
|
| 312 | - . '<br />' . propre('[->http://php.net/manual/fr/features.file-upload.errors.php]'); |
|
| 311 | + $msg = _T('pass_erreur').' '.$error |
|
| 312 | + . '<br />'.propre('[->http://php.net/manual/fr/features.file-upload.errors.php]'); |
|
| 313 | 313 | } |
| 314 | 314 | break; |
| 315 | 315 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | include_spip('inc/minipres'); |
| 328 | 328 | echo minipres( |
| 329 | 329 | $msg, |
| 330 | - "<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><a href='" . rawurldecode((string) $GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . '</button></a></div>' |
|
| 330 | + "<div style='text-align: ".$GLOBALS['spip_lang_right']."'><a href='".rawurldecode((string) $GLOBALS['redirect'])."'><button type='button'>"._T('ecrire:bouton_suivant').'</button></a></div>' |
|
| 331 | 331 | ); |
| 332 | 332 | exit; |
| 333 | 333 | } |
@@ -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 | /** |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | 31 | function set_spip_doc(?string $fichier): string { |
| 32 | - if ($fichier && str_starts_with($fichier, (string) _DIR_IMG)) { |
|
| 33 | - return substr($fichier, strlen((string) _DIR_IMG)); |
|
| 34 | - } else { |
|
| 35 | - // ex: fichier distant |
|
| 36 | - return $fichier ?? ''; |
|
| 37 | - } |
|
| 32 | + if ($fichier && str_starts_with($fichier, (string) _DIR_IMG)) { |
|
| 33 | + return substr($fichier, strlen((string) _DIR_IMG)); |
|
| 34 | + } else { |
|
| 35 | + // ex: fichier distant |
|
| 36 | + return $fichier ?? ''; |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -46,26 +46,26 @@ discard block |
||
| 46 | 46 | * @return bool|string |
| 47 | 47 | */ |
| 48 | 48 | function get_spip_doc(?string $fichier) { |
| 49 | - if ($fichier === null) { |
|
| 50 | - return false; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - // fichier distant |
|
| 54 | - if (tester_url_absolue($fichier)) { |
|
| 55 | - return $fichier; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - // gestion d'erreurs, fichier='' |
|
| 59 | - if (!strlen($fichier)) { |
|
| 60 | - return false; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if (!str_starts_with($fichier, (string) _DIR_IMG)) { |
|
| 64 | - $fichier = _DIR_IMG . $fichier; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // fichier normal |
|
| 68 | - return $fichier; |
|
| 49 | + if ($fichier === null) { |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + // fichier distant |
|
| 54 | + if (tester_url_absolue($fichier)) { |
|
| 55 | + return $fichier; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + // gestion d'erreurs, fichier='' |
|
| 59 | + if (!strlen($fichier)) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if (!str_starts_with($fichier, (string) _DIR_IMG)) { |
|
| 64 | + $fichier = _DIR_IMG . $fichier; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // fichier normal |
|
| 68 | + return $fichier; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -79,26 +79,26 @@ discard block |
||
| 79 | 79 | * @return string |
| 80 | 80 | */ |
| 81 | 81 | function creer_repertoire_documents($ext) { |
| 82 | - $rep = sous_repertoire(_DIR_IMG, $ext); |
|
| 83 | - |
|
| 84 | - if (!$ext || !$rep) { |
|
| 85 | - spip_logger()->info("creer_repertoire_documents '$rep' interdit"); |
|
| 86 | - exit; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - // Cette variable de configuration peut etre posee par un plugin |
|
| 90 | - // par exemple acces_restreint |
|
| 91 | - // sauf pour logo/ utilise pour stocker les logoon et logooff |
|
| 92 | - if ( |
|
| 93 | - isset($GLOBALS['meta']['creer_htaccess']) |
|
| 94 | - && $GLOBALS['meta']['creer_htaccess'] == 'oui' |
|
| 95 | - && $ext !== 'logo' |
|
| 96 | - ) { |
|
| 97 | - include_spip('inc/acces'); |
|
| 98 | - verifier_htaccess($rep); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - return $rep; |
|
| 82 | + $rep = sous_repertoire(_DIR_IMG, $ext); |
|
| 83 | + |
|
| 84 | + if (!$ext || !$rep) { |
|
| 85 | + spip_logger()->info("creer_repertoire_documents '$rep' interdit"); |
|
| 86 | + exit; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + // Cette variable de configuration peut etre posee par un plugin |
|
| 90 | + // par exemple acces_restreint |
|
| 91 | + // sauf pour logo/ utilise pour stocker les logoon et logooff |
|
| 92 | + if ( |
|
| 93 | + isset($GLOBALS['meta']['creer_htaccess']) |
|
| 94 | + && $GLOBALS['meta']['creer_htaccess'] == 'oui' |
|
| 95 | + && $ext !== 'logo' |
|
| 96 | + ) { |
|
| 97 | + include_spip('inc/acces'); |
|
| 98 | + verifier_htaccess($rep); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + return $rep; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -107,19 +107,19 @@ discard block |
||
| 107 | 107 | * @param string $nom |
| 108 | 108 | */ |
| 109 | 109 | function effacer_repertoire_temporaire($nom) { |
| 110 | - if ($d = opendir($nom)) { |
|
| 111 | - while (($f = readdir($d)) !== false) { |
|
| 112 | - if (is_file("$nom/$f")) { |
|
| 113 | - spip_unlink("$nom/$f"); |
|
| 114 | - } else { |
|
| 115 | - if ($f != '.' && $f != '..' && is_dir("$nom/$f")) { |
|
| 116 | - effacer_repertoire_temporaire("$nom/$f"); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - closedir($d); |
|
| 122 | - @rmdir($nom); |
|
| 110 | + if ($d = opendir($nom)) { |
|
| 111 | + while (($f = readdir($d)) !== false) { |
|
| 112 | + if (is_file("$nom/$f")) { |
|
| 113 | + spip_unlink("$nom/$f"); |
|
| 114 | + } else { |
|
| 115 | + if ($f != '.' && $f != '..' && is_dir("$nom/$f")) { |
|
| 116 | + effacer_repertoire_temporaire("$nom/$f"); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + closedir($d); |
|
| 122 | + @rmdir($nom); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // |
@@ -136,44 +136,44 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | function copier_document($ext, $orig, $source, $subdir = null) { |
| 138 | 138 | |
| 139 | - $orig = preg_replace(',\.\.+,', '.', $orig); // pas de .. dans le nom du doc |
|
| 140 | - $dir = creer_repertoire_documents($subdir ?: $ext); |
|
| 141 | - |
|
| 142 | - $dest = preg_replace('/<[^>]*>/', '', basename($orig)); |
|
| 143 | - $dest = preg_replace('/\.([^.]+)$/', '', $dest); |
|
| 144 | - $dest = translitteration($dest); |
|
| 145 | - $dest = preg_replace('/[^.=\w-]+/', '_', (string) $dest); |
|
| 146 | - |
|
| 147 | - // ne pas accepter de noms de la forme -r90.jpg qui sont reserves |
|
| 148 | - // pour les images transformees par rotation (action/documenter) |
|
| 149 | - $dest = preg_replace(',-r(90|180|270)$,', '', $dest); |
|
| 150 | - |
|
| 151 | - while (preg_match(',\.(\w+)$,', $dest, $m)) { |
|
| 152 | - if ( |
|
| 153 | - !function_exists('verifier_upload_autorise') |
|
| 154 | - || !($r = verifier_upload_autorise($dest)) |
|
| 155 | - || !empty($r['autozip']) |
|
| 156 | - ) { |
|
| 157 | - $dest = substr($dest, 0, -strlen($m[0])) . '_' . $m[1]; |
|
| 158 | - break; |
|
| 159 | - } else { |
|
| 160 | - $dest = substr($dest, 0, -strlen($m[0])); |
|
| 161 | - $ext = $m[1] . '.' . $ext; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // Si le document "source" est deja au bon endroit, ne rien faire |
|
| 166 | - if ($source == ($dir . $dest . '.' . $ext)) { |
|
| 167 | - return $source; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - // sinon tourner jusqu'a trouver un numero correct |
|
| 171 | - $n = 0; |
|
| 172 | - while (@file_exists($newFile = $dir . $dest . ($n++ ? ('-' . $n) : '') . '.' . $ext)) { |
|
| 173 | - ; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - return deplacer_fichier_upload($source, $newFile); |
|
| 139 | + $orig = preg_replace(',\.\.+,', '.', $orig); // pas de .. dans le nom du doc |
|
| 140 | + $dir = creer_repertoire_documents($subdir ?: $ext); |
|
| 141 | + |
|
| 142 | + $dest = preg_replace('/<[^>]*>/', '', basename($orig)); |
|
| 143 | + $dest = preg_replace('/\.([^.]+)$/', '', $dest); |
|
| 144 | + $dest = translitteration($dest); |
|
| 145 | + $dest = preg_replace('/[^.=\w-]+/', '_', (string) $dest); |
|
| 146 | + |
|
| 147 | + // ne pas accepter de noms de la forme -r90.jpg qui sont reserves |
|
| 148 | + // pour les images transformees par rotation (action/documenter) |
|
| 149 | + $dest = preg_replace(',-r(90|180|270)$,', '', $dest); |
|
| 150 | + |
|
| 151 | + while (preg_match(',\.(\w+)$,', $dest, $m)) { |
|
| 152 | + if ( |
|
| 153 | + !function_exists('verifier_upload_autorise') |
|
| 154 | + || !($r = verifier_upload_autorise($dest)) |
|
| 155 | + || !empty($r['autozip']) |
|
| 156 | + ) { |
|
| 157 | + $dest = substr($dest, 0, -strlen($m[0])) . '_' . $m[1]; |
|
| 158 | + break; |
|
| 159 | + } else { |
|
| 160 | + $dest = substr($dest, 0, -strlen($m[0])); |
|
| 161 | + $ext = $m[1] . '.' . $ext; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // Si le document "source" est deja au bon endroit, ne rien faire |
|
| 166 | + if ($source == ($dir . $dest . '.' . $ext)) { |
|
| 167 | + return $source; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + // sinon tourner jusqu'a trouver un numero correct |
|
| 171 | + $n = 0; |
|
| 172 | + while (@file_exists($newFile = $dir . $dest . ($n++ ? ('-' . $n) : '') . '.' . $ext)) { |
|
| 173 | + ; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + return deplacer_fichier_upload($source, $newFile); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -188,28 +188,28 @@ discard block |
||
| 188 | 188 | * @return bool|string |
| 189 | 189 | */ |
| 190 | 190 | function determine_upload($type = '') { |
| 191 | - if (!function_exists('autoriser')) { |
|
| 192 | - include_spip('inc/autoriser'); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - if ( |
|
| 196 | - !autoriser('chargerftp') |
|
| 197 | - || $type == 'logos' |
|
| 198 | - ) { # on ne le permet pas pour les logos |
|
| 199 | - return false; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - $repertoire = _DIR_TRANSFERT; |
|
| 203 | - if (!@is_dir($repertoire)) { |
|
| 204 | - $repertoire = str_replace(_DIR_TMP, '', (string) $repertoire); |
|
| 205 | - $repertoire = sous_repertoire(_DIR_TMP, $repertoire); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - if (!$GLOBALS['visiteur_session']['restreint']) { |
|
| 209 | - return $repertoire; |
|
| 210 | - } else { |
|
| 211 | - return sous_repertoire($repertoire, $GLOBALS['visiteur_session']['login']); |
|
| 212 | - } |
|
| 191 | + if (!function_exists('autoriser')) { |
|
| 192 | + include_spip('inc/autoriser'); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + if ( |
|
| 196 | + !autoriser('chargerftp') |
|
| 197 | + || $type == 'logos' |
|
| 198 | + ) { # on ne le permet pas pour les logos |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + $repertoire = _DIR_TRANSFERT; |
|
| 203 | + if (!@is_dir($repertoire)) { |
|
| 204 | + $repertoire = str_replace(_DIR_TMP, '', (string) $repertoire); |
|
| 205 | + $repertoire = sous_repertoire(_DIR_TMP, $repertoire); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + if (!$GLOBALS['visiteur_session']['restreint']) { |
|
| 209 | + return $repertoire; |
|
| 210 | + } else { |
|
| 211 | + return sous_repertoire($repertoire, $GLOBALS['visiteur_session']['login']); |
|
| 212 | + } |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -228,31 +228,31 @@ discard block |
||
| 228 | 228 | * @return bool|mixed|string |
| 229 | 229 | */ |
| 230 | 230 | function deplacer_fichier_upload($source, $dest, $move = false) { |
| 231 | - // Securite |
|
| 232 | - if (str_starts_with($dest, (string) _DIR_RACINE)) { |
|
| 233 | - $dest = _DIR_RACINE . preg_replace(',\.\.+,', '.', substr($dest, strlen((string) _DIR_RACINE))); |
|
| 234 | - } else { |
|
| 235 | - $dest = preg_replace(',\.\.+,', '.', $dest); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - $ok = $move ? @rename($source, $dest) : @copy($source, $dest); |
|
| 239 | - if (!$ok) { |
|
| 240 | - $ok = @move_uploaded_file($source, $dest); |
|
| 241 | - } |
|
| 242 | - if ($ok) { |
|
| 243 | - @chmod($dest, _SPIP_CHMOD & ~0111); |
|
| 244 | - } else { |
|
| 245 | - $f = @fopen($dest, 'w'); |
|
| 246 | - if ($f) { |
|
| 247 | - fclose($f); |
|
| 248 | - } else { |
|
| 249 | - include_spip('inc/flock'); |
|
| 250 | - raler_fichier($dest); |
|
| 251 | - } |
|
| 252 | - spip_unlink($dest); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - return $ok ? $dest : false; |
|
| 231 | + // Securite |
|
| 232 | + if (str_starts_with($dest, (string) _DIR_RACINE)) { |
|
| 233 | + $dest = _DIR_RACINE . preg_replace(',\.\.+,', '.', substr($dest, strlen((string) _DIR_RACINE))); |
|
| 234 | + } else { |
|
| 235 | + $dest = preg_replace(',\.\.+,', '.', $dest); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + $ok = $move ? @rename($source, $dest) : @copy($source, $dest); |
|
| 239 | + if (!$ok) { |
|
| 240 | + $ok = @move_uploaded_file($source, $dest); |
|
| 241 | + } |
|
| 242 | + if ($ok) { |
|
| 243 | + @chmod($dest, _SPIP_CHMOD & ~0111); |
|
| 244 | + } else { |
|
| 245 | + $f = @fopen($dest, 'w'); |
|
| 246 | + if ($f) { |
|
| 247 | + fclose($f); |
|
| 248 | + } else { |
|
| 249 | + include_spip('inc/flock'); |
|
| 250 | + raler_fichier($dest); |
|
| 251 | + } |
|
| 252 | + spip_unlink($dest); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + return $ok ? $dest : false; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -276,60 +276,60 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | function check_upload_error($error, $msg = '', $return = false) { |
| 278 | 278 | |
| 279 | - if (!$error) { |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - spip_logger()->info("Erreur upload $error -- cf. http://php.net/manual/fr/features.file-upload.errors.php"); |
|
| 284 | - |
|
| 285 | - switch ($error) { |
|
| 286 | - case 4: /* UPLOAD_ERR_NO_FILE */ |
|
| 287 | - return true; |
|
| 288 | - |
|
| 289 | - # on peut affiner les differents messages d'erreur |
|
| 290 | - case 1: /* UPLOAD_ERR_INI_SIZE */ |
|
| 291 | - $msg = _T( |
|
| 292 | - 'upload_limit', |
|
| 293 | - ['max' => ini_get('upload_max_filesize')] |
|
| 294 | - ); |
|
| 295 | - break; |
|
| 296 | - case 2: /* UPLOAD_ERR_FORM_SIZE */ |
|
| 297 | - $msg = _T( |
|
| 298 | - 'upload_limit', |
|
| 299 | - ['max' => ini_get('upload_max_filesize')] |
|
| 300 | - ); |
|
| 301 | - break; |
|
| 302 | - case 3: /* UPLOAD_ERR_PARTIAL */ |
|
| 303 | - $msg = _T( |
|
| 304 | - 'upload_limit', |
|
| 305 | - ['max' => ini_get('upload_max_filesize')] |
|
| 306 | - ); |
|
| 307 | - break; |
|
| 308 | - |
|
| 309 | - default: /* autre */ |
|
| 310 | - if (!$msg) { |
|
| 311 | - $msg = _T('pass_erreur') . ' ' . $error |
|
| 312 | - . '<br />' . propre('[->http://php.net/manual/fr/features.file-upload.errors.php]'); |
|
| 313 | - } |
|
| 314 | - break; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - spip_logger()->info("erreur upload $error"); |
|
| 318 | - if ($return) { |
|
| 319 | - return $msg; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - if (_request('iframe') == 'iframe') { |
|
| 323 | - echo "<div class='upload_answer upload_error'>$msg</div>"; |
|
| 324 | - exit; |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - include_spip('inc/minipres'); |
|
| 328 | - echo minipres( |
|
| 329 | - $msg, |
|
| 330 | - "<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><a href='" . rawurldecode((string) $GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . '</button></a></div>' |
|
| 331 | - ); |
|
| 332 | - exit; |
|
| 279 | + if (!$error) { |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + spip_logger()->info("Erreur upload $error -- cf. http://php.net/manual/fr/features.file-upload.errors.php"); |
|
| 284 | + |
|
| 285 | + switch ($error) { |
|
| 286 | + case 4: /* UPLOAD_ERR_NO_FILE */ |
|
| 287 | + return true; |
|
| 288 | + |
|
| 289 | + # on peut affiner les differents messages d'erreur |
|
| 290 | + case 1: /* UPLOAD_ERR_INI_SIZE */ |
|
| 291 | + $msg = _T( |
|
| 292 | + 'upload_limit', |
|
| 293 | + ['max' => ini_get('upload_max_filesize')] |
|
| 294 | + ); |
|
| 295 | + break; |
|
| 296 | + case 2: /* UPLOAD_ERR_FORM_SIZE */ |
|
| 297 | + $msg = _T( |
|
| 298 | + 'upload_limit', |
|
| 299 | + ['max' => ini_get('upload_max_filesize')] |
|
| 300 | + ); |
|
| 301 | + break; |
|
| 302 | + case 3: /* UPLOAD_ERR_PARTIAL */ |
|
| 303 | + $msg = _T( |
|
| 304 | + 'upload_limit', |
|
| 305 | + ['max' => ini_get('upload_max_filesize')] |
|
| 306 | + ); |
|
| 307 | + break; |
|
| 308 | + |
|
| 309 | + default: /* autre */ |
|
| 310 | + if (!$msg) { |
|
| 311 | + $msg = _T('pass_erreur') . ' ' . $error |
|
| 312 | + . '<br />' . propre('[->http://php.net/manual/fr/features.file-upload.errors.php]'); |
|
| 313 | + } |
|
| 314 | + break; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + spip_logger()->info("erreur upload $error"); |
|
| 318 | + if ($return) { |
|
| 319 | + return $msg; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + if (_request('iframe') == 'iframe') { |
|
| 323 | + echo "<div class='upload_answer upload_error'>$msg</div>"; |
|
| 324 | + exit; |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + include_spip('inc/minipres'); |
|
| 328 | + echo minipres( |
|
| 329 | + $msg, |
|
| 330 | + "<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><a href='" . rawurldecode((string) $GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . '</button></a></div>' |
|
| 331 | + ); |
|
| 332 | + exit; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -346,14 +346,14 @@ discard block |
||
| 346 | 346 | * @return string |
| 347 | 347 | */ |
| 348 | 348 | function corriger_extension($ext) { |
| 349 | - $ext = preg_replace(',[^a-z0-9],i', '', $ext); |
|
| 350 | - |
|
| 351 | - return match ($ext) { |
|
| 352 | - 'htm' => 'html', |
|
| 353 | - 'jpeg' => 'jpg', |
|
| 354 | - 'tiff' => 'tif', |
|
| 355 | - 'aif' => 'aiff', |
|
| 356 | - 'mpeg' => 'mpg', |
|
| 357 | - default => $ext, |
|
| 358 | - }; |
|
| 349 | + $ext = preg_replace(',[^a-z0-9],i', '', $ext); |
|
| 350 | + |
|
| 351 | + return match ($ext) { |
|
| 352 | + 'htm' => 'html', |
|
| 353 | + 'jpeg' => 'jpg', |
|
| 354 | + 'tiff' => 'tif', |
|
| 355 | + 'aif' => 'aiff', |
|
| 356 | + 'mpeg' => 'mpg', |
|
| 357 | + default => $ext, |
|
| 358 | + }; |
|
| 359 | 359 | } |
@@ -19,19 +19,19 @@ |
||
| 19 | 19 | * Retourne la liste des menus favoris par défaut ainsi que leur rang |
| 20 | 20 | */ |
| 21 | 21 | function inc_definir_menus_favoris_dist() { |
| 22 | - return [ |
|
| 22 | + return [ |
|
| 23 | 23 | |
| 24 | - // Menu Édition, |
|
| 25 | - 'auteurs' => 1, |
|
| 26 | - 'rubriques' => 2, |
|
| 27 | - 'articles' => 3, |
|
| 24 | + // Menu Édition, |
|
| 25 | + 'auteurs' => 1, |
|
| 26 | + 'rubriques' => 2, |
|
| 27 | + 'articles' => 3, |
|
| 28 | 28 | |
| 29 | - // Menu Maintenance |
|
| 30 | - 'admin_vider' => 1, |
|
| 29 | + // Menu Maintenance |
|
| 30 | + 'admin_vider' => 1, |
|
| 31 | 31 | |
| 32 | - // Menu Configurations |
|
| 33 | - 'configurer_identite' => 1, |
|
| 34 | - 'admin_plugin' => 2, |
|
| 32 | + // Menu Configurations |
|
| 33 | + 'configurer_identite' => 1, |
|
| 34 | + 'admin_plugin' => 2, |
|
| 35 | 35 | |
| 36 | - ]; |
|
| 36 | + ]; |
|
| 37 | 37 | } |