@@ -3968,7 +3968,7 @@ |
||
3968 | 3968 | * @param int|string $options Either a PATHINFO_* constant, |
3969 | 3969 | * or a string name to return only the specified piece |
3970 | 3970 | * |
3971 | - * @return string|array |
|
3971 | + * @return string |
|
3972 | 3972 | */ |
3973 | 3973 | public static function mb_pathinfo($path, $options = null) |
3974 | 3974 | { |
@@ -209,7 +209,7 @@ |
||
209 | 209 | * Connect to a POP3 server. |
210 | 210 | * |
211 | 211 | * @param string $host |
212 | - * @param int|bool $port |
|
212 | + * @param integer $port |
|
213 | 213 | * @param int $tval |
214 | 214 | * |
215 | 215 | * @return bool |
@@ -1314,7 +1314,7 @@ |
||
1314 | 1314 | * If no reply has been received yet, it will return null. |
1315 | 1315 | * If no pattern was matched, it will return false. |
1316 | 1316 | * |
1317 | - * @return bool|null|string |
|
1317 | + * @return string |
|
1318 | 1318 | * |
1319 | 1319 | * @see recordLastTransactionID() |
1320 | 1320 | */ |
@@ -183,6 +183,9 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | |
186 | + /** |
|
187 | + * @param integer $n |
|
188 | + */ |
|
186 | 189 | private function getChars($n) |
187 | 190 | { |
188 | 191 | $response = null; |
@@ -225,6 +228,9 @@ discard block |
||
225 | 228 | } |
226 | 229 | |
227 | 230 | |
231 | + /** |
|
232 | + * @param false|string $str |
|
233 | + */ |
|
228 | 234 | private function readInt($str) |
229 | 235 | { |
230 | 236 | $size = unpack("C*", $str); |
@@ -13,227 +13,227 @@ |
||
13 | 13 | |
14 | 14 | class fastImage |
15 | 15 | { |
16 | - private $strpos = 0; |
|
17 | - private $str; |
|
18 | - private $uri; |
|
19 | - private $type; |
|
20 | - private $handle; |
|
16 | + private $strpos = 0; |
|
17 | + private $str; |
|
18 | + private $uri; |
|
19 | + private $type; |
|
20 | + private $handle; |
|
21 | 21 | |
22 | - public function __construct($uri = null) |
|
23 | - { |
|
24 | - if ($uri) $this->load($uri); |
|
25 | - } |
|
22 | + public function __construct($uri = null) |
|
23 | + { |
|
24 | + if ($uri) $this->load($uri); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - public function load($uri) |
|
29 | - { |
|
30 | - if ($this->handle) $this->close(); |
|
31 | - |
|
32 | - $this->uri = $uri; |
|
33 | - $this->handle = fopen($uri, 'r'); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - public function close() |
|
38 | - { |
|
39 | - if (is_resource($this->handle)) fclose($this->handle); |
|
40 | - } |
|
28 | + public function load($uri) |
|
29 | + { |
|
30 | + if ($this->handle) $this->close(); |
|
31 | + |
|
32 | + $this->uri = $uri; |
|
33 | + $this->handle = fopen($uri, 'r'); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + public function close() |
|
38 | + { |
|
39 | + if (is_resource($this->handle)) fclose($this->handle); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - public function getSize() |
|
44 | - { |
|
45 | - $this->strpos = 0; |
|
46 | - if ($this->getType()) |
|
47 | - { |
|
48 | - return array_values($this->parseSize()); |
|
49 | - } |
|
50 | - |
|
51 | - return false; |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - public function getType() |
|
56 | - { |
|
57 | - $this->strpos = 0; |
|
58 | - |
|
59 | - if (!$this->type) |
|
60 | - { |
|
61 | - switch ($this->getChars(2)) |
|
62 | - { |
|
63 | - case "BM": |
|
64 | - return $this->type = 'bmp'; |
|
65 | - case "GI": |
|
66 | - return $this->type = 'gif'; |
|
67 | - case chr(0xFF).chr(0xd8): |
|
68 | - return $this->type = 'jpeg'; |
|
69 | - case chr(0x89).'P': |
|
70 | - return $this->type = 'png'; |
|
71 | - default: |
|
72 | - return false; |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - return $this->type; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - private function parseSize() |
|
81 | - { |
|
82 | - $this->strpos = 0; |
|
83 | - |
|
84 | - switch ($this->type) |
|
85 | - { |
|
86 | - case 'png': |
|
87 | - return $this->parseSizeForPNG(); |
|
88 | - case 'gif': |
|
89 | - return $this->parseSizeForGIF(); |
|
90 | - case 'bmp': |
|
91 | - return $this->parseSizeForBMP(); |
|
92 | - case 'jpeg': |
|
93 | - return $this->parseSizeForJPEG(); |
|
94 | - } |
|
95 | - |
|
96 | - return null; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - private function parseSizeForPNG() |
|
101 | - { |
|
102 | - $chars = $this->getChars(25); |
|
103 | - |
|
104 | - return unpack("N*", substr($chars, 16, 8)); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - private function parseSizeForGIF() |
|
109 | - { |
|
110 | - $chars = $this->getChars(11); |
|
111 | - |
|
112 | - return unpack("S*", substr($chars, 6, 4)); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - private function parseSizeForBMP() |
|
117 | - { |
|
118 | - $chars = $this->getChars(29); |
|
119 | - $chars = substr($chars, 14, 14); |
|
120 | - $type = unpack('C', $chars); |
|
121 | - |
|
122 | - return (reset($type) == 40) ? unpack('L*', substr($chars, 4)) : unpack('L*', substr($chars, 4, 8)); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - private function parseSizeForJPEG() |
|
127 | - { |
|
128 | - $state = null; |
|
129 | - |
|
130 | - while (true) |
|
131 | - { |
|
132 | - switch ($state) |
|
133 | - { |
|
134 | - default: |
|
135 | - $this->getChars(2); |
|
136 | - $state = 'started'; |
|
137 | - break; |
|
138 | - |
|
139 | - case 'started': |
|
140 | - $b = $this->getByte(); |
|
141 | - if ($b === false) return false; |
|
142 | - |
|
143 | - $state = $b == 0xFF ? 'sof' : 'started'; |
|
144 | - break; |
|
145 | - |
|
146 | - case 'sof': |
|
147 | - $b = $this->getByte(); |
|
148 | - if (in_array($b, range(0xe0, 0xef))) |
|
149 | - { |
|
150 | - $state = 'skipframe'; |
|
151 | - } |
|
152 | - elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF)))) |
|
153 | - { |
|
154 | - $state = 'readsize'; |
|
155 | - } |
|
156 | - elseif ($b == 0xFF) |
|
157 | - { |
|
158 | - $state = 'sof'; |
|
159 | - } |
|
160 | - else |
|
161 | - { |
|
162 | - $state = 'skipframe'; |
|
163 | - } |
|
164 | - break; |
|
165 | - |
|
166 | - case 'skipframe': |
|
167 | - $skip = $this->readInt($this->getChars(2)) - 2; |
|
168 | - $state = 'doskip'; |
|
169 | - break; |
|
170 | - |
|
171 | - case 'doskip': |
|
172 | - $this->getChars($skip); |
|
173 | - $state = 'started'; |
|
174 | - break; |
|
175 | - |
|
176 | - case 'readsize': |
|
177 | - $c = $this->getChars(7); |
|
178 | - |
|
179 | - return array($this->readInt(substr($c, 5, 2)), $this->readInt(substr($c, 3, 2))); |
|
180 | - } |
|
181 | - } |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - private function getChars($n) |
|
186 | - { |
|
187 | - $response = null; |
|
188 | - |
|
189 | - // do we need more data? |
|
190 | - if ($this->strpos + $n -1 >= strlen($this->str)) |
|
191 | - { |
|
192 | - $end = ($this->strpos + $n); |
|
193 | - |
|
194 | - while (strlen($this->str) < $end && $response !== false) |
|
195 | - { |
|
196 | - // read more from the file handle |
|
197 | - $need = $end - ftell($this->handle); |
|
198 | - |
|
199 | - if ($response = fread($this->handle, $need)) |
|
200 | - { |
|
201 | - $this->str .= $response; |
|
202 | - } |
|
203 | - else |
|
204 | - { |
|
205 | - return false; |
|
206 | - } |
|
207 | - } |
|
208 | - } |
|
209 | - |
|
210 | - $result = substr($this->str, $this->strpos, $n); |
|
211 | - $this->strpos += $n; |
|
212 | - |
|
213 | - // we are dealing with bytes here, so force the encoding |
|
214 | - return mb_convert_encoding($result, "8BIT"); |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - private function getByte() |
|
219 | - { |
|
220 | - $c = $this->getChars(1); |
|
221 | - $b = unpack("C", $c); |
|
222 | - |
|
223 | - return reset($b); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - private function readInt($str) |
|
228 | - { |
|
229 | - $size = unpack("C*", $str); |
|
230 | - |
|
231 | - return ($size[1] << 8) + $size[2]; |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - public function __destruct() |
|
236 | - { |
|
237 | - $this->close(); |
|
238 | - } |
|
43 | + public function getSize() |
|
44 | + { |
|
45 | + $this->strpos = 0; |
|
46 | + if ($this->getType()) |
|
47 | + { |
|
48 | + return array_values($this->parseSize()); |
|
49 | + } |
|
50 | + |
|
51 | + return false; |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + public function getType() |
|
56 | + { |
|
57 | + $this->strpos = 0; |
|
58 | + |
|
59 | + if (!$this->type) |
|
60 | + { |
|
61 | + switch ($this->getChars(2)) |
|
62 | + { |
|
63 | + case "BM": |
|
64 | + return $this->type = 'bmp'; |
|
65 | + case "GI": |
|
66 | + return $this->type = 'gif'; |
|
67 | + case chr(0xFF).chr(0xd8): |
|
68 | + return $this->type = 'jpeg'; |
|
69 | + case chr(0x89).'P': |
|
70 | + return $this->type = 'png'; |
|
71 | + default: |
|
72 | + return false; |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + return $this->type; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + private function parseSize() |
|
81 | + { |
|
82 | + $this->strpos = 0; |
|
83 | + |
|
84 | + switch ($this->type) |
|
85 | + { |
|
86 | + case 'png': |
|
87 | + return $this->parseSizeForPNG(); |
|
88 | + case 'gif': |
|
89 | + return $this->parseSizeForGIF(); |
|
90 | + case 'bmp': |
|
91 | + return $this->parseSizeForBMP(); |
|
92 | + case 'jpeg': |
|
93 | + return $this->parseSizeForJPEG(); |
|
94 | + } |
|
95 | + |
|
96 | + return null; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + private function parseSizeForPNG() |
|
101 | + { |
|
102 | + $chars = $this->getChars(25); |
|
103 | + |
|
104 | + return unpack("N*", substr($chars, 16, 8)); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + private function parseSizeForGIF() |
|
109 | + { |
|
110 | + $chars = $this->getChars(11); |
|
111 | + |
|
112 | + return unpack("S*", substr($chars, 6, 4)); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + private function parseSizeForBMP() |
|
117 | + { |
|
118 | + $chars = $this->getChars(29); |
|
119 | + $chars = substr($chars, 14, 14); |
|
120 | + $type = unpack('C', $chars); |
|
121 | + |
|
122 | + return (reset($type) == 40) ? unpack('L*', substr($chars, 4)) : unpack('L*', substr($chars, 4, 8)); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + private function parseSizeForJPEG() |
|
127 | + { |
|
128 | + $state = null; |
|
129 | + |
|
130 | + while (true) |
|
131 | + { |
|
132 | + switch ($state) |
|
133 | + { |
|
134 | + default: |
|
135 | + $this->getChars(2); |
|
136 | + $state = 'started'; |
|
137 | + break; |
|
138 | + |
|
139 | + case 'started': |
|
140 | + $b = $this->getByte(); |
|
141 | + if ($b === false) return false; |
|
142 | + |
|
143 | + $state = $b == 0xFF ? 'sof' : 'started'; |
|
144 | + break; |
|
145 | + |
|
146 | + case 'sof': |
|
147 | + $b = $this->getByte(); |
|
148 | + if (in_array($b, range(0xe0, 0xef))) |
|
149 | + { |
|
150 | + $state = 'skipframe'; |
|
151 | + } |
|
152 | + elseif (in_array($b, array_merge(range(0xC0,0xC3), range(0xC5,0xC7), range(0xC9,0xCB), range(0xCD,0xCF)))) |
|
153 | + { |
|
154 | + $state = 'readsize'; |
|
155 | + } |
|
156 | + elseif ($b == 0xFF) |
|
157 | + { |
|
158 | + $state = 'sof'; |
|
159 | + } |
|
160 | + else |
|
161 | + { |
|
162 | + $state = 'skipframe'; |
|
163 | + } |
|
164 | + break; |
|
165 | + |
|
166 | + case 'skipframe': |
|
167 | + $skip = $this->readInt($this->getChars(2)) - 2; |
|
168 | + $state = 'doskip'; |
|
169 | + break; |
|
170 | + |
|
171 | + case 'doskip': |
|
172 | + $this->getChars($skip); |
|
173 | + $state = 'started'; |
|
174 | + break; |
|
175 | + |
|
176 | + case 'readsize': |
|
177 | + $c = $this->getChars(7); |
|
178 | + |
|
179 | + return array($this->readInt(substr($c, 5, 2)), $this->readInt(substr($c, 3, 2))); |
|
180 | + } |
|
181 | + } |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + private function getChars($n) |
|
186 | + { |
|
187 | + $response = null; |
|
188 | + |
|
189 | + // do we need more data? |
|
190 | + if ($this->strpos + $n -1 >= strlen($this->str)) |
|
191 | + { |
|
192 | + $end = ($this->strpos + $n); |
|
193 | + |
|
194 | + while (strlen($this->str) < $end && $response !== false) |
|
195 | + { |
|
196 | + // read more from the file handle |
|
197 | + $need = $end - ftell($this->handle); |
|
198 | + |
|
199 | + if ($response = fread($this->handle, $need)) |
|
200 | + { |
|
201 | + $this->str .= $response; |
|
202 | + } |
|
203 | + else |
|
204 | + { |
|
205 | + return false; |
|
206 | + } |
|
207 | + } |
|
208 | + } |
|
209 | + |
|
210 | + $result = substr($this->str, $this->strpos, $n); |
|
211 | + $this->strpos += $n; |
|
212 | + |
|
213 | + // we are dealing with bytes here, so force the encoding |
|
214 | + return mb_convert_encoding($result, "8BIT"); |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + private function getByte() |
|
219 | + { |
|
220 | + $c = $this->getChars(1); |
|
221 | + $b = unpack("C", $c); |
|
222 | + |
|
223 | + return reset($b); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + private function readInt($str) |
|
228 | + { |
|
229 | + $size = unpack("C*", $str); |
|
230 | + |
|
231 | + return ($size[1] << 8) + $size[2]; |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + public function __destruct() |
|
236 | + { |
|
237 | + $this->close(); |
|
238 | + } |
|
239 | 239 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes. |
169 | 169 | * The other dimension (height or width) will be calculated autamaticaly |
170 | 170 | * @param integer $bigger_size |
171 | - * @return array */ |
|
171 | + * @return integer[] */ |
|
172 | 172 | |
173 | 173 | public function get_prop_size($bigger_size) { |
174 | 174 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * no samo po edno (x ili y) izmerenie |
256 | 256 | * @param integer $width |
257 | 257 | * @param integer $height |
258 | - * @return bool */ |
|
258 | + * @return gd */ |
|
259 | 259 | |
260 | 260 | public function resize_overflow($width, $height) { |
261 | 261 | |
@@ -397,6 +397,12 @@ discard block |
||
397 | 397 | return false; |
398 | 398 | } |
399 | 399 | |
400 | + /** |
|
401 | + * @param integer $x1 |
|
402 | + * @param integer $y1 |
|
403 | + * @param integer $x2 |
|
404 | + * @param integer $y2 |
|
405 | + */ |
|
400 | 406 | public function imagefilledrectangle($x1, $y1, $x2, $y2, $color) { |
401 | 407 | $color = $this->gd_color($color); |
402 | 408 | if ($color === false) return false; |
@@ -1,44 +1,44 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc GD extension class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.51 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010, 2011 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc GD extension class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.51 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010, 2011 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class gd { |
16 | 16 | |
17 | - /** GD resource |
|
18 | - * @var resource */ |
|
17 | + /** GD resource |
|
18 | + * @var resource */ |
|
19 | 19 | protected $image; |
20 | 20 | |
21 | - /** Image width |
|
22 | - * @var integer */ |
|
21 | + /** Image width |
|
22 | + * @var integer */ |
|
23 | 23 | protected $width; |
24 | 24 | |
25 | - /** Image height |
|
26 | - * @var integer */ |
|
25 | + /** Image height |
|
26 | + * @var integer */ |
|
27 | 27 | protected $height; |
28 | 28 | |
29 | - /** Init error |
|
30 | - * @var bool */ |
|
29 | + /** Init error |
|
30 | + * @var bool */ |
|
31 | 31 | public $init_error = false; |
32 | 32 | |
33 | - /** Last builded image type constant (IMAGETYPE_XXX) |
|
34 | - * @var integer */ |
|
33 | + /** Last builded image type constant (IMAGETYPE_XXX) |
|
34 | + * @var integer */ |
|
35 | 35 | public $type; |
36 | 36 | |
37 | - /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height. |
|
38 | - * Returns FALSE on failure. The only one parameter $image can be an instance of this class, |
|
39 | - * a GD resource, an array(width, height) or path to image file. |
|
40 | - * @param mixed $image |
|
41 | - * @return array */ |
|
37 | + /** Returns an array. Element 0 - GD resource. Element 1 - width. Element 2 - height. |
|
38 | + * Returns FALSE on failure. The only one parameter $image can be an instance of this class, |
|
39 | + * a GD resource, an array(width, height) or path to image file. |
|
40 | + * @param mixed $image |
|
41 | + * @return array */ |
|
42 | 42 | |
43 | 43 | protected function build_image($image) { |
44 | 44 | |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | return $return; |
88 | 88 | } |
89 | 89 | |
90 | - /** Parameter $image can be: |
|
91 | - * 1. An instance of this class (copy instance). |
|
92 | - * 2. A GD resource. |
|
93 | - * 3. An array with two elements. First - width, second - height. Create a blank image. |
|
94 | - * 4. A filename string. Get image form file. |
|
95 | - * The non-required parameter $bigger_size is the bigger dimension (width or height) the image |
|
96 | - * will be resized to. The other dimension (height or width) will be calculated autamaticaly |
|
97 | - * @param mixed $image |
|
98 | - * @param integer $bigger_size |
|
99 | - * @return gd */ |
|
90 | + /** Parameter $image can be: |
|
91 | + * 1. An instance of this class (copy instance). |
|
92 | + * 2. A GD resource. |
|
93 | + * 3. An array with two elements. First - width, second - height. Create a blank image. |
|
94 | + * 4. A filename string. Get image form file. |
|
95 | + * The non-required parameter $bigger_size is the bigger dimension (width or height) the image |
|
96 | + * will be resized to. The other dimension (height or width) will be calculated autamaticaly |
|
97 | + * @param mixed $image |
|
98 | + * @param integer $bigger_size |
|
99 | + * @return gd */ |
|
100 | 100 | |
101 | 101 | public function __construct($image, $bigger_size=null) { |
102 | 102 | $this->image = $this->width = $this->height = null; |
@@ -123,30 +123,30 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - /** Returns the GD resource |
|
127 | - * @return resource */ |
|
126 | + /** Returns the GD resource |
|
127 | + * @return resource */ |
|
128 | 128 | |
129 | 129 | public function get_image() { |
130 | 130 | return $this->image; |
131 | 131 | } |
132 | 132 | |
133 | - /** Returns the image width |
|
134 | - * @return integer */ |
|
133 | + /** Returns the image width |
|
134 | + * @return integer */ |
|
135 | 135 | |
136 | 136 | public function get_width() { |
137 | 137 | return $this->width; |
138 | 138 | } |
139 | 139 | |
140 | - /** Returns the image height |
|
141 | - * @return integer */ |
|
140 | + /** Returns the image height |
|
141 | + * @return integer */ |
|
142 | 142 | |
143 | 143 | public function get_height() { |
144 | 144 | return $this->height; |
145 | 145 | } |
146 | 146 | |
147 | - /** Returns calculated proportional width from the given height |
|
148 | - * @param integer $resized_height |
|
149 | - * @return integer */ |
|
147 | + /** Returns calculated proportional width from the given height |
|
148 | + * @param integer $resized_height |
|
149 | + * @return integer */ |
|
150 | 150 | |
151 | 151 | public function get_prop_width($resized_height) { |
152 | 152 | $width = intval(($this->width * $resized_height) / $this->height); |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | return $width; |
155 | 155 | } |
156 | 156 | |
157 | - /** Returns calculated proportional height from the given width |
|
158 | - * @param integer $resized_width |
|
159 | - * @return integer */ |
|
157 | + /** Returns calculated proportional height from the given width |
|
158 | + * @param integer $resized_width |
|
159 | + * @return integer */ |
|
160 | 160 | |
161 | 161 | public function get_prop_height($resized_width) { |
162 | 162 | $height = intval(($this->height * $resized_width) / $this->width); |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | return $height; |
165 | 165 | } |
166 | 166 | |
167 | - /** Returns an array with calculated proportional width & height. |
|
168 | - * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes. |
|
169 | - * The other dimension (height or width) will be calculated autamaticaly |
|
170 | - * @param integer $bigger_size |
|
171 | - * @return array */ |
|
167 | + /** Returns an array with calculated proportional width & height. |
|
168 | + * The parameter $bigger_size is the bigger dimension (width or height) of calculated sizes. |
|
169 | + * The other dimension (height or width) will be calculated autamaticaly |
|
170 | + * @param integer $bigger_size |
|
171 | + * @return array */ |
|
172 | 172 | |
173 | 173 | public function get_prop_size($bigger_size) { |
174 | 174 | |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | return array($width, $height); |
187 | 187 | } |
188 | 188 | |
189 | - /** Resize image. Returns TRUE on success or FALSE on failure |
|
190 | - * @param integer $width |
|
191 | - * @param integer $height |
|
192 | - * @return bool */ |
|
189 | + /** Resize image. Returns TRUE on success or FALSE on failure |
|
190 | + * @param integer $width |
|
191 | + * @param integer $height |
|
192 | + * @return bool */ |
|
193 | 193 | |
194 | 194 | public function resize($width, $height) { |
195 | 195 | if (!$width) $width = 1; |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - /** Resize the given image source (GD, gd object or image file path) to fit in the own image. |
|
207 | - * The outside ares will be cropped out. Returns TRUE on success or FALSE on failure |
|
208 | - * @param mixed $src |
|
209 | - * @return bool */ |
|
206 | + /** Resize the given image source (GD, gd object or image file path) to fit in the own image. |
|
207 | + * The outside ares will be cropped out. Returns TRUE on success or FALSE on failure |
|
208 | + * @param mixed $src |
|
209 | + * @return bool */ |
|
210 | 210 | |
211 | 211 | public function resize_crop($src) { |
212 | 212 | $image_details = $this->build_image($src); |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | - /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure |
|
237 | - * @param integer $width |
|
238 | - * @param integer $height |
|
239 | - * @return bool */ |
|
236 | + /** Resize image to fit in given resolution. Returns TRUE on success or FALSE on failure |
|
237 | + * @param integer $width |
|
238 | + * @param integer $height |
|
239 | + * @return bool */ |
|
240 | 240 | |
241 | 241 | public function resize_fit($width, $height) { |
242 | 242 | if ((!$width && !$height) || (($width == $this->width) && ($height == $this->height))) |
@@ -250,12 +250,12 @@ discard block |
||
250 | 250 | return $this->resize($width, $height); |
251 | 251 | } |
252 | 252 | |
253 | - /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height. |
|
254 | - * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik, |
|
255 | - * no samo po edno (x ili y) izmerenie |
|
256 | - * @param integer $width |
|
257 | - * @param integer $height |
|
258 | - * @return bool */ |
|
253 | + /** Neka si predstavim vyobrazhaem pravoygylnik s razmeri $width i $height. |
|
254 | + * Izobrazhenieto shte se preorazmeri taka che to shte izliza ot tozi pravoygylnik, |
|
255 | + * no samo po edno (x ili y) izmerenie |
|
256 | + * @param integer $width |
|
257 | + * @param integer $height |
|
258 | + * @return bool */ |
|
259 | 259 | |
260 | 260 | public function resize_overflow($width, $height) { |
261 | 261 | |
@@ -368,30 +368,30 @@ discard block |
||
368 | 368 | |
369 | 369 | |
370 | 370 | |
371 | - /*** gif transparent fix - 1.10.2013 ***/ |
|
371 | + /*** gif transparent fix - 1.10.2013 ***/ |
|
372 | 372 | |
373 | - $transindex = imagecolortransparent($src); |
|
374 | - $palletsize = imagecolorstotal($src); |
|
375 | - if($transindex >= 0 && $transindex < $palletsize) { |
|
376 | - $transcol = imagecolorsforindex($src, $transindex); |
|
373 | + $transindex = imagecolortransparent($src); |
|
374 | + $palletsize = imagecolorstotal($src); |
|
375 | + if($transindex >= 0 && $transindex < $palletsize) { |
|
376 | + $transcol = imagecolorsforindex($src, $transindex); |
|
377 | 377 | |
378 | - /*** end gif transparent fix ***/ |
|
378 | + /*** end gif transparent fix ***/ |
|
379 | 379 | |
380 | - $transindex = imagecolorallocatealpha($this->image, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
|
381 | - imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex); |
|
382 | - imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); |
|
383 | - imagecolortransparent($this->image, $transindex); |
|
384 | - for($y=0; $y<$dst_h; ++$y) |
|
385 | - for($x=0; $x<$dst_w; ++$x) |
|
386 | - if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex); |
|
387 | - imagetruecolortopalette($this->image, true, 255); |
|
388 | - } |
|
389 | - else { |
|
390 | - $transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127); |
|
391 | - imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent); |
|
392 | - imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); |
|
393 | - } |
|
394 | - return $this->image; |
|
380 | + $transindex = imagecolorallocatealpha($this->image, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
|
381 | + imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transindex); |
|
382 | + imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); |
|
383 | + imagecolortransparent($this->image, $transindex); |
|
384 | + for($y=0; $y<$dst_h; ++$y) |
|
385 | + for($x=0; $x<$dst_w; ++$x) |
|
386 | + if(((imagecolorat($this->image, $x, $y)>>24) & 0x7F) >= 100) imagesetpixel($this->image, $x, $y, $transindex); |
|
387 | + imagetruecolortopalette($this->image, true, 255); |
|
388 | + } |
|
389 | + else { |
|
390 | + $transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127); |
|
391 | + imagefilledrectangle($this->image, 0, 0, $dst_w, $dst_h, $transparent); |
|
392 | + imagecopyresampled($this->image, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); |
|
393 | + } |
|
394 | + return $this->image; |
|
395 | 395 | |
396 | 396 | } else |
397 | 397 | return false; |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | public function imagegif($filename=null) { |
420 | 420 | if (is_null($filename) && !headers_sent()) |
421 | 421 | header("Content-Type: image/gif"); |
422 | - @imagesavealpha($this->image, true); |
|
422 | + @imagesavealpha($this->image, true); |
|
423 | 423 | return imagegif($this->image, $filename); |
424 | 424 | } |
425 | 425 | } |
@@ -179,7 +179,6 @@ |
||
179 | 179 | |
180 | 180 | /** Resize and crop the image to fit in given resolution. Returns TRUE on |
181 | 181 | * success or FALSE on failure |
182 | - * @param mixed $src |
|
183 | 182 | * @param integer $offset |
184 | 183 | * @return bool */ |
185 | 184 | abstract public function resizeCrop($width, $height, $offset=false); |
@@ -1,45 +1,45 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Abstract image driver class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc Abstract image driver class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | abstract class image { |
16 | 16 | const DEFAULT_JPEG_QUALITY = 75; |
17 | 17 | |
18 | 18 | /** Image resource or object |
19 | - * @var mixed */ |
|
19 | + * @var mixed */ |
|
20 | 20 | protected $image; |
21 | 21 | |
22 | 22 | /** Image width in pixels |
23 | - * @var integer */ |
|
23 | + * @var integer */ |
|
24 | 24 | protected $width; |
25 | 25 | |
26 | 26 | /** Image height in pixels |
27 | - * @var integer */ |
|
27 | + * @var integer */ |
|
28 | 28 | protected $height; |
29 | 29 | |
30 | 30 | /** Init error |
31 | - * @var bool */ |
|
31 | + * @var bool */ |
|
32 | 32 | protected $initError = false; |
33 | 33 | |
34 | 34 | /** Driver specific options |
35 | - * @var array */ |
|
35 | + * @var array */ |
|
36 | 36 | protected $options = array(); |
37 | 37 | |
38 | 38 | |
39 | 39 | /** Magic method which allows read-only access to all protected or private |
40 | - * class properties |
|
41 | - * @param string $property |
|
42 | - * @return mixed */ |
|
40 | + * class properties |
|
41 | + * @param string $property |
|
42 | + * @return mixed */ |
|
43 | 43 | |
44 | 44 | final public function __get($property) { |
45 | 45 | return property_exists($this, $property) ? $this->$property : null; |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | |
48 | 48 | |
49 | 49 | /** Constructor. Parameter $image should be: |
50 | - * 1. An instance of image driver class (copy instance). |
|
51 | - * 2. An image represented by the type of the $image property |
|
52 | - * (resource or object). |
|
53 | - * 3. An array with two elements. First - width, second - height. |
|
54 | - * Creates a blank image. |
|
55 | - * 4. A filename string. Get image form file. |
|
56 | - * Second paramaeter is used by pass some specific image driver options |
|
57 | - * @param mixed $image |
|
58 | - * @param array $options */ |
|
50 | + * 1. An instance of image driver class (copy instance). |
|
51 | + * 2. An image represented by the type of the $image property |
|
52 | + * (resource or object). |
|
53 | + * 3. An array with two elements. First - width, second - height. |
|
54 | + * Creates a blank image. |
|
55 | + * 4. A filename string. Get image form file. |
|
56 | + * Second paramaeter is used by pass some specific image driver options |
|
57 | + * @param mixed $image |
|
58 | + * @param array $options */ |
|
59 | 59 | |
60 | 60 | public function __construct($image, array $options=array()) { |
61 | 61 | $this->image = $this->width = $this->height = null; |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | |
71 | 71 | |
72 | 72 | /** Factory pattern to load selected driver. $image and $options are passed |
73 | - * to the constructor of the image driver |
|
74 | - * @param string $driver |
|
75 | - * @param mixed $image |
|
76 | - * @return object */ |
|
73 | + * to the constructor of the image driver |
|
74 | + * @param string $driver |
|
75 | + * @param mixed $image |
|
76 | + * @return object */ |
|
77 | 77 | |
78 | 78 | final static function factory($driver, $image, array $options=array()) { |
79 | 79 | $class = "image_$driver"; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | |
83 | 83 | |
84 | 84 | /** Checks if the drivers in the array parameter could be used. Returns first |
85 | - * found one |
|
86 | - * @param array $drivers |
|
87 | - * @return string */ |
|
85 | + * found one |
|
86 | + * @param array $drivers |
|
87 | + * @return string */ |
|
88 | 88 | |
89 | 89 | final static function getDriver(array $drivers=array('gd')) { |
90 | 90 | foreach ($drivers as $driver) { |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | |
102 | 102 | |
103 | 103 | /** Returns an array. Element 0 - image resource. Element 1 - width. Element 2 - height. |
104 | - * Returns FALSE on failure. |
|
105 | - * @param mixed $image |
|
106 | - * @return array */ |
|
104 | + * Returns FALSE on failure. |
|
105 | + * @param mixed $image |
|
106 | + * @return array */ |
|
107 | 107 | |
108 | 108 | final protected function buildImage($image) { |
109 | 109 | $class = get_class($this); |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | |
129 | 129 | |
130 | 130 | /** Returns calculated proportional width from the given height |
131 | - * @param integer $resizedHeight |
|
132 | - * @return integer */ |
|
131 | + * @param integer $resizedHeight |
|
132 | + * @return integer */ |
|
133 | 133 | |
134 | 134 | final public function getPropWidth($resizedHeight) { |
135 | 135 | $width = round(($this->width * $resizedHeight) / $this->height); |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | |
140 | 140 | |
141 | 141 | /** Returns calculated proportional height from the given width |
142 | - * @param integer $resizedWidth |
|
143 | - * @return integer */ |
|
142 | + * @param integer $resizedWidth |
|
143 | + * @return integer */ |
|
144 | 144 | |
145 | 145 | final public function getPropHeight($resizedWidth) { |
146 | 146 | $height = round(($this->height * $resizedWidth) / $this->width); |
@@ -150,45 +150,45 @@ discard block |
||
150 | 150 | |
151 | 151 | |
152 | 152 | /** Checks if PHP needs some extra extensions to use the image driver. This |
153 | - * static method should be implemented into driver classes like abstract |
|
154 | - * methods |
|
155 | - * @return bool */ |
|
153 | + * static method should be implemented into driver classes like abstract |
|
154 | + * methods |
|
155 | + * @return bool */ |
|
156 | 156 | static function available() { return false; } |
157 | 157 | |
158 | 158 | /** Checks if file is an image. This static method should be implemented into |
159 | - * driver classes like abstract methods |
|
160 | - * @param string $file |
|
161 | - * @return bool */ |
|
159 | + * driver classes like abstract methods |
|
160 | + * @param string $file |
|
161 | + * @return bool */ |
|
162 | 162 | static function checkImage($file) { return false; } |
163 | 163 | |
164 | 164 | /** Resize image. Should return TRUE on success or FALSE on failure |
165 | - * @param integer $width |
|
166 | - * @param integer $height |
|
167 | - * @return bool */ |
|
165 | + * @param integer $width |
|
166 | + * @param integer $height |
|
167 | + * @return bool */ |
|
168 | 168 | abstract public function resize($width, $height); |
169 | 169 | |
170 | 170 | /** Resize image to fit in given resolution. Should returns TRUE on success |
171 | - * or FALSE on failure. If $background is set, the image size will be |
|
172 | - * $width x $height and the empty spaces (if any) will be filled with defined |
|
173 | - * color. Background color examples: "#5f5", "#ff67ca", array(255, 255, 255) |
|
174 | - * @param integer $width |
|
175 | - * @param integer $height |
|
176 | - * @param mixed $background |
|
177 | - * @return bool */ |
|
171 | + * or FALSE on failure. If $background is set, the image size will be |
|
172 | + * $width x $height and the empty spaces (if any) will be filled with defined |
|
173 | + * color. Background color examples: "#5f5", "#ff67ca", array(255, 255, 255) |
|
174 | + * @param integer $width |
|
175 | + * @param integer $height |
|
176 | + * @param mixed $background |
|
177 | + * @return bool */ |
|
178 | 178 | abstract public function resizeFit($width, $height, $background=false); |
179 | 179 | |
180 | 180 | /** Resize and crop the image to fit in given resolution. Returns TRUE on |
181 | - * success or FALSE on failure |
|
182 | - * @param mixed $src |
|
183 | - * @param integer $offset |
|
184 | - * @return bool */ |
|
181 | + * success or FALSE on failure |
|
182 | + * @param mixed $src |
|
183 | + * @param integer $offset |
|
184 | + * @return bool */ |
|
185 | 185 | abstract public function resizeCrop($width, $height, $offset=false); |
186 | 186 | |
187 | 187 | |
188 | 188 | /** Rotate image |
189 | - * @param integer $angle |
|
190 | - * @param string $background |
|
191 | - * @return bool */ |
|
189 | + * @param integer $angle |
|
190 | + * @param string $background |
|
191 | + * @return bool */ |
|
192 | 192 | abstract public function rotate($angle, $background="#000000"); |
193 | 193 | |
194 | 194 | abstract public function flipHorizontal(); |
@@ -196,44 +196,44 @@ discard block |
||
196 | 196 | abstract public function flipVertical(); |
197 | 197 | |
198 | 198 | /** Apply a PNG or GIF watermark to the image. $top and $left parameters sets |
199 | - * the offset of the watermark in pixels. Boolean and NULL values are possible |
|
200 | - * too. In default case (FALSE, FALSE) the watermark should be applyed to |
|
201 | - * the bottom right corner. NULL values means center aligning. If the |
|
202 | - * watermark is bigger than the image or it's partialy or fully outside the |
|
203 | - * image, it shoudn't be applied |
|
204 | - * @param string $file |
|
205 | - * @param mixed $top |
|
206 | - * @param mixed $left |
|
207 | - * @return bool */ |
|
199 | + * the offset of the watermark in pixels. Boolean and NULL values are possible |
|
200 | + * too. In default case (FALSE, FALSE) the watermark should be applyed to |
|
201 | + * the bottom right corner. NULL values means center aligning. If the |
|
202 | + * watermark is bigger than the image or it's partialy or fully outside the |
|
203 | + * image, it shoudn't be applied |
|
204 | + * @param string $file |
|
205 | + * @param mixed $top |
|
206 | + * @param mixed $left |
|
207 | + * @return bool */ |
|
208 | 208 | abstract public function watermark($file, $left=false, $top=false); |
209 | 209 | |
210 | 210 | /** Should output the image. Second parameter is used to pass some options like |
211 | - * 'file' - if is set, the output will be written to a file |
|
212 | - * 'quality' - compression quality |
|
213 | - * It's possible to use extra specific options required by image type ($type) |
|
214 | - * @param string $type |
|
215 | - * @param array $options |
|
216 | - * @return bool */ |
|
211 | + * 'file' - if is set, the output will be written to a file |
|
212 | + * 'quality' - compression quality |
|
213 | + * It's possible to use extra specific options required by image type ($type) |
|
214 | + * @param string $type |
|
215 | + * @param array $options |
|
216 | + * @return bool */ |
|
217 | 217 | abstract public function output($type='jpeg', array $options=array()); |
218 | 218 | |
219 | 219 | /** This method should create a blank image with selected size. Should returns |
220 | - * resource or object related to the created image, which will be passed to |
|
221 | - * $image property |
|
222 | - * @param integer $width |
|
223 | - * @param integer $height |
|
224 | - * @return mixed */ |
|
220 | + * resource or object related to the created image, which will be passed to |
|
221 | + * $image property |
|
222 | + * @param integer $width |
|
223 | + * @param integer $height |
|
224 | + * @return mixed */ |
|
225 | 225 | abstract protected function getBlankImage($width, $height); |
226 | 226 | |
227 | 227 | /** This method should create an image from source image. Only first parameter |
228 | - * ($image) is input. Its type should be filename string or a type of the |
|
229 | - * $image property. See the constructor reference for details. The |
|
230 | - * parametters $width and $height are output only. Should returns resource or |
|
231 | - * object related to the created image, which will be passed to $image |
|
232 | - * property |
|
233 | - * @param mixed $image |
|
234 | - * @param integer $width |
|
235 | - * @param integer $height |
|
236 | - * @return mixed */ |
|
228 | + * ($image) is input. Its type should be filename string or a type of the |
|
229 | + * $image property. See the constructor reference for details. The |
|
230 | + * parametters $width and $height are output only. Should returns resource or |
|
231 | + * object related to the created image, which will be passed to $image |
|
232 | + * property |
|
233 | + * @param mixed $image |
|
234 | + * @param integer $width |
|
235 | + * @param integer $height |
|
236 | + * @return mixed */ |
|
237 | 237 | abstract protected function getImage($image, &$width, &$height); |
238 | 238 | |
239 | 239 | } |
@@ -327,6 +327,11 @@ |
||
327 | 327 | return imagecolorallocate($this->image, $r, $g, $b); |
328 | 328 | } |
329 | 329 | |
330 | + /** |
|
331 | + * @param integer $x1 |
|
332 | + * @param integer $y1 |
|
333 | + * @param boolean $color |
|
334 | + */ |
|
330 | 335 | protected function imageFilledRectangle($x1, $y1, $x2, $y2, $color) { |
331 | 336 | $color = $this->gdColor($color); |
332 | 337 | if ($color === false) return false; |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc GD image driver class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc GD image driver class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class image_gd extends image { |
16 | 16 |
@@ -18,6 +18,9 @@ discard block |
||
18 | 18 | protected $root; |
19 | 19 | protected $ignored; |
20 | 20 | |
21 | + /** |
|
22 | + * @param string $folder |
|
23 | + */ |
|
21 | 24 | function __construct($file, $folder, $ignored=null) { |
22 | 25 | $this->zip = new ZipArchive(); |
23 | 26 | |
@@ -39,6 +42,9 @@ discard block |
||
39 | 42 | $this->zip->close(); |
40 | 43 | } |
41 | 44 | |
45 | + /** |
|
46 | + * @param string $folder |
|
47 | + */ |
|
42 | 48 | function zip($folder, $parent=null) { |
43 | 49 | $full_path = "{$this->root}$parent$folder"; |
44 | 50 | $zip_path = "$parent$folder"; |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project. The class are taken from |
4 | - * http://www.php.net/manual/en/function.ziparchive-addemptydir.php |
|
5 | - * |
|
6 | - * @desc Directory to ZIP file archivator |
|
7 | - * @package KCFinder |
|
8 | - * @version 2.54 |
|
9 | - * @author Pavel Tzonkov <[email protected]> |
|
10 | - * @copyright 2010-2014 KCFinder Project |
|
11 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
12 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
13 | - * @link http://kcfinder.sunhater.com |
|
14 | - */ |
|
4 | + * http://www.php.net/manual/en/function.ziparchive-addemptydir.php |
|
5 | + * |
|
6 | + * @desc Directory to ZIP file archivator |
|
7 | + * @package KCFinder |
|
8 | + * @version 2.54 |
|
9 | + * @author Pavel Tzonkov <[email protected]> |
|
10 | + * @copyright 2010-2014 KCFinder Project |
|
11 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
12 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
13 | + * @link http://kcfinder.sunhater.com |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | class zipFolder { |
17 | 17 | protected $zip; |
@@ -102,7 +102,6 @@ discard block |
||
102 | 102 | |
103 | 103 | /** Checks if the given file is really writable. The standard PHP function |
104 | 104 | * is_writable() does not work properly on Windows servers. |
105 | - * @param string $dir |
|
106 | 105 | * @return bool */ |
107 | 106 | |
108 | 107 | static function isWritable($filename) { |
@@ -114,7 +113,6 @@ discard block |
||
114 | 113 | } |
115 | 114 | |
116 | 115 | /** Get the extension from filename |
117 | - * @param string $file |
|
118 | 116 | * @param bool $toLower |
119 | 117 | * @return string */ |
120 | 118 |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc File helper class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc File helper class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class file { |
16 | 16 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | 'zip' => 'application/x-zip' |
101 | 101 | ); |
102 | 102 | |
103 | - /** Checks if the given file is really writable. The standard PHP function |
|
104 | - * is_writable() does not work properly on Windows servers. |
|
105 | - * @param string $dir |
|
106 | - * @return bool */ |
|
103 | + /** Checks if the given file is really writable. The standard PHP function |
|
104 | + * is_writable() does not work properly on Windows servers. |
|
105 | + * @param string $dir |
|
106 | + * @return bool */ |
|
107 | 107 | |
108 | 108 | static function isWritable($filename) { |
109 | 109 | $filename = path::normalize($filename); |
@@ -113,26 +113,26 @@ discard block |
||
113 | 113 | return true; |
114 | 114 | } |
115 | 115 | |
116 | - /** Get the extension from filename |
|
117 | - * @param string $file |
|
118 | - * @param bool $toLower |
|
119 | - * @return string */ |
|
116 | + /** Get the extension from filename |
|
117 | + * @param string $file |
|
118 | + * @param bool $toLower |
|
119 | + * @return string */ |
|
120 | 120 | |
121 | 121 | static function getExtension($filename, $toLower=true) { |
122 | 122 | return preg_match('/^.*\.([^\.]*)$/s', $filename, $patt) |
123 | 123 | ? ($toLower ? strtolower($patt[1]) : $patt[1]) : ""; |
124 | 124 | } |
125 | 125 | |
126 | - /** Get MIME type of the given filename. If Fileinfo PHP extension is |
|
127 | - * available the MIME type will be fetched by the file's content. The |
|
128 | - * second parameter is optional and defines the magic file path. If you |
|
129 | - * skip it, the default one will be loaded. |
|
130 | - * If Fileinfo PHP extension is not available the MIME type will be fetched |
|
131 | - * by filename extension regarding $MIME property. If the file extension |
|
132 | - * does not exist there, returned type will be application/octet-stream |
|
133 | - * @param string $filename |
|
134 | - * @param string $magic |
|
135 | - * @return string */ |
|
126 | + /** Get MIME type of the given filename. If Fileinfo PHP extension is |
|
127 | + * available the MIME type will be fetched by the file's content. The |
|
128 | + * second parameter is optional and defines the magic file path. If you |
|
129 | + * skip it, the default one will be loaded. |
|
130 | + * If Fileinfo PHP extension is not available the MIME type will be fetched |
|
131 | + * by filename extension regarding $MIME property. If the file extension |
|
132 | + * does not exist there, returned type will be application/octet-stream |
|
133 | + * @param string $filename |
|
134 | + * @param string $magic |
|
135 | + * @return string */ |
|
136 | 136 | |
137 | 137 | static function getMimeType($filename, $magic=null) { |
138 | 138 | if (class_exists("finfo")) { |
@@ -149,26 +149,26 @@ discard block |
||
149 | 149 | return isset(self::$MIME[$ext]) ? self::$MIME[$ext] : "application/octet-stream"; |
150 | 150 | } |
151 | 151 | |
152 | - /** Get inexistant filename based on the given filename. If you skip $dir |
|
153 | - * parameter the directory will be fetched from $filename and returned |
|
154 | - * value will be full filename path. The third parameter is optional and |
|
155 | - * defines the template, the filename will be renamed to. Default template |
|
156 | - * is {name}({sufix}){ext}. Examples: |
|
157 | - * |
|
158 | - * file::getInexistantFilename("/my/directory/myfile.txt"); |
|
159 | - * If myfile.txt does not exist - returns the same path to the file |
|
160 | - * otherwise returns "/my/directory/myfile(1).txt" |
|
161 | - * |
|
162 | - * file::getInexistantFilename("myfile.txt", "/my/directory"); |
|
163 | - * returns "myfile.txt" or "myfile(1).txt" or "myfile(2).txt" etc... |
|
164 | - * |
|
165 | - * file::getInexistantFilename("myfile.txt", "/dir", "{name}[{sufix}]{ext}"); |
|
166 | - * returns "myfile.txt" or "myfile[1].txt" or "myfile[2].txt" etc... |
|
167 | - * |
|
168 | - * @param string $filename |
|
169 | - * @param string $dir |
|
170 | - * @param string $tpl |
|
171 | - * @return string */ |
|
152 | + /** Get inexistant filename based on the given filename. If you skip $dir |
|
153 | + * parameter the directory will be fetched from $filename and returned |
|
154 | + * value will be full filename path. The third parameter is optional and |
|
155 | + * defines the template, the filename will be renamed to. Default template |
|
156 | + * is {name}({sufix}){ext}. Examples: |
|
157 | + * |
|
158 | + * file::getInexistantFilename("/my/directory/myfile.txt"); |
|
159 | + * If myfile.txt does not exist - returns the same path to the file |
|
160 | + * otherwise returns "/my/directory/myfile(1).txt" |
|
161 | + * |
|
162 | + * file::getInexistantFilename("myfile.txt", "/my/directory"); |
|
163 | + * returns "myfile.txt" or "myfile(1).txt" or "myfile(2).txt" etc... |
|
164 | + * |
|
165 | + * file::getInexistantFilename("myfile.txt", "/dir", "{name}[{sufix}]{ext}"); |
|
166 | + * returns "myfile.txt" or "myfile[1].txt" or "myfile[2].txt" etc... |
|
167 | + * |
|
168 | + * @param string $filename |
|
169 | + * @param string $dir |
|
170 | + * @param string $tpl |
|
171 | + * @return string */ |
|
172 | 172 | |
173 | 173 | static function getInexistantFilename($filename, $dir=null, $tpl=null) { |
174 | 174 | if ($tpl === null) $tpl = "{name}({sufix}){ext}"; |