License: http://www.gnu.org/copyleft/gpl.html
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
error_reporting(0);
// includes
require("includes/pixelpost.php");
require("includes/markdown.php");
require("includes/functions.php");
require("includes/exifer1_5/exif.php");
// Set cookie for visitor counter, re-count a person after 60 mins
setcookie("lastvisit","expires in 60 minutes",time() +60*60);
// save user info if requested
if(isset($_POST['vcookie'])) {
$vcookiename = addslashes($_POST['name']);
$vcookieurl = addslashes($_POST['url']);
// modified for Email
$vcookieemail = clean($_POST['email']);
setcookie("visitorinfo","$vcookiename%$vcookieurl%$vcookieemail",time() +60*60*24*30); // save cookie 30 days
}
start_mysql();
book_visitor($pixelpost_db_prefix."visitors");
// get config
if($cfgrow = sql_array("select * from ".$pixelpost_db_prefix."config")) {
$upload_dir = $cfgrow['imagepath'];
} else
{
echo "Coming Soon. Not Installed Yet.";
exit;
}
if($mod_rewrite == "1") {
$showprefix = "";
} else {
$showprefix = "index.php?showimage=";
}
$tz = $cfgrow['timezone'];
$datetime = gmdate("Y-m-d H:i:s",time()+(3600 * $tz)); // current date+time
$cdate = $datetime; // for future posting, current date+time
// get the language file
if (file_exists("language/lang-".$cfgrow['langfile'].".php"))
{
require("language/lang-".$cfgrow['langfile'].".php");
}
else
{
echo 'Error: No language folder exists or the file "lang-' .$cfgrow['langfile'] .'.php" is missing in that folder. Make sure that you have uploaded all necessary files with the exact same names as mentioned here.';
exit;
}
$pixelpost_site_title = $cfgrow['sitetitle'];
// Added ability to use header and footers for templates. They are not needed but used if included in the template
$header = file_get_contents("templates/".$cfgrow['template']."/header.html");
$footer = file_get_contents("templates/".$cfgrow['template']."/footer.html");
// You can now add any template you want by just adding the template and a link to it. For example,
// ?x=about will load the template about_template.html
if( $_GET['x'] == "ref" ) {
// Maintain backwards compatibility with the referer template
$_GET['x'] = "referer";
}
if( file_exists( "templates/".$cfgrow['template']."/".$_GET['x']."_template.html" ) ){
$tpl = file_get_contents("templates/".$cfgrow['template']."/".$_GET['x']."_template.html");
} else {
if (!file_exists("templates/".$cfgrow['template']."/image_template.html"))
{
echo 'Error: No template folder exists by the name of "' .$cfgrow['template'] .'" or the file image_template.html is missing in that folder. Make sure that you have uploaded all necessary files with the exact same names as mentioned here.';
exit;
}
$tpl = file_get_contents("templates/".$cfgrow['template']."/image_template.html");
}
if($_GET['popup'] == "comment") {
$tpl = file_get_contents("templates/".$cfgrow['template']."/comment_template.html");
}
// Added ability to use header and footers for templates. They are not needed but used if included in the template
$tpl = $header . $tpl . $footer;
// Get visitor count
$visitors = sql_array("select count(*) as count from ".$pixelpost_db_prefix."visitors");
$pixelpost_visitors = $visitors['count'];
// Get number of photos in database
$photonumb = sql_array("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where datetime<='$datetime'");
$pixelpost_photonumb = $photonumb['count'];
// images/main site
if($_GET['x'] == "") {
// Get Current Image.
if($_GET['showimage'] == "") {
$row = sql_array("select * from ".$pixelpost_db_prefix."pixelpost where datetime<='$cdate' order by datetime DESC limit 0,1");
} else {
$row = sql_array("select * from ".$pixelpost_db_prefix."pixelpost where (id='".$_GET['showimage']."')");
}
if(!$row['image']) {
echo "Coming Soon! Nothing to show. No image to show here!";
exit;
}
$image_name = $row['image'];
$image_title = pullout($row['headline']);
$image_id = $row['id'];
$image_datetime = $row['datetime'];
$image_datetime_formatted = strtotime($image_datetime);
$image_datetime_formatted = date($cfgrow['dateformat'],$image_datetime_formatted);
$image_date = substr($row['datetime'],0,10);
$image_time = substr($row['datetime'],11,5);
$image_date_year_full = substr($row['datetime'],0,4);
$image_date_year = substr($row['datetime'],2,2);
$image_date_month = substr($row['datetime'],5,2);
$image_date_day = substr($row['datetime'],8,2);
$image_notes = markdown(pullout($row['body']));
$thumbnail_extra = getimagesize("thumbnails/thumb_$image_name");
$image_extra = getimagesize("images/$image_name");
$image_width = $image_extra['0'];
$image_height = $image_extra['1'];
$tpl = str_replace("",$image_width,$tpl);
$tpl = str_replace("",$image_height,$tpl);
$local_width = $thumbnail_extra['0'];
$local_height = $thumbnail_extra['1'];
$image_thumbnail = "";
// thumnail no link
$image_thumbnail_no_link = "";
$image_permalink = "$lang_permalink"; // permalink automated for fancy url/no fancy
// get previous image id and name
$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");
$image_previous_name = $previous_row['image'];
$image_previous_id = $previous_row['id'];
$image_previous_title = pullout($previous_row['headline']);
$image_previous_link = "$lang_previous";
list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name");
$image_previous_thumbnail = "";
if($image_previous_id == "") {
$image_previous_id = $image_id;
$image_previous_title = "$lang_no_previous";
$image_previous_link = "";
$image_previous_thumbnail = "";
}
// get next image id and name
$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");
$image_next_name = $next_row['image'];
$image_next_id = $next_row['id'];
$image_next_title = pullout($next_row['headline']);
$image_next_link = "$lang_next";
list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name");
$image_next_thumbnail = "";
if($image_next_id == "") {
$image_next_id = $image_id;
$image_next_title = "$lang_no_next";
$image_next_link = "";
$image_next_thumbnail = "";
}
if(function_exists(gd_info)) {
$gd_info = gd_info();
if($gd_info != "") { // check that gd is here before this
$aheadnumb = sql_array("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where (datetime > '$image_datetime') and (datetime<='$cdate')");
$aheadnumb = $aheadnumb['count'];
$behindnumb = sql_array("select count(*) as count from ".$pixelpost_db_prefix."pixelpost where (datetime < '$image_datetime') and (datetime<='$cdate')");
$behindnumb = $behindnumb['count'];
$aheadlimit = round(($cfgrow['thumbnumber']-1)/2);
$behindlimit = round(($cfgrow['thumbnumber']-1)/2);
if($aheadnumb <= "1") {
$behindlimit = ($cfgrow['thumbnumber']-1)-$aheadnumb;
$aheadlimit = $aheadnumb;
}
if($behindnumb <= "1") {
$aheadlimit = ($cfgrow['thumbnumber']-1)-$behindnumb;
$behindlimit = $behindnumb;
}
$totalthumbcounter = 0; // will count up to four no matter what
$ahead_thumbs = "";
$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");
while(list($id,$headline,$image) = mysql_fetch_row($thumbs_ahead)) {
$headline = pullout($headline);
list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name");
$ahead_thumbs .= "";
$totalthumbcounter++;
}
$behind_thumbs = "";
$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");
while(list($id,$headline,$image) = mysql_fetch_row($thumbs_behind)) {
$headline = pullout($headline);
list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name");
$behind_thumbs = "$behind_thumbs";
}
list($local_width,$local_height,$type,$attr) = getimagesize("thumbnails/thumb_$image_name");
$thumbnail_row = "$behind_thumbs$ahead_thumbs";
$tpl = str_replace("",$thumbnail_row,$tpl);
} // gd_info()
} // func exist
// Modified from Mark Lewin's hack for multiple categories
$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'";
$query = mysql_query($querystr);
$image_category_number = 0;
while(list($cat_id,$name) = mysql_fetch_row($query)) {
$name = pullout($name);
$image_category_all .= "" .$cfgrow['catgluestart'] .$name .$cfgrow['catglueend']." ";
$image_category_all_paged .= "" .$cfgrow['catgluestart'] .$name .$cfgrow['catglueend']." ";
$image_category_number = $image_category_number +1;
}
if ($image_category_number >1)
{$image_categoryword = "$lang_category_plural $image_category";}
else {$image_categoryword = "$lang_category_singular $image_category";}
$tpl = str_replace("",$pixelpost_site_title,$tpl);
$tpl = str_replace("",$image_categoryword." ".$image_category_all,$tpl);
// for paged_archive addon
$tpl = str_replace("",$image_categoryword." ".$image_category_all_paged,$tpl);
$tpl = str_replace("",$image_date_year_full,$tpl);
$tpl = str_replace("",$image_date_year,$tpl);
$tpl = str_replace("",$image_date_month,$tpl);
$tpl = str_replace("",$image_date_day,$tpl);
$tpl = str_replace("",$image_thumbnail,$tpl);
// thumbnail no link
$tpl = str_replace("",$image_thumbnail_no_link,$tpl);
$tpl = str_replace("",$image_date,$tpl);
$tpl = str_replace("",$image_time,$tpl);
$tpl = str_replace("",$image_name,$tpl);
$tpl = str_replace("",$image_title,$tpl);
$tpl = str_replace("",$image_datetime_formatted,$tpl);
$tpl = str_replace("",$image_notes,$tpl);
// image notes without HTML tags
$tpl = str_replace("",strip_tags($image_notes),$tpl);
$tpl = str_replace("",$image_id,$tpl);
$tpl = str_replace("",$image_previous_link,$tpl);
$tpl = str_replace("",$image_previous_thumbnail,$tpl);
$tpl = str_replace("",$image_previous_id,$tpl);
$tpl = str_replace("",$image_previous_title,$tpl);
$tpl = str_replace("",$image_next_id,$tpl);
$tpl = str_replace("",$image_next_title,$tpl);
$tpl = str_replace("",$image_next_thumbnail,$tpl);
$tpl = str_replace("",$image_next_link,$tpl);
// get number of comments
$cnumb_row = sql_array("select count(*) as count from ".$pixelpost_db_prefix."comments where parent_id='$image_id'");
$image_comments_number = $cnumb_row['count'];
// get latest comment
$latest_comment = sql_array("select parent_id from ".$pixelpost_db_prefix."comments order by id desc limit 0,1");
$latest_comment = $latest_comment['parent_id'];
$queryrow = sql_array("select headline from ".$pixelpost_db_prefix."pixelpost where id='$latest_comment'");
$latest_comment_name = pullout($queryrow['headline']);
// EXIF STUFF
$curr_image = "images/$image_name";
$exif_result = read_exif_data_raw($curr_image,"0");
$exposure = $exif_result['SubIFD']['ExposureTime']; // exposure time
if($exposure != "")
{
$exposure = reduceExif($exposure);
$exposure = "$exposure sec";
}
$aperture = $exif_result['SubIFD']['FNumber']; // Aperture
$capture_date = $exif_result['SubIFD']['DateTimeOriginal']; // Date and Time
$flash = $exif_result['SubIFD']['Flash']; // flash
$focal = $exif_result['SubIFD']['FocalLength']; // focal length
$info_camera_manu = trim($exif_result['IFD0']['Make']); // camera maker
$info_camera_model = trim($exif_result['IFD0']['Model']); // camera model
$iso = pullout($exif_result['SubIFD']['ISOSpeedRatings']); // not working apparently
if($flash == "No Flash") {
$flash = "$lang_flash_not_fired";
}
elseif ($flash) {$flash = "$lang_flash_fired";}
$tpl = ereg_replace("",$exposure,$tpl);
if($exposure != "")
{
$exposure = "$lang_exposure $exposure";
$tpl = ereg_replace("",$exposure,$tpl);
}
$tpl = ereg_replace("",$aperture,$tpl);
if($aperture != "")
{
$aperture = "$lang_aperture $aperture";
$tpl = ereg_replace("",$aperture,$tpl);
}
$tpl = ereg_replace("",$capture_date,$tpl);
if($capture_date != "")
{
$capture_date = "$lang_capture_date $capture_date";
$tpl = ereg_replace("",$capture_date,$tpl);
}
$tpl = ereg_replace("",$focal,$tpl);
if($focal != "")
{
$focal = "$lang_focal $focal";
$tpl = ereg_replace("",$focal,$tpl);
}
$tpl = ereg_replace("",$info_camera_manu,$tpl);
if($info_camera_manu != "")
{
$info_camera_manu = "$lang_camera_maker $info_camera_manu";
$tpl = ereg_replace("",$info_camera_manu,$tpl);
}
$tpl = ereg_replace("",$info_camera_model,$tpl);
if($info_camera_model != "")
{
$info_camera_model = "$lang_camera_model $info_camera_model";
$tpl = ereg_replace("",$info_camera_model,$tpl);
}
$tpl = str_replace("",$iso,$tpl);
if($iso != "") {
$iso = "$lang_iso $iso";
$tpl = ereg_replace("",$iso,$tpl);
}
$tpl = ereg_replace("",$flash,$tpl);
if($flash != "") {
$flash = "$lang_flash $flash";
$tpl = ereg_replace("",$flash,$tpl);
}
/////////////
// build a string with all comments
if(($_GET['x'] == "") or ($_GET['popup'] == "comment")) {
if($_GET['comment'] == "save") {
$datetime = gmdate("Y-m-d H:i:s",time()+(3600 * $cfgrow['timezone'])); // current date+time //was date("Y-m-d H:i:s");
$ip = $_SERVER['REMOTE_ADDR'];
$parent_id = $_POST['parent_id'];
$message = clean($_POST['message']);
$name = clean($_POST['name']);
$url = clean($_POST['url']);
$parent_name = $_POST['parent_name'];
$email = clean($_POST['email']);
if($parent_id == "") {
$extra_message = "$lang_message_missing_image";
}
if($message == "") {
$extra_message = "$lang_message_missing_comment";
}
if(($parent_id != "") and ($message != "")) {
sql_save("
insert into ".$pixelpost_db_prefix."comments(id,parent_id,datetime,ip,message,name,url,email)
VALUES('NULL','$parent_id','$datetime','$ip','$message','$name','$url','$email')
");
}
}
// visitor information in comments
$vinfo_name = "";
$vinfo_url = "";
$vinfo_email = "";
if(isset($_COOKIE['visitorinfo'])) {
list($vinfo_name,$vinfo_url,$vinfo_email) = split("%",$_COOKIE['visitorinfo']);
}
$tpl = str_replace("",$vinfo_name,$tpl);
$tpl = str_replace("",$vinfo_url,$tpl);
$tpl = str_replace("",$vinfo_email,$tpl);
if($_GET['showimage'] == "") { $imageid = $image_id; } else { $imageid = $_GET['showimage']; }
$image_comments = print_comments($imageid);
$tpl = str_replace("",$image_comments,$tpl);
if(($_GET['popup'] == "comment") AND ($_GET['x'] != "save_comment")) { echo $tpl; exit; }
} // end if comment
} // end imageprint
// fix a popuplink
// refererlog
if($_GET['x'] == "referer") {
$referer_print = "
";
// only count referers from the last seven days
gmdate("Y-m-d H:i:s",time()+(3600 * $cfgrow['timezone'])); // current date+time
$from_date = mktime(0,0,0,gmdate("m",time()+(3600 * $cfgrow['timezone'])) ,gmdate("d",time()+(3600 * $cfgrow['timezone'])) -7,gmdate("Y",time()+(3600 * $cfgrow['timezone'])) );
$from_date = strftime("%Y-%m-%d", $from_date);
$from_date = "$from_date 00:00:00";
$referer = "";
$query = mysql_query("select distinct referer from ".$pixelpost_db_prefix."visitors where (referer!='') AND (datetime>'$from_date')");
while(list($nreferer) = mysql_fetch_row($query)) {
$nreferer = htmlentities($nreferer);
$referer .= "!".$nreferer;
}
$referer = split("!",$referer);
$ref_biglist = "";
foreach($referer as $value) {
if($value != "") {
$row = sql_array("select count(*) as count from ".$pixelpost_db_prefix."visitors where (referer='$value') AND (datetime>'$from_date')");
$refnumb = $row['count'];
$ref_biglist .= "$refnumb@$value!";
}
}
$ref_biglist = split("!",$ref_biglist);
rsort($ref_biglist,SORT_NUMERIC);
foreach($ref_biglist as $value) {
list($numb,$referer) = explode("@",$value);
if($numb > "0") {
if($numb < "10") { $numb = "0$numb"; }
$referername = $referer;
$length = strlen($referername);
if($length > 50) { $referername = substr($referername,0,50); $referername = "$referername..."; }
$referer_print .= "