Subversion Repositories taios

Rev

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
 
32
$dirName = $_GET['dir'];
33
if (empty($dirName))
34
{
35
    $page->redirect('index.php');
36
}
37
 
446 tom 38
$page->drawHeader();
448 tom 39
write('<br /><h3>RSS</h3>');
40
$page->drawMenuItem('RSS Feed', 'photos/rss.php?dir=' . $dirName);
446 tom 41
$page->drawMiddle();
42
 
242 tom 43
write('<p class="bold"><a href="index.php">Back to Photos</a></p><br />');
241 tom 44
 
329 tom 45
if (file_exists("albums/" . $dirName . "/description.txt"))
326 tom 46
{
330 tom 47
    write('<p>' . $page->replaceBBCode(file_get_contents("albums/" . $dirName . "/description.txt")) . '</p><br />');
326 tom 48
}
49
 
238 tom 50
write('<table>');
51
write('<tr>');
52
 
358 tom 53
$directory = "albums/" . $dirName . "/";
357 tom 54
$sortOrder = "newestFirst";
55
 
56
$results = array();
57
$handler = opendir($directory);
58
 
59
while ($file = readdir($handler))
60
{
61
    if ($file != '.' && $file != '..' && $file != "robots.txt" && $file != ".htaccess" && getimagesize($directory . $file))
62
    {
63
           $currentModified = filectime($directory . $file);
64
           $file_names[] = $file;
65
           $file_dates[] = $currentModified;
66
    }    
67
}
68
 
69
closedir($handler);
70
 
71
if ($sortOrder == "newestFirst")
72
{
73
    arsort($file_dates);
74
}
75
else
76
{
77
    asort($file_dates);
78
}
79
 
80
$file_names_Array = array_keys($file_dates);
81
foreach ($file_names_Array as $idx => $name) $name=$file_names[$name];
82
$file_dates = array_merge($file_dates);
83
 
84
$i = 0;
85
 
86
$indexInArray = 0;
238 tom 87
$i = 0;
88
 
357 tom 89
foreach ($file_dates as $$file_dates)
236 tom 90
{
357 tom 91
    $j = $file_names_Array[$indexInArray];
92
    $file = $file_names[$j];
93
 
94
    if ($i >= 3)
327 tom 95
    {
357 tom 96
        write('</tr><tr>');
97
        $i = 0;
98
    }
238 tom 99
 
359 tom 100
    $filename = $directory . $file;
400 tom 101
    $size = getImageSizes($filename, 280, 260);
357 tom 102
 
378 tom 103
    write('<td><a href="' . str_replace(" ", "%20", $filename) . '"><img width="' . $size[0] . '" height="' . $size[1] . '" src="' . str_replace(" ", "%20", $filename) . '" /></a></td>');
238 tom 104
 
357 tom 105
    $i++;
106
    $indexInArray++;
236 tom 107
}
108
 
238 tom 109
write('</tr>');
379 tom 110
write('</table>');
238 tom 111
 
236 tom 112
$page->drawFooter();
113
 
114
?>
115