( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
if($_POST && array_key_exists("file", $_FILES)){
/*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);
$myaccount= $_POST['myaccountX'];
$videouser= $_POST['myaccountX'];
function checkfile($input){
$ext = array('mp4', '3gp', '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;
}else{
$good['safe'] = false;
}
return $good;
}
$uploaddir = '/var/www/html/v/uploads/gallery/';
$upload = basename($_FILES['file']['name']);
$titleme = basename($_FILES['file']['name']);
$date = md5(date('D, d M Y H:i:s'));
$upload = $date.basename($_FILES['userfile']['name']);
$upload =preg_replace('/[\!@#$%^&*()+=,;:]/', '', $upload);
$upload = preg_replace('/[\ ]/', '-', $upload);
$uploadfile = $uploaddir .$upload.".jpg";
$safe_file = checkfile($_FILES['file']);
if($safe_file['safe'] == 1)
{
/* if ($result = process_image_upload('file')) {*/
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
$filename =$_FILES['file']['tmp_name'];
$base = basename($uploadfile);
set_time_limit(300);
require("reporterSQL.php");
$db = new NewsSQL($dbname);
$time=time();
$ip=$_SERVER['REMOTE_ADDR'];
$adddate = time();
$nameinfo2 = $db->getuser($videouser);
if (!empty($nameinfo2)){
while (list($key,$val)=each($nameinfo2)) {
$user_name = stripslashes($val["user_name"]).rand(100,999);
$query = mysqli_query("INSERT INTO `profilepicture` (title,catalogid, ip,adddate,picture,isdisplay,type) VALUES ('$user_name', '$videouser','$ip','$adddate','$base','11','3')") or die(mysql_error());
$w=600;
$h=600;
$source ="/var/www/html/v/uploads/gallery/$base";
$image_path="/var/www/html/v/uploads/gthumbs/$base";
$check ="/var/www/html/v/uploads/gallery/$base";
//Get the original image dimensions + type
list($source_width, $source_height, $source_type) = getimagesize($source);
//Figure out if we need to create a new JPG, PNG or GIF
$ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
if ($ext == "jpg" || $ext == "jpeg") {
$source_gdim=imagecreatefromjpeg($source);
} elseif ($ext == "png") {
$source_gdim=imagecreatefrompng($source);
} elseif ($ext == "gif") {
$source_gdim=imagecreatefromgif($source);
} else {
//Invalid file type? Return.
return;
}
if ($w && !$h) {
$ratio = $w / $source_width;
$temp_width = $w;
$temp_height = $source_height * $ratio;
$background = imagecreatetruecolor($temp_width, $temp_height);
imagecopyresampled(
$background,
$source_gdim,
0, 0,
0, 0,
$temp_width, $temp_height,
$source_width, $source_height
);
} else {
$source_aspect_ratio = $source_width / $source_height;
$desired_aspect_ratio = $w / $h;
if ($source_aspect_ratio > $desired_aspect_ratio) {
$temp_height = $h;
$temp_width = ( int ) ($h * $source_aspect_ratio);
} else {
$temp_width = $w;
$temp_height = ( int ) ($w / $source_aspect_ratio);
}
$temp_gdim = imagecreatetruecolor($temp_width, $temp_height);
imagecopyresampled(
$temp_gdim,
$source_gdim,
0, 0,
0, 0,
$temp_width, $temp_height,
$source_width, $source_height
);
$x0 = ($temp_width - $w) / 2;
$y0 = ($temp_height - $h) / 2;
$background = imagecreatetruecolor($w, $h);
imagecopy(
$background,
$temp_gdim,
0, 0,
$x0, $y0,
$w, $h
);
}
if ($ext == "jpg" || $ext == "jpeg") {
ImageJpeg($background,$image_path,100);
} elseif ($ext == "png") {
ImagePng($background,$image_path);
} elseif ($ext == "gif") {
ImageGif($background,$image_path);
} else {
return;
}
ImageDestroy ($background);
$ext = strtolower(pathinfo($check, PATHINFO_EXTENSION));
if ($ext == "png") {
unlink($check);
}
echo "$user_name";
} }
} else {
echo "File Too Large";
// echo "file size!"; // print_r($_FILES);
}
}else{
echo "Wrong File Type";
// echo "wrong type";
}
//echo "1";
}
?>