Mercurial > hg > mgallery
annotate mgtool.php @ 53:4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 20 Jul 2016 04:39:56 +0300 |
parents | 5fbc443be538 |
children | 624c50e1b52d |
rev | line source |
---|---|
0 | 1 #!/usr/bin/php |
2 <?php | |
3 // | |
4 // Yet Another Image Gallery | |
5 // Commandline tool for creating / updating gallery | |
32 | 6 // (C) Copyright 2015-2016 Tecnic Software productions (TNSP) |
0 | 7 // |
8 require_once "mgallery.inc.php"; | |
9 | |
10 // | |
11 // Array for specifying what will be copied and converted | |
12 // from the image file's EXIF information tag(s). | |
13 // | |
45 | 14 $galExifConversions = |
15 [ | |
16 [ MG_STR, "caption" , "ImageDescription" ], | |
17 [ MG_STR, "copyright" , "Copyright" ], | |
18 [ MG_STR, "model" , "Model" ], | |
19 [ MG_INT, "width" , ["COMPUTED", "Width"] ], | |
20 [ MG_INT, "height" , ["COMPUTED", "Height"] ], | |
21 [ MG_DVA, "fnumber" , "FNumber" ], | |
22 [ MG_DVA, "exposure" , "ExposureTime" ], | |
23 [ MG_INT, "iso" , "ISOSpeedRatings" ], | |
24 [ MG_STR, "lensmodel" , "UndefinedTag:0xA434" ], | |
25 [ MG_DVA, "focallength" , "FocalLength" ], | |
26 [ MG_STR, "datetime" , "DateTimeOriginal" ], | |
27 [ MG_STR, "datetime" , "DateTimeDigitized" ], | |
28 [ MG_INT, "filesize" , "FileSize" ], | |
29 ]; | |
0 | 30 |
31 define("GCMD_UPDATE" , 1); | |
32 define("GCMD_RESCAN" , 2); | |
33 define("GCMD_CLEAN" , 3); | |
34 | |
35 define("GCLEAN_CACHES" , 0x01); | |
36 define("GCLEAN_THUMBNAILS", 0x02); | |
37 define("GCLEAN_ALL" , 0x0f); | |
38 | |
39 define("GUPD_MED_IMAGE" , 0x01); | |
40 define("GUPD_TN_IMAGE" , 0x02); | |
41 define("GUPD_IMAGES" , 0x0f); | |
42 define("GUPD_EXIF_INFO" , 0x10); | |
43 define("GUPD_CAPTION" , 0x20); | |
44 | |
45 | |
46 // | |
47 // Convert and scale image file function, for generating | |
48 // the intermediate size images and thumbnails. Uses the | |
49 // PHP ImageMagick bindings. | |
50 // | |
51 function mgConvertImage($inFilename, $outFilename, $outDim, $outFormat, $outQuality, $thumb) | |
52 { | |
53 // Create conversion entity | |
53
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
54 try |
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
55 { |
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
56 $img = new Imagick($inFilename); |
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
57 } |
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
58 catch (Exception $e) |
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
59 { |
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
60 return mgError("ImageMagick exception for file '".$inFilename."':\n".$e->getMessage()."\n"); |
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
61 } |
4c0a08b0ef65
Handle ImageMagick exceptions for loading input images.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
62 |
0 | 63 if ($img === FALSE) |
64 return mgError("ImageMagick could not digest the file '".$inFilename."'.\n"); | |
65 | |
51
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
66 $profiles = $img->getImageProfiles("icc", true); |
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
67 $img->setImageDepth(16); |
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
68 $img->transformImageColorspace(Imagick::COLORSPACE_SRGB); |
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
69 $img->setImageColorspace(Imagick::COLORSPACE_SRGB); |
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
70 |
0 | 71 if ($outDim !== FALSE) |
72 { | |
73 // Get dimensions, setup background | |
74 $dim = $img->getImageGeometry(); | |
75 //$img->setImageBackgroundColor(imagick::COLOR_BLACK); | |
76 $img->setGravity(imagick::GRAVITY_CENTER); | |
77 | |
78 | |
79 if ($dim["width"] < $dim["height"]) | |
80 { | |
81 $stmp = $outDim[0]; | |
82 $outDim[0] = $outDim[1]; | |
83 $outDim[1] = $stmp; | |
84 } | |
85 | |
86 if ($dim["width"] != $outDim[0] || $dim["height"] != $outDim[1]) | |
87 { | |
88 $outDim[1] = ($dim["height"] * $outDim[0]) / $dim["width"]; | |
89 } | |
90 | |
91 // Act based on image size vs. desired size and $thumb mode | |
92 if ($thumb || $dim["width"] > $outDim[0] || $dim["height"] > $outDim[1]) | |
93 { | |
94 // Image is larger | |
1
a07447c02b13
Use Lanczos filter for scaling instead of quadratic. Better quality and
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
95 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_LANCZOS, 1); |
0 | 96 $img->setImageExtent($outDim[0], $outDim[1]); |
51
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
97 // $img->normalizeImage(); |
0 | 98 $img->unsharpMaskImage(0, 0.5, 1, 0.05); |
99 } | |
100 if ($dim["width"] < $outDim[0] || $dim["height"] < $outDim[1]) | |
101 { | |
102 // Image is smaller than requested dimension(s)? | |
1
a07447c02b13
Use Lanczos filter for scaling instead of quadratic. Better quality and
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
103 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_LANCZOS, 1); |
0 | 104 $img->setImageExtent($outDim[0], $outDim[1]); |
51
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
105 // $img->normalizeImage(); |
0 | 106 $img->unsharpMaskImage(0, 0.5, 1, 0.05); |
107 } | |
108 } | |
109 | |
51
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
110 |
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
111 $img->setImageDepth(8); |
0 | 112 $img->setFormat($outFormat); |
113 $img->setCompressionQuality($outQuality); | |
51
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
114 |
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
115 $img->stripImage(); |
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
116 if (!empty($profiles)) |
549541f3e9c0
Possibly improve medium and thumbnail image generation by controlling Imagick components better.
Matti Hamalainen <ccr@tnsp.org>
parents:
46
diff
changeset
|
117 $img->profileImage("icc", $profiles["icc"]); |
0 | 118 |
119 $img->writeImage($outFilename); | |
120 $img->removeImage(); | |
121 return TRUE; | |
122 } | |
123 | |
124 | |
125 // | |
126 // Converts one value (mainly from EXIF tag information) | |
52 | 127 // by doing explicit type casting and special conversions. |
0 | 128 // |
129 function mgConvertExifData($val, $vtype) | |
130 { | |
131 switch ($vtype) | |
132 { | |
46
e58292065b01
Let arrays through mgConvertExifData() when the type is MG_STR without
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
133 case MG_STR: return is_array($val) ? $val : (string) $val; |
0 | 134 case MG_INT: return intval($val); |
135 case MG_BOOL: return intval($val); | |
136 case MG_DVA: | |
137 if (sscanf($val, "%d/%d", $v1, $v2) == 2) | |
138 { | |
139 if ($v1 < $v2) | |
140 return $val; | |
141 else | |
142 return sprintf("%1.1f", $v1 / $v2); | |
143 } | |
144 else | |
145 return $val; | |
146 | |
147 default: | |
148 return $val; | |
149 } | |
150 } | |
151 | |
152 | |
153 // | |
154 // Conditionally copies one "field" from an associated array/hash to another. | |
155 // If destination is already SET, nothing will be done. If source does | |
156 // not exist (e.g. one or more of the keys do not exist in source array), | |
157 // a default value will be used, if provided. | |
158 // Source may have multi-depth keys, destination has one key. | |
159 // | |
160 function mgCopyEntryData(&$dst, $src, $vtype, $dkey, $skeys, $default = NULL) | |
161 { | |
162 // Is destination already set? | |
163 if (isset($dst[$dkey])) | |
164 return FALSE; | |
165 | |
166 // If input key is not array, change it into one | |
167 if (!is_array($skeys)) | |
168 $skeys = array($skeys); | |
169 | |
170 // Traverse input array by using consequent keys | |
171 $tmp = &$src; | |
172 foreach ($skeys as $skey) | |
173 { | |
174 if (!array_key_exists($skey, $tmp)) | |
175 { | |
176 // Key didn't exist, try for default | |
177 if ($default !== NULL) | |
178 $dst[$dkey] = $default; | |
179 return FALSE; | |
180 } | |
181 else | |
182 $tmp = &$tmp[$skey]; | |
183 } | |
184 | |
185 // Optionally convert the input value | |
186 $dst[$dkey] = mgConvertExifData($tmp, $vtype); | |
187 return TRUE; | |
188 } | |
189 | |
190 | |
191 // | |
192 // Attempt to get gallery album data from various sources. | |
193 // | |
194 function mgGetAlbumData($galBasePath, $galPath) | |
195 { | |
196 // Check path permissions | |
197 $galData = array(); | |
198 if (is_readable($galPath)) | |
199 { | |
200 // First, try to read gallery/album info file | |
201 $filename = mgGetPath($galPath, "info_file"); | |
202 if ($filename !== FALSE && file_exists($filename)) | |
203 { | |
204 mgDebug("Reading INFOFILE: ".$filename."\n"); | |
205 if (($galData = parse_ini_file($filename, FALSE)) === FALSE) | |
206 $galData = array(); | |
207 } | |
208 | |
209 // Read header file, if any, and we don't have "header" field set yet | |
210 $filename = mgGetPath($galPath, "header_file"); | |
211 if ($filename !== FALSE && file_exists($filename) && | |
212 !isset($galData["header"])) | |
213 { | |
214 mgDebug("Reading HEADERFILE: ".$filename."\n"); | |
215 $galData["header"] = file_get_contents($filename); | |
216 } | |
217 | |
218 // Check for alternate key/values for album title/caption | |
219 if (isset($galData["title"]) && !isset($galData["caption"])) | |
220 { | |
221 $galData["caption"] = $galData["title"]; | |
222 unset($galData["title"]); | |
223 } | |
224 } | |
225 else | |
226 $galData["hide"] = TRUE; | |
227 | |
228 // If caption is not set, use last path component for | |
229 // a fallback value in case we don't discover proper title | |
230 // from other sources we can't check here yet. | |
231 $path = explode("/", $galPath); | |
232 $galData["fallback_caption"] = ucfirst(str_replace("_", " ", end($path))); | |
233 | |
234 // Last, store the current gallery path | |
235 $len = strlen($galBasePath); | |
236 if ($len < strlen($galPath) && substr($galPath, 0, $len) == $galBasePath) | |
237 $galData["path"] = substr($galPath, $len); | |
238 else | |
239 $galData["path"] = ""; | |
240 | |
241 return $galData; | |
242 } | |
243 | |
244 | |
245 function mgReadCaptionsFile($galBasePath, $galPath) | |
246 { | |
247 $captions = array(); | |
248 $filename = mgGetPath($galPath, "captions_file"); | |
249 if ($filename === FALSE || ($fp = @fopen($filename, "rb")) === FALSE) | |
250 return $captions; | |
251 | |
252 mgDebug("Reading CAPTIONS: ".$filename."\n"); | |
253 | |
254 // Read and parse data | |
255 while (!feof($fp)) | |
256 { | |
257 $str = trim(fgets($fp)); | |
258 // Ignore comments and empty lines | |
259 if ($str != "#" && $str != "") | |
260 { | |
11
0b097770061d
Improve content hiding functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
261 if (preg_match("/^([#%]?)\s*(\S+?)\s+(.+)$/", $str, $m)) |
45 | 262 $captions[$m[2]] = ["caption" => $m[3], "hide" => ($m[1] == "#"), "hide_contents" => ($m[1] == "%"), "used" => FALSE]; |
0 | 263 else |
11
0b097770061d
Improve content hiding functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
264 if (preg_match("/^([#%]?)\s*(\S+?)$/", $str, $m)) |
45 | 265 $captions[$m[2]] = ["hide" => ($m[1] == "#"), "hide_contents" => ($m[1] == "%"), "used" => FALSE]; |
0 | 266 } |
267 } | |
268 | |
269 fclose($fp); | |
270 return $captions; | |
271 } | |
272 | |
273 | |
274 function mgMakeDir($path, $perm) | |
275 { | |
276 if (!file_exists($path)) | |
277 { | |
278 if (mkdir($path, $perm, TRUE) === false) | |
279 return mgError("Could not create directory '".$path."'\n"); | |
280 } | |
281 return TRUE; | |
282 } | |
283 | |
284 | |
285 function mgYesNoPrompt($msg, $default = FALSE) | |
286 { | |
287 echo $msg." [".($default ? "Y/n" : "y/N")."]? "; | |
288 $sprompt = strtolower(trim(fgets(STDIN))); | |
289 | |
290 if ($default) | |
291 return ($sprompt == "n"); | |
292 else | |
293 return ($sprompt == "y"); | |
294 } | |
295 | |
296 | |
297 function mgDelete($path, $recurse) | |
298 { | |
299 global $flagDoDelete; | |
300 if (is_dir($path)) | |
301 { | |
302 if (($dirHandle = @opendir($path)) === FALSE) | |
303 return mgError("Could not read directory '".$path."'.\n"); | |
304 | |
305 while (($dirFile = @readdir($dirHandle)) !== FALSE) | |
306 { | |
307 if ($dirFile != "." && $dirFile != "..") | |
308 mgDelete($path."/".$dirFile, $recurse); | |
309 } | |
310 closedir($dirHandle); | |
311 | |
312 echo " - ".$path." [DIR]\n"; | |
313 if ($flagDoDelete) | |
314 rmdir($path); | |
315 } | |
316 else | |
317 { | |
318 if (!$recurse) | |
319 echo " - ".$path."\n"; | |
320 if ($flagDoDelete) | |
321 unlink($path); | |
322 } | |
323 } | |
324 | |
325 | |
326 function mgCheckQuit($now = FALSE) | |
327 { | |
328 global $flagQuit; | |
329 | |
330 // Dispatch pending signals | |
331 pcntl_signal_dispatch(); | |
332 | |
333 // Check result | |
334 if ($now && $flagQuit) | |
335 mgFatal("Quitting.\n"); | |
336 | |
337 return $flagQuit; | |
338 } | |
339 | |
340 | |
341 function mgNeedUpdate($entry, $field, $cvalue) | |
342 { | |
343 if (!array_key_exists($field, $entry)) | |
344 return TRUE; | |
345 | |
346 return ($entry[$field] < $cvalue); | |
347 } | |
348 | |
349 | |
30
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
350 function mgSortFunc($a, $b) |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
351 { |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
352 if (isset($a["datetime"]) && isset($b["datetime"])) |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
353 return strcmp($b["datetime"], $a["datetime"]); |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
354 else |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
355 return 0; |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
356 } |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
357 |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
358 |
16
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
359 function mgWriteGalleryCache($cacheFilename, &$gallery, &$entries, &$parentEntry) |
15
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
360 { |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
361 // Store gallery cache for this directory |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
362 $images = array(); |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
363 $albums = array(); |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
364 foreach ($entries as $ename => &$edata) |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
365 { |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
366 if ($edata["hide"]) |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
367 continue; |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
368 |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
369 unset($edata["hide"]); |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
370 if ($edata["type"] == 0) |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
371 $images[$ename] = &$edata; |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
372 else |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
373 $albums[$ename] = &$edata; |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
374 } |
30
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
375 |
f2c21a8b9071
Sort images in a folder by their capture timestamp.
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
376 uasort($images, "mgSortFunc"); |
37
99dc0843d7df
Fix sorting of albums to match image sorting.
Matti Hamalainen <ccr@tnsp.org>
parents:
35
diff
changeset
|
377 krsort($albums); |
15
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
378 |
16
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
379 // Choose gallery album image |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
380 if (count($images) > 0) |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
381 { |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
382 end($images); |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
383 $parentEntry["image"] = key($images); |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
384 } |
35
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
385 else |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
386 foreach ($albums as $aid => &$adata) |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
387 if (isset($adata["image"])) |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
388 { |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
389 $parentEntry["image"] = &$adata; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
390 break; |
985596db0f01
Implement recursive depth album covers.
Matti Hamalainen <ccr@tnsp.org>
parents:
32
diff
changeset
|
391 } |
16
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
392 |
15
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
393 $str = |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
394 "<?\n". |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
395 "\$galData = ".var_export($gallery, TRUE).";\n". |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
396 "\$galAlbumsIndex = ".var_export(array_keys($albums), TRUE).";\n". |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
397 "\$galImagesIndex = ".var_export(array_keys($images), TRUE).";\n". |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
398 "\$galEntries = ".var_export($entries, TRUE).";\n". |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
399 "?>"; |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
400 |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
401 if (@file_put_contents($cacheFilename, $str, LOCK_EX) === FALSE) |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
402 return mgError("Error writing '".$cacheFilename."'\n"); |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
403 |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
404 return TRUE; |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
405 } |
805f93962cf9
Factorize gallery cache file writing to a separate function.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
406 |
16
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
407 |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
408 function mgHandleDirectory($mode, $basepath, $path, &$parentData, &$parentEntry, $writeMode, $startAt) |
0 | 409 { |
410 global $galExifConversions, $galTNPath, $galCleanFlags; | |
411 | |
412 // Get cache file path | |
413 if (($cacheFilename = mgGetPath($path, "cache_file")) === FALSE) | |
414 return mgError("Cache filename / path not set.\n"); | |
415 | |
416 mgCheckQuit(TRUE); | |
417 | |
418 // Read directory contents | |
419 $entries = array(); | |
420 if (($dirHandle = @opendir($path)) === FALSE) | |
421 return mgError("Could not read directory '".$path."'.\n"); | |
422 | |
423 while (($dirFile = @readdir($dirHandle)) !== FALSE) | |
424 { | |
425 $realFile = $path."/".$dirFile; | |
426 if (is_dir($realFile)) | |
427 { | |
428 if ($dirFile[0] != "." && $dirFile != $galTNPath) | |
429 $entries[$dirFile] = array("type" => 1, "base" => $dirFile, "ext" => "", "mtime" => filemtime($realFile)); | |
430 } | |
431 else | |
6
405a02586fc2
Fix handling of image files that have spaces in filename (regexp used \S,
Matti Hamalainen <ccr@tnsp.org>
parents:
1
diff
changeset
|
432 if (preg_match("/^([^\/]+)(".mgGetSetting("format_exts").")$/i", $dirFile, $dirMatch)) |
0 | 433 $entries[$dirFile] = array("type" => 0, "base" => $dirMatch[1], "ext" => $dirMatch[2], "mtime" => filemtime($realFile), "hide" => false); |
434 } | |
435 closedir($dirHandle); | |
436 | |
437 mgCheckQuit(); | |
438 | |
439 // Cleanup mode | |
440 if ($mode == GCMD_CLEAN) | |
441 { | |
442 $gallery = array(); | |
443 | |
444 if ($writeMode) | |
445 { | |
446 if ($galCleanFlags & GCLEAN_CACHES) | |
447 mgDelete($cacheFilename, FALSE); | |
448 | |
449 if ($galCleanFlags & GCLEAN_THUMBNAILS) | |
450 mgDelete($path."/".$galTNPath, TRUE); | |
451 } | |
452 } | |
453 else | |
454 // Update modes | |
455 if ($mode == GCMD_UPDATE || $mode == GCMD_RESCAN) | |
456 { | |
457 // Load current cache file, if it exists | |
458 $galEntries = array(); | |
459 $cacheTime = -1; | |
460 if ($mode == GCMD_UPDATE && file_exists($cacheFilename)) | |
461 { | |
462 $cacheTime = filemtime($cacheFilename); | |
463 @include $cacheFilename; | |
464 } | |
465 | |
466 // Read caption data | |
467 $captions = mgReadCaptionsFile($basepath, $path); | |
468 $gallery = mgGetAlbumData($basepath, $path); | |
469 if ($parentData !== NULL && $parentEntry !== NULL) | |
470 { | |
16
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
471 $gallery["parent"] = &$parentData; |
0 | 472 mgCopyEntryData($gallery, $parentEntry, MG_STR, "caption", "caption"); |
473 } | |
474 | |
475 // Start actual processing | |
476 $nentries = count($entries); | |
477 $nentry = 0; | |
478 echo $path." .. "; | |
479 foreach ($entries as $ename => &$edata) | |
480 { | |
481 printf("\r%s (%1.1f%%) ..", $path, ($nentry * 100.0) / $nentries); | |
482 | |
483 $nentry++; | |
484 $efilename = $path."/".$ename; | |
485 | |
486 if (array_key_exists($ename, $galEntries)) | |
487 $galEntry = &$galEntries[$ename]; | |
488 else | |
489 $galEntry = array(); | |
490 | |
491 mgCheckQuit(FALSE); | |
492 | |
493 // Update with captions file data, if any | |
494 if (array_key_exists($ename, $captions)) | |
495 { | |
496 foreach ($captions[$ename] as $ckey => $cval) | |
497 $edata[$ckey] = $cval; | |
498 } | |
499 | |
500 // Handle entry based on type | |
501 if ($edata["type"] == 0) | |
502 { | |
503 $updFlags = 0; | |
504 $tnPath = $path."/".$galTNPath; | |
505 $medFilename = $tnPath."/".$edata["base"].mgGetSetting("med_suffix").$edata["ext"]; | |
506 $tnFilename = $tnPath."/".$ename; | |
507 $capFilename = $path."/".$edata["base"].".txt"; | |
508 | |
509 // Check what we need to update .. | |
510 if (!file_exists($medFilename) || filemtime($medFilename) < $edata["mtime"]) | |
511 $updFlags |= GUPD_MED_IMAGE; | |
512 | |
513 if (!file_exists($tnFilename) || filemtime($tnFilename) < $edata["mtime"]) | |
514 $updFlags |= GUPD_TN_IMAGE; | |
515 | |
516 if (mgNeedUpdate($galEntry, "mtime", $edata["mtime"])) | |
517 $updFlags |= GUPD_EXIF_INFO; | |
518 | |
519 if (file_exists($capFilename) && | |
520 mgNeedUpdate($galEntry, "mtime", filemtime($capFilename))) | |
521 $updFlags |= GUPD_CAPTION; | |
522 | |
523 // Check for EXIF info | |
524 if (($updFlags & GUPD_EXIF_INFO) && | |
525 ($exif = @exif_read_data($efilename)) !== FALSE) | |
526 { | |
527 echo "%"; | |
528 foreach ($galExifConversions as $conv) | |
529 mgCopyEntryData($edata, $exif, $conv[0], $conv[1], $conv[2]); | |
530 } | |
531 else | |
532 { | |
533 // Copy old data that is not yet in new | |
534 echo "*"; | |
535 foreach ($galEntry as $okey => $odata) | |
536 { | |
537 if (!array_key_exists($okey, $edata)) | |
538 $edata[$okey] = $odata; | |
539 } | |
540 } | |
541 | |
542 // Generate thumbnails, etc. | |
543 if ($updFlags & GUPD_IMAGES) | |
544 { | |
545 mgMakeDir($tnPath, 0755); | |
546 | |
547 if ($updFlags & GUPD_MED_IMAGE) | |
548 { | |
549 echo "1"; | |
550 mgConvertImage($efilename, $medFilename, | |
551 array(mgGetSetting("med_width"), mgGetSetting("med_height")), | |
552 "JPEG", mgGetSetting("med_quality"), TRUE); | |
553 } | |
554 | |
555 if ($updFlags & GUPD_TN_IMAGE) | |
556 { | |
557 echo "2"; | |
558 mgConvertImage($efilename, $tnFilename, | |
559 array(mgGetSetting("tn_width"), mgGetSetting("tn_height")), | |
560 "JPEG", mgGetSetting("tn_quality"), TRUE); | |
561 } | |
562 } | |
563 | |
564 // Check for .txt caption file | |
565 if ($updFlags & GUPD_CAPTION) | |
566 { | |
567 echo "?"; | |
568 if (($tmpData = @file_get_contents($capFilename)) !== FALSE) | |
569 $edata["caption"] = $tmpData; | |
570 } | |
571 } | |
572 else | |
573 if ($edata["type"] == 1) | |
574 { | |
10 | 575 // Set some of the album data here |
0 | 576 $tmp = mgGetAlbumData($basepath, $efilename); |
577 mgCopyEntryData($edata, $tmp, MG_STR, "caption", "caption"); | |
578 mgCopyEntryData($edata, $tmp, MG_STR, "caption", "fallback_caption"); | |
579 mgCopyEntryData($edata, $tmp, MG_STR, "caption", "title"); | |
580 mgCopyEntryData($edata, $tmp, MG_BOOL, "hide", "hide", FALSE); | |
11
0b097770061d
Improve content hiding functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
581 mgCopyEntryData($edata, $tmp, MG_BOOL, "hide_contents", "hide_contents", FALSE); |
0 | 582 } |
583 } | |
584 | |
585 echo "\r".$path." ..... DONE\n"; | |
586 | |
587 mgCheckQuit(TRUE); | |
588 } | |
589 else | |
590 mgFatal("Invalid work mode '".$mode."'.\n"); | |
591 | |
592 mgCheckQuit(TRUE); | |
593 | |
594 // Recurse to subdirectories | |
9
232086da1670
Fix generating of sub-album/dirs names without gallery.info to specify
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
595 foreach ($entries as $ename => &$edata) |
0 | 596 if ($edata["type"] == 1) |
597 { | |
598 $epath = $path."/".$ename."/"; | |
599 $newWriteMode = ($writeMode === FALSE && $epath == $startAt) || $writeMode; | |
600 | |
601 if (!mgHandleDirectory($mode, $basepath, $epath, $gallery, $edata, $newWriteMode, $startAt)) | |
602 return FALSE; | |
603 } | |
604 | |
16
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
605 // Finish update modes |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
606 if ($mode == GCMD_UPDATE || $mode == GCMD_RESCAN) |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
607 { |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
608 // Store gallery cache for this directory |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
609 if ($writeMode && !mgWriteGalleryCache($cacheFilename, $gallery, $entries, $parentEntry)) |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
610 return FALSE; |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
611 } |
3491ab93630e
Add sub-gallery thumbnails to gallery cache data.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
612 |
0 | 613 mgCheckQuit(TRUE); |
614 | |
615 return TRUE; | |
616 } | |
617 | |
618 | |
619 function mgSigHandler($signo) | |
620 { | |
621 global $flagQuit; | |
622 switch ($signo) | |
623 { | |
624 case SIGTERM: | |
625 mgFatal("Received SIGTERM.\n"); | |
626 break; | |
627 | |
628 case SIGQUIT: | |
629 case SIGINT: | |
630 $flagQuit = TRUE; | |
631 break; | |
632 | |
633 } | |
634 } | |
635 | |
636 | |
637 function mgProcessGalleries($cmd, $path) | |
638 { | |
639 global $galTNPath; | |
640 | |
641 // Fetch the settings we need | |
642 if (mgReadSettings() === FALSE) | |
643 die("MGallery not configured.\n"); | |
644 | |
645 // Check validity of some settings | |
646 $galPath = mgGetSetting("base_path"); | |
647 $galTNPath = mgCleanPath(TRUE, mgGetSetting("tn_path")); | |
648 if ($galTNPath != mgGetSetting("tn_path")) | |
649 mgError("Invalid tn_path, using '".$galTNPath."'.\n"); | |
650 | |
651 if (strpos($galTNPath, "/") !== FALSE || $galTNPath == "") | |
652 mgFatal("Invalid tn_path '".$galTNPath."'.\n"); | |
653 | |
654 $parentData = $parentEntry = NULL; | |
655 $writeMode = TRUE; | |
656 $startAt = NULL; | |
657 | |
658 // Check for path argument | |
659 if ($path !== FALSE) | |
660 { | |
661 // Check the given path, needs to be "under" the gallery path | |
662 $cmp = mgCleanPath(TRUE, mgRealPath($galPath))."/"; | |
663 $tmp = mgCleanPath(TRUE, mgRealPath($path))."/"; | |
664 if (substr($tmp, 0, strlen($cmp)) != $cmp) | |
665 mgFatal("Path '".$path."' ('".$tmp."') does not reside under '".$galPath."' ('".$cmp."')!\n"); | |
666 | |
667 // Check if we need to bootstrap | |
668 if ($cmp != $tmp) | |
669 { | |
670 $bpath = mgCleanPath(TRUE, mgRealPath($tmp."../")); | |
671 | |
672 if ($cmd != GCMD_CLEAN) | |
673 { | |
674 $cacheFile = mgGetPath($bpath, "cache_file"); | |
675 if (!file_exists($cacheFile)) | |
676 mgFatal("Can't start working from '".$path."', parent '".$cacheFile."' does not exist!\n"); | |
677 | |
678 @include($cacheFile); | |
679 if (!isset($galEntries) || !isset($galData)) | |
680 mgFatal("Cache file '".$cacheFile."' is broken or stale.\n"); | |
681 } | |
682 | |
683 $writeMode = FALSE; | |
684 $startAt = $tmp; | |
685 $path = $bpath; | |
686 | |
687 echo "Starting: '".$startAt."' inside '".$path."'.\n"; | |
688 } | |
689 else | |
690 $path = $tmp; | |
691 } | |
692 else | |
693 $path = $galPath; | |
694 | |
695 // Start working | |
696 echo "Gallery path: '".$galPath."', starting at '".$path."' ...\n"; | |
697 mgHandleDirectory($cmd, $galPath, $path, $parentData, $parentEntry, $writeMode, $startAt); | |
698 } | |
699 | |
700 | |
701 function mgShowCopyright() | |
702 { | |
703 global $mgProgVersion, $mgProgCopyright, | |
704 $mgProgInfo, $mgProgEmail; | |
705 | |
706 echo | |
707 "MGTool ".$mgProgVersion." - MGallery management tool\n". | |
708 $mgProgInfo." ".$mgProgEmail."\n". | |
709 "(C) Copyright ".$mgProgCopyright."\n"; | |
710 } | |
711 | |
712 | |
713 function mgShowHelp() | |
714 { | |
715 global $argv; | |
716 echo | |
717 "Usage: ".basename($argv[0])." <command> [arguments]\n". | |
718 "\n". | |
719 " --help - Show this help.\n". | |
720 " --version - Show version information.\n". | |
721 "\n". | |
722 " update [path]\n". | |
723 " Update directories under <path> or all gallery dirs.\n". | |
724 " Conditionally scans dirs for new or changed images and\n". | |
725 " updates cache files as needed.\n". | |
726 "\n". | |
727 " rescan [path]\n". | |
728 " Like 'update', but forces all cache files to be regenerated\n". | |
729 " and EXIF/caption/etc information to be re-scanned even\n". | |
730 " if the file timestamps do not justify re-scanning.\n". | |
731 "\n". | |
732 " clean <all|caches|thumbnails> [path]\n". | |
733 " Delete all generated files or selectively cache files or\n". | |
734 " everything inside thumbnail directories.\n". | |
735 "\n". | |
736 " config\n". | |
737 " Display configuration values.\n". | |
738 "\n"; | |
739 } | |
740 | |
741 | |
742 // | |
743 // Main code starts | |
744 // | |
745 if (php_sapi_name() != "cli" || !empty($_SERVER["REMOTE_ADDR"])) | |
746 { | |
747 header("Status: 404 Not Found"); | |
748 die(); | |
749 } | |
750 | |
751 pcntl_signal(SIGTERM, "mgSigHandler"); | |
752 pcntl_signal(SIGHUP, "mgSigHandler"); | |
753 pcntl_signal(SIGQUIT, "mgSigHandler"); | |
754 pcntl_signal(SIGINT, "mgSigHandler"); | |
755 | |
756 | |
757 $cmd = mgCArgLC(1); | |
758 switch ($cmd) | |
759 { | |
760 case "--version": | |
761 case "version": | |
762 case "ver": | |
763 mgShowCopyright(); | |
764 break; | |
765 | |
766 case FALSE: | |
767 // No arguments | |
768 mgError("Nothing to do. Showing help:\n"); | |
769 | |
770 case "--help": | |
771 case "help": | |
772 if ($cmd !== FALSE) | |
773 mgShowCopyright(); | |
774 mgShowHelp(); | |
775 break; | |
776 | |
777 case "update": case "up": case "upd": case "upda": | |
778 mgProcessGalleries(GCMD_UPDATE, mgCArg(2)); | |
779 break; | |
780 | |
781 case "rescan": case "re": case "res": | |
782 mgProcessGalleries(GCMD_RESCAN, mgCArg(2)); | |
783 break; | |
784 | |
785 case "clean": case "cl": case "cle": | |
786 $cmode = mgCArgLC(2, 2); | |
787 switch ($cmode) | |
788 { | |
789 case "al": $galCleanFlags = GCLEAN_ALL; break; | |
790 case "ca": $galCleanFlags = GCLEAN_CACHES; break; | |
791 case "th": $galCleanFlags = GCLEAN_THUMBNAILS; break; | |
792 case FALSE: | |
793 mgFatal("Cleaning requires a mode argument.\n"); | |
794 | |
795 default: | |
796 mgFatal("Invalid clean mode '".mgCArg(2)."'.\n"); | |
797 } | |
798 $flagDoDelete = FALSE; | |
799 mgProcessGalleries(GCMD_CLEAN, mgCArg(3)); | |
800 echo "--\n"; | |
801 if (mgYesNoPrompt("Really delete the above files and directories?")) | |
802 { | |
25
c698618e6f67
Actually implement deletion.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
803 echo "Deleting ...\n"; |
c698618e6f67
Actually implement deletion.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
804 $flagDoDelete = TRUE; |
c698618e6f67
Actually implement deletion.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
805 mgProcessGalleries(GCMD_CLEAN, mgCArg(3)); |
c698618e6f67
Actually implement deletion.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
806 } |
c698618e6f67
Actually implement deletion.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
807 else |
c698618e6f67
Actually implement deletion.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
808 { |
c698618e6f67
Actually implement deletion.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
809 echo "Okay, canceling operation.\n"; |
0 | 810 } |
811 break; | |
812 | |
813 case "config": | |
814 case "dump": | |
815 if (mgReadSettings() === FALSE) | |
816 die("MGallery not configured.\n"); | |
817 | |
818 foreach ($mgDefaults as $key => $dval) | |
819 { | |
820 $sval = mgGetSetting($key); | |
26 | 821 if ($cmd == "dump") |
822 { | |
823 printf("%-20s = %s\n", $key, mgGetDValStr($dval[0], $sval)); | |
824 } | |
825 else | |
826 { | |
827 printf("%-20s = %s%s\n", | |
828 $key, | |
829 mgGetDValStr($dval[0], $sval), | |
830 ($dval[1] !== NULL && $sval !== $dval[1]) ? " (default: ".mgGetDValStr($dval[0], $dval[1]).")" : ""); | |
831 } | |
0 | 832 } |
833 break; | |
834 | |
835 default: | |
836 mgError("Unknown option/command '".$cmd."'.\n"); | |
837 break; | |
838 } | |
839 | |
840 ?> |