Subversion Repositories taios

Rev

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