Files

88 lines
3.4 KiB
PHP
Raw Permalink Normal View History

2026-11-17 16:15:01 -05:00
<?php if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/include/analytics/adrotation/includes/');
include(PATHTOINCLUDES."base.php");
date_default_timezone_set('UTC');
if(!isset($_POST["adlink"]))
{
}
$al=$_POST["adlink"];
if (filter_var($al, FILTER_VALIDATE_URL)!== false) {
echo '{"status":"valid","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}';
exit();
} else {
echo '{"status":"not valid","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}';
exit();
}
if($al=="")
{
echo '{"status":"URL for ad required!","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}';
exit();
}
// A list of permitted file extensions
$allowed = array('png', 'jpg', 'jpeg', 'gif');
if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){
$em="";
//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":"", "img":"", "extension":"","hcid":""}';
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":"", "img":"", "extension":"","hcid":""}';
exit();
}
$updir=dirname( __FILE__ );
$updir=$updir."/ad_uploads";
$imgurl="/include/analytics/adrotation/ad_uploads/".$_FILES['upl']['name'];
$ipath="//include/analytics/adrotation/ad_uploads/";
$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 <a href=\"http://bateworld.com/help_contact.php\" target=\"_blank\">bateworld customer satisfaction</a> !","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;
$urlissue=0;
echo '{"status":"success","imgurl":"'.$ipath.'","iname":"'.$iname.'","iwidth":"'.$width.'","iheight":"'.$height.'","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}';
exit();
// insert image details into database table
}
}
echo '{"status":"error general","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}';
exit();