<?php
@header('Content-type: text/html;charset=windows-1256');
@date_default_timezone_set("Asia/riyadh");
// Code Net , Mahdi Hamid :)
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>10,
'ignore_errors'=> true
)
);
$context = stream_context_create
(["http" => array(
"header" => "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36" ),
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false]]);
function downloadImage($remote_links) {
$ch = curl_init($remote_links);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0");
curl_setopt($ch, CURLOPT_REFERER, $remote_links);
$data = curl_exec($ch);
if(curl_errno($ch)){
curl_close($ch);
return false;
}
curl_close($ch);
return $data;
}
function watermark($name, $ext, $logo){
$src_img = null;
if (preg_match("/jpg|jpeg/i",$ext)){$src_img=@imagecreatefromjpeg($name);}
elseif (preg_match("/webp/i",$ext)){$src_img=@imagecreatefromwebp($name);}
elseif (preg_match("/png/i",$ext)){$src_img=@imagecreatefrompng($name);}
elseif (preg_match("/avif/i",$ext)){$src_img=@imagecreatefrompng($name);}
if (!$src_img) return false;
$src_logo = @imagecreatefrompng($logo);
if (!$src_logo) return false;
$bwidth = imageSX($src_img);
$bheight = imageSY($src_img);
$lwidth = imageSX($src_logo);
$lheight = imageSY($src_logo);
if ($bwidth > 160 && $bheight > 130) {
$src_x = $bwidth - ($lwidth + 5);
$src_y = $bheight - ($lheight + 5);
ImageAlphaBlending($src_img, true);
ImageCopy($src_img,$src_logo,$src_x,$src_y,0,0,$lwidth,$lheight);
if (preg_match("/jpg|jpeg/i",$ext)){imagejpeg($src_img, $name, 90);}
elseif (preg_match("/png/i",$ext)){imagepng($src_img, $name);}
elseif (preg_match("/webp/i",$ext)){imagewebp($src_img, $name);}
elseif (preg_match("/avif/i",$ext)){imagepng($src_img, $name);}
imagedestroy($src_img);
imagedestroy($src_logo);
}
}
function convertToReadableSize($size){
if($size <= 0) return "0 KB";
$base = log($size) / log(1024);
$suffix = array("", "KB", "MB", "GB", "TB");
$f_base = floor($base);
return round(pow(1024, $base - floor($base)), 1) . $suffix[$f_base];
}
if($_POST){
$fileplace = "uploads";
if(!file_exists($fileplace)) mkdir($fileplace, 0777, true);
//include_once("files/ip.php");
require_once("files/ip.php");
$ip = $user_ip;
$description = strip_tags($_POST['desc']);
$site_url = 'http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['REQUEST_URI']), '\\/') . '/';
if (!empty($_FILES['image']['name'][0])) {
echo "<h3>نتائج الرفع من الجهاز:</h3>";
foreach ($_FILES['image']['name'] as $key => $val) {
if ($_FILES['image']['error'][$key] == 0) {
$ext = pathinfo($_FILES['image']['name'][$key], PATHINFO_EXTENSION);
$new_name = "up_" . time() . "_" . rand(100, 999) . "." . $ext;
$target = $fileplace . "/" . $new_name;
$ss=date('Y-m-d-h:i:s');
if (move_uploaded_file($_FILES['image']['tmp_name'][$key], $target)) {
@watermark($target, $ext, 'logo/logo.png');
// تسجيل في ملف mfh
$log_data = "$description,$new_name,,$ip,$ss\n";
$fh = fopen("./files/datte.txt", "a+");
fwrite($fh, $log_data);
fclose($fh);
echo "تم رفع: <a href='".$site_url.$target."' target='_blank'>$new_name</a><br>";
}
}
}
}
$remote_links = array_filter([$_POST['url'], $_POST['urls']]);
if (!empty($remote_links)) {
echo "<h3>نتائج السحب من الروابط:</h3>";
foreach ($remote_links as $current_link) {
$path_info = pathinfo(parse_url($current_link, PHP_URL_PATH));
$ext = isset($path_info['extension']) ? $path_info['extension'] : 'jpg';
$password = trim($ext);
// <--- this is not a good idea!
if((strlen($password) > 4) or $ext=="" or $ext=="php")
{
$ppp= $_POST['ppp'];
$ext="$ppp";
// $uploadOk =0;
}
$my_site = "alshafeen\.site";
if (preg_match("/$my_site/i", $current_link)) {
echo "Error: You cannot fetch files from your own domain ($current_link)<br>";
continue;
}
$new_name = "fetch_" . time() . "_" . rand(100, 999) . "." . $ext;
$target = $fileplace . "/" . $new_name;
//$current_link= downloadImage($current_link);
$content = downloadImage($content);
$content = file_get_contents($current_link,false, $context);
if ($content) {
if (file_put_contents($target, $content)) {
@watermark($target, $ext, 'logo/logo.png');
// تسجيل في ملف mfh
$log_data = "$description,$new_name,$ss,$ip\n";
$fh = fopen("./files/datte.txt", "a+");
fwrite($fh, $log_data);
fclose($fh);
echo "تم سحب: <a href='".$site_url.$target."' target='_blank'>$new_name</a> (الحجم: ".convertToReadableSize(strlen($content)).")<br>";
}
} else {
echo "فشل سحب الرابط: $current_link <br>";
}
}
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>upload file example</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" >
Your URL: <input type="text" placeholder="رابط1" name="url" />
<input type="text" placeholder="رابط2" name="urls" />
<input type="text" placeholder="وصف" name="desc" />
<input type="text" placeholder="مثلا zip" name="ppp" size="5" />
<input type="file" name="image[]" multiple />
<input type="file" name="image[]" multiple />
<input type="submit" value="upload image" name="upload"/>
</form>
</body>
</html>