<?php
#
# HLstatsX - Real-time player and clan rankings and statistics for Half-Life 2
# http://www.hlstatsx.com/
# Copyright (C) 2006 Tobias Oetzel (Tobi@hlstatsx.com)
#
# HlstatsX is an enhanced version of HLstats made by Simon Garner
# HLstats - Real-time player and clan rankings and statistics for Half-Life
# http://sourceforge.net/projects/hlstats/
# Copyright (C) 2001  Simon Garner
#             
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
	
	
	/*
	 * HLstatsX Page Footer This file will be inserted at the end of every page
	 * generated by HLstats. This file can contain PHP code.
	 */
     
  #if (SHOW_CITIES == 1)  
   # new LocateCities();
    
?>

<br>
<center>
<?php echo $g_options["font_small"]; ?>Generated in real-time by <a href="http://www.hlstatsx.com">HLstatsX</a> V<?php echo VERSION; ?>&nbsp;&nbsp;<a href="http://www.hlstatsx.com/masterserver">(Official Serverlist)</a>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;[<a href="<?php echo $g_options["scripturl"]; ?>?mode=admin">Admin</a>]<?php echo $g_options["fontend_small"]; ?><br>
</center>

<?php
  global $mode;
  global $game;
  global $redirect_to_game;
  
  if ((SHOW_GOOGLE_MAP == 1) && ($mode == "contents") && ($redirect_to_game > 0))  {

?> 
            <style type="text/css">
               v\:* { behavior:url(#default#VML); }
            </style>
            <script src="http://maps.google.com/maps?file=api&v=1&key=<?php echo GOOGLE_MAP_KEY; ?>" type="text/javascript"></script>
            <script type="text/javascript">
                 var icon = new GIcon();
                 icon.image = "<?php echo $g_options["imgdir"]; ?>/mm_20_blue.png";
                 icon.shadow = "<?php echo $g_options["imgdir"]; ?>/mm_20_shadow.png";
                 icon.iconSize = new GSize(12, 20);
                 icon.shadowSize = new GSize(22, 20);
                 icon.iconAnchor = new GPoint(6, 20);
                 icon.infoWindowAnchor = new GPoint(5, 1);

                 var map = new GMap(document.getElementById("map"));
                 GEvent.addListener(map, "moveend", function() {var center = map.getCenterLatLng();var latLngStr = '(' + center.y + ', ' + center.x + ')'; document.getElementById("message").innerHTML = latLngStr;});
                 map.addControl(new GSmallZoomControl());
                 map.addControl(new GMapTypeControl());
                 <?php
                    switch (strtoupper(GOOGLE_MAP_REGION)) {
                      case "EUROPE"         : echo 'map.centerAndZoom(new GPoint(8.5, 48.8),     13);';
                                              break;    
                      case "NORTH AMERICA"  : echo 'map.centerAndZoom(new GPoint(-97.0, 45.0),   14);';
                                              break;
                      case "SOUTH AMERICA"  : echo 'map.centerAndZoom(new GPoint(-61.2, -14.8),  14);';
                                              break;    
                      case "NORTH AFRICA"   : echo 'map.centerAndZoom(new GPoint(8.4, 25.4),     13);';
                                              break;
                      case "SOUTH AFRICA"   : echo 'map.centerAndZoom(new GPoint(23.7, -29.0),   12);';
                                              break;    
                      case "NORTH EUROPE"   : echo 'map.centerAndZoom(new GPoint(15.4, 62.6),    13);';
                                              break;
                      case "EAST EUROPE"    : echo 'map.centerAndZoom(new GPoint(31.8, 51.9),    13);';
                                              break;
                      case "GERMANY"        : echo 'map.centerAndZoom(new GPoint(10.1, 51.1),    12);';
                                              break;    
                      case "FRANCE"         : echo 'map.centerAndZoom(new GPoint(2.4, 47.2),     12);';
                                              break;    
                      case "SPAIN"          : echo 'map.centerAndZoom(new GPoint(-4.0, 40.3),    12);';
                                              break;    
                      case "UNITED KINGDOM" : echo 'map.centerAndZoom(new GPoint(-4.3, 54.0),    12);';
                                              break;    
                      case "DENMARK"        : echo 'map.centerAndZoom(new GPoint(9.2, 56.1),     11);';
                                              break;    
                      case "SWEDEN"         : echo 'map.centerAndZoom(new GPoint(16.3, 63.2),    13);';
                                              break;   
                      case "NORWAY"         : echo 'map.centerAndZoom(new GPoint(13.1, 65.6),    13);';
                                              break;    
                      case "FINLAND"        : echo 'map.centerAndZoom(new GPoint(26.6, 65.1),    13);';
                                              break;    
                      case "NETHERLANDS"    : echo 'map.centerAndZoom(new GPoint(5.4, 52.3),     10);';
                                              break;
                      case "BELGIUM"        : echo 'map.centerAndZoom(new GPoint(4.5, 50.7),     10);';
                                              break;    
                      case "SUISSE"         : echo 'map.centerAndZoom(new GPoint(8.2, 46.8),     10);';
                                              break;    
                      case "AUSTRIA"        : echo 'map.centerAndZoom(new GPoint(14.1, 47.7),    10);';
                                              break;    
                      case "POLAND"         : echo 'map.centerAndZoom(new GPoint(19.3, 52.1),    11);';
                                              break;    
                      case "ITALY"          : echo 'map.centerAndZoom(new GPoint(12.7, 42.6),    11);';
                                              break;    
                      case "TURKEY"         : echo 'map.centerAndZoom(new GPoint(34.9, 39.0),    11);';
                                              break;    
                      case "BRAZIL"         : echo 'map.centerAndZoom(new GPoint(-53.1, -12.0),  13);';
                                              break;    
                      case "ARGENTINA"      : echo 'map.centerAndZoom(new GPoint(-65.7, -34.3),  14);';
                                              break;    
                      case "RUSSIA"         : echo 'map.centerAndZoom(new GPoint(98.8, 65.7),    14);';
                                              break;    
                      case "ASIA"           : echo 'map.centerAndZoom(new GPoint(85.6, 39.4),    14);';
                                              break;    
                      case "CHINA"          : echo 'map.centerAndZoom(new GPoint(104.0, 36.2),   13);';
                                              break;    
                      case "JAPAN"          : echo 'map.centerAndZoom(new GPoint(136.8, 36.2),   12);';
                                              break;    
                      case "SOUTH KOREA"    : echo 'map.centerAndZoom(new GPoint(127.8, 36.6),   11);';
                                              break;    
                      case "AUSTRALIA"      : echo 'map.centerAndZoom(new GPoint(134.8, -26.1),  13);';
                                              break;    
                      case "WORLD"          : echo 'map.centerAndZoom(new GPoint(8.5, 25.0),     15);';
                                              break;    
                      default               : echo 'map.centerAndZoom(new GPoint(8.5, 48.8),     13);';
                                              break;    
                    }
                    switch (strtoupper(GOOGLE_MAP_TYPE)) {
                      case "SATELLITE"      : echo 'map.setMapType(G_SATELLITE_TYPE);';
                                              break;    
                      case "MAP"            : echo 'map.setMapType(G_MAP_TYPE);';
                                              break;    
                      case "HYBRID"         : echo 'map.setMapType(G_HYBRID_TYPE);';
                                              break;    
                      default               : echo 'map.setMapType(G_SATELLITE_TYPE);';
                                              break;    
                    }    
                 ?>       
                 
                
                 function createMarker(point, name, city, country, kills, deaths, time, player_id) {
                   var marker    = new GMarker(point, icon);
                   var html_text = '<table border=0 style="text-align:left;"><tr><td colspan="2" align="left" style="border-bottom:1px solid black;"><a href="hlstats.php?mode=playerinfo&player='+player_id+'" style="color:blue;font-weight:bold;text-decoration:none;"><small>'+name+'</small></a></td></tr>'+
                                   '<tr><td><small>Location</small></td><td><small>'+city+', '+country+'<small></td></tr>'+
                                   '<tr><td><small>Frags</small></td><td><small>'+kills+':'+deaths+'<small></td></tr>'+
                                   '<tr><td><small>Time</small></td><td><small>'+time+'<small></td></tr>'+
                                   '</table>';  
                   map.addOverlay(marker);
                   GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html_text);});
                 }
                 
                 
                 <?php
                   global $db;
                   $data = array();
                   $db->query("SELECT hlstats_Livestats.* FROM hlstats_Livestats, hlstats_Servers WHERE hlstats_Livestats.cli_lat<>0 AND hlstats_Livestats.cli_lng<>0 AND hlstats_Livestats.cli_address<>'' AND hlstats_Servers.serverId=hlstats_Livestats.server_id AND hlstats_Servers.game='$game'");
                   while ($rowdata = $db->fetch_array()) {
                     $search_pattern  = array("/[^A-Za-z0-9\[\]*.,=()!\"$%&^`´':;ß²³#+~_\-|<>\/@{}äöüÄÖÜ ]/");
                     $replace_pattern = array("");
                     $rowdata['name'] = preg_replace($search_pattern, $replace_pattern, $rowdata['name']);
                    
                     $stamp    = time()-$rowdata['connected'];
                     $hours    = sprintf("%02d", floor($stamp / 3600));
                     $min      = sprintf("%02d", floor(($stamp % 3600) / 60));
                     $sec      = sprintf("%02d", floor($stamp % 60)); 
                     $time_str = $hours.":".$min.":".$sec;  
                     echo "createMarker(new GPoint(".$rowdata['cli_lng'].", ".
                                                     $rowdata['cli_lat']."), \"".
                                                     htmlentities(urldecode($rowdata['name']), ENT_QUOTES)."\", \"".
                                                     htmlentities(urldecode($rowdata['cli_city']), ENT_QUOTES)."\", \"".
                                                     htmlentities(ucfirst(strtolower(urldecode($rowdata['cli_country']))), ENT_QUOTES)."\", ".
                                                     $rowdata['kills'].",".$rowdata['deaths'].", \"".
                                                     $time_str."\",".$rowdata['player_id'].");\n";
                    }                                   
                 ?>
            </script>
<?php } ?>            


</body>
</html>
