forked from tsawyer/allmon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
voter.php
80 lines (71 loc) · 2.47 KB
/
voter.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
<?php
include "header.php";
$node = @trim(strip_tags($_GET['node']));
$nodeURL = "http://stats.allstarlink.org/nodeinfo.cgi?node=$node";
// If no node number use first non-voter in INI
if (empty($node)) {
die ("Please provide voter node number. (ie voter.php?node=1234)");
}
// Get Allstar database file
$db = "astdb.txt";
$astdb = array();
if (file_exists($db)) {
$fh = fopen($db, "r");
if (flock($fh, LOCK_SH)){
while(($line = fgets($fh)) !== FALSE) {
$arr = split("\|", trim($line));
$astdb[$arr[0]] = $arr;
}
}
flock($fh, LOCK_UN);
fclose($fh);
}
if (array_key_exists($node, $astdb)) {
$nodeRow = $astdb[$node];
$info = $nodeRow[1] . ' ' . $nodeRow[2] . ' ' . $nodeRow[3];
}
?>
<script>
// prevent IE caching
$.ajaxSetup ({
cache: false,
timeout: 3000
});
// when DOM is ready
$(document).ready(function() {
var ajax_request;
// Ajax display
function updateVoter( ) {
if(typeof ajax_request !== 'undefined') {
// Abort slow requests
ajax_request.abort();
}
ajax_request = $.ajax( { url:'voterserver.php', data: { 'node' : <?php echo $node; ?>}, type:'get', success: function(result) {
$('#link_list').html(result);
}, complete: updateVoter, timeout: 30000
});
}
// Go.
updateVoter();
});
</script>
<h2>
<?php
if (empty($info)) {
#print "Voter <a href='$nodeURL' target=_blank>$node</a>";
} else {
#print "Voter <a href='$nodeURL' target=_blank>$node</a> $info";
}
?>
</h2>
<div id="link_list">Loading voter.</div>
<div style='width:500px; text-align:left;'>
The numbers indicate the relative signal strength. The value ranges from 0 to 255, a range of approximately 30db.
A value of zero means that no signal is being received. The color of the bars indicate the type of RTCM client.
</div>
<div style='width: 240px; text-align:left; position: relative; left: 160px;'>
<div style='background-color: #0099FF; color: white; text-align: center;'>A blue bar indicates a voting station.</div>
<div style='background-color: greenyellow; color: black; text-align: center;'>Green indicates the station is voted.</div>
<div style='background-color: cyan; color: black; text-align: center;'>Cyan is a non-voting mix station. </div>
</div>
<?php include "footer.php"; ?>