Файл: pages/render/manekenImage2.php
Строк: 64
<?php
// Physical module map v50.6: public URL stays clean while code lives in /pages.
if (!defined('GAME_ROOT')) define('GAME_ROOT', dirname(__DIR__, 2));
chdir(GAME_ROOT);
if (PHP_SAPI !== 'cli') { $_SERVER['PHP_SELF']='/manekenImage2.php'; $_SERVER['SCRIPT_NAME']='/manekenImage2.php'; }
/* Манекен Арены: безопасная генерация изображения PHP 8.4/GD; by Метриум (Стэлп) */
require_once GAME_ROOT.'/system/common.php';
require_once GAME_ROOT.'/system/functions.php';
header('Content-Type: image/jpeg');
header('Cache-Control: public, max-age=300');
$g = isset($_GET['g']) ? (int)_num($_GET['g']) : 0;
$g = in_array($g, [0,1], true) ? $g : 0;
$baseCandidates = [
GAME_ROOT.'/images/maneken/arena/'.$g.'.png',
GAME_ROOT.'/images/maneken/'.$g.'.png',
GAME_ROOT.'/images/maneken/arena/0.png',
GAME_ROOT.'/images/maneken/0.png',
];
$image = false;
foreach ($baseCandidates as $base) {
if (is_file($base)) {
$tmp = @imagecreatefrompng($base);
if ($tmp instanceof GdImage) { $image = $tmp; break; }
}
}
if (!$image) {
$image = imagecreatetruecolor(120,160);
$bg = imagecolorallocate($image, 24,24,24);
imagefilledrectangle($image,0,0,119,159,$bg);
}
foreach ([7,8,3,1,2,4,6,5] as $slot) {
$key='w_'.$slot;
$itemId = isset($_GET[$key]) ? (int)_num($_GET[$key]) : 0;
if ($itemId <= 0) continue;
$item = db_fetch_one('SELECT `id`,`w` FROM `items` WHERE `id` = :id LIMIT 1', ['id'=>$itemId]);
if (!$item || (int)($item['w'] ?? 0) !== $slot) continue;
$layerPath = GAME_ROOT.'/images/maneken/'.$g.'/'.$itemId.'.png';
if (!is_file($layerPath)) continue;
$layer = @imagecreatefrompng($layerPath);
if (!$layer instanceof GdImage) continue;
imagealphablending($image, true);
imagecopy($image,$layer,0,0,0,0,min(120,imagesx($layer)),min(160,imagesy($layer)));
}
imagejpeg($image,null,90);
exit;