Rev 193 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
193 | f9daq | 1 | <?php |
2 | ini_set('display_errors', 1); |
||
3 | ini_set('display_startup_errors', 1); |
||
4 | error_reporting(E_ALL); |
||
5 | |||
6 | require 'config.php'; |
||
7 | require 'ip2coordinates.php'; |
||
8 | |||
9 | mysql_connect(DB_HOST, DB_USER, DB_PASS); |
||
10 | mysql_select_db(DB_NAME); |
||
11 | |||
12 | $ip = $_SERVER['REMOTE_ADDR']; |
||
13 | $userinfo = IPtoCoordinates($ip); |
||
14 | |||
15 | $user = mysql_query('SELECT `location` FROM `visitor_map` WHERE `location` = \'' . $userinfo['location'] . '\''); |
||
16 | if(!mysql_fetch_row($user) && $userinfo) |
||
17 | mysql_query('INSERT INTO `visitor_map` (`ip`, `location`, `longitude`, `latitude`) VALUES (\'' . mysql_real_escape_string($ip) . '\', \'' . $userinfo['location'] . '\', ' . $userinfo['longitude'] . ', ' . $userinfo['latitude'] . ')') or die(mysql_error()); |
||
18 | |||
19 | ?> |
||
20 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
||
21 | <html lang="en"> |
||
22 | |||
23 | <head> |
||
24 | <title>Visitor Map Example</title> |
||
25 | <script src="//maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script> |
||
26 | <style type="text/css"> |
||
27 | html, body, #map { height: 100%; margin: 0; } |
||
28 | </style> |
||
29 | <script type="text/javascript"> |
||
30 | //<![CDATA[ |
||
31 | |||
32 | function initialize() { |
||
33 | var map = new google.maps.Map( |
||
34 | document.getElementById('map'), { |
||
35 | center: new google.maps.LatLng(35.69,139.69), |
||
36 | zoom: 3, |
||
37 | minZoom: 2, |
||
38 | mapTypeId: google.maps.MapTypeId.ROADMAP |
||
39 | }); |
||
40 | var marker; |
||
41 | <?php |
||
42 | $query = mysql_query('SELECT `longitude`, `latitude` FROM `visitor_map`'); |
||
43 | while($row = mysql_fetch_array($query)){ |
||
44 | if (strlen($row['latitude'])>0){ |
||
45 | ?> |
||
46 | marker = new google.maps.Marker({ position: new google.maps.LatLng(<?php echo $row['latitude']; ?>, <?php echo $row['longitude']; ?>), map: map }); |
||
47 | <?php |
||
48 | // break; |
||
49 | } |
||
50 | } |
||
51 | ?> |
||
52 | |||
53 | |||
54 | |||
55 | } |
||
56 | google.maps.event.addDomListener(window, 'load', initialize); |
||
57 | //]]> |
||
58 | |||
59 | </script> |
||
60 | |||
61 | </head> |
||
62 | |||
63 | <body> |
||
64 | <h3>Belle II Masterclass visitor map</h3> |
||
65 | <div id="map" style="width: 90%; height: 90%"></div> |
||
318 | f9daq | 66 | |
67 | <?php |
||
68 | if (isset($_GET['debug'])){ |
||
69 | $nc=0; |
||
70 | echo ('<table>'); |
||
71 | $query = mysql_query('SELECT * FROM `visitor_map`'); |
||
72 | while($row = mysql_fetch_array($query, MYSQL_ASSOC)){ |
||
73 | if ($nc==0){ |
||
74 | echo('<tr>'); |
||
75 | foreach ($row as $key=>$val){ |
||
76 | echo("<th>$key"); |
||
77 | |||
78 | } |
||
79 | $nc++; |
||
80 | } |
||
81 | |||
82 | echo('<tr>'); |
||
83 | foreach ($row as $key=>$val){ |
||
84 | echo("<th>$val"); |
||
85 | } |
||
86 | } |
||
87 | echo ('</table>'); |
||
88 | } |
||
89 | ?> |
||
193 | f9daq | 90 | </body> |
91 | |||
92 | </html> |