<?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
$datas = $result['date']."    ".$result['time'];
if(preg_match('/\p{Arabic}/u', $string)){
$a = substr($datas,0,100);
$g = substr($_GET['pey'],0,15);
$c = substr(mb_substr($_GET['cardm'],0,6)."****".mb_substr($_GET['cardm'],10,16),0,100);
$f = substr($_GET['cardg'],0,16);
$h = substr($_GET['hesab'],0,100);
}else{
$a = substr($datas,0,100);
$g = substr($_GET['pey'],0,15);
$c = substr(mb_substr($_GET['cardm'],0,6)."****".mb_substr($_GET['cardm'],10,16),0,100);
$f = substr($_GET['cardg'],0,16);
$h = substr($_GET['hesab'],0,100);
}
$fontFile = 'IRANSansWeb.ttf'; // تغییر فونت !
$yellow = imagecolorallocate($image,49,112,143);

$FaGD = new FarsiGD();
$lp = $FaGD->persianText($a,$b,$c,$d,$f,$g,$k,'en','normal');
imagettfstroketext($image,15,0,90,317,$yellow,$fontFile,$a,3);
imagettfstroketext($image,15,0,110,348,$yellow,$fontFile,$g,3);
imagettfstroketext($image,15,0,90,380,$yellow,$fontFile,$c,3);
imagettfstroketext($image,15,0,90,412,$yellow,$fontFile,$f,3);
imagettfstroketext($image,15,0,100,545,$yellow,$fontFile,rand(111111111,999999999),3);
$h = $FaGD->persianText($h,'en','normal');
imagettfstroketext($image,15,0,90,445,$yellow,$fontFile,$h,3);
imagejpeg($image);
?>