-
Notifications
You must be signed in to change notification settings - Fork 2
/
pics.php
156 lines (131 loc) · 3.76 KB
/
pics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
# TODO:
# - auto thumbnails
# - admin/upload page
# cofiguration variables
$pic_dir = 'pics';
$title = 'Pictures of Past Coastal Valley Lines Shows';
# header and sidebars
include 'header.html';
# figure out if we're viewing an album and adjust
$page = false;
if( isset($_GET["page"] ) ) {
if( file_exists("pics/".$_GET['page']) ) {
$page = $_GET['page'];
$pic_dir = "pics/".$page;
$title = "Sorry, no title for this album yet";
if( file_exists("$pic_dir/.index.txt") and
false !== ($fh = fopen("$pic_dir/.index.txt", "r")) ) {
$title = htmlentities(fgets($fh));
fclose($fh);
}
}
}
# figure out if we're viewing an album or an image
$img = false;
if( isset($_GET['img'])) {
if( file_exists("$pic_dir/".$_GET['img']) ) {
$img = $_GET['img'];
$img_path = "$pic_dir/$img";
}
}
# open our directory and get a listing
$files = array();
if( $dir = opendir($pic_dir) ) {
while( false !== ($file = readdir($dir))) {
if( ! preg_match('/^\./', $file) ) {
$files[] = $file;
}
}
closedir($dir);
}
# code here
?>
<div id="picture_content">
<h3><?
# page title here
print $title;
?></h3>
<div class='featurebox_center'>
<?
# if we're displaying an image, just do that
if( $img ) {
print "<div id=\"img_nav\">";
# It's a start. Still need to deal with resize/scaling issues
print "<img alt=\"\" src=\"$img_path\"/><br/>\n";
# TODO: next, previous, album links
# TODO: CSS center
# get our position in the array
$pos = array_search($img, $files);
# Link? to first image
if( $pos > 0 ) {
print "<a href=\"pics.php?page=$page&img=".$files[0]."\">";
}
print "<<First";
if( $pos > 0 ) {
print "</a>";
}
print " ";
# Link? to previous image
if( $pos > 0 ) {
print "<a href=\"pics.php?page=$page&img=".$files[$pos-1]."\">";
}
print "<Prev";
if( $pos > 0 ) print "</a>";
# Link to album
print " <a href=\"pics.php?page=$page\">Album</a> ";
# Link? to next
$next = false;
if( isset($files[$pos+1]) ) $next = $files[$pos+1];
if( $next ) {
print "<a href=\"pics.php?page=$page&img=$next\">";
}
print "Next>";
if( $next ) {
print "</a>";
}
print " ";
# Link? to last
if( $next ) {
print "<a href=\"pics.php?page=$page&img=".$files[count($files)-1]."\">";
}
print "Last>>";
if( $next ) print "</a>";
print "</div>\n";
} else {
$i = 0;
if( $page ) {
print "<table width=\"100%\"><tr>\n";
}
# display here
foreach($files as $file) {
if( $page ) {
if( $i % 3 == 0 and $i != 0 ) {
print "</tr><tr>\n";
}
print "<td width=\"33%\">";
print "<a href=\"pics.php?page=$page&img=$file\">";
print "<img alt=\"\" src=\"$pic_dir/thumbnails/$file\"/>";
print "</a></td>\n";
$i++;
} else {
$name = $file;
if( file_exists("$pic_dir/$file/.index.txt") and
($fh = fopen("$pic_dir/$file/.index.txt", "r") ) ) {
$name = htmlentities(fgets($fh));
fclose($fh);
}
print "<h2><a href=\"pics.php?page=$file\">$name</a></h2>\n";
}
}
if( $page ) {
print "</tr></table>\n";
}
}
?>
</div>
</div>
<?
# footer
include 'footer.html';
?>