@@ -8,32 +8,32 @@ |
||
| 8 | 8 | * Sous-noeud de Boucle |
| 9 | 9 | **/ |
| 10 | 10 | class Critere { |
| 11 | - /** Type de noeud */ |
|
| 12 | - public string $type = 'critere'; |
|
| 13 | - |
|
| 14 | - /** Opérateur (>, <, >=, IN, ...) */ |
|
| 15 | - public ?string $op = null; |
|
| 16 | - |
|
| 17 | - /** Présence d'une négation (truc !op valeur) */ |
|
| 18 | - public bool $not = false; |
|
| 19 | - |
|
| 20 | - /** Présence d'une exclusion (!truc op valeur) */ |
|
| 21 | - public string $exclus = ''; |
|
| 22 | - |
|
| 23 | - /** Présence d'une condition dans le critère (truc ?) */ |
|
| 24 | - public bool $cond = false; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Paramètres du critère |
|
| 28 | - * - $param[0] : élément avant l'opérateur |
|
| 29 | - * - $param[1..n] : éléments après l'opérateur |
|
| 30 | - * |
|
| 31 | - * FIXME: type unique. |
|
| 32 | - * @var false|array |
|
| 33 | - * - false: erreur de syntaxe |
|
| 34 | - */ |
|
| 35 | - public $param = []; |
|
| 36 | - |
|
| 37 | - /** Numéro de ligne dans le code source du squelette */ |
|
| 38 | - public int $ligne = 0; |
|
| 11 | + /** Type de noeud */ |
|
| 12 | + public string $type = 'critere'; |
|
| 13 | + |
|
| 14 | + /** Opérateur (>, <, >=, IN, ...) */ |
|
| 15 | + public ?string $op = null; |
|
| 16 | + |
|
| 17 | + /** Présence d'une négation (truc !op valeur) */ |
|
| 18 | + public bool $not = false; |
|
| 19 | + |
|
| 20 | + /** Présence d'une exclusion (!truc op valeur) */ |
|
| 21 | + public string $exclus = ''; |
|
| 22 | + |
|
| 23 | + /** Présence d'une condition dans le critère (truc ?) */ |
|
| 24 | + public bool $cond = false; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Paramètres du critère |
|
| 28 | + * - $param[0] : élément avant l'opérateur |
|
| 29 | + * - $param[1..n] : éléments après l'opérateur |
|
| 30 | + * |
|
| 31 | + * FIXME: type unique. |
|
| 32 | + * @var false|array |
|
| 33 | + * - false: erreur de syntaxe |
|
| 34 | + */ |
|
| 35 | + public $param = []; |
|
| 36 | + |
|
| 37 | + /** Numéro de ligne dans le code source du squelette */ |
|
| 38 | + public int $ligne = 0; |
|
| 39 | 39 | } |
@@ -4,21 +4,21 @@ |
||
| 4 | 4 | |
| 5 | 5 | abstract class AbstractIterateur |
| 6 | 6 | { |
| 7 | - protected string $type; |
|
| 7 | + protected string $type; |
|
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Calcul du total des elements |
|
| 11 | - * |
|
| 12 | - * @var int|null |
|
| 13 | - **/ |
|
| 14 | - public $total = null; |
|
| 9 | + /** |
|
| 10 | + * Calcul du total des elements |
|
| 11 | + * |
|
| 12 | + * @var int|null |
|
| 13 | + **/ |
|
| 14 | + public $total = null; |
|
| 15 | 15 | |
| 16 | - /** Erreur presente ? **/ |
|
| 17 | - public bool $err = false; |
|
| 16 | + /** Erreur presente ? **/ |
|
| 17 | + public bool $err = false; |
|
| 18 | 18 | |
| 19 | - public function __construct( |
|
| 20 | - protected array $command, |
|
| 21 | - protected array $info = [] |
|
| 22 | - ) { |
|
| 23 | - } |
|
| 19 | + public function __construct( |
|
| 20 | + protected array $command, |
|
| 21 | + protected array $info = [] |
|
| 22 | + ) { |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -7,32 +7,32 @@ |
||
| 7 | 7 | * privée ou dans un de ses sous menus |
| 8 | 8 | */ |
| 9 | 9 | class Bouton { |
| 10 | - /** Sous-barre de boutons / onglets */ |
|
| 11 | - public array $sousmenu = []; |
|
| 10 | + /** Sous-barre de boutons / onglets */ |
|
| 11 | + public array $sousmenu = []; |
|
| 12 | 12 | |
| 13 | - /** Position dans le menu */ |
|
| 14 | - public int $position = 0; |
|
| 13 | + /** Position dans le menu */ |
|
| 14 | + public int $position = 0; |
|
| 15 | 15 | |
| 16 | - /** Entrée favorite (sa position dans les favoris) ? */ |
|
| 17 | - public int $favori = 0; |
|
| 16 | + /** Entrée favorite (sa position dans les favoris) ? */ |
|
| 17 | + public int $favori = 0; |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Définit un bouton |
|
| 22 | - */ |
|
| 23 | - public function __construct( |
|
| 24 | - /** L'icone à mettre dans le bouton */ |
|
| 25 | - public string $icone, |
|
| 26 | - /** Le nom de l'entrée d'i18n associé */ |
|
| 27 | - public string $libelle, |
|
| 28 | - /** L'URL de la page (null => ?exec=nom) */ |
|
| 29 | - public ?string $url = null, |
|
| 30 | - /** Arguments supplémentaires de l'URL */ |
|
| 31 | - public string|array|null $urlArg = null, |
|
| 32 | - /** URL du javascript */ |
|
| 33 | - public ?string $url2 = null, |
|
| 34 | - /** Pour ouvrir une fenêtre à part */ |
|
| 35 | - public ?string $target = null |
|
| 36 | - ) { |
|
| 37 | - } |
|
| 20 | + /** |
|
| 21 | + * Définit un bouton |
|
| 22 | + */ |
|
| 23 | + public function __construct( |
|
| 24 | + /** L'icone à mettre dans le bouton */ |
|
| 25 | + public string $icone, |
|
| 26 | + /** Le nom de l'entrée d'i18n associé */ |
|
| 27 | + public string $libelle, |
|
| 28 | + /** L'URL de la page (null => ?exec=nom) */ |
|
| 29 | + public ?string $url = null, |
|
| 30 | + /** Arguments supplémentaires de l'URL */ |
|
| 31 | + public string|array|null $urlArg = null, |
|
| 32 | + /** URL du javascript */ |
|
| 33 | + public ?string $url2 = null, |
|
| 34 | + /** Pour ouvrir une fenêtre à part */ |
|
| 35 | + public ?string $target = null |
|
| 36 | + ) { |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | /** L'URL de la page (null => ?exec=nom) */ |
| 29 | 29 | public ?string $url = null, |
| 30 | 30 | /** Arguments supplémentaires de l'URL */ |
| 31 | - public string|array|null $urlArg = null, |
|
| 31 | + public string | array | null $urlArg = null, |
|
| 32 | 32 | /** URL du javascript */ |
| 33 | 33 | public ?string $url2 = null, |
| 34 | 34 | /** Pour ouvrir une fenêtre à part */ |
@@ -7,21 +7,21 @@ |
||
| 7 | 7 | * @internal |
| 8 | 8 | */ |
| 9 | 9 | class Collection implements \Stringable { |
| 10 | - private array $vars = []; |
|
| 10 | + private array $vars = []; |
|
| 11 | 11 | |
| 12 | - public function add(string $var, string $value) { |
|
| 13 | - $this->vars[$var] = $value; |
|
| 14 | - } |
|
| 12 | + public function add(string $var, string $value) { |
|
| 13 | + $this->vars[$var] = $value; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function getString(): string { |
|
| 17 | - $string = ''; |
|
| 18 | - foreach ($this->vars as $key => $value) { |
|
| 19 | - $string .= "$key: $value;\n"; |
|
| 20 | - } |
|
| 21 | - return $string; |
|
| 22 | - } |
|
| 16 | + public function getString(): string { |
|
| 17 | + $string = ''; |
|
| 18 | + foreach ($this->vars as $key => $value) { |
|
| 19 | + $string .= "$key: $value;\n"; |
|
| 20 | + } |
|
| 21 | + return $string; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function __toString(): string { |
|
| 25 | - return $this->getString(); |
|
| 26 | - } |
|
| 24 | + public function __toString(): string { |
|
| 25 | + return $this->getString(); |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -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 | /** |
@@ -32,110 +32,110 @@ discard block |
||
| 32 | 32 | * @return array |
| 33 | 33 | */ |
| 34 | 34 | function plugins_get_infos_dist($plug = false, $reload = false, $dir = _DIR_PLUGINS, $clean_old = false) { |
| 35 | - $contenu = null; |
|
| 36 | - $res = null; |
|
| 37 | - static $cache = ''; |
|
| 38 | - static $filecache = ''; |
|
| 39 | - |
|
| 40 | - if ($cache === '') { |
|
| 41 | - $filecache = _DIR_TMP . 'plugin_xml_cache.gz'; |
|
| 42 | - if (is_file($filecache)) { |
|
| 43 | - lire_fichier($filecache, $contenu); |
|
| 44 | - $cache = unserialize($contenu); |
|
| 45 | - } |
|
| 46 | - if (!is_array($cache)) { |
|
| 47 | - $cache = []; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - if (defined('_VAR_MODE') && _VAR_MODE == 'recalcul') { |
|
| 52 | - $reload = true; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - if ($plug === false) { |
|
| 56 | - ecrire_fichier($filecache, serialize($cache)); |
|
| 57 | - |
|
| 58 | - return $cache; |
|
| 59 | - } elseif (is_string($plug)) { |
|
| 60 | - $res = plugins_get_infos_un($plug, $reload, $dir, $cache); |
|
| 61 | - } elseif (is_array($plug)) { |
|
| 62 | - $res = false; |
|
| 63 | - if (!$reload) { |
|
| 64 | - $reload = -1; |
|
| 65 | - } |
|
| 66 | - foreach ($plug as $nom) { |
|
| 67 | - $res |= plugins_get_infos_un($nom, $reload, $dir, $cache); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // Nettoyer le cache des vieux plugins qui ne sont plus la |
|
| 71 | - if ($clean_old && isset($cache[$dir]) && (is_countable($cache[$dir]) ? count($cache[$dir]) : 0)) { |
|
| 72 | - foreach (array_keys($cache[$dir]) as $p) { |
|
| 73 | - if (!in_array($p, $plug)) { |
|
| 74 | - unset($cache[$dir][$p]); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - if ($res) { |
|
| 80 | - ecrire_fichier($filecache, serialize($cache)); |
|
| 81 | - } |
|
| 82 | - if (!isset($cache[$dir])) { |
|
| 83 | - return []; |
|
| 84 | - } |
|
| 85 | - if (is_string($plug)) { |
|
| 86 | - return $cache[$dir][$plug] ?? []; |
|
| 87 | - } else { |
|
| 88 | - return $cache[$dir]; |
|
| 89 | - } |
|
| 35 | + $contenu = null; |
|
| 36 | + $res = null; |
|
| 37 | + static $cache = ''; |
|
| 38 | + static $filecache = ''; |
|
| 39 | + |
|
| 40 | + if ($cache === '') { |
|
| 41 | + $filecache = _DIR_TMP . 'plugin_xml_cache.gz'; |
|
| 42 | + if (is_file($filecache)) { |
|
| 43 | + lire_fichier($filecache, $contenu); |
|
| 44 | + $cache = unserialize($contenu); |
|
| 45 | + } |
|
| 46 | + if (!is_array($cache)) { |
|
| 47 | + $cache = []; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + if (defined('_VAR_MODE') && _VAR_MODE == 'recalcul') { |
|
| 52 | + $reload = true; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + if ($plug === false) { |
|
| 56 | + ecrire_fichier($filecache, serialize($cache)); |
|
| 57 | + |
|
| 58 | + return $cache; |
|
| 59 | + } elseif (is_string($plug)) { |
|
| 60 | + $res = plugins_get_infos_un($plug, $reload, $dir, $cache); |
|
| 61 | + } elseif (is_array($plug)) { |
|
| 62 | + $res = false; |
|
| 63 | + if (!$reload) { |
|
| 64 | + $reload = -1; |
|
| 65 | + } |
|
| 66 | + foreach ($plug as $nom) { |
|
| 67 | + $res |= plugins_get_infos_un($nom, $reload, $dir, $cache); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // Nettoyer le cache des vieux plugins qui ne sont plus la |
|
| 71 | + if ($clean_old && isset($cache[$dir]) && (is_countable($cache[$dir]) ? count($cache[$dir]) : 0)) { |
|
| 72 | + foreach (array_keys($cache[$dir]) as $p) { |
|
| 73 | + if (!in_array($p, $plug)) { |
|
| 74 | + unset($cache[$dir][$p]); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + if ($res) { |
|
| 80 | + ecrire_fichier($filecache, serialize($cache)); |
|
| 81 | + } |
|
| 82 | + if (!isset($cache[$dir])) { |
|
| 83 | + return []; |
|
| 84 | + } |
|
| 85 | + if (is_string($plug)) { |
|
| 86 | + return $cache[$dir][$plug] ?? []; |
|
| 87 | + } else { |
|
| 88 | + return $cache[$dir]; |
|
| 89 | + } |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
| 93 | 93 | function plugins_get_infos_un($plug, $reload, $dir, &$cache) { |
| 94 | - if (!is_readable($file = "$dir$plug/paquet.xml")) { |
|
| 95 | - return false; |
|
| 96 | - } |
|
| 97 | - $time = (int) @filemtime($file); |
|
| 98 | - if ($time < 0) { |
|
| 99 | - return false; |
|
| 100 | - } |
|
| 101 | - $md5 = md5_file($file); |
|
| 102 | - |
|
| 103 | - $pcache = $cache[$dir][$plug] ?? ['filemtime' => 0, 'md5_file' => '']; |
|
| 104 | - |
|
| 105 | - // si le cache est valide |
|
| 106 | - if ( |
|
| 107 | - (int) $reload <= 0 |
|
| 108 | - && $time > 0 |
|
| 109 | - && $time <= $pcache['filemtime'] |
|
| 110 | - && $md5 == $pcache['md5_file'] |
|
| 111 | - ) { |
|
| 112 | - return false; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // si on arrive pas a lire le fichier, se contenter du cache |
|
| 116 | - if (!($texte = spip_file_get_contents($file))) { |
|
| 117 | - return false; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $f = charger_fonction('infos_paquet', 'plugins'); |
|
| 121 | - $ret = $f($texte, $plug, $dir); |
|
| 122 | - $ret['filemtime'] = $time; |
|
| 123 | - $ret['md5_file'] = $md5; |
|
| 124 | - // Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent |
|
| 125 | - // utiliser un necessite php. SPIP procure donc la version php courante du serveur. |
|
| 126 | - // chaque librairie php est aussi procurée, par exemple 'php:curl'. |
|
| 127 | - if (isset($ret['prefix']) && $ret['prefix'] == 'spip') { |
|
| 128 | - $ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()]; |
|
| 129 | - foreach (get_loaded_extensions() as $ext) { |
|
| 130 | - $ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)]; |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - $diff = ($ret != $pcache); |
|
| 134 | - |
|
| 135 | - if ($diff) { |
|
| 136 | - $cache[$dir][$plug] = $ret; |
|
| 94 | + if (!is_readable($file = "$dir$plug/paquet.xml")) { |
|
| 95 | + return false; |
|
| 96 | + } |
|
| 97 | + $time = (int) @filemtime($file); |
|
| 98 | + if ($time < 0) { |
|
| 99 | + return false; |
|
| 100 | + } |
|
| 101 | + $md5 = md5_file($file); |
|
| 102 | + |
|
| 103 | + $pcache = $cache[$dir][$plug] ?? ['filemtime' => 0, 'md5_file' => '']; |
|
| 104 | + |
|
| 105 | + // si le cache est valide |
|
| 106 | + if ( |
|
| 107 | + (int) $reload <= 0 |
|
| 108 | + && $time > 0 |
|
| 109 | + && $time <= $pcache['filemtime'] |
|
| 110 | + && $md5 == $pcache['md5_file'] |
|
| 111 | + ) { |
|
| 112 | + return false; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // si on arrive pas a lire le fichier, se contenter du cache |
|
| 116 | + if (!($texte = spip_file_get_contents($file))) { |
|
| 117 | + return false; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $f = charger_fonction('infos_paquet', 'plugins'); |
|
| 121 | + $ret = $f($texte, $plug, $dir); |
|
| 122 | + $ret['filemtime'] = $time; |
|
| 123 | + $ret['md5_file'] = $md5; |
|
| 124 | + // Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent |
|
| 125 | + // utiliser un necessite php. SPIP procure donc la version php courante du serveur. |
|
| 126 | + // chaque librairie php est aussi procurée, par exemple 'php:curl'. |
|
| 127 | + if (isset($ret['prefix']) && $ret['prefix'] == 'spip') { |
|
| 128 | + $ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()]; |
|
| 129 | + foreach (get_loaded_extensions() as $ext) { |
|
| 130 | + $ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)]; |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + $diff = ($ret != $pcache); |
|
| 134 | + |
|
| 135 | + if ($diff) { |
|
| 136 | + $cache[$dir][$plug] = $ret; |
|
| 137 | 137 | # echo count($cache[$dir]), $dir,$plug, " $reloadc<br>"; |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - return $diff; |
|
| 140 | + return $diff; |
|
| 141 | 141 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | static $filecache = ''; |
| 39 | 39 | |
| 40 | 40 | if ($cache === '') { |
| 41 | - $filecache = _DIR_TMP . 'plugin_xml_cache.gz'; |
|
| 41 | + $filecache = _DIR_TMP.'plugin_xml_cache.gz'; |
|
| 42 | 42 | if (is_file($filecache)) { |
| 43 | 43 | lire_fichier($filecache, $contenu); |
| 44 | 44 | $cache = unserialize($contenu); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | if (isset($ret['prefix']) && $ret['prefix'] == 'spip') { |
| 128 | 128 | $ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()]; |
| 129 | 129 | foreach (get_loaded_extensions() as $ext) { |
| 130 | - $ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)]; |
|
| 130 | + $ret['procure']['php:'.$ext] = ['nom' => 'php:'.$ext, 'version' => phpversion($ext)]; |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | $diff = ($ret != $pcache); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | asort($liste_plugins); |
| 64 | 64 | $exposed = urldecode(_request('plugin') ?? ''); |
| 65 | 65 | |
| 66 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 66 | + $block_par_lettre = false; //count($liste_plugins)>10; |
|
| 67 | 67 | $fast_liste_plugins_actifs = []; |
| 68 | 68 | $fast_liste_plugins_checked = []; |
| 69 | 69 | if (is_array($liste_plugins_actifs)) { |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | $actif = isset($fast_liste_plugins_actifs[$plug]); |
| 89 | 89 | $checked = isset($fast_liste_plugins_checked[$plug]); |
| 90 | 90 | $block_actif |= $actif; |
| 91 | - $expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins . $plug || $exposed === substr( |
|
| 91 | + $expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins.$plug || $exposed === substr( |
|
| 92 | 92 | $dir_plugins, |
| 93 | 93 | strlen(_DIR_RACINE) |
| 94 | - ) . $plug)); |
|
| 95 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 94 | + ).$plug)); |
|
| 95 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins)."\n"; |
|
| 96 | 96 | } |
| 97 | 97 | $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
| 98 | 98 | $class = basename($dir_plugins); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | include_spip('inc/charsets'); |
| 16 | 16 | |
@@ -26,90 +26,90 @@ discard block |
||
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | 28 | function plugins_afficher_liste_dist( |
| 29 | - $url_page, |
|
| 30 | - $liste_plugins, |
|
| 31 | - $liste_plugins_checked, |
|
| 32 | - $liste_plugins_actifs, |
|
| 33 | - $dir_plugins = _DIR_PLUGINS, |
|
| 34 | - $afficher_un = 'afficher_plugin' |
|
| 29 | + $url_page, |
|
| 30 | + $liste_plugins, |
|
| 31 | + $liste_plugins_checked, |
|
| 32 | + $liste_plugins_actifs, |
|
| 33 | + $dir_plugins = _DIR_PLUGINS, |
|
| 34 | + $afficher_un = 'afficher_plugin' |
|
| 35 | 35 | ) { |
| 36 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 37 | - $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 36 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 37 | + $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 38 | 38 | |
| 39 | - $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 39 | + $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 40 | 40 | |
| 41 | - $all_infos = pipeline( |
|
| 42 | - 'filtrer_liste_plugins', |
|
| 43 | - [ |
|
| 44 | - 'args' => [ |
|
| 45 | - 'liste_plugins' => $liste_plugins, |
|
| 46 | - 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 47 | - 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 48 | - 'dir_plugins' => $dir_plugins |
|
| 49 | - ], |
|
| 50 | - 'data' => $all_infos |
|
| 51 | - ] |
|
| 52 | - ); |
|
| 41 | + $all_infos = pipeline( |
|
| 42 | + 'filtrer_liste_plugins', |
|
| 43 | + [ |
|
| 44 | + 'args' => [ |
|
| 45 | + 'liste_plugins' => $liste_plugins, |
|
| 46 | + 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 47 | + 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 48 | + 'dir_plugins' => $dir_plugins |
|
| 49 | + ], |
|
| 50 | + 'data' => $all_infos |
|
| 51 | + ] |
|
| 52 | + ); |
|
| 53 | 53 | |
| 54 | - $liste_plugins = array_flip($liste_plugins); |
|
| 55 | - foreach (array_keys($liste_plugins) as $chemin) { |
|
| 56 | - // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 57 | - if (isset($all_infos[$chemin])) { |
|
| 58 | - $liste_plugins[$chemin] = strtoupper(trim((string) typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 59 | - } else { |
|
| 60 | - unset($liste_plugins[$chemin]); |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - asort($liste_plugins); |
|
| 64 | - $exposed = urldecode(_request('plugin') ?? ''); |
|
| 54 | + $liste_plugins = array_flip($liste_plugins); |
|
| 55 | + foreach (array_keys($liste_plugins) as $chemin) { |
|
| 56 | + // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 57 | + if (isset($all_infos[$chemin])) { |
|
| 58 | + $liste_plugins[$chemin] = strtoupper(trim((string) typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 59 | + } else { |
|
| 60 | + unset($liste_plugins[$chemin]); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + asort($liste_plugins); |
|
| 64 | + $exposed = urldecode(_request('plugin') ?? ''); |
|
| 65 | 65 | |
| 66 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 67 | - $fast_liste_plugins_actifs = []; |
|
| 68 | - $fast_liste_plugins_checked = []; |
|
| 69 | - if (is_array($liste_plugins_actifs)) { |
|
| 70 | - $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 71 | - } |
|
| 72 | - if (is_array($liste_plugins_checked)) { |
|
| 73 | - $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 74 | - } |
|
| 66 | + $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 67 | + $fast_liste_plugins_actifs = []; |
|
| 68 | + $fast_liste_plugins_checked = []; |
|
| 69 | + if (is_array($liste_plugins_actifs)) { |
|
| 70 | + $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 71 | + } |
|
| 72 | + if (is_array($liste_plugins_checked)) { |
|
| 73 | + $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $res = ''; |
|
| 77 | - $block = ''; |
|
| 78 | - $initiale = ''; |
|
| 79 | - $block_actif = false; |
|
| 80 | - foreach ($liste_plugins as $plug => $nom) { |
|
| 81 | - if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 82 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 83 | - $initiale = $i; |
|
| 84 | - $block = ''; |
|
| 85 | - $block_actif = false; |
|
| 86 | - } |
|
| 87 | - // le rep suivant |
|
| 88 | - $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 89 | - $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 90 | - $block_actif |= $actif; |
|
| 91 | - $expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins . $plug || $exposed === substr( |
|
| 92 | - $dir_plugins, |
|
| 93 | - strlen(_DIR_RACINE) |
|
| 94 | - ) . $plug)); |
|
| 95 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 96 | - } |
|
| 97 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 98 | - $class = basename($dir_plugins); |
|
| 76 | + $res = ''; |
|
| 77 | + $block = ''; |
|
| 78 | + $initiale = ''; |
|
| 79 | + $block_actif = false; |
|
| 80 | + foreach ($liste_plugins as $plug => $nom) { |
|
| 81 | + if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 82 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 83 | + $initiale = $i; |
|
| 84 | + $block = ''; |
|
| 85 | + $block_actif = false; |
|
| 86 | + } |
|
| 87 | + // le rep suivant |
|
| 88 | + $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 89 | + $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 90 | + $block_actif |= $actif; |
|
| 91 | + $expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins . $plug || $exposed === substr( |
|
| 92 | + $dir_plugins, |
|
| 93 | + strlen(_DIR_RACINE) |
|
| 94 | + ) . $plug)); |
|
| 95 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 96 | + } |
|
| 97 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 98 | + $class = basename($dir_plugins); |
|
| 99 | 99 | |
| 100 | - return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 100 | + return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | function affiche_block_initiale($initiale, $block, $block_actif) { |
| 105 | - if (strlen((string) $block)) { |
|
| 106 | - return "<li class='item'>" |
|
| 107 | - . bouton_block_depliable($initiale, (bool) $block_actif) |
|
| 108 | - . debut_block_depliable($block_actif) |
|
| 109 | - . "<ul>$block</ul>" |
|
| 110 | - . fin_block() |
|
| 111 | - . '</li>'; |
|
| 112 | - } |
|
| 105 | + if (strlen((string) $block)) { |
|
| 106 | + return "<li class='item'>" |
|
| 107 | + . bouton_block_depliable($initiale, (bool) $block_actif) |
|
| 108 | + . debut_block_depliable($block_actif) |
|
| 109 | + . "<ul>$block</ul>" |
|
| 110 | + . fin_block() |
|
| 111 | + . '</li>'; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return ''; |
|
| 114 | + return ''; |
|
| 115 | 115 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -27,24 +27,24 @@ discard block |
||
| 27 | 27 | * Environnement du formulaire |
| 28 | 28 | **/ |
| 29 | 29 | function formulaires_configurer_reducteur_charger_dist() { |
| 30 | - $valeurs = []; |
|
| 31 | - foreach ( |
|
| 32 | - [ |
|
| 33 | - 'image_process', |
|
| 34 | - 'formats_graphiques', |
|
| 35 | - 'creer_preview', |
|
| 36 | - 'taille_preview', |
|
| 37 | - ] as $m |
|
| 38 | - ) { |
|
| 39 | - $valeurs[$m] = $GLOBALS['meta'][$m] ?? null; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - $valeurs['taille_preview'] = (int) $valeurs['taille_preview']; |
|
| 43 | - if ($valeurs['taille_preview'] < 10) { |
|
| 44 | - $valeurs['taille_preview'] = 120; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - return $valeurs; |
|
| 30 | + $valeurs = []; |
|
| 31 | + foreach ( |
|
| 32 | + [ |
|
| 33 | + 'image_process', |
|
| 34 | + 'formats_graphiques', |
|
| 35 | + 'creer_preview', |
|
| 36 | + 'taille_preview', |
|
| 37 | + ] as $m |
|
| 38 | + ) { |
|
| 39 | + $valeurs[$m] = $GLOBALS['meta'][$m] ?? null; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + $valeurs['taille_preview'] = (int) $valeurs['taille_preview']; |
|
| 43 | + if ($valeurs['taille_preview'] < 10) { |
|
| 44 | + $valeurs['taille_preview'] = 120; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + return $valeurs; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
@@ -55,52 +55,52 @@ discard block |
||
| 55 | 55 | * Retours des traitements |
| 56 | 56 | **/ |
| 57 | 57 | function formulaires_configurer_reducteur_traiter_dist() { |
| 58 | - $res = ['editable' => true]; |
|
| 59 | - |
|
| 60 | - if (is_array($image_process = _request('image_process_'))) { |
|
| 61 | - $image_process = array_keys($image_process); |
|
| 62 | - $image_process = reset($image_process); |
|
| 63 | - |
|
| 64 | - // application du choix de vignette |
|
| 65 | - if ($image_process) { |
|
| 66 | - // mettre a jour les formats graphiques lisibles |
|
| 67 | - switch ($image_process) { |
|
| 68 | - case 'gd2': |
|
| 69 | - $formats_graphiques = $GLOBALS['meta']['gd_formats_read']; |
|
| 70 | - break; |
|
| 71 | - case 'netpbm': |
|
| 72 | - $formats_graphiques = $GLOBALS['meta']['netpbm_formats']; |
|
| 73 | - break; |
|
| 74 | - case 'convert': |
|
| 75 | - case 'imagick': |
|
| 76 | - $formats_graphiques = 'gif,jpg,png,webp'; |
|
| 77 | - break; |
|
| 78 | - default: #debug |
|
| 79 | - $formats_graphiques = ''; |
|
| 80 | - $image_process = 'non'; |
|
| 81 | - break; |
|
| 82 | - } |
|
| 83 | - ecrire_meta('formats_graphiques', $formats_graphiques, 'non'); |
|
| 84 | - ecrire_meta('image_process', $image_process, 'non'); |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - foreach ( |
|
| 89 | - [ |
|
| 90 | - 'creer_preview' |
|
| 91 | - ] as $m |
|
| 92 | - ) { |
|
| 93 | - if (!is_null($v = _request($m))) { |
|
| 94 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - if (!is_null($v = _request('taille_preview'))) { |
|
| 98 | - ecrire_meta('taille_preview', (int) $v); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 102 | - |
|
| 103 | - return $res; |
|
| 58 | + $res = ['editable' => true]; |
|
| 59 | + |
|
| 60 | + if (is_array($image_process = _request('image_process_'))) { |
|
| 61 | + $image_process = array_keys($image_process); |
|
| 62 | + $image_process = reset($image_process); |
|
| 63 | + |
|
| 64 | + // application du choix de vignette |
|
| 65 | + if ($image_process) { |
|
| 66 | + // mettre a jour les formats graphiques lisibles |
|
| 67 | + switch ($image_process) { |
|
| 68 | + case 'gd2': |
|
| 69 | + $formats_graphiques = $GLOBALS['meta']['gd_formats_read']; |
|
| 70 | + break; |
|
| 71 | + case 'netpbm': |
|
| 72 | + $formats_graphiques = $GLOBALS['meta']['netpbm_formats']; |
|
| 73 | + break; |
|
| 74 | + case 'convert': |
|
| 75 | + case 'imagick': |
|
| 76 | + $formats_graphiques = 'gif,jpg,png,webp'; |
|
| 77 | + break; |
|
| 78 | + default: #debug |
|
| 79 | + $formats_graphiques = ''; |
|
| 80 | + $image_process = 'non'; |
|
| 81 | + break; |
|
| 82 | + } |
|
| 83 | + ecrire_meta('formats_graphiques', $formats_graphiques, 'non'); |
|
| 84 | + ecrire_meta('image_process', $image_process, 'non'); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + foreach ( |
|
| 89 | + [ |
|
| 90 | + 'creer_preview' |
|
| 91 | + ] as $m |
|
| 92 | + ) { |
|
| 93 | + if (!is_null($v = _request($m))) { |
|
| 94 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + if (!is_null($v = _request('taille_preview'))) { |
|
| 98 | + ecrire_meta('taille_preview', (int) $v); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 102 | + |
|
| 103 | + return $res; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,17 +113,17 @@ discard block |
||
| 113 | 113 | * URL d'action pour tester la librairie graphique en créant une vignette |
| 114 | 114 | **/ |
| 115 | 115 | function url_vignette_choix(string $process): string { |
| 116 | - $ok = match ($process) { |
|
| 117 | - 'gd2' => function_exists('ImageCreateTrueColor'), |
|
| 118 | - 'netpbm' => !(defined('_PNMSCALE_COMMAND') && _PNMSCALE_COMMAND == ''), |
|
| 119 | - 'imagick' => method_exists(\Imagick::class, 'readImage'), |
|
| 120 | - 'convert' => !(defined('_CONVERT_COMMAND') && _CONVERT_COMMAND == ''), |
|
| 121 | - default => false, |
|
| 122 | - }; |
|
| 123 | - |
|
| 124 | - if (!$ok) { |
|
| 125 | - return ''; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 116 | + $ok = match ($process) { |
|
| 117 | + 'gd2' => function_exists('ImageCreateTrueColor'), |
|
| 118 | + 'netpbm' => !(defined('_PNMSCALE_COMMAND') && _PNMSCALE_COMMAND == ''), |
|
| 119 | + 'imagick' => method_exists(\Imagick::class, 'readImage'), |
|
| 120 | + 'convert' => !(defined('_CONVERT_COMMAND') && _CONVERT_COMMAND == ''), |
|
| 121 | + default => false, |
|
| 122 | + }; |
|
| 123 | + |
|
| 124 | + if (!$ok) { |
|
| 125 | + return ''; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 129 | 129 | } |
@@ -125,5 +125,5 @@ |
||
| 125 | 125 | return ''; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 128 | + return generer_url_action('tester', "arg=$process&time=".time()); |
|
| 129 | 129 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | if (defined('_DECLARER_CHOIX_DB')) { |
| 30 | 30 | $nom_connect = _DECLARER_CHOIX_DB; |
| 31 | 31 | $n = ''; |
| 32 | - while (in_array($nom_connect . $n, $deja)) { |
|
| 32 | + while (in_array($nom_connect.$n, $deja)) { |
|
| 33 | 33 | $n = ($n ? $n + 1 : 1); |
| 34 | 34 | } |
| 35 | 35 | $nom_connect .= $n; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | function liste_serveurs() { |
| 59 | 59 | $options = []; |
| 60 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 60 | + $dir = _DIR_RESTREINT.'req/'; |
|
| 61 | 61 | $d = opendir($dir); |
| 62 | 62 | if (!$d) { |
| 63 | 63 | return []; |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | while ($f = readdir($d)) { |
| 66 | 66 | if ( |
| 67 | 67 | preg_match('/^(.*)[.]php$/', $f, $s) |
| 68 | - && is_readable($f = $dir . $f) |
|
| 68 | + && is_readable($f = $dir.$f) |
|
| 69 | 69 | ) { |
| 70 | 70 | require_once($f); |
| 71 | 71 | $s = $s[1]; |
| 72 | - $v = 'spip_versions_' . $s; |
|
| 72 | + $v = 'spip_versions_'.$s; |
|
| 73 | 73 | if (function_exists($v) && $v()) { |
| 74 | 74 | $options[$s] = "install_select_type_$s"; |
| 75 | 75 | } else { |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
| 129 | 129 | if ($link) { |
| 130 | - $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 130 | + $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_'.$serveur_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 131 | 131 | $GLOBALS['connexions'][$serveur_db] = $link; |
| 132 | 132 | define('_DECLARER_SERVEUR_DB', $serveur_db); |
| 133 | 133 | define('_DECLARER_ADRESSE_DB', $adresse_db); |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $f = preg_replace(',[^\w],', '', (string) $nom_connect); |
| 178 | 178 | if ($f !== $nom_connect) { |
| 179 | 179 | $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
| 180 | - } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 180 | + } elseif (file_exists(_DIR_CONNECT.$nom_connect.'.php')) { |
|
| 181 | 181 | $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
| 182 | 182 | } else { |
| 183 | 183 | define('_DECLARER_NOM_CONNECT', $nom_connect); |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | '' |
| 212 | 212 | ); |
| 213 | 213 | |
| 214 | - install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 214 | + install_fichier_connexion(_DIR_CONNECT._DECLARER_NOM_CONNECT.'.php', $conn); |
|
| 215 | 215 | |
| 216 | 216 | return [ |
| 217 | - 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>']) |
|
| 217 | + 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>'._DECLARER_NOM_CONNECT.'</strong>']) |
|
| 218 | 218 | ]; |
| 219 | 219 | } |
@@ -10,210 +10,210 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/install'); |
| 17 | 17 | |
| 18 | 18 | function formulaires_declarer_bases_charger_dist() { |
| 19 | 19 | |
| 20 | - if (!autoriser('detruire')) { |
|
| 21 | - return false; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - [$adresse_db, $login_db, $pass_db, $sel, $server_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 25 | - |
|
| 26 | - $deja = bases_referencees(_FILE_CONNECT); |
|
| 27 | - // proposer un nom de connect si pas encore saisi |
|
| 28 | - $nom_connect = ''; |
|
| 29 | - if (defined('_DECLARER_CHOIX_DB')) { |
|
| 30 | - $nom_connect = _DECLARER_CHOIX_DB; |
|
| 31 | - $n = ''; |
|
| 32 | - while (in_array($nom_connect . $n, $deja)) { |
|
| 33 | - $n = ($n ? $n + 1 : 1); |
|
| 34 | - } |
|
| 35 | - $nom_connect .= $n; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - return [ |
|
| 39 | - '_etapes' => 3, |
|
| 40 | - '_bases_deja' => $deja, |
|
| 41 | - '_bases_prop' => defined('_DECLARER_SERVEUR_DB') ? liste_bases(_DECLARER_SERVEUR_DB) : '', |
|
| 42 | - '_tables' => (defined('_DECLARER_SERVEUR_DB') && defined('_DECLARER_CHOIX_DB')) ? |
|
| 43 | - $tables = sql_alltable('%', _DECLARER_SERVEUR_DB) |
|
| 44 | - : |
|
| 45 | - [], |
|
| 46 | - 'main_db' => '', |
|
| 47 | - '_serveurs' => liste_serveurs(), |
|
| 48 | - 'sql_serveur_db' => 'sqlite3', // valeur par defaut |
|
| 49 | - 'adresse_db' => $adresse_db, |
|
| 50 | - 'login_db' => '', |
|
| 51 | - 'pass_db' => '', |
|
| 52 | - 'choix_db' => '', |
|
| 53 | - 'table_new' => '', |
|
| 54 | - 'nom_connect' => $nom_connect, |
|
| 55 | - ]; |
|
| 20 | + if (!autoriser('detruire')) { |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + [$adresse_db, $login_db, $pass_db, $sel, $server_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 25 | + |
|
| 26 | + $deja = bases_referencees(_FILE_CONNECT); |
|
| 27 | + // proposer un nom de connect si pas encore saisi |
|
| 28 | + $nom_connect = ''; |
|
| 29 | + if (defined('_DECLARER_CHOIX_DB')) { |
|
| 30 | + $nom_connect = _DECLARER_CHOIX_DB; |
|
| 31 | + $n = ''; |
|
| 32 | + while (in_array($nom_connect . $n, $deja)) { |
|
| 33 | + $n = ($n ? $n + 1 : 1); |
|
| 34 | + } |
|
| 35 | + $nom_connect .= $n; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + return [ |
|
| 39 | + '_etapes' => 3, |
|
| 40 | + '_bases_deja' => $deja, |
|
| 41 | + '_bases_prop' => defined('_DECLARER_SERVEUR_DB') ? liste_bases(_DECLARER_SERVEUR_DB) : '', |
|
| 42 | + '_tables' => (defined('_DECLARER_SERVEUR_DB') && defined('_DECLARER_CHOIX_DB')) ? |
|
| 43 | + $tables = sql_alltable('%', _DECLARER_SERVEUR_DB) |
|
| 44 | + : |
|
| 45 | + [], |
|
| 46 | + 'main_db' => '', |
|
| 47 | + '_serveurs' => liste_serveurs(), |
|
| 48 | + 'sql_serveur_db' => 'sqlite3', // valeur par defaut |
|
| 49 | + 'adresse_db' => $adresse_db, |
|
| 50 | + 'login_db' => '', |
|
| 51 | + 'pass_db' => '', |
|
| 52 | + 'choix_db' => '', |
|
| 53 | + 'table_new' => '', |
|
| 54 | + 'nom_connect' => $nom_connect, |
|
| 55 | + ]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function liste_serveurs() { |
| 59 | - $options = []; |
|
| 60 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 61 | - $d = opendir($dir); |
|
| 62 | - if (!$d) { |
|
| 63 | - return []; |
|
| 64 | - } |
|
| 65 | - while ($f = readdir($d)) { |
|
| 66 | - if ( |
|
| 67 | - preg_match('/^(.*)[.]php$/', $f, $s) |
|
| 68 | - && is_readable($f = $dir . $f) |
|
| 69 | - ) { |
|
| 70 | - require_once($f); |
|
| 71 | - $s = $s[1]; |
|
| 72 | - $v = 'spip_versions_' . $s; |
|
| 73 | - if (function_exists($v) && $v()) { |
|
| 74 | - $options[$s] = "install_select_type_$s"; |
|
| 75 | - } else { |
|
| 76 | - spip_logger()->info("$s: portage indisponible"); |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - ksort($options); |
|
| 81 | - |
|
| 82 | - return $options; |
|
| 59 | + $options = []; |
|
| 60 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 61 | + $d = opendir($dir); |
|
| 62 | + if (!$d) { |
|
| 63 | + return []; |
|
| 64 | + } |
|
| 65 | + while ($f = readdir($d)) { |
|
| 66 | + if ( |
|
| 67 | + preg_match('/^(.*)[.]php$/', $f, $s) |
|
| 68 | + && is_readable($f = $dir . $f) |
|
| 69 | + ) { |
|
| 70 | + require_once($f); |
|
| 71 | + $s = $s[1]; |
|
| 72 | + $v = 'spip_versions_' . $s; |
|
| 73 | + if (function_exists($v) && $v()) { |
|
| 74 | + $options[$s] = "install_select_type_$s"; |
|
| 75 | + } else { |
|
| 76 | + spip_logger()->info("$s: portage indisponible"); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + ksort($options); |
|
| 81 | + |
|
| 82 | + return $options; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | function liste_bases($server_db) { |
| 86 | - if ( |
|
| 87 | - is_null($server_db) |
|
| 88 | - || !$result = sql_listdbs($server_db) |
|
| 89 | - ) { |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $noms = []; |
|
| 94 | - |
|
| 95 | - // si sqlite : result est deja un tableau |
|
| 96 | - if (is_array($result)) { |
|
| 97 | - $noms = $result; |
|
| 98 | - } else { |
|
| 99 | - while ($row = sql_fetch($result, $server_db)) { |
|
| 100 | - $noms[] = reset($row); |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - return $noms; |
|
| 86 | + if ( |
|
| 87 | + is_null($server_db) |
|
| 88 | + || !$result = sql_listdbs($server_db) |
|
| 89 | + ) { |
|
| 90 | + return ''; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $noms = []; |
|
| 94 | + |
|
| 95 | + // si sqlite : result est deja un tableau |
|
| 96 | + if (is_array($result)) { |
|
| 97 | + $noms = $result; |
|
| 98 | + } else { |
|
| 99 | + while ($row = sql_fetch($result, $server_db)) { |
|
| 100 | + $noms[] = reset($row); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + return $noms; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | function formulaires_declarer_bases_verifier_1_dist() { |
| 108 | - $erreurs = []; |
|
| 109 | - [$def_adresse_db, $def_login_db, $def_pass_db, $sel_db, $def_serveur_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 110 | - |
|
| 111 | - if (!$adresse_db = _request('adresse_db')) { |
|
| 112 | - $adresse_db = defined('_INSTALL_HOST_DB') ? _INSTALL_HOST_DB : $def_adresse_db; |
|
| 113 | - } |
|
| 114 | - if (!$serveur_db = _request('sql_serveur_db')) { |
|
| 115 | - $serveur_db = defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : $def_serveur_db; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - $login_db = $pass_db = ''; |
|
| 119 | - if (!preg_match(',^sqlite,i', (string) $serveur_db)) { |
|
| 120 | - if (!$login_db = _request('login_db')) { |
|
| 121 | - $login_db = defined('_INSTALL_USER_DB') ? _INSTALL_USER_DB : $def_login_db; |
|
| 122 | - } |
|
| 123 | - if (!$pass_db = _request('pass_db')) { |
|
| 124 | - $pass_db = defined('_INSTALL_PASS_DB') ? _INSTALL_PASS_DB : $def_pass_db; |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
|
| 129 | - if ($link) { |
|
| 130 | - $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 131 | - $GLOBALS['connexions'][$serveur_db] = $link; |
|
| 132 | - define('_DECLARER_SERVEUR_DB', $serveur_db); |
|
| 133 | - define('_DECLARER_ADRESSE_DB', $adresse_db); |
|
| 134 | - define('_DECLARER_LOGIN_DB', $login_db); |
|
| 135 | - define('_DECLARER_PASS_DB', $pass_db); |
|
| 136 | - // si on est sur le meme serveur que connect.php |
|
| 137 | - // indiquer quelle est la db utilisee pour l'exclure des choix possibles |
|
| 138 | - if ($serveur_db == $def_serveur_db && $adresse_db == $def_adresse_db) { |
|
| 139 | - set_request('main_db', $sel_db); |
|
| 140 | - } else { |
|
| 141 | - set_request('main_db', ''); |
|
| 142 | - } |
|
| 143 | - } else { |
|
| 144 | - $erreurs['message_erreur'] = _T('avis_connexion_echec_1'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return $erreurs; |
|
| 108 | + $erreurs = []; |
|
| 109 | + [$def_adresse_db, $def_login_db, $def_pass_db, $sel_db, $def_serveur_db] = analyse_fichier_connection(_FILE_CONNECT); |
|
| 110 | + |
|
| 111 | + if (!$adresse_db = _request('adresse_db')) { |
|
| 112 | + $adresse_db = defined('_INSTALL_HOST_DB') ? _INSTALL_HOST_DB : $def_adresse_db; |
|
| 113 | + } |
|
| 114 | + if (!$serveur_db = _request('sql_serveur_db')) { |
|
| 115 | + $serveur_db = defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : $def_serveur_db; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + $login_db = $pass_db = ''; |
|
| 119 | + if (!preg_match(',^sqlite,i', (string) $serveur_db)) { |
|
| 120 | + if (!$login_db = _request('login_db')) { |
|
| 121 | + $login_db = defined('_INSTALL_USER_DB') ? _INSTALL_USER_DB : $def_login_db; |
|
| 122 | + } |
|
| 123 | + if (!$pass_db = _request('pass_db')) { |
|
| 124 | + $pass_db = defined('_INSTALL_PASS_DB') ? _INSTALL_PASS_DB : $def_pass_db; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
|
| 129 | + if ($link) { |
|
| 130 | + $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 131 | + $GLOBALS['connexions'][$serveur_db] = $link; |
|
| 132 | + define('_DECLARER_SERVEUR_DB', $serveur_db); |
|
| 133 | + define('_DECLARER_ADRESSE_DB', $adresse_db); |
|
| 134 | + define('_DECLARER_LOGIN_DB', $login_db); |
|
| 135 | + define('_DECLARER_PASS_DB', $pass_db); |
|
| 136 | + // si on est sur le meme serveur que connect.php |
|
| 137 | + // indiquer quelle est la db utilisee pour l'exclure des choix possibles |
|
| 138 | + if ($serveur_db == $def_serveur_db && $adresse_db == $def_adresse_db) { |
|
| 139 | + set_request('main_db', $sel_db); |
|
| 140 | + } else { |
|
| 141 | + set_request('main_db', ''); |
|
| 142 | + } |
|
| 143 | + } else { |
|
| 144 | + $erreurs['message_erreur'] = _T('avis_connexion_echec_1'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return $erreurs; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function formulaires_declarer_bases_verifier_2_dist() { |
| 151 | - $erreurs = []; |
|
| 152 | - $choix_db = _request('choix_db'); |
|
| 153 | - if ($choix_db == '-1') { |
|
| 154 | - $choix_db = _request('table_new'); |
|
| 155 | - } |
|
| 156 | - if (!$choix_db) { |
|
| 157 | - $erreurs['choix_db'] = _T('info_obligatoire'); |
|
| 158 | - } else { |
|
| 159 | - define('_ECRIRE_INSTALL', 1); // hackons sqlite |
|
| 160 | - if (!sql_selectdb($choix_db, _DECLARER_SERVEUR_DB)) { |
|
| 161 | - $erreurs['choix_db'] = _T('avis_base_inaccessible', ['base' => $choix_db]); |
|
| 162 | - } else { |
|
| 163 | - define('_DECLARER_CHOIX_DB', $choix_db); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - return $erreurs; |
|
| 151 | + $erreurs = []; |
|
| 152 | + $choix_db = _request('choix_db'); |
|
| 153 | + if ($choix_db == '-1') { |
|
| 154 | + $choix_db = _request('table_new'); |
|
| 155 | + } |
|
| 156 | + if (!$choix_db) { |
|
| 157 | + $erreurs['choix_db'] = _T('info_obligatoire'); |
|
| 158 | + } else { |
|
| 159 | + define('_ECRIRE_INSTALL', 1); // hackons sqlite |
|
| 160 | + if (!sql_selectdb($choix_db, _DECLARER_SERVEUR_DB)) { |
|
| 161 | + $erreurs['choix_db'] = _T('avis_base_inaccessible', ['base' => $choix_db]); |
|
| 162 | + } else { |
|
| 163 | + define('_DECLARER_CHOIX_DB', $choix_db); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + return $erreurs; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | function formulaires_declarer_bases_verifier_3_dist() { |
| 171 | - $erreurs = []; |
|
| 172 | - $nom_connect = _request('nom_connect'); |
|
| 173 | - if (!$nom_connect) { |
|
| 174 | - $erreurs['nom_connect'] = _T('info_obligatoire'); |
|
| 175 | - } else { |
|
| 176 | - // securite : le nom doit etre un mot sans caracteres speciaux |
|
| 177 | - $f = preg_replace(',[^\w],', '', (string) $nom_connect); |
|
| 178 | - if ($f !== $nom_connect) { |
|
| 179 | - $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
|
| 180 | - } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 181 | - $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
|
| 182 | - } else { |
|
| 183 | - define('_DECLARER_NOM_CONNECT', $nom_connect); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - return $erreurs; |
|
| 171 | + $erreurs = []; |
|
| 172 | + $nom_connect = _request('nom_connect'); |
|
| 173 | + if (!$nom_connect) { |
|
| 174 | + $erreurs['nom_connect'] = _T('info_obligatoire'); |
|
| 175 | + } else { |
|
| 176 | + // securite : le nom doit etre un mot sans caracteres speciaux |
|
| 177 | + $f = preg_replace(',[^\w],', '', (string) $nom_connect); |
|
| 178 | + if ($f !== $nom_connect) { |
|
| 179 | + $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
|
| 180 | + } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 181 | + $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
|
| 182 | + } else { |
|
| 183 | + define('_DECLARER_NOM_CONNECT', $nom_connect); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + return $erreurs; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | function formulaires_declarer_bases_traiter_dist() { |
| 191 | 191 | |
| 192 | - $adresse_db = _DECLARER_ADRESSE_DB; |
|
| 193 | - if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 194 | - [, $adresse_db, $port] = $r; |
|
| 195 | - } else { |
|
| 196 | - $port = ''; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - $server_db = addcslashes((string) _DECLARER_SERVEUR_DB, "'\\"); |
|
| 200 | - |
|
| 201 | - $conn = install_mode_appel($server_db) |
|
| 202 | - . install_connexion( |
|
| 203 | - $adresse_db, |
|
| 204 | - $port, |
|
| 205 | - _DECLARER_LOGIN_DB, |
|
| 206 | - _DECLARER_PASS_DB, |
|
| 207 | - _DECLARER_CHOIX_DB, |
|
| 208 | - _DECLARER_SERVEUR_DB, |
|
| 209 | - '', |
|
| 210 | - '', |
|
| 211 | - '' |
|
| 212 | - ); |
|
| 213 | - |
|
| 214 | - install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 215 | - |
|
| 216 | - return [ |
|
| 217 | - 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>']) |
|
| 218 | - ]; |
|
| 192 | + $adresse_db = _DECLARER_ADRESSE_DB; |
|
| 193 | + if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 194 | + [, $adresse_db, $port] = $r; |
|
| 195 | + } else { |
|
| 196 | + $port = ''; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + $server_db = addcslashes((string) _DECLARER_SERVEUR_DB, "'\\"); |
|
| 200 | + |
|
| 201 | + $conn = install_mode_appel($server_db) |
|
| 202 | + . install_connexion( |
|
| 203 | + $adresse_db, |
|
| 204 | + $port, |
|
| 205 | + _DECLARER_LOGIN_DB, |
|
| 206 | + _DECLARER_PASS_DB, |
|
| 207 | + _DECLARER_CHOIX_DB, |
|
| 208 | + _DECLARER_SERVEUR_DB, |
|
| 209 | + '', |
|
| 210 | + '', |
|
| 211 | + '' |
|
| 212 | + ); |
|
| 213 | + |
|
| 214 | + install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 215 | + |
|
| 216 | + return [ |
|
| 217 | + 'message_ok' => _T('install_connect_ok', ['connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>']) |
|
| 218 | + ]; |
|
| 219 | 219 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | # preparer un lien pour quand redirige_formulaire ne fonctionne pas |
| 144 | 144 | $m = redirige_formulaire($res['redirect']); |
| 145 | 145 | $valeurs['_deja_loge'] = inserer_attribut( |
| 146 | - '<a>' . _T('login_par_ici') . "</a>$m", |
|
| 146 | + '<a>'._T('login_par_ici')."</a>$m", |
|
| 147 | 147 | 'href', |
| 148 | 148 | $res['redirect'] |
| 149 | 149 | ); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | function login_autoriser() { |
| 291 | 291 | include_spip('inc/autoriser'); |
| 292 | 292 | if (!autoriser('ecrire')) { |
| 293 | - $h = generer_url_action('logout', 'logout=prive&url=' . urlencode((string) self())); |
|
| 293 | + $h = generer_url_action('logout', 'logout=prive&url='.urlencode((string) self())); |
|
| 294 | 294 | |
| 295 | 295 | return [ |
| 296 | 296 | 'message_erreur' => '<h1>' |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | . '</h1><p>' |
| 299 | 299 | . _T('texte_erreur_visiteur') |
| 300 | 300 | . "</p><p class='retour'>[<a href='$h'>" |
| 301 | - . _T('icone_deconnecter') . '</a>]</p>' |
|
| 301 | + . _T('icone_deconnecter').'</a>]</p>' |
|
| 302 | 302 | ]; |
| 303 | 303 | } |
| 304 | 304 | |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | // transformer la cible absolue en cible relative |
| 351 | 351 | // pour pas echouer quand la meta adresse_site est foireuse |
| 352 | 352 | if (strncmp((string) $cible, (string) ($u = url_de_base()), strlen((string) $u)) == 0) { |
| 353 | - $cible = './' . substr((string) $cible, strlen((string) $u)); |
|
| 353 | + $cible = './'.substr((string) $cible, strlen((string) $u)); |
|
| 354 | 354 | } elseif (tester_url_absolue($cible) && !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) { |
| 355 | 355 | // si c'est une url absolue, refuser la redirection |
| 356 | 356 | // sauf si cette securite est levee volontairement par le webmestre |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | if ($cible && $cible != self('&') && $cible != self()) { |
| 363 | 363 | $res['redirect'] = $cible; |
| 364 | 364 | $res['message_ok'] = inserer_attribut( |
| 365 | - '<a>' . _T('login_par_ici') . '</a>', |
|
| 365 | + '<a>'._T('login_par_ici').'</a>', |
|
| 366 | 366 | 'href', |
| 367 | 367 | $cible |
| 368 | 368 | ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | * true si espace privé, false sinon. |
| 31 | 31 | **/ |
| 32 | 32 | function is_url_prive($cible) { |
| 33 | - include_spip('inc/filtres_mini'); |
|
| 34 | - $path = parse_url(tester_url_absolue($cible) ? $cible : url_absolue($cible)); |
|
| 35 | - $path = ($path['path'] ?? ''); |
|
| 33 | + include_spip('inc/filtres_mini'); |
|
| 34 | + $path = parse_url(tester_url_absolue($cible) ? $cible : url_absolue($cible)); |
|
| 35 | + $path = ($path['path'] ?? ''); |
|
| 36 | 36 | |
| 37 | - return str_starts_with(substr($path, -strlen((string) _DIR_RESTREINT_ABS)), (string) _DIR_RESTREINT_ABS); |
|
| 37 | + return str_starts_with(substr($path, -strlen((string) _DIR_RESTREINT_ABS)), (string) _DIR_RESTREINT_ABS); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -59,110 +59,110 @@ discard block |
||
| 59 | 59 | * Environnement du formulaire |
| 60 | 60 | **/ |
| 61 | 61 | function formulaires_login_charger_dist($cible = '', $options = [], $deprecated = null) { |
| 62 | - $erreur = _request('var_erreur'); |
|
| 63 | - |
|
| 64 | - if (!is_array($options)) { |
|
| 65 | - $options = [ |
|
| 66 | - 'login' => $options, |
|
| 67 | - 'prive' => $deprecated |
|
| 68 | - ]; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $login = (empty($options['login']) ? '' : $options['login']); |
|
| 72 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 73 | - // conserver le fonctionnement historique |
|
| 74 | - if (!isset($options['autofocus'])) { |
|
| 75 | - $options['autofocus'] = true; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if (!$login) { |
|
| 79 | - $login = (string) _request('var_login'); |
|
| 80 | - } |
|
| 81 | - // si on est deja identifie |
|
| 82 | - if (!$login && isset($GLOBALS['visiteur_session']['email'])) { |
|
| 83 | - $login = $GLOBALS['visiteur_session']['email']; |
|
| 84 | - } |
|
| 85 | - if (!$login && isset($GLOBALS['visiteur_session']['login'])) { |
|
| 86 | - $login = $GLOBALS['visiteur_session']['login']; |
|
| 87 | - } |
|
| 88 | - // ou si on a un cookie admin |
|
| 89 | - if ( |
|
| 90 | - !$login |
|
| 91 | - && isset($_COOKIE['spip_admin']) |
|
| 92 | - && preg_match(',^@(.*)$,', (string) $_COOKIE['spip_admin'], $regs) |
|
| 93 | - ) { |
|
| 94 | - $login = $regs[1]; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - $lang = $GLOBALS['spip_lang']; |
|
| 98 | - include_spip('inc/auth'); |
|
| 99 | - $row = auth_informer_login($login); |
|
| 100 | - |
|
| 101 | - // retablir la langue de l'URL si forcee (on ignore la langue de l'auteur dans ce cas) |
|
| 102 | - if (_request('lang') === $lang && $GLOBALS['spip_lang'] !== $lang) { |
|
| 103 | - changer_langue($lang); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // Construire l'environnement du squelette |
|
| 107 | - // Ne pas proposer de "rester connecte quelques jours" |
|
| 108 | - // si la duree de l'alea est inferieure a 12 h (valeur par defaut) |
|
| 109 | - |
|
| 110 | - $valeurs = [ |
|
| 111 | - 'var_login' => $login, |
|
| 112 | - 'editable' => !$row, |
|
| 113 | - 'cnx' => $row['cnx'] ?? '0', |
|
| 114 | - 'auth_http' => login_auth_http(), |
|
| 115 | - 'rester_connecte' => ((_RENOUVELLE_ALEA < 12 * 3600) ? '' : ' '), |
|
| 116 | - '_logo' => $row['logo'] ?? '', |
|
| 117 | - '_alea_actuel' => $row['alea_actuel'] ?? '', |
|
| 118 | - '_alea_futur' => $row['alea_futur'] ?? '', |
|
| 119 | - '_pipeline' => 'affiche_formulaire_login', // faire passer le formulaire dans un pipe dedie pour les methodes auth |
|
| 120 | - '_autofocus' => ($options['autofocus'] && $options['autofocus'] !== 'non') ? ' ' : '', |
|
| 121 | - ]; |
|
| 122 | - |
|
| 123 | - if ($erreur || !isset($GLOBALS['visiteur_session']['id_auteur']) || !$GLOBALS['visiteur_session']['id_auteur']) { |
|
| 124 | - $valeurs['editable'] = true; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 128 | - include_spip('inc/autoriser'); |
|
| 129 | - $loge = autoriser('ecrire'); |
|
| 130 | - } else { |
|
| 131 | - $loge = (isset($GLOBALS['visiteur_session']['auth']) && $GLOBALS['visiteur_session']['auth'] != ''); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // Si on est connecte, appeler traiter() |
|
| 135 | - // et lancer la redirection si besoin |
|
| 136 | - if (!$valeurs['editable'] && $loge && _request('formulaire_action') !== 'login') { |
|
| 137 | - $traiter = charger_fonction('traiter', 'formulaires/login'); |
|
| 138 | - $res = $traiter($cible, $login, $prive); |
|
| 139 | - $valeurs = array_merge($valeurs, $res); |
|
| 140 | - |
|
| 141 | - if (isset($res['redirect']) && $res['redirect']) { |
|
| 142 | - include_spip('inc/headers'); |
|
| 143 | - # preparer un lien pour quand redirige_formulaire ne fonctionne pas |
|
| 144 | - $m = redirige_formulaire($res['redirect']); |
|
| 145 | - $valeurs['_deja_loge'] = inserer_attribut( |
|
| 146 | - '<a>' . _T('login_par_ici') . "</a>$m", |
|
| 147 | - 'href', |
|
| 148 | - $res['redirect'] |
|
| 149 | - ); |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - // en cas d'echec de cookie, inc_auth a renvoye vers le script de |
|
| 153 | - // pose de cookie ; s'il n'est pas la, c'est echec cookie |
|
| 154 | - // s'il est la, c'est probablement un bookmark sur bonjour=oui, |
|
| 155 | - // et pas un echec cookie. |
|
| 156 | - if ($erreur == 'cookie') { |
|
| 157 | - $valeurs['echec_cookie'] = ' '; |
|
| 158 | - } elseif ($erreur) { |
|
| 159 | - // une erreur d'un SSO indique dans la redirection vers ici |
|
| 160 | - // mais il faut se proteger de toute tentative d'injection malveilante |
|
| 161 | - include_spip('inc/filtres'); |
|
| 162 | - $valeurs['message_erreur'] = textebrut($erreur); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return $valeurs; |
|
| 62 | + $erreur = _request('var_erreur'); |
|
| 63 | + |
|
| 64 | + if (!is_array($options)) { |
|
| 65 | + $options = [ |
|
| 66 | + 'login' => $options, |
|
| 67 | + 'prive' => $deprecated |
|
| 68 | + ]; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $login = (empty($options['login']) ? '' : $options['login']); |
|
| 72 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 73 | + // conserver le fonctionnement historique |
|
| 74 | + if (!isset($options['autofocus'])) { |
|
| 75 | + $options['autofocus'] = true; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if (!$login) { |
|
| 79 | + $login = (string) _request('var_login'); |
|
| 80 | + } |
|
| 81 | + // si on est deja identifie |
|
| 82 | + if (!$login && isset($GLOBALS['visiteur_session']['email'])) { |
|
| 83 | + $login = $GLOBALS['visiteur_session']['email']; |
|
| 84 | + } |
|
| 85 | + if (!$login && isset($GLOBALS['visiteur_session']['login'])) { |
|
| 86 | + $login = $GLOBALS['visiteur_session']['login']; |
|
| 87 | + } |
|
| 88 | + // ou si on a un cookie admin |
|
| 89 | + if ( |
|
| 90 | + !$login |
|
| 91 | + && isset($_COOKIE['spip_admin']) |
|
| 92 | + && preg_match(',^@(.*)$,', (string) $_COOKIE['spip_admin'], $regs) |
|
| 93 | + ) { |
|
| 94 | + $login = $regs[1]; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + $lang = $GLOBALS['spip_lang']; |
|
| 98 | + include_spip('inc/auth'); |
|
| 99 | + $row = auth_informer_login($login); |
|
| 100 | + |
|
| 101 | + // retablir la langue de l'URL si forcee (on ignore la langue de l'auteur dans ce cas) |
|
| 102 | + if (_request('lang') === $lang && $GLOBALS['spip_lang'] !== $lang) { |
|
| 103 | + changer_langue($lang); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // Construire l'environnement du squelette |
|
| 107 | + // Ne pas proposer de "rester connecte quelques jours" |
|
| 108 | + // si la duree de l'alea est inferieure a 12 h (valeur par defaut) |
|
| 109 | + |
|
| 110 | + $valeurs = [ |
|
| 111 | + 'var_login' => $login, |
|
| 112 | + 'editable' => !$row, |
|
| 113 | + 'cnx' => $row['cnx'] ?? '0', |
|
| 114 | + 'auth_http' => login_auth_http(), |
|
| 115 | + 'rester_connecte' => ((_RENOUVELLE_ALEA < 12 * 3600) ? '' : ' '), |
|
| 116 | + '_logo' => $row['logo'] ?? '', |
|
| 117 | + '_alea_actuel' => $row['alea_actuel'] ?? '', |
|
| 118 | + '_alea_futur' => $row['alea_futur'] ?? '', |
|
| 119 | + '_pipeline' => 'affiche_formulaire_login', // faire passer le formulaire dans un pipe dedie pour les methodes auth |
|
| 120 | + '_autofocus' => ($options['autofocus'] && $options['autofocus'] !== 'non') ? ' ' : '', |
|
| 121 | + ]; |
|
| 122 | + |
|
| 123 | + if ($erreur || !isset($GLOBALS['visiteur_session']['id_auteur']) || !$GLOBALS['visiteur_session']['id_auteur']) { |
|
| 124 | + $valeurs['editable'] = true; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 128 | + include_spip('inc/autoriser'); |
|
| 129 | + $loge = autoriser('ecrire'); |
|
| 130 | + } else { |
|
| 131 | + $loge = (isset($GLOBALS['visiteur_session']['auth']) && $GLOBALS['visiteur_session']['auth'] != ''); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // Si on est connecte, appeler traiter() |
|
| 135 | + // et lancer la redirection si besoin |
|
| 136 | + if (!$valeurs['editable'] && $loge && _request('formulaire_action') !== 'login') { |
|
| 137 | + $traiter = charger_fonction('traiter', 'formulaires/login'); |
|
| 138 | + $res = $traiter($cible, $login, $prive); |
|
| 139 | + $valeurs = array_merge($valeurs, $res); |
|
| 140 | + |
|
| 141 | + if (isset($res['redirect']) && $res['redirect']) { |
|
| 142 | + include_spip('inc/headers'); |
|
| 143 | + # preparer un lien pour quand redirige_formulaire ne fonctionne pas |
|
| 144 | + $m = redirige_formulaire($res['redirect']); |
|
| 145 | + $valeurs['_deja_loge'] = inserer_attribut( |
|
| 146 | + '<a>' . _T('login_par_ici') . "</a>$m", |
|
| 147 | + 'href', |
|
| 148 | + $res['redirect'] |
|
| 149 | + ); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + // en cas d'echec de cookie, inc_auth a renvoye vers le script de |
|
| 153 | + // pose de cookie ; s'il n'est pas la, c'est echec cookie |
|
| 154 | + // s'il est la, c'est probablement un bookmark sur bonjour=oui, |
|
| 155 | + // et pas un echec cookie. |
|
| 156 | + if ($erreur == 'cookie') { |
|
| 157 | + $valeurs['echec_cookie'] = ' '; |
|
| 158 | + } elseif ($erreur) { |
|
| 159 | + // une erreur d'un SSO indique dans la redirection vers ici |
|
| 160 | + // mais il faut se proteger de toute tentative d'injection malveilante |
|
| 161 | + include_spip('inc/filtres'); |
|
| 162 | + $valeurs['message_erreur'] = textebrut($erreur); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return $valeurs; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | |
@@ -177,20 +177,20 @@ discard block |
||
| 177 | 177 | * - chaîne vide sinon. |
| 178 | 178 | **/ |
| 179 | 179 | function login_auth_http() { |
| 180 | - if (!$GLOBALS['ignore_auth_http'] && _request('var_erreur') == 'cookie') { |
|
| 181 | - include_spip('inc/session'); |
|
| 182 | - $cookie = lire_cookie_session(true); |
|
| 183 | - if ($cookie !== 'test_echec_cookie' |
|
| 184 | - && (preg_match(',apache,', \PHP_SAPI) || preg_match(',^Apache.* PHP,', (string) $_SERVER['SERVER_SOFTWARE'])) |
|
| 185 | - // Attention dans le cas 'intranet' la proposition de se loger |
|
| 186 | - // par auth_http peut conduire a l'echec. |
|
| 187 | - && !(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) |
|
| 188 | - ) { |
|
| 189 | - return generer_url_action('cookie', '', false, true); |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - return ''; |
|
| 180 | + if (!$GLOBALS['ignore_auth_http'] && _request('var_erreur') == 'cookie') { |
|
| 181 | + include_spip('inc/session'); |
|
| 182 | + $cookie = lire_cookie_session(true); |
|
| 183 | + if ($cookie !== 'test_echec_cookie' |
|
| 184 | + && (preg_match(',apache,', \PHP_SAPI) || preg_match(',^Apache.* PHP,', (string) $_SERVER['SERVER_SOFTWARE'])) |
|
| 185 | + // Attention dans le cas 'intranet' la proposition de se loger |
|
| 186 | + // par auth_http peut conduire a l'echec. |
|
| 187 | + && !(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) |
|
| 188 | + ) { |
|
| 189 | + return generer_url_action('cookie', '', false, true); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + return ''; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -216,64 +216,64 @@ discard block |
||
| 216 | 216 | **/ |
| 217 | 217 | function formulaires_login_verifier_dist($cible = '', $options = [], $deprecated = null) { |
| 218 | 218 | |
| 219 | - $erreurs = []; |
|
| 220 | - if (!is_array($options)) { |
|
| 221 | - $options = [ |
|
| 222 | - 'login' => $options, |
|
| 223 | - 'prive' => $deprecated |
|
| 224 | - ]; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 228 | - |
|
| 229 | - $session_login = _request('var_login'); |
|
| 230 | - $session_password = _request('password'); |
|
| 231 | - $session_remember = _request('session_remember'); |
|
| 232 | - |
|
| 233 | - if (!$session_login) { |
|
| 234 | - # pas de login saisi ! |
|
| 235 | - return ['var_login' => _T('info_obligatoire')]; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - // appeler auth_identifier_login qui va : |
|
| 239 | - // - renvoyer un string si echec (message d'erreur) |
|
| 240 | - // - un array decrivant l'auteur identifie si possible |
|
| 241 | - // - rediriger vers un SSO qui renverra in fine sur action/auth qui finira l'authentification |
|
| 242 | - include_spip('inc/auth'); |
|
| 243 | - $auteur = auth_identifier_login($session_login, $session_password); |
|
| 244 | - // on arrive ici si on ne s'est pas identifie avec un SSO |
|
| 245 | - if (!is_array($auteur)) { |
|
| 246 | - $erreurs = []; |
|
| 247 | - if (is_string($auteur) && strlen($auteur)) { |
|
| 248 | - $erreurs['var_login'] = $auteur; |
|
| 249 | - } |
|
| 250 | - include_spip('inc/cookie'); |
|
| 251 | - spip_setcookie('spip_admin', '', time() - 3600, httponly: true); |
|
| 252 | - if (strlen((string) $session_password)) { |
|
| 253 | - $erreurs['password'] = _T('login_erreur_pass'); |
|
| 254 | - } else { |
|
| 255 | - // sinon c'est un login en deux passe old style (ou js en panne) |
|
| 256 | - // pas de message d'erreur |
|
| 257 | - $erreurs['password'] = ' '; |
|
| 258 | - $erreurs['message_erreur'] = ''; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - return $erreurs; |
|
| 262 | - } |
|
| 263 | - // on a ete authentifie, construire la session |
|
| 264 | - // en gerant la duree demandee pour son cookie |
|
| 265 | - if ($session_remember !== null) { |
|
| 266 | - $auteur['cookie'] = $session_remember; |
|
| 267 | - } |
|
| 268 | - // si la connexion est refusee on renvoi un message erreur de mot de passe |
|
| 269 | - // car en donnant plus de detail on renseignerait un assaillant sur l'existence d'un compte |
|
| 270 | - if (auth_loger($auteur) === false) { |
|
| 271 | - $erreurs['message_erreur'] = _T('login_erreur_pass'); |
|
| 272 | - return $erreurs; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - return (is_null($prive) ? is_url_prive($cible) : $prive) |
|
| 276 | - ? login_autoriser() : []; |
|
| 219 | + $erreurs = []; |
|
| 220 | + if (!is_array($options)) { |
|
| 221 | + $options = [ |
|
| 222 | + 'login' => $options, |
|
| 223 | + 'prive' => $deprecated |
|
| 224 | + ]; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 228 | + |
|
| 229 | + $session_login = _request('var_login'); |
|
| 230 | + $session_password = _request('password'); |
|
| 231 | + $session_remember = _request('session_remember'); |
|
| 232 | + |
|
| 233 | + if (!$session_login) { |
|
| 234 | + # pas de login saisi ! |
|
| 235 | + return ['var_login' => _T('info_obligatoire')]; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + // appeler auth_identifier_login qui va : |
|
| 239 | + // - renvoyer un string si echec (message d'erreur) |
|
| 240 | + // - un array decrivant l'auteur identifie si possible |
|
| 241 | + // - rediriger vers un SSO qui renverra in fine sur action/auth qui finira l'authentification |
|
| 242 | + include_spip('inc/auth'); |
|
| 243 | + $auteur = auth_identifier_login($session_login, $session_password); |
|
| 244 | + // on arrive ici si on ne s'est pas identifie avec un SSO |
|
| 245 | + if (!is_array($auteur)) { |
|
| 246 | + $erreurs = []; |
|
| 247 | + if (is_string($auteur) && strlen($auteur)) { |
|
| 248 | + $erreurs['var_login'] = $auteur; |
|
| 249 | + } |
|
| 250 | + include_spip('inc/cookie'); |
|
| 251 | + spip_setcookie('spip_admin', '', time() - 3600, httponly: true); |
|
| 252 | + if (strlen((string) $session_password)) { |
|
| 253 | + $erreurs['password'] = _T('login_erreur_pass'); |
|
| 254 | + } else { |
|
| 255 | + // sinon c'est un login en deux passe old style (ou js en panne) |
|
| 256 | + // pas de message d'erreur |
|
| 257 | + $erreurs['password'] = ' '; |
|
| 258 | + $erreurs['message_erreur'] = ''; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + return $erreurs; |
|
| 262 | + } |
|
| 263 | + // on a ete authentifie, construire la session |
|
| 264 | + // en gerant la duree demandee pour son cookie |
|
| 265 | + if ($session_remember !== null) { |
|
| 266 | + $auteur['cookie'] = $session_remember; |
|
| 267 | + } |
|
| 268 | + // si la connexion est refusee on renvoi un message erreur de mot de passe |
|
| 269 | + // car en donnant plus de detail on renseignerait un assaillant sur l'existence d'un compte |
|
| 270 | + if (auth_loger($auteur) === false) { |
|
| 271 | + $erreurs['message_erreur'] = _T('login_erreur_pass'); |
|
| 272 | + return $erreurs; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + return (is_null($prive) ? is_url_prive($cible) : $prive) |
|
| 276 | + ? login_autoriser() : []; |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -288,21 +288,21 @@ discard block |
||
| 288 | 288 | * - tableau vide sinon. |
| 289 | 289 | **/ |
| 290 | 290 | function login_autoriser() { |
| 291 | - include_spip('inc/autoriser'); |
|
| 292 | - if (!autoriser('ecrire')) { |
|
| 293 | - $h = generer_url_action('logout', 'logout=prive&url=' . urlencode((string) self())); |
|
| 294 | - |
|
| 295 | - return [ |
|
| 296 | - 'message_erreur' => '<h1>' |
|
| 297 | - . _T('avis_erreur_visiteur') |
|
| 298 | - . '</h1><p>' |
|
| 299 | - . _T('texte_erreur_visiteur') |
|
| 300 | - . "</p><p class='retour'>[<a href='$h'>" |
|
| 301 | - . _T('icone_deconnecter') . '</a>]</p>' |
|
| 302 | - ]; |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - return []; |
|
| 291 | + include_spip('inc/autoriser'); |
|
| 292 | + if (!autoriser('ecrire')) { |
|
| 293 | + $h = generer_url_action('logout', 'logout=prive&url=' . urlencode((string) self())); |
|
| 294 | + |
|
| 295 | + return [ |
|
| 296 | + 'message_erreur' => '<h1>' |
|
| 297 | + . _T('avis_erreur_visiteur') |
|
| 298 | + . '</h1><p>' |
|
| 299 | + . _T('texte_erreur_visiteur') |
|
| 300 | + . "</p><p class='retour'>[<a href='$h'>" |
|
| 301 | + . _T('icone_deconnecter') . '</a>]</p>' |
|
| 302 | + ]; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + return []; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -323,55 +323,55 @@ discard block |
||
| 323 | 323 | * Retours du traitement |
| 324 | 324 | **/ |
| 325 | 325 | function formulaires_login_traiter_dist($cible = '', $options = [], $deprecated = null) { |
| 326 | - $res = []; |
|
| 327 | - |
|
| 328 | - if (!is_array($options)) { |
|
| 329 | - $options = [ |
|
| 330 | - 'login' => $options, |
|
| 331 | - 'prive' => $deprecated |
|
| 332 | - ]; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - $login = (empty($options['login']) ? '' : $options['login']); |
|
| 336 | - $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 337 | - |
|
| 338 | - // Si on se connecte dans l'espace prive, |
|
| 339 | - // ajouter "bonjour" (repere a peu pres les cookies desactives) |
|
| 340 | - if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 341 | - $cible = parametre_url($cible, 'bonjour', 'oui', '&'); |
|
| 342 | - } |
|
| 343 | - if ($cible == '@page_auteur') { |
|
| 344 | - $cible = generer_objet_url($GLOBALS['auteur_session']['id_auteur'], 'auteur'); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - if ($cible) { |
|
| 348 | - $cible = parametre_url($cible, 'var_login', '', '&'); |
|
| 349 | - |
|
| 350 | - // transformer la cible absolue en cible relative |
|
| 351 | - // pour pas echouer quand la meta adresse_site est foireuse |
|
| 352 | - if (strncmp((string) $cible, (string) ($u = url_de_base()), strlen((string) $u)) == 0) { |
|
| 353 | - $cible = './' . substr((string) $cible, strlen((string) $u)); |
|
| 354 | - } elseif (tester_url_absolue($cible) && !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) { |
|
| 355 | - // si c'est une url absolue, refuser la redirection |
|
| 356 | - // sauf si cette securite est levee volontairement par le webmestre |
|
| 357 | - $cible = ''; |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - // Si on est connecte, envoyer vers la destination |
|
| 362 | - if ($cible && $cible != self('&') && $cible != self()) { |
|
| 363 | - $res['redirect'] = $cible; |
|
| 364 | - $res['message_ok'] = inserer_attribut( |
|
| 365 | - '<a>' . _T('login_par_ici') . '</a>', |
|
| 366 | - 'href', |
|
| 367 | - $cible |
|
| 368 | - ); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - // avant de rediriger il faut mettre a jour les sessions sur le disque si on a charge une session |
|
| 372 | - if (function_exists('terminer_actualiser_sessions')) { |
|
| 373 | - terminer_actualiser_sessions(); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return $res; |
|
| 326 | + $res = []; |
|
| 327 | + |
|
| 328 | + if (!is_array($options)) { |
|
| 329 | + $options = [ |
|
| 330 | + 'login' => $options, |
|
| 331 | + 'prive' => $deprecated |
|
| 332 | + ]; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + $login = (empty($options['login']) ? '' : $options['login']); |
|
| 336 | + $prive = (empty($options['prive']) ? null : $options['prive']); |
|
| 337 | + |
|
| 338 | + // Si on se connecte dans l'espace prive, |
|
| 339 | + // ajouter "bonjour" (repere a peu pres les cookies desactives) |
|
| 340 | + if (is_null($prive) ? is_url_prive($cible) : $prive) { |
|
| 341 | + $cible = parametre_url($cible, 'bonjour', 'oui', '&'); |
|
| 342 | + } |
|
| 343 | + if ($cible == '@page_auteur') { |
|
| 344 | + $cible = generer_objet_url($GLOBALS['auteur_session']['id_auteur'], 'auteur'); |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + if ($cible) { |
|
| 348 | + $cible = parametre_url($cible, 'var_login', '', '&'); |
|
| 349 | + |
|
| 350 | + // transformer la cible absolue en cible relative |
|
| 351 | + // pour pas echouer quand la meta adresse_site est foireuse |
|
| 352 | + if (strncmp((string) $cible, (string) ($u = url_de_base()), strlen((string) $u)) == 0) { |
|
| 353 | + $cible = './' . substr((string) $cible, strlen((string) $u)); |
|
| 354 | + } elseif (tester_url_absolue($cible) && !defined('_AUTORISER_LOGIN_ABS_REDIRECT')) { |
|
| 355 | + // si c'est une url absolue, refuser la redirection |
|
| 356 | + // sauf si cette securite est levee volontairement par le webmestre |
|
| 357 | + $cible = ''; |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + // Si on est connecte, envoyer vers la destination |
|
| 362 | + if ($cible && $cible != self('&') && $cible != self()) { |
|
| 363 | + $res['redirect'] = $cible; |
|
| 364 | + $res['message_ok'] = inserer_attribut( |
|
| 365 | + '<a>' . _T('login_par_ici') . '</a>', |
|
| 366 | + 'href', |
|
| 367 | + $cible |
|
| 368 | + ); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + // avant de rediriger il faut mettre a jour les sessions sur le disque si on a charge une session |
|
| 372 | + if (function_exists('terminer_actualiser_sessions')) { |
|
| 373 | + terminer_actualiser_sessions(); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return $res; |
|
| 377 | 377 | } |