-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakeworldmap.php
More file actions
39 lines (37 loc) · 1.47 KB
/
makeworldmap.php
File metadata and controls
39 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?
include("config.php");
$file = fopen($irpg_db,"r");
fgets($file,1024);
$itemfile = fopen($irpg_itemdb,"r");
fgets($itemfile,1024);
session_start(); // sessions to generate only one map / person / 20s
if (isset($_SESSION['time']) && time()-$_SESSION['time'] < 20) {
header("Location: maperror.png");
exit(0);
}
$_SESSION['time']=time();
$map = imageCreate(500,500);
$magenta = ImageColorAllocate($map, 255, 0, 255);
$blue = imageColorAllocate($map, 0, 128, 255);
$red = imageColorAllocate($map, 211, 0, 0);
$orange = imageColorAllocate($map, 255, 128, 0);
$yellow = imageColorAllocate($map, 255, 192, 0);
ImageColorTransparent($map, $magenta);
while ($line=fgets($file,1024)) {
list(,,,,,,,,$online,,$x,$y) = explode("\t",trim($line));
if ($online == 1) $color = $blue;
else $color = $red;
imageLine($map, $x-$crosssize, $y, $x+$crosssize, $y, $color);
imageLine($map, $x, $y-$crosssize, $x, $y+$crosssize, $color);
}
while ($line=fgets($itemfile,1024)) {
list($x,$y,,$level) = explode("\t",trim($line));
if (is_numeric($level)) $color = $orange;
else $color = $yellow;
imageLine($map, $x-$crosssize, $y-$crosssize, $x+$crosssize, $y+$crosssize, $color);
imageLine($map, $x+$crosssize, $y-$crosssize, $x-$crosssize, $y+$crosssize, $color);
}
header("Content-type: image/png");
imagePNG($map);
imageDestroy($map);
?>