admin.php 10.6 KB
Newer Older
Eric - kg6wxc's avatar
Eric - kg6wxc committed
1
<?php 
Eric - kg6wxc's avatar
Eric - kg6wxc committed
2
$INCLUDE_DIR = "../..";
Eric - kg6wxc's avatar
Eric - kg6wxc committed
3
4
$USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini");
include $INCLUDE_DIR . "/scripts/wxc_functions.inc";
5
@include $INCLUDE_DIR . "/custom.inc";
Eric - kg6wxc's avatar
Eric - kg6wxc committed
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

$sqlSrvStatus;
$arname = "";

$sql_connection = wxc_connectToMySQL();

if (!$sql_connection) {
    $sqlSrvStatus = 0;
}else {
    $sqlSrvStatus = 1;
    $totalNumNodes = mysqli_num_rows(mysqli_query($sql_connection, "SELECT node from node_info"));
    $totalNumNodesWithLocations = mysqli_num_rows(mysqli_query($sql_connection, "SELECT node FROM node_info WHERE lat != '0' AND lon != '0'"));
    $totalNumLinks = mysqli_num_rows(mysqli_query($sql_connection, "SELECT node from topology"));
    $totalNumLinksWithLocations = mysqli_num_rows(mysqli_query($sql_connection, "SELECT node from topology where ((linklat != '0' OR linklat IS NOT NULL) AND (linklon != '0' OR linklon IS NOT NULL)) AND ((nodelat != '0' OR nodelat IS NOT NULL) AND (nodelon != '0' OR nodelon IS NOT NULL));"));
    $totalRemovedNodes = mysqli_num_rows(mysqli_query($sql_connection, "SELECT node from removed_nodes"));
    $totalIgnoredNodes = mysqli_num_rows(mysqli_query($sql_connection, "SELECT ip FROM hosts_ignore"));
    $lastUpdateNodeInfo = wxc_getMySql("SELECT currently_running, table_last_update FROM map_info WHERE id = 'NODEINFO'");
    $lastUpdateLinkInfo = wxc_getMySql("SELECT table_last_update FROM map_info WHERE id = 'LINKINFO'");
    $totalNumNonMeshMarkers = mysqli_num_rows(mysqli_query($sql_connection, "SELECT name from marker_info"));
    mysqli_close($sql_connection);    
}
?>
<!DOCTYPE html>
<html>
<head>
<title>MeshMap Admin Page</title>

33
34
35
36
37
if (file_exists("./admin.css") {
	<link rel='stylesheet' href='admin.css'>
}else {
	<link rel='stylesheet' href='admin.css-default'>
}
Eric - kg6wxc's avatar
Eric - kg6wxc committed
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
<!-- extra javascripts and css needed -->
<script src='../javascripts/jquery-3.2.1.js'></script>
<!-- <script type="text/javascript" src="../javascripts/jquery.dataTables.min.js"></script> -->
<!--  <link rel="stylesheet" type="text/css" href="../css/jquery.dataTables.min.css"> -->
<!-- <style type="text/css" class="init"></style> -->

<script>
var arname="<?php $tr_arname=isset($_REQUEST['arname']); echo "$tr_arname"; ?>";
function loadThePage(div_id, script)
{
        $("#"+div_id).html('<center><br><b>Loading...</b><br><?php echo "$tr_arname"; ?></center>');
        if (script == "changeLocation" ) {
        	$.ajax({
                type: "POST",
                url: "update_node_location.php",
                data: "arname="+arname,
                success: function(msg){
                        $("#"+div_id).html(msg);
						$('#nav_link_location').css("background-color", "#dddddd");
						$('#nav_link_non_mesh').css("background-color", "");
						$('#nav_link_removed').css("background-color", "");
						$('#nav_link_report').css("background-color", "");
                	}
        	});
        }
        if (script == "nonMeshStations") {
            $.ajax({
                    type: "POST",
                    url: "non_mesh_stations.php",
                    data: "arname="+arname,
                    success: function(msg){
                        $("#"+div_id).html(msg);
						$('#nav_link_location').css("background-color", "");
						$('#nav_link_non_mesh').css("background-color", "#dddddd");
						$('#nav_link_removed').css("background-color", "");
						$('#nav_link_report').css("background-color", "");
                    }
            });
        }
        if (script == "removedNodes") {
            $.ajax({
                    type: "POST",
                    url: "view_removed_nodes.php",
                    data: "arname="+arname,
                    success: function(msg){
                        $("#"+div_id).html(msg);
						$('#nav_link_location').css("background-color", "");
						$('#nav_link_non_mesh').css("background-color", "");
						$('#nav_link_removed').css("background-color", "#dddddd");
						$('#nav_link_report').css("background-color", "");
                    }
            });
        }
        if (script == "nodeReport") {
            $.ajax({
                    type: "POST",
                    url: "../node_report.php",
                    data: "arname="+arname,
                    success: function(msg){
                        $("#"+div_id).html(msg);
						$('#nav_link_location').css("background-color", "");
						$('#nav_link_non_mesh').css("background-color", "");
						$('#nav_link_removed').css("background-color", "");
						$('#nav_link_report').css("background-color", "#dddddd");
					}
            });
        }
        if (script == "viewMap") {
            $.ajax({
                    type: "POST",
                    url: "../map.php",
                    data: "arname="+arname,
                    success: function(msg){
                            $("#"+div_id).html(msg);
                    }
            });
        }
}
//auto updating values in the "status" area (hopefully)
var db_stats_ajax_call = function() {
		//ajax query code
		$.ajax({
			type: "GET",
			url: "status_updates.php",
			data: "arname="+arname,
			success: function(msg) {
				$("#admin_status").html(msg);
			}
		});
}
var interval = 1000 * 60 * 1; //every 1 minute
setInterval(db_stats_ajax_call, interval);
</script>
</head>
<body>
<div id='admin_wrapper'>

<div id='admin_header'>
<img style="height: 1.5em;" src="../images/WXC.png">
<strong><span class='em1-5Text'><a class='normalTextLink' id='admin_main_link' href=''>Mesh Map Admin Page</a></span></strong>
<span class='emDot5Text'>(beta)</span>
<br>
Running on <?php
echo $_SERVER['HTTP_HOST'] . " ";
?>

<!-- The links at the lower part of the "header" -->
<div class='admin_nav_links' id='admin_nav_links'>
<a id="nav_link_location" href="javascript:onclick=loadThePage('admin_content', 'changeLocation');">Change Node Location</a>
&nbsp;&nbsp;
<a id="nav_link_non_mesh" href="javascript:onclick=loadThePage('admin_content', 'nonMeshStations');">Add Non-Mesh Map Marker</a>
&nbsp;&nbsp;
<a id="nav_link_removed" href="javascript:onclick=loadThePage('admin_content', 'removedNodes');">View Removed Nodes</a>
&nbsp;&nbsp;
<a id="nav_link_report" href="javascript:onclick=loadThePage('admin_content', 'nodeReport');">Node Report</a>
&nbsp;&nbsp;
<!-- <s>View Map</s>(not yet, reload map page to see changes) -->
<!-- <a href="javascript:onclick=loadThePage('admin_content', 'viewMap');">View Map</a> -->
</div> <!-- end admin_nav_links inner div -->

<div id='admin_status'>
<table id="admin_sql_status_table">
<thead>
<tr>
<th colspan="3" class="admin_sql_status_table_background">
<strong>SQL server </strong>
<?php
echo "&nbsp;( " . $USER_SETTINGS['sql_server'] . " ): \n";
if($sqlSrvStatus == 1) {
    echo '<img class="img-valign emDot75Text" src="../images/greenDot.png">' . "\n";
}else {
    echo '<img class="img-valign emDot75Text" src="../images/redDot.png">' . "\n";
}

echo "</th>";
echo "<th class=\"admin_sql_status_table_background\"></th>\n";
echo "<th class=\"admin_sql_status_table_background\"></th>\n";
echo "<th style=\"text-align: right;\" colspan=\"3\" class=\"admin_sql_status_table_background\">\n";
echo "Currently Polling Nodes: ";
if($lastUpdateNodeInfo['currently_running'] == 1) {
    echo '<img class="img-valign emDot75Text" src="../images/greenDot.png">' . "\n";
}else {
    echo '<img class="img-valign emDot75Text" src="../images/redDot.png">' . "\n";
}
echo "</tr>";
echo "</thead>\n";
//echo "<table id='admin_sql_status_table'>";
echo "<tbody>";
echo "<tr>\n";
echo "<td class=\"admin_sql_status_table_background\">Nodes:</td>\n";
echo "<td class=\"admin_sql_status_table_background\">$totalNumNodes</td>\n";
echo "<td class=\"admin_sql_status_table_background\">With Locations:</td>\n";
echo "<td class=\"admin_sql_status_table_background\">$totalNumNodesWithLocations</td>\n";
echo "<td colspan=\"2\" class=\"admin_sql_status_table_background\">Nodes Last Polled:</td>\n";
//echo "<td class=\"admin_sql_status_table_background\">&nbsp;</td>\n";
echo "<td class=\"admin_sql_status_table_background\">" . $lastUpdateNodeInfo['table_last_update'] . "\n";
echo "<td class=\"admin_sql_status_table_background\"></td>\n";
echo "</tr>";
echo "<tr>";
echo "<td class=\"admin_sql_status_table_background\">Links:</td>\n";
echo "<td class=\"admin_sql_status_table_background\">$totalNumLinks</td>\n";
echo "<td class=\"admin_sql_status_table_background\">With Locations:</td>\n";
echo "<td class=\"admin_sql_status_table_background\">$totalNumLinksWithLocations</td>\n";
echo "<td colspan=\"2\" class=\"admin_sql_status_table_background\">Links Last Updated:</td>\n";
//echo "<td class=\"admin_sql_status_table_background\">Updated:</td>\n";
echo "<td class=\"admin_sql_status_table_background\">" . $lastUpdateLinkInfo['table_last_update'] . "\n";
echo "<td class=\"admin_sql_status_table_background\">&nbsp;</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"admin_sql_status_table_background\">Expired:</td>\n";
echo "<td style=\"text-align: left;\" class=\"admin_sql_status_table_background\">$totalRemovedNodes</td>\n";
echo "<td style=\"text-align: right;\" class=\"admin_sql_status_table_background\">Ignored:</td>\n";
echo "<td class=\"admin_sql_status_table_background\">$totalIgnoredNodes</td>\n";
//echo "<td class=\"admin_sql_status_table_background\"></td>\n";
//echo "<td class=\"admin_sql_status_table_background\"></td>\n";
echo "<td class=\"admin_sql_status_table_background\">Non Mesh Icons:</td>\n";
echo "<td class=\"admin_sql_status_table_background\">$totalNumNonMeshMarkers</td>\n";
echo "<td colspan=\"2\" style=\"text-align: right;\" class=\"admin_sql_status_table_background\">Parallel Mode: ";
if ($USER_SETTINGS['node_polling_parallel'] == "1") {
    echo "Yes";
}else {
    echo "No";
}
echo "</td>\n";
echo "</tr>\n";
echo "</tbody>";
//echo "</table>";
// echo "<br>Nodes: " . $totalNumNodes . " \n";
// echo "&nbsp;&nbsp;With Locations: " . $totalNumNodesWithLocations . "&nbsp;\n";
// echo "<br>Links: " . $totalNumLinks . "\n";
// echo "&nbsp;&nbsp;With Locations: " . $totalNumLinksWithLocations . "\n";
// echo "<br>Expired: " . $totalRemovedNodes . "\n";
?>
</table>
<!-- <strong>Currently Polling: </strong> -->
</div> <!-- end admin_status inner div -->

</div> <!-- end admin_header div -->

<div id='admin_content'>
<br>
Please use the tabs/links above to navigate to the different sections.
<br>
<br>
Most tables are sortable, just click on the header.
<br>
<br>
Eventually, you should be able to have different users and actually have to login to use most of this.
<br>
<br>
Have fun and let me know any issues or ideas you find.
<br>
(especially any "metrics" you can think of to watch in the "status" area)
<br>
-wxc
</div>

</div> <!-- wrapper close -->
<?php //mysqli_close($sql_connection); ?>
</body>
</html>