-
Notifications
You must be signed in to change notification settings - Fork 2
/
devices_locations_map.php
174 lines (118 loc) · 3.78 KB
/
devices_locations_map.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/*
* Copyright (c) 2020 Barchampas Gerasimos <makindosx@gmail.com>.
* inveniet is a program for locating computers tablets and mobile phones.
*
* inveniet is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* inveniet 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
session_start();
if (!isset($_SESSION['login']))
{
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<link rel="icon" type="image/png" sizes="96x96" href="assets/img/favicon.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> Device Location </title>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require('__DEV__/function.php');
require('__ROOT__/class_cn.php');
$obj = new security;
$host=$obj->connect[0];
$user=$obj->connect[1];
$pass=$obj->connect[2];
$db=$obj->connect[3];
$conn = new mysqli($host,$user,$pass,$db);
if($conn->connect_error)
{
die ("Cannot connect to server " .$conn->connect_error);
}
else
{
$admin = $_SESSION['login'];
if (isset($_POST['map_location']))
{
$map_location = input($_POST['map_location']);
$lat = explode(",", $map_location, 2);
$lat = $lat[0];
$text_part1 = strstr($map_location, ',');
$text_part1 = substr($text_part1, 1);
$lng = explode("-", $text_part1, 2);
$lng = $lng[0];
$text_part2 = strstr($text_part1, '-');
$text_part2 = substr($text_part2, 1);
$device_id = explode("-", $text_part2, 2);
$device_id = $device_id[0];
$address = strstr($text_part2, '-');
$address = substr($address, 1);
#print map_location
$all_info_marker = "'User fingerprint: " . $device_id . "<br>" . "Address: " . $address . "'";
echo'<div id="map"></div>';
echo"
<script>
// This example displays a marker at the center of Australia.
// When the user clicks the marker, an info window opens.
function initMap() {
var uluru = {lat: $lat, lng: $lng};
var map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: 'hybrid',
zoom: 16,
center: uluru
});
var contentString = $all_info_marker;
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: uluru,
map: map,
title: 'Location Device'
});
marker.addListener('click', function() {
infowindow.open(map, marker);
});
}
</script>";
} // end of isset submit location
} // end of else connect
$conn->close();
?>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=initMap"></script>"
</body>
</html>