( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
if($_POST && array_key_exists("userfile", $_FILES)){
define('WATERMARK_OVERLAY_IMAGE', 'watermark.png');
define('WATERMARK_OVERLAY_IMAGEb', 'watermark.png');
define('WATERMARK_OVERLAY_IMAGEs', 'watermark.png');
define('WATERMARK_OVERLAY_OPACITY', 100);
define('WATERMARK_OUTPUT_QUALITY', 100);
require("reporterSQL.php");
$db = new NewsSQL($dbname);
function create_watermark($thepicha, $output_file_path)
{
list($source_width, $source_height, $source_type) = getimagesize($thepicha);
if ($source_type === NULL) {
return false;
}
switch ($source_type) {
case IMAGETYPE_GIF:
$new_img = imagecreatefromgif($thepicha);
break;
case IMAGETYPE_JPEG:
$new_img = imagecreatefromjpeg($thepicha);
break;
case IMAGETYPE_PNG:
$new_img = imagecreatefrompng($thepicha);
break;
default:
return false;
}
if($source_width > 600 && $source_width < 2000)
{
$overlay_gd_image = imagecreatefrompng(WATERMARK_OVERLAY_IMAGE);
}
if( $source_width > 0 && $source_width < 600 )
{
$overlay_gd_image = imagecreatefrompng(WATERMARK_OVERLAY_IMAGEs);
}
if($source_width > 2000 && $source_width < 90000)
{
$overlay_gd_image = imagecreatefrompng(WATERMARK_OVERLAY_IMAGEb);
}
$overlay_width = imagesx($overlay_gd_image);
$overlay_height = imagesy($overlay_gd_image);
imagecopymerge(
$new_img,
$overlay_gd_image,
$source_width - $overlay_width,
$source_height - $overlay_height,
0,
0,
$overlay_width,
$overlay_height,
WATERMARK_OVERLAY_OPACITY
);
imagejpeg($new_img, $output_file_path, WATERMARK_OUTPUT_QUALITY);
}
/*function getMimeType()
{
$finfo = new finfo(FILEINFO_MIME);
$type = $finfo->file($_FILES['userfile']['tmp_name']);//change the field_name
$mime = substr($type, 0, strpos($type, ';'));
return $mime;
}
function isValidImage()
{
$mime = getMimeType();
if(stristr($mime,'image'))
return true;
else
return false;
}
$res=isValidImage();*/
$input = $_FILES['userfile'];
$ext = array('mpg', 'wma', 'avi','mov', 'flv', 'mp4','mp3','pdf', 'm4v', 'avi', 'qt', 'wmv', 'rm', '3gp', 'mpeg', 'divx', 'moov', 'asf', 'swf', 'vob', 'jpg', 'gif', 'png', 'jpeg');
$extfile = substr($input['name'],-4);
$extfile = explode('.',$extfile);
$good = array();
$extfile = $extfile[1];
$extfile = strtolower($extfile);
if(in_array($extfile, $ext)){
$good['safe'] = true;
$good['ext'] = $extfile;
switch ($extfile)
{
case 'gif':
// We will be converting GIFs to PNGs to avoid transparency issues when resizing GIFs
// This is maybe not the ideal solution, but IE6 can suck it
$creationFunction = 'ImageCreateFromGif';
$type = 0;
$kind = "gif";
$outputFunction = 'ImagePng';
$mime = 'image/png'; // We need to convert GIFs to PNGs
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'png':
$creationFunction = 'ImageCreateFromPng';
$type = 0;
$kind = "png";
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
case 'jpg':
$creationFunction = 'ImageCreateFromJpeg';
$type = 0;
$kind = "jpg";
$quality=100;
break;
case 'mp4':
$creationFunction = 'ImageCreateFromJpeg';
$type = 11;
$kind = "mp4";
$quality=100;
break;
case 'mp3':
$creationFunction = 'ImageCreateFromJpeg';
$type = 10;
$kind = "mp3";
$quality=100;
break;
default:
exit("0");
break;
}
}else{
exit("0");
}
/*require_once('S3.php');
define('ACCESS_KEY', 'AKIAJWAA2EGCM7FEUI2A');
define('SECRET_KEY', '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');
define('BUCKET_NAME', 'runinga');
$bucket ='runinga';
$s3 = new S3(ACCESS_KEY, SECRET_KEY);*/
//S3::setAuth(awsAccessKey, awsSecretKey);
function remove_accent($str)
{
$a = array('�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','�','A','a','A','a','A','a','C','c','C','c','C','c','C','c','D','d','�','d','E','e','E','e','E','e','E','e','E','e','G','g','G','g','G','g','G','g','H','h','H','h','I','i','I','i','I','i','I','i','I','i','?','?','J','j','K','k','L','l','L','l','L','l','?','?','L','l','N','n','N','n','N','n','?','O','o','O','o','O','o','�','�','R','r','R','r','R','r','S','s','S','s','S','s','�','�','T','t','T','t','T','t','U','u','U','u','U','u','U','u','U','u','U','u','W','w','Y','y','�','Z','z','Z','z','�','�','?','�','O','o','U','u','A','a','I','i','O','o','U','u','U','u','U','u','U','u','U','u','?','?','?','?','?','?');
$b = array('A','A','A','A','A','A','AE','C','E','E','E','E','I','I','I','I','D','N','O','O','O','O','O','O','U','U','U','U','Y','s','a','a','a','a','a','a','ae','c','e','e','e','e','i','i','i','i','n','o','o','o','o','o','o','u','u','u','u','y','y','A','a','A','a','A','a','C','c','C','c','C','c','C','c','D','d','D','d','E','e','E','e','E','e','E','e','E','e','G','g','G','g','G','g','G','g','H','h','H','h','I','i','I','i','I','i','I','i','I','i','IJ','ij','J','j','K','k','L','l','L','l','L','l','L','l','l','l','N','n','N','n','N','n','n','O','o','O','o','O','o','OE','oe','R','r','R','r','R','r','S','s','S','s','S','s','S','s','T','t','T','t','T','t','U','u','U','u','U','u','U','u','U','u','U','u','W','w','Y','y','Y','Z','z','Z','z','Z','z','s','f','O','o','U','u','A','a','I','i','O','o','U','u','U','u','U','u','U','u','U','u','A','a','AE','ae','O','o');
return str_replace($a, $b, $str);
}
$sector = $_POST["sector"];
$mixed =$_POST['u'];
$who =$_POST['who'];
$process = explode("-", $mixed);
$checkcount = count($process);
$c = $checkcount - 1; // find last element
$n = $checkcount - 2;
$a = $checkcount - 3;
$yanani = $process[$c];
$videouser = $process[$n];
$appno = $process[$a];
$pic = $process[$n];
switch ($sector) {
case "startags" :
$uploaddir = 'uploads/startags/';
break;
case "theme" :
$uploaddir = 'uploads/startags/';
break;
case "replaceit" :
$uploaddir = 'uploads/startags/';
$uploaddir2 = 'uploads/gthumbs/';
$oldpic =$_POST['oldpic'];
$picID =$_POST['picID'];
break;
case "market" :
$uploaddir = 'uploads/gthumbs/';
break;
case "mygallery" :
$uploaddir = 'uploads/gthumbs/';
break;
case "addgallery" :
/*$uploaddir = 'uploads/gallery/';*/ $uploaddir = 'uploads/gthumbs/';
case "3DFonts" :
/*$uploaddir = 'uploads/gallery/';*/ $uploaddir = 'uploads/3DFonts/';
break;
case "mobilegallery" :
$uploaddir = '/var/www/html/v/uploads/gallery/';
break;
case "distribution" :
$uploaddir = 'uploads/distribution/';
break;
case "addMyGraphics" :
$uploaddir = 'uploads/layouts/';
break;
case "profilepicture" :
$uploaddir = 'uploads/gallery/';
break;
case "replacebrand" :
$uploaddir = 'uploads/startags/';
$uploaddir2 = 'uploads/gthumbs/';
break;
case "default" :
$uploaddir = 'uploads/gthumbs/';
break;
}
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($_FILES['userfile']['name']);
$titleme = basename($_FILES['userfile']['name']);
$titleme = remove_accent($titleme);
$url = strtolower(trim($titleme));
$url = preg_replace('/[^a-z0-9-]/', '-', $url);
$url = preg_replace('/-+/', "-", $url);
$upload =preg_replace('/[\!@#$%^&*()+=,;:]/', '', $upload);
$upload = preg_replace('/[\ ]/', '-', $upload);
$upload = $videouser.$upload;
$uploadfile = $uploaddir .$upload;
$uploadfile = $uploadfile;
/* require_once('class.ImageFilter.php');
$filter = new ImageFilter;
$score = $filter->GetScore($_FILES['userfile']['tmp_name']);
if(isset($score))
{
if($score >= 20)
{
echo "0";
exit();
}}
*/
/* $input_file = "test.png";
$output_file = "test.jpg";
$input = imagecreatefrompng($input_file);
list($width, $height) = getimagesize($input_file);
$output = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($output, 255, 255, 255);
imagefilledrectangle($output, 0, 0, $width, $height, $white);
imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
imagejpeg($output, $output_file); */
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile) ) {
$extension = $safe_file['ext'];
$base = basename($uploadfile, $safe_file['ext']);
$db_file = $base;
$new_file = $base.'flv';
$new_image = $videouser.$base.'jpg';
$new_pic = $videouser.$base;
$new_image_path = $live_img.$new_image;
$new_flv = $VideoPath.$new_file;
set_time_limit(500);
switch ($sector) {
/* case "gallery" :
@$addfile = $db->addbranding($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
*/
/*case "gallery" :
@$addfile = $db->addtogallery($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
*/
case "replaceit" :
@$addfile = $db->replaceit($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload,$oldpic,$picID,$who);
break;
case "market" :
@$addfile = $db->market($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
case "theme" :
@$addfile = $db->theme($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
case "startags" :
@$addfile = $db->addstarfile($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
case "addMyGraphics" :
@$addfile = $db->addMyGraphics($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
case "profilepicture" :
@$addfile = $db->addprofile($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
case "addgallery" :
@$addfile = $db->addgallery($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
case "3DFonts" :
@$addfile = $db->ThreeDFonts($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
case "mygallery" :
@$addfile = $db->addgalleryPhotos($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
case "replacebrand" :
@$addfile = $db->replacebrand($pic,$videouser);
break;
case "distribution" :
@$addfile = $db-> distributionfile($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$kind,$upload);
break;
case "default" :
@$addfile = $db->addvideofile($appno,$videouser,$yanani,$db_file,$new_image,$titleme,$url,$type,$upload);
break;
}
/*include("squash.php");*/
echo "1";
} else {
echo "0";
// echo "file size!"; // print_r($_FILES);
}
}else{
echo "0";
// echo "wrong type";
}
//echo "1";
?>