diff options
Diffstat (limited to 'model/Image.php')
-rw-r--r-- | model/Image.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/model/Image.php b/model/Image.php index f0bb390..d77cfb1 100644 --- a/model/Image.php +++ b/model/Image.php | |||
@@ -12,15 +12,17 @@ class Image | |||
12 | public $path; | 12 | public $path; |
13 | public $pathMini; | 13 | public $pathMini; |
14 | public $FileName; // après sécurisation | 14 | public $FileName; // après sécurisation |
15 | public $permissions; | ||
15 | public $width; | 16 | public $width; |
16 | public $pathInfos; | 17 | public $pathInfos; |
17 | public $erreur; | 18 | public $erreur; |
18 | 19 | ||
19 | public function __construct(string $page, string $folder, bool $ajax) | 20 | public function __construct(string $page, string $folder, bool $ajax, int $permissions = 0666) |
20 | { | 21 | { |
21 | $this->ajax = $ajax; | 22 | $this->ajax = $ajax; |
22 | $this->page = $page; | 23 | $this->page = $page; |
23 | $this->folder = $folder; | 24 | $this->folder = $folder; |
25 | $this->permissions = $permissions; | ||
24 | $this->path = 'data/' . $this->folder . '/images/'; | 26 | $this->path = 'data/' . $this->folder . '/images/'; |
25 | $this->pathMini = 'data/' . $this->folder . '/images-mini/'; | 27 | $this->pathMini = 'data/' . $this->folder . '/images-mini/'; |
26 | } | 28 | } |
@@ -59,7 +61,7 @@ class Image | |||
59 | if (in_array($extension, $extautorisées)) | 61 | if (in_array($extension, $extautorisées)) |
60 | { | 62 | { |
61 | move_uploaded_file($_FILES['upload']['tmp_name'], $this->path . $this->FileName); | 63 | move_uploaded_file($_FILES['upload']['tmp_name'], $this->path . $this->FileName); |
62 | chmod($this->path . $this->FileName, 0666); | 64 | chmod($this->path . $this->FileName, $this->permissions); |
63 | } | 65 | } |
64 | else | 66 | else |
65 | { | 67 | { |
@@ -95,9 +97,11 @@ class Image | |||
95 | // 0 signifie qu'on conserve les proportions | 97 | // 0 signifie qu'on conserve les proportions |
96 | $Image->thumbnailImage($this->width, 0); | 98 | $Image->thumbnailImage($this->width, 0); |
97 | } | 99 | } |
98 | 100 | ||
99 | // écriture dans un fichier | 101 | // écriture dans un fichier |
100 | $Image->writeImage($this->pathMini . $this->pathInfos['filename'] . '-mini.' . $this->pathInfos['extension']); | 102 | $nomMiniImage = $this->pathMini . $this->pathInfos['filename'] . '-mini.' . $this->pathInfos['extension']; |
103 | $Image->writeImage($nomMiniImage); | ||
104 | chmod($nomMiniImage, $this->permissions); | ||
101 | } | 105 | } |
102 | elseif($imageLibrary == 'gd') | 106 | elseif($imageLibrary == 'gd') |
103 | { | 107 | { |
@@ -124,6 +128,7 @@ class Image | |||
124 | { | 128 | { |
125 | imagejpeg($source, $nomMiniImage); | 129 | imagejpeg($source, $nomMiniImage); |
126 | } | 130 | } |
131 | chmod($nomMiniImage, $this->permissions); | ||
127 | } | 132 | } |
128 | else | 133 | else |
129 | { | 134 | { |