Файл: pages/render/manekenImage.php
Строк: 46
<?php
declare(strict_types=1);
if (!defined('GAME_ROOT')) define('GAME_ROOT', dirname(__DIR__, 2));
chdir(GAME_ROOT);
if (PHP_SAPI !== 'cli') { $_SERVER['PHP_SELF']='/manekenImage.php'; $_SERVER['SCRIPT_NAME']='/manekenImage.php'; }
require_once './system/common.php'; require_once './system/functions.php';
header('Content-Type: image/png');
$g=max(0,min(1,(int)($_GET['g']??0)));
$base='./images/maneken/'.$g.'.png';
if(!is_file($base)){http_response_code(404);exit;}
$image=@imagecreatefrompng($base); if(!$image){http_response_code(500);exit;}
imagealphablending($image,true); imagesavealpha($image,true);
// Historical layer order is important for clothing overlap.
foreach([7,8,3,1,2,4,6,5] as $slot){
$itemId=max(0,(int)($_GET['w_'.$slot]??0)); if($itemId<=0)continue;
$item=db_fetch_one('SELECT `w` FROM `items` WHERE `id`=:i LIMIT 1',['i'=>$itemId]);
$path='./images/maneken/'.$g.'/'.$itemId.'.png';
if(!$item || (int)($item['w']??0)!==$slot || !is_file($path))continue;
$layer=@imagecreatefrompng($path); if(!$layer)continue;
imagealphablending($layer,true); imagesavealpha($layer,true);
imagecopy($image,$layer,0,0,0,0,min(imagesx($image),imagesx($layer)),min(imagesy($image),imagesy($layer)));
}
imagepng($image);