-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminHeatmap.php
156 lines (122 loc) · 4.39 KB
/
adminHeatmap.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
<?php
session_start();
if(!isset($_SESSION['username']))
{
header('location:Welcome.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="adminstylemap.css">
<link rel="stylesheet" href="admin_style.css">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css">
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<div class="caption">
<h1>Optimize Data</h1>
</div>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a href="WelcomeAdmin.php">Home</a>
<a href="ViewStatus.php">View Status</a>
<a href="RequestTimings.php">Response Times</a>
<a href="erwtima3.php">HTTP Headers</a>
<a href="adminHeatmap.php">Optimize Data</a>
<a href="logout.php">Logout</a>
</div>
<div id="main">
<div class="container">
<div class="nav-wrapper">
<div class="left-side">
<div class="nav-link-wrapper">
<a><span onclick="openNav()">Menu</span></a>
</div>
</div>
</div>
<div id="mapid"></div>
<script>
//basic tou xarth
let mymap = L.map("mapid");
let osmUrl = "https://tile.openstreetmap.org/{z}/{x}/{y}.png";
let osmAttrib ='Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors';
let osm = new L.TileLayer(osmUrl, {attribution: osmAttrib});
mymap.addLayer(osm);
mymap.setView([38.246242, 21.7350847],4);
//pairnw dedomena apo th vash
let markerpositions = [];
let lines = [];
$.ajax({
'async': true,
'global': false,
'type': "POST",
'url': "adminHeatData.php",
'dataType': "json",
'success': function(data) {
markerpositions = data[0];
lines = data[1];
markers2 = data[2];
plithos_ip = data[3];
max = markers2[0].plithos;
/*console.log(max);*/
//gia to prasino marker
var greenIcon = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-green.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
//gia na vrw ta origins
$.each(lines, function(){
let orgname = null;
let orglat = null;
let orglng = null;
$.each(this, function(index, value){
if(index == "cname")
{orgname = value;}
else if(index == "clat")
{orglat = value;}
else {orglng = value;}
});
let marker = new L.marker([orglat, orglng], {icon :greenIcon}).addTo(mymap).bindPopup("<b> Location of user: </b>" + orgname);
//gia na vrw tis aitiseis - mple
$.each(markers2, function(){
let templat = null;
let templng = null;
let tempname = null;
let temp_paxos = null;
$.each(this, function(index, value){
if(index == "lat1")
{templat = value;}
else if(index == "long1")
{templng = value;}
else if (index == "name1")
{tempname = value;}
else {temp_paxos = value;}
});
if (tempname == orgname){
let marker1 = new L.marker([templat, templng]).addTo(mymap).bindPopup("<b> Location of HTTP Requests of user: </b>" +tempname);
let latlngs = Array();
latlngs.push(marker.getLatLng());
latlngs.push(marker1.getLatLng());
let polyline = L.polyline(latlngs, {color: 'blue', weight: temp_paxos/max}).addTo(mymap);
}
});
});
}
});
</script>
</div>
</div>
<!-- footer -->
<div class="footer2">
<p> All copyrigths reserved. ©</p>
</div>
</body>
<script src="index_js.js"></script>
</html>