<?php
/**
 * Project:        M.VuiZ.Net
 * Author:         nampt.me <admin@vuiz.net>
 * Copyright:      © 2025 vuiz.net All rights reserved.
 */
header('Content-Type: image/png');
header('Content-disposition: attachment;filename="logo.png"');
$text = empty($_GET['text']) ? 'ONE PIECE' : $_GET['text'];
$texts = empty($_GET['texts']) ? 'Thời đại hải tặc' : $_GET['texts'];
$size = empty($_GET['size']) ? 40 : $_GET['size'];
 
$font = __DIR__.'/UVNBanTay.TTF';
$bbox= imagettfbbox(20,0,$font,$texts);
$rong= $bbox[2];

function get($url, $data){
	$curl = curl_init($url);
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_POST, true);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	$headers = array(
		"Content-Type: application/x-www-form-urlencoded",
	);
	curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
	$data = http_build_query($data);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	$result = curl_exec($curl);
	curl_close($curl);
	return $result;
}
$url = 'https://fontmeme.com/loadme_21.php';
$sent = array('name'=>'one piece font.ttf','text'=>$text,'size'=>$size,'style_color'=>'4F6FFF','style_effect'=>'Style-Cuphead');
$path = trim(get($url,$sent));
//$path = 'http://anonymouse.org/cgi-bin/anon-www.cgi/'.$path;
/*
$files = 'down/'.basename($path).'.png';
copy($path,$files);
*/
$img = imagecreatefrompng($path);
$size= getimagesize($path);
$w=$size[0]; //rong
$h=$size[1];//cao


$y = $h+28;
$icon = imagecreatefrompng('licon.png');
$icon2 = imagecreatefrompng('licon2.png');
$im  = imagecreatetruecolor($w+120,84);
$mau = imagecolorallocate($im,213,38,50);
imagealphablending($im,false);
imagesavealpha($im,true);
$transparent = imagecolorallocatealpha($im, 255, 255, 255, 127);
imagefilledrectangle($im, 0, 0, $w+120,84, $transparent);


imagecopy($im,$icon,0,0,0,0,imagesx($icon),imagesy($icon));
imagecopy($im,$icon2,$w+55,0,0,0,imagesx($icon2),imagesy($icon2));
imagecopy($im,$img,55,30,0,0,$w,$h);

$vt = ($w+120-$rong)/2;
imagefttext($im, 20, 0, $vt, 27, $mau, $font,$texts);
imagepng($im);
imagedestroy($im);

?>