Subversion Repositories taios

Rev

Rev 358 | Rev 376 | 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
 
358 tom 50
$directory = "albums/" . $dirName . "/";
357 tom 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
$indexInArray = 0;
238 tom 84
$i = 0;
85
 
357 tom 86
foreach ($file_dates as $$file_dates)
236 tom 87
{
357 tom 88
    $j = $file_names_Array[$indexInArray];
89
    $file = $file_names[$j];
90
 
91
    if ($i >= 3)
327 tom 92
    {
357 tom 93
        write('</tr><tr>');
94
        $i = 0;
95
    }
238 tom 96
 
359 tom 97
    $filename = $directory . $file;
357 tom 98
    $size = getImageSizes($filename, 300, 300);
99
 
100
    write('<td><a href="' . $filename . '"><img width="' . $size[0] . '" height="' . $size[1] . '" src="' . $filename . '" /></a></td>');
238 tom 101
 
357 tom 102
    $i++;
103
    $indexInArray++;
236 tom 104
}
105
 
238 tom 106
write('</tr>');
107
write('<table>');
108
 
236 tom 109
$page->drawFooter();
110
 
111
?>
112