gc-fallout - cert. background
[anomen-overlay.git] / www-apps / gc-fallout / dev / cert.php
blob737d7b58ec0ecc1ad3a6fc2d8184808aeb583282
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);
24 imagefill($certimg, 0, 0, $bg);
26 $bg_img = imagecreatefrompng("img/cert_bg.png");
27 imagecopy($certimg, $bg_img, 0, 0, 0, 0, $C_WIDTH, $C_HEIGHT);
30 $i = 0;
31 foreach($U['perky'] as $perk) {
32 if (file_exists("perky/$perk.png")) {
33 $p = imagecreatefrompng("perky/$perk.png");
35 else if (file_exists("perky/$perk.jpg")) {
36 $p = imagecreatefromjpeg("perky/$perk.jpg");
39 $x = ($i % PERK_COLS) * (PERK_WIDTH + PERK_PADDING);
40 $y = floor($i / PERK_COLS) * (PERK_HEIGHT + PERK_PADDING);
41 imagecopy($certimg, $p, $x + CERT_BORDER , $y + CERT_BORDER, 0, 0, PERK_WIDTH, PERK_HEIGHT);
42 imagedestroy($p);
43 $i++;
46 //for ($i=2; $i < 8; $i ++) {
47 // imagestring($certimg, 5, PERK_WIDTH * 3 / 2, PERK_HEIGHT * ( $i / 3) , 'TEST', $red_color);
48 //}
50 imagestring($certimg, 5, 20, 10, "${U['login']}", $red_color);
51 imagestring($certimg, 5, 20, 30, "Pen${ii}ze: ${U['penize']} | Karma: ${U['karma']} | J${ii}dlo: ${U['jidlo']}", $text_color);
52 imagestring($certimg, 5, 180, 10, "Skore ${U['skore']}", $text_color);
54 //imagejpeg($certimg, NULL, 90);
55 imagepng($certimg);
56 imagedestroy($certimg);