5 if (is_dir("plugins")) {
6 $plugins = scandir("plugins");
7 array_shift($plugins); array_shift($plugins); // remove . and ..
8 foreach ($plugins as $p) if (is_file("plugins/$p/functions.php"))
9 require "plugins/$p/functions.php";
12 function plugins_include($phpFile)
14 foreach ($GLOBALS['plugins'] as $p) if (is_file("plugins/$p/$phpFile"))
15 require "plugins/$p/$phpFile";
18 function getPathInfo()
20 $simplePath = $_SERVER["PATH_INFO"];
21 if ($simplePath == '/') $simplePath = '';
22 // extra security check to avoid /photos/index/../.. like urls, maybe useless but..
23 if (strpos($simplePath, '..') !== false) die(".. found in url");
28 if (! function_exists('getImageLink')) {
29 function getImageLink($imageSimplePath)
31 return $GLOBALS['rootUrl'].IMAGES_DIR.$imageSimplePath;
35 if (! function_exists('getPreview')) {
36 function getPreview($imgFile, $maxSize = THUMB_SIZE)
38 # example: data/myalbum/100.mypic.jpg
39 $newImgFile = DATA_DIR."/".dirname($imgFile)."/".$maxSize.".".basename($imgFile);
41 # if the preview is a symlink, image is already good sized
42 if (is_link($newImgFile)) return $imgFile;
44 if (! is_file($newImgFile))
46 # this tels the template to flush output after displaying previews
47 $GLOBALS["generating"] = true;
49 # reset script time limit to 20s (wont work in safe mode)
52 $ext = strtolower(substr($imgFile, -4));
54 $img = imagecreatefromjpeg($imgFile);
56 $img = imagecreatefrompng($imgFile);
60 # if the image is already small, make a symlink, and return it
61 if ($w <= $maxSize and $h <= $maxSize) {
63 symlink($imgFile, $newImgFile);
67 # config to allow group writable files
69 # create the thumbs directory recursively
70 if (! is_dir(dirname($newImgFile))) mkdir(dirname($newImgFile), 0777, true);
74 $newH = $h/($w/$maxSize);
76 $newW = $w/($h/$maxSize);
80 $newImg = imagecreatetruecolor($newW, $newH);
82 imagecopyresampled($newImg, $img, 0, 0, 0, 0, $newW, $newH, $w, $h);
85 imagejpeg($newImg, $newImgFile);
87 imagepng($newImg, $newImgFile);
90 imagedestroy($newImg);
97 function getAlbumPreview($dir)
99 $previewFile = DATA_DIR."/$dir/albumpreview";
101 if (is_file("$previewFile.jpg")) {
102 return "$previewFile.jpg";
103 } else if (is_file("$previewFile.empty")) {
105 } else if (is_file("$previewFile.png")) {
106 return "$previewFile.png";
108 # config to allow group writable files
110 # create the thumbs directory recursively
111 if (! is_dir(dirname($previewFile))) mkdir(dirname($previewFile), 0777, true);
113 // no preview: look for a preview in current dir, write it, return it
114 foreach (scandir($dir) as $file) if ($file[0] != '.') {
115 $ext = strtolower(substr($file, -4));
116 if ($ext == ".jpg" or $ext == ".png") {
117 $thumb = getPreview("$dir/$file");
118 copy($thumb, $previewFile.$ext);
119 return $previewFile.$ext;
120 } else if (is_dir("$dir/$file")) {
121 $subPreview = getAlbumPreview("$dir/$file");
123 $myPreview = dirname($previewFile)."/".basename($subPreview);
124 copy($subPreview, $myPreview);
130 // nothing found. create empty file
131 touch("$previewFile.empty");