This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
header.inc
218 lines (187 loc) · 6.96 KB
/
header.inc
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
<?php
// Set title
$var1 = explode('/', $_SERVER['REQUEST_URI']);
$var2 = array_pop($var1);
$uri = urldecode($var2);
#$uri = urldecode(array_pop(explode('/', $_SERVER['REQUEST_URI'])));
$pageTitle = strtoupper($_SERVER['SERVER_NAME']) . " | Allmon | ";
if (preg_match("/voter\.php\?node=(\d+)$/", $uri, $matches)) {
$pageTitle .= "RTCM " . $matches[1];
} elseif (preg_match("/link\.php\?nodes=(.+)$/", $uri, $matches)) {
$pageTitle .= $matches[1];
} elseif (preg_match("/about/", $uri, $matches)) {
$pageTitle .= "" . ucfirst($matches[0]);
}
$home = '/';
if (!empty($var1[1])) {
$home="/" . $var1[1];
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $pageTitle; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="By hand with a text editor">
<meta name="description" content="Allstar node manager">
<meta name="keywords" content="allstar monitor, app_rpt, asterisk">
<meta name="robots" content="noindex, nofollow">
<meta name="author" content="Tim Sawyer, WD6AWP">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link type="text/css" rel="stylesheet" href="allmon.css">
<link type="text/css" rel="stylesheet" href="jquery-ui.css">
<script src="jquery-3.3.1.min.js"></script>
<script src="jquery-ui.min.js"></script>
<script type="text/javascript">
// Was allmon.js
// when DOM is ready
$(document).ready(function() {
//Set to hide Login Link
hideLoginLink = false
// Hide login link on page load?
if (hideLoginLink) {
$('#loginlink').hide();
}
<?php if ($_SESSION['loggedin'] === true) { ?>
$('#loginlink').hide();
<?php } else { ?>
$('#connect_form').hide();
$('#logoutlink').hide();
<?php } ?>
// Login dialog
$("#login").dialog( {
autoOpen: false,
title: 'Manager Login',
modal: true,
open: function() {
// On open, hide the original submit button
$( this ).find( "[type=submit]" ).hide();
},
buttons: [ {
text: "OK",
type: "submit",
form: "login",
click: function() {
var user = $('form input:text').val();
var passwd = $('input:password').val();
$(this).dialog("close");
$('#test_area').load("login.php", { 'user' : user, 'passwd' : passwd }, function(response) {
if (response.substr(0,5) != 'Sorry') {
$('#connect_form').show();
$('#logoutlink').show();
$('#loginlink').hide();
}
});
$('#test_area').stop().css('opacity', 1).fadeIn(50).delay(1000).fadeOut(2000);
}
} ]
});
// make enter key submit login form
$('#login').on('keyup', function(e){
if (e.keyCode == 13) {
$(':button:contains("OK")').click();
}
});
// Login dialog opener
$("#loginlink").click(function() {
$("#login").dialog('open');
return false;
});
// Logout
$('#logoutlink').click(function(event) {
$.get("logout.php");
if (! hideLoginLink) {
$('#loginlink').show();
}
$('#logoutlink').hide();
$('#connect_form').hide();
event.preventDefault();
});
// Ajax function a link
$('#connect, #monitor, #permanent, #localmonitor, #disconnect').click(function() {
var button = this.id; // which button was pushed
var localNode = $('#localnode').val();
var remoteNode = $('#node').val();
var perm = $('input:checkbox:checked').val();
if (remoteNode.length == 0) {
alert('Please enter the remote node number.');
return;
}
if (button == 'disconnect') {
r = confirm("Disconnect " + remoteNode + " from " + localNode + "?");
if (r !== true) {
return;
}
}
$.ajax( { url:'connect.php', data: { 'remotenode' : remoteNode, 'perm' : perm, 'button' : button, 'localnode' : localNode }, type:'post', success: function(result) {
$('#test_area').html(result);
$('#test_area').stop().css('opacity', 1).fadeIn(50).delay(1000).fadeOut(2000);
}
});
});
$('#controlpanel').click(function (event) {
var url = "controlpanel.php?node=" + $('#localnode').val();
var windowName = "controlPanel";
var windowSize = 'height=750, width=900';
window.open(url, windowName, windowSize);
event.preventDefault();
});
// Click on a cell to populate the input form
$('table').on('click', 'td', function( event ) {
// Shows the table ID, the text of the cell, the class of the cell and the ID of the cell.
//console.log('clicked:', $( this ).closest('table').attr('id'), $( this ).text(), $( this ).attr('class'), $( this ).attr('id'));
// shows x and y coordinates of clicked cell
//console.log('coordinates:', 'y=' + this.cellIndex, 'x=' + this.parentNode.rowIndex);
if ( $( this ).attr('class') == 'nodeNum') {
// Put node number into id="node"
$('#connect_form #node').val($( this ).text());
// split table ID and put node into id="localnode"
var idarr = $( this ).closest('table').attr('id').split('_');
$('#connect_form #localnode').val(idarr[1]);
}
});
// Uncomment this block to allow shift+h to show login dialog.
$(document).keypress(function(event) {
if (hideLoginLink) {
var checkWebkitandIE=(event.which==72 ? 1 : 0);
var checkMoz=(event.which==104 && event.shiftKey ? 1 : 0);
<?php if ($_SESSION['loggedin'] !== true) { ?>
if (checkWebkitandIE || checkMoz) {
$("#login").dialog('open');
return false;
}
<?php } ?>
}
});
});
</script>
</head>
<body>
<div id="header">
<div id="headerTitle"><a href="<?php echo $home ?>">Allstar Monitor II</a></div>
<div id="headerTag">
Monitoring the World One Node at a Time
</div>
<!-- Login opener -->
<div id="headerLogin">
<a href="#" id="loginlink">Login</a>
<a href="#" id="logoutlink">Logout</a>
</div>
<div id="headerImg"><img src="allstarLogo.png" alt="Allstar Logo"></div>
</div>
<div class="clearer"></div>
<!-- Login form -->
<div id="login">
<div>
<form method="post" action="">
<table>
<tr><td>Username:</td><td><input style="width: 150px;" type="text" name="user" autocapitalize="none"></td></tr>
<tr><td>Password:</td><td><input style="width: 150px;" type="password" name="password"></td></tr>
</table>
</form>
</div>
</div>
<?php include "menu.inc" ?>
<!-- Command response area -->
<div id="test_area"></div>