gc-fallout - certificate
[anomen-overlay.git] / www-apps / gc-fallout / dev / cert.php
blob000a5dba456a8e19a93907b4f65761e36ee71d0c
1 <?php
2 header('Content-type: image/png');
4 require_once('toolbox.php');
6 if (empty($_SERVER["QUERY_STRING"])) {
7 header('X-Error: no token');
8 readfile('img/no.png');
9 die;
12 $token = $_SERVER["QUERY_STRING"];
14 $U = decodeToken($token);
16 $C_WIDTH = PERK_WIDTH*PERK_COLS + (PERK_COLS-1)*PERK_PADDING + 2*CERT_BORDER;
17 $C_HEIGHT = PERK_HEIGHT*PERK_ROWS + (PERK_ROWS-1)*PERK_PADDING + 2*CERT_BORDER;
18 $certimg = imagecreatetruecolor($C_WIDTH, $C_HEIGHT);
19 $bg = imagecolorallocate($certimg, 0xd0, 0xd0, 0xd0);
20 $red_color = imagecolorallocate($certimg, 0xff, 0x00, 0x00);
21 $text_color = imagecolorallocate($certimg, 0x00, 0x7f, 0x00);
22 $ii = chr(0xED);
23 $aa = chr(0xE1);
24 $oo = chr(0xF3);
26 imagefill($certimg, 0, 0, $bg);
28 $bg_img = imagecreatefrompng("img/cert_bg.png");
29 imagecopy($certimg, $bg_img, 0, 0, 0, 0, $C_WIDTH, $C_HEIGHT);
32 $i = 0;
33 foreach($U['perky'] as $perk) {
34 if (file_exists("perky/$perk.png")) {
35 $p = imagecreatefrompng("perky/$perk.png");
37 else if (file_exists("perky/$perk.jpg")) {
38 $p = imagecreatefromjpeg("perky/$perk.jpg");
41 $x = ($i % PERK_COLS) * (PERK_WIDTH + PERK_PADDING);
42 $y = floor($i / PERK_COLS) * (PERK_HEIGHT + PERK_PADDING);
43 imagecopy($certimg, $p, $x + CERT_BORDER , $y + CERT_BORDER, 0, 0, PERK_WIDTH, PERK_HEIGHT);
44 imagedestroy($p);
45 $i++;
48 //for ($i=2; $i < 8; $i ++) {
49 // imagestring($certimg, 5, PERK_WIDTH * 3 / 2, PERK_HEIGHT * ( $i / 3) , 'TEST', $red_color);
50 //}
52 imagestring($certimg, 5, 250, 10, "${U['login']}", $red_color);
53 imagestring($certimg, 5, 600, 10, "Z${aa}tky: ${U['penize']} | Karma: ${U['karma']} | J${ii}dlo: ${U['jidlo']}", $text_color);
54 imagestring($certimg, 5, 50, 10, "Sk${oo}re ${U['skore']}", $text_color);
56 //imagejpeg($certimg, NULL, 90);
57 imagepng($certimg);
58 imagedestroy($certimg);