--- /dev/null
+<?
+
+function fixFileSize($size) {
+ if (substr($size/1000,0,1) == '0') {
+ return $size.' bytes';
+ }
+ else {
+ return round($size/1000,2).' K';
+ }
+}
+
+
+$dirinfo = pathinfo(__FILE__);
+$dir = $dirinfo[dirname];
+$topdir = explode("/",$dir);
+$topdir = $topdir[count($topdir)-1];
+
+
+$handle = opendir($dir);
+while (false !== ($file = readdir($handle))) {
+ $files[] = $file;
+}
+sort($files);
+if (!isset($image)) {
+ srand((double)microtime()*1000000);
+ for ($i = 0; $i <= 10; $i++) {
+ $random = rand(0,10);
+ $image = $files[$random];
+ if (file_exists($image) && substr($image,-4) == '.jpg' || substr($image,-4) == '.png' || substr($image,-4) == '.gif') {
+ $good = 1;
+ break;
+ }
+ }
+}
+else {
+ if (file_exists($image) && substr($image,-4) == '.jpg' || substr($image,-4) == '.png' || substr($image,-4) == '.gif') {
+ $good = 1;
+ }
+}
+
+$output = '<head>
+<title>'.strtoupper('Index of /'.$topdir . (($good) ? " :: ". $image : "")).'</title>
+<style type="text/css">
+body {
+ margin:10px;
+ padding:10px;
+ vertical-align:top;
+ font-family:verdana,arial,helvetica,sans-serif;
+ font-size:9px;
+ color:black;
+}
+td {
+ vertical-align:top;
+ font-family:verdana,arial,helvetica,sans-serif;
+ font-size:9px;
+ color:black;
+ height:100%;
+ background-color:white;
+}
+a {
+ font-family:verdana,arial,helvetica,sans-serif;
+ font-size:9px;
+ color:#999999;
+ text-decoration:none;
+}
+a:hover {
+ font-family:verdana,arial,helvetica,sans-serif;
+ font-size:9px;
+ color:black;
+ text-decoration:underline;
+}
+h2 {
+ font-family:verdana,arial,helvetica,sans-serif;
+ font-size:12px;
+ color:black;
+ font-weight:bold;
+}
+</style>
+</head>
+<body style="padding-top:20px;padding-left:20px;">';
+
+$output .= '<h2>'.strtoupper('Index of /'.$topdir . (($good) ? " :: ". $image : "")).'</h2>';
+if ($good) {
+ $output .= '<p><img src="'.$image.'" /></p>';
+}
+$output .= '<table><tr><td>';
+foreach($files as $file) {
+ $firstchar = substr($file,0,1);
+ $extn = substr($file,-3);
+ $lastchar = substr($file,-1);
+ if ($firstchar != '.' && $firstchar != '~' && $firstchar != '#' && $lastchar != '~' && $lastchar != '#' && $extn != 'php'){
+ $usablefiles[] = $file;
+ }
+}
+
+$c = 1;
+$total = count($usablefiles);
+$max = round($total / 4);
+
+foreach($usablefiles as $file) {
+ $output .= '<a href="'.$PHP_SELF.'?image='.$file.'">'.$file.'</a> ('
+ .fixFileSize(filesize($file))
+ .')<br />'
+ ."\n";
+ if ($c == $max) {
+ $output .= '</td><td>';
+ $c = 0;
+ }
+ $c++;
+}
+$output .= '</td></tr></table>';
+
+echo $output;
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+// thumb.php - generates a thumbnail of an image. if no image exists, spits out a default.
+// $view - pathname to image to thumbnail.
+
+// set up some config variables
+if (empty($width)) $width = 72; // max width of thumb
+if (empty($height)) $height = 72; // max height of thumb
+
+// send the PNG header
+header('Content-type: image/png');
+// get old photo
+$extn = substr($view, -3);
+$view = '/var/www/wadda.org/htdocs/images/images/'.$view;
+switch($extn) {
+case 'jpg':
+$old = @ImageCreateFromJPEG($view);
+break;
+
+case 'png':
+$old = @ImageCreateFromPNG($view);
+break;
+}
+
+// check for no file
+if (!$old) {
+ $new = ImageCreate (80, 80); // Create a blank image
+ $bgc = ImageColorAllocate ($new, 216, 216, 216);
+ $tc = ImageColorAllocate ($new, 16, 16, 16);
+ ImageFilledRectangle ($new, 0, 0, 80, 80, $bgc);
+ /* Output an errmsg */
+ ImageString ($new, 1, 25, 30, "eek!", $tc);
+} else {
+ $old_x = ImageSX($old);
+ $old_y = ImageSY($old);
+
+ // make new thumbnail
+ if ($old_y > $old_x) {
+ $new_y = $height; // max height of thumb
+ $new_x = ($old_x * $new_y)/$old_y; // retain aspect ratio
+ } else {
+ $new_x = $width; // max width of thumb
+ $new_y = ($old_y * $new_x)/$old_x; // retain aspect ratio
+ }
+ $new = ImageCreateTrueColor($new_x, $new_y);
+ @ImageCopyResized($new, $old, 0, 0, 0, 0, $new_x, $new_y, $old_x, $old_y);
+}
+ImageInterlace($new);
+
+ImagePNG($new);
+?>
\ No newline at end of file