root/dev/mods/signature_generator/sig.php @ 39

Revision 39, 1.9 KB (checked in by exi, 14 years ago)

created cache/data for several purposes
small changes to comments and kill details to filter for valid killids
added signature generator alpha-version

Line 
1<?php
2if (!$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
9if (!$plt_id = $_GET['i'])
10{
11    exit;
12}
13require_once("common/class.pilot.php");
14require_once("common/class.corp.php");
15require_once("common/class.alliance.php");
16require_once("common/class.killlist.php");
17
18$pilot = new Pilot($plt_id);
19if (!$pilot->exists())
20{
21    exit;
22}
23$corp = $pilot->getCorp();
24$alliance = $corp->getAlliance();
25
26// we dont generate pictures for non-member
27if (ALLIANCE_ID && $alliance->getID() != ALLIANCE_ID)
28{
29    exit;
30}
31elseif (CORP_ID && $corp->getID() != CORP_ID)
32{
33    exit;
34}
35
36// check for cached version
37if (file_exists('cache/data/sig_'.$plt_id))
38{
39    $age = filemtime('cache/data/sig_'.$plt_id);
40
41    // cache files for 30 minutes
42    if (time() - $age < 30*60)
43    {
44        header('Content-Type: image/png');
45        readfile('cache/data/sig_'.$plt_id);
46        return;
47    }
48}
49
50// check template
51if (!file_exists('mods/signature_generator/signatures/'.$sig_name.'.png'))
52{
53    exit;
54}
55$im = imagecreatefrompng('mods/signature_generator/signatures/'.$sig_name.'.png');
56
57$red = imagecolorallocate($im, 255, 10, 10);
58$orange = imagecolorallocate($im, 150, 120, 20);
59$blue = imagecolorallocate($im, 0, 0, 200);
60$white = imagecolorallocate($im, 255, 255, 255);
61$black = imagecolorallocate($im, 0, 0, 0);
62
63$grey_trans = imagecolorallocatealpha($im, 50, 50, 50, 50);
64$greyred_trans = imagecolorallocatealpha($im, 50, 10, 10, 50);
65
66$name = $pilot->getName();
67
68$list = new KillList();
69$list->setOrdered(true);
70$list->setLimit(1);
71$list->setPodsNoobships(false);
72$list->addInvolvedPilot($pilot);
73$kill = $list->getKill();
74
75require('mods/signature_generator/settings/'.$sig_name.'.php');
76
77header('Content-Type: image/png');
78//imagepng($im);
79imagepng($im, 'cache/data/sig_'.$plt_id);
80readfile('cache/data/sig_'.$plt_id);
81?>
Note: See TracBrowser for help on using the browser.