-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·282 lines (259 loc) · 12.4 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?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.
*/
if (file_exists("./pgs/functions.php")) {
require_once("./pgs/functions.php");
} else {
die("functions.php does not exist. I");
}
if (file_exists("./pgs/config.inc.php")) {
require_once("./pgs/config.inc.php");
} else {
die("config.inc.php does not exist.");
}
if (!class_exists('ParseXML')) require_once("./pgs/class.parsexml.php");
if (!class_exists('Node')) require_once("./pgs/class.node.php");
if (!class_exists('xReflector')) require_once("./pgs/class.reflector.php");
if (!class_exists('Station')) require_once("./pgs/class.station.php");
if (!class_exists('Peer')) require_once("./pgs/class.peer.php");
if (!class_exists('Interlink')) require_once("./pgs/class.interlink.php");
$Reflector = new xReflector();
$Reflector->SetFlagFile("./pgs/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 = "";
}
function getContentHandler()
{
switch ($_GET["show"]) {
case 'users' :
return "pgs/users.php?module=" . $_GET["module"];
case 'repeaters' :
return "pgs/repeaters.php?module=" . $_GET["module"];
case 'liveircddb' :
return "pgs/liveircddb.php?module=" . $_GET["module"];
case 'peers' :
return "pgs/peers.php?module=" . $_GET["module"];
case 'reflectors' :
return "pgs/reflectors.php?module=" . $_GET["module"];
case 'moduleslist' :
return "pgs/moduleslist.php?module=" . $_GET["module"];
case 'sysinfo' :
return "pgs/sysinfo.php?module=" . $_GET["module"];
case 'sgs' :
return "pgs/sgs.php?module=" . $_GET["module"];
default :
return "pgs/users.php?module=" . $_GET["module"];
}
}
function getRefreshTimeout()
{
global $PageOptions;
switch ($_GET["show"]) {
case 'users' :
return $PageOptions['PageRefreshDelay'];
case 'repeaters' :
return $PageOptions['PageRefreshDelay'];
case 'liveircddb' :
return $PageOptions['PageRefreshDelay'];
case 'peers' :
return $PageOptions['PageRefreshDelay'];
case 'reflectors' :
return null;
case 'moduleslist' :
return null;
case 'sysinfo' :
return $PageOptions['PageRefreshDelay'];
case 'sgs' :
return $PageOptions['PageRefreshAlt'];
default :
return $PageOptions['PageRefreshDelay'];
}
}
?>
<!DOCTYPE html>
<html lang=" en">
<head>
<base href="/" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<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" href="./favicon.ico" type="image/vnd.microsoft.icon">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!-- own css -->
<link rel="stylesheet" href="/css/style.css">
<style type="text/css">
/* Make sure pills strech to whole screen on lg break point */
@media (max-width: 992px) {
.nav-fill .nav-item {
width: 100% !important;
flex-basis: unset !important;
}
}
</style>
<?php if (file_exists("./tracking.php")) include_once("tracking.php"); ?>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
<div class="media border-right mr-3 pr-0">
<img class="m-0 p-0" style="height:75px;" src="<?php echo $PageOptions['LogoFile']; ?>">
<div class="media-body text-center">
<p class="navbar-brand h1 mt-0 mb-0 ml-3 mr-3"><?php echo $Reflector->GetReflectorName(); echo isset($PageOptions['SGS']['name']) ? "<br>" . $PageOptions['SGS']['name'] : ""; ?></p>
<p class="border-top pt-1 mt-0 mb-0 ml-3 mr-3"><small><a target="_blank"
href="<?php echo $PageOptions['CustomTXTLink']; ?>"><?php echo $PageOptions['CustomTXT'];?></a></small>
</p>
</div>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="nav collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="nav nav-pills nav-fill">
<a class="nav-link nav-item<?php echo (($_GET['show'] == "users" || $_GET['show'] == "") && $_GET['module'] == "") ? ' active' : ''; ?>"
href="./index.php?show=users">Utilisateurs (<?php echo $Reflector->StationCount(); ?>) / Modules
(<?php echo count($Reflector->GetModules()); ?>)</a>
<a class="nav-link nav-item<?php echo ($_GET['show'] == "repeaters") ? ' active' : ''; ?>"
href="./index.php?show=repeaters">Relais / Nodes (<?php echo $Reflector->NodeCount(); ?>)</a>
<a class="nav-link nav-item<?php echo ($_GET['show'] == "moduleslist") ? ' active' : ''; ?>"
href="./index.php?show=moduleslist">Liste des Modules
(<?php echo count($PageOptions['ModuleNames']); ?>)</a>
<a class="nav-link nav-item<?php echo ($_GET['show'] == "peers") ? ' active' : ''; ?>"
href="./index.php?show=peers">Interlink (<?php echo $Reflector->PeerCount(); ?>)</a>
<a class="nav-link nav-item<?php echo ($_GET['show'] == "sgs") ? ' active' : ''; ?>"
href="./index.php?show=sgs">Smart Group Server</a>
<a class="nav-link nav-item<?php echo ($_GET['show'] == "reflectors") ? ' active' : ''; ?>"
href="./index.php?show=reflectors">Liste des réflecteurs XLX</a>
<a class="nav-link nav-item<?php echo ($_GET['show'] == "sysinfo") ? ' active' : ''; ?>"
href="./index.php?show=sysinfo">Infos. Système</a>
<!-- <a class="nav-link nav-item<?php echo ($_GET['show'] == "liveircddb") ? ' active' : ''; ?>" href="./index.php?show=liveircddb">D-Star live</a> -->
</div>
</div>
</nav>
<?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>';
}
}
?>
<div class="container-fluid" id="dashboard-content">
<div class="row justify-content-md-left" id="place-holder">
<h5>Loading ...</h5>
</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
================================================== -->
<!-- <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous">
</script> -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous">
</script>
<script language="javascript">
function reloadDashboard()
{
/*var scrolls = [];
var tables = $("#dashboard-content").find("table");
if(tables != null)
{
tables.each(t => scrolls.push(t.scrollLeft()));
}*/
$("#dashboard-content").load("<?php echo getContentHandler(); ?>&nocache=" + Date.now());
/*if(scrolls != null)
{
var tables = $("#dashboard-content").find("table");
for(var i =0; i < scrolls.length || i < tables.length; i++)
{
tables[i].scrollLeft(scrolls[i]);
}
}*/
/*var xhr=null;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.open("GET", "<?php echo getContentHandler(); ?>&nocache=" + Date.now(), true);
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
document.getElementById('dashboard-content').innerHTML = xhr.responseText;
}
}
xhr.send(null);*/
<?php
$timeout = getRefreshTimeout();
if(isset($timeout))
echo "setTimeout(reloadDashboard, " . $timeout . ");\n";
?>
}
reloadDashboard();
</script>
</body>
</html>