Subversion Repositories taios

Rev

Rev 301 | Rev 327 | 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
 
326 tom 42
if (file_exists("description.txt"))
43
{
44
    write('<p>' . $page->replaceBBCode(file_get_contents("description.txt")) . '</p>');
45
}
46
 
238 tom 47
write('<table>');
48
write('<tr>');
49
 
50
$i = 0;
51
 
236 tom 52
$dir = dir('albums/' . $dirName);
53
while (($file = $dir->read()) !== false)
54
{
55
    if ($file[0] != '.')
56
    {
239 tom 57
        if ($i >= 4)
238 tom 58
        {
59
            write('</tr><tr>');
300 tom 60
            $i = 0;
238 tom 61
        }
62
 
63
        $filename = 'albums/' . $dirName . '/' . $file;
64
        $size = getImageSizes($filename, 200, 200);
65
 
301 tom 66
        write('<td><a href="' . $filename . '"><img width="' . $size[0] . '" height="' . $size[1] . '" src="' . $filename . '" /></a></td>');
238 tom 67
 
68
        $i++;
236 tom 69
    }
70
}
71
 
238 tom 72
write('</tr>');
73
write('<table>');
74
 
236 tom 75
$page->drawFooter();
76
 
77
?>
78