<?php
error_reporting(0);
include('FarsiGD.php');
function circleWaterMark($imagex,$imagey){
    if(empty($imagex) || empty($imagey))
        throw new Error();
    $imX = imagecreatefromstring(file_get_contents($imagex)) or die();
    $imY = imagecreatefromstring(file_get_contents($imagey)) or die();
    list($source_width, $source_height, $source_type) = getimagesize($imagey);
    list($w, $s, $source_type) = getimagesize($imagex);
    $corner_image = imagecreatetruecolor($source_width,$source_height);
    $clear_colour = imagecolorallocate($corner_image,255,0,255);
    imagecolortransparent($imY,$clear_colour);
    $clear_colour = imagecolorallocate($imX,000,000,255);
    imagecolortransparent($imX,$clear_colour);
    $mask = imagecreatetruecolor($source_width, $source_height);
    $black = imagecolorallocate($mask, 0, 0, 0);
    $magenta = imagecolorallocate($mask, 255, 0, 255);
    imagefill($mask, 0, 0, $magenta);
    imagefilledellipse($mask,$source_width / 2,$source_height / 2,$source_width+5,$source_height,$black);
    imagecolortransparent($mask, $black);
    imagecopymerge($imY,$mask,0,0,0,0,$source_width,$source_height,100);
    $final_img = imagecreatetruecolor($w, $s);
    imagealphablending($final_img, true);
    imagesavealpha($final_img, true);
    imagecopy($final_img, $imY, 315, 170, 0, 0, $source_width, $source_height);
    imagecopy($final_img, $imX, 0, 0, 0, 0, $w, $s);
    return $final_img;
}
function imagettfstroketext(&$image, $size, $angle, $x, $y, &$textcolor, $fontfile, $text, $px) {
    for($c1 = ($x-abs($px)); $c1 <= ($x+abs($px)); $c1++)
        for($c2 = ($y-abs($px)); $c2 <= ($y+abs($px)); $c2++)
            $bg = imagettftext($image, $size, $angle, $c1, $c2, $fontfile, $text);
        return imagettftext($image, $size, $angle, $x, $y, $textcolor, $fontfile, $text);
}

header('content-type:image/jpeg');
$image = circleWaterMark('ch.jpg',$_GET['imgurl']);
$string=$_GET['text'];
$get = file_get_contents("http://api.NovaTeamCo.ir/time");
$result = json_decode($get, true);
#--Result
if(preg_match('/\p{Arabic}/u', $string)){
$g = substr($_GET['pey'],0,15);
$hh = mb_substr($_GET['cardm'],0,4).'-'.mb_substr($_GET['cardm'],4,4).'-'.mb_substr($_GET['cardm'],8,4).'-'.mb_substr($_GET['cardm'],12,16);
$c = substr(mb_substr($hh,0,7)."**-****".mb_substr($hh,14,16),0,100);
$hh4 = mb_substr($_GET['cardg'],0,4).'-'.mb_substr($_GET['cardg'],4,4).'-'.mb_substr($_GET['cardg'],8,4).'-'.mb_substr($_GET['cardg'],12,16);
$f = substr(mb_substr($hh4,0,7)."**-****".mb_substr($hh4,14,16),0,100);
$h = substr($_GET['hesab'],0,100);
}else{
$g = substr($_GET['pey'],0,15);
$hh = mb_substr($_GET['cardm'],0,4).'-'.mb_substr($_GET['cardm'],4,4).'-'.mb_substr($_GET['cardm'],8,4).'-'.mb_substr($_GET['cardm'],12,16);
$c = substr(mb_substr($hh,0,7)."**-****".mb_substr($hh,14,16),0,100);
$hh4 = mb_substr($_GET['cardg'],0,4).'-'.mb_substr($_GET['cardg'],4,4).'-'.mb_substr($_GET['cardg'],8,4).'-'.mb_substr($_GET['cardg'],12,16);
$f = substr(mb_substr($hh4,0,7)."**-****".mb_substr($hh4,14,16),0,100);
$h = substr($_GET['hesab'],0,100);
}
$fontFile = 'IRANSansWeb.ttf'; // تغییر فونت !
$yellow = imagecolorallocate($image,255,255,255);

$FaGD = new FarsiGD();
$lp = $FaGD->persianText($a,$b,$c,$d,$f,$g,$k,'en','normal');
imagettfstroketext($image,20,0,135,530,$yellow,$fontFile,$c,3);
imagettfstroketext($image,20,0,200,607,$yellow,$fontFile,$g,3);
imagettfstroketext($image,20,0,135,735,$yellow,$fontFile,$f,3);
imagettfstroketext($image,20,0,135,805,$yellow,$fontFile,$c,3);
imagettfstroketext($image,20,0,135,875,$yellow,$fontFile,$result['date']." - ".$result['time'],3);
imagettfstroketext($image,20,0,135,945,$yellow,$fontFile,rand(111111111,999999999),3);
imagettfstroketext($image,20,0,135,1010,$yellow,$fontFile,rand(1111111111,9999999999),3);
$h = $FaGD->persianText($h,'en','normal');
imagettfstroketext($image,20,0,135,665,$yellow,$fontFile,$h,3);
imagejpeg($image);
?>