source: irpg/trunk/htdocs/makemap.php@ 5497

Last change on this file since 5497 was 4283, checked in by Daimonos Tereutes, 14 years ago

suppression des shortopentags

File size: 2.0 KB
Line 
1<?php
2 include("config.php");
3 session_start(); // sessions to generate only one map / person / 20s
4 if (isset($_SESSION['time']) && time()-$_SESSION['time'] < 20) {
5 header("Location: maperror.png");
6 exit(0);
7 }
8 $_SESSION['time']=time();
9 $map = imageCreate(500,500);
10
11 $user = substr($_GET['player'],0,30);
12
13 $stringx=$stringy=-1;
14
15 $file = file($irpg_db);
16 unset($file[0]);
17
18 foreach ($file as $line) {
19 list($username,,,,,,,,,,$x,$y) = explode("\t",trim($line));
20 if ($username == $user) {
21 $stringx = $x;
22 $stringy = $y;
23 break;
24 }
25 }
26 if ($stringx == $stringy && $stringx == -1) {
27 imageString($map,5,200,245,"NO SUCH USER",imagecolorallocate($map,255,0,0));
28 }
29 else {
30 $width = imageFontWidth(5);
31 $height = imageFontHeight(5);
32 if ($x+((strlen($user)+1)*$width) > 500) {
33 $stringx = $x - ((strlen($user)+1)*$width)-12;
34 }
35 if ($y+$height > 500) {
36 $stringy = $y - ($height/2)-2;
37 }
38 $magenta = imageColorAllocate($map,255,0,255);
39 imageColorTransparent($map,$magenta);
40 $brown = imagecolorallocate($map, 102, 51, 0);
41 $parchment = imagecolorallocate($map, 255, 255, 204);
42
43 // Avoid drawing a brown dot on a brown area
44 $rgb = imageColorAt($map, $x, $y);
45 if ($rgb > 0) { // $rgb is 0 on our parchment-colored areas
46 $temp = $brown;
47 $brown = $parchment;
48 $parchment = $temp;
49 }
50 // YOU ARE HERE
51 imageFilledEllipse($map, $x, $y, 6, 6, $brown);
52 // background for text
53 imageFilledRectangle($map,$stringx+6,$stringy-($height/2),$stringx+6+$width*(strlen($user)+1),$stringy+($height/2),$brown);
54 // text itself
55 imageString($map,5,$stringx+7+($width/2),$stringy-($height/2)-1,$user,$parchment);
56 }
57 header("Content-type: image/png");
58 imagePNG($map);
59 imageDestroy($map);
60?>
Note: See TracBrowser for help on using the repository browser.