المشاركات 198 |
+التقييم 8 |
تاريخ التسجيل Oct 2020 |
الاقامة Arbic |
نظام التشغيل Other |
رقم العضوية 2450 |
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>
upload file example
</title>
</head>
<body>
<form action="up.php" method="post" enctype="multipart/form-data" >
<input type="file" name="image[]" multiple />
<input type="submit" value="upload image" name="upload"/>
</form>
</body>
</html>
<?php
include('Thumbnail.class.php');
@header('Content-type: text/html;charset=windows-1252');
//error_reporting(0);
$up= "upload/";
$i=0;
$sepext = explode('.', strtolower($_FILES['image']['name'][$i]));
$type = end($sepext);
$t=array('image/jpeg' , 'image/png' , 'image/gif','image/webp','application/zip' , 'application/rar');
if($_POST['upload']=='upload image')
{
while($_FILES['image']['name'][$i] != null)
{
$type = $_FILES['image']['type'];
$fnames = $_FILES['image']['name'][$i];
$fsize = $_FILES['image']['size'][$i];
$ftype = $_FILES['image']['type'][$i];
$ftemp = $_FILES['image']['tmp_name'][$i];
if($fnames == '')
{
echo 'please enter a file';
}
elseif($fsize > 500000)
{
echo 'the file size is bigger than 5mb';
}
elseif(!in_array($ftype,$t))
{
echo 'the type of file is not allowed';
}
else
{
// if(!in_array($type, $t)) {
if(!file_exists('upload'))
{
mkdir('upload','777');
}
//$fnames = iconv("UTF-8", "Windows-1252//IGNORE", $fnames);
// Displaying the encoded string
//echo $encodedString;
// $fnames="bin2hex($fnames), '\n'";
$fnames="upload/$fnames";
move_uploaded_file($ftemp,$fnames);
$thumb=new Thumbnail("$fnames");
$thumb->quality='100';
$mxx="water.png";
$thumb->img_watermark='watermark.png';
//$fnames="$up.$fnames";
$img_watermark_Hmargin=10;
$img_watermark_Vmargin=10;
//$img_watermark_Valing="TOP";
//$img_watermark_Haling="LEFT";
//$thumb->img_watermark_Valing="left";
$thumb->img_watermark_Valing="left";
$thumb->img_watermark_Haling="top";
// $thumbs->process();
$thumb->process();
// generate image
$thumb->save("$fnames");
if ($ftype =="image/png" or $ftype=="image/jpeg" or $ftype=="image/jpg"or $ftype=="image/gif" or $ftype=="image/webp"){
echo 'Image address: <b><img width="150" src="http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$fnames.' "/><br>';} else {
echo 'http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$fnames.'<br>';
}}
$i++;
}}
?>
<?php
include('Thumbnail.class.php');
// يفضل دائماً استخدام UTF-8 بدلاً من windows-1252 لدعم أفضل للغة العربية
@header('Content-type: text/html;charset=utf-8');
$up = "upload/";
$i = 0;
$t = array('image/jpeg', 'image/png', 'image/gif', 'image/webp', 'application/zip', 'application/rar');
if(isset($_POST['upload']) && $_POST['upload'] == 'upload image')
{
while(!empty($_FILES['image']['name'][$i]))
{
$fnames_orig = $_FILES['image']['name'][$i];
$fsize = $_FILES['image']['size'][$i];
$ftype = $_FILES['image']['type'][$i];
$ftemp = $_FILES['image']['tmp_name'][$i];
// استخراج امتداد الملف الأصلي (مثلاً .png أو .jpg)
$ext = pathinfo($fnames_orig, PATHINFO_EXTENSION);
// --- الحل هنا: توليد اسم جديد للملف ---
// سيتم دمج الوقت الحالي مع رقم عشوائي لضمان عدم التكرار
$new_name = time() . "_" . rand(1000, 9999) . "." . $ext;
$fnames = "upload/" . $new_name;
if($fnames_orig == '') {
echo 'please enter a file';
}
elseif($fsize > 5242880) { // 5MB تقريباً
echo 'the file size is bigger than 5mb';
}
elseif(!in_array($ftype, $t)) {
echo 'the type of file is not allowed';
}
else {
if(!file_exists('upload')) {
mkdir('upload', 0777, true);
}
if(move_uploaded_file($ftemp, $fnames)) {
$thumb = new Thumbnail($fnames);
$thumb->quality = '100';
$thumb->img_watermark = 'watermark.png';
$thumb->img_watermark_Valing = "left";
$thumb->img_watermark_Haling = "top";
$thumb->process();
$thumb->save($fnames);
$full_url = 'http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$fnames;
if (in_array($ftype, array("image/png", "image/jpeg", "image/jpg", "image/gif", "image/webp"))) {
echo 'Image address: <b><a href="'.$full_url.'">'.$full_url.'</a></b><br>';
echo '<img width="150" src="'.$full_url.'"/><br><hr>';
} else {
echo 'File address: <a href="'.$full_url.'">'.$full_url.'</a><br><hr>';
}
}
}
$i++;
}
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
$url=$_POST['url']['$r'];
هذا الكود
PHP كود :
<?php
@header('Content-type: text/html;charset=windows-1256');
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>1,
'ignore_errors'=> true
)
);
$context = stream_context_create
(["http" => array(
"header" => "User-Agent:Mozilla/5.0 (Linux; Android 5.0; SM-G900FD) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.74 Mobile Safari/537.36"
),
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]
);
//$contexttt = stream_context_create($opts);
/* $file = 'https://vb4arb.com/vb/attachment.php?aid=30174';
$newfile = '/home/xxx/domains/xxx.com/public_html/uploads/gooo.jpg';
(copy($file, $newfile,false,$contexttt));
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}*/
//error_reporting(E_ALL);
date_default_timezone_set("Asia/riyadh");
//include("downloads.php");
/*
$agent = $_SERVER["HTTP_USER_AGENT"];
if( preg_match('/MSIE (\d+\.\d+);/', $agent) ) {
echo "You're using Internet Explorer";
} else if (preg_match('/Chrome[\/\s](\d+\.\d+)/', $agent) ) {
echo "You're using Chrome";
} else if (preg_match('/Edge\/\d+/', $agent) ) {
echo "You're using Edge";
} else if ( preg_match('/Firefox[\/\s](\d+\.\d+)/', $agent) ) {
echo "You're using Firefox";
} else if ( preg_match('/OPR[\/\s](\d+\.\d+)/', $agent) ) {
echo "You're using Opera";
} else if (preg_match('/Safari[\/\s](\d+\.\d+)/', $agent) ) {
echo "You're using Safari";
}
*/
//ini_set('user_agent', 'My-Application/2.5');
function watermark($name, $ext, $logo){
if (preg_match("/jpg|jpeg/",$ext)){$src_img=imagecreatefromjpeg($name);}
if (preg_match("/webp/",$ext)){$src_img=imagecreatefromwebp($name);}
if (preg_match("/png/",$ext)){$src_img=imagecreatefrompng($name);}
if (preg_match("/gif/",$ext)){$src_img=imagecreatefromgif($name);}
// if (preg_match("/svg/",$ext)){$src_img=imagecreatefromsvg($name);}
$src_logo = imagecreatefrompng($logo);
$bwidth = imageSX($src_img);
$bheight = imageSY($src_img);
$lwidth = imageSX($src_logo);
$lheight = imageSY($src_logo);
//fix bug for 1beta3
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/",$ext)){imagejpeg($src_img, $name);}
if (preg_match("/png/",$ext)){imagepng($src_img, $name);}
if (preg_match("/webp/",$ext)){imagewebp($src_img, $name);}
if (preg_match("/gif/",$ext)){imagegif($src_img, $name);}
// if (preg_match("/svg/",$ext)){imagesvg($src_img, $name);}
}# < 150
else
{
return false;
}
}
//blog.theonlytutorials.com
//blog.theonlytutorials.com
//author: agurchand
$memory_limit='128M';
$max_execution_time='300';
if($_POST){
//get the url
$url = $_POST['url'];
$urls = $_POST['urls'];
//add time to the current
$newname= basename($urls);
//add time to the current filename
$name = basename($url);
list($txt, $ext ) = explode(".", $name);
list($txt, $type ) = explode(".", $newname);
function convertToReadableSize($size){
$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];
}
/*$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'$url');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, '$name');
$name = curl_exec($curl_handle);
curl_close($curl_handle);*/
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
return curl_exec($ch);
curl_close ($ch);
}
function file_get_html() {
$dom = new simple_html_dom;
$args = func_get_args();
$dom->load(call_user_func_array('curl', $args), true);
return $dom;
}
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch,CURLOPT_HEADER, TRUE); curl_setopt($ch,CURLOPT_NOBODY, TRUE); $name = curl_exec($ch);
$size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); curl_close($ch);
$sizee= convertToReadableSize($size);
//list($width, $height) = getimagesize($url);
$name = date('d-m-Y-H:i:s', time());
//time();
$password = trim($ext);
// <--- this is not a good idea!
if((strlen($password) > 4) or $ext=="svg")
{
$ext="jpg";
// $uploadOk = 0;
}
$name = $name.".".$ext;
$newname = $newname."".$type;
//$namess = basename($url);
$files = new SplFileInfo($name);
$exttt = $files->getExtension();
//PATHINFO_EXTENSION
$extt = pathinfo($name,PATHINFO_EXTENSION);
//if($exttt==""){$ext=".jpg";}
$file_ext = (explode('.', $name));
$end = end($file_ext);
//$ext="jpg";
$ext=".jpg".$ext;
$type="".$type;
// $ext = end($sepext);
/*$t=array('jpg' , 'png' , 'gif','ip' , 'rar');
if(!in_array($ext,$t))
{ echo gggg;}else {
*/
//$namee="http://xxx.com/uploads/$name";
//$size3= getimagesize("http://xxx.com/uploads/07-04-2026-21:16:01.jpg");
//$size2= filesize("http://xxx.com/uploads/07-04-2026-22:20:46.webp") . ' bytes';
//$size1=convertToReadableSize("$namee");
//here is the actual code to get the file from the url and save it to the uploads folder
//get the file from the url using file_get_contents and put it into the folder using file_put_contents
require_once("files/ip.php");
$ip = $user_ip;
$description = strip_tags($_POST['desc']);
$descriptions="$description,$name,$ip";
$namess="ddd";/*
$filelist = fopen("./files/".$namess.".mfh","w");
fwrite($filelist, $name ."|". name ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|".$_POST['pprotect']."|\n");*/
//$password=$_GET['password'];
$fh = fopen("./files/".$namess.".mfh","a+"); fwrite($fh,$descriptions."\n");
//write to txtfile
//fwrite($fh,$password."\n");
// write to txtfile
fclose($fh);
$fileplacee="uploads";
@wateermark($fileplacee."/".$newname,$type,'logo/logo.png');
$newfile = '/home/xxx/domains/xxx.com/public_html/uploads/'.time().'.'.$type.'';
(copy($urls, $newfile));
$upload = file_put_contents("uploads/$name",file_get_contents($url,false,$context));
$fileplace="uploads";
@watermark($fileplace."/".$name,$ext,'logo/logo.png');
//include('Thumbnail.class.php');
// $thumb=new Thumbnail("$name");
// $thumb->quality='100';
// $thumb->process();
// generate image
// $thumb->save("$name");
$filesk= "$name";
//$name = str_replace("?format=jpg","gg",$filesk);
//echo $TXTREM ;
//check success
//$info = getimagesize('http://xxx.com/uploads/$name');
/*$tmp= tmpfile();
$names= "http://xxx.com/uploads/$name";
$ch=curl_init($url);
curl_setopt_array($ch,array(
CURLOPT_FILE=>$tmp,
CURLOPT_ENCODING=>''
));
curl_exec($ch);
curl_close($ch);
list($width, $height) = getimagesize($names);
fclose($tmp);
$filename = "http://xxx.com/uploads/07-04-2026-22:20:46.webp";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);*/
//$ss=filesize($name);
$newfile= str_replace("/home/xxx/domains/xxx.com/public_html/","http://xxx.com/","$newfile");
if($upload)
echo "Success:$name,<br> type: $extt, size: $sizee,$newfile,<br>$name2 <a href='uploads/".$name."' target='_blank'>Check Uploaded</a>"; else "please check your folder permission";
}
//}
?>
<html>
<head><title>Theonlytutorials - Simple File Upload from URL Script!</title></head>
<body>
<h3>Theonlytutorials.com - Very Simple File Upload from URL Script!</h3>
<form action="" method="post">
Your URL: <input type="text" name="url" />
<input type="text" name="urls" />
<input type="text" name="desc" />
<input type="submit" value="upload Images" name="upload"/>
</form>
</body>
</html>
حاولت فيه مااستطع
<?php
@header('Content-type: text/html;charset=windows-1256');
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>1,
'ignore_errors'=> true
)
);
$context = stream_context_create([
"http" => array(
"header" => "User-Agent:Mozilla/5.0 (Linux; Android 5.0; SM-G900FD) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.74 Mobile Safari/537.36"
),
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
date_default_timezone_set("Asia/riyadh");
function watermark($name, $ext, $logo){
if (preg_match("/jpg|jpeg/",$ext)){$src_img=@imagecreatefromjpeg($name);}
if (preg_match("/webp/",$ext)){$src_img=@imagecreatefromwebp($name);}
if (preg_match("/png/",$ext)){$src_img=@imagecreatefrompng($name);}
if (preg_match("/gif/",$ext)){$src_img=@imagecreatefromgif($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/",$ext)){imagejpeg($src_img, $name);}
if (preg_match("/png/",$ext)){imagepng($src_img, $name);}
if (preg_match("/webp/",$ext)){imagewebp($src_img, $name);}
if (preg_match("/gif/",$ext)){imagegif($src_img, $name);}
imagedestroy($src_img);
imagedestroy($src_logo);
} else {
return false;
}
}
$memory_limit='128M';
$max_execution_time='300';
if($_POST){
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];
}
// مصفوفة الروابط من الفورم
$input_urls = array();
if(!empty($_POST['url'])) $input_urls[] = $_POST['url'];
if(!empty($_POST['urls'])) $input_urls[] = $_POST['urls'];
require_once("files/ip.php");
$ip = $user_ip;
$description = strip_tags($_POST['desc']);
$fileplace = "uploads";
foreach($input_urls as $current_url){
// استخراج الامتداد الأصلي وتوليد اسم إنجليزي جديد
$path_parts = pathinfo(parse_url($current_url, PHP_URL_PATH));
$ext = isset($path_parts['extension']) ? $path_parts['extension'] : 'jpg';
// الاسم الجديد يعتمد على الوقت لمنع مشاكل اللغة العربية والتكرار
$new_filename = time() . "_" . rand(100,999) . "." . $ext;
$target_path = $fileplace . "/" . $new_filename;
// سحب الملف
$file_data = @file_get_contents($current_url, false, $context);
if($file_data) {
if(file_put_contents($target_path, $file_data)) {
// إضافة العلامة المائية
@watermark($target_path, $ext, 'logo/logo.png');
// تسجيل في ملف mfh
$descriptions = "$description,$new_filename,$ip";
$fh = fopen("./files/ddd.mfh", "a+");
fwrite($fh, $descriptions . "\n");
fclose($fh);
$full_url = 'http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['REQUEST_URI']), '\\/') . '/' . $target_path;
echo "Success: $new_filename <br> URL: <a href='$full_url' target='_blank'>$full_url</a><br><hr>";
}
} else {
echo "Failed to download: $current_url <br><hr>";
}
}
}
?>
.
|
اضافة رد
|
اريد حل لهذه المشكلة البسيطة وهو ترميز اسماء الملفات
| أدوات الموضوع | |
|
| الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
| اريد منع زوار واعضاء من تحميل الملفات من قسم معين فى المنتدى | مكتبة الأميرة | ركن مشاكل وطلبات المنتديات | 5 | 12-28-2021 08:39 PM |
| طلب بعض التعديلات البسيطة على ستايل هيلبرنت | Freight Club | ركن مشاكل وطلبات المنتديات | 5 | 09-13-2021 07:39 PM |
| مشكله في اسماء الملفات | almayed | ركن مشاكل وطلبات المنتديات | 8 | 11-12-2020 02:23 AM |
| [Facebook] اسماء مزخرفة , اسماء للفيس بوك , زخرفة يقبلها الفيس بوك | S!L3NT H!LL | ركن مواقع التواصل الإجتماعي | 2 | 07-28-2018 07:54 PM |
| اريد حل المشكلة سريعا مشكلة الروابط الصديقة بعد التحويل من vb | GarageJo.com | ركن مشاكل وطلبات الزين فورو XENFORO | 4 | 12-22-2017 11:13 AM |