'_')); continue; } if (empty($current_key)) continue; $GLOBALS[$current_key] = $arg; } } $title = 'Untitled album'; $links = '
  • '; parse_cmd_parameters('disable-thumbs|source|destination|title|links'); if (empty($source)) die("You have to give source dir\n"); if (empty($destination)) $destination = $source; $enableThumbs = true; if (!empty($disable_thumbs)) $enableThumbs = false; // Length of the side list of thumbnais (when viewing an image) $thumblistLength = 4; // Copy images to out dir? $copyFiles = TRUE; if ($destination == $source) $copyFiles = false; // Template for viewing images $defaultTemplate = << #TITLE

    #TITLE

    #FILENAME

    #DESCRIPTION (#SIZE Ko)

    #THUMBNAILS
    EOF; // Template for index file $indexTemplate = << #TITLE

    #TITLE

    #DESCRIPTION (#SIZE Ko)

    #THUMBNAILS
    EOF; $defaultStyle = << $width, "height" => $height, "type" => $type); $fp = fopen($destination."/_".$file, "w"); fputs($fp, $thumb); fclose($fp); } } } // Generation of images pages reset($fileList); sort($fileList); $i = 0; foreach($fileList as $file) { // Getting some image informations $current = $source . "/" . $file; $imageInfo = getimagesize($current); $size = round(filesize($current) / 1000); if(array_key_exists($file, $descriptions)) $desc = $descriptions[$file]; else $desc = "--"; // Begin of strings to replace in the template $replaceStrings = array( "#TITLE" => htmlspecialchars($title), "#FILENAME" => $file, "#WIDTH" => $imageInfo[0], "#HEIGHT" => $imageInfo[1], "#TYPE" => $imageInfo[2], "#MIMETYPE" => $imageInfo['mime'], "#DESCRIPTION" => $desc, "#SIZE" => $size); // Generating thumbs mini-list $currentThumbs = '
      '; $start = $i - floor($thumblistLength / 2); $end = $i + ceil($thumblistLength / 2);; if($start < 0) { $end -= $start; $start = 0; } if($end >= count($fileList)) { $start -= $end - count($fileList) + 1; if($start < 0) $start = 0; $end = count($fileList) - 1; } for($j = $start; $j <= $end;$j++) { $cur = $fileList[$j]; $curname = substr($cur,0,strpos($cur,".")).".html"; if ($j == $i) { $currentThumbs.= '
    • '; if (isset($thumbs[$cur])) { $width = round($thumbs[$cur]['width'] / 2); $height = round($thumbs[$cur]['height'] / 2); } } else { $currentThumbs.= '
    • '; if (isset($thumbs[$cur])) { $width = $thumbs[$cur]['width']; $height = $thumbs[$cur]['height']; } } $currentThumbs.= ''; if($enableThumbs && isset($thumbs[$cur])) $currentThumbs.= ''.$cur.''; else $currentThumbs.= $cur; $currentThumbs.= "
    • \n"; } $currentThumbs.= '
    '; $replaceStrings['#THUMBNAILS'] = $currentThumbs; $template = strtr($defaultTemplate, $replaceStrings); $filename = substr($file,0,strpos($file,".")).".html"; $fp = fopen($destination."/".$filename,"w"); fputs($fp,$template); fclose($fp); if($copyFiles) copy($current, $destination."/".$file); $i++; } // Generation of index page reset($fileList); sort($fileList); $image = $source."/".$fileList[0]; $imageInfo = getimagesize($image); $size = round(filesize($image) / 1000); if(array_key_exists($fileList[0],$descriptions)) $desc = $descriptions[$fileList[0]]; else $desc = $title; $replaceStrings = array( "#TITLE" => htmlspecialchars($title), "#FILENAME" => $fileList[0], "#WIDTH" => $imageInfo[0], "#HEIGHT" => $imageInfo[1], "#TYPE" => $imageInfo[2], "#MIMETYPE" => $imageInfo['mime'], "#DESCRIPTION" => $desc, "#SIZE" => $size); $template = strtr($indexTemplate, $replaceStrings); $thumbList = ""; $template = str_replace("#THUMBNAILS",$thumbList,$template); $fp = fopen($destination."/index.html","w"); fputs($fp,$template); fclose($fp); file_put_contents($destination."/style.css", $defaultStyle); echo "Done.\n"; ?>