1 | <?
|
---|
2 | include("config.php");
|
---|
3 | $file = fopen($irpg_db,"r");
|
---|
4 | fgets($file, 1024);
|
---|
5 |
|
---|
6 | session_start(); // sessions to generate only one map / person / 20s
|
---|
7 | if (isset($_SESSION['time']) && time()-$_SESSION['time'] < 20) {
|
---|
8 | header("Location: maperror.png");
|
---|
9 | exit(0);
|
---|
10 | }
|
---|
11 | $_SESSION['time']=time();
|
---|
12 | $file = fopen($irpg_qfile,"r");
|
---|
13 | $type=0;
|
---|
14 | while ($line=fgets($file,1024)) {
|
---|
15 | $arg = explode(" ",trim($line));
|
---|
16 | if ($arg[0] == "Y") {
|
---|
17 | $type = $arg[1];
|
---|
18 | }
|
---|
19 | elseif ($arg[0] == "P") {
|
---|
20 | $p1[0] = $arg[1];
|
---|
21 | $p1[1] = $arg[2];
|
---|
22 | $p2[0] = $arg[3];
|
---|
23 | $p2[1] = $arg[4];
|
---|
24 | }
|
---|
25 | elseif ($arg[0] == "S") {
|
---|
26 | if ($type == 1) $time = $arg[1];
|
---|
27 | elseif ($type == 2) $stage = $arg[1];
|
---|
28 | }
|
---|
29 | elseif ($arg[0] == "P1") {
|
---|
30 | $player[1]['name'] = $arg[1];
|
---|
31 | if ($type == 2) {
|
---|
32 | $player[1]['x'] = $arg[2];
|
---|
33 | $player[1]['y'] = $arg[3];
|
---|
34 | }
|
---|
35 | }
|
---|
36 | elseif ($arg[0] == "P2") {
|
---|
37 | $player[2]['name'] = $arg[1];
|
---|
38 | if ($type == 2) {
|
---|
39 | $player[2]['x'] = $arg[2];
|
---|
40 | $player[2]['y'] = $arg[3];
|
---|
41 | }
|
---|
42 | }
|
---|
43 | elseif ($arg[0] == "P3") {
|
---|
44 | $player[3]['name'] = $arg[1];
|
---|
45 | if ($type == 2) {
|
---|
46 | $player[3]['x'] = $arg[2];
|
---|
47 | $player[3]['y'] = $arg[3];
|
---|
48 | }
|
---|
49 | }
|
---|
50 | elseif ($arg[0] == "P4") {
|
---|
51 | $player[4]['name'] = $arg[1];
|
---|
52 | if ($type == 2) {
|
---|
53 | $player[4]['x'] = $arg[2];
|
---|
54 | $player[4]['y'] = $arg[3];
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|
58 | if ($type != 2) {
|
---|
59 | header("Location: maperror.png");
|
---|
60 | exit(0);
|
---|
61 | }
|
---|
62 |
|
---|
63 | $map = imageCreate(500,500);
|
---|
64 | $magenta = imageColorAllocate($map, 255, 0, 255);
|
---|
65 | imageColorTransparent($map,$magenta);
|
---|
66 | $blue = imageColorAllocate($map, 0, 128, 255);
|
---|
67 | $red = imageColorAllocate($map, 255, 0, 0);
|
---|
68 |
|
---|
69 | imageFilledEllipse($map, $player[1]['x'], $player[1]['y'], 6, 6, $blue);
|
---|
70 | imageFilledEllipse($map, $player[2]['x'], $player[2]['y'], 6, 6, $blue);
|
---|
71 | imageFilledEllipse($map, $player[3]['x'], $player[3]['y'], 6, 6, $blue);
|
---|
72 | imageFilledEllipse($map, $player[4]['x'], $player[4]['y'], 6, 6, $blue);
|
---|
73 | if ($stage == 1) imageFilledEllipse($map, $p1[0], $p1[1], 8, 8, $red);
|
---|
74 | else imageFilledEllipse($map, $p2[0], $p2[1], 9, 9, $red);
|
---|
75 |
|
---|
76 | header("Content-type: image/png");
|
---|
77 | imagePNG($map);
|
---|
78 | imageDestroy($map);
|
---|
79 | ?>
|
---|