Browse code

Inital commit with Data from ESF-2

Richard Cornwell (K9RCP) authored on 01/27/2022 10:55:50
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,132 @@
1
+<?php
2
+if(file_exists("../data/spotrep-".strtoupper(base64_decode($_GET['d'])).".txt")) {
3
+	$dfile = "../data/spotrep-".strtoupper(base64_decode($_GET['d'])).".txt";
4
+	$dcall = base64_decode($_GET['d']);
5
+} else {
6
+	$dfile = "../data.txt";
7
+	$dcall = "ALL";
8
+}
9
+if (isset($_GET['ms'])) {
10
+	echo md5_file($dfile);
11
+	die();
12
+}
13
+?>
14
+<!DOCTYPE html>
15
+<html> <head>
16
+  <meta charset="utf-8">
17
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
18
+  <title>SpotRep2 Map - K9RCP</title>
19
+  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
20
+  <style>
21
+
22
+* { margin: 0; padding: 0; }
23
+  #mapid { height: 100%; width: 100%; position: absolute !important; }
24
+  body {
25
+   height: 100%;
26
+   overflow: hidden;
27
+   width: 100%;
28
+}
29
+  </style>
30
+  <!-- Google Font: Source Sans Pro -->
31
+  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
32
+ <link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
33
+   integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
34
+   crossorigin=""/>
35
+    <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
36
+   integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
37
+   crossorigin=""></script>
38
+</head>
39
+<body>
40
+    	 <div style="background-color: black;" id="mapid" width="600px" height="600px"></div>
41
+         <script>
42
+<?php
43
+if(isset($_COOKIE['mapzoom']) && isset($_COOKIE['mapcenter'])) { ?>
44
+var map = L.map('mapid').setView([<?php echo str_replace(array("LatLng(", ")"), "", $_COOKIE['mapcenter']); ?>], <?php echo $_COOKIE['mapzoom']; ?>);
45
+<?php } else { ?>
46
+var map = L.map('mapid').setView([45.290899, -122.976504], 8);
47
+
48
+<?php } ?>
49
+
50
+L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
51
+    attribution: 'SpotRep Mapping by K9RCP', // Update this with your mapping attribution
52
+    maxZoom: 18,
53
+    id: 'mapbox/streets-v11',
54
+    tileSize: 512,
55
+    zoomOffset: -1,
56
+    accessToken: '' // You will need to get a accessToken from your mapping provider.
57
+}).addTo(map);
58
+
59
+map.addEventListener('mousemove', function(ev) {
60
+	document.cookie = "mapcenter="+map.getCenter();
61
+	document.cookie = "mapzoom="+map.getZoom();
62
+});
63
+
64
+
65
+	var LeafIcon = L.Icon.extend({
66
+		options: {
67
+			iconSize:     [18, 18],
68
+		}
69
+	});
70
+
71
+
72
+
73
+<?php
74
+
75
+$rawdata = explode("\n", file_get_contents($dfile));
76
+
77
+foreach ($rawdata as &$dataraw2) {
78
+	if(strlen($dataraw2) > 3) {
79
+		$data = explode("|", $dataraw2);
80
+        	echo "L.marker([".str_replace("\n", "", explode("=", $data[5])[1]).", ".str_replace("\n", "", explode("=", $data[6])[1])."]).bindPopup('<b>Callsign: </b>".str_replace("\n", "", explode("=", $data[4])[1])." <br /><br />";
81
+		echo "<b>Subject: </b>".str_replace("\n", "", explode("=", $data[2])[1])." <br />";
82
+
83
+		for ($i = 5; $i < (count($data) - 0); $i++) {
84
+			echo trim(str_replace(array("\n"."\r"), "", "<b>".htmlspecialchars(str_replace(array(":T", ":M"), "", explode("=", $data[$i])[0])).": </b>".htmlspecialchars(str_replace(array("'", ")", ",","(","\n"), "", explode("=", $data[$i])[1]))))."<br />";
85
+		}
86
+		echo "').addTo(map);\n";
87
+	}
88
+}
89
+?>
90
+
91
+var updateXml;
92
+
93
+function createRequestObject() {
94
+    var ro;
95
+    var browser = navigator.appName;
96
+    if (browser == "Microsoft Internet Explorer") {
97
+        ro = new ActiveXObject("Microsoft.XMLHTTP");
98
+    } else {
99
+        ro = new XMLHttpRequest();
100
+    }
101
+    return ro;
102
+}
103
+var xmlHttp = createRequestObject();
104
+var lastapidata = null;
105
+var lastimagedata = null;
106
+function runapipull() {
107
+    xmlHttp.open('get', '?d=<?php echo str_replace("=", "", base64_encode($dcall)); ?>&ms=' + new Date().getTime());
108
+    xmlHttp.onreadystatechange = readapidata;
109
+    xmlHttp.send(null);
110
+}
111
+
112
+function readapidata() {
113
+    if (xmlHttp.readyState == 4) {
114
+		data = xmlHttp.responseText;
115
+
116
+		if (data != "<?php echo md5_file($dfile); ?>") {
117
+			location.reload();
118
+	        }
119
+		clearInterval(updateXml);
120
+		updateXml = setInterval( function(){ runapipull(); }, 5000 );
121
+        //setTimeout("runapipull()", 15000);
122
+    }
123
+}
124
+runapipull();
125
+        </script>
126
+
127
+      </div>
128
+
129
+
130
+</body>
131
+</html>
132
+