| 1 |
<?php |
| 2 |
/* |
| 3 |
* @author: Jakub Stasiak <kuba.stasiak at gmail.com> |
| 4 |
*/ |
| 5 |
|
| 6 |
function u2i ($str) |
| 7 |
{ |
| 8 |
// return iconv ('utf-8', 'iso8859-2', $str); |
| 9 |
return $str; |
| 10 |
} |
| 11 |
|
| 12 |
/* |
| 13 |
function g ($str) // taki wrapper, później się da die albo error w przypadku stringa niezgodnego z konwencją |
| 14 |
{ |
| 15 |
return addslashes ($str); |
| 16 |
} |
| 17 |
*/ |
| 18 |
|
| 19 |
function Usage () |
| 20 |
{ |
| 21 |
global $DefaultFont; |
| 22 |
global $DefaultSize; |
| 23 |
$font = $DefaultFont; |
| 24 |
$size = $DefaultSize; |
| 25 |
|
| 26 |
$img = ImageCreate (500, 60); |
| 27 |
|
| 28 |
$bg = ImageColorAllocate ($img, 255, 255, 255); |
| 29 |
$red = ImageColorAllocate ($img, 255, 0, 0); |
| 30 |
|
| 31 |
ImageTTFText ($img, $size*1.2, 0, 5, 10+$size*1.2, $red, $font, u2i (SIGN_INVALID_PARAMS_NOTIFY)); |
| 32 |
ImageTTFText ($img, $size*1.2, 0, 5, 15 + 2*$size*1.2, $red, $font, u2i (SIGN_VALID_PARAMS_EXAMPLE)); |
| 33 |
ImageTTFText ($img, $size*1.2, 0, 5, 20 + 3*$size*1.2, $red, $font, u2i (STH)); |
| 34 |
|
| 35 |
ImageJPEG ($img, '', 60); |
| 36 |
exit; |
| 37 |
} |
| 38 |
|
| 39 |
require_once ('includes/config.php'); |
| 40 |
|
| 41 |
require_once ('includes/getlang.php'); |
| 42 |
GetLang (); |
| 43 |
GetLoc ('sign'); |
| 44 |
|
| 45 |
$DefaultSize = 9; |
| 46 |
$DefaultFont = './fonts/Vera.ttf'; |
| 47 |
|
| 48 |
|
| 49 |
header ('Content-type: image/jpeg'); |
| 50 |
|
| 51 |
if ( |
| 52 |
!isset ($_GET['id']) or !is_numeric ($_GET['id']) |
| 53 |
or $_GET['id'] < 1 |
| 54 |
or !isset ($_GET['type']) or !is_numeric ($_GET['type']) |
| 55 |
or $_GET['type'] < 1 or $_GET['type'] > 3 |
| 56 |
) { |
| 57 |
Usage (); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
if(time() - @filectime('images/sigs/cache/'.$_GET['id'].'-'.$_GET['type'].'.jpg') > 43200) |
| 62 |
{ |
| 63 |
$id = $_GET['id']; |
| 64 |
$type = $_GET['type']; |
| 65 |
|
| 66 |
$res = $db->getRow ('SELECT p.user, p.level, p.rasa, p.klasa, p.age, t.type FROM players p LEFT JOIN team t ON t.gameid=p.id WHERE p.id=\''.$id.'\''); |
| 67 |
|
| 68 |
if (empty($res['level'])) { |
| 69 |
Usage (); |
| 70 |
} |
| 71 |
if(!empty($res['type'])) |
| 72 |
{ |
| 73 |
$stype = $type.$res['type']; |
| 74 |
} |
| 75 |
else |
| 76 |
{ |
| 77 |
$stype = $type; |
| 78 |
} |
| 79 |
|
| 80 |
$nick = $res['user']; |
| 81 |
$class = $res['klasa']; |
| 82 |
$race = $res['rasa']; |
| 83 |
$age = $res['age']; |
| 84 |
$level = $res['level']; |
| 85 |
|
| 86 |
$nickstr = $nick.' ('.$id.')'; |
| 87 |
$racestr = $race.' '.$class; |
| 88 |
$levelstr = LEVEL.' '.$level.'. '.AGE.' '.$age.'.'; |
| 89 |
$smallstr = $nick.' ('.$id.')'; |
| 90 |
|
| 91 |
|
| 92 |
$basepath = 'images/sigs'; |
| 93 |
$img = ImageCreateFromJpeg($basepath.'/'.$stype.'.jpg'); |
| 94 |
$white = ImageColorAllocate ($img, 255, 255, 255); |
| 95 |
$black = ImageColorAllocate ($img, 0, 0, 0); |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
switch ($type) { |
| 100 |
//TODO: jeszcze jakiś mały userbarek by pasowało zrobić, ale to w wolnej chwili |
| 101 |
/*case '4': |
| 102 |
ImageString ($img, $size, 5, 5, u2i ($smallstr), $white); |
| 103 |
break; */ |
| 104 |
case '1': |
| 105 |
case '2': |
| 106 |
case '3': |
| 107 |
$font = $DefaultFont; |
| 108 |
$size = $DefaultSize; |
| 109 |
ImageTTFText ($img, $size, 0, 11, 11+$size, $white, $font, u2i ($nickstr)); |
| 110 |
ImageTTFText ($img, $size, 0, 11, 45+$size, $white, $font, u2i ($racestr)); |
| 111 |
ImageTTFText ($img, $size, 0, 11, 79+$size, $white, $font, u2i ($levelstr)); |
| 112 |
} |
| 113 |
|
| 114 |
ImageJPEG ($img, 'images/sigs/cache/'.$_GET['id'].'-'.$_GET['type'].'.jpg', 90); |
| 115 |
} |
| 116 |
virtual('images/sigs/cache/'.$_GET['id'].'-'.$_GET['type'].'.jpg'); |
| 117 |
?> |