X-Git-Url: http://positon.org/gitweb/?p=bizou.git;a=blobdiff_plain;f=index.php;h=846c7aedbe7bd7fc1df8dbe1a9bbb6ffe2e51317;hp=7c9b46274f571d05f4d97a05de39ef03177e4512;hb=7d72e379b104d72addf1b1feafbf1385f8fa21b8;hpb=205e0526554aaac5089ca353e5d4e708f2e0e635 diff --git a/index.php b/index.php index 7c9b462..846c7ae 100644 --- a/index.php +++ b/index.php @@ -48,6 +48,29 @@ function getImageLink($imageSimplePath) } } +// functions to display a "progress page" when thumbs are generating +function beginGenerating () +{ + if (! isset($GLOBALS["generating"])) { + echo "

If you get: \"Fatal error: Maximum execution time exceeded\", refresh this page.
Please wait while generating thumbnails:

\n"; + ob_flush(); flush(); + $GLOBALS["generating"] = true; + } +} +function displayGenerated($thumbFile) +{ + if (isset($GLOBALS["generating"])) { + echo basename($thumbFile)."\n"; + ob_flush(); flush(); + } +} +function endGenerating() { + if (isset($GLOBALS["generating"])) { + echo "

Finished. This page will be refreshed.

\n"; + exit(); + } +} + function getPreview($imgFile, $maxSize = THUMB_SIZE) { # example: data/myalbum/100.mypic.jpg @@ -55,6 +78,11 @@ function getPreview($imgFile, $maxSize = THUMB_SIZE) if (! is_file($newImgFile)) { + beginGenerating(); + + # reset script time limit to 20s (wont work in safe mode) + set_time_limit(20); + $ext = strtolower(substr($imgFile, -4)); if ($ext == ".jpg") $img = imagecreatefromjpeg($imgFile); @@ -94,6 +122,8 @@ function getPreview($imgFile, $maxSize = THUMB_SIZE) imagedestroy($img); imagedestroy($newImg); + + displayGenerated($newImgFile); } return $GLOBALS['rootUrl'].$newImgFile; @@ -156,6 +186,8 @@ foreach (scandir($realDir) as $file) if ($file != '.' and $file != '..') } } +endGenerating(); + if (dirname($simplePath) !== '') $parentLink = $scriptUrl.dirname($simplePath); else