Rev 400 | Rev 446 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
236 | tom | 1 | <?php |
2 | |||
3 | require '../_taios.php'; |
||
4 | |||
238 | tom | 5 | function getImageSizes($sourceImageFilePath, $maxResizeWidth, $maxResizeHeight) { |
6 | |||
7 | $size = getimagesize($sourceImageFilePath); |
||
8 | $origWidth = $size[0]; |
||
9 | $origHeight = $size[1]; |
||
10 | |||
11 | $resizedWidth = $origWidth; |
||
12 | $resizedHeight = $origHeight; |
||
13 | |||
14 | if ($resizedWidth > $maxResizeWidth) |
||
15 | { |
||
16 | $aspectRatio = $maxResizeWidth / $resizedWidth; |
||
17 | $resizedWidth = round($aspectRatio * $resizedWidth); |
||
18 | $resizedHeight = round($aspectRatio * $resizedHeight); |
||
19 | } |
||
20 | if ($resizedHeight > $maxResizeHeight) |
||
21 | { |
||
22 | $aspectRatio = $maxResizeHeight / $resizedHeight; |
||
23 | $resizedWidth = round($aspectRatio * $resizedWidth); |
||
24 | $resizedHeight = round($aspectRatio * $resizedHeight); |
||
25 | } |
||
26 | |||
239 | tom | 27 | return array($resizedWidth, $resizedHeight); |
238 | tom | 28 | } |
29 | |||
236 | tom | 30 | $page = new Taios_Page('Photo Albums', '../'); |
31 | $page->drawHeader(); |
||
32 | $page->drawMiddle(); |
||
33 | |||
34 | $dirName = $_GET['dir']; |
||
35 | if (empty($dirName)) |
||
36 | { |
||
37 | $page->redirect('index.php'); |
||
38 | } |
||
39 | |||
242 | tom | 40 | write('<p class="bold"><a href="index.php">Back to Photos</a></p><br />'); |
241 | tom | 41 | |
329 | tom | 42 | if (file_exists("albums/" . $dirName . "/description.txt")) |
326 | tom | 43 | { |
330 | tom | 44 | write('<p>' . $page->replaceBBCode(file_get_contents("albums/" . $dirName . "/description.txt")) . '</p><br />'); |
326 | tom | 45 | } |
46 | |||
442 | tom | 47 | write('<p><a href="rss.php?dir=' . $dirName . '">RSS Feed</a></p>'); |
48 | |||
238 | tom | 49 | write('<table>'); |
50 | write('<tr>'); |
||
51 | |||
358 | tom | 52 | $directory = "albums/" . $dirName . "/"; |
357 | tom | 53 | $sortOrder = "newestFirst"; |
54 | |||
55 | $results = array(); |
||
56 | $handler = opendir($directory); |
||
57 | |||
58 | while ($file = readdir($handler)) |
||
59 | { |
||
60 | if ($file != '.' && $file != '..' && $file != "robots.txt" && $file != ".htaccess" && getimagesize($directory . $file)) |
||
61 | { |
||
62 | $currentModified = filectime($directory . $file); |
||
63 | $file_names[] = $file; |
||
64 | $file_dates[] = $currentModified; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | closedir($handler); |
||
69 | |||
70 | if ($sortOrder == "newestFirst") |
||
71 | { |
||
72 | arsort($file_dates); |
||
73 | } |
||
74 | else |
||
75 | { |
||
76 | asort($file_dates); |
||
77 | } |
||
78 | |||
79 | $file_names_Array = array_keys($file_dates); |
||
80 | foreach ($file_names_Array as $idx => $name) $name=$file_names[$name]; |
||
81 | $file_dates = array_merge($file_dates); |
||
82 | |||
83 | $i = 0; |
||
84 | |||
85 | $indexInArray = 0; |
||
238 | tom | 86 | $i = 0; |
87 | |||
357 | tom | 88 | foreach ($file_dates as $$file_dates) |
236 | tom | 89 | { |
357 | tom | 90 | $j = $file_names_Array[$indexInArray]; |
91 | $file = $file_names[$j]; |
||
92 | |||
93 | if ($i >= 3) |
||
327 | tom | 94 | { |
357 | tom | 95 | write('</tr><tr>'); |
96 | $i = 0; |
||
97 | } |
||
238 | tom | 98 | |
359 | tom | 99 | $filename = $directory . $file; |
400 | tom | 100 | $size = getImageSizes($filename, 280, 260); |
357 | tom | 101 | |
378 | tom | 102 | write('<td><a href="' . str_replace(" ", "%20", $filename) . '"><img width="' . $size[0] . '" height="' . $size[1] . '" src="' . str_replace(" ", "%20", $filename) . '" /></a></td>'); |
238 | tom | 103 | |
357 | tom | 104 | $i++; |
105 | $indexInArray++; |
||
236 | tom | 106 | } |
107 | |||
238 | tom | 108 | write('</tr>'); |
379 | tom | 109 | write('</table>'); |
238 | tom | 110 | |
236 | tom | 111 | $page->drawFooter(); |
112 | |||
113 | ?> |
||
114 |