[39] | 1 | <?php |
---|
| 2 | if (!$sig_name = $_GET['s']) |
---|
| 3 | { |
---|
| 4 | $sig_name = 'default'; |
---|
| 5 | } |
---|
| 6 | $sig_name = str_replace('.', '', $sig_name); |
---|
| 7 | $sig_name = str_replace('/', '', $sig_name); |
---|
| 8 | |
---|
[165] | 9 | function errorPic($string) |
---|
[39] | 10 | { |
---|
[165] | 11 | $im = imagecreate(200, 60); |
---|
| 12 | $black = imagecolorallocate($im, 0, 0, 0); |
---|
| 13 | $red = imagecolorallocate($im, 250, 200, 20); |
---|
| 14 | imagefill($im, 1, 1, $black); |
---|
| 15 | imagestring($im, 3, 10, 10, 'Error: '.$string, $red); |
---|
| 16 | header('Content-Type: image/jpeg'); |
---|
| 17 | imagejpeg($im); |
---|
[39] | 18 | exit; |
---|
| 19 | } |
---|
[165] | 20 | |
---|
| 21 | if (!$plt_id = $_GET['i']) |
---|
| 22 | { |
---|
| 23 | errorPic('No pilot id specified.'); |
---|
| 24 | } |
---|
[190] | 25 | require_once("common/includes/class.pilot.php"); |
---|
| 26 | require_once("common/includes/class.corp.php"); |
---|
| 27 | require_once("common/includes/class.alliance.php"); |
---|
| 28 | require_once("common/includes/class.killlist.php"); |
---|
[39] | 29 | |
---|
| 30 | $pilot = new Pilot($plt_id); |
---|
| 31 | if (!$pilot->exists()) |
---|
| 32 | { |
---|
[165] | 33 | errorPic('That pilot doesnt exist.'); |
---|
[39] | 34 | } |
---|
| 35 | $corp = $pilot->getCorp(); |
---|
| 36 | $alliance = $corp->getAlliance(); |
---|
| 37 | |
---|
| 38 | // we dont generate pictures for non-member |
---|
| 39 | if (ALLIANCE_ID && $alliance->getID() != ALLIANCE_ID) |
---|
| 40 | { |
---|
[165] | 41 | errorPic('Wrong alliance.'); |
---|
[39] | 42 | } |
---|
| 43 | elseif (CORP_ID && $corp->getID() != CORP_ID) |
---|
| 44 | { |
---|
[165] | 45 | errorPic('Wrong corporation.'); |
---|
[39] | 46 | } |
---|
| 47 | |
---|
[72] | 48 | $id = abs(crc32($sig_name)); |
---|
[39] | 49 | // check for cached version |
---|
[72] | 50 | if (file_exists('cache/data/sig_'.$id.'_'.$plt_id)) |
---|
[39] | 51 | { |
---|
[72] | 52 | $age = filemtime('cache/data/sig_'.$id.'_'.$plt_id); |
---|
[39] | 53 | |
---|
| 54 | // cache files for 30 minutes |
---|
| 55 | if (time() - $age < 30*60) |
---|
| 56 | { |
---|
[87] | 57 | if (file_exists('mods/signature_generator/signatures/'.$sig_name.'/typ.png')) |
---|
| 58 | { |
---|
| 59 | header('Content-Type: image/png'); |
---|
| 60 | } |
---|
| 61 | else |
---|
| 62 | { |
---|
| 63 | header('Content-Type: image/jpeg'); |
---|
| 64 | } |
---|
[72] | 65 | readfile('cache/data/sig_'.$id.'_'.$plt_id); |
---|
[39] | 66 | return; |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | // check template |
---|
[72] | 71 | if (!is_dir('mods/signature_generator/signatures/'.$sig_name)) |
---|
[39] | 72 | { |
---|
[165] | 73 | errorPic('Template not found.'); |
---|
[39] | 74 | } |
---|
| 75 | |
---|
[87] | 76 | // let the template do the work, we just output $im |
---|
[72] | 77 | require('mods/signature_generator/signatures/'.$sig_name.'/'.$sig_name.'.php'); |
---|
[39] | 78 | |
---|
[87] | 79 | if (file_exists('mods/signature_generator/signatures/'.$sig_name.'/typ.png')) |
---|
| 80 | { |
---|
| 81 | header('Content-Type: image/png'); |
---|
| 82 | } |
---|
| 83 | else |
---|
| 84 | { |
---|
| 85 | header('Content-Type: image/jpeg'); |
---|
| 86 | } |
---|
[72] | 87 | imagejpeg($im, 'cache/data/sig_'.$id.'_'.$plt_id, 95); |
---|
| 88 | readfile('cache/data/sig_'.$id.'_'.$plt_id); |
---|
[39] | 89 | ?> |
---|