From 09894a7518f4946c65dc56ea6835812445daad23 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 21 Sep 2023 11:34:42 +0200 Subject: [PATCH] =?UTF-8?q?G=C3=A9n=C3=A9re=20automatiquement=20les=20cont?= =?UTF-8?q?enus=20des=20nouveaux=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .htaccess | 41 ++++++++++++++++++++++++++++++----- core/core.php | 18 +++++++-------- core/module/course/course.php | 4 ++++ 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/.htaccess b/.htaccess index 9027759..9bd3ba5 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,36 @@ -# Bloque l'accès aux données et aux log - - Order deny,allow - Deny from all - \ No newline at end of file +# Active la compression GZIP - option Apache + + mod_gzip_on Yes + mod_gzip_dechunk Yes + mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ + mod_gzip_item_include handler ^cgi-script$ + mod_gzip_item_include mime ^text\.* + mod_gzip_item_include mime ^application/x-javascript.* + mod_gzip_item_exclude mime ^image\.* + mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* + + +# Active la compression DEFLATE - option Apache + + AddOutputFilterByType DEFLATE text/plain + AddOutputFilterByType DEFLATE text/html + AddOutputFilterByType DEFLATE text/xml + AddOutputFilterByType DEFLATE text/shtml + AddOutputFilterByType DEFLATE text/css + AddOutputFilterByType DEFLATE application/xml + AddOutputFilterByType DEFLATE application/xhtml+xml + AddOutputFilterByType DEFLATE application/rss+xml + AddOutputFilterByType DEFLATE application/javascript + AddOutputFilterByType DEFLATE application/x-javascript + + +# Bloque l'accès à la liste des fichiers +Options -Indexes + +# Désactive l'option de substitution automatique + + Options -MultiViews + + +# ne pas supprimer la ligne URL rewriting ! +# URL rewriting diff --git a/core/core.php b/core/core.php index 5d184d8..f8c8a49 100644 --- a/core/core.php +++ b/core/core.php @@ -365,7 +365,7 @@ class common if ( file_exists(self::DATA_DIR . self::$siteContent . '/' . $stageId . '.json') === false ) { - $this->initData($stageId); + $this->initData($stageId, self::$siteContent); } } @@ -634,31 +634,31 @@ class common * Données valides : page ou module */ - public function initData($module) + public function initData($module, $path) { // Tableau avec les données vierges require_once('core/module/install/ressource/defaultdata.php'); // L'arborescence - if (!file_exists(self::DATA_DIR . self::$siteContent)) { - mkdir(self::DATA_DIR . self::$siteContent, 0755); + if (!file_exists(self::DATA_DIR . $path)) { + mkdir(self::DATA_DIR . $path, 0755); } - if (!file_exists(self::DATA_DIR . self::$siteContent . '/content')) { - mkdir(self::DATA_DIR . self::$siteContent . '/content', 0755); + if (!file_exists(self::DATA_DIR . $path . '/content')) { + mkdir(self::DATA_DIR . $path . '/content', 0755); } /* * Le site d'accueil, home ne dispose pas des mêmes modèles */ - $template = self::$siteContent === 'home' ? init::$siteTemplate : init::$courseDefault; + $template = $path === 'home' ? init::$siteTemplate : init::$courseDefault; // Création de page ou de module $this->setData([$module, $template[$module]]); // Création des pages if ($module === 'page') { - $content = self::$siteContent === 'home' ? init::$siteContent : init::$courseContent; + $content = $path === 'home' ? init::$siteContent : init::$courseContent; foreach ($content as $key => $value) { - $this->setPage($key, $value, self::$siteContent); + $this->setPage($key, $value, $path); } } diff --git a/core/module/course/course.php b/core/module/course/course.php index a9a62ca..027a30c 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -105,6 +105,10 @@ class course extends common // Créer la structure de données mkdir(self::DATA_DIR . $courseId); + $this->initDB('page', $courseId); + $this->initDB('module', $courseId); + $this->initData('page', $courseId); + $this->initData('module', $courseId); // BDD des inscrits $this->setData([