forked from M17-Project/ref-dash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
228 lines (204 loc) · 8.96 KB
/
index.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
/*
* This dashboard is being developed by the DVBrazil Team as a courtesy to
* the XLX Multiprotocol Gateway Reflector Server project.
* The dashboard is based of the Bootstrap dashboard template.
*
* This code is further edited by KC1AWV for the M17 Reflector M17-M17
*/
if (file_exists("./include/functions.php")) {
require_once("./include/functions.php");
} else {
die("functions.php does not exist.");
}
if (file_exists("./include/config.inc.php")) {
require_once("./include/config.inc.php");
} else {
die("config.inc.php does not exist.");
}
if (!class_exists('ParseXML')) require_once("./include/class.parsexml.php");
if (!class_exists('Node')) require_once("./include/class.node.php");
if (!class_exists('xReflector')) require_once("./include/class.reflector.php");
if (!class_exists('Station')) require_once("./include/class.station.php");
if (!class_exists('Peer')) require_once("./include/class.peer.php");
if (!class_exists('Interlink')) require_once("./include/class.interlink.php");
$Reflector = new xReflector();
$Reflector->SetFlagFile("./include/country.csv");
$Reflector->SetPIDFile($Service['PIDFile']);
$Reflector->SetXMLFile($Service['XMLFile']);
$Reflector->LoadXML();
if ($CallingHome['Active']) {
$CallHomeNow = false;
if (!file_exists($CallingHome['HashFile'])) {
$Hash = CreateCode(16);
$LastSync = 0;
$Ressource = @fopen($CallingHome['HashFile'], "w");
if ($Ressource) {
@fwrite($Ressource, "<?php\n");
@fwrite($Ressource, "\n" . '$LastSync = 0;');
@fwrite($Ressource, "\n" . '$Hash = "' . $Hash . '";');
@fwrite($Ressource, "\n\n" . '?>');
@fclose($Ressource);
@exec("chmod 777 " . $CallingHome['HashFile']);
$CallHomeNow = true;
}
} else {
include($CallingHome['HashFile']);
if ($LastSync < (time() - $CallingHome['PushDelay'])) {
$Ressource = @fopen($CallingHome['HashFile'], "w");
if ($Ressource) {
@fwrite($Ressource, "<?php\n");
@fwrite($Ressource, "\n" . '$LastSync = ' . time() . ';');
@fwrite($Ressource, "\n" . '$Hash = "' . $Hash . '";');
@fwrite($Ressource, "\n\n" . '?>');
@fclose($Ressource);
}
$CallHomeNow = true;
}
}
if ($CallHomeNow || isset($_GET['callhome'])) {
$Reflector->SetCallingHome($CallingHome, $Hash);
$Reflector->ReadInterlinkFile();
$Reflector->PrepareInterlinkXML();
$Reflector->PrepareReflectorXML();
$Reflector->CallHome();
}
} else {
$Hash = "";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="<?php echo $PageOptions['MetaDescription']; ?>"/>
<meta name="keywords" content="<?php echo $PageOptions['MetaKeywords']; ?>"/>
<meta name="author" content="<?php echo $PageOptions['MetaAuthor']; ?>"/>
<meta name="revisit" content="<?php echo $PageOptions['MetaRevisit']; ?>"/>
<meta name="robots" content="<?php echo $PageOptions['MetaAuthor']; ?>"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title><?php echo $Reflector->GetReflectorName(); ?> Reflector Dashboard</title>
<link rel="icon" type="image/png" href="/images/icons/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="/images/icons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/images/icons/favicon-96x96.png" sizes="96x96">
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/dashboard.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<?php
if ($PageOptions['PageRefreshActive']) {
echo '
<script src="./js/jquery-1.12.4.min.js"></script>
<script>
var PageRefresh;
function ReloadPage() {
$.get("./index.php'.(isset($_GET['show'])?'?show='.$_GET['show']:'').'", function(data) {
var BodyStart = data.indexOf("<bo"+"dy");
var BodyEnd = data.indexOf("</bo"+"dy>");
if ((BodyStart >= 0) && (BodyEnd > BodyStart)) {
BodyStart = data.indexOf(">", BodyStart)+1;
$("body").html(data.substring(BodyStart, BodyEnd));
}
})
.always(function() {
PageRefresh = setTimeout(ReloadPage, '.$PageOptions['PageRefreshDelay'].');
});
}';
if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'reflectors') && ($_GET['show'] != 'interlinks') && ($_GET['show'] != 'livequadnet'))) {
echo '
PageRefresh = setTimeout(ReloadPage, ' . $PageOptions['PageRefreshDelay'] . ');';
}
echo '
function SuspendPageRefresh() {
clearTimeout(PageRefresh);
}
</script>';
}
if (!isset($_GET['show'])) $_GET['show'] = "";
?>
</head>
<body>
<?php if (file_exists("./tracking.php")) {
include_once("tracking.php");
} ?>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand"><?php echo $Reflector->GetReflectorName(); ?> Reflector | IPv4: <?php echo $PageOptions['IPV4']; ?> | IPv6: <?php echo $PageOptions['IPV6']; ?></span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="navbar-info">mrefd v<?php echo $Reflector->GetVersion(); ?> - Dashboard
v<?php echo $PageOptions['DashboardVersion']; ?></li>
<li class="navbar-info">Service
uptime: <?php echo FormatSeconds($Reflector->GetServiceUptime()); ?></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li<?php echo (($_GET['show'] == "users") || ($_GET['show'] == "")) ? ' class="active"' : ''; ?>><a
href="./index.php">Last Heard</a></li>
<li<?php echo ($_GET['show'] == "repeaters") ? ' class="active"' : ''; ?>><a
href="./index.php?show=repeaters">Links (<?php echo $Reflector->NodeCount(); ?>)</a></li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<?php
if ($CallingHome['Active']) {
if (!is_readable($CallingHome['HashFile']) && (!is_writeable($CallingHome['HashFile']))) {
echo '
<div class="error">
your private hash in ' . $CallingHome['HashFile'] . ' could not be created, please check your config file and the permissions for the defined folder.
</div>';
}
}
switch ($_GET['show']) {
case 'users' :
require_once("./include/users.php");
break;
case 'repeaters' :
require_once("./include/repeaters.php");
break;
default :
require_once("./include/users.php");
}
?>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p><a href="mailto:<?php echo $PageOptions['ContactEmail']; ?>"><?php echo $PageOptions['ContactEmail']; ?></a>
</p>
</div>
</footer>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>