Дополнение к инструкции.)
[cswowd.git] / map / instance.php
blob2b3580491019629fc4e1de9ec7a62a653068f4f2
1 <?php
2 include_once("../conf.php");
3 include_once("zone_tables.php");
4 mysql_connect($config['hostname'],$config['username'],$config['password']) or die("Unable to connect to the database.".mysql_error());
5 mysql_select_db($config['dbName']) or die(mysql_error());
7 echo "<html>";
8 echo "<head>";
9 echo "<meta http-equiv=Content-Type content=text/html; charset=utf-8>";
10 echo "<title></title>";
11 static $baseImagePath = "img/map_image/";
13 $id = intval(@$_REQUEST['id']);
14 if ($map=="")
15 $map = intval(@$_REQUEST['map']);
16 $x = intval(@$_REQUEST['x']);
17 $y = intval(@$_REQUEST['y']);
19 $map_info = get_Map($map);
20 if ($map_info==0)
22 $name=get_map_name($map);
23 echo "<center><table valign=\"bottom\"><tr><td><img src=\"../images/wowd.jpg\"></td></tr><tr><td><center>Отсутствует карта: $name</center></td></tr></table></center>";
25 else
27 $map = $map_info[0];
28 $name = $map_info[1];
29 $areaX1 = $map_info[2];
30 $areaX2 = $map_info[3];
31 $areaY1 = $map_info[4];
32 $areaY2 = $map_info[5];
33 $imageX = $map_info[6];
34 $imageY = $map_info[7];
35 $background = $baseImagePath.$map_info[8];
37 <style type="text/css">
38 <!--
39 body {
40 margin-left: 0px;
41 margin-top: 0px;
42 margin-right: 0px;
43 margin-bottom: 0px;
44 color: #EABA28;
45 background-color: #000000;
47 -->
48 </style>
49 </head>
50 <body>
52 <?php
53 echo "<center>";
55 $scale=floatval(@$_REQUEST['scale']);
56 if ($scale==0) $scale=1;
57 if ($scale<0.25) $scale=0.25;
58 //if ($imageY>768) $scale = 2;
59 $imageX/=$scale;
60 $imageY/=$scale;
61 $sizeX = $imageY;
62 $sizeY = $imageX+4;
63 $tableBorder = 1;
64 $tableWidth = $imageY+$tableBorder*2+8;
65 echo "<table border=$tableBorder width=$tableWidth>";
66 echo "<tbody><tr><td align = center>$name</td></tr>";
67 echo "<tr><td width=$sizeX height=$sizeY align=left valign=top>";
68 echo "<span style=\"position: relative; border: 0px; left: 0; top: 0;\">&nbsp;";
69 echo "<img src=$background width=$imageY height=$imageX style=\"position: absolute; border: 0px; left: 0; top: 0;\">";
70 if ($x!=0 && $y!=0)
72 $x=round($imageX*($x - $areaX1)/($areaX2-$areaX1)-8,0);
73 $y=round($imageY*($y - $areaY1)/($areaY2-$areaY1)-8,0);
74 echo "<img src=\"img/gps_icon.png\" style=\"position: absolute; border: 0px; left: $y; top: $x;\">\n";
77 $res2 = mysql_query("SELECT * FROM `gameobject` WHERE `map`='$map' ORDER BY `id`") or die(mysql_error());
78 $lastID = -1;
79 while ($row2=mysql_fetch_array($res2))
81 if ($row2['id']!=$lastID)
83 $res = mysql_query("SELECT * FROM `gameobject_template` WHERE entry = '$row2[id]' LIMIT 1") or die(mysql_error());
84 $row = mysql_fetch_array($res);
85 $row['name']=str_replace("'","`",$row['name']);
86 $row['name']=str_replace("\"","`",$row['name']);
87 mysql_free_result($res);
88 $lastID = $row2['id'];
90 $mapID= $row2['map'];
91 $posx = $row2['position_x'];
92 $posy = $row2['position_y'];
93 $type = $row['type'];
94 $time = get_time_text($row2['spawntimesecs']);
96 if ($row2['id']==$id){$img = "img/gps_icon.png";$centerImage = 8;}
97 else {$img = "img/iron.gif"; $centerImage = 4;}
99 if ($areaX1 > $posx && $areaX2 < $posx &&
100 $areaY1 > $posy && $areaY2 < $posy && $map == $mapID)
102 $x=$imageX*($posx - $areaX1)/($areaX2-$areaX1)-$centerImage;
103 $y=$imageY*($posy - $areaY1)/($areaY2-$areaY1)-$centerImage;
104 $name = validateTextForMap($row['name']);
105 echo "<img src=\"$img\" style=\"position: absolute; border: 0px; left: $y; top: $x;\"onmouseover=\"this.T_TITLE='<div align=center>$name</div>';return escape('Респавн: $time<br>GUID $row2[guid]<br>$posx $posy $row2[position_z] $row2[map]')\"></a>\n";
108 $res2 = mysql_query("SELECT * FROM `creature` WHERE `map`='$map' ORDER BY `id`") or die(mysql_error());
109 $lastID = -1;
110 while ($row2=mysql_fetch_array($res2))
112 if ($row2['id']!=$lastID)
114 $res = mysql_query("SELECT * FROM `creature_template` WHERE Entry = '$row2[id]' LIMIT 1") or die(mysql_error());
115 $row = mysql_fetch_array($res);
116 $row['name']=str_replace("'","`",$row['name']);
117 $row['name']=str_replace("\"","`",$row['name']);
118 mysql_free_result($res);
119 $lastID = $row2['id'];
121 $mapID= $row2['map'];
122 $posx = $row2['position_x'];
123 $posy = $row2['position_y'];
124 $type = $row['type'];
125 $time = get_time_text($row2['spawntimesecs']);
127 if ($row2['id']==$id){$img = "img/gps_icon.png";$centerImage = 8;}
128 else {$img = "img/green.gif"; $centerImage = 2;}
130 // if ($areaX1 > $posx && $areaX2 < $posx &&
131 // $areaY1 > $posy && $areaY2 < $posy && $map == $mapID)
133 $x=$imageX*($posx - $areaX1)/($areaX2-$areaX1)-$centerImage;
134 $y=$imageY*($posy - $areaY1)/($areaY2-$areaY1)-$centerImage;
135 $name = validateTextForMap($row['name']);
136 echo "<img src=\"$img\" style=\"position: absolute; border: 0px; left: $y; top: $x;\"onmouseover=\"this.T_TITLE='<div align=center>$name</div>';return escape('Уровень: $row[minlevel]-$row[maxlevel]<br>Ранг $row[rank]<br>Тип: $NPCType[$type]<br>Жизнь: $row2[curhealth]<br>Урон: $row[mindmg] - $row[maxdmg]<br>Респавн: $time<br>GUID $row2[guid]<br>$posx $posy $row2[position_z] $row2[map]')\"></a>\n";
139 echo "</span>";
140 echo "</td></tr></tbody>";
141 echo "</table>";
142 echo "</center>";
145 <script language="JavaScript" type="text/javascript" src="wz_tooltip.js"></script>
146 <script language="JavaScript" type="text/javascript"></script>
147 </body>
148 </html>
149 <?php