From 9a28c38adb3585e55caeecd64d2171832a3684e9 Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 2 Mar 2022 04:54:24 +0100 Subject: detection poids max php.ini --- config.php | 22 ++++++++++++++---- controller/backup.php | 4 +++- controller/installation.php | 30 ++++++++++++++++++++++++- data/.htaccess | 1 - data/index.html | 0 lib/.htaccess | 1 - lib/ckeditor5/build/index.html | 0 lib/ckeditor5/build/translations/index.html | 0 lib/ckeditor5/index.html | 0 lib/ckeditor5/src/index.html | 0 lib/htmlawed/.htaccess | 1 + lib/index.html | 0 model/Image.php | 35 +++++++++++++---------------- public/accueil/index.html | 0 public/css/accueil.css | 4 +--- public/css/index.html | 0 public/css/pages_articles_simples.css | 4 ++++ public/fonts/index.html | 0 public/header_images/index.html | 0 public/menu/index.html | 0 view/courriel.php | 2 +- view/pageArticlesSimples.php | 2 +- 22 files changed, 73 insertions(+), 33 deletions(-) delete mode 100644 data/.htaccess create mode 100644 data/index.html delete mode 100644 lib/.htaccess create mode 100644 lib/ckeditor5/build/index.html create mode 100644 lib/ckeditor5/build/translations/index.html create mode 100644 lib/ckeditor5/index.html create mode 100644 lib/ckeditor5/src/index.html create mode 100644 lib/htmlawed/.htaccess create mode 100644 lib/index.html create mode 100644 public/accueil/index.html create mode 100644 public/css/index.html create mode 100644 public/fonts/index.html create mode 100644 public/header_images/index.html create mode 100644 public/menu/index.html diff --git a/config.php b/config.php index 658fc12..946763a 100644 --- a/config.php +++ b/config.php @@ -12,11 +12,25 @@ $imageLibrary = 'imagick'; $archiveFormat = 'zip'; // seul zip est supporté pour l'instant -// taille max des fichiers à adapter au php.ini -$maxWeight = 2000000; - // mode de stockage des données // écrire 'files' ou 'database' $storage = 'files'; // laisser 'files'!! -// l'utilisation d'une BDD n'est pas prévue pour l'instant \ No newline at end of file +// l'utilisation d'une BDD n'est pas prévue pour l'instant + + +// actuellement inutile +// taille max des fichiers dans le php.ini (défaut = 2M) +/*function return_bytes ($size_str) +{ + switch (substr ($size_str, -1)) + { + case 'M': case 'm': return (int)$size_str * 1048576; + case 'K': case 'k': return (int)$size_str * 1024; + case 'G': case 'g': return (int)$size_str * 1073741824; + default: return $size_str; + } +} +$maxWeight = return_bytes(ini_get('upload_max_filesize'));*/ +/*ini_set('upload_max_filesize', '3M'); +echo(ini_get('upload_max_filesize')); die();*/ diff --git a/controller/backup.php b/controller/backup.php index 4fb01ef..1477c55 100644 --- a/controller/backup.php +++ b/controller/backup.php @@ -156,8 +156,10 @@ function restaurer($from) } elseif(isset($_FILES['archive']) && $_FILES['archive']['error'] != 0) { - $message = '

Erreur: Le fichier n\'a pas pu être téléchargé correctement."

'; + $message = '

Erreur: Le fichier n\'a pas pu être téléchargé correctement.
+ Au fait, "upload_max_filesize" dans le php.ini vaut ' . ini_get('upload_max_filesize') . '.

'; } require('view/backup.php'); } + diff --git a/controller/installation.php b/controller/installation.php index bf6826d..7e3863b 100644 --- a/controller/installation.php +++ b/controller/installation.php @@ -52,6 +52,7 @@ function installation() // valeur en octal $droitsDossiers = 0777; // mettre 0755 en production + $droitsFichiers = 0666; if(!file_exists('data') && !mkdir('data')) { @@ -67,6 +68,8 @@ function installation() require('view/backup.php'); exit(); } + touch('data/index.html'); + chmod('data/index.html', $droitsFichiers); $listePages = array('melaine', 'discographie', 'concerts', 'presse', 'ateliers', 'liens', 'peinture', 'archives'); foreach ($listePages as $page) @@ -76,16 +79,31 @@ function installation() mkdir('data/' . $page); chmod('data/' . $page, $droitsDossiers); } + if(!file_exists('data/' . $page . 'index.html')) + { + touch('data/' . $page . '/index.html'); + chmod('data/' . $page . '/index.html', $droitsFichiers); + } if(!file_exists('data/' . $page . '/html')) { mkdir('data/' . $page . '/html'); chmod('data/' . $page . '/html', $droitsDossiers); } + if(!file_exists('data/' . $page . '/html/index.html')) + { + touch('data/' . $page . '/html/index.html'); + chmod('data/' . $page . '/html/index.html', $droitsFichiers); + } if(!file_exists('data/' . $page . '/images')) { mkdir('data/' . $page . '/images'); chmod('data/' . $page . '/images', $droitsDossiers); } + if(!file_exists('data/' . $page . '/images/index.html')) + { + touch('data/' . $page . '/images/index.html'); + chmod('data/' . $page . '/images/index.html', $droitsFichiers); + } // if(!file_exists('data/' . $page . '/multimedia')) // { // mkdir('data/' . $page . '/multimedia'); @@ -98,11 +116,22 @@ function installation() mkdir('data/discographie/json'); chmod('data/discographie/json', $droitsDossiers); } + if(!file_exists('data/discographie/json/index.html')) + { + touch('data/discographie/json/index.html'); + chmod('data/discographie/json/index.html', $droitsFichiers); + } if(!file_exists('data/discographie/images-mini')) { mkdir('data/discographie/images-mini'); chmod('data/discographie/images-mini', $droitsDossiers); } + if(!file_exists('data/discographie/images-mini/index.html')) + { + touch('data/discographie/images-mini/index.html'); + chmod('data/discographie/images-mini/index.html', $droitsFichiers); + } + // le modèle donnera les droits 0666 (octal) aux nouveaux fichiers à l'intérieur des dossiers // créer le melainePHP.zip if(!file_exists("data/melainePHP.zip")) @@ -110,7 +139,6 @@ function installation() require('controller/backup.php'); creerMelainePHP(); } - // le modèle donnera les droits 0666 (octal) aux nouveaux fichiers à l'intérieur des dossiers // création d'un mot de passe si password.txt est vide createPassword(); diff --git a/data/.htaccess b/data/.htaccess deleted file mode 100644 index 45552cb..0000000 --- a/data/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Options -Indexes \ No newline at end of file diff --git a/data/index.html b/data/index.html new file mode 100644 index 0000000..e69de29 diff --git a/lib/.htaccess b/lib/.htaccess deleted file mode 100644 index 45552cb..0000000 --- a/lib/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Options -Indexes \ No newline at end of file diff --git a/lib/ckeditor5/build/index.html b/lib/ckeditor5/build/index.html new file mode 100644 index 0000000..e69de29 diff --git a/lib/ckeditor5/build/translations/index.html b/lib/ckeditor5/build/translations/index.html new file mode 100644 index 0000000..e69de29 diff --git a/lib/ckeditor5/index.html b/lib/ckeditor5/index.html new file mode 100644 index 0000000..e69de29 diff --git a/lib/ckeditor5/src/index.html b/lib/ckeditor5/src/index.html new file mode 100644 index 0000000..e69de29 diff --git a/lib/htmlawed/.htaccess b/lib/htmlawed/.htaccess new file mode 100644 index 0000000..45552cb --- /dev/null +++ b/lib/htmlawed/.htaccess @@ -0,0 +1 @@ +Options -Indexes \ No newline at end of file diff --git a/lib/index.html b/lib/index.html new file mode 100644 index 0000000..e69de29 diff --git a/model/Image.php b/model/Image.php index d94e95d..4cceb0f 100644 --- a/model/Image.php +++ b/model/Image.php @@ -25,32 +25,27 @@ class Image public function upload() { - global $maxWeight; - // traitement et enregistrement de l'image if (isset($_FILES['upload']) AND $_FILES['upload']['error'] == 0) // 0 signifie ok { - if ($_FILES['upload']['size'] <= $maxWeight) - { - $this->pathInfos = pathinfo($_FILES['upload']['name']); - $extension = $this->pathInfos['extension']; - $extautorisées = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff'); - // on prend la même liste que celle côté javascript, le SVG est bloqué pour raison de sécurité (javascript à l'intérieur) - if (in_array($extension, $extautorisées)) - { - move_uploaded_file($_FILES['upload']['tmp_name'], $this->path . $_FILES['upload']['name']); - chmod($this->path . $_FILES['upload']['name'], 0666); - } - else{$this->erreur = 'mauvais format, veuillez utiliser une image comportant un de ces formats: jpg ou jpeg, png, gif, bmp, webp, tiff
le format svg n\'est pas supporté';} - } - else - { - $this->erreur = 'erreur du serveur: le fichier téléchargé est trop lourd, poids max = ' . $maxWeight . ' octets'; - } + $this->pathInfos = pathinfo($_FILES['upload']['name']); + $extension = $this->pathInfos['extension']; + $extautorisées = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff'); + // on prend la même liste que celle côté javascript, le SVG est bloqué pour raison de sécurité (javascript à l'intérieur) + if (in_array($extension, $extautorisées)) + { + move_uploaded_file($_FILES['upload']['tmp_name'], $this->path . $_FILES['upload']['name']); + chmod($this->path . $_FILES['upload']['name'], 0666); + } + else + { + $this->erreur = 'mauvais format, veuillez utiliser une image comportant un de ces formats: jpg ou jpeg, png, gif, bmp, webp, tiff
le format svg n\'est pas supporté'; + } } else { - $this->erreur = 'erreur du serveur: le fichier téléchargé est trop lourd, poids max = ' . $maxWeight . ' octets'; + $this->erreur = 'Erreur: Le fichier n\'a pas pu être téléchargé correctement.
+ Au fait, "upload_max_filesize" dans le php.ini vaut ' . ini_get('upload_max_filesize') . '.'; } // retour des rêquetes AJAX diff --git a/public/accueil/index.html b/public/accueil/index.html new file mode 100644 index 0000000..e69de29 diff --git a/public/css/accueil.css b/public/css/accueil.css index b95e818..b7dcf06 100644 --- a/public/css/accueil.css +++ b/public/css/accueil.css @@ -116,7 +116,7 @@ form #courriel { padding-top: 30px; - font-size: 85%; + font-size: 90%; } #courriel * @@ -154,8 +154,6 @@ form width: 700px; z-index: 2; padding-top: 2px; - /*text-align: center;*/ - /*font-family: Sans-serif;*/ } #modeAdmin p diff --git a/public/css/index.html b/public/css/index.html new file mode 100644 index 0000000..e69de29 diff --git a/public/css/pages_articles_simples.css b/public/css/pages_articles_simples.css index 5f20753..124166b 100644 --- a/public/css/pages_articles_simples.css +++ b/public/css/pages_articles_simples.css @@ -24,6 +24,10 @@ figure { border-bottom: 3px black double; } +.boutonNouvelArticle +{ + font-size: 90%; +} .boutonArticle a { padding: 2px; diff --git a/public/fonts/index.html b/public/fonts/index.html new file mode 100644 index 0000000..e69de29 diff --git a/public/header_images/index.html b/public/header_images/index.html new file mode 100644 index 0000000..e69de29 diff --git a/public/menu/index.html b/public/menu/index.html new file mode 100644 index 0000000..e69de29 diff --git a/view/courriel.php b/view/courriel.php index 77a4eb0..3d401fb 100644 --- a/view/courriel.php +++ b/view/courriel.php @@ -1,5 +1,5 @@
- +

Envoyez-moi un courriel à:
diff --git a/view/pageArticlesSimples.php b/view/pageArticlesSimples.php index a8c94d2..88cce4c 100644 --- a/view/pageArticlesSimples.php +++ b/view/pageArticlesSimples.php @@ -81,7 +81,7 @@ if($_SESSION['admin'] == 1) { ?>
-

+

Nouvel article -- cgit v1.2.3