Требование: PHP => 5.3, часть 2
[cswow.git] / module / maps / map.php
blobf20b45875ed3f04c05c39ecb59fc3507f1d39889
1 <?php
2 include_once("include/map_data.php");
4 $text='';
5 $ajaxptr = '';
7 $map = @$_REQUEST['map']=='' ? -1 : intval(@$_REQUEST['map']);
8 $area = intval(@$_REQUEST['area']);
9 $width = intval(@$_REQUEST['width']) ? intval(@$_REQUEST['width']) : 900;
11 if ($area) {$a=getRenderAreaData($area); $map = $a[0];}
13 //*****************************************************************************
14 // Create points list
15 //*****************************************************************************
16 $pointsList = new mapPoints();
17 if ($npc_id = intval(@$_REQUEST['npc']))
19 $ajaxptr.="&npc=$npc_id";
20 $pointsList->addNpc($npc_id, $map);
21 $text = '<center>'.getCreatureName($npc_id).'</center>';
23 if ($obj_id = intval(@$_REQUEST['obj']))
25 $ajaxptr.="&obj=$obj_id";
26 $pointsList->addGo($obj_id, $map);
27 $text = '<center>'.getGameobjectName($obj_id).'</center>';
29 if ($point = @$_REQUEST['point'])
31 $ajaxptr.='&point='.$point;
32 $p = explode(':', $point);
33 $pointsList->addPoint(@$p[0], @$p[1], @$p[2], @$p[3]);
34 $text = '<br>';//'<center>Point: map='.@$p[0].' x='.@$p[1].' y='.@$p[2].' z='.@$p[3].'</center>';
36 if ($waypoint = @$_REQUEST['waypoint'])
38 $ajaxptr.='&waypoint='.$waypoint;
39 $pointsList->addWaypoint($waypoint, $dDB->selectCell('SELECT `map` FROM `creature` WHERE `guid` = ?d', $waypoint));
42 if ($width) $ajaxptr.="&width=$width";
44 $ajaxmode = !(!$ajaxmode || (@$_REQUEST['map']=='' && $area==0 && !isset($_REQUEST['gps'])));
46 if (!$ajaxmode)
48 echo "<script type=\"text/javascript\" src=\"js/mapper.js\"></script>";
49 echo $text;
51 if($pointsList->getCount())
53 // Create maps and area list
54 $list = $pointsList->getMapsList();
56 if (count(@$list['area']) + count(@$list['map']) > 1)
58 echo "<select onchange=\"areaSelect(this)\" style=\"WIDTH: ".($width+8)."px\">";
59 if (isset($list['area']))
61 echo '<optgroup label="'.$lang['map_areas'].'">';
62 foreach($list['area'] as $a)
63 echo "<option value='?area=".$a['id'].$ajaxptr."'>".$a['text']."</option>";
64 echo '</optgroup>';
66 if (isset($list['gps']))
68 foreach($list['gps'] as $g)
69 echo "<option value='?map=".$map.$ajaxptr."&gps'>".$lang['map_gps'].' - '.$g['text']."</option>";
71 if (isset($list['map']))
73 echo '<optgroup label="'.$lang['map_maps'].'">';
74 foreach($list['map'] as $m)
75 echo "<option value='?map=".$m['id'].$ajaxptr."'>".$m['text']."</option>";
76 echo '</optgroup>';
78 echo "</select>";
80 $area = $area==0 ? @$list['area'][0]['id'] : $area;
81 $map = $map==-1 ? @$list['map'][0]['id'] : $map;
83 echo "<script type=\"text/javascript\" src=\"js/mapper.js\"></script>";
84 echo "<div id=mapper>";
87 //==============================================================================
88 if (isset($_REQUEST['gps']))
90 renderGPSMap("GPS", $width, $pointsList->points);
91 // echo "<script type=\"text/javascript\">cacheMap('?map=".$map.$ajaxptr."gps')</script>";
93 else if ($area>0)
95 renderArea($area, $width, $pointsList->points);
96 // echo "<script type=\"text/javascript\">cacheMap('?area=".$area.$ajaxptr."')</script>";
98 else if ($map>=0)
100 renderMap($map, $width, $pointsList->points);
101 // echo "<script type=\"text/javascript\">cacheMap('?map=".$map.$ajaxptr."')</script>";
103 else
104 echo $lang['map_no_found'];
105 //==============================================================================
107 if (!$ajaxmode)
108 echo "</div>";