5000000) { $tmpfile=$_FILES['upl']['tmp_name']; @unlink($_FILES['upl']['tmp_name']); $isgone=file_exists($tmpfile); echo '{"status":"Error: Image file size exceeds 5MB !","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}'; exit(); } $updir=dirname( __FILE__ ); $updir=$updir."/uploads/ctp/".$_SESSION["cp_userid"]; $imgurl="/mini-upload-form/uploads/ctp/".$_SESSION["cp_userid"]."/".$_FILES['upl']['name']; $ipath="/mini-upload-form/uploads/ctp/".$_SESSION["cp_userid"]; $imgpath=$updir."/".$_FILES['upl']['name']; $imgname=$_FILES['upl']['name']; $icount=0; $sqlnc="SELECT Count(`caption_this_pic`.`hcimagename`) AS `incount` FROM `caption_this_pic` WHERE `caption_this_pic`.`hcimagename` = '".$imgname."'"; $querync=mysql_query($sqlnc) or $em=$em.mysql_error(); $icount = mysql_result($querync,0); mysql_free_result($querync); if($icount > 0) { @unlink($_FILES['upl']['tmp_name']); echo '{"status":"Error: Duplicate Image Name","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}'; exit(); } if(!is_dir($updir)) { if(!mkdir($updir,0777)){echo '{"status":"System Error: Please try again.","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":,"hcid":""}';exit();} } if(move_uploaded_file($_FILES['upl']['tmp_name'], $updir."/".$_FILES['upl']['name'])){ //strip image of Exif data - which can be corrupt // use copy and then create thumbnail $iname = pathinfo($imgpath); $iname=$iname['filename']; $full=$updir."/".$iname."_full.".$extension; $medium=$updir."/".$iname."_medium.".$extension; $thumbnail=$updir."/".$iname."_thumbnail.".$extension; $image = new Imagick($imgpath); $image->stripImage(); // Writes resultant image to output directory //$image->writeImage($full); $image->destroy(); //resize image $size = getimagesize($imgpath); $owidth=$size[0]; $oheight=$size[1]; include("resize-class.php"); $width=$owidth; $height=$oheight; if($owidth > $oheight) { if($owidth >= 800) { $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(800,800,'landscape'); $resizeObj -> saveImage($full, 100); } else { copy($imgpath, $full); } $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(210,210,'landscape'); $resizeObj -> saveImage($medium, 100); $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(100,100,'landscape'); //crop image to 435px width by 220 height $resizeObj -> saveImage($thumbnail, 100); } if($owidth < $oheight || $owidth == $oheight){ if($owidth >= 800) { $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(800,800,'portrait'); $resizeObj -> saveImage($full, 100); } else { copy($imgpath, $full); } $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(210,210,'landscape'); //crop image to 435px width by 220 height $resizeObj -> saveImage($medium, 100); $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(100,100,'landscape'); //crop image to 435px width by 220 height $resizeObj -> saveImage($thumbnail, 100); } $urlissue=0; // insert image details into database table $sqlins="INSERT INTO `caption_this_pic` (`hcuid`,`hcuname`,`hcemail`,`hcimgurl`,`hcimgwdth`,`hcimgheight`,`hcimagename`,`badurl`,`hc_path`,`hc_name`,`hc_ext`) VALUES ( ".$_SESSION["cp_userid"].", '".$_SESSION["nickname"]."', '".$_SESSION["cp_useremail"]."', '".$imgurl."', ".$width.", ".$height.", '".$imgname."', ".$urlissue.", '".$ipath."', '".$iname."', '".$extension."')"; $qins=mysql_query($sqlins) or $em=$em.mysql_error(); $hcid= mysql_insert_id(); $unixtime=time(); $blogdate=gmdate("F d, Y"); $thetitle="Caption This Pic ".$blogdate; $thebody='
'.$blogdate.'
Caption This Pic
'; $thebody=htmlspecialchars($thebody, ENT_QUOTES, 'UTF-8'); $sqlins="INSERT INTO `se_blogentries` ( `se_blogentries`.`blogentry_user_id`, `se_blogentries`.`blogentry_blogentrycat_id`, `se_blogentries`.`blogentry_date`, `se_blogentries`.`blogentry_views`, `se_blogentries`.`blogentry_title`, `se_blogentries`.`blogentry_body`, `se_blogentries`.`blogentry_search`, `se_blogentries`.`blogentry_privacy`, `se_blogentries`.`blogentry_comments`, `se_blogentries`.`blogentry_trackbacks`, `se_blogentries`.`blogentry_totalcomments`, `se_blogentries`.`blogentry_totaltrackbacks` ) VALUES ( 70695, 3, $unixtime, 0, '".$thetitle."', '".$thebody."', 0, 31, 31, '', 0, 0 )"; $queryins=mysql_query($sqlins) or $em=$em.mysql_error(); $blogid= mysql_insert_id(); $sqlbid="UPDATE `caption_this_pic` SET `caption_this_pic`.`blogid` = ".$blogid." WHERE `caption_this_pic`.`hcidu` = ".$hcid; $querybid=mysql_query($sqlbid) or $em=$em.mysql_error(); $status="Not Active"; $colorclass="yellow"; $userad=""; // do nothing on error ??? echo '{"status":"success","imgurl":"'.$ipath.'","iname":"'.$iname.'","iwidth":"'.$width.'","iheight":"'.$height.'","badurl":"'.$urlissue.'", "img":"'.$iname.'", "extension":"'.$extension.'","hcid":"'.$hcid.'", "icount":"'.$icount.'"}'; mail("phil@b8world.com", "Caption This Pic", "New CTP Created"); exit(); } } echo '{"status":"error general","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}'; exit();