4 // // Based on code taken from Teri Solow - http://terisolow.com/source.php?url=/photoblog.php
6 // // include('comments.php');
8 // the code for printing/adding comments is
9 // basically straight from my picture script:
10 // http://www.terisolow.com/programs.php#PHP-pics
18 include $serverroot."/header.shtml";
19 // connect to database and get picture information
24 function show_image($imagename, $imagearray) {
25 global $home, $serverroot, $PHP_SELF, $HTTP_POST_VARS, $HTTP_SERVER_VARS, $banned, $table;
26 $img_data = $imagearray[$imagename];
27 $img_size = getimagesize($serverroot.$home."camblog/".$img_data['file']);
28 $width = $img_size[0];
29 $height = $img_size[1];
31 if ($width>$width_scale) {
32 $ratio = $width/$width_scale;
33 $width = $width_scale;
34 $height = round($height/$ratio);
36 $images = array_keys($imagearray);
38 foreach ($images as $image) {
46 if ($image == $imagename) {
59 print "<hr align=\"center\" size=\"2\" width=\"95%\" noshade=\"noshade\" />
60 <center><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"90%\"><tr><td align=\"left\" width=\"33%\">
61 <a class=\"inflate\" href=\"$HTTP_SERVER_VARS[PHP_SELF]?image=$prev\"><-- previous</a>
63 <td align=\"center\" width=\"34%\"><a href=\"$HTTP_SERVER_VARS[PHP_SELF]\">back</a></td>
64 <td align=\"right\" width=\"33%\">
65 <a class=\"inflate\" href=\"$HTTP_SERVER_VARS[PHP_SELF]?image=$next\">next --></a>
66 </td></tr></table></center>
69 <img src=\"$home./camblog/".$img_data['file']."\" border=\"0\" width=\"$width\" height=\"$height\" alt=\"".$img_data['file']."\" />
70 <br /><em class=\"date\">".$img_data['date']."</em><br />
71 <strong>".$img_data['subject']."</strong>
73 <p style=\"margin: 10px 40px 10px 40px\">\n";
74 print $img_data['description'];
75 print "</p><br />\n\n";
77 // $notify = show_comments($img_data['file'], $table);
78 // comment_form($img_data['file'], $table, $notify);
81 function show_all($imagearray, $page) {
82 global $HTTP_SERVER_VARS, $home, $serverroot, $table, $picsperpage;
84 // given page number and number of pics per page, find starting and
88 $end = $start+$picsperpage;
91 $start = $page*$picsperpage;
92 if ($start > count($imagearray)) {
94 $end = $start+$picsperpage;
97 $end = $start+$picsperpage;
100 // find out how many pages there are
101 $numpages = ceil(count($imagearray)/$picsperpage);
102 print "<hr align=\"center\" size=\"2\" width=\"95%\" noshade=\"noshade\" />
106 <p>These pictures were taken with my mobile phone.</p>
111 print "<div class=\"hr\">
112 <p class=\"leftside\">photo tekniklog</p>
113 <p class=\"rightside\">".count($imagearray)." images; $picsperpage images/page; page ";
115 print "/".$numpages."</p>
116 <div style=\"clear: both;\"></div></div>\n\n";
118 print "<div style=\"float: left; align: left;\">";
121 print "<a href=\"$HTTP_SERVER_VARS[PHP_SELF]?page=$last\"><<</a>";
123 print "</div>\n<div style=\"float: right; align: right;\">";
124 if ($page<$numpages-1) {
126 print "<a href=\"$HTTP_SERVER_VARS[PHP_SELF]?page=$next\">>></a>";
128 print "</div>\n<div style=\"clear: both;\"></div>";
130 print "<div style=\"text-align: center; margin: 0px 50px 0px 50px;\">
131 <br clear=\"all\" />\n\n";
134 foreach ($imagearray as $image) {
135 if (($curr>=$start)&&($curr<$end)) {
136 $thumbname = "/Pictures/camblog/tiny".$image['file'];
138 // $comments = num_comments($image['file'], $table);
139 //if ($comments==0) {
140 //$nocomments = "No comments";
142 //else if ($comments==1) {
143 //$nocomments = "One comment";
146 //$nocomments = "$comments comments";
149 print "<div class=\"thumbnail\" style=\"height: 140px\">
150 <a class=\"art\" href=\"$HTTP_SERVER_VARS[PHP_SELF]?image=".$image['file']."\"><img class=\"art\" src=\"$thumbname\" border=\"0\" width=\"125\" height=\"93\" alt=\"".$image['date']."\" title=\"".$image['date']." - $nocomments\" /></a><br />\n";
152 print "<span class=\"comment_notify\">$nocomments</span><br />";
154 print "$nocomments<br />";
156 print $image['date']."<br />";
157 print $image['subject'];
164 print "<br clear=\"all\" />\n";
167 print "<div style=\"font-size: x-small; text-align: center; font-family: lucidatypewriter, clean, courier, monospace;\">";
168 print "<strong>~ Page ~</strong><br />\n";
169 for ($i = 0; $i < $numpages; $i++) {
174 print " <a href=\"$HTTP_SERVER_VARS[PHP_SELF]?page=$i\">$i</a> ";
181 function sanitize($input) {
182 $output = str_replace("<br />", "[br]", $input);
183 $output = htmlspecialchars($output, ENT_QUOTES);
184 $output = str_replace("[br]", " <br />\n", $input);
188 $workincludefile = $serverroot.$home."/camblog/index.txt";
189 $worklinearray = file($workincludefile);
190 $worklines = array_keys($worklinearray);
191 foreach ($worklines as $line) {
192 $element = explode("::", $worklinearray[$line]);
193 $thisfile = $element[0];
194 $thissubject = sanitize($element[1]);
195 $thisdesc = sanitize($element[2]);
196 $thisdate = date("M j Y H:i", substr($thisfile, 0, -4));
197 $images[$thisfile] = array("file"=>$thisfile, "subject"=>$thissubject, "description"=>$thisdesc, "date"=>$thisdate);
199 $images = array_reverse($images, TRUE);
200 $image = $HTTP_GET_VARS['image'];
201 $page = $HTTP_GET_VARS['page'];
202 if (empty($page)) { $page = 0; }
203 if (array_key_exists($image, $images)) {
204 show_image($image, $images);
206 show_all($images, $page);
209 include('../footer.php');