@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -10,57 +10,57 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function formulaires_configurer_langue_charger_dist() { |
| 17 | - $valeurs = []; |
|
| 17 | + $valeurs = []; |
|
| 18 | 18 | |
| 19 | - include_spip('inc/lang'); |
|
| 20 | - $l_site = $GLOBALS['meta']['langue_site']; |
|
| 21 | - $langue_site = traduire_nom_langue($l_site); |
|
| 19 | + include_spip('inc/lang'); |
|
| 20 | + $l_site = $GLOBALS['meta']['langue_site']; |
|
| 21 | + $langue_site = traduire_nom_langue($l_site); |
|
| 22 | 22 | |
| 23 | - $langues = explode(',', (string) $GLOBALS['meta']['langues_proposees']); |
|
| 24 | - if (!in_array($l_site, $langues)) { |
|
| 25 | - $langues[] = $l_site; |
|
| 26 | - } |
|
| 27 | - sort($langues); |
|
| 23 | + $langues = explode(',', (string) $GLOBALS['meta']['langues_proposees']); |
|
| 24 | + if (!in_array($l_site, $langues)) { |
|
| 25 | + $langues[] = $l_site; |
|
| 26 | + } |
|
| 27 | + sort($langues); |
|
| 28 | 28 | |
| 29 | - $res = ''; |
|
| 30 | - foreach ($langues as $l) { |
|
| 31 | - $res .= "<option value='$l'" |
|
| 32 | - . ($l == $l_site ? " selected='selected'" : '') |
|
| 33 | - . '>' . traduire_nom_langue($l) . "</option>\n"; |
|
| 34 | - } |
|
| 29 | + $res = ''; |
|
| 30 | + foreach ($langues as $l) { |
|
| 31 | + $res .= "<option value='$l'" |
|
| 32 | + . ($l == $l_site ? " selected='selected'" : '') |
|
| 33 | + . '>' . traduire_nom_langue($l) . "</option>\n"; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - return [ |
|
| 37 | - '_langues' => $res, |
|
| 38 | - '_langue_site' => $langue_site, |
|
| 39 | - 'changer_langue_site' => '', |
|
| 40 | - ]; |
|
| 36 | + return [ |
|
| 37 | + '_langues' => $res, |
|
| 38 | + '_langue_site' => $langue_site, |
|
| 39 | + 'changer_langue_site' => '', |
|
| 40 | + ]; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | function formulaires_configurer_langue_traiter_dist() { |
| 45 | - $res = ['editable' => true]; |
|
| 45 | + $res = ['editable' => true]; |
|
| 46 | 46 | |
| 47 | - if ($lang = _request('changer_langue_site')) { |
|
| 48 | - include_spip('inc/lang'); |
|
| 49 | - // verif que la langue demandee est licite |
|
| 50 | - if (changer_langue($lang)) { |
|
| 51 | - ecrire_meta('langue_site', $lang); |
|
| 52 | - // le test a defait ca: |
|
| 53 | - utiliser_langue_visiteur(); |
|
| 54 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 55 | - include_spip('inc/rubriques'); |
|
| 56 | - calculer_langues_rubriques(); |
|
| 57 | - } |
|
| 58 | - // le test a defait ca: |
|
| 59 | - utiliser_langue_visiteur(); |
|
| 60 | - } |
|
| 61 | - if (!$res['message_ok']) { |
|
| 62 | - $res['message_erreur'] = _L('erreur'); |
|
| 63 | - } |
|
| 47 | + if ($lang = _request('changer_langue_site')) { |
|
| 48 | + include_spip('inc/lang'); |
|
| 49 | + // verif que la langue demandee est licite |
|
| 50 | + if (changer_langue($lang)) { |
|
| 51 | + ecrire_meta('langue_site', $lang); |
|
| 52 | + // le test a defait ca: |
|
| 53 | + utiliser_langue_visiteur(); |
|
| 54 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 55 | + include_spip('inc/rubriques'); |
|
| 56 | + calculer_langues_rubriques(); |
|
| 57 | + } |
|
| 58 | + // le test a defait ca: |
|
| 59 | + utiliser_langue_visiteur(); |
|
| 60 | + } |
|
| 61 | + if (!$res['message_ok']) { |
|
| 62 | + $res['message_erreur'] = _L('erreur'); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return $res; |
|
| 65 | + return $res; |
|
| 66 | 66 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | **/ |
| 30 | 30 | |
| 31 | 31 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 32 | - return; |
|
| 32 | + return; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // utilise pour le logo du site, donc doit rester ici |
@@ -47,88 +47,88 @@ discard block |
||
| 47 | 47 | * @return array|false Variables d'environnement pour le fond |
| 48 | 48 | */ |
| 49 | 49 | function formulaires_editer_logo_charger_dist($objet, $id_objet, $retour = '', $options = []) { |
| 50 | - // pas dans une boucle ? formulaire pour le logo du site |
|
| 51 | - // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 52 | - if (!$objet) { |
|
| 53 | - $objet = 'site'; |
|
| 54 | - } |
|
| 50 | + // pas dans une boucle ? formulaire pour le logo du site |
|
| 51 | + // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 52 | + if (!$objet) { |
|
| 53 | + $objet = 'site'; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $objet = objet_type($objet); |
|
| 57 | - $_id_objet = id_table_objet($objet); |
|
| 56 | + $objet = objet_type($objet); |
|
| 57 | + $_id_objet = id_table_objet($objet); |
|
| 58 | 58 | |
| 59 | - if (!is_array($options)) { |
|
| 60 | - $options = unserialize($options); |
|
| 61 | - } |
|
| 62 | - $options = spip_sanitize_from_request($options, '*'); |
|
| 59 | + if (!is_array($options)) { |
|
| 60 | + $options = unserialize($options); |
|
| 61 | + } |
|
| 62 | + $options = spip_sanitize_from_request($options, '*'); |
|
| 63 | 63 | |
| 64 | - if (!isset($options['titre'])) { |
|
| 65 | - $balise_img = chercher_filtre('balise_img'); |
|
| 66 | - $img = $balise_img(chemin_image('image-24.png'), '', 'cadre-icone'); |
|
| 67 | - $libelles = pipeline('libeller_logo', $GLOBALS['logo_libelles']); |
|
| 68 | - $libelle = (($id_objet || $objet != 'rubrique') ? $objet : 'racine'); |
|
| 69 | - if (isset($libelles[$libelle])) { |
|
| 70 | - $libelle = $libelles[$libelle]; |
|
| 71 | - } elseif ($libelle = objet_info($objet, 'texte_logo_objet')) { |
|
| 72 | - $libelle = _T($libelle); |
|
| 73 | - } else { |
|
| 74 | - $libelle = _L('Logo'); |
|
| 75 | - } |
|
| 76 | - switch ($objet) { |
|
| 77 | - case 'article': |
|
| 78 | - $libelle .= ' ' . aider('logoart'); |
|
| 79 | - break; |
|
| 80 | - case 'breve': |
|
| 81 | - $libelle .= ' ' . aider('breveslogo'); |
|
| 82 | - break; |
|
| 83 | - case 'rubrique': |
|
| 84 | - $libelle .= ' ' . aider('rublogo'); |
|
| 85 | - break; |
|
| 86 | - default: |
|
| 87 | - break; |
|
| 88 | - } |
|
| 64 | + if (!isset($options['titre'])) { |
|
| 65 | + $balise_img = chercher_filtre('balise_img'); |
|
| 66 | + $img = $balise_img(chemin_image('image-24.png'), '', 'cadre-icone'); |
|
| 67 | + $libelles = pipeline('libeller_logo', $GLOBALS['logo_libelles']); |
|
| 68 | + $libelle = (($id_objet || $objet != 'rubrique') ? $objet : 'racine'); |
|
| 69 | + if (isset($libelles[$libelle])) { |
|
| 70 | + $libelle = $libelles[$libelle]; |
|
| 71 | + } elseif ($libelle = objet_info($objet, 'texte_logo_objet')) { |
|
| 72 | + $libelle = _T($libelle); |
|
| 73 | + } else { |
|
| 74 | + $libelle = _L('Logo'); |
|
| 75 | + } |
|
| 76 | + switch ($objet) { |
|
| 77 | + case 'article': |
|
| 78 | + $libelle .= ' ' . aider('logoart'); |
|
| 79 | + break; |
|
| 80 | + case 'breve': |
|
| 81 | + $libelle .= ' ' . aider('breveslogo'); |
|
| 82 | + break; |
|
| 83 | + case 'rubrique': |
|
| 84 | + $libelle .= ' ' . aider('rublogo'); |
|
| 85 | + break; |
|
| 86 | + default: |
|
| 87 | + break; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - $options['titre'] = $img . $libelle; |
|
| 91 | - } |
|
| 92 | - if (!isset($options['editable'])) { |
|
| 93 | - include_spip('inc/autoriser'); |
|
| 94 | - $options['editable'] = autoriser('iconifier', $objet, $id_objet); |
|
| 95 | - } |
|
| 90 | + $options['titre'] = $img . $libelle; |
|
| 91 | + } |
|
| 92 | + if (!isset($options['editable'])) { |
|
| 93 | + include_spip('inc/autoriser'); |
|
| 94 | + $options['editable'] = autoriser('iconifier', $objet, $id_objet); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - $res = [ |
|
| 98 | - 'editable' => ($GLOBALS['meta']['activer_logos'] == 'oui' ? ' ' : '') && (!isset($options['editable']) || $options['editable']), |
|
| 99 | - 'logo_survol' => ($GLOBALS['meta']['activer_logos_survol'] == 'oui' ? ' ' : ''), |
|
| 100 | - 'objet' => $objet, |
|
| 101 | - 'id_objet' => $id_objet, |
|
| 102 | - '_options' => $options, |
|
| 103 | - '_show_upload_off' => '', |
|
| 104 | - ]; |
|
| 97 | + $res = [ |
|
| 98 | + 'editable' => ($GLOBALS['meta']['activer_logos'] == 'oui' ? ' ' : '') && (!isset($options['editable']) || $options['editable']), |
|
| 99 | + 'logo_survol' => ($GLOBALS['meta']['activer_logos_survol'] == 'oui' ? ' ' : ''), |
|
| 100 | + 'objet' => $objet, |
|
| 101 | + 'id_objet' => $id_objet, |
|
| 102 | + '_options' => $options, |
|
| 103 | + '_show_upload_off' => '', |
|
| 104 | + ]; |
|
| 105 | 105 | |
| 106 | - // rechercher le logo de l'objet |
|
| 107 | - // la fonction prend un parametre '_id_objet' etrange : |
|
| 108 | - // le nom de la cle primaire (et non le nom de la table) |
|
| 109 | - // ou directement le nom du raccourcis a chercher |
|
| 110 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 111 | - $etats = $res['logo_survol'] ? ['on', 'off'] : ['on']; |
|
| 112 | - foreach ($etats as $etat) { |
|
| 113 | - $logo = $chercher_logo($id_objet, $_id_objet, $etat); |
|
| 114 | - if ($logo) { |
|
| 115 | - $res['logo_' . $etat] = $logo[0]; |
|
| 116 | - $res['logo_id_' . $etat] = $logo[5]['id_document'] ?? ''; |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - // pas de logo_on -> pas de formulaire pour le survol |
|
| 120 | - if (!isset($res['logo_on'])) { |
|
| 121 | - $res['logo_survol'] = ''; |
|
| 122 | - } elseif (!isset($res['logo_off']) && _request('logo_up')) { |
|
| 123 | - $res['_show_upload_off'] = ' '; |
|
| 124 | - } |
|
| 106 | + // rechercher le logo de l'objet |
|
| 107 | + // la fonction prend un parametre '_id_objet' etrange : |
|
| 108 | + // le nom de la cle primaire (et non le nom de la table) |
|
| 109 | + // ou directement le nom du raccourcis a chercher |
|
| 110 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 111 | + $etats = $res['logo_survol'] ? ['on', 'off'] : ['on']; |
|
| 112 | + foreach ($etats as $etat) { |
|
| 113 | + $logo = $chercher_logo($id_objet, $_id_objet, $etat); |
|
| 114 | + if ($logo) { |
|
| 115 | + $res['logo_' . $etat] = $logo[0]; |
|
| 116 | + $res['logo_id_' . $etat] = $logo[5]['id_document'] ?? ''; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + // pas de logo_on -> pas de formulaire pour le survol |
|
| 120 | + if (!isset($res['logo_on'])) { |
|
| 121 | + $res['logo_survol'] = ''; |
|
| 122 | + } elseif (!isset($res['logo_off']) && _request('logo_up')) { |
|
| 123 | + $res['_show_upload_off'] = ' '; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - // si le logo n'est pas editable et qu'il n'y en a pas, on affiche pas du tout le formulaire |
|
| 127 | - if (!$res['editable'] && !isset($res['logo_off']) && !isset($res['logo_on'])) { |
|
| 128 | - return false; |
|
| 129 | - } |
|
| 126 | + // si le logo n'est pas editable et qu'il n'y en a pas, on affiche pas du tout le formulaire |
|
| 127 | + if (!$res['editable'] && !isset($res['logo_off']) && !isset($res['logo_on'])) { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - return $res; |
|
| 131 | + return $res; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @return string Hash du formulaire |
| 143 | 143 | */ |
| 144 | 144 | function formulaires_editer_logo_identifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 145 | - return serialize([$objet, $id_objet]); |
|
| 145 | + return serialize([$objet, $id_objet]); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -158,31 +158,31 @@ discard block |
||
| 158 | 158 | * @return array Erreurs du formulaire |
| 159 | 159 | */ |
| 160 | 160 | function formulaires_editer_logo_verifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 161 | - $erreurs = []; |
|
| 162 | - // verifier les extensions |
|
| 163 | - $sources = formulaire_editer_logo_get_sources(); |
|
| 164 | - include_spip('action/editer_logo'); |
|
| 165 | - $extensions_possibles = $GLOBALS['formats_logos']; |
|
| 166 | - if (in_array('jpg', $extensions_possibles)) { |
|
| 167 | - $extensions_possibles[] = 'jpeg'; |
|
| 168 | - } |
|
| 169 | - foreach ($sources as $etat => $file) { |
|
| 170 | - // seulement si une reception correcte a eu lieu |
|
| 171 | - if ($file && $file['error'] == 0) { |
|
| 172 | - if ( |
|
| 173 | - !in_array( |
|
| 174 | - strtolower(pathinfo((string) $file['name'], PATHINFO_EXTENSION)), |
|
| 175 | - $extensions_possibles |
|
| 176 | - ) |
|
| 177 | - ) { |
|
| 178 | - $erreurs['logo_' . $etat] = _L('Extension non reconnue'); |
|
| 179 | - } |
|
| 180 | - } elseif ($file && $file['error'] != 0 && isset($file['msg'])) { |
|
| 181 | - $erreurs['message_erreur'] = $file['msg']; |
|
| 182 | - } |
|
| 183 | - } |
|
| 161 | + $erreurs = []; |
|
| 162 | + // verifier les extensions |
|
| 163 | + $sources = formulaire_editer_logo_get_sources(); |
|
| 164 | + include_spip('action/editer_logo'); |
|
| 165 | + $extensions_possibles = $GLOBALS['formats_logos']; |
|
| 166 | + if (in_array('jpg', $extensions_possibles)) { |
|
| 167 | + $extensions_possibles[] = 'jpeg'; |
|
| 168 | + } |
|
| 169 | + foreach ($sources as $etat => $file) { |
|
| 170 | + // seulement si une reception correcte a eu lieu |
|
| 171 | + if ($file && $file['error'] == 0) { |
|
| 172 | + if ( |
|
| 173 | + !in_array( |
|
| 174 | + strtolower(pathinfo((string) $file['name'], PATHINFO_EXTENSION)), |
|
| 175 | + $extensions_possibles |
|
| 176 | + ) |
|
| 177 | + ) { |
|
| 178 | + $erreurs['logo_' . $etat] = _L('Extension non reconnue'); |
|
| 179 | + } |
|
| 180 | + } elseif ($file && $file['error'] != 0 && isset($file['msg'])) { |
|
| 181 | + $erreurs['message_erreur'] = $file['msg']; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return $erreurs; |
|
| 185 | + return $erreurs; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -198,47 +198,47 @@ discard block |
||
| 198 | 198 | * @return array Retour des traitements |
| 199 | 199 | */ |
| 200 | 200 | function formulaires_editer_logo_traiter_dist($objet, $id_objet, $retour = '', $options = []) { |
| 201 | - $res = ['editable' => ' ']; |
|
| 201 | + $res = ['editable' => ' ']; |
|
| 202 | 202 | |
| 203 | - // pas dans une boucle ? formulaire pour le logo du site |
|
| 204 | - // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 205 | - if (!$objet) { |
|
| 206 | - $objet = 'site'; |
|
| 207 | - } |
|
| 203 | + // pas dans une boucle ? formulaire pour le logo du site |
|
| 204 | + // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 205 | + if (!$objet) { |
|
| 206 | + $objet = 'site'; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - include_spip('action/editer_logo'); |
|
| 209 | + include_spip('action/editer_logo'); |
|
| 210 | 210 | |
| 211 | - // effectuer la suppression si demandee d'un logo |
|
| 212 | - $on = _request('supprimer_logo_on'); |
|
| 213 | - if ($on || _request('supprimer_logo_off')) { |
|
| 214 | - logo_supprimer($objet, $id_objet, $on ? 'on' : 'off'); |
|
| 215 | - $res['message_ok'] = ''; // pas besoin de message : la validation est visuelle |
|
| 216 | - set_request('logo_up', ' '); |
|
| 217 | - } // sinon supprimer ancien logo puis copier le nouveau |
|
| 218 | - else { |
|
| 219 | - $sources = formulaire_editer_logo_get_sources(); |
|
| 220 | - foreach ($sources as $etat => $file) { |
|
| 221 | - if ($file && $file['error'] == 0) { |
|
| 222 | - if ($err = logo_modifier($objet, $id_objet, $etat, $file)) { |
|
| 223 | - $res['message_erreur'] = $err; |
|
| 224 | - } else { |
|
| 225 | - $res['message_ok'] = ''; |
|
| 226 | - } // pas besoin de message : la validation est visuelle |
|
| 227 | - set_request('logo_up', ' '); |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 211 | + // effectuer la suppression si demandee d'un logo |
|
| 212 | + $on = _request('supprimer_logo_on'); |
|
| 213 | + if ($on || _request('supprimer_logo_off')) { |
|
| 214 | + logo_supprimer($objet, $id_objet, $on ? 'on' : 'off'); |
|
| 215 | + $res['message_ok'] = ''; // pas besoin de message : la validation est visuelle |
|
| 216 | + set_request('logo_up', ' '); |
|
| 217 | + } // sinon supprimer ancien logo puis copier le nouveau |
|
| 218 | + else { |
|
| 219 | + $sources = formulaire_editer_logo_get_sources(); |
|
| 220 | + foreach ($sources as $etat => $file) { |
|
| 221 | + if ($file && $file['error'] == 0) { |
|
| 222 | + if ($err = logo_modifier($objet, $id_objet, $etat, $file)) { |
|
| 223 | + $res['message_erreur'] = $err; |
|
| 224 | + } else { |
|
| 225 | + $res['message_ok'] = ''; |
|
| 226 | + } // pas besoin de message : la validation est visuelle |
|
| 227 | + set_request('logo_up', ' '); |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - // Invalider les caches de l'objet |
|
| 233 | - include_spip('inc/invalideur'); |
|
| 234 | - suivre_invalideur("id='$objet/$id_objet'"); |
|
| 232 | + // Invalider les caches de l'objet |
|
| 233 | + include_spip('inc/invalideur'); |
|
| 234 | + suivre_invalideur("id='$objet/$id_objet'"); |
|
| 235 | 235 | |
| 236 | 236 | |
| 237 | - if ($retour) { |
|
| 238 | - $res['redirect'] = $retour; |
|
| 239 | - } |
|
| 237 | + if ($retour) { |
|
| 238 | + $res['redirect'] = $retour; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - return $res; |
|
| 241 | + return $res; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | |
@@ -250,29 +250,29 @@ discard block |
||
| 250 | 250 | * Sources des fichiers dans les clés `on` ou `off` |
| 251 | 251 | */ |
| 252 | 252 | function formulaire_editer_logo_get_sources() { |
| 253 | - if (!$_FILES) { |
|
| 254 | - $_FILES = $GLOBALS['HTTP_POST_FILES'] ?? []; |
|
| 255 | - } |
|
| 256 | - if (!is_array($_FILES)) { |
|
| 257 | - return []; |
|
| 258 | - } |
|
| 253 | + if (!$_FILES) { |
|
| 254 | + $_FILES = $GLOBALS['HTTP_POST_FILES'] ?? []; |
|
| 255 | + } |
|
| 256 | + if (!is_array($_FILES)) { |
|
| 257 | + return []; |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - include_spip('inc/documents'); |
|
| 261 | - $sources = []; |
|
| 262 | - foreach (['on', 'off'] as $etat) { |
|
| 263 | - $logo = 'logo_' . $etat; |
|
| 264 | - if (isset($_FILES[$logo])) { |
|
| 265 | - if ($_FILES[$logo]['error'] == 0) { |
|
| 266 | - $sources[$etat] = $_FILES[$logo]; |
|
| 267 | - } elseif ($_FILES[$logo]['error'] != 0) { |
|
| 268 | - $msg = check_upload_error($_FILES[$logo]['error'], false, true); |
|
| 269 | - if ($msg && is_string($msg)) { |
|
| 270 | - $sources[$etat] = $_FILES[$logo]; |
|
| 271 | - $sources[$etat]['msg'] = $msg; |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - } |
|
| 275 | - } |
|
| 260 | + include_spip('inc/documents'); |
|
| 261 | + $sources = []; |
|
| 262 | + foreach (['on', 'off'] as $etat) { |
|
| 263 | + $logo = 'logo_' . $etat; |
|
| 264 | + if (isset($_FILES[$logo])) { |
|
| 265 | + if ($_FILES[$logo]['error'] == 0) { |
|
| 266 | + $sources[$etat] = $_FILES[$logo]; |
|
| 267 | + } elseif ($_FILES[$logo]['error'] != 0) { |
|
| 268 | + $msg = check_upload_error($_FILES[$logo]['error'], false, true); |
|
| 269 | + if ($msg && is_string($msg)) { |
|
| 270 | + $sources[$etat] = $_FILES[$logo]; |
|
| 271 | + $sources[$etat]['msg'] = $msg; |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - return $sources; |
|
| 277 | + return $sources; |
|
| 278 | 278 | } |
@@ -10,53 +10,53 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function formulaires_configurer_multilinguisme_charger_dist() { |
| 17 | - $valeurs = []; |
|
| 18 | - $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 19 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 20 | - $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - if ( |
|
| 24 | - (is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0) |
|
| 25 | - || count(explode(',', (string) $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 26 | - ) { |
|
| 27 | - $selection = (is_null(_request('multi_objets')) ? |
|
| 28 | - explode(',', (string) $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 29 | - $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 30 | - $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - return $valeurs; |
|
| 17 | + $valeurs = []; |
|
| 18 | + $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 19 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 20 | + $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + if ( |
|
| 24 | + (is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0) |
|
| 25 | + || count(explode(',', (string) $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 26 | + ) { |
|
| 27 | + $selection = (is_null(_request('multi_objets')) ? |
|
| 28 | + explode(',', (string) $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 29 | + $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 30 | + $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + return $valeurs; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | function formulaires_configurer_multilinguisme_traiter_dist() { |
| 38 | - $res = ['editable' => true]; |
|
| 39 | - // un checkbox seul de name X non coche n'est pas poste. |
|
| 40 | - // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 41 | - foreach (['multi_secteurs'] as $m) { |
|
| 42 | - if (!is_null(_request($m . '_check'))) { |
|
| 43 | - ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 47 | - if (!is_null($v = _request($m))) { |
|
| 48 | - // join et enlever la valeur vide '' |
|
| 49 | - ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if (($i = _request('langues_auth')) && is_array($i)) { |
|
| 54 | - $i = array_unique(array_merge($i, explode(',', (string) $GLOBALS['meta']['langues_utilisees']))); |
|
| 55 | - ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 56 | - } |
|
| 57 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 58 | - |
|
| 59 | - return $res; |
|
| 38 | + $res = ['editable' => true]; |
|
| 39 | + // un checkbox seul de name X non coche n'est pas poste. |
|
| 40 | + // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 41 | + foreach (['multi_secteurs'] as $m) { |
|
| 42 | + if (!is_null(_request($m . '_check'))) { |
|
| 43 | + ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 47 | + if (!is_null($v = _request($m))) { |
|
| 48 | + // join et enlever la valeur vide '' |
|
| 49 | + ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if (($i = _request('langues_auth')) && is_array($i)) { |
|
| 54 | + $i = array_unique(array_merge($i, explode(',', (string) $GLOBALS['meta']['langues_utilisees']))); |
|
| 55 | + ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 56 | + } |
|
| 57 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 58 | + |
|
| 59 | + return $res; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | 68 | function table_supporte_lang($table_sql) { |
| 69 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 70 | - $desc = $trouver_table($table_sql); |
|
| 71 | - if (!$desc || !isset($desc['field']['lang'])) { |
|
| 72 | - return ''; |
|
| 73 | - } |
|
| 69 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 70 | + $desc = $trouver_table($table_sql); |
|
| 71 | + if (!$desc || !isset($desc['field']['lang'])) { |
|
| 72 | + return ''; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return ' '; |
|
| 75 | + return ' '; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -82,65 +82,65 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function table_supporte_trad($table_sql) { |
| 85 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 86 | - $desc = $trouver_table($table_sql); |
|
| 87 | - if (!$desc || !isset($desc['field']['id_trad'])) { |
|
| 88 | - return ''; |
|
| 89 | - } |
|
| 85 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 86 | + $desc = $trouver_table($table_sql); |
|
| 87 | + if (!$desc || !isset($desc['field']['id_trad'])) { |
|
| 88 | + return ''; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - return ' '; |
|
| 91 | + return ' '; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | function saisie_langues_utiles($name, $selection) { |
| 96 | - include_spip('inc/lang_liste'); |
|
| 97 | - $langues = $GLOBALS['codes_langues']; |
|
| 98 | - |
|
| 99 | - $langues_installees = explode(',', (string) $GLOBALS['meta']['langues_proposees']); |
|
| 100 | - $langues_trad = array_flip($langues_installees); |
|
| 101 | - |
|
| 102 | - $langues_bloquees = explode(',', (string) $GLOBALS['meta']['langues_utilisees']); |
|
| 103 | - |
|
| 104 | - $res = ''; |
|
| 105 | - |
|
| 106 | - $i = 0; |
|
| 107 | - foreach ($langues_bloquees as $code_langue) { |
|
| 108 | - $nom_langue = $langues[$code_langue]; |
|
| 109 | - $res .= "<li class='choix " |
|
| 110 | - . alterner(++$i, 'odd', 'even') |
|
| 111 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 112 | - . "'>" |
|
| 113 | - . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 114 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 115 | - . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | - . '</li>'; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ($res) { |
|
| 120 | - $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $res .= "<ul id='langues_proposees'>"; |
|
| 124 | - |
|
| 125 | - $i = 0; |
|
| 126 | - $langues_bloquees = array_flip($langues_bloquees); |
|
| 127 | - foreach ($langues as $code_langue => $nom_langue) { |
|
| 128 | - if (!isset($langues_bloquees[$code_langue])) { |
|
| 129 | - $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 130 | - $res .= "<li class='choix " |
|
| 131 | - . alterner(++$i, 'odd', 'even') |
|
| 132 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 133 | - . "'>" |
|
| 134 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 135 | - . $checked |
|
| 136 | - . '/>' |
|
| 137 | - . "<label for='{$name}_$code_langue'" |
|
| 138 | - . ($checked ? " class='on'" : '') |
|
| 139 | - . '>' |
|
| 140 | - . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | - . '</li>'; |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - return $res . "</ul><div class='nettoyeur'></div>"; |
|
| 96 | + include_spip('inc/lang_liste'); |
|
| 97 | + $langues = $GLOBALS['codes_langues']; |
|
| 98 | + |
|
| 99 | + $langues_installees = explode(',', (string) $GLOBALS['meta']['langues_proposees']); |
|
| 100 | + $langues_trad = array_flip($langues_installees); |
|
| 101 | + |
|
| 102 | + $langues_bloquees = explode(',', (string) $GLOBALS['meta']['langues_utilisees']); |
|
| 103 | + |
|
| 104 | + $res = ''; |
|
| 105 | + |
|
| 106 | + $i = 0; |
|
| 107 | + foreach ($langues_bloquees as $code_langue) { |
|
| 108 | + $nom_langue = $langues[$code_langue]; |
|
| 109 | + $res .= "<li class='choix " |
|
| 110 | + . alterner(++$i, 'odd', 'even') |
|
| 111 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 112 | + . "'>" |
|
| 113 | + . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 114 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 115 | + . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 116 | + . '</li>'; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ($res) { |
|
| 120 | + $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $res .= "<ul id='langues_proposees'>"; |
|
| 124 | + |
|
| 125 | + $i = 0; |
|
| 126 | + $langues_bloquees = array_flip($langues_bloquees); |
|
| 127 | + foreach ($langues as $code_langue => $nom_langue) { |
|
| 128 | + if (!isset($langues_bloquees[$code_langue])) { |
|
| 129 | + $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 130 | + $res .= "<li class='choix " |
|
| 131 | + . alterner(++$i, 'odd', 'even') |
|
| 132 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 133 | + . "'>" |
|
| 134 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 135 | + . $checked |
|
| 136 | + . '/>' |
|
| 137 | + . "<label for='{$name}_$code_langue'" |
|
| 138 | + . ($checked ? " class='on'" : '') |
|
| 139 | + . '>' |
|
| 140 | + . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 141 | + . '</li>'; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + return $res . "</ul><div class='nettoyeur'></div>"; |
|
| 146 | 146 | } |
@@ -10,138 +10,138 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | include_spip('inc/presentation'); |
| 16 | 16 | include_spip('inc/config'); |
| 17 | 17 | |
| 18 | 18 | function formulaires_configurer_relayeur_charger_dist() { |
| 19 | - return [ |
|
| 20 | - 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 21 | - 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 22 | - 'test_proxy' => 'https://www.spip.net/', |
|
| 23 | - ]; |
|
| 19 | + return [ |
|
| 20 | + 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 21 | + 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 22 | + 'test_proxy' => 'https://www.spip.net/', |
|
| 23 | + ]; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | function formulaires_configurer_relayeur_verifier_dist() { |
| 27 | - $erreurs = []; |
|
| 28 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 29 | - $http_noproxy = _request('http_noproxy'); |
|
| 30 | - |
|
| 31 | - if ($http_proxy && !tester_url_absolue($http_proxy)) { |
|
| 32 | - $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - if (!isset($erreurs['http_proxy']) && _request('tester_proxy')) { |
|
| 36 | - if (!$http_proxy) { |
|
| 37 | - $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 38 | - } else { |
|
| 39 | - include_spip('inc/distant'); |
|
| 40 | - $test_proxy = _request('test_proxy'); |
|
| 41 | - $t = parse_url((string) $test_proxy); |
|
| 42 | - if (!@$t['host']) { |
|
| 43 | - $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 44 | - } else { |
|
| 45 | - include_spip('inc/texte'); // pour aide, couper, lang |
|
| 46 | - $info = ''; |
|
| 47 | - if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 48 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - // il faut fausser le proxy actuel pour faire le test ! |
|
| 52 | - $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 53 | - $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 54 | - $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 55 | - $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 56 | - $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 57 | - $page = $page['page'] ?? ''; |
|
| 58 | - $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 59 | - $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 60 | - if ($page) { |
|
| 61 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 62 | - $erreurs['message_erreur'] = ''; |
|
| 63 | - } else { |
|
| 64 | - $erreurs['message_erreur'] = $info . _T( |
|
| 65 | - 'info_impossible_lire_page', |
|
| 66 | - ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 67 | - ) |
|
| 68 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 69 | - . aider('confhttpproxy'); |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return $erreurs; |
|
| 27 | + $erreurs = []; |
|
| 28 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 29 | + $http_noproxy = _request('http_noproxy'); |
|
| 30 | + |
|
| 31 | + if ($http_proxy && !tester_url_absolue($http_proxy)) { |
|
| 32 | + $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + if (!isset($erreurs['http_proxy']) && _request('tester_proxy')) { |
|
| 36 | + if (!$http_proxy) { |
|
| 37 | + $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 38 | + } else { |
|
| 39 | + include_spip('inc/distant'); |
|
| 40 | + $test_proxy = _request('test_proxy'); |
|
| 41 | + $t = parse_url((string) $test_proxy); |
|
| 42 | + if (!@$t['host']) { |
|
| 43 | + $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 44 | + } else { |
|
| 45 | + include_spip('inc/texte'); // pour aide, couper, lang |
|
| 46 | + $info = ''; |
|
| 47 | + if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 48 | + $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + // il faut fausser le proxy actuel pour faire le test ! |
|
| 52 | + $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 53 | + $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 54 | + $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 55 | + $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 56 | + $page = recuperer_url($test_proxy, ['transcoder' => true]); |
|
| 57 | + $page = $page['page'] ?? ''; |
|
| 58 | + $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 59 | + $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 60 | + if ($page) { |
|
| 61 | + $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 62 | + $erreurs['message_erreur'] = ''; |
|
| 63 | + } else { |
|
| 64 | + $erreurs['message_erreur'] = $info . _T( |
|
| 65 | + 'info_impossible_lire_page', |
|
| 66 | + ['test_proxy' => "<tt>$test_proxy</tt>"] |
|
| 67 | + ) |
|
| 68 | + . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 69 | + . aider('confhttpproxy'); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return $erreurs; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function formulaires_configurer_relayeur_traiter_dist() { |
| 79 | - $res = ['editable' => true]; |
|
| 79 | + $res = ['editable' => true]; |
|
| 80 | 80 | |
| 81 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 82 | - $http_noproxy = _request('http_noproxy'); |
|
| 83 | - if ($http_proxy !== null) { |
|
| 84 | - ecrire_meta('http_proxy', $http_proxy); |
|
| 85 | - } |
|
| 81 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 82 | + $http_noproxy = _request('http_noproxy'); |
|
| 83 | + if ($http_proxy !== null) { |
|
| 84 | + ecrire_meta('http_proxy', $http_proxy); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - if ($http_noproxy !== null) { |
|
| 88 | - ecrire_meta('http_noproxy', $http_noproxy); |
|
| 89 | - } |
|
| 87 | + if ($http_noproxy !== null) { |
|
| 88 | + ecrire_meta('http_noproxy', $http_noproxy); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 91 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 92 | 92 | |
| 93 | - return $res; |
|
| 93 | + return $res; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | function relayeur_saisie_ou_config($http_proxy, $default) { |
| 97 | - // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 98 | - if (preg_match(',:\*\*\*\*@,', (string) $http_proxy)) { |
|
| 99 | - $http_proxy = $default; |
|
| 100 | - } |
|
| 97 | + // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 98 | + if (preg_match(',:\*\*\*\*@,', (string) $http_proxy)) { |
|
| 99 | + $http_proxy = $default; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return $http_proxy; |
|
| 102 | + return $http_proxy; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // Function glue_url : le pendant de parse_url |
| 106 | 106 | function glue_url($url) { |
| 107 | - if (!is_array($url)) { |
|
| 108 | - return false; |
|
| 109 | - } |
|
| 110 | - // scheme |
|
| 111 | - $uri = (empty($url['scheme'])) ? '' : $url['scheme'] . '://'; |
|
| 112 | - // user & pass |
|
| 113 | - if (!empty($url['user'])) { |
|
| 114 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 115 | - } |
|
| 116 | - // host |
|
| 117 | - $uri .= $url['host']; |
|
| 118 | - // port |
|
| 119 | - $port = (empty($url['port'])) ? '' : ':' . $url['port']; |
|
| 120 | - $uri .= $port; |
|
| 121 | - // path |
|
| 122 | - $uri .= $url['path']; |
|
| 107 | + if (!is_array($url)) { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 110 | + // scheme |
|
| 111 | + $uri = (empty($url['scheme'])) ? '' : $url['scheme'] . '://'; |
|
| 112 | + // user & pass |
|
| 113 | + if (!empty($url['user'])) { |
|
| 114 | + $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 115 | + } |
|
| 116 | + // host |
|
| 117 | + $uri .= $url['host']; |
|
| 118 | + // port |
|
| 119 | + $port = (empty($url['port'])) ? '' : ':' . $url['port']; |
|
| 120 | + $uri .= $port; |
|
| 121 | + // path |
|
| 122 | + $uri .= $url['path']; |
|
| 123 | 123 | // fragment or query |
| 124 | - if (isset($url['fragment'])) { |
|
| 125 | - $uri .= '#' . $url['fragment']; |
|
| 126 | - } elseif (isset($url['query'])) { |
|
| 127 | - $uri .= '?' . $url['query']; |
|
| 128 | - } |
|
| 124 | + if (isset($url['fragment'])) { |
|
| 125 | + $uri .= '#' . $url['fragment']; |
|
| 126 | + } elseif (isset($url['query'])) { |
|
| 127 | + $uri .= '?' . $url['query']; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - return $uri; |
|
| 130 | + return $uri; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | // Ne pas afficher la partie 'password' du proxy |
| 135 | 135 | function no_password_proxy_url($http_proxy) { |
| 136 | - if ( |
|
| 137 | - $http_proxy |
|
| 138 | - && ($p = @parse_url((string) $http_proxy)) |
|
| 139 | - && isset($p['pass']) |
|
| 140 | - && $p['pass'] |
|
| 141 | - ) { |
|
| 142 | - $p['pass'] = '****'; |
|
| 143 | - $http_proxy = glue_url($p); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return $http_proxy; |
|
| 136 | + if ( |
|
| 137 | + $http_proxy |
|
| 138 | + && ($p = @parse_url((string) $http_proxy)) |
|
| 139 | + && isset($p['pass']) |
|
| 140 | + && $p['pass'] |
|
| 141 | + ) { |
|
| 142 | + $p['pass'] = '****'; |
|
| 143 | + $http_proxy = glue_url($p); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return $http_proxy; |
|
| 147 | 147 | } |