02-04-26, 02:02 AM
(آخر تعديل لهذه المشاركة : 02-04-26, 02:04 AM {2} بواسطة Amir_Alzubidy.)
PHP كود :
<?php
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
function GetCacheID()
{
global $db;
$SQL = "INSERT INTO " . TABLE_PREFIX . "y2ksw_imgcache2 (ID) VALUES (0)";
$db->query_write($SQL);
return $db->insert_id();
}
function CacheImages($message_body, $old_message, $forum_home)
{
$n = 0;
$pos_end = -1;
for(;;)
{
$pos_start = strpos(strtolower($message_body), '[img]', $pos_end + 1);
if($pos_start === FALSE) break;
$pos_end = strpos(strtolower($message_body), '[/img]', $pos_start + 1);
if($pos_end === FALSE) break;
$pos_start += 5;
$pos_end--;
$files[$n]['url'] = substr($message_body, $pos_start, $pos_end - $pos_start + 1);
$n++;
}
if(!$n) return $old_message;
for($i = 0; $i < $n; $i++)
{
if(strpos($files[$i]['url'], $forum_home . 'imgcache/2/') !== FALSE)
$files[$i]['url'] = '';
$matar = strtolower($files[$i]['url']);
if (preg_match("/alshafeen.site|alsh3er.com/i", $matar)) $files[$i]['url'] = '';
}
for($i = 0; $i < $n; $i++)
{
$a = $files[$i]['url'];
if($a)
{
for($j = $i + 1; $j < $n; $j++)
{
if($files[$j]['url'] == $a) $files[$j]['url'] = '';
}
}
}
for($i = 0; $i < $n; $i++)
{
if(@getimagesize($files[$i]['url']))
{
$files[$i]['content'] = @file_get_contents($files[$i]['url'], false, $GLOBALS['context']);
$typemkhm = strrchr($files[$i]['url'], '.');
}
}
for($i = 0; $i < $n; $i++)
{
$k = strlen($files[$i]['content']);
if($k)
{
$id = GetCacheID();
$f = 'imgcache/2/' . sprintf('%d', $id) . 'alsh3er' . $typemkhm;
$hFile = @fopen($f, 'wb');
if($hFile)
{
@fwrite($hFile, $files[$i]['content'], $k);
fclose($hFile);
$files[$i]['content'] = '';
// إضافة ختم نصي على الصورة
AddWatermark($f, "alsh3er.site");
$old_url = $files[$i]['url'];
$new_url = $forum_home . $f;
$old_message = str_replace($old_url, $new_url, $old_message);
}
}
}
return $old_message;
}
function AddWatermark($imagePath, $text)
{
$info = getimagesize($imagePath);
$mime = $info['mime'];
switch($mime) {
case 'image/jpeg': $img = imagecreatefromjpeg($imagePath); break;
case 'image/png': $img = imagecreatefrompng($imagePath); break;
case 'image/gif': $img = imagecreatefromgif($imagePath); break;
default: return;
}
$color = imagecolorallocatealpha($img, 255, 255, 255, 50); // أبيض شفاف
$font = __DIR__ . '/arial.ttf'; // ضع خط TTF هنا
$font_size = 12;
if(file_exists($font)) {
$bbox = imagettfbbox($font_size, 0, $font, $text);
$x = imagesx($img) - ($bbox[2] - $bbox[0]) - 10;
$y = imagesy($img) - 10;
imagettftext($img, $font_size, 0, $x, $y, $color, $font, $text);
}
switch($mime) {
case 'image/jpeg': imagejpeg($img, $imagePath); break;
case 'image/png': imagepng($img, $imagePath); break;
case 'image/gif': imagegif($img, $imagePath); break;
}
imagedestroy($img);
}
?>إذا فيه صور WebP، ما رح ينقلها أو يضيف لها ختم
إذا الصورة.jpg,.png, أو.gifالكود يشتغل تمام
إذا الصورة.imagecreatefromjpeg/png/gif
تفشل، وما رح ينزل الصورة ولا يضيف الختم
الحل هو استخدام دوال WebP
-----------------------
كود اخر باستخدام دوال WebP :
يدعم جميع أنواع الصور مثل JPG, PNG, GIF, WebP.
اضافة ختم نصي أسفل يمين كل صورة.
يعمل مباشرة بدون كرون
تنقل الصور من أي URL حتى لو SSL غير موثوق.
PHP كود :
<?php
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
function GetCacheID()
{
global $db;
$SQL = "INSERT INTO " . TABLE_PREFIX . "y2ksw_imgcache2 (ID) VALUES (0)";
$db->query_write($SQL);
return $db->insert_id();
}
function CacheImages($message_body, $old_message, $forum_home)
{
$n = 0;
$pos_end = -1;
for(;;)
{
$pos_start = strpos(strtolower($message_body), '[img]', $pos_end + 1);
if($pos_start === FALSE) break;
$pos_end = strpos(strtolower($message_body), '[/img]', $pos_start + 1);
if($pos_end === FALSE) break;
$pos_start += 5;
$pos_end--;
$files[$n]['url'] = substr($message_body, $pos_start, $pos_end - $pos_start + 1);
$n++;
}
if(!$n) return $old_message;
for($i = 0; $i < $n; $i++)
{
if(strpos($files[$i]['url'], $forum_home . 'imgcache/2/') !== FALSE)
$files[$i]['url'] = '';
$matar = strtolower($files[$i]['url']);
if (preg_match("/alshafeen.site|alsh3er.com/i", $matar)) $files[$i]['url'] = '';
}
for($i = 0; $i < $n; $i++)
{
$a = $files[$i]['url'];
if($a)
{
for($j = $i + 1; $j < $n; $j++)
{
if($files[$j]['url'] == $a) $files[$j]['url'] = '';
}
}
}
for($i = 0; $i < $n; $i++)
{
if(@getimagesize($files[$i]['url']))
{
$files[$i]['content'] = @file_get_contents($files[$i]['url'], false, $GLOBALS['context']);
$files[$i]['ext'] = strtolower(pathinfo($files[$i]['url'], PATHINFO_EXTENSION));
}
}
for($i = 0; $i < $n; $i++)
{
$k = strlen($files[$i]['content']);
if($k)
{
$id = GetCacheID();
$f = 'imgcache/2/' . sprintf('%d', $id) . 'alsh3er.' . $files[$i]['ext'];
$hFile = @fopen($f, 'wb');
if($hFile)
{
@fwrite($hFile, $files[$i]['content'], $k);
fclose($hFile);
$files[$i]['content'] = '';
// إضافة ختم نصي على الصورة
AddWatermark($f, "alsh3er.site");
$old_url = $files[$i]['url'];
$new_url = $forum_home . $f;
$old_message = str_replace($old_url, $new_url, $old_message);
}
}
}
return $old_message;
}
function AddWatermark($imagePath, $text)
{
$info = getimagesize($imagePath);
$mime = $info['mime'];
switch($mime) {
case 'image/jpeg': $img = imagecreatefromjpeg($imagePath); break;
case 'image/png': $img = imagecreatefrompng($imagePath); break;
case 'image/gif': $img = imagecreatefromgif($imagePath); break;
case 'image/webp': $img = imagecreatefromwebp($imagePath); break;
default: return;
}
$color = imagecolorallocatealpha($img, 255, 255, 255, 50); // أبيض شفاف
$font = __DIR__ . '/arial.ttf'; // ضع خط TTF هنا
$font_size = 12;
if(file_exists($font)) {
$bbox = imagettfbbox($font_size, 0, $font, $text);
$x = imagesx($img) - ($bbox[2] - $bbox[0]) - 10;
$y = imagesy($img) - 10;
imagettftext($img, $font_size, 0, $x, $y, $color, $font, $text);
}
switch($mime) {
case 'image/jpeg': imagejpeg($img, $imagePath); break;
case 'image/png': imagepng($img, $imagePath); break;
case 'image/gif': imagegif($img, $imagePath); break;
case 'image/webp': imagewebp($img, $imagePath); break;
}
imagedestroy($img);
}
?>

![[صورة مرفقة: 177461173141861.gif]](https://up6.cc/2026/03/177461173141861.gif)