paulo@0: <?php paulo@0: $thumbs_dir = "thumbs/"; paulo@0: $browse_dir = "browse/"; paulo@0: paulo@0: function listThumbs($thumbs_dir) { paulo@0: $dh = opendir($thumbs_dir); paulo@0: if ($dh) { paulo@0: while (($file = readdir($dh)) !== false) { paulo@0: if (strncmp($file, ".", 1) != 0) paulo@0: $files[] = $file; paulo@0: } paulo@0: paulo@0: sort($files, SORT_NUMERIC); paulo@0: foreach ($files as $file) paulo@5: echo '<A HREF="browse.php?id=' . $file . '" NAME="' . $file . '"><IMG SRC="' . $thumbs_dir . $file . '"></A> ' . "\n"; paulo@0: paulo@0: closedir($dh); paulo@0: } paulo@0: } paulo@0: paulo@0: function browse($browse_dir, $thumbs_dir) { paulo@0: include('../../../login.php'); paulo@0: paulo@0: $database = 'pauloang_pics'; paulo@0: paulo@0: $link = mysql_connect('localhost', $username, $password); paulo@0: if (!$link) paulo@0: die('Could not connect to MySQL server: ' . mysql_error()); paulo@0: paulo@0: $db_selected = mysql_select_db($database, $link); paulo@0: if (!$db_selected) paulo@0: die('Could not select database: ' . mysql_error()); paulo@0: paulo@0: paulo@0: foreach ($_GET as $getKey => $getValue) { paulo@0: if ($getKey == "id" && !empty($_GET[$getKey])) { paulo@0: $dh = opendir($browse_dir); paulo@0: if ($dh) { paulo@0: while (($file = readdir($dh)) !== false) { paulo@0: if (strncmp($file, ".", 1) != 0) paulo@0: $files[] = $file; paulo@0: } paulo@0: } paulo@0: closedir($dh); paulo@0: paulo@0: sort($files, SORT_NUMERIC); paulo@0: for ($i = 0, $size = sizeof($files); $i < $size; $i++) { paulo@0: if ($files[$i] == $getValue) { paulo@0: if ($i > 0) { paulo@25: echo '<A HREF="browse.php?id=' . $files[$i - 1] . '" ID="prev" accesskey="p">'; paulo@5: echo '<IMG SRC="' . $thumbs_dir . $files[$i - 1] . '">'; paulo@0: echo '</A>' . "\n"; paulo@0: } paulo@0: if ($i < $size - 1) { paulo@25: echo '<A HREF="browse.php?id=' . $files[$i + 1] . '" ID="next" accesskey="n">'; paulo@5: echo '<IMG SRC="' . $thumbs_dir . $files[$i + 1] . '">'; paulo@0: echo '</A>' . "\n"; paulo@0: } paulo@0: echo '<br>' . "\n"; paulo@25: echo '<A HREF="./index.php#' . $files[$i] . '" ID="up" accesskey="u">'; paulo@0: echo '<IMG SRC="' . $browse_dir . $files[$i] . '"> '; paulo@0: echo '</A>' . "\n"; paulo@0: paulo@0: $query = 'SELECT * FROM '. basename(getcwd()) . ' WHERE id = "' . $getValue . '"'; paulo@0: $results = mysql_query($query); paulo@0: paulo@0: if ($results) { paulo@0: $row = mysql_fetch_assoc($results); paulo@0: $caption = $row['caption']; paulo@0: echo '<P>' . $caption . '</P>' . "\n"; paulo@0: } paulo@0: paulo@0: break; paulo@0: } paulo@0: } paulo@0: break; paulo@0: } paulo@0: } paulo@0: } paulo@0: ?>