تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
طلب اضافة ختم الصور لهذا الكود
#39
اضافة الى ماسبق يبدوا ان دالة سحب الملف ودالة ختم الصور لهما الدور الاساسي في النقل
هذا كود سكربت بسيط لسحب الملفات من رابط يسحب جميع الصور ويختمها سوا من صحيفة المرصد او صحيفة الرياض او خبرني لاكن لاينقل الصور من موقع ويكيبيديا
<?php
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);}

$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);}

}# < 150
else
{
return false;
}

}
$context = stream_context_create([
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
    ],
]);
//blog.theonlytutorials.com
//author: agurchand

$memory_limit='128M';

$max_execution_time='300';
if($_POST){
//get the url
$url = $_POST['url'];

//add time to the current filename
$name = basename($url);
list($txt, $ext) = explode(".", $name);
$name = time();
$name = $name.".".$ext;


$ext=".jpg".$ext;
// $ext = end($sepext);     
/*$t=array('jpg' , 'png' , 'gif','ip' , 'rar');
    if(!in_array($ext,$t))
{ echo gggg;}else  {
*/
//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
$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
if($upload)
echo "Success:$name <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="submit" value="upload Images" name="upload"/>
</form>
</body>
</html>

الله يعطيك العافيه على المجهود
ختم الصوره لاكن ظهرت سوداء ليس فيها محتوى
الرد }}}
تم الشكر بواسطة: Amir_Alzubidy


الردود في هذا الموضوع
RE: طلب اضافة ختم الصور لهذا الكود - بواسطة nnnjk - 04-04-26, 05:42 PM


التنقل السريع :


يقوم بقرائة الموضوع: