annotate pics/common.php @ 11:ab0455f2a832

myrss/step1.xsl: parse only link rel="alternate" for Atom feeds
author paulo@twcdns.fastsearch.net
date Tue, 14 Sep 2010 23:32:09 -0700
parents 561c0b0f3234
children 8314130afe1d
rev   line source
paulo@0 1 <?php
paulo@0 2 $thumbs_dir = "thumbs/";
paulo@0 3 $browse_dir = "browse/";
paulo@0 4
paulo@0 5 function listThumbs($thumbs_dir) {
paulo@0 6 $dh = opendir($thumbs_dir);
paulo@0 7 if ($dh) {
paulo@0 8 while (($file = readdir($dh)) !== false) {
paulo@0 9 if (strncmp($file, ".", 1) != 0)
paulo@0 10 $files[] = $file;
paulo@0 11 }
paulo@0 12
paulo@0 13 sort($files, SORT_NUMERIC);
paulo@0 14 foreach ($files as $file)
paulo@5 15 echo '<A HREF="browse.php?id=' . $file . '" NAME="' . $file . '"><IMG SRC="' . $thumbs_dir . $file . '"></A> ' . "\n";
paulo@0 16
paulo@0 17 closedir($dh);
paulo@0 18 }
paulo@0 19 }
paulo@0 20
paulo@0 21 function browse($browse_dir, $thumbs_dir) {
paulo@0 22 include('../../../login.php');
paulo@0 23
paulo@0 24 $database = 'pauloang_pics';
paulo@0 25
paulo@0 26 $link = mysql_connect('localhost', $username, $password);
paulo@0 27 if (!$link)
paulo@0 28 die('Could not connect to MySQL server: ' . mysql_error());
paulo@0 29
paulo@0 30 $db_selected = mysql_select_db($database, $link);
paulo@0 31 if (!$db_selected)
paulo@0 32 die('Could not select database: ' . mysql_error());
paulo@0 33
paulo@0 34
paulo@0 35 foreach ($_GET as $getKey => $getValue) {
paulo@0 36 if ($getKey == "id" && !empty($_GET[$getKey])) {
paulo@0 37 $dh = opendir($browse_dir);
paulo@0 38 if ($dh) {
paulo@0 39 while (($file = readdir($dh)) !== false) {
paulo@0 40 if (strncmp($file, ".", 1) != 0)
paulo@0 41 $files[] = $file;
paulo@0 42 }
paulo@0 43 }
paulo@0 44 closedir($dh);
paulo@0 45
paulo@0 46 sort($files, SORT_NUMERIC);
paulo@0 47 for ($i = 0, $size = sizeof($files); $i < $size; $i++) {
paulo@0 48 if ($files[$i] == $getValue) {
paulo@0 49 if ($i > 0) {
paulo@5 50 echo '<A HREF="browse.php?id=' . $files[$i - 1] . '" accesskey="p">';
paulo@5 51 echo '<IMG SRC="' . $thumbs_dir . $files[$i - 1] . '">';
paulo@0 52 echo '</A>' . "\n";
paulo@0 53 }
paulo@0 54 if ($i < $size - 1) {
paulo@5 55 echo '<A HREF="browse.php?id=' . $files[$i + 1] . '" accesskey="n">';
paulo@5 56 echo '<IMG SRC="' . $thumbs_dir . $files[$i + 1] . '">';
paulo@0 57 echo '</A>' . "\n";
paulo@0 58 }
paulo@0 59 echo '<br>' . "\n";
paulo@5 60 echo '<A HREF="./index.php#' . $files[$i] . '">';
paulo@0 61 echo '<IMG SRC="' . $browse_dir . $files[$i] . '"> ';
paulo@0 62 echo '</A>' . "\n";
paulo@0 63
paulo@0 64 $query = 'SELECT * FROM '. basename(getcwd()) . ' WHERE id = "' . $getValue . '"';
paulo@0 65 $results = mysql_query($query);
paulo@0 66
paulo@0 67 if ($results) {
paulo@0 68 $row = mysql_fetch_assoc($results);
paulo@0 69 $caption = $row['caption'];
paulo@0 70 echo '<P>' . $caption . '</P>' . "\n";
paulo@0 71 }
paulo@0 72
paulo@0 73 break;
paulo@0 74 }
paulo@0 75 }
paulo@0 76 break;
paulo@0 77 }
paulo@0 78 }
paulo@0 79 }
paulo@0 80 ?>