| [ PHPXref.com ] | [ Generated: Sun Jul 20 20:03:19 2008 ] | [ Pixelpost 1.4.3 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 5 Pixelpost version 1.4.3 6 7 Pixelpost www: http://www.pixelpost.org/ 8 9 Version 1.4.2: 10 Development Team: 11 Ramin Mehran, Connie Mueller-Goedecke, Robert Prouse, Will Duncan, Joseph Spurling, GeoS 12 Version 1.1 to Version 1.3: Linus <http://www.shapestyle.se> 13 14 Contact: thecrew@pixelpost.org 15 Copyright 2005 Pixelpost.org <http://www.pixelpost.org> 16 17 18 License: http://www.gnu.org/copyleft/gpl.html 19 20 This program is free software; you can redistribute it and/or 21 modify it under the terms of the GNU General Public License 22 as published by the Free Software Foundation; either version 2 23 of the License, or (at your option) any later version. 24 25 This program is distributed in the hope that it will be useful, 26 but WITHOUT ANY WARRANTY; without even the implied warranty of 27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 GNU General Public License for more details. 29 30 You should have received a copy of the GNU General Public License 31 along with this program; if not, write to the Free Software 32 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 33 34 */ 35 36 error_reporting(0); 37 ini_set('arg_separator.output', '&'); 38 39 // includes 40 require ("includes/pixelpost.php"); 41 require ("includes/markdown.php"); 42 require ("includes/functions.php"); 43 require ("includes/exifer1_5/exif.php"); 44 require ("includes/no-refer-spam.php"); 45 46 // Set cookie for visitor counter, re-count a person after 60 mins 47 setcookie("lastvisit","expires in 24 hours",time() +60*60*24); 48 49 // save user info if requested 50 if(isset($_POST['vcookie'])) { 51 $vcookiename = addslashes($_POST['name']); 52 $vcookieurl = addslashes($_POST['url']); 53 // modified for Email 54 $vcookieemail = clean($_POST['email']); 55 setcookie("visitorinfo","$vcookiename%$vcookieurl%$vcookieemail",time() +60*60*24*30); // save cookie 30 days 56 } 57 58 59 start_mysql(); 60 book_visitor($pixelpost_db_prefix."visitors"); 61 62 // get config 63 if($cfgrow = sql_array("select * from ".$pixelpost_db_prefix."config")) { 64 $upload_dir = $cfgrow['imagepath']; 65 } else 66 { 67 echo "Coming Soon. Not Installed Yet."; 68 exit; 69 } 70 71 if($mod_rewrite == "1") { 72 $showprefix = ""; 73 } else { 74 $showprefix = "index.php?showimage="; 75 } 76 $tz = $cfgrow['timezone']; 77 $datetime = gmdate("Y-m-d H:i:s",time()+(3600 * $tz)); // current date+time 78 $cdate = $datetime; // for future posting, current date+time 79 80 // get the language file 81 if (file_exists("language/lang-".$cfgrow['langfile'].".php")) 82 { 83 require("language/lang-".$cfgrow['langfile'].".php"); 84 } 85 else 86 { 87 echo '<b>Error:</b><br />No <b>language</b> folder exists or the file <b>"lang-' .$cfgrow['langfile'] .'.php"</b> is missing in that folder.<br />Make sure that you have uploaded all necessary files with the exact same names as mentioned here.'; 88 exit; 89 } 90 $pixelpost_site_title = $cfgrow['sitetitle']; 91 92 93 // Added ability to use header and footers for templates. They are not needed but used if included in the template 94 $header = file_get_contents("templates/".$cfgrow['template']."/header.html"); 95 $footer = file_get_contents("templates/".$cfgrow['template']."/footer.html"); 96 // You can now add any template you want by just adding the template and a link to it. For example, 97 // ?x=about will load the template about_template.html 98 99 // x="ref" or x="referer" is blocked due to referrer-spam 100 if( $_GET['x'] == "ref" ) { 101 // Maintain backwards compatibility with the referer template 102 $_GET['x'] = "referer"; 103 } 104 105 if( file_exists( "templates/".$cfgrow['template']."/".$_GET['x']."_template.html" ) ){ 106 $tpl = file_get_contents("templates/".$cfgrow['template']."/".$_GET['x']."_template.html"); 107 } else { 108 109 if (!file_exists("templates/".$cfgrow['template']."/image_template.html")) 110 { 111 echo '<b>Error:</b><br />No template folder exists by the name of <b>"' .$cfgrow['template'] .'"</b> or the file <b>image_template.html</b> is missing in that folder.<br />Make sure that you have uploaded all necessary files with the exact same names as mentioned here.'; 112 exit; 113 } 114 $tpl = file_get_contents("templates/".$cfgrow['template']."/image_template.html"); 115 } 116 117 if($_GET['popup'] == "comment") { 118 $tpl = file_get_contents("templates/".$cfgrow['template']."/comment_template.html"); 119 } 120 121 // Added ability to use header and footers for templates. They are not needed but used if included in the template 122 $tpl = $header . $tpl . $footer; 123 124 // Get visitor count 125 $visitors = sql_array("select count(*) as count from ".$pixelpost_db_prefix."visitors"); 126 $pixelpost_visitors = $visitors['count']; 127 // Get number of photos in database 128 $photonumb = sql_array("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime'"); 129 130 $pixelpost_photonumb = $photonumb['count']; 131 132 // images/main site 133 if($_GET['x'] == "") { 134 // Get Current Image. 135 if($_GET['showimage'] == "") { 136 $row = sql_array("select * from ".$pixelpost_db_prefix."pixelpost where datetime<='$cdate' order by datetime DESC limit 0,1"); 137 } else { 138 $row = sql_array("select * from ".$pixelpost_db_prefix."pixelpost where (id='".$_GET['showimage']."')"); 139 } 140 if(!$row['image']) { 141 echo "Coming Soon! Nothing to show. No image to show here!"; 142 exit; 143 } 144 $image_name = $row['image']; 145 $image_title = pullout($row['headline']); 146 $image_id = $row['id']; 147 $image_datetime = $row['datetime']; 148 $image_datetime_formatted = strtotime($image_datetime); 149 $image_datetime_formatted = date($cfgrow['dateformat'],$image_datetime_formatted); 150 $image_date = substr($row['datetime'],0,10); 151 $image_time = substr($row['datetime'],11,5); 152 $image_date_year_full = substr($row['datetime'],0,4); 153 $image_date_year = substr($row['datetime'],2,2); 154 $image_date_month = substr($row['datetime'],5,2); 155 $image_date_day = substr($row['datetime'],8,2); 156 $image_notes = markdown(pullout($row['body'])); 157 $thumbnail_extra = getimagesize("thumbnails/thumb_$image_name"); 158 $image_extra = getimagesize("images/$image_name"); 159 $image_width = $image_extra['0']; 160 $image_height = $image_extra['1']; 161 $tpl = str_replace("<IMAGE_WIDTH>",$image_width,$tpl); 162 $tpl = str_replace("<IMAGE_HEIGHT>",$image_height,$tpl); 163 $local_width = $thumbnail_extra['0']; 164 $local_height = $thumbnail_extra['1']; 165 166 // added by ramin to reseve ' and "s. 167 $image_title = htmlspecialchars($image_title,ENT_QUOTES); 168 169 //$image_title = htmlentities($image_title ); 170 $image_thumbnail = "<a href='$showprefix$image_id'><img src='thumbnails/thumb_$image_name' alt='$image_title' title='$image_title' width='$local_width' height='$local_height' /></a>"; 171 // thumnail no link 172 $image_thumbnail_no_link = "<img src='thumbnails/thumb_$image_name' alt='$image_title' title='$image_title' width='$local_width' height='$local_height' />"; 173 174 $image_permalink = "<a href='$showprefix$image_id'>$lang_permalink</a>"; // permalink automated for fancy url/no fancy 175 176 // get previous image id and name 177 $previous_row = sql_array("select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime < '$image_datetime') and (datetime<='$cdate') order by datetime desc limit 0,1"); 178 $image_previous_name = $previous_row['image']; 179 $image_previous_id = $previous_row['id']; 180 $image_previous_title = pullout($previous_row['headline']); 181 $image_previous_link = "<a href='$showprefix$image_previous_id'>$lang_previous</a>"; 182 list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name"); 183 $image_previous_thumbnail = "<a href='$showprefix$image_previous_id'><img src='thumbnails/thumb_$image_previous_name' width='$local_width' height='$local_height' alt='$image_previous_title' title='$image_previous_title' /></a>"; 184 if($image_previous_id == "") { 185 $image_previous_id = $image_id; 186 $image_previous_title = "$lang_no_previous"; 187 $image_previous_link = ""; 188 $image_previous_thumbnail = ""; 189 } 190 191 // get next image id and name 192 $next_row = sql_array("select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime > '$image_datetime') and (datetime<='$cdate') order by datetime asc limit 0,1"); 193 $image_next_name = $next_row['image']; 194 $image_next_id = $next_row['id']; 195 $image_next_title = pullout($next_row['headline']); 196 $image_next_link = "<a href='$showprefix$image_next_id'>$lang_next</a>"; 197 list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name"); 198 $image_next_thumbnail = "<a href='$showprefix$image_next_id'><img src='thumbnails/thumb_$image_next_name' alt='$image_next_title' width='$local_width' height='$local_height' title='$image_next_title' /></a>"; 199 if($image_next_id == "") { 200 $image_next_id = $image_id; 201 $image_next_title = "$lang_no_next"; 202 $image_next_link = ""; 203 $image_next_thumbnail = ""; 204 } 205 206 if(function_exists(gd_info)) { 207 $gd_info = gd_info(); 208 if($gd_info != "") { // check that gd is here before this 209 $aheadnumb = sql_array("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where (datetime > '$image_datetime') and (datetime<='$cdate')"); 210 $aheadnumb = $aheadnumb['count']; 211 $behindnumb = sql_array("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where (datetime < '$image_datetime') and (datetime<='$cdate')"); 212 $behindnumb = $behindnumb['count']; 213 $aheadlimit = round(($cfgrow['thumbnumber']-1)/2); 214 $behindlimit = round(($cfgrow['thumbnumber']-1)/2); 215 if($aheadnumb <= $aheadlimit) { 216 $behindlimit = ($cfgrow['thumbnumber']-1)-$aheadnumb; 217 $aheadlimit = $aheadnumb; 218 } 219 if($behindnumb <= $behindlimit) { 220 $aheadlimit = ($cfgrow['thumbnumber']-1)-$behindnumb; 221 $behindlimit = $behindnumb; 222 } 223 $totalthumbcounter = 1; 224 $ahead_thumbs = ""; 225 $ahead_thumbs_reverse =""; 226 $thumbs_ahead = mysql_query("select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime > '$image_datetime') and (datetime<='$cdate') order by datetime asc limit 0,$aheadlimit"); 227 while(list($id,$headline,$image) = mysql_fetch_row($thumbs_ahead)) { 228 $headline = pullout($headline); 229 $headline = htmlspecialchars($headline,ENT_QUOTES); 230 list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name"); 231 $ahead_thumbs .= "<a href='$showprefix$id'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>"; 232 $ahead_thumbs_reverse = "<a href='$showprefix$id'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>" .$ahead_thumbs_reverse ; 233 $totalthumbcounter++; 234 } 235 $behind_thumbs = ""; 236 $behind_thumbs_reverse =""; 237 $thumbs_behind = mysql_query("select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime < '$image_datetime') and (datetime<='$cdate') order by datetime desc limit 0,$behindlimit"); 238 while(list($id,$headline,$image) = mysql_fetch_row($thumbs_behind)) { 239 $headline = pullout($headline); 240 $headline = htmlspecialchars($headline,ENT_QUOTES); 241 list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name"); 242 $behind_thumbs = "<a href='$showprefix$id'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>$behind_thumbs"; 243 $behind_thumbs_reverse .= "<a href='$showprefix$id'><img src='thumbnails/thumb_$image' alt='$headline' title='$headline' class='thumbnails' width='$local_width' height='$local_height' /></a>"; 244 $totalthumbcounter++; 245 } 246 247 list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name"); 248 $thumbnail_row = "$behind_thumbs<a href='$showprefix$image_id'><img src='thumbnails/thumb_$image_name' alt='$image_title' title='$image_title' class='current-thumbnail' width='$local_width' height='$local_height' /></a>$ahead_thumbs"; 249 $thumbnail_row_reverse = "$ahead_thumbs_reverse<a href='$showprefix$image_id'><img src='thumbnails/thumb_$image_name' alt='$image_title' title='$image_title' class='current-thumbnail' width='$local_width' height='$local_height' /></a>$behind_thumbs_reverse"; 250 $tpl = str_replace("<IMAGE_THUMBNAIL_ROW>",$thumbnail_row,$tpl); 251 $tpl = str_replace("<IMAGE_THUMBNAIL_ROW_REV>",$thumbnail_row_reverse,$tpl); 252 } // gd_info() 253 } // func exist 254 255 // Modified from Mark Lewin's hack for multiple categories 256 257 $querystr = "select t1.cat_id,t2.name from ".$pixelpost_db_prefix."catassoc as t1 inner join ".$pixelpost_db_prefix."categories t2 on t1.cat_id = t2.id where t1.image_id = '$image_id' order by t2.name "; 258 $query = mysql_query($querystr); 259 $image_category_number = 0; 260 while(list($cat_id,$name) = mysql_fetch_row($query)) { 261 $name = pullout($name); 262 $image_category_all .= "<a href='$PHP_SELF?x=browse&category=$cat_id'>" .$cfgrow['catgluestart'] .$name .$cfgrow['catglueend']."</a> "; 263 $image_category_all_paged .= "<a href='$PHP_SELF?x=browse&category=$cat_id&pagenum=1'>" .$cfgrow['catgluestart'] .$name .$cfgrow['catglueend']."</a> "; 264 $image_category_number = $image_category_number +1; 265 } 266 267 if ($image_category_number >1) 268 {$image_categoryword = "$lang_category_plural $image_category";} 269 else {$image_categoryword = "$lang_category_singular $image_category";} 270 $tpl = str_replace("<SITE_TITLE>",$pixelpost_site_title,$tpl); 271 $tpl = str_replace("<IMAGE_CATEGORY>",$image_categoryword." ".$image_category_all,$tpl); 272 // for paged_archive addon 273 $tpl = str_replace("<IMAGE_CATEGORY_PAGED>",$image_categoryword." ".$image_category_all_paged,$tpl); 274 $tpl = str_replace("<IMAGE_DATE_YEAR_FULL>",$image_date_year_full,$tpl); 275 $tpl = str_replace("<IMAGE_DATE_YEAR>",$image_date_year,$tpl); 276 $tpl = str_replace("<IMAGE_DATE_MONTH>",$image_date_month,$tpl); 277 $tpl = str_replace("<IMAGE_DATE_DAY>",$image_date_day,$tpl); 278 $tpl = str_replace("<IMAGE_THUMBNAIL>",$image_thumbnail,$tpl); 279 // thumbnail no link 280 $tpl = str_replace("<IMAGE_THUMBNAIL_NO_LINK>",$image_thumbnail_no_link,$tpl); 281 $tpl = str_replace("<IMAGE_DATE>",$image_date,$tpl); 282 $tpl = str_replace("<IMAGE_TIME>",$image_time,$tpl); 283 $tpl = str_replace("<IMAGE_NAME>",$image_name,$tpl); 284 $tpl = str_replace("<IMAGE_TITLE>",$image_title,$tpl); 285 $tpl = str_replace("<IMAGE_DATETIME>",$image_datetime_formatted,$tpl); 286 $tpl = str_replace("<IMAGE_NOTES>",$image_notes,$tpl); 287 // image notes without HTML tags 288 $tpl = str_replace("<IMAGE_NOTES_CLEAN>",strip_tags($image_notes),$tpl); 289 $tpl = str_replace("<IMAGE_ID>",$image_id,$tpl); 290 $tpl = str_replace("<IMAGE_PREVIOUS_LINK>",$image_previous_link,$tpl); 291 $tpl = str_replace("<IMAGE_PREVIOUS_THUMBNAIL>",$image_previous_thumbnail,$tpl); 292 $tpl = str_replace("<IMAGE_PREVIOUS_ID>",$image_previous_id,$tpl); 293 $tpl = str_replace("<IMAGE_PREVIOUS_TITLE>",$image_previous_title,$tpl); 294 $tpl = str_replace("<IMAGE_NEXT_ID>",$image_next_id,$tpl); 295 $tpl = str_replace("<IMAGE_NEXT_TITLE>",$image_next_title,$tpl); 296 $tpl = str_replace("<IMAGE_NEXT_THUMBNAIL>",$image_next_thumbnail,$tpl); 297 $tpl = str_replace("<IMAGE_NEXT_LINK>",$image_next_link,$tpl); 298 299 // get number of comments 300 $cnumb_row = sql_array("select count(*) as count from ".$pixelpost_db_prefix."comments where parent_id='$image_id'"); 301 $image_comments_number = $cnumb_row['count']; 302 303 // get latest comment 304 $latest_comment = sql_array("select parent_id from ".$pixelpost_db_prefix."comments order by id desc limit 0,1"); 305 $latest_comment = $latest_comment['parent_id']; 306 $queryrow = sql_array("select headline from ".$pixelpost_db_prefix."pixelpost where id='$latest_comment'"); 307 $latest_comment_name = pullout($queryrow['headline']); 308 309 310 311 // EXIF STUFF, modified by Connie not to present empty TAGs when no EXIF-info at hand 312 $curr_image = "images/$image_name"; 313 314 // set empty-tag + prepare not to produce empty exif-tags in the template 315 $empty_exif = ""; 316 317 $exif_result = read_exif_data_raw($curr_image,"0"); 318 $exposure = $exif_result['SubIFD']['ExposureTime']; // exposure time 319 if($exposure != "") 320 { 321 $exposure = reduceExif($exposure); 322 $exposure = "$exposure sec"; 323 } 324 325 326 $aperture = $exif_result['SubIFD']['FNumber']; // Aperture 327 $capture_date = $exif_result['SubIFD']['DateTimeOriginal']; // Date and Time 328 329 $flash = $exif_result['SubIFD']['Flash']; // flash 330 $focal = $exif_result['SubIFD']['FocalLength']; // focal length 331 $info_camera_manu = trim($exif_result['IFD0']['Make']); // camera maker 332 $info_camera_model = trim($exif_result['IFD0']['Model']); // camera model 333 $iso = pullout($exif_result['SubIFD']['ISOSpeedRatings']); // not working apparently 334 if($flash == "No Flash&q