تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
طلب اضافة ختم الصور لهذا الكود
#21
المفروض كذا يشتغل : 
PHP كود :
<?php

function GetCacheID() {
    global $db;
    $SQL "INSERT INTO " TABLE_PREFIX "y2ksw_imgcache2 (ID) VALUES (0)";
    $db->query_write($SQL);
    return $db->insert_id();
}

function 
DownloadImage($url) {
    if (empty($url)) return false;

    $context stream_context_create([
        'http' => [
            'header' => "User-Agent: Mozilla/5.0\r\n"
        ],
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ]);

    return @file_get_contents($urlfalse$context);
}

function 
CacheImages($message_body$old_message$forum_home) {

    $files = [];
    $n 0;
    $pos_end = -1;

    while (($pos_start strpos(strtolower($message_body), '[img]'$pos_end 1)) !== false) {

        $pos_end strpos(strtolower($message_body), '[/img]'$pos_start 1);
        if ($pos_end === false) break;

        $pos_start += 5;
        $pos_end--;

        $url trim(substr($message_body$pos_start$pos_end $pos_start 1));
        $files[$n]['url'] = $url;
        $n++;
    }

    if (!$n) return $old_message;

    foreach ($files as $i => $file) {

        if (empty($file['url'])) continue;

        if (!empty($forum_home) && strpos($file['url'], $forum_home 'imgcache/2/') !== false) {
            $files[$i]['url'] = '';
            continue;
        }

        $matar strtolower($file['url']);
        if (preg_match("/alshafeen.site|alsh3er.com/i"$matar)) {
            $files[$i]['url'] = '';
            continue;
        }
    }

    for ($i 0$i $n$i++) {
        if (empty($files[$i]['url'])) continue;

        for ($j $i 1$j $n$j++) {
            if ($files[$j]['url'] == $files[$i]['url']) {
                $files[$j]['url'] = '';
            }
        }
    }

    foreach ($files as $file) {

        if (empty($file['url'])) continue;

        $content DownloadImage($file['url']);
        if (!$content) continue;

        $tmp tempnam(sys_get_temp_dir(), "img_");
        file_put_contents($tmp$content);

        $info = @getimagesize($tmp);
        if (!$info) {
            unlink($tmp);
            continue;
        }

        $ext '';

        if ($info['mime'] == 'image/jpeg'$ext 'jpg';
        elseif ($info['mime'] == 'image/png'$ext 'png';
        elseif ($info['mime'] == 'image/gif'$ext 'gif';
        elseif ($info['mime'] == 'image/webp'$ext 'webp';

        if ($ext == '') {
            unlink($tmp);
            continue;
        }

        $id GetCacheID();
        $new_file 'imgcache/2/' $id 'alsh3er.' $ext;

        copy($tmp$new_file);
        unlink($tmp);

        AddWatermark($new_file"alsh3er.site");

        $old_message str_replace($file['url'], $forum_home $new_file$old_message);
    }

    return $old_message;
}

function 
AddWatermark($imagePath$text) {

    $info getimagesize($imagePath);
    if (!$info) return;

    if ($info['mime'] == 'image/jpeg'$img imagecreatefromjpeg($imagePath);
    elseif ($info['mime'] == 'image/png'$img imagecreatefrompng($imagePath);
    elseif ($info['mime'] == 'image/gif'$img imagecreatefromgif($imagePath);
    elseif ($info['mime'] == 'image/webp'$img imagecreatefromwebp($imagePath);
    else return;

    $color imagecolorallocatealpha($img25525525550);

    imagestring(
        $img,
        3,
        imagesx($img) - 120,
        imagesy($img) - 15,
        $text,
        $color
    
);

    if ($info['mime'] == 'image/jpeg'imagejpeg($img$imagePath);
    elseif ($info['mime'] == 'image/png'imagepng($img$imagePath);
    elseif ($info['mime'] == 'image/gif'imagegif($img$imagePath);
    elseif ($info['mime'] == 'image/webp'imagewebp($img$imagePath);

    imagedestroy($img);
}

?>

اذا عندك اني ديسك ترا ممكن نحل المشكلة من زمان
او تيم فيور او حاجه تانية المهم نشوف الدنيا عندك عاملة ازاااي
بكل الاحوال انا صعب احدد من فين المشكلة لذلك طبيعي جداً تظهر معنا الاخطاء
على العموم انت جرب الكود الحالي و بانتظار ردك القادم
تحياتي لك
[صورة مرفقة: 177461173141861.gif]
الرد }}}
تم الشكر بواسطة: nnnjk , nnnjk , nnnjk
#22
يعطيك العافيه
تم تحميل الصوره من موقع صحيفة الرياض وختمها
لاكن لم ينقل لي هذه الصوره
https://www.khaberni.com/upload/news/thu...57c49.webp
الرد }}}
تم الشكر بواسطة: Amir_Alzubidy
#23
هذا النوع من المواقع يستخدم:
حماية Hotlink + ضغط WebP + Headers

استبدل الدالة  DownloadImage فقط :
PHP كود :
function DownloadImage($url) {
    if (empty($url)) return false;

    // الطريقة الأولى
    $context stream_context_create([
        'http' => [
            'header' => "User-Agent: Mozilla/5.0\r\n"
        ],
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ]);

    $data = @file_get_contents($urlfalse$context);

    // إذا فشل → نستخدم cURL
    if ($data === false || strlen($data) < 100) {

        $ch curl_init($url);
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false,
            CURLOPT_TIMEOUT => 20,

            CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120 Safari/537.36',

            CURLOPT_HTTPHEADER => [
                'Accept: image/webp,image/apng,image/*,*/*;q=0.8',
                'Referer: https://www.khaberni.com/',
                'Connection: keep-alive'
            ]
        ]);

        $data curl_exec($ch);
        curl_close($ch);
    }

    return $data;

[صورة مرفقة: 177461173141861.gif]
الرد }}}
تم الشكر بواسطة: nnnjk , nnnjk , nnnjk
#24
مشكور
ياليت يكون السحب من جميع المواقع وليس فقط موقع واحد
على العموم سوف اجربه
الرد }}}
تم الشكر بواسطة: Amir_Alzubidy
#25
(04-04-26, 01:38 AM)nnnjk كتب : مشكور
ياليت يكون السحب من جميع المواقع وليس فقط موقع واحد
على العموم سوف اجربه

الكود الحالي لو اشتغل معاك تمام فهو  يغطي 99% من المواقع
[صورة مرفقة: 177461173141861.gif]
الرد }}}
تم الشكر بواسطة: nnnjk , nnnjk
#26
مشكور
جربته ماسحب الصوره من الموقع المذكور
لي موقع اخر ليس فيه شهادة دومين
https وليس فيه حماية نقل الصور وليس فيه خاصية ssl
لم ينقل الصوره باامتداد webp
اعتقد ان المشكله من نوع الملف webp يحتوي على اربعة حروف وليس ثلاثة حروف
الرد }}}
تم الشكر بواسطة: Amir_Alzubidy
#27
(04-04-26, 02:06 AM)nnnjk كتب : مشكور
جربته ماسحب الصوره من الموقع المذكور
لي موقع اخر ليس فيه شهادة دومين
https وليس فيه حماية نقل الصور وليس فيه خاصية ssl
لم ينقل الصوره باامتداد webp
اعتقد ان المشكله من نوع الملف webp يحتوي على اربعة حروف وليس ثلاثة حروف

لا ابداً  عدد الأحرف ما له أي علاقة
الصورة يتم تحميلها بالفعل لكن لا يتم ختمها فيتم حذفها 

حل مؤقت  تحول WebP إلى JPG وتختمه (حتى لو السيرفر ما يدعم WebP)
لو بعد هذا في موقع ما ينقل هذا يعني السيرفر فيه حماية قوية
الاحتمال الاكبر مشكلة Cloudflare أو Cookies

PHP كود :
<?php
function GetCacheID() {
    global $db;
    $SQL "INSERT INTO " TABLE_PREFIX "y2ksw_imgcache2 (ID) VALUES (0)";
    $db->query_write($SQL);
    return $db->insert_id();
}
function 
DownloadImage($url) {
    if (empty($url)) return false;
    $context stream_context_create([
        'http' => [
            'header' => "User-Agent: Mozilla/5.0\r\n"
        ],
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ]);
    $data = @file_get_contents($urlfalse$context);
    if ($data === false || strlen($data) < 100) {
        $ch curl_init($url);
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false,
            CURLOPT_TIMEOUT => 20,
            CURLOPT_USERAGENT => 'Mozilla/5.0',
            CURLOPT_HTTPHEADER => [
                'Accept: image/webp,image/apng,image/*,*/*;q=0.8',
                'Referer: ' $url
            
]
        ]);
        $data curl_exec($ch);
        curl_close($ch);
    }
    return $data;
}
function 
CacheImages($message_body$old_message$forum_home) {
    $files = [];
    $n 0;
    $pos_end = -1;
    while (($pos_start strpos(strtolower($message_body), '[img]'$pos_end 1)) !== false) {
        $pos_end strpos(strtolower($message_body), '[/img]'$pos_start 1);
        if ($pos_end === false) break;
        $pos_start += 5;
        $pos_end--;
        $url trim(substr($message_body$pos_start$pos_end $pos_start 1));
        $files[$n]['url'] = $url;
        $n++;
    }
    if (!$n) return $old_message;
    foreach ($files as $i => $file) {
        if (empty($file['url'])) continue;
        if (!empty($forum_home) && strpos($file['url'], $forum_home 'imgcache/2/') !== false) {
            $files[$i]['url'] = '';
            continue;
        }
        $matar strtolower($file['url']);
        if (preg_match("/alshafeen.site|alsh3er.com/i"$matar)) {
            $files[$i]['url'] = '';
            continue;
        }
    }
    for ($i 0$i $n$i++) {
        if (empty($files[$i]['url'])) continue;
        for ($j $i 1$j $n$j++) {
            if ($files[$j]['url'] == $files[$i]['url']) {
                $files[$j]['url'] = '';
            }
        }
    }
    foreach ($files as $file) {
        if (empty($file['url'])) continue;
        $content DownloadImage($file['url']);
        if (!$content) continue;
        $tmp tempnam(sys_get_temp_dir(), "img_");
        file_put_contents($tmp$content);
        $info = @getimagesize($tmp);
        $ext '';
        if ($info && isset($info['mime'])) {
            if ($info['mime'] == 'image/jpeg'$ext 'jpg';
            elseif ($info['mime'] == 'image/png'$ext 'png';
            elseif ($info['mime'] == 'image/gif'$ext 'gif';
            elseif ($info['mime'] == 'image/webp'$ext 'jpg';
        }
        if ($ext == '') {
            if (strpos($file['url'], '.webp') !== false) {
                $ext 'jpg';
            } else {
                unlink($tmp);
                continue;
            }
        }
        $id GetCacheID();
        $new_file 'imgcache/2/' $id 'alsh3er.' $ext;
        if ($info && isset($info['mime']) && $info['mime'] == 'image/webp') {
            $img = @imagecreatefromstring(file_get_contents($tmp));
            if ($img) {
                imagejpeg($img$new_file90);
                imagedestroy($img);
            } else {
                copy($tmp$new_file);
            }
        } else {
            copy($tmp$new_file);
        }
        unlink($tmp);
        AddWatermark($new_file"alsh3er.site");
        $old_message str_replace($file['url'], $forum_home $new_file$old_message);
    }
    return $old_message;
}
function 
AddWatermark($imagePath$text) {
    $info getimagesize($imagePath);
    if (!$info) return;
    if ($info['mime'] == 'image/jpeg'$img imagecreatefromjpeg($imagePath);
    elseif ($info['mime'] == 'image/png'$img imagecreatefrompng($imagePath);
    elseif ($info['mime'] == 'image/gif'$img imagecreatefromgif($imagePath);
    else return;
    $color imagecolorallocatealpha($img25525525550);
    imagestring(
        $img,
        3,
        imagesx($img) - 120,
        imagesy($img) - 15,
        $text,
        $color
    
);
    if ($info['mime'] == 'image/jpeg'imagejpeg($img$imagePath);
    elseif ($info['mime'] == 'image/png'imagepng($img$imagePath);
    elseif ($info['mime'] == 'image/gif'imagegif($img$imagePath);
    imagedestroy($img);
}
?>
[صورة مرفقة: 177461173141861.gif]
الرد }}}
تم الشكر بواسطة: nnnjk , nnnjk , nnnjk
#28
تسلم
استبدلت الكود المستخدم بالكود الجديد فنقل الصوره وحول امتداد الصوره الى jpg لاكن لم يختمها
الرد }}}
تم الشكر بواسطة: Amir_Alzubidy
#29
(04-04-26, 02:48 AM)nnnjk كتب : تسلم
استبدلت الكود المستخدم بالكود الجديد فنقل الصوره وحول امتداد الصوره الى jpg لاكن لم يختمها

استبدل دالة AddWatermark بالكامل بهذا:

PHP كود :
function AddWatermark($imagePath$text) {

    $data = @file_get_contents($imagePath);
    if (!$data) return;

    $img = @imagecreatefromstring($data);
    if (!$img) return;

    $color imagecolorallocatealpha($img25525525550);

    imagestring(
        $img,
        3,
        imagesx($img) - 120,
        imagesy($img) - 15,
        $text,
        $color
    
);

    imagejpeg($img$imagePath90);

    imagedestroy($img);

[صورة مرفقة: 177461173141861.gif]
الرد }}}
تم الشكر بواسطة: nnnjk
#30
مشكور
نقل الصوره من نوع webp وغير امتدادها الى jpg ولم يختم الصوره
الرد }}}
تم الشكر بواسطة:



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


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