= 3) { $tmpfile=$_FILES['upl']['tmp_name']; @unlink($_FILES['upl']['tmp_name']); $isgone=file_exists($tmpfile); echo '{"status":"Error: You have exceeded the limit of 3 ads. Please delete an ad and try again.","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":""}'; exit; } //check image extention $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION); if(!in_array(strtolower($extension), $allowed)){ $tmpfile=$_FILES['upl']['tmp_name']; @unlink($_FILES['upl']['tmp_name']); $isgone=file_exists($tmpfile); echo '{"status":"Error: Please upload a jpg, gif, or png file !","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":""}'; exit; } // check size of image $thesize=$_FILES['upl']['size']; if($thesize > 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":""}'; exit; } $updir=dirname( __FILE__ ); $updir=$updir."/uploads/".$_SESSION["cp_userid"]; $imgurl="/mini-upload-form/uploads/".$_SESSION["cp_userid"]."/".$_FILES['upl']['name']; $imgpath=$updir."/".$_FILES['upl']['name']; $imgname=$_FILES['upl']['name']; if(!is_dir($updir)) { if(!mkdir($updir,0777)){echo '{"status":"System Error: Please try again. If error persists, please contact bateworld customer satisfaction !","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":""}';exit;} } if(move_uploaded_file($_FILES['upl']['tmp_name'], $updir."/".$_FILES['upl']['name'])){ //strip image of Exif data - which can be corrupt $image = new Imagick($imgpath); $image->stripImage(); // Writes resultant image to output directory $image->writeImage($imgpath); $image->destroy(); //resize image $size = getimagesize($imgpath); $width=$size[0]; $height=$size[1]; include("resize-class.php"); if($width >= $height) { $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(435,'landscape'); //resize to landscape with fixed width of 435 px $resizeObj -> saveImage($imgpath, 100); $size = getimagesize($imgpath); $width=$size[0]; $height=$size[1]; } if($height > 116 || $height > $width) { $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(435,116,'crop'); //crop image to 435px width by 220 height $resizeObj -> saveImage($imgpath, 100); $width=435; $height=116; } $urlissue=0; $headers = @get_headers($theadlink); if(strpos($headers[0],'404')==true) {$urlissue=1;} // insert image details into database table $sqlins="INSERT INTO `community_user_ads` (`userid`,`username`,`useremail`,`image_url`,`image_width`,`image_height`,`thelink`,`image_name`,`badurl`) VALUES( ".$_SESSION["cp_userid"].", '".$_SESSION["nickname"]."', '".$_SESSION["cp_useremail"]."', '".$imgurl."', ".$width.", ".$height.", ".GetSQLValueString($theadlink,"text").", '".$imgname."', ".$urlissue.")"; $qins=mysql_query($sqlins) or $em=$em.mysql_error(); $adid= mysql_insert_id(); $status="Approval Pending"; $colorclass="yellow"; $userad=""; $userad.=''.$status.''; $userad.='N/AN/AN/A'; $userad.='edit | del'; $userad.=''; $userad.='
'; // do nothing on error ??? echo '{"status":"success","imgurl":"'.$imgurl.'","iwidth":"'.$width.'","iheight":"'.$height.'","thecount":"'.$row[0].'","badurl":"'.$urlissue.'","userad":"'.$userad.'", "adid":"'.$adid.'"}'; mail("phil@b8world.com", "New Members Section Add", "Waiting For Approval"); mail("bateworld@gmail.com", "New Members Section Add", "Waiting For Approval"); mail("bwecreative@gmail.com", "New Members Section Add", "Waiting For Approval"); mail("bateworldhelp@gmail.com", "New Members Section Add", "Waiting For Approval"); exit(); } } echo '{"status":"error general","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":""}'; exit;