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