From 47775ec420e934ac6b4574b466a5470e789aa644 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 29 Oct 2021 19:25:17 +0200 Subject: [PATCH] =?UTF-8?q?cinfig=20=C3=A0=20v=C3=A9rifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/config/config.php | 277 ++++------------------ core/module/config/view/index/index.php | 34 +-- core/module/config/view/safety/safety.php | 26 +- 3 files changed, 79 insertions(+), 258 deletions(-) diff --git a/core/module/config/config.php b/core/module/config/config.php index 6b2bc2cb..fa17a5ea 100644 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -406,58 +406,15 @@ class config extends common { $this->setData(['user',$this->getuser('id'),'accessCsrf',$_SESSION['csrf']]); } // Sauvegarder - $this->setData([ - 'config', - [ - 'analyticsId' => $this->getInput('configAdvancedAnalyticsId'), - 'autoBackup' => $this->getInput('configAdvancedAutoBackup', helper::FILTER_BOOLEAN), - 'maintenance' => $this->getInput('configAdvancedMaintenance', helper::FILTER_BOOLEAN), - 'cookieConsent' => $this->getInput('configAdvancedCookieConsent', helper::FILTER_BOOLEAN), - 'favicon' => $this->getInput('configAdvancedFavicon'), - 'faviconDark' => $this->getInput('configAdvancedFaviconDark'), - 'social' => [ - 'facebookId' => $this->getInput('configAdvancedSocialFacebookId'), - 'linkedinId' => $this->getInput('configAdvancedSocialLinkedinId'), - 'instagramId' => $this->getInput('configAdvancedSocialInstagramId'), - 'pinterestId' => $this->getInput('configAdvancedSocialPinterestId'), - 'twitterId' => $this->getInput('configAdvancedSocialTwitterId'), - 'youtubeId' => $this->getInput('configAdvancedSocialYoutubeId'), - 'youtubeUserId' => $this->getInput('configAdvancedSocialYoutubeUserId'), - 'githubId' => $this->getInput('configAdvancedSocialGithubId') - ], - 'timezone' => $this->getInput('configAdvancedTimezone', helper::FILTER_STRING_SHORT, true), - 'autoUpdate' => $this->getInput('configAdvancedAutoUpdate', helper::FILTER_BOOLEAN), - 'autoUpdateHtaccess' => $this->getInput('configAdvancedAutoUpdateHtaccess', helper::FILTER_BOOLEAN), - 'proxyType' => $this->getInput('configAdvancedProxyType'), - 'proxyUrl' => $this->getInput('configAdvancedProxyUrl'), - 'proxyPort' => $this->getInput('configAdvancedProxyPort',helper::FILTER_INT), - 'captchaStrong' => $this->getInput('configAdvancedCaptchaStrong',helper::FILTER_BOOLEAN), - 'autoDisconnect' => $this->getInput('configAdvancedAutoDisconnect',helper::FILTER_BOOLEAN), - 'smtp' => [ - 'enable' => $this->getInput('configAdvancedSmtpEnable',helper::FILTER_BOOLEAN), - 'host' => $this->getInput('configAdvancedSmtpHost',helper::FILTER_STRING_SHORT), - 'port' => $this->getInput('configAdvancedSmtpPort',helper::FILTER_INT), - 'auth' => $this->getInput('configAdvancedSmtpAuth',helper::FILTER_BOOLEAN), - 'secure' => $this->getInput('configAdvancedSmtpSecure'), - 'username' => $this->getInput('configAdvancedSmtpUsername',helper::FILTER_STRING_SHORT), - 'password' =>helper::encrypt($this->getData(['config','smtp','username']),$this->getInput('configAdvancedSmtpPassword')), - 'sender' => $this->getInput('configAdvancedSmtpSender',helper::FILTER_MAIL) - ], - 'seo' => [ - 'robots' => $this->getInput('configAdvancedSeoRobots',helper::FILTER_BOOLEAN) - ], - 'connect' => [ - 'attempt' => $this->getInput('configAdvancedConnectAttempt',helper::FILTER_INT), - 'timeout' => $this->getInput('configAdvancedConnectTimeout',helper::FILTER_INT), - 'log' => $this->getInput('configAdvancedConnectLog',helper::FILTER_BOOLEAN), - 'anonymousIp' => $this->getInput('configAdvancedConnectAnonymousIp',helper::FILTER_INT), - 'captcha' => $this->getInput('configAdvancedConnectCaptcha',helper::FILTER_BOOLEAN), - ], - 'i18n' => [ - 'enable' => $this->getData(['config', 'i18n', 'enable']) - ] - ] - ]); + $this->setData(['config', 'autoBackup', $this->getInput('configAdvancedAutoBackup', helper::FILTER_BOOLEAN)]); + $this->setData(['config', 'maintenance', $this->getInput('configAdvancedMaintenance', helper::FILTER_BOOLEAN)]); + $this->setData(['config', 'cookieConsent', $this->getInput('configAdvancedCookieConsent', helper::FILTER_BOOLEAN)]); + $this->setData(['config', 'favicon', $this->getInput('configAdvancedFavicon')]); + $this->setData(['config', 'faviconDark', $this->getInput('configAdvancedFaviconDark')]); + $this->setData(['config', 'timezone', $this->getInput('configAdvancedTimezone', helper::FILTER_STRING_SHORT, true)]); + $this->setData(['config', 'autoUpdate', $this->getInput('configAdvancedAutoUpdate', helper::FILTER_BOOLEAN)]); + $this->setData(['config', 'autoUpdateHtaccess', $this->getInput('configAdvancedAutoUpdateHtaccess', helper::FILTER_BOOLEAN)]); + // Efface les fichiers de backup lorsque l'option est désactivée if ($this->getInput('configAdvancedFileBackup', helper::FILTER_BOOLEAN) === false) { $path = realpath('site/data'); @@ -561,14 +518,11 @@ class config extends common { 'sitemapPageLabel' => empty($this->getInput('configSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('configSitemapPageLabel', helper::FILTER_STRING_SHORT), 'metaDescription' => $this->getInput('configMetaDescription', helper::FILTER_STRING_LONG, true), 'title' => $this->getInput('configTitle', helper::FILTER_STRING_SHORT, true) - ] + ], ]); $this->setData(['config', 'i18n', 'enable', $this->getInput('configI18n',helper::FILTER_BOOLEAN) ]); - // Générer robots.txt et sitemap - $this->generateFiles(); - // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(), @@ -607,6 +561,18 @@ class config extends common { * Sécurité de la connexion **/ public function safety() { + // Soumission du formulaire + if($this->isPost()) { + $this->setData([ 'config', 'captchaStrong', $this->getInput('configAdvancedCaptchaStrong',helper::FILTER_BOOLEAN)]); + $this->setData([ 'config', 'autoDisconnect', $this->getInput('configAdvancedAutoDisconnect',helper::FILTER_BOOLEAN)]); + $this->setData([ 'config', 'connect' => [ + 'attempt' => $this->getInput('configAdvancedConnectAttempt',helper::FILTER_INT), + 'timeout' => $this->getInput('configAdvancedConnectTimeout',helper::FILTER_INT), + 'log' => $this->getInput('configAdvancedConnectLog',helper::FILTER_BOOLEAN), + 'anonymousIp' => $this->getInput('configAdvancedConnectAnonymousIp',helper::FILTER_INT), + 'captcha' => $this->getInput('configAdvancedConnectCaptcha',helper::FILTER_BOOLEAN) + ]]); + } // Valeurs en sortie $this->addOutput([ 'title' => 'Configuration avancée', @@ -620,68 +586,31 @@ class config extends common { public function social() { // Soumission du formulaire if($this->isPost()) { - - // Répercuter la suppression de la page dans la configuration du footer - if ( $this->getData(['theme','footer','displaySearch']) === true - AND $this->getInput('configSearchPageId') === 'none' - ){ - $this->setData(['theme', 'footer', 'displaySearch', false]); - } - if ( $this->getData(['theme','footer','displayLegal']) === true - AND $this->getInput('configLegalPageId') === 'none' - ){ - $this->setData(['theme', 'footer', 'displayLegal', false]); - } - // Sauvegarder - $this->setData([ - 'locale', - [ - 'homePageId' => $this->getInput('configHomePageId', helper::FILTER_ID, true), - 'page404' => $this->getInput('configPage404'), - 'page403' => $this->getInput('configPage403'), - 'page302' => $this->getInput('configPage302'), - 'legalPageId' => $this->getInput('configLegalPageId'), - 'searchPageId' => $this->getInput('configSearchPageId'), - 'searchPageLabel' => empty($this->getInput('configSearchPageLabel', helper::FILTER_STRING_SHORT)) ? 'Rechercher' : $this->getInput('configSearchPageLabel', helper::FILTER_STRING_SHORT), - 'legalPageLabel' => empty($this->getInput('configLegalPageLabel', helper::FILTER_STRING_SHORT)) ? 'Mentions légales' : $this->getInput('configLegalPageLabel', helper::FILTER_STRING_SHORT), - 'sitemapPageLabel' => empty($this->getInput('configSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('configSitemapPageLabel', helper::FILTER_STRING_SHORT), - 'metaDescription' => $this->getInput('configMetaDescription', helper::FILTER_STRING_LONG, true), - 'title' => $this->getInput('configTitle', helper::FILTER_STRING_SHORT, true) - ] - ]); + $this->setData([ 'config', 'analyticsId', $this->getInput('configAdvancedAnalyticsId')]); + $this->setData([ 'config', 'social' => [ + 'facebookId' => $this->getInput('configAdvancedSocialFacebookId'), + 'linkedinId' => $this->getInput('configAdvancedSocialLinkedinId'), + 'instagramId' => $this->getInput('configAdvancedSocialInstagramId'), + 'pinterestId' => $this->getInput('configAdvancedSocialPinterestId'), + 'twitterId' => $this->getInput('configAdvancedSocialTwitterId'), + 'youtubeId' => $this->getInput('configAdvancedSocialYoutubeId'), + 'youtubeUserId' => $this->getInput('configAdvancedSocialYoutubeUserId'), + 'githubId' => $this->getInput('configAdvancedSocialGithubId') + ]]); - $this->setData(['config', 'i18n', 'enable', $this->getInput('configI18n',helper::FILTER_BOOLEAN) ]); - - // Générer robots.txt et sitemap - $this->generateFiles(); + $this->setData([ 'config', 'seo' => [ + 'robots' => $this->getInput('configAdvancedSeoRobots',helper::FILTER_BOOLEAN) + ]]); // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(), - 'notification' => 'Modifications enregistrées', + 'notification' => 'Modifications enregistrées ' , 'state' => true ]); } - // Liste des pages - self::$pagesList = $this->getData(['page']); - foreach(self::$pagesList as $page => $pageId) { - if ($this->getData(['page',$page,'block']) === 'bar' || - $this->getData(['page',$page,'disable']) === true) { - unset(self::$pagesList[$page]); - } - } - - self::$orphansList = $this->getData(['page']); - foreach(self::$orphansList as $page => $pageId) { - if ($this->getData(['page',$page,'block']) === 'bar' || - $this->getData(['page',$page,'disable']) === true || - $this->getdata(['page',$page, 'position']) !== 0) { - unset(self::$orphansList[$page]); - } - } - // Valeurs en sortie $this->addOutput([ 'title' => 'Référencement', @@ -696,125 +625,21 @@ class config extends common { public function network() { // Soumission du formulaire if($this->isPost()) { - // Basculement en mise à jour auto - // Remise à 0 du compteur - if ($this->getData(['config','autoUpdate']) === false && - $this->getInput('configAdvancedAutoUpdate', helper::FILTER_BOOLEAN) === true) { - $this->setData(['core','lastAutoUpdate',0]); - } - // Eviter déconnexion automatique après son activation - if ( $this->getData(['config','autoDisconnect']) === false - AND $this->getInput('configAdvancedAutoDisconnect',helper::FILTER_BOOLEAN) === true ) { - $this->setData(['user',$this->getuser('id'),'accessCsrf',$_SESSION['csrf']]); - } // Sauvegarder - $this->setData([ - 'config', - [ - 'analyticsId' => $this->getInput('configAdvancedAnalyticsId'), - 'autoBackup' => $this->getInput('configAdvancedAutoBackup', helper::FILTER_BOOLEAN), - 'maintenance' => $this->getInput('configAdvancedMaintenance', helper::FILTER_BOOLEAN), - 'cookieConsent' => $this->getInput('configAdvancedCookieConsent', helper::FILTER_BOOLEAN), - 'favicon' => $this->getInput('configAdvancedFavicon'), - 'faviconDark' => $this->getInput('configAdvancedFaviconDark'), - 'social' => [ - 'facebookId' => $this->getInput('configAdvancedSocialFacebookId'), - 'linkedinId' => $this->getInput('configAdvancedSocialLinkedinId'), - 'instagramId' => $this->getInput('configAdvancedSocialInstagramId'), - 'pinterestId' => $this->getInput('configAdvancedSocialPinterestId'), - 'twitterId' => $this->getInput('configAdvancedSocialTwitterId'), - 'youtubeId' => $this->getInput('configAdvancedSocialYoutubeId'), - 'youtubeUserId' => $this->getInput('configAdvancedSocialYoutubeUserId'), - 'githubId' => $this->getInput('configAdvancedSocialGithubId') - ], - 'timezone' => $this->getInput('configAdvancedTimezone', helper::FILTER_STRING_SHORT, true), - 'autoUpdate' => $this->getInput('configAdvancedAutoUpdate', helper::FILTER_BOOLEAN), - 'autoUpdateHtaccess' => $this->getInput('configAdvancedAutoUpdateHtaccess', helper::FILTER_BOOLEAN), - 'proxyType' => $this->getInput('configAdvancedProxyType'), - 'proxyUrl' => $this->getInput('configAdvancedProxyUrl'), - 'proxyPort' => $this->getInput('configAdvancedProxyPort',helper::FILTER_INT), - 'captchaStrong' => $this->getInput('configAdvancedCaptchaStrong',helper::FILTER_BOOLEAN), - 'autoDisconnect' => $this->getInput('configAdvancedAutoDisconnect',helper::FILTER_BOOLEAN), - 'smtp' => [ - 'enable' => $this->getInput('configAdvancedSmtpEnable',helper::FILTER_BOOLEAN), - 'host' => $this->getInput('configAdvancedSmtpHost',helper::FILTER_STRING_SHORT), - 'port' => $this->getInput('configAdvancedSmtpPort',helper::FILTER_INT), - 'auth' => $this->getInput('configAdvancedSmtpAuth',helper::FILTER_BOOLEAN), - 'secure' => $this->getInput('configAdvancedSmtpSecure'), - 'username' => $this->getInput('configAdvancedSmtpUsername',helper::FILTER_STRING_SHORT), - 'password' =>helper::encrypt($this->getData(['config','smtp','username']),$this->getInput('configAdvancedSmtpPassword')), - 'sender' => $this->getInput('configAdvancedSmtpSender',helper::FILTER_MAIL) - ], - 'seo' => [ - 'robots' => $this->getInput('configAdvancedSeoRobots',helper::FILTER_BOOLEAN) - ], - 'connect' => [ - 'attempt' => $this->getInput('configAdvancedConnectAttempt',helper::FILTER_INT), - 'timeout' => $this->getInput('configAdvancedConnectTimeout',helper::FILTER_INT), - 'log' => $this->getInput('configAdvancedConnectLog',helper::FILTER_BOOLEAN), - 'anonymousIp' => $this->getInput('configAdvancedConnectAnonymousIp',helper::FILTER_INT), - 'captcha' => $this->getInput('configAdvancedConnectCaptcha',helper::FILTER_BOOLEAN), - ], - 'i18n' => [ - 'enable' => $this->getData(['config', 'i18n', 'enable']) - ] - ] - ]); - // Efface les fichiers de backup lorsque l'option est désactivée - if ($this->getInput('configAdvancedFileBackup', helper::FILTER_BOOLEAN) === false) { - $path = realpath('site/data'); - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) - { - if (strpos($filename,'backup.json')) { - unlink($filename); - } - } - if (file_exists('site/data/.backup')) unlink('site/data/.backup'); - } else { - touch('site/data/.backup'); - } - // Notice - if(self::$inputNotices === []) { - // Active la réécriture d'URL - $rewrite = $this->getInput('rewrite', helper::FILTER_BOOLEAN); - if( - $rewrite - AND helper::checkRewrite() === false - ) { - // Ajout des lignes dans le .htaccess - file_put_contents( - '.htaccess', - PHP_EOL . - '' . PHP_EOL . - "\tRewriteEngine on" . PHP_EOL . - "\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL . - "\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL . - "\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL . - "\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL . - "\tRewriteCond %{SERVER_PORT} 80" . PHP_EOL . - "\tRewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]" . PHP_EOL . - '', - FILE_APPEND - ); - // Change le statut de la réécriture d'URL (pour le helper::baseUrl() de la redirection) - helper::$rewriteStatus = true; - } - // Désactive la réécriture d'URL - elseif( - $rewrite === false - AND helper::checkRewrite() - ) { - // Suppression des lignes dans le .htaccess - $htaccess = explode('# URL rewriting', file_get_contents('.htaccess')); - file_put_contents('.htaccess', $htaccess[0] . '# URL rewriting'); - // Change le statut de la réécriture d'URL (pour le helper::baseUrl() de la redirection) - helper::$rewriteStatus = false; - } - // Met à jour la baseUrl - $this->setData(['core', 'baseUrl', helper::baseUrl(true,false) ]); - } - // Générer robots.txt et sitemap - $this->generateFiles(); + $this->setData([ 'config', 'proxyType', $this->getInput('configAdvancedProxyType')]); + $this->setData([ 'config', 'proxyUrl', $this->getInput('configAdvancedProxyUrl')]); + $this->setData([ 'config', 'proxyUrl', $this->getInput('configAdvancedProxyUrl')]); + $this->setData([ 'config', 'smtp' => [ + 'enable' => $this->getInput('configAdvancedSmtpEnable',helper::FILTER_BOOLEAN), + 'host' => $this->getInput('configAdvancedSmtpHost',helper::FILTER_STRING_SHORT), + 'port' => $this->getInput('configAdvancedSmtpPort',helper::FILTER_INT), + 'auth' => $this->getInput('configAdvancedSmtpAuth',helper::FILTER_BOOLEAN), + 'secure' => $this->getInput('configAdvancedSmtpSecure'), + 'username' => $this->getInput('configAdvancedSmtpUsername',helper::FILTER_STRING_SHORT), + 'password' =>helper::encrypt($this->getData(['config','smtp','username']),$this->getInput('configAdvancedSmtpPassword')), + 'sender' => $this->getInput('configAdvancedSmtpSender',helper::FILTER_MAIL) + ]]); + // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . $this->getUrl(), diff --git a/core/module/config/view/index/index.php b/core/module/config/view/index/index.php index c37ad64d..9b88bb5a 100644 --- a/core/module/config/view/index/index.php +++ b/core/module/config/view/index/index.php @@ -101,30 +101,6 @@ 'help' => 'Vérifiez d\'abord que votre serveur autorise l\'URL rewriting (ce qui n\'est pas le cas chez Free).' ]); ?> - - -
-
- $this->getData(['config','captchaStrong']), - 'help' => 'Option recommandée pour sécuriser la connexion. S\'applique à tous les captchas du site. Le captcha simple se limite à une addition de nombres de 0 à 10. Le captcha complexe utilise quatre opérations de nombres de 0 à 20. Activation recommandée.' - ]); ?> -
-
- $this->getData(['config','autoDisconnect']), - 'help' => 'Déconnecte les sessions ouvertes précédemment sur d\'autres navigateurs ou terminaux. Activation recommandée.' - ]); ?> -
- -
-
-
- $this->getData(['config', 'autoBackup']), - 'help' => 'Une archive contenant le dossier /site/data est copiée dans le dossier \'site/backup\'. La sauvegarde est conservée pendant 30 jours.

Les fichiers du site ne sont pas sauvegardés automatiquement. Activation recommandée.' - ]); ?> -

@@ -167,11 +143,19 @@

Maintenance

-
+
+ $this->getData(['config', 'autoBackup']), + 'help' => 'Une archive contenant le dossier /site/data est copiée dans le dossier \'site/backup\'. La sauvegarde est conservée pendant 30 jours.

Les fichiers du site ne sont pas sauvegardés automatiquement. Activation recommandée.' + ]); ?> +

+
$this->getData(['config', 'maintenance']) ]); ?>
+
+
helper::baseUrl() . 'config/backup', diff --git a/core/module/config/view/safety/safety.php b/core/module/config/view/safety/safety.php index 78bfa11c..9b9cd75d 100644 --- a/core/module/config/view/safety/safety.php +++ b/core/module/config/view/safety/safety.php @@ -63,6 +63,25 @@

Sécurité de la connexion

+
+
+ $this->getData(['config', 'connect','captcha']) + ]); ?> +
+
+ $this->getData(['config','captchaStrong']), + 'help' => 'Option recommandée pour sécuriser la connexion. S\'applique à tous les captchas du site. Le captcha simple se limite à une addition de nombres de 0 à 10. Le captcha complexe utilise quatre opérations de nombres de 0 à 20. Activation recommandée.' + ]); ?> +
+
+ $this->getData(['config','autoDisconnect']), + 'help' => 'Déconnecte les sessions ouvertes précédemment sur d\'autres navigateurs ou terminaux. Activation recommandée.' + ]); ?> +
+
-
-
- $this->getData(['config', 'connect','captcha']) - ]); ?> -
-