-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking_maps6.php
71 lines (48 loc) · 1.82 KB
/
working_maps6.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
ini_set('display_errors', 1);
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
$dbh = pg_connect("host=localhost port=5432 dbname=ip_database user=postgres password=******");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
// execute query
if (isset($_GET['Submit1'])) {
$start=$_GET['startTime'];
$end=$_GET['endTime'];
$din=$_GET['date'];
$con=$_GET['continent'];
$ty=$_GET['type'];
$sql = "SELECT ip_prefixes, city_location, lat, lng, isp, type FROM markers where date_='$din' AND time_ BETWEEN '$start' AND '$end' AND continent='$con' AND type='$ty'";
$result = pg_query($dbh, $sql);
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = pg_fetch_array($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'ip_prefixes="' . parseToXML($row['ip_prefixes']) . '" ';
echo 'city_location="' . parseToXML($row['city_location']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'isp="' . parseToXML($row['isp']) . '" ';
echo 'type="' . parseToXML($row['type']) . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
//header("Location:http://localhost/ip_maps.html?Submit1=HIT&IP=$ip");
}
//header("Location:http://localhost/ip_maps.html");//Submit1=HIT&IP=$ip
?>