Subversion Repositories f9daq

Rev

Rev 193 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 193 Rev 318
1
<?php
1
<?php
2
ini_set('display_errors', 1);
2
ini_set('display_errors', 1);
3
ini_set('display_startup_errors', 1);
3
ini_set('display_startup_errors', 1);
4
error_reporting(E_ALL);
4
error_reporting(E_ALL);
5
 
5
 
6
require 'config.php';
6
require 'config.php';
7
require 'ip2coordinates.php';
7
require 'ip2coordinates.php';
8
 
8
 
9
mysql_connect(DB_HOST, DB_USER, DB_PASS);
9
mysql_connect(DB_HOST, DB_USER, DB_PASS);
10
mysql_select_db(DB_NAME);
10
mysql_select_db(DB_NAME);
11
 
11
 
12
$ip = $_SERVER['REMOTE_ADDR'];
12
$ip = $_SERVER['REMOTE_ADDR'];
13
$userinfo = IPtoCoordinates($ip);
13
$userinfo = IPtoCoordinates($ip);
14
 
14
 
15
$user = mysql_query('SELECT `location` FROM `visitor_map` WHERE `location` = \'' . $userinfo['location'] . '\'');
15
$user = mysql_query('SELECT `location` FROM `visitor_map` WHERE `location` = \'' . $userinfo['location'] . '\'');
16
if(!mysql_fetch_row($user) && $userinfo)
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());
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
 
18
 
19
?>
19
?>
20
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
20
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
21
<html lang="en">
21
<html lang="en">
22
 
22
 
23
 <head>
23
 <head>
24
  <title>Visitor Map Example</title>
24
  <title>Visitor Map Example</title>
25
   <script src="//maps.googleapis.com/maps/api/js?sensor=false"   type="text/javascript"></script>
25
   <script src="//maps.googleapis.com/maps/api/js?sensor=false"   type="text/javascript"></script>
26
    <style type="text/css">
26
    <style type="text/css">
27
      html, body, #map { height: 100%; margin: 0; }
27
      html, body, #map { height: 100%; margin: 0; }
28
    </style>
28
    </style>
29
    <script type="text/javascript">
29
    <script type="text/javascript">
30
        //<![CDATA[
30
        //<![CDATA[
31
 
31
 
32
    function initialize() {
32
    function initialize() {
33
      var map = new google.maps.Map(
33
      var map = new google.maps.Map(
34
        document.getElementById('map'), {
34
        document.getElementById('map'), {
35
          center: new google.maps.LatLng(35.69,139.69),
35
          center: new google.maps.LatLng(35.69,139.69),
36
          zoom: 3,
36
          zoom: 3,
37
          minZoom: 2,
37
          minZoom: 2,
38
          mapTypeId: google.maps.MapTypeId.ROADMAP
38
          mapTypeId: google.maps.MapTypeId.ROADMAP
39
      });
39
      });
40
     var marker;
40
     var marker;
41
<?php
41
<?php
42
     $query = mysql_query('SELECT `longitude`, `latitude` FROM `visitor_map`');
42
     $query = mysql_query('SELECT `longitude`, `latitude` FROM `visitor_map`');
43
     while($row = mysql_fetch_array($query)){
43
     while($row = mysql_fetch_array($query)){
44
         if (strlen($row['latitude'])>0){
44
         if (strlen($row['latitude'])>0){
45
?>
45
?>
46
     marker = new google.maps.Marker({ position: new google.maps.LatLng(<?php echo $row['latitude']; ?>, <?php echo $row['longitude']; ?>), map: map });
46
     marker = new google.maps.Marker({ position: new google.maps.LatLng(<?php echo $row['latitude']; ?>, <?php echo $row['longitude']; ?>), map: map });
47
<?php
47
<?php
48
//                                break;
48
//                                break;
49
         }
49
         }
50
     }
50
     }
51
?>
51
?>
52
 
52
 
53
 
53
 
54
 
54
 
55
    }
55
    }
56
    google.maps.event.addDomListener(window, 'load', initialize);
56
    google.maps.event.addDomListener(window, 'load', initialize);
57
        //]]>
57
        //]]>
58
 
58
 
59
    </script>
59
    </script>
60
 
60
 
61
 </head>
61
 </head>
62
 
62
 
63
 <body>
63
 <body>
64
<h3>Belle II Masterclass visitor map</h3>
64
<h3>Belle II Masterclass visitor map</h3>
65
  <div id="map" style="width: 90%; height: 90%"></div>
65
  <div id="map" style="width: 90%; height: 90%"></div>
-
 
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
?>
66
 </body>
90
 </body>
67
 
91
 
68
</html>
92
</html>
69
 
93