Rev 349 | Rev 358 | 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 | |||
238 | tom | 47 | write('<table>'); |
48 | write('<tr>'); |
||
49 | |||
357 | tom | 50 | $directory = "albums" . $dirName . "/"; |
51 | $sortOrder = "newestFirst"; |
||
52 | |||
53 | $results = array(); |
||
54 | $handler = opendir($directory); |
||
55 | |||
56 | while ($file = readdir($handler)) |
||
57 | { |
||
58 | if ($file != '.' && $file != '..' && $file != "robots.txt" && $file != ".htaccess" && getimagesize($directory . $file)) |
||
59 | { |
||
60 | $currentModified = filectime($directory . $file); |
||
61 | $file_names[] = $file; |
||
62 | $file_dates[] = $currentModified; |
||
63 | } |
||
64 | } |
||
65 | |||
66 | closedir($handler); |
||
67 | |||
68 | if ($sortOrder == "newestFirst") |
||
69 | { |
||
70 | arsort($file_dates); |
||
71 | } |
||
72 | else |
||
73 | { |
||
74 | asort($file_dates); |
||
75 | } |
||
76 | |||
77 | $file_names_Array = array_keys($file_dates); |
||
78 | foreach ($file_names_Array as $idx => $name) $name=$file_names[$name]; |
||
79 | $file_dates = array_merge($file_dates); |
||
80 | |||
81 | $i = 0; |
||
82 | |||
83 | /* //Loop through dates array and then echo the list |
||
84 | foreach ($file_dates as $$file_dates){ |
||
85 | $date = $file_dates; |
||
86 | $j = $file_names_Array[$i]; |
||
87 | $file = $file_names[$j]; |
||
88 | $i++; |
||
89 | |||
90 | echo "File name: $file - Date Added: $date. <br/>"; |
||
91 | }*/ |
||
92 | |||
93 | $indexInArray = 0; |
||
238 | tom | 94 | $i = 0; |
95 | |||
357 | tom | 96 | foreach ($file_dates as $$file_dates) |
236 | tom | 97 | { |
357 | tom | 98 | $j = $file_names_Array[$indexInArray]; |
99 | $file = $file_names[$j]; |
||
100 | |||
101 | if ($i >= 3) |
||
327 | tom | 102 | { |
357 | tom | 103 | write('</tr><tr>'); |
104 | $i = 0; |
||
105 | } |
||
238 | tom | 106 | |
357 | tom | 107 | $filename = 'albums/' . $dirName . '/' . $file; |
108 | $size = getImageSizes($filename, 300, 300); |
||
109 | |||
110 | write('<td><a href="' . $filename . '"><img width="' . $size[0] . '" height="' . $size[1] . '" src="' . $filename . '" /></a></td>'); |
||
238 | tom | 111 | |
357 | tom | 112 | $i++; |
113 | $indexInArray++; |
||
236 | tom | 114 | } |
115 | |||
238 | tom | 116 | write('</tr>'); |
117 | write('<table>'); |
||
118 | |||
236 | tom | 119 | $page->drawFooter(); |
120 | |||
121 | ?> |
||
122 |