From 2a8563ce9ae300b0ffcbab8dd11f8c4bc1cd5d46 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Thu, 14 Mar 2024 19:14:13 +0100 Subject: [PATCH 01/18] =?UTF-8?q?json=20v=C3=A9rif?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/class/jsondb/JsonDb.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/class/jsondb/JsonDb.class.php b/core/class/jsondb/JsonDb.class.php index 0061417b..29d932a3 100644 --- a/core/class/jsondb/JsonDb.class.php +++ b/core/class/jsondb/JsonDb.class.php @@ -130,8 +130,8 @@ class JsonDb extends \Prowebcraft\Dot } $this->data = json_decode(file_get_contents($this->db), true); if (!$this->data === null && json_last_error() !== JSON_ERROR_NONE) { - throw new \InvalidArgumentException('Database file ' . $this->db - . ' contains invalid json object. Please validate or remove file'); + throw new \InvalidArgumentException('Le fichier ' . $this->db + . ' contient des données invalides.'); } } return $this->data; @@ -142,9 +142,14 @@ class JsonDb extends \Prowebcraft\Dot */ public function save() { - $v = json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); + $v = json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT | JSON_PRETTY_PRINT); + // $v = json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); $l = strlen($v); $t = 0; + if ($v === false) { + error_log('Erreur d\'encodage JSON : ' . json_last_error_msg()); + exit ('Erreur d\'encodage JSON : ' . json_last_error_msg()); + } while ($t < 5) { $w = file_put_contents($this->db, $v); // Multi user get a locker if ($w == $l) { From a02ce894c8add0396d2b306d4ee922721b9986f2 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Thu, 14 Mar 2024 20:36:30 +0100 Subject: [PATCH 02/18] 13.1.08 changes --- CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 0e6fa285..169f2a03 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,9 +3,10 @@ ## Version 13.1.08 -### Amélioration +### Améliorations - Sauvegarde de l'état des sélecteurs dans les tables des fontes et des utilisateurs. +- Ajoute des contrôles d'intégrité des base de données Json lors des opérations de chargement et de sauvegarde. ## Version 13.1.07 From f61c2a977aa5d3bb269d6c4c8519ac822bfdaae4 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 15 Mar 2024 20:10:06 +0100 Subject: [PATCH 03/18] config options --- module/folder/folder.php | 103 ++++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index f79022bf..7159835d 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -75,41 +75,74 @@ class folder extends common } -private function getFolderContent($chemin) -{ - // Vérifier si le chemin existe et est un dossier - if (is_dir($chemin)) { - // Ouvrir le dossier - if ($dh = opendir($chemin)) { - $items = isset($items) ? $items : '
    '; - // Parcourir les éléments du dossier - while (($element = readdir($dh)) !== false) { - // Exclure les éléments spéciaux - if ($element != '.' && $element != '..') { - // Construire le chemin complet de l'élément - $cheminComplet = $chemin . $element; - - // Vérifier si c'est un dossier - if (is_dir($cheminComplet)) { - // Afficher le nom du dossier avec un élément details - $items .= "
  • $element"; - // Appeler récursivement la fonction pour ce sous-dossier - $items .= $this->getFolderContent($cheminComplet); - $items .= '
  • '; - } else { - // Afficher le nom du fichier comme un lien - $items .= "
  • $element
  • "; - } - } - } - $items .= "
"; - - // Fermer le dossier - closedir($dh); - } - return $items; - } -} + private function getFolderContent($chemin, $config = []) + { + $showSubFolder = isset($config['showsubfolder']) ? $config['showsubfolder'] : true; + $sort = isset($config['sort']) ? $config['sort'] : true; + + // Vérifier si le chemin existe et est un dossier + if (!is_null($chemin) && is_dir($chemin)) { + // Ouvrir le dossier + if ($dh = opendir($chemin)) { + // Initialiser les tableaux pour les sous-dossiers et les fichiers + $subDirectories = []; + $files = []; + + // Parcourir les éléments du dossier + while (($element = readdir($dh)) !== false) { + // Exclure les éléments spéciaux + if ($element != '.' && $element != '..') { + // Construire le chemin complet de l'élément + $cheminComplet = $chemin . '/' .$element; + + // Vérifier si c'est un dossier + if (is_dir($cheminComplet)) { + // Ajouter le dossier au tableau des sous-dossiers + $subDirectories[] = $element; + } else { + // Ajouter le fichier au tableau des fichiers + $files[] = $element; + } + } + } + + // Fermer le dossier + closedir($dh); + + // Trier les sous-dossiers et les fichiers si nécessaire + if ($sort) { + sort($subDirectories); + sort($files); + } + + // Initialiser la liste des éléments + $items = '
    '; + + // Ajouter les sous-dossiers à la liste si configuré pour les afficher + if ($showSubFolder) { + foreach ($subDirectories as $subDirectory) { + $items .= "
  • $subDirectory"; + // Appeler récursivement la fonction pour ce sous-dossier + $items .= $this->getFolderContent($chemin . '/' . $subDirectory, $config); + $items .= '
  • '; + } + } + + // Ajouter les fichiers à la liste + foreach ($files as $file) { + $items .= "
  • $file
  • "; + } + + // Fermer la liste + $items .= "
"; + + return $items; + } + } + + return ''; + } + From 75203d6e8e20991b09444729a669e866607f5fe9 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 15 Mar 2024 20:13:58 +0100 Subject: [PATCH 04/18] config options --- module/folder/folder.php | 36 +++++++++++++--------------- module/folder/view/config/config.php | 17 +++++++++---- module/folder/view/index/index.php | 2 +- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 7159835d..81b13009 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -54,7 +54,12 @@ class folder extends common $this->getUser('permission', __CLASS__, __FUNCTION__) === true && $this->isPost() ) { - $this->setData(['module', $this->getUrl(0), 'path', preg_replace('/^\\./', '', $this->getInput('folderEditPath')) ]); + $this->setData(['module', + $this->getUrl(0),[ + 'path'=> preg_replace('/^\\./', '', $this->getInput('folderConfigPath')), + 'title' => $this->getInput('folderConfigTitle') + + ]]); // Valeurs en sortie $this->addOutput([ @@ -75,13 +80,10 @@ class folder extends common } - private function getFolderContent($chemin, $config = []) + private function getFolderContent($chemin) { - $showSubFolder = isset($config['showsubfolder']) ? $config['showsubfolder'] : true; - $sort = isset($config['sort']) ? $config['sort'] : true; - // Vérifier si le chemin existe et est un dossier - if (!is_null($chemin) && is_dir($chemin)) { + if (is_dir($chemin)) { // Ouvrir le dossier if ($dh = opendir($chemin)) { // Initialiser les tableaux pour les sous-dossiers et les fichiers @@ -109,23 +111,19 @@ class folder extends common // Fermer le dossier closedir($dh); - // Trier les sous-dossiers et les fichiers si nécessaire - if ($sort) { - sort($subDirectories); - sort($files); - } + // Trier les sous-dossiers et les fichiers + sort($subDirectories); + sort($files); // Initialiser la liste des éléments $items = '
    '; - // Ajouter les sous-dossiers à la liste si configuré pour les afficher - if ($showSubFolder) { - foreach ($subDirectories as $subDirectory) { - $items .= "
  • $subDirectory"; - // Appeler récursivement la fonction pour ce sous-dossier - $items .= $this->getFolderContent($chemin . '/' . $subDirectory, $config); - $items .= '
  • '; - } + // Ajouter les sous-dossiers à la liste + foreach ($subDirectories as $subDirectory) { + $items .= "
  • $subDirectory"; + // Appeler récursivement la fonction pour ce sous-dossier + $items .= $this->getFolderContent($chemin . '/' . $subDirectory); + $items .= '
  • '; } // Ajouter les fichiers à la liste diff --git a/module/folder/view/config/config.php b/module/folder/view/config/config.php index b38dd561..f4946c9d 100644 --- a/module/folder/view/config/config.php +++ b/module/folder/view/config/config.php @@ -17,12 +17,19 @@

    - 'Dossier', - 'class' => 'filemanager', - 'selected' => $this->getData(['module', $this->getUrl(0), 'path']) - ]); ?> + 'Dossier', + 'class' => 'filemanager', + 'selected' => $this->getData(['module', $this->getUrl(0), 'path']) + ]); ?>
    +
    + 'Titre', + 'placeholder' => 'Répertoire', + 'value' => empty($this->getData(['module', $this->getUrl(0), 'title'])) ? 'Répertoire' : $this->getData(['module', $this->getUrl(0), 'title']) + ]); ?> +
    diff --git a/module/folder/view/index/index.php b/module/folder/view/index/index.php index 25607194..cf4506dc 100644 --- a/module/folder/view/index/index.php +++ b/module/folder/view/index/index.php @@ -1,6 +1,6 @@
    -

    Répertoire

    +

    getData(['module', $this->getUrl(0), 'title']);?>

    \ No newline at end of file From c4fc466876490b863586365d081c87fee40c0dd4 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 15 Mar 2024 21:14:49 +0100 Subject: [PATCH 05/18] config deux options --- module/folder/folder.php | 157 +++++++++++++++------------ module/folder/view/config/config.php | 80 ++++++++------ 2 files changed, 135 insertions(+), 102 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 81b13009..dc86ddba 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -36,7 +36,10 @@ class folder extends common public function index() { - self::$folders = $this->getFolderContent($this->getData(['module', $this->getUrl(0), 'path'])); + $config['showsubfolder'] = $this->getData(['module', $this->getUrl(0), 'subfolder']); + $config['sort'] = $this->getData(['module', $this->getUrl(0), 'sort']); + + self::$folders = $this->getFolderContent($this->getData(['module', $this->getUrl(0), 'path']), $config); // Valeurs en sortie $this->addOutput([ @@ -54,12 +57,18 @@ class folder extends common $this->getUser('permission', __CLASS__, __FUNCTION__) === true && $this->isPost() ) { - $this->setData(['module', - $this->getUrl(0),[ - 'path'=> preg_replace('/^\\./', '', $this->getInput('folderConfigPath')), - 'title' => $this->getInput('folderConfigTitle') + $this->setData([ + 'module', + $this->getUrl(0), + [ + 'path' => preg_replace('/^\\./', '', $this->getInput('folderConfigPath')), + 'title' => $this->getInput('folderConfigTitle'), + 'sort' => $this->getInput('folderConfigSort', helper::FILTER_BOOLEAN), + 'subfolder' => $this->getInput('folderConfigSubfolder', helper::FILTER_BOOLEAN), + 'folder' => $this->getInput('folderConfigFolder', helper::FILTER_BOOLEAN), - ]]); + ] + ]); // Valeurs en sortie $this->addOutput([ @@ -80,70 +89,80 @@ class folder extends common } - private function getFolderContent($chemin) - { - // Vérifier si le chemin existe et est un dossier - if (is_dir($chemin)) { - // Ouvrir le dossier - if ($dh = opendir($chemin)) { - // Initialiser les tableaux pour les sous-dossiers et les fichiers - $subDirectories = []; - $files = []; - - // Parcourir les éléments du dossier - while (($element = readdir($dh)) !== false) { - // Exclure les éléments spéciaux - if ($element != '.' && $element != '..') { - // Construire le chemin complet de l'élément - $cheminComplet = $chemin . '/' .$element; - - // Vérifier si c'est un dossier - if (is_dir($cheminComplet)) { - // Ajouter le dossier au tableau des sous-dossiers - $subDirectories[] = $element; - } else { - // Ajouter le fichier au tableau des fichiers - $files[] = $element; - } - } - } - - // Fermer le dossier - closedir($dh); - - // Trier les sous-dossiers et les fichiers - sort($subDirectories); - sort($files); - - // Initialiser la liste des éléments - $items = '
      '; - - // Ajouter les sous-dossiers à la liste - foreach ($subDirectories as $subDirectory) { - $items .= "
    • $subDirectory"; - // Appeler récursivement la fonction pour ce sous-dossier - $items .= $this->getFolderContent($chemin . '/' . $subDirectory); - $items .= '
    • '; - } - - // Ajouter les fichiers à la liste - foreach ($files as $file) { - $items .= "
    • $file
    • "; - } - - // Fermer la liste - $items .= "
    "; - - return $items; - } - } - - return ''; - } - +private function getFolderContent($chemin, $config = []) +{ + $showSubFolder = isset($config['showsubfolder']) ? $config['showsubfolder'] : true; + $sort = isset($config['sort']) ? $config['sort'] : true; + + // Vérifier si le chemin existe et est un dossier + if (is_dir($chemin)) { + // Ouvrir le dossier + if ($dh = opendir($chemin)) { + // Initialiser les tableaux pour les sous-dossiers et les fichiers + $subDirectories = []; + $files = []; + + // Parcourir les éléments du dossier + while (($element = readdir($dh)) !== false) { + // Exclure les éléments spéciaux + if ($element != '.' && $element != '..') { + // Construire le chemin complet de l'élément + $cheminComplet = $chemin . '/' .$element; + + // Vérifier si c'est un dossier + if (is_dir($cheminComplet)) { + // Ajouter le dossier au tableau des sous-dossiers + $subDirectories[] = $element; + } else { + // Ajouter le fichier au tableau des fichiers + $files[] = $element; + } + } + } + + // Fermer le dossier + closedir($dh); + + // Trier les sous-dossiers et les fichiers si nécessaire + if ($sort) { + sort($subDirectories); + sort($files); + } + + // Initialiser la liste des éléments + $items = '
      '; + + // Ajouter les sous-dossiers à la liste si configuré pour les afficher + if ($showSubFolder) { + foreach ($subDirectories as $subDirectory) { + $items .= "
    • $subDirectory"; + // Appeler récursivement la fonction pour ce sous-dossier + $items .= $this->getFolderContent($chemin . '/' . $subDirectory, $config); + $items .= '
    • '; + } + } + + // Ajouter les fichiers à la liste + foreach ($files as $file) { + $items .= "
    • $file
    • "; + } + + // Fermer la liste + $items .= "
    "; + + return $items; + } + } + + return ''; +} + + + + + + - - /** * Liste les dossier contenus dans RFM diff --git a/module/folder/view/config/config.php b/module/folder/view/config/config.php index f4946c9d..8960452c 100644 --- a/module/folder/view/config/config.php +++ b/module/folder/view/config/config.php @@ -1,39 +1,53 @@ -
    -
    - 'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), - 'value' => template::ico('left') - ]); ?> -
    -
    - +
    +
    + 'buttonGrey', + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0), + 'value' => template::ico('left') + ]); ?> +
    +
    + +
    +
    +
    +
    +
    +

    + +

    +
    +
    + 'Dossier', + 'class' => 'filemanager', + 'selected' => $this->getData(['module', $this->getUrl(0), 'path']) + ]); ?> +
    +
    + 'Titre', + 'placeholder' => 'Répertoire', + 'value' => empty ($this->getData(['module', $this->getUrl(0), 'title'])) ? 'Répertoire' : $this->getData(['module', $this->getUrl(0), 'title']) + ]); ?> +
    +
    +
    +
    + $this->getData(['module', $this->getUrl(0), 'sort']) + ]); ?> +
    +
    + $this->getData(['module', $this->getUrl(0), 'subfolder']) + ]); ?> +
    +
    -
    -
    -
    -

    -
    -
    - 'Dossier', - 'class' => 'filemanager', - 'selected' => $this->getData(['module', $this->getUrl(0), 'path']) - ]); ?> -
    -
    - 'Titre', - 'placeholder' => 'Répertoire', - 'value' => empty($this->getData(['module', $this->getUrl(0), 'title'])) ? 'Répertoire' : $this->getData(['module', $this->getUrl(0), 'title']) - ]); ?> -
    -
    -
    -
    -
    +
    Version n° From 49180ab4ed64a83950dd7ab131a193bad0a1e6de Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sat, 16 Mar 2024 08:36:52 +0100 Subject: [PATCH 06/18] =?UTF-8?q?Dossiers=20d=C3=A9pli=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/folder/folder.php | 149 ++++++++++++++++---------- module/folder/view/config/config.php | 14 ++- module/folder/view/index/index.css | 17 ++- module/folder/view/index/index.js.php | 11 ++ 4 files changed, 131 insertions(+), 60 deletions(-) create mode 100644 module/folder/view/index/index.js.php diff --git a/module/folder/folder.php b/module/folder/folder.php index dc86ddba..bb6b9447 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -36,9 +36,13 @@ class folder extends common public function index() { + // Configuration de l'affichage $config['showsubfolder'] = $this->getData(['module', $this->getUrl(0), 'subfolder']); $config['sort'] = $this->getData(['module', $this->getUrl(0), 'sort']); + $config['showdetails'] = $this->getData(['module', $this->getUrl(0), 'details']); + $config['initialfolderstate'] = $this->getData(['module', $this->getUrl(0), 'folderstate']); + // Générer l'affichage self::$folders = $this->getFolderContent($this->getData(['module', $this->getUrl(0), 'path']), $config); // Valeurs en sortie @@ -66,7 +70,8 @@ class folder extends common 'sort' => $this->getInput('folderConfigSort', helper::FILTER_BOOLEAN), 'subfolder' => $this->getInput('folderConfigSubfolder', helper::FILTER_BOOLEAN), 'folder' => $this->getInput('folderConfigFolder', helper::FILTER_BOOLEAN), - + 'details' => $this->getInput('folderConfigDetails', helper::FILTER_BOOLEAN), + 'folderstate' => $this->getInput('folderConfigFolderState', helper::FILTER_BOOLEAN), ] ]); @@ -88,74 +93,104 @@ class folder extends common ]); } + private function getFolderContent($chemin, $config = []) + { + $showSubFolder = isset ($config['showsubfolder']) ? $config['showsubfolder'] : true; + $sort = isset ($config['sort']) ? $config['sort'] : true; + $showDetails = isset ($config['showdetails']) ? $config['showdetails'] : false; + $initialFolderState = isset ($config['initialfolderstate']) ? $config['initialfolderstate'] : 'collapsed'; -private function getFolderContent($chemin, $config = []) -{ - $showSubFolder = isset($config['showsubfolder']) ? $config['showsubfolder'] : true; - $sort = isset($config['sort']) ? $config['sort'] : true; + // Vérifier si le chemin existe et est un dossier + if (is_dir($chemin)) { + // Ouvrir le dossier + if ($dh = opendir($chemin)) { + // Initialiser les tableaux pour les sous-dossiers et les fichiers + $subDirectories = []; + $files = []; - // Vérifier si le chemin existe et est un dossier - if (is_dir($chemin)) { - // Ouvrir le dossier - if ($dh = opendir($chemin)) { - // Initialiser les tableaux pour les sous-dossiers et les fichiers - $subDirectories = []; - $files = []; + // Parcourir les éléments du dossier + while (($element = readdir($dh)) !== false) { + // Exclure les éléments spéciaux + if ($element != '.' && $element != '..') { + // Construire le chemin complet de l'élément + $cheminComplet = $chemin . '/' . $element; - // Parcourir les éléments du dossier - while (($element = readdir($dh)) !== false) { - // Exclure les éléments spéciaux - if ($element != '.' && $element != '..') { - // Construire le chemin complet de l'élément - $cheminComplet = $chemin . '/' .$element; + // Vérifier si c'est un dossier + if (is_dir($cheminComplet)) { + // Ajouter le dossier au tableau des sous-dossiers + $subDirectories[] = $element; + } else { + // Ajouter le fichier au tableau des fichiers + $files[] = $element; + } + } + } - // Vérifier si c'est un dossier - if (is_dir($cheminComplet)) { - // Ajouter le dossier au tableau des sous-dossiers - $subDirectories[] = $element; - } else { - // Ajouter le fichier au tableau des fichiers - $files[] = $element; - } - } - } + // Fermer le dossier + closedir($dh); - // Fermer le dossier - closedir($dh); + // Trier les sous-dossiers et les fichiers si nécessaire + if ($sort) { + sort($subDirectories); + sort($files); + } - // Trier les sous-dossiers et les fichiers si nécessaire - if ($sort) { - sort($subDirectories); - sort($files); - } + // Initialiser la liste des éléments + $items = '
      '; - // Initialiser la liste des éléments - $items = '
        '; + // Ajouter les sous-dossiers à la liste si configuré pour les afficher + if ($showSubFolder) { + foreach ($subDirectories as $subDirectory) { + $folderClass = ''; + if ($initialFolderState == 'collapsed') { + $folderClass = 'collapsible'; + } + $items .= "
      • $subDirectory
          getFolderContent($chemin . '/' . $subDirectory, $config); + $items .= '
      • '; + } + } - // Ajouter les sous-dossiers à la liste si configuré pour les afficher - if ($showSubFolder) { - foreach ($subDirectories as $subDirectory) { - $items .= "
      • $subDirectory"; - // Appeler récursivement la fonction pour ce sous-dossier - $items .= $this->getFolderContent($chemin . '/' . $subDirectory, $config); - $items .= '
      • '; - } - } + // Ajouter les fichiers à la liste + foreach ($files as $file) { + $fileFullPath = $chemin . '/' . $file; + $fileInfo = ''; + if ($showDetails) { + $fileSize = filesize($fileFullPath); + $fileSizeFormatted = $this->formatSizeUnits($fileSize); + $fileInfo = " " . date("Y-m-d H:i:s", filemtime($fileFullPath)) . ", $fileSizeFormatted"; + } + $items .= "
      • $file$fileInfo
      • "; + } - // Ajouter les fichiers à la liste - foreach ($files as $file) { - $items .= "
      • $file
      • "; - } + // Fermer la liste + $items .= "
      "; - // Fermer la liste - $items .= "
    "; + return $items; + } + } - return $items; - } - } + return ''; + } + + + + private function formatSizeUnits($bytes) + { + $units = array('octest', 'Ko', 'Mo', 'Go', 'To'); + $i = 0; + while ($bytes >= 1024) { + $bytes /= 1024; + $i++; + } + return round($bytes, 2) . ' ' . $units[$i]; + } - return ''; -} diff --git a/module/folder/view/config/config.php b/module/folder/view/config/config.php index 8960452c..2d7702f5 100644 --- a/module/folder/view/config/config.php +++ b/module/folder/view/config/config.php @@ -34,16 +34,26 @@
    -
    +
    $this->getData(['module', $this->getUrl(0), 'sort']) ]); ?>
    -
    +
    $this->getData(['module', $this->getUrl(0), 'subfolder']) ]); ?>
    +
    + $this->getData(['module', $this->getUrl(0), 'details']) + ]); ?> +
    +
    + $this->getData(['module', $this->getUrl(0), 'folderstate']) + ]); ?> +
    diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index ac52c9db..821c8cb3 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -1,7 +1,7 @@ #dirindex article { display: block; margin: 0 auto; - width: 480px; + width: 600px; } #dirindex a { @@ -42,4 +42,19 @@ #dirindex li { padding-left: 5px; list-style-position : outside; +} + +/* Style pour le pliage/dépliage des dossiers */ +.toggle { + cursor: pointer; +} + +/* Style pour les sous-éléments des dossiers */ +.sub-items { + list-style-type: none; +} + +/* Style pour les informations de fichier */ +.file-info { + float: right; } \ No newline at end of file diff --git a/module/folder/view/index/index.js.php b/module/folder/view/index/index.js.php new file mode 100644 index 00000000..106f4cbb --- /dev/null +++ b/module/folder/view/index/index.js.php @@ -0,0 +1,11 @@ + + +$(document).ready(function() { + // Gérer le clic sur les éléments avec la classe toggle + $('.toggle').click(function() { + // Trouver le prochain élément de type ul avec la classe sub-items + var subItems = $(this).next('ul.sub-items'); + // Toggle pour afficher ou cacher les sous-éléments + subItems.slideToggle(); + }); +}); From 5e7c9597cd49b3edda959a8523d584b769096f4d Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 08:07:54 +0100 Subject: [PATCH 07/18] Format de date --- module/folder/folder.php | 2 +- module/folder/view/index/index.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index bb6b9447..e13aeb03 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -163,7 +163,7 @@ class folder extends common if ($showDetails) { $fileSize = filesize($fileFullPath); $fileSizeFormatted = $this->formatSizeUnits($fileSize); - $fileInfo = " " . date("Y-m-d H:i:s", filemtime($fileFullPath)) . ", $fileSizeFormatted"; + $fileInfo = " " . date("d-m-Y H:i", filemtime($fileFullPath)) . " - $fileSizeFormatted"; } $items .= "
  • $file$fileInfo
  • "; } diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index 821c8cb3..028bbbb3 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -52,6 +52,7 @@ /* Style pour les sous-éléments des dossiers */ .sub-items { list-style-type: none; + margin-left: -40px; } /* Style pour les informations de fichier */ From d89455d86a4dde3d5d2c5bf2a57c83949912913f Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 09:08:08 +0100 Subject: [PATCH 08/18] Alignement des dates --- module/folder/folder.php | 33 +++++++++++++++--------------- module/folder/view/index/index.css | 10 ++++++--- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index e13aeb03..d3430759 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -95,11 +95,11 @@ class folder extends common private function getFolderContent($chemin, $config = []) { - $showSubFolder = isset ($config['showsubfolder']) ? $config['showsubfolder'] : true; - $sort = isset ($config['sort']) ? $config['sort'] : true; - $showDetails = isset ($config['showdetails']) ? $config['showdetails'] : false; - $initialFolderState = isset ($config['initialfolderstate']) ? $config['initialfolderstate'] : 'collapsed'; - + $showSubFolder = isset($config['showsubfolder']) ? $config['showsubfolder'] : true; + $sort = isset($config['sort']) ? $config['sort'] : true; + $showDetails = isset($config['showdetails']) ? $config['showdetails'] : false; + $initialFolderState = isset($config['initialfolderstate']) ? $config['initialfolderstate'] : 'collapsed'; + // Vérifier si le chemin existe et est un dossier if (is_dir($chemin)) { // Ouvrir le dossier @@ -107,14 +107,14 @@ class folder extends common // Initialiser les tableaux pour les sous-dossiers et les fichiers $subDirectories = []; $files = []; - + // Parcourir les éléments du dossier while (($element = readdir($dh)) !== false) { // Exclure les éléments spéciaux if ($element != '.' && $element != '..') { // Construire le chemin complet de l'élément $cheminComplet = $chemin . '/' . $element; - + // Vérifier si c'est un dossier if (is_dir($cheminComplet)) { // Ajouter le dossier au tableau des sous-dossiers @@ -125,19 +125,19 @@ class folder extends common } } } - + // Fermer le dossier closedir($dh); - + // Trier les sous-dossiers et les fichiers si nécessaire if ($sort) { sort($subDirectories); sort($files); } - + // Initialiser la liste des éléments $items = '
      '; - + // Ajouter les sous-dossiers à la liste si configuré pour les afficher if ($showSubFolder) { foreach ($subDirectories as $subDirectory) { @@ -155,7 +155,7 @@ class folder extends common $items .= '
    '; } } - + // Ajouter les fichiers à la liste foreach ($files as $file) { $fileFullPath = $chemin . '/' . $file; @@ -163,20 +163,21 @@ class folder extends common if ($showDetails) { $fileSize = filesize($fileFullPath); $fileSizeFormatted = $this->formatSizeUnits($fileSize); - $fileInfo = " " . date("d-m-Y H:i", filemtime($fileFullPath)) . " - $fileSizeFormatted"; + $fileInfo = "
    " . date("d-m-Y H:i", filemtime($fileFullPath)) . " - $fileSizeFormatted
    "; } $items .= "
  • $file$fileInfo
  • "; } - + // Fermer la liste $items .= "
"; - + return $items; } } - + return ''; } + diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index 028bbbb3..8c570d35 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -55,7 +55,11 @@ margin-left: -40px; } -/* Style pour les informations de fichier */ -.file-info { + +.file-info-container { + display: flex; float: right; -} \ No newline at end of file + align-content: left; + /* Ajout d'une largeur fixe à la div */ + width: 200px; +} From 10083e7ee8a55f0f66df91733673a30c7baf5f9b Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 09:13:32 +0100 Subject: [PATCH 09/18] Folder Alignements --- module/folder.zip | Bin 0 -> 6094 bytes module/folder/folder.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 module/folder.zip diff --git a/module/folder.zip b/module/folder.zip new file mode 100644 index 0000000000000000000000000000000000000000..3d675ab035d6d2faaa43edd1f9128a84807046fe GIT binary patch literal 6094 zcmb7I1yq#l(_bVO5D^yTl1rDA2ue#g2rRfX(#_J{(j_b+3P^WLEFefIAt@pu-6_(I zARnuLFI>*O_w&x4d1v>WJ->Npo_S_|&!Z%Vigp8l6ntqr^&emU_W%MY0VXz9M#lE+ z4^^)LfYcd##i=QddUV=-~Sb@y)5PnY*2n>>qe44CnmhU4Ek0#~|&~-LX^XQ?%`4}}vF^c)Y z_jWURdM2&SX|;o++BQ|%=BhMys0yo24G(j@lc``C;`QN*p5^vxiI>#V0v{nScbsIf z%Gy(hO4%X7_yDG>L^wFlzz1MMo8Fp_Wglu(vPr)+bhn=O-VkUS#~u9{%hZ8dwMY?>FOh*58Gy03*Hl-TcJ zH^Wh}Uh5Qzk9{u~haFPKg?T2YB$Ja-z{zKUIepsP+w8TOwaE)%5ZZ1?B9pzi5m{)|>t78OdNuiXny_)VB+HhyO#E~>cbgVz%d<;fUt?XqL!o$w7%D|>QbD609GoxOLKUA=`+3au^2Y@ThQq{^g+olxJVXeUlhdmN zXmu*4#91{)c0q9?bkQ*_2F}$U&Xwv@pHCE}${iS`!X=`02S4YJ`DE1}>ow%s_F&h45_3p?w7d{c=q3M%eZm^8_bE9F9v$qsDeZ}lqanxQ5# zg)GY5?p7oo$_Ax(eM)Z@`XlgXxR~`YunC&zRuV0vjwO?=-;DA#)yV0KTgJvusQ2n8 z6xQCT&}=So$*~G?GVK7@Du|NEWPEg%1+FX9t<;!HoQycvMv{UgxZo_pvS!?bST>j} zaOnrWyIPtpFq8zGcrfb3ix%GJ6_JlS(e+p-3zAvaQrCEDAGn2ub)dUTFbL;{qJ>yH zP!$W@zV8rPL?&I4{@hlm9VT;SX@CY`$otBIt|rKTXmfM80(WStZVSh3DWV$(9AH3M zg{3_VTpe2i(qnzT)|lG7uyin4qcIbhJG%NRBn_}6Lp%kh!HUCcQT+IQ2fToiws*)H zy%am()H%0|&vtFN2*1C*efK+>xYLpd0o_1ani^xJ5dpSTD`LyDbE*=+&1YO~s^7y_ zhLxg0oJ;CF5ba8HeI)_$+%yLZchXXrYQF&+Xql;26H(*b@GdFh^+!ssP8Z^r#j7^; zWtCZfB;1Ru|B?cHN4eXhQI46XRRG8lZgW4eUhEOWO7TjSEX3W5qrhsnH{;RcSLF3T zkLDO?H1nd*GBzQkQTGgsoe`^wOPm-=>YE;-dcWAgkwN?Ey+AHyKN-;ynAyuN!Kk<2 zVTMsfD{5}JAxjo5q7L-dtBj{9D1B5u{?%BFZZohyR@q193kT>{D8HlH<1YJ?_93A=hTA&-V!7a`VTL?rUntWKrP0HM-q}^$uaH%czmfGPZe(P{1(=m%4Z@ z+uh(!dLK3QHNQy7>CSLO?Le`)c#ov+0wlYPi{3=Hz};+d2XLwcpN`R7&_25XPqtudrb zl=vs68;LF6R2Yy^ zG{X>-2NQ$N7HWGL!%3oZk*>J9UFJ9GHs{Pu7iUisj~POmZu{a@B6gHy0vl~;$oz_? z<|&Pv2a2hxaPy%|j8@yzb6N_N@>sHjW&(=w9ek|Pnw-9pX;Uwy(DLz<l}EhSeYzc zl=XMLCQoV&jtIsxt8PDtS+;!{k?qf%WqC4|q&R;#XN02Fe+{e;HcFCP z2@oGYTLrQYW-+lWbpoAjs>|pRni49AREURfVI&-Qf=z1bnC-O?&5??HRas#RvjW`& z#?055WN#)k2HzE`RmwaSvVffgZ5bvZ{B-W&1%|v-k9xn}oygrQzLUe>#knjQS}<36$%|(H+r)s1DRqZDC_3Mj3WT6 zC&iIs)U;jdL2PP!f=tb9Sv#I>ELV&3a#*o*6~#E%)JJ%BglC}Efn ze;%xn?Q!Mr+hn;+JBv!2eCb2kc9xDVIhi7*vRMe=N@8<*OxN5?Rm|%wG5ThvhL56^ zQ==1J!b?&iF>sAS%je0OGcoEhx%frNi7AkTr}@SHv;>;58TzSt8L7H48dqY&1}ZA6 z%6owc{?2m}# zbBcU!r?yubMm4TIlk^-O4d5Q>!XWS5Q4QLN=gj;NqY7?#nme4QpxhaigC?i6BsQT` zRdiS92?0@rZhjdTdiIIow!%r2%AA#d0ld2QbfIcY2${f9MQgHwv*aPube_QN3->q0 zsQ+Fozvfg&=ALoqnIi3_>^Z5(!DescjDNc!Ue2f#L1H@9E~;}4V+p-xRkGA9IFg$9 zD3c>>!nl%GitS$PtRo)7ZYyYag65F1o6D_?WIxq2bA;0K1|UJyRFz%dSi8<`rVV-+ zR~P_N4P%p>?FxGJXmNQe%XmXl`0Use=r0eP^%a7}n53P<8HC%lYHmBar7p_vQ zT}yr>GL4-=G;?j7a+Og@+zal?>q(H?n%jnkY2GQgD^xEO19>xRA@(|8TG-Z+GtPuj z9N)lZV+?&!;r?865)EmuB52Y?M;PoD=;TExAA_yq2jb%?>tsJD-V$ zI0!eQPg}wW@(IvEz^b>^wutDH?8f*|&?sS2 z4mY3O7bR6w_OQ1)B9(UO&T;II$x9kP)0pGndULfhEx22J=2(B0Hi%2hCNB#8pbwkg zC#^+0y03xOc6}HQz7E^piLT{ryY7i|>4qbRl7p{PLHqiZEmU`Od$| zHqWzhv7sUnk$m%)tco~YLjG;`dG6rv_~*HU)=Lh4myMoh9+{ep{0GTLf61yJ;nlyU z=0CI3U#oyzWF(=wIF>HD%Jgf*`8QX;L9Z^lLN3e2v4EU&za-Ny_WEC4{l}?y(GhaW zTx_4nDf3G*{e1BL+0pOKoQuAY4f*1({A*B+`2XzdH`=q396AQ_#j(#mvu9g=fB^aH F{{W4~?9~7O literal 0 HcmV?d00001 diff --git a/module/folder/folder.php b/module/folder/folder.php index d3430759..9d1acd62 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -183,7 +183,7 @@ class folder extends common private function formatSizeUnits($bytes) { - $units = array('octest', 'Ko', 'Mo', 'Go', 'To'); + $units = array('octets', 'Ko', 'Mo', 'Go', 'To'); $i = 0; while ($bytes >= 1024) { $bytes /= 1024; From e811660d7cc99d69076637d405e4eda24f364f51 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 12:53:04 +0100 Subject: [PATCH 10/18] =?UTF-8?q?13.1.08=20mise=C3=A0=20jour=20automatis?= =?UTF-8?q?=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 1 + core/module/config/tool/autobackup.php | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 core/module/config/tool/autobackup.php diff --git a/CHANGES.md b/CHANGES.md index 0e6fa285..52d90e08 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ ### Amélioration - Sauvegarde de l'état des sélecteurs dans les tables des fontes et des utilisateurs. +- Fournit un outil de mise à jour automatisé. ## Version 13.1.07 diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php new file mode 100644 index 00000000..0b919a85 --- /dev/null +++ b/core/module/config/tool/autobackup.php @@ -0,0 +1,26 @@ +open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); +$directory = '../../../../site'; +$files = new RecursiveIteratorIterator( + new RecursiveCallbackFilterIterator( + new RecursiveDirectoryIterator( + $directory, + RecursiveDirectoryIterator::SKIP_DOTS + ), + function ($fileInfo, $key, $iterator) use ($filter) { + return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); + } + ) +); +foreach ($files as $name => $file) { + if (!$file->isDir()) { + $filePath = $file->getRealPath(); + $relativePath = substr($filePath, strlen(realpath($directory)) + 1); + $zip->addFile($filePath, $relativePath); + } +} +$zip->close(); \ No newline at end of file From 5f5815cbd950b9c555a7911515145f41977ac00a Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 20:49:15 +0100 Subject: [PATCH 11/18] clean auto backup --- core/module/config/tool/cleanautobackup.php | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 core/module/config/tool/cleanautobackup.php diff --git a/core/module/config/tool/cleanautobackup.php b/core/module/config/tool/cleanautobackup.php new file mode 100644 index 00000000..732ac562 --- /dev/null +++ b/core/module/config/tool/cleanautobackup.php @@ -0,0 +1,22 @@ +isFile() && $file->getExtension() === 'tar.gz') { + // Vérifie si le fichier a été modifié avant la limite de temps + if ($file->getMTime() < $timeLimit) { + // Supprime le fichier + unlink($file->getRealPath()); + } + } +} +?> From a47cbe49fe9ebe7b47abb365d7bf447e7dfb442b Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 17 Mar 2024 21:09:37 +0100 Subject: [PATCH 12/18] =?UTF-8?q?D=C3=A9bordements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/folder/folder.php | 2 +- module/folder/view/index/index.css | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/module/folder/folder.php b/module/folder/folder.php index 9d1acd62..7c959b3b 100644 --- a/module/folder/folder.php +++ b/module/folder/folder.php @@ -165,7 +165,7 @@ class folder extends common $fileSizeFormatted = $this->formatSizeUnits($fileSize); $fileInfo = "
" . date("d-m-Y H:i", filemtime($fileFullPath)) . " - $fileSizeFormatted
"; } - $items .= "
  • $file$fileInfo
  • "; + $items .= "
  • $file
    $fileInfo
  • "; } // Fermer la liste diff --git a/module/folder/view/index/index.css b/module/folder/view/index/index.css index 8c570d35..b8499eda 100644 --- a/module/folder/view/index/index.css +++ b/module/folder/view/index/index.css @@ -63,3 +63,10 @@ /* Ajout d'une largeur fixe à la div */ width: 200px; } + +.file-name { + max-width: 400px; /* Largeur maximale du nom de fichier */ + white-space: nowrap; /* Empêcher le débordement du texte à la ligne suivante */ + overflow: hidden; /* Cacher tout texte qui dépasse */ + text-overflow: ellipsis; /* Ajouter des points de suspension (...) pour indiquer que le texte a été tronqué */ +} \ No newline at end of file From c4a23de7448f13cf72c2f228f945af96c3c7669c Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 18 Mar 2024 08:42:36 +0100 Subject: [PATCH 13/18] =?UTF-8?q?Contr=C3=B4le=20de=20cl=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/config/tool/.htaccess | 4 +++ core/module/config/tool/autobackup.php | 28 ++++++++++++++++++--- core/module/config/tool/cleanautobackup.php | 28 +++++++++++++++++++++ core/module/config/tool/data.key | 1 + 4 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 core/module/config/tool/.htaccess create mode 100644 core/module/config/tool/data.key diff --git a/core/module/config/tool/.htaccess b/core/module/config/tool/.htaccess new file mode 100644 index 00000000..a5decbff --- /dev/null +++ b/core/module/config/tool/.htaccess @@ -0,0 +1,4 @@ + + Order Allow,Deny + Deny from all + diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php index 0b919a85..26503f50 100644 --- a/core/module/config/tool/autobackup.php +++ b/core/module/config/tool/autobackup.php @@ -1,6 +1,28 @@ open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); @@ -23,4 +45,4 @@ foreach ($files as $name => $file) { $zip->addFile($filePath, $relativePath); } } -$zip->close(); \ No newline at end of file +$zip->close(); diff --git a/core/module/config/tool/cleanautobackup.php b/core/module/config/tool/cleanautobackup.php index 732ac562..a97d38ef 100644 --- a/core/module/config/tool/cleanautobackup.php +++ b/core/module/config/tool/cleanautobackup.php @@ -1,4 +1,32 @@ Date: Mon, 18 Mar 2024 08:51:51 +0100 Subject: [PATCH 14/18] change key --- core/module/config/tool/data.key | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/module/config/tool/data.key b/core/module/config/tool/data.key index 40776184..e404799e 100644 --- a/core/module/config/tool/data.key +++ b/core/module/config/tool/data.key @@ -1 +1 @@ -nokXpczxvrc8hg \ No newline at end of file +saisirunecle \ No newline at end of file From 11753b44761b06c32a7418bc13d533658409dab6 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 18 Mar 2024 17:30:35 +0100 Subject: [PATCH 15/18] add data.key to git ignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 578c3da9..1c959d05 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ site/i18n/*.json core/vendor/tinymce/link_list.json robots.txt sitemap.xml -.gitignore \ No newline at end of file +.gitignore +core/module/config/tool/data.key \ No newline at end of file From 2cbd3d5923ec613f47af8ca3eee885da15dd8249 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 18 Mar 2024 17:40:56 +0100 Subject: [PATCH 16/18] Update rolling backup --- core/module/config/tool/autobackup.php | 56 ++++++++++----------- core/module/config/tool/cleanautobackup.php | 42 ++++++++-------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php index 26503f50..bb1e1fa4 100644 --- a/core/module/config/tool/autobackup.php +++ b/core/module/config/tool/autobackup.php @@ -11,38 +11,38 @@ La clé doit être fournie en tant que paramètre "key" dans l'URL et correspond */ // Vérification de la clé -if (isset($_GET['key'])) { +if (isset ($_GET['key'])) { $key = $_GET['key']; $storedKey = file_get_contents('data.key'); if ($key !== $storedKey) { - die("Clé invalide !"); + http_response_code(401); + exit(); } } else { - die("Clé manquante !"); -} - -// Création du ZIP -$filter = ['backup', 'tmp']; -$fileName = date('Y-m-d-H-i-s', time()) . '-rolling-backup.zip'; -$zip = new ZipArchive(); -$zip->open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); -$directory = '../../../../site'; -$files = new RecursiveIteratorIterator( - new RecursiveCallbackFilterIterator( - new RecursiveDirectoryIterator( - $directory, - RecursiveDirectoryIterator::SKIP_DOTS - ), - function ($fileInfo, $key, $iterator) use ($filter) { - return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); + // Création du ZIP + $filter = ['backup', 'tmp']; + $fileName = date('Y-m-d-H-i-s', time()) . '-rolling-backup.zip'; + $zip = new ZipArchive(); + $zip->open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); + $directory = '../../../../site'; + $files = new RecursiveIteratorIterator( + new RecursiveCallbackFilterIterator( + new RecursiveDirectoryIterator( + $directory, + RecursiveDirectoryIterator::SKIP_DOTS + ), + function ($fileInfo, $key, $iterator) use ($filter) { + return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); + } + ) + ); + foreach ($files as $name => $file) { + if (!$file->isDir()) { + $filePath = $file->getRealPath(); + $relativePath = substr($filePath, strlen(realpath($directory)) + 1); + $zip->addFile($filePath, $relativePath); } - ) -); -foreach ($files as $name => $file) { - if (!$file->isDir()) { - $filePath = $file->getRealPath(); - $relativePath = substr($filePath, strlen(realpath($directory)) + 1); - $zip->addFile($filePath, $relativePath); } -} -$zip->close(); + $zip->close(); + http_response_code(201); +} \ No newline at end of file diff --git a/core/module/config/tool/cleanautobackup.php b/core/module/config/tool/cleanautobackup.php index a97d38ef..c18800b9 100644 --- a/core/module/config/tool/cleanautobackup.php +++ b/core/module/config/tool/cleanautobackup.php @@ -11,7 +11,7 @@ Le script vérifie également la présence et la validité d'une clé spécifiqu */ // Vérification de la clé -if (isset($_GET['key'])) { +if (isset ($_GET['key'])) { // Récupération de la clé fournie en GET $key = $_GET['key']; @@ -20,31 +20,31 @@ if (isset($_GET['key'])) { // Vérification de correspondance entre les clés if ($key !== $storedKey) { - die("Clé invalide !"); + http_response_code(401); + exit(); } } else { - // Si la clé est manquante, affiche un message d'erreur et arrête l'exécution du script - die("Clé manquante !"); -} -// Récupère le nombre de jours à partir de la variable GET 'days' -$days = isset($_GET['days']) ? (int)$_GET['days'] : 1; // Par défaut à 1 si non spécifié + // Récupère le nombre de jours à partir de la variable GET 'days' + $days = isset ($_GET['days']) ? (int) $_GET['days'] : 1; // Par défaut à 1 si non spécifié -// Chemin vers le répertoire contenant les fichiers -$directory = '../../../../site/backup/'; // Remplacez par le chemin réel + // Chemin vers le répertoire contenant les fichiers + $directory = '../../../../site/backup/'; // Remplacez par le chemin réel -// Convertit le nombre de jours en secondes -$timeLimit = strtotime("-$days days"); + // Convertit le nombre de jours en secondes + $timeLimit = strtotime("-$days days"); -// Crée un nouvel objet DirectoryIterator -foreach (new DirectoryIterator($directory) as $file) { - // Vérifie si l'élément courant est un fichier et a l'extension 'tar.gz' - if ($file->isFile() && $file->getExtension() === 'tar.gz') { - // Vérifie si le fichier a été modifié avant la limite de temps - if ($file->getMTime() < $timeLimit) { - // Supprime le fichier - unlink($file->getRealPath()); + // Crée un nouvel objet DirectoryIterator + foreach (new DirectoryIterator($directory) as $file) { + // Vérifie si l'élément courant est un fichier et a l'extension 'tar.gz' + if ($file->isFile() && $file->getExtension() === 'tar.gz') { + // Vérifie si le fichier a été modifié avant la limite de temps + if ($file->getMTime() < $timeLimit) { + // Supprime le fichier + unlink($file->getRealPath()); + } } } -} -?> + // Si la clé est manquante, affiche un message d'erreur et arrête l'exécution du script + http_response_code(201); +} \ No newline at end of file From 1147b5c5e1fff513cea77da6c0db5a7d2fa3b8a5 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 18 Mar 2024 17:50:54 +0100 Subject: [PATCH 17/18] update roling backup --- core/module/config/tool/autobackup.php | 1 - core/module/config/tool/cleanautobackup.php | 1 - 2 files changed, 2 deletions(-) diff --git a/core/module/config/tool/autobackup.php b/core/module/config/tool/autobackup.php index bb1e1fa4..52166257 100644 --- a/core/module/config/tool/autobackup.php +++ b/core/module/config/tool/autobackup.php @@ -18,7 +18,6 @@ if (isset ($_GET['key'])) { http_response_code(401); exit(); } -} else { // Création du ZIP $filter = ['backup', 'tmp']; $fileName = date('Y-m-d-H-i-s', time()) . '-rolling-backup.zip'; diff --git a/core/module/config/tool/cleanautobackup.php b/core/module/config/tool/cleanautobackup.php index c18800b9..f0144d10 100644 --- a/core/module/config/tool/cleanautobackup.php +++ b/core/module/config/tool/cleanautobackup.php @@ -23,7 +23,6 @@ if (isset ($_GET['key'])) { http_response_code(401); exit(); } -} else { // Récupère le nombre de jours à partir de la variable GET 'days' $days = isset ($_GET['days']) ? (int) $_GET['days'] : 1; // Par défaut à 1 si non spécifié From fd511229181cca42029257d29b0407e5ca598dc9 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 21 Mar 2024 13:26:42 +0100 Subject: [PATCH 18/18] =?UTF-8?q?Mise=20=C3=A0=20jour=20RSS=20Feed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/blog/blog.php | 2 +- module/blog/changes.md | 2 + module/blog/vendor/FeedWriter/CHANGELOG.md | 74 ++++++++++++++++++++++ module/blog/vendor/FeedWriter/Feed.php | 39 ++++++++---- module/blog/vendor/FeedWriter/Item.php | 16 +++-- module/blog/vendor/FeedWriter/README.md | 8 +++ module/news/changes.md | 2 + module/news/news.php | 2 +- module/news/vendor/FeedWriter/CHANGELOG.md | 74 ++++++++++++++++++++++ module/news/vendor/FeedWriter/Feed.php | 39 ++++++++---- module/news/vendor/FeedWriter/Item.php | 16 +++-- module/news/vendor/FeedWriter/README.md | 8 +++ 12 files changed, 244 insertions(+), 38 deletions(-) create mode 100644 module/blog/vendor/FeedWriter/CHANGELOG.md create mode 100644 module/news/vendor/FeedWriter/CHANGELOG.md diff --git a/module/blog/blog.php b/module/blog/blog.php index 0cbc3da5..479721fe 100755 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -16,7 +16,7 @@ class blog extends common { - const VERSION = '7.5'; + const VERSION = '7.6'; const REALNAME = 'Blog'; const DELETE = true; const UPDATE = '0.0'; diff --git a/module/blog/changes.md b/module/blog/changes.md index 73c72c89..d5e5fa92 100755 --- a/module/blog/changes.md +++ b/module/blog/changes.md @@ -1,3 +1,5 @@ +# Version 7.6 +- Mise à jour RSS Feed # Version 7.5 - Bug paramètre de localisation erroné # Version 7.4 diff --git a/module/blog/vendor/FeedWriter/CHANGELOG.md b/module/blog/vendor/FeedWriter/CHANGELOG.md new file mode 100644 index 00000000..a5286c48 --- /dev/null +++ b/module/blog/vendor/FeedWriter/CHANGELOG.md @@ -0,0 +1,74 @@ +# Change Log +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) . + +## [v1.1.2] - 2023-05-25 +### Changed +- Throw an exception if required feed elements are set with ```NULL``` value. See issue #46. + +## [v1.1.1] - 2016-11-19 +### Changed +- Improved the documentation. +- Changed to PSR-4 autoloader in composer.json. + +### Fixed +- Item::addElement did not method chain in error conditions. + +## [v1.1.0] - 2016-11-08 +### Added +- Support for multiple element values. +- Support for a feed description in ATOM feeds. +- Support for ATOM feeds without ```link``` elements. +- Support for a feed image in RSS 1.0 and ATOM feeds. + +### Changed +- The script does now throw Exceptions instead of stopping the PHP interpreter on error conditions. +- The unique identifier for ATOM feeds / entries use the feed / entry title for generating the ID (previously the feed / entry link). +- Some URI schemes for ```Item::setId``` were wrongly allowed. +- The parameter order of the ```Feed::setImage``` method was changed. + +### Fixed +- Fixed slow generation of the feed with huge amounts of feed entries (like 40k entries). +- Fixed PHP warning when ```Feed::setChannelAbout``` for RSS 1.0 feeds was not called. +- A feed element was generated twice if the element content & attribute value was ```NULL```. +- The detection of twice the same link with ```rel=alternate```, ```hreflang``` & ```type``` did not work. + +### Removed +- The deprecated method ```Item::setEnclosure``` was removed. Use ```Item::addEnclosure``` instead. + +## [v1.0.4] - 2016-04-17 +### Changed +- The unique identifier for ATOM feed entries is now compliant to the ATOM standard. + +### Fixed +- Filter more invalid XML chars. +- Fixed a PHP warning displayed if ```Feed::setTitle``` or ```Feed::setLink``` was not called. + +## [v1.0.3] - 2015-11-11 +### Added +- Method for removing tags which were CDATA encoded. + +### Fixed +- Fixed error when the filtering of invalid XML chars failed. +- Fixed missing docblock documentation. + +## [v1.0.2] - 2015-01-23 +### Fixed +- Fixed a wrong docblock return data type. + +## [v1.0.1] - 2014-09-21 +### Fixed +- Filter invalid XML chars. + +## v1.0 - 2014-09-14 + + +[Unreleased]: https://github.com/mibe/FeedWriter/compare/v1.1.2...HEAD +[v1.1.2]: https://github.com/mibe/FeedWriter/compare/v1.1.1...v1.1.2 +[v1.1.1]: https://github.com/mibe/FeedWriter/compare/v1.1.0...v1.1.1 +[v1.1.0]: https://github.com/mibe/FeedWriter/compare/v1.0.4...v1.1.0 +[v1.0.4]: https://github.com/mibe/FeedWriter/compare/v1.0.3...v1.0.4 +[v1.0.3]: https://github.com/mibe/FeedWriter/compare/v1.0.2...v1.0.3 +[v1.0.2]: https://github.com/mibe/FeedWriter/compare/v1.0.1...v1.0.2 +[v1.0.1]: https://github.com/mibe/FeedWriter/compare/v1.0...v1.0.1 diff --git a/module/blog/vendor/FeedWriter/Feed.php b/module/blog/vendor/FeedWriter/Feed.php index 9e0650a8..63295325 100755 --- a/module/blog/vendor/FeedWriter/Feed.php +++ b/module/blog/vendor/FeedWriter/Feed.php @@ -2,10 +2,11 @@ namespace FeedWriter; use \DateTime; +use \DateTimeInterface; /* * Copyright (C) 2008 Anis uddin Ahmad - * Copyright (C) 2010-2016 Michael Bemmerl + * Copyright (C) 2010-2016, 2022 Michael Bemmerl * * This file is part of the "Universal Feed Writer" project. * @@ -76,6 +77,13 @@ abstract class Feed */ private $version = null; + /** + * Contains the encoding of this feed. + * + * @var string + */ + private $encoding = 'utf-8'; + /** * Constructor * @@ -87,9 +95,6 @@ abstract class Feed { $this->version = $version; - // Setting default encoding - $this->encoding = 'utf-8'; - // Setting default value for essential channel element $this->setTitle($version . ' Feed'); @@ -396,9 +401,13 @@ abstract class Feed * @access public * @param string $title value of 'title' channel tag * @return self + * @throws \InvalidArgumentException if the title is empty or NULL. */ public function setTitle($title) { + if (empty($title)) + throw new \InvalidArgumentException('The title may not be empty or NULL.'); + return $this->setChannelElement('title', $title); } @@ -406,15 +415,15 @@ abstract class Feed * Set the date when the feed was lastly updated. * * This adds the 'updated' element to the feed. The value of the date parameter - * can be either an instance of the DateTime class, an integer containing a UNIX + * can be either a class implementing DateTimeInterface, an integer containing a UNIX * timestamp or a string which is parseable by PHP's 'strtotime' function. * * Not supported in RSS1 feeds. * * @access public - * @param DateTime|int|string Date which should be used. + * @param DateTimeInterface|int|string Date which should be used. * @return self - * @throws \InvalidArgumentException if the given date is not an instance of DateTime, a UNIX timestamp or a date string. + * @throws \InvalidArgumentException if the given date is not an implementation of DateTimeInterface, a UNIX timestamp or a date string. * @throws InvalidOperationException if this method is called on an RSS1 feed. */ public function setDate($date) @@ -425,7 +434,7 @@ abstract class Feed // The feeds have different date formats. $format = $this->version == Feed::ATOM ? \DATE_ATOM : \DATE_RSS; - if ($date instanceof DateTime) + if ($date instanceof DateTimeInterface || $date instanceof DateTime) $date = $date->format($format); else if(is_numeric($date) && $date >= 0) $date = date($format, $date); @@ -438,7 +447,7 @@ abstract class Feed $date = date($format, $timestamp); } else - throw new \InvalidArgumentException('The given date is not an instance of DateTime, a UNIX timestamp or a date string.'); + throw new \InvalidArgumentException('The given date is not an implementation of DateTimeInterface, a UNIX timestamp or a date string.'); if ($this->version == Feed::ATOM) $this->setChannelElement('updated', $date); @@ -454,9 +463,13 @@ abstract class Feed * @access public * @param string $description Description of the feed. * @return self + * @throws \InvalidArgumentException if the description is empty or NULL. */ public function setDescription($description) { + if (empty($description)) + throw new \InvalidArgumentException('The description may not be empty or NULL.'); + if ($this->version != Feed::ATOM) $this->setChannelElement('description', $description); else @@ -471,9 +484,13 @@ abstract class Feed * @access public * @param string $link value of 'link' channel tag * @return self + * @throws \InvalidArgumentException if the link is empty or NULL. */ public function setLink($link) { + if (empty($link)) + throw new \InvalidArgumentException('The link may not be empty or NULL.'); + if ($this->version == Feed::ATOM) $this->setAtomLink($link); else @@ -667,7 +684,7 @@ abstract class Feed /** * Replace invalid XML characters. * - * @link http://www.phpwact.org/php/i18n/charsets#xml See utf8_for_xml() function + * @link https://web.archive.org/web/20160608013721/http://www.phpwact.org:80/php/i18n/charsets#xml See utf8_for_xml() function * @link http://www.w3.org/TR/REC-xml/#charsets * @link https://github.com/mibe/FeedWriter/issues/30 * @@ -906,7 +923,7 @@ abstract class Feed $out .= "" . PHP_EOL . "" . PHP_EOL . "" . PHP_EOL; // An image has its own element after the channel elements. - if (array_key_exists('image', $this->data)) + if (array_key_exists('Image', $this->data)) $out .= $this->makeNode('image', $this->data['Image'], array('rdf:about' => $this->data['Image']['url'])); } else if ($this->version == Feed::ATOM) { // ATOM feeds have a unique feed ID. Use the title channel element as key. diff --git a/module/blog/vendor/FeedWriter/Item.php b/module/blog/vendor/FeedWriter/Item.php index 695afe41..5e2049ea 100755 --- a/module/blog/vendor/FeedWriter/Item.php +++ b/module/blog/vendor/FeedWriter/Item.php @@ -2,6 +2,7 @@ namespace FeedWriter; use \DateTime; +use \DateTimeInterface; /* * Copyright (C) 2008 Anis uddin Ahmad @@ -217,19 +218,19 @@ class Item /** * Set the 'date' element of the feed item. * - * The value of the date parameter can be either an instance of the - * DateTime class, an integer containing a UNIX timestamp or a string + * The value of the date parameter can be either a class implementing + * DateTimeInterface, an integer containing a UNIX timestamp or a string * which is parseable by PHP's 'strtotime' function. * * @access public - * @param DateTime|int|string $date Date which should be used. + * @param DateTimeInterface|int|string $date Date which should be used. * @return self * @throws \InvalidArgumentException if the given date was not parseable. */ public function setDate($date) { if (!is_numeric($date)) { - if ($date instanceof DateTime) + if ($date instanceof DateTimeInterface || $date instanceof DateTime) $date = $date->getTimestamp(); else { $date = strtotime($date); @@ -277,7 +278,7 @@ class Item * Attach a external media to the feed item. * Not supported in RSS 1.0 feeds. * - * See RFC 4288 for syntactical correct MIME types. + * See RFC 6838 for syntactical correct MIME types. * * Note that you should avoid the use of more than one enclosure in one item, * since some RSS aggregators don't support it. @@ -288,7 +289,8 @@ class Item * @param string $type The MIME type attribute of the media. * @param boolean $multiple Specifies if multiple enclosures are allowed * @return self - * @link https://tools.ietf.org/html/rfc4288 + * @link https://tools.ietf.org/html/rfc6838 + * @link http://www.iana.org/assignments/media-types/media-types.xhtml * @throws \InvalidArgumentException if the length or type parameter is invalid. * @throws InvalidOperationException if this method is called on RSS1 feeds. */ @@ -389,7 +391,7 @@ class Item // Check if the given ID is an valid URI scheme (see RFC 4287 4.2.6) // The list of valid schemes was generated from http://www.iana.org/assignments/uri-schemes // by using only permanent or historical schemes. - $validSchemes = array('aaa', 'aaas', 'about', 'acap', 'acct', 'cap', 'cid', 'coap', 'coaps', 'crid', 'data', 'dav', 'dict', 'dns', 'example', 'fax', 'file', 'filesystem', 'ftp', 'geo', 'go', 'gopher', 'h323', 'http', 'https', 'iax', 'icap', 'im', 'imap', 'info', 'ipp', 'ipps', 'iris', 'iris.beep', 'iris.lwz', 'iris.xpc', 'iris.xpcs', 'jabber', 'ldap', 'mailserver', 'mailto', 'mid', 'modem', 'msrp', 'msrps', 'mtqp', 'mupdate', 'news', 'nfs', 'ni', 'nih', 'nntp', 'opaquelocktoken', 'pack', 'pkcs11', 'pop', 'pres', 'prospero', 'reload', 'rtsp', 'rtsps', 'rtspu', 'service', 'session', 'shttp', 'sieve', 'sip', 'sips', 'sms', 'snews', 'snmp', 'soap.beep', 'soap.beeps', 'stun', 'stuns', 'tag', 'tel', 'telnet', 'tftp', 'thismessage', 'tip', 'tn3270', 'turn', 'turns', 'tv', 'urn', 'vemmi', 'videotex', 'vnc', 'wais', 'ws', 'wss', 'xcon', 'xcon-userid', 'xmlrpc.beep', 'xmlrpc.beeps', 'xmpp', 'z39.50', 'z39.50r', 'z39.50s'); + $validSchemes = array('aaa', 'aaas', 'about', 'acap', 'acct', 'bb', 'cap', 'cid', 'coap', 'coap+tcp', 'coap+ws', 'coaps', 'coaps+tcp', 'coaps+ws', 'crid', 'data', 'dav', 'dict', 'dns', 'drop', 'dtn', 'example', 'fax', 'file', 'filesystem', 'ftp', 'geo', 'go', 'gopher', 'grd', 'h323', 'http', 'https', 'iax', 'icap', 'im', 'imap', 'info', 'ipn', 'ipp', 'ipps', 'iris', 'iris.beep', 'iris.lwz', 'iris.xpc', 'iris.xpcs', 'jabber', 'ldap', 'leaptofrogans', 'mailserver', 'mailto', 'mid', 'modem', 'msrp', 'msrps', 'mt', 'mtqp', 'mupdate', 'news', 'nfs', 'ni', 'nih', 'nntp', 'opaquelocktoken', 'p1', 'pack', 'pkcs11', 'pop', 'pres', 'prospero', 'reload', 'rtsp', 'rtsps', 'rtspu', 'service', 'session', 'shttp (OBSOLETE)', 'sieve', 'sip', 'sips', 'sms', 'snews', 'snmp', 'soap.beep', 'soap.beeps', 'stun', 'stuns', 'tag', 'tel', 'telnet', 'tftp', 'thismessage', 'tip', 'tn3270', 'turn', 'turns', 'tv', 'upt', 'urn', 'vemmi', 'videotex', 'vnc', 'wais', 'wpid', 'ws', 'wss', 'xcon', 'xcon-userid', 'xmlrpc.beep', 'xmlrpc.beeps', 'xmpp', 'z39.50', 'z39.50r', 'z39.50s'); $found = FALSE; $checkId = strtolower($id); diff --git a/module/blog/vendor/FeedWriter/README.md b/module/blog/vendor/FeedWriter/README.md index f630af99..29744f43 100755 --- a/module/blog/vendor/FeedWriter/README.md +++ b/module/blog/vendor/FeedWriter/README.md @@ -12,6 +12,11 @@ Once a feed is fully composed with its items, the feed class can generate the ne If you don't have **PHP 5.3** available on your system there is a version supporting **PHP 5.0** and above. See the `legacy-php-5.0` branch. +## Installation +You can install via [Composer](https://getcomposer.org/). + + composer require mibe/feedwriter + ## Documentation The documentation can be found in the `gh-pages` branch, or on [GitHub Pages](https://mibe.github.io/FeedWriter/). @@ -40,3 +45,6 @@ In chronological order: - Pavel Khakhlou - Daniel - Tino Goratsch +- John +- Özgür Görgülü +- Jan Tojnar diff --git a/module/news/changes.md b/module/news/changes.md index 428123d7..99f691bb 100644 --- a/module/news/changes.md +++ b/module/news/changes.md @@ -1,3 +1,5 @@ +# Version 5.5 +- Mise à jour RSS Feed # Version 5.4 - Bug paramètre de localisation erroné # Version 5.3 diff --git a/module/news/news.php b/module/news/news.php index f4f6f1f1..0d2c6ea7 100644 --- a/module/news/news.php +++ b/module/news/news.php @@ -16,7 +16,7 @@ class news extends common { - const VERSION = '5.4'; + const VERSION = '5.5'; const REALNAME = 'News'; const DATADIRECTORY = self::DATA_DIR . 'news/'; diff --git a/module/news/vendor/FeedWriter/CHANGELOG.md b/module/news/vendor/FeedWriter/CHANGELOG.md new file mode 100644 index 00000000..a5286c48 --- /dev/null +++ b/module/news/vendor/FeedWriter/CHANGELOG.md @@ -0,0 +1,74 @@ +# Change Log +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) . + +## [v1.1.2] - 2023-05-25 +### Changed +- Throw an exception if required feed elements are set with ```NULL``` value. See issue #46. + +## [v1.1.1] - 2016-11-19 +### Changed +- Improved the documentation. +- Changed to PSR-4 autoloader in composer.json. + +### Fixed +- Item::addElement did not method chain in error conditions. + +## [v1.1.0] - 2016-11-08 +### Added +- Support for multiple element values. +- Support for a feed description in ATOM feeds. +- Support for ATOM feeds without ```link``` elements. +- Support for a feed image in RSS 1.0 and ATOM feeds. + +### Changed +- The script does now throw Exceptions instead of stopping the PHP interpreter on error conditions. +- The unique identifier for ATOM feeds / entries use the feed / entry title for generating the ID (previously the feed / entry link). +- Some URI schemes for ```Item::setId``` were wrongly allowed. +- The parameter order of the ```Feed::setImage``` method was changed. + +### Fixed +- Fixed slow generation of the feed with huge amounts of feed entries (like 40k entries). +- Fixed PHP warning when ```Feed::setChannelAbout``` for RSS 1.0 feeds was not called. +- A feed element was generated twice if the element content & attribute value was ```NULL```. +- The detection of twice the same link with ```rel=alternate```, ```hreflang``` & ```type``` did not work. + +### Removed +- The deprecated method ```Item::setEnclosure``` was removed. Use ```Item::addEnclosure``` instead. + +## [v1.0.4] - 2016-04-17 +### Changed +- The unique identifier for ATOM feed entries is now compliant to the ATOM standard. + +### Fixed +- Filter more invalid XML chars. +- Fixed a PHP warning displayed if ```Feed::setTitle``` or ```Feed::setLink``` was not called. + +## [v1.0.3] - 2015-11-11 +### Added +- Method for removing tags which were CDATA encoded. + +### Fixed +- Fixed error when the filtering of invalid XML chars failed. +- Fixed missing docblock documentation. + +## [v1.0.2] - 2015-01-23 +### Fixed +- Fixed a wrong docblock return data type. + +## [v1.0.1] - 2014-09-21 +### Fixed +- Filter invalid XML chars. + +## v1.0 - 2014-09-14 + + +[Unreleased]: https://github.com/mibe/FeedWriter/compare/v1.1.2...HEAD +[v1.1.2]: https://github.com/mibe/FeedWriter/compare/v1.1.1...v1.1.2 +[v1.1.1]: https://github.com/mibe/FeedWriter/compare/v1.1.0...v1.1.1 +[v1.1.0]: https://github.com/mibe/FeedWriter/compare/v1.0.4...v1.1.0 +[v1.0.4]: https://github.com/mibe/FeedWriter/compare/v1.0.3...v1.0.4 +[v1.0.3]: https://github.com/mibe/FeedWriter/compare/v1.0.2...v1.0.3 +[v1.0.2]: https://github.com/mibe/FeedWriter/compare/v1.0.1...v1.0.2 +[v1.0.1]: https://github.com/mibe/FeedWriter/compare/v1.0...v1.0.1 diff --git a/module/news/vendor/FeedWriter/Feed.php b/module/news/vendor/FeedWriter/Feed.php index 9e0650a8..63295325 100644 --- a/module/news/vendor/FeedWriter/Feed.php +++ b/module/news/vendor/FeedWriter/Feed.php @@ -2,10 +2,11 @@ namespace FeedWriter; use \DateTime; +use \DateTimeInterface; /* * Copyright (C) 2008 Anis uddin Ahmad - * Copyright (C) 2010-2016 Michael Bemmerl + * Copyright (C) 2010-2016, 2022 Michael Bemmerl * * This file is part of the "Universal Feed Writer" project. * @@ -76,6 +77,13 @@ abstract class Feed */ private $version = null; + /** + * Contains the encoding of this feed. + * + * @var string + */ + private $encoding = 'utf-8'; + /** * Constructor * @@ -87,9 +95,6 @@ abstract class Feed { $this->version = $version; - // Setting default encoding - $this->encoding = 'utf-8'; - // Setting default value for essential channel element $this->setTitle($version . ' Feed'); @@ -396,9 +401,13 @@ abstract class Feed * @access public * @param string $title value of 'title' channel tag * @return self + * @throws \InvalidArgumentException if the title is empty or NULL. */ public function setTitle($title) { + if (empty($title)) + throw new \InvalidArgumentException('The title may not be empty or NULL.'); + return $this->setChannelElement('title', $title); } @@ -406,15 +415,15 @@ abstract class Feed * Set the date when the feed was lastly updated. * * This adds the 'updated' element to the feed. The value of the date parameter - * can be either an instance of the DateTime class, an integer containing a UNIX + * can be either a class implementing DateTimeInterface, an integer containing a UNIX * timestamp or a string which is parseable by PHP's 'strtotime' function. * * Not supported in RSS1 feeds. * * @access public - * @param DateTime|int|string Date which should be used. + * @param DateTimeInterface|int|string Date which should be used. * @return self - * @throws \InvalidArgumentException if the given date is not an instance of DateTime, a UNIX timestamp or a date string. + * @throws \InvalidArgumentException if the given date is not an implementation of DateTimeInterface, a UNIX timestamp or a date string. * @throws InvalidOperationException if this method is called on an RSS1 feed. */ public function setDate($date) @@ -425,7 +434,7 @@ abstract class Feed // The feeds have different date formats. $format = $this->version == Feed::ATOM ? \DATE_ATOM : \DATE_RSS; - if ($date instanceof DateTime) + if ($date instanceof DateTimeInterface || $date instanceof DateTime) $date = $date->format($format); else if(is_numeric($date) && $date >= 0) $date = date($format, $date); @@ -438,7 +447,7 @@ abstract class Feed $date = date($format, $timestamp); } else - throw new \InvalidArgumentException('The given date is not an instance of DateTime, a UNIX timestamp or a date string.'); + throw new \InvalidArgumentException('The given date is not an implementation of DateTimeInterface, a UNIX timestamp or a date string.'); if ($this->version == Feed::ATOM) $this->setChannelElement('updated', $date); @@ -454,9 +463,13 @@ abstract class Feed * @access public * @param string $description Description of the feed. * @return self + * @throws \InvalidArgumentException if the description is empty or NULL. */ public function setDescription($description) { + if (empty($description)) + throw new \InvalidArgumentException('The description may not be empty or NULL.'); + if ($this->version != Feed::ATOM) $this->setChannelElement('description', $description); else @@ -471,9 +484,13 @@ abstract class Feed * @access public * @param string $link value of 'link' channel tag * @return self + * @throws \InvalidArgumentException if the link is empty or NULL. */ public function setLink($link) { + if (empty($link)) + throw new \InvalidArgumentException('The link may not be empty or NULL.'); + if ($this->version == Feed::ATOM) $this->setAtomLink($link); else @@ -667,7 +684,7 @@ abstract class Feed /** * Replace invalid XML characters. * - * @link http://www.phpwact.org/php/i18n/charsets#xml See utf8_for_xml() function + * @link https://web.archive.org/web/20160608013721/http://www.phpwact.org:80/php/i18n/charsets#xml See utf8_for_xml() function * @link http://www.w3.org/TR/REC-xml/#charsets * @link https://github.com/mibe/FeedWriter/issues/30 * @@ -906,7 +923,7 @@ abstract class Feed $out .= "" . PHP_EOL . "" . PHP_EOL . "" . PHP_EOL; // An image has its own element after the channel elements. - if (array_key_exists('image', $this->data)) + if (array_key_exists('Image', $this->data)) $out .= $this->makeNode('image', $this->data['Image'], array('rdf:about' => $this->data['Image']['url'])); } else if ($this->version == Feed::ATOM) { // ATOM feeds have a unique feed ID. Use the title channel element as key. diff --git a/module/news/vendor/FeedWriter/Item.php b/module/news/vendor/FeedWriter/Item.php index 695afe41..5e2049ea 100644 --- a/module/news/vendor/FeedWriter/Item.php +++ b/module/news/vendor/FeedWriter/Item.php @@ -2,6 +2,7 @@ namespace FeedWriter; use \DateTime; +use \DateTimeInterface; /* * Copyright (C) 2008 Anis uddin Ahmad @@ -217,19 +218,19 @@ class Item /** * Set the 'date' element of the feed item. * - * The value of the date parameter can be either an instance of the - * DateTime class, an integer containing a UNIX timestamp or a string + * The value of the date parameter can be either a class implementing + * DateTimeInterface, an integer containing a UNIX timestamp or a string * which is parseable by PHP's 'strtotime' function. * * @access public - * @param DateTime|int|string $date Date which should be used. + * @param DateTimeInterface|int|string $date Date which should be used. * @return self * @throws \InvalidArgumentException if the given date was not parseable. */ public function setDate($date) { if (!is_numeric($date)) { - if ($date instanceof DateTime) + if ($date instanceof DateTimeInterface || $date instanceof DateTime) $date = $date->getTimestamp(); else { $date = strtotime($date); @@ -277,7 +278,7 @@ class Item * Attach a external media to the feed item. * Not supported in RSS 1.0 feeds. * - * See RFC 4288 for syntactical correct MIME types. + * See RFC 6838 for syntactical correct MIME types. * * Note that you should avoid the use of more than one enclosure in one item, * since some RSS aggregators don't support it. @@ -288,7 +289,8 @@ class Item * @param string $type The MIME type attribute of the media. * @param boolean $multiple Specifies if multiple enclosures are allowed * @return self - * @link https://tools.ietf.org/html/rfc4288 + * @link https://tools.ietf.org/html/rfc6838 + * @link http://www.iana.org/assignments/media-types/media-types.xhtml * @throws \InvalidArgumentException if the length or type parameter is invalid. * @throws InvalidOperationException if this method is called on RSS1 feeds. */ @@ -389,7 +391,7 @@ class Item // Check if the given ID is an valid URI scheme (see RFC 4287 4.2.6) // The list of valid schemes was generated from http://www.iana.org/assignments/uri-schemes // by using only permanent or historical schemes. - $validSchemes = array('aaa', 'aaas', 'about', 'acap', 'acct', 'cap', 'cid', 'coap', 'coaps', 'crid', 'data', 'dav', 'dict', 'dns', 'example', 'fax', 'file', 'filesystem', 'ftp', 'geo', 'go', 'gopher', 'h323', 'http', 'https', 'iax', 'icap', 'im', 'imap', 'info', 'ipp', 'ipps', 'iris', 'iris.beep', 'iris.lwz', 'iris.xpc', 'iris.xpcs', 'jabber', 'ldap', 'mailserver', 'mailto', 'mid', 'modem', 'msrp', 'msrps', 'mtqp', 'mupdate', 'news', 'nfs', 'ni', 'nih', 'nntp', 'opaquelocktoken', 'pack', 'pkcs11', 'pop', 'pres', 'prospero', 'reload', 'rtsp', 'rtsps', 'rtspu', 'service', 'session', 'shttp', 'sieve', 'sip', 'sips', 'sms', 'snews', 'snmp', 'soap.beep', 'soap.beeps', 'stun', 'stuns', 'tag', 'tel', 'telnet', 'tftp', 'thismessage', 'tip', 'tn3270', 'turn', 'turns', 'tv', 'urn', 'vemmi', 'videotex', 'vnc', 'wais', 'ws', 'wss', 'xcon', 'xcon-userid', 'xmlrpc.beep', 'xmlrpc.beeps', 'xmpp', 'z39.50', 'z39.50r', 'z39.50s'); + $validSchemes = array('aaa', 'aaas', 'about', 'acap', 'acct', 'bb', 'cap', 'cid', 'coap', 'coap+tcp', 'coap+ws', 'coaps', 'coaps+tcp', 'coaps+ws', 'crid', 'data', 'dav', 'dict', 'dns', 'drop', 'dtn', 'example', 'fax', 'file', 'filesystem', 'ftp', 'geo', 'go', 'gopher', 'grd', 'h323', 'http', 'https', 'iax', 'icap', 'im', 'imap', 'info', 'ipn', 'ipp', 'ipps', 'iris', 'iris.beep', 'iris.lwz', 'iris.xpc', 'iris.xpcs', 'jabber', 'ldap', 'leaptofrogans', 'mailserver', 'mailto', 'mid', 'modem', 'msrp', 'msrps', 'mt', 'mtqp', 'mupdate', 'news', 'nfs', 'ni', 'nih', 'nntp', 'opaquelocktoken', 'p1', 'pack', 'pkcs11', 'pop', 'pres', 'prospero', 'reload', 'rtsp', 'rtsps', 'rtspu', 'service', 'session', 'shttp (OBSOLETE)', 'sieve', 'sip', 'sips', 'sms', 'snews', 'snmp', 'soap.beep', 'soap.beeps', 'stun', 'stuns', 'tag', 'tel', 'telnet', 'tftp', 'thismessage', 'tip', 'tn3270', 'turn', 'turns', 'tv', 'upt', 'urn', 'vemmi', 'videotex', 'vnc', 'wais', 'wpid', 'ws', 'wss', 'xcon', 'xcon-userid', 'xmlrpc.beep', 'xmlrpc.beeps', 'xmpp', 'z39.50', 'z39.50r', 'z39.50s'); $found = FALSE; $checkId = strtolower($id); diff --git a/module/news/vendor/FeedWriter/README.md b/module/news/vendor/FeedWriter/README.md index f630af99..29744f43 100755 --- a/module/news/vendor/FeedWriter/README.md +++ b/module/news/vendor/FeedWriter/README.md @@ -12,6 +12,11 @@ Once a feed is fully composed with its items, the feed class can generate the ne If you don't have **PHP 5.3** available on your system there is a version supporting **PHP 5.0** and above. See the `legacy-php-5.0` branch. +## Installation +You can install via [Composer](https://getcomposer.org/). + + composer require mibe/feedwriter + ## Documentation The documentation can be found in the `gh-pages` branch, or on [GitHub Pages](https://mibe.github.io/FeedWriter/). @@ -40,3 +45,6 @@ In chronological order: - Pavel Khakhlou - Daniel - Tino Goratsch +- John +- Özgür Görgülü +- Jan Tojnar