filename = $filename; if (eregi(".jpg$",$this->filename) || eregi(".jpeg$",$this->filename)) { if (!is_dir(THUMB_DIR)) { mkdir(THUMB_DIR,0775); } $thumb_path = THUMB_DIR."/".THUMB_PREFIX.$this->filename; if (!file_exists($thumb_path)) { $image = @imagecreatefromjpeg($this->filename); if ($image) { $this->valid = true; $this->height = @imagesy($image); $this->width = @imagesx($image); if (max($this->width,$this->height) > MAX_DIMENSION) { if ($this->width > $this->height) { $thumb_scale = MAX_DIMENSION / $this->width; } else { $thumb_scale = MAX_DIMENSION / $this->height; } $thumb_height = (int) ($this->height * $thumb_scale); $thumb_width = (int) ($this->width * $thumb_scale); $thumb_height = max($thumb_height, 1); $thumb_width = max($thumb_width, 1); $thumb_image = imagecreatetruecolor($thumb_width,$thumb_height); imagecopyresized($thumb_image,$image,0,0,0,0,$thumb_width,$thumb_height,$this->width,$this->height); imagejpeg($thumb_image,$thumb_path); } else { copy($this->filename,$thumb_path); } } else { $this->valid = false; } } else { $this->valid = true; } } } } function print_dir_links() { $url_root = "http://".$_SERVER["HTTP_HOST"]; $dirs = explode("/", dirname($_SERVER['PHP_SELF'])); echo "

".$_SERVER["SERVER_NAME"].""; $path = $url_root; for ($i = 1; $i < count($dirs) - 1; $i++) { $dir = $dirs[$i]; $path .= "/$dir"; echo "/$dir"; } echo "/".$dirs[count($dirs) - 1]."/

\n"; } function print_info($dir) { $info_file = $dir."/info"; if (is_file($info_file)) { $fp = fopen($info_file, "r"); if($fp) { echo fread($fp, filesize($info_file)); return true; } } return false; } function is_pic($file) { if (eregi(".jpg$", $file) || eregi(".jpeg$", $file) || eregi(".png$", $file)) { return true; } return false; } function display_pics() { if ($dir = opendir('.')) { while ($filename = readdir($dir)) { if (is_dir($filename) && $filename != "thumbs" && $filename != "captions" && $filename && $filename != "." && $filename != "..") { $directories[] = $filename; } else if (is_pic($filename)) { $images[$filename] = new image($filename); } } if (sizeof($directories) > 0) { usort($directories,strnatcmp); echo "\n"; echo "\n"; echo "\n"; echo "\n\n"; foreach ($directories as $directory) { echo "\n\n\n\n"; } echo "
albuminfo
\n"; echo "$directory/"; echo "\n"; if (!print_info($directory)) { echo " "; } echo "
"; } if (sizeof($images) > 0) { uksort($images,strnatcmp); echo "\n"; for ($i = 0; $i < NUM_COLUMNS; $i++) { echo "\n"; } $column = 1; foreach ($images as $image) { if ($column == 1) { echo "\n"; } if ($image->valid) { echo "\n"; if ($column == NUM_COLUMNS) { echo "\n"; $column = 1; } else { $column++; } } while ($column != 1 && $column <= NUM_COLUMNS) { echo "\n"; $column++; } echo "\n
filename\">filename\">
\n"; } else { echo "
error reading file
\n"; } echo "$image->filename"; $caption_path = "captions/$image->filename".".caption"; if (is_file($caption_path)) { $fp = fopen($caption_path, "r"); if($fp) { echo "
\n".fread($fp, filesize($caption_path)); } } echo "
 
\n"; } } else { echo "error reading directory\n"; } } echo "\n\n"; echo "\n"; echo "\n"; echo "\n\n\n
\n"; print_dir_links(); print_info("."); echo "
"; echo "
\n"; display_pics(); echo "
\n"; echo "\n"; echo "\n"; echo "\n\n\n
\n"; echo "up one level\n"; echo "
"; echo "\n"; ?>