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