<html><head><title>Burning Well Uploads</title></head>
<body><h1>Browse for BurningWell Uploads</h1>
<?php
if ($_GET['sd'] == '') {
        $dh = opendir ('$$HOME$$/photos');
        while (($adir = readdir ($dh)) != false) {
                if (substr ($adir, 0, 3) == '200' &&
                 is_dir ('/home/leonb/photos/' . $adir)) {
                        $dirs[] = $adir;
                }
        }
        asort ($dirs);
        foreach ($dirs as $adir) {
                echo '<p><a href="./?sd=' . urlencode ($adir) . '">' .
                 $adir . "</a></p>\n";
        }
        closedir ($dh);
} else {
        echo '<h2>' . $_GET['sd'] . "</h2>\n";
        echo '<table border=0 cellspacing=0 cellpadding=5>';
        $td = 0;
        $dh = opendir ('$$HOME$$/photos/' . $_GET['sd']);
        while (($apic = readdir ($dh)) != false) {
                if (substr ($apic, -4) == '.jpg') {
                        $files[] = $apic;
                }
        }
        asort ($files);
        foreach ($files as $apic) {
                if ($td < 1) echo '<tr>';
                echo '<td><a href="addpic.phtml?d=';
                echo urlencode ($_GET['sd']) . '&p=' . urlencode ($apic);
                echo '" target=_blank><img border=0 alt=" "';
                echo ' src="thumb.phtml?d=' . urlencode ($_GET['sd']);
                echo '&p=' . urlencode ($apic);
                echo '"></a></td>' . "\n";
                ++ $td;
                if ($td > 3) {
                        echo "</tr>\n";
                        $td = 0;
                }
        }
        if ($td) {
                while ($td < 3) {
                        echo '<td> </td>';
                        ++ $td;
                }
                echo "</tr>\n";
        }
        closedir ($dh);
        echo '</table>';
}
?></body></html>