From 7bba87fed90ad82c9d92e4ead664513e711bd018 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Mon, 2 Mar 2020 13:08:03 +0100 Subject: [PATCH] [9.2.23] Proxy Web --- CHANGES.md | 2 ++ core/core.php | 29 +++++++++++++++++ core/module/config/config.php | 15 +++++++-- core/module/config/view/index/index.php | 31 ++++++++++++++++++- core/module/install/ressource/defaultdata.php | 6 +++- 5 files changed, 79 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 662d93dd..24f12810 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ # Changelog ## version 9.2.23 +- Nouveauté : + - Configuration du réseau : proxy http ou tcp sans authentification - Corrections : - Fonction magic_quotes dépréciée supprimée. - Mise à jour en ligne : diff --git a/core/core.php b/core/core.php index 11ff451b..13a42874 100644 --- a/core/core.php +++ b/core/core.php @@ -221,6 +221,25 @@ class common { // Mise à jour des données core $this->update(); + + // Données de proxy + $proxy = $this->getData(['config','proxyType']) . $this->getData(['config','proxyUrl']) . ':' . $this->getData(['config','proxyPort']); + if (!empty($this->getData(['config','proxyUrl'])) && + !empty($this->getData(['config','proxyPort'])) ) { + $context = array( + 'http' => array( + 'proxy' => $proxy, + 'request_fulluri' => true, + 'verify_peer' => false, + 'verify_peer_name' => false, + ), + "ssl"=>array( + "verify_peer"=>false, + "verify_peer_name"=>false + ) + ); + stream_context_set_default($context); + } } /** @@ -1061,6 +1080,16 @@ class common { $this->setData(['core', 'dataVersion', 9221]); $this->saveData(); } + // Version 9.2.23 + if($this->getData(['core', 'dataVersion']) < 9223) { + // Utile pour l'installation d'un backup sur un autre serveur + // mais avec la réécriture d'URM + $this->setData(['config', 'proxyUrl', '' ]); + $this->setData(['config', 'proxyPort', '' ]); + $this->setData(['config', 'proxyType', 'tcp://' ]); + $this->setData(['core', 'dataVersion', 9223]); + $this->saveData(); + } } } diff --git a/core/module/config/config.php b/core/module/config/config.php index 099ac0b0..ad74da6f 100755 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -147,6 +147,11 @@ class config extends common { 15 => '15 articles', 20 => '20 articles' ]; + // Type de proxy + public static $proxyType = [ + 'tcp://' => 'TCP', + 'http://' => 'HTTP' + ]; public function generateFiles() { @@ -288,6 +293,9 @@ class config extends common { $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN) === true) { $this->setData(['core','lastAutoUpdate',0]); } + // Vérification du proxy + $proxy = $this->getData(['config','proxyType']) . $this->getData(['config','proxyUrl']) . ':' . $this->getData(['config','proxyPort']); + $this->setData([ 'config', [ @@ -310,9 +318,12 @@ class config extends common { ], 'timezone' => $this->getInput('configTimezone', helper::FILTER_STRING_SHORT, true), 'title' => $this->getInput('configTitle', helper::FILTER_STRING_SHORT, true), - 'itemsperPage' => $this->getInput('itemsperPage', helper::FILTER_INT,true), + 'itemsperPage' => $this->getInput('configItemsperPage', helper::FILTER_INT,true), 'legalPageId' => $this->getInput('configLegalPageId'), - 'autoUpdate' => $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN) + 'autoUpdate' => $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN), + 'proxyType' => $this->getInput('configProxyType'), + 'proxyUrl' => $this->getInput('configProxyUrl'), + 'proxyPort' => $this->getInput('configProxyPort',helper::FILTER_INT) ] ]); if(self::$inputNotices === []) { diff --git a/core/module/config/view/index/index.php b/core/module/config/view/index/index.php index fff8fd10..8afcb10d 100755 --- a/core/module/config/view/index/index.php +++ b/core/module/config/view/index/index.php @@ -53,7 +53,7 @@ ]); ?>
- 'Articles par page', 'selected' => $this->getData(['config', 'itemsperPage']), 'help' => 'Modules Blog et News' @@ -285,6 +285,35 @@
+
+
+
+

Paramètres réseaux

+
+
+ 'Type de proxy', + 'selected' => $this->getData(['config', 'proxyType']) + ]); ?> +
+
+ 'Adresse du proxy', + 'placeholder' => 'cache.proxy.fr', + 'value' => $this->getData(['config', 'proxyUrl']) + ]); ?> +
+
+ 'Port du proxy', + 'placeholder' => '6060', + 'value' => $this->getData(['config', 'proxyPort']) + ]); ?> +
+
+
+
+
diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 968d6a66..a546eeec 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -21,12 +21,16 @@ class install extends common { 'timezone' => 'Europe/Paris', 'title' => 'Zwii, votre site en quelques clics !', 'itemsperPage' => 10, - 'legalPageId' => 'mentions-legales' + 'legalPageId' => 'mentions-legales', + 'proxyUrl' => "", + 'proxyPort' => "", + 'proxyType' => "tcp://" ], 'core' => [ 'dataVersion' => 0, 'lastBackup' => 0, 'lastClearTmp' => 0, + 'lastAutoUpdate' => 0, 'baseUrl' => '' ], 'page' => [