Commit bfbf4570 authored by Eric - kg6wxc's avatar Eric - kg6wxc
Browse files

Bugfix/Update/Enhancement Admin pages

Finally finished a rough version of some admin pages that allow for
maintenance of the DB, fixing node locations, removing nodes, etc...
Username/Password is required to use the admin pages.
You must create an intial user/password.
When you first load the admin page it will ask you to create an initial
user.
This initial user is a "super user" and will be able to create other
users.
(more info is on the admin pages themselves)

Fixed a stupid mistake in export2csv.php.

Rearranged the columns in the node_info datebase which make the data
more readable when exported as CSV file.

Removed old DB columns that were now unused.

Changed the *.css-default file(s) to *-default.css so that IE will use
them without complaints.

More than a few other little changes here and there...
parent 12b091b3
......@@ -26,8 +26,10 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail.
<ul>
<li><strong>Apache webserver</strong><br/>
(or equiv)</li>
<li><strong>PHP</strong></li>
<li><strong>PHP mysqli extension</strong></li>
<li><strong>PHP5+</strong></li>
<li><strong>mysqli PHP extension</strong></li>
<li><strong>openssl PHP extension</strong><br/>
(One or both of these extensions may need to be enabled in php.ini)</li>
<li><strong>MySQL/MariaDB</strong><br/>
(Other database systems are up to you)</li>
<li><strong>An AREDN Mesh node available over the local network</strong><br/>
......@@ -94,11 +96,12 @@ Building/Using a map tile server is not for the faint of heart!</blockquote>
<li><p><strong>2: Import the SQL file to create the database</strong><br/>
<em>Example</em>: <code>sudo mysql &lt; node_map.sql</code></p></li>
<li><p><strong>3: Create a user for the database, you might have to login to the mysql server as root.</strong><br/>
Here is an example of creating a mySQL user and granting access to the node_map database:</p>
Here is an example of creating a mySQL user and granting access to the node_map database:<br/>
Choose your own password!</p>
<blockquote><p><code>sudo mysql</code><br/>
<code>CREATE USER 'mesh-map'@'localhost' IDENTIFIED BY 'password';</code><br/>
<code>GRANT SELECT, DELETE, DROP, INSERT, TRIGGER, UPDATE on node_map.* TO 'mesh-map'@'localhost';</code><br/>
<code>GRANT ALL PRIVILEGES on node_map.* TO 'mesh-map'@'localhost';</code><br/>
<code>FLUSH PRIVLEGES;</code></p></blockquote></li>
<li><p><strong>4: Copy scripts/user-settings.ini-default to /scripts/user-settings.ini and edit the user-settings.ini file</strong></p>
......@@ -108,7 +111,8 @@ It is <strong>very important</strong> to make sure your SQL username and passwor
<li>Also important is, if the system that this is running on cannot resolve &ldquo;localnode.local.mesh&rdquo; you can change that in the user-settings.ini file.</li>
<li>Once you save to the user-settings.ini file any changes you make will not be overwritten by future updates.<br/>
The &ldquo;-default&rdquo; files <em>will probably</em> change though and you will need to update your personal files when this happens.</li>
<li>There are many other things you can change in the ini files. Default Map center position, the header messages, etc.</li>
<li>There are many other things you can change in the ini files.<br/>
The default center position of the map, node expiration intervals, the header messages, logo, etc.</li>
<li><em>Please read</em> the comments in the user-settings.ini file for more info about the different settings.</li>
<li>There is also a &ldquo;custom.inc-default&rdquo; PHP file that can be used for more site specific overrides if needed.<br/>
Read that file for info on what it does, it can safely be ignored by most users.</li>
......@@ -194,18 +198,24 @@ Hopefully in the future this process can be more automated.</p>
This can be useful to see if all the data is there or to find nodes that have no location set. (or other issues)</p>
<p>There is an &ldquo;admin&rdquo; page, which is still in the works, what is there now does work tho.<br/>
Try to load up: http://(hostname)/meshmap/admin/admin.php in your web browser.<br/>
Load up: http://(hostname)/meshmap/admin/admin.php in your web browser.<br/>
The first time the admin page is loaded it will ask you to create a username and password, do so.<br/>
This initial user will be a &ldquo;super-user&rdquo; and can then add/remove other users.<br/>
I&rsquo;ve tried to provide instructions on the admin pages themselves.<br/>
From the admin pages you can &ldquo;fix&rdquo; a nodes location, which can be helpful for those users that forget the &ldquo;-&rdquo; in front of their longitude. :)<br/>
The admin pages also allow for the addition of &ldquo;Non Mesh&rdquo; Markers, fire stations, police stations, EOC&rsquo;s , etc&hellip;</p>
You can add the &ldquo;Non Mesh&rdquo; Markers, fire stations, police stations, EOC&rsquo;s , etc from the admin pages&hellip;<br/>
The admin pages also allow for some maintenance of the database, more feedback is encouraged on this!</p>
<p>You can change the way the page looks by copying webpage/css/meshmap.css-default to webpage/css/meshmap.css.</p>
<p>You can change the way the page looks by copying webpage/css/meshmap-default.css to webpage/css/meshmap.css.<br/>
The meshmap.css file will be used in place of the -default.css file.<br/>
(This also applies to other *-default.css files)</p>
<h2>ToDo List</h2>
<hr />
<p>(In no particular order)<br/>
- [x] Finally finish my admin page idea.<br/>
- [x] Add new MeshMap Logo.<br/>
- [x] Change the user editable files to be distributed with &ldquo;-default&rdquo; added to the extension, no more tar.gz file.<br/>
- [x] Use a cookie instead of _POST for the internet check (No more stupid dialog box on refresh).<br/>
......
......@@ -19,8 +19,10 @@ Donations / Beer accepted! :) (paypal possibly coming soon, email: kg6wxc@gmail.
---------------
- **Apache webserver**
(or equiv)
- **PHP**
- **PHP mysqli extension**
- **PHP5+**
- **mysqli PHP extension**
- **openssl PHP extension**
(One or both of these extensions may need to be enabled in php.ini)
- **MySQL/MariaDB**
(Other database systems are up to you)
- **An AREDN Mesh node available over the local network**
......@@ -75,10 +77,11 @@ Building/Using a map tile server is not for the faint of heart!</blockquote>
*Example*: `sudo mysql < node_map.sql`
- **3: Create a user for the database, you might have to login to the mysql server as root.**
Here is an example of creating a mySQL user and granting access to the node_map database:
Here is an example of creating a mySQL user and granting access to the node_map database:
Choose your own password!
> `sudo mysql`
> `CREATE USER 'mesh-map'@'localhost' IDENTIFIED BY 'password';`
> `GRANT SELECT, DELETE, DROP, INSERT, TRIGGER, UPDATE on node_map.* TO 'mesh-map'@'localhost';`
> `GRANT ALL PRIVILEGES on node_map.* TO 'mesh-map'@'localhost';`
> `FLUSH PRIVLEGES;`
- **4: Copy scripts/user-settings.ini-default to /scripts/user-settings.ini and edit the user-settings.ini file**
......@@ -87,7 +90,8 @@ Here is an example of creating a mySQL user and granting access to the node_map
* Also important is, if the system that this is running on cannot resolve "localnode.local.mesh" you can change that in the user-settings.ini file.
* Once you save to the user-settings.ini file any changes you make will not be overwritten by future updates.
The "-default" files *will probably* change though and you will need to update your personal files when this happens.
* There are many other things you can change in the ini files. Default Map center position, the header messages, etc.
* There are many other things you can change in the ini files.
The default center position of the map, node expiration intervals, the header messages, logo, etc.
* *Please read* the comments in the user-settings.ini file for more info about the different settings.
* There is also a "custom.inc-default" PHP file that can be used for more site specific overrides if needed.
Read that file for info on what it does, it can safely be ignored by most users.
......@@ -152,16 +156,22 @@ http://(hostname)/meshmap/node_report.php will show you all the info in the DB w
This can be useful to see if all the data is there or to find nodes that have no location set. (or other issues)
There is an "admin" page, which is still in the works, what is there now does work tho.
Try to load up: http://(hostname)/meshmap/admin/admin.php in your web browser.
Load up: http://(hostname)/meshmap/admin/admin.php in your web browser.
The first time the admin page is loaded it will ask you to create a username and password, do so.
This initial user will be a "super-user" and can then add/remove other users.
I've tried to provide instructions on the admin pages themselves.
From the admin pages you can "fix" a nodes location, which can be helpful for those users that forget the "-" in front of their longitude. :)
The admin pages also allow for the addition of "Non Mesh" Markers, fire stations, police stations, EOC's , etc...
You can add the "Non Mesh" Markers, fire stations, police stations, EOC's , etc from the admin pages...
The admin pages also allow for some maintenance of the database, more feedback is encouraged on this!
You can change the way the page looks by copying webpage/css/meshmap.css-default to webpage/css/meshmap.css.
You can change the way the page looks by copying webpage/css/meshmap-default.css to webpage/css/meshmap.css.
The meshmap.css file will be used in place of the -default.css file.
(This also applies to other *-default.css files)
## ToDo List
----------
(In no particular order)
- [x] Finally finish my admin page idea.
- [x] Add new MeshMap Logo.
- [x] Change the user editable files to be distributed with "-default" added to the extension, no more tar.gz file.
- [x] Use a cookie instead of _POST for the internet check (No more stupid dialog box on refresh).
......
-- --------------------------------------------------------
-- Host: camphost
-- Server version: 10.0.30-MariaDB - MariaDB Server
-- Host: 192.168.81.222
-- Server version: 10.2.14-MariaDB-log - MariaDB Server
-- Server OS: Linux
-- HeidiSQL Version: 9.5.0.5264
-- HeidiSQL Version: 9.4.0.5125
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
......@@ -26,28 +26,16 @@ CREATE TABLE IF NOT EXISTS `hosts_ignore` (
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Hostnames to ignore because they are probably not AREDN nodes.';
-- Data exporting was unselected.
-- Dumping structure for table node_map.mac_ip_name_map
CREATE TABLE IF NOT EXISTS `mac_ip_name_map` (
`mac_address` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`ip_address` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`node_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
UNIQUE KEY `hostname` (`node_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Hostnames, IP address, and MAC addresses';
-- Data exporting was unselected.
-- Dumping structure for table node_map.map_info
CREATE TABLE IF NOT EXISTS `map_info` (
`id` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`table_or_script_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`table_records_num` int(11) DEFAULT NULL,
`table_update_num` int(11) NOT NULL DEFAULT '0',
`table_update_num` int(11) NOT NULL DEFAULT 0,
`table_last_update` datetime DEFAULT NULL,
`script_last_run` datetime DEFAULT NULL,
`currently_running` int(11) DEFAULT '0' COMMENT 'tells us if getNodeInfo is currently running or not',
`user` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`passwd` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_login` datetime DEFAULT NULL,
`currently_running` int(11) DEFAULT 0 COMMENT 'tells us if getNodeInfo is currently running or not',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Keeping track of some things about the map';
......@@ -67,53 +55,51 @@ CREATE TABLE IF NOT EXISTS `marker_info` (
-- Data exporting was unselected.
-- Dumping structure for table node_map.node_info
CREATE TABLE IF NOT EXISTS `node_info` (
`wifi_mac_address` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`node` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`lat` double DEFAULT NULL,
`lon` double DEFAULT NULL,
`wlan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_seen` datetime DEFAULT NULL,
`model` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`firmware_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`ssid` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`channel` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`chanbw` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`api_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`board_id` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`tunnel_installed` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`active_tunnel_count` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`channel` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`grid_square` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`lat` double DEFAULT NULL,
`lon` double DEFAULT NULL,
`wifi_mac_address` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`api_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`board_id` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`firmware_mfg` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`grid_square` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`lan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`wlan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`sysinfo_json` mediumblob,
`olsrinfo_json` mediumblob,
`last_seen` datetime DEFAULT NULL,
`location_fix` int(11) DEFAULT '0',
`sysinfo_json` mediumblob DEFAULT NULL,
`location_fix` int(11) DEFAULT 0,
UNIQUE KEY `node` (`node`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Information about the nodes\r\ntaken from sysinfo.json that is on every node.';
-- Data exporting was unselected.
-- Dumping structure for table node_map.removed_nodes
CREATE TABLE IF NOT EXISTS `removed_nodes` (
`wifi_mac_address` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`node` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`lat` double DEFAULT NULL,
`lon` double DEFAULT NULL,
`wlan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_seen` datetime DEFAULT NULL,
`model` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`firmware_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`ssid` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`channel` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`chanbw` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`api_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`board_id` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`tunnel_installed` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`active_tunnel_count` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`channel` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`gridsquare` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`lat` double DEFAULT NULL,
`lon` double DEFAULT NULL,
`wifi_mac_address` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`api_version` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`board_id` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`firmware_mfg` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`grid_square` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`lan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`wlan_ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`sysinfo_json` mediumblob,
`olsrinfo_json` mediumblob,
`last_seen` datetime DEFAULT NULL,
`sysinfo_json` mediumblob DEFAULT NULL,
`time_removed` datetime DEFAULT NULL,
UNIQUE KEY `node` (`node`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='A place to put old nodes';
......@@ -137,7 +123,7 @@ CREATE TABLE IF NOT EXISTS `topology` (
-- Dumping structure for table node_map.users
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`admin` int(1) DEFAULT '0',
`admin` int(1) DEFAULT 0,
`user` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`passwd` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_login` datetime DEFAULT NULL,
......
......@@ -538,21 +538,21 @@ if ($getNodeInfo) {
$sql = "INSERT INTO $sql_db_tbl(
wifi_mac_address, node, model, firmware_version, lat, lon, grid_square, ssid, chanbw, api_version, board_id,
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, olsrinfo_json, last_seen)
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, last_seen)
VALUES('$wifi_mac_address', '$node', '$model', '$firmware_version',
'$lat', '$lon', '$grid_square', '$ssid', '$chanbw', '$api_version', '$board_id',
'$tunnel_installed', '$active_tunnel_count', '$channel',
'$firmware_mfg', '$lan_ip', '$wlan_ip', '$sysinfoJson', '$olsrdInfo', NOW())
'$firmware_mfg', '$lan_ip', '$wlan_ip', '$sysinfoJson', NOW())
ON DUPLICATE KEY UPDATE wifi_mac_address = '$wifi_mac_address', node = '$node', model = '$model', firmware_version = '$firmware_version',
lat = '$lat', lon = '$lon', grid_square = '$grid_square', ssid = '$ssid', chanbw = '$chanbw', api_version = '$api_version',
board_id = '$board_id', tunnel_installed = '$tunnel_installed',
active_tunnel_count = '$active_tunnel_count', channel = '$channel',
firmware_mfg = '$firmware_mfg', lan_ip = '$lan_ip', wlan_ip = '$wlan_ip',
sysinfo_json = '$sysinfoJson', olsrinfo_json = '$olsrdInfo', last_seen = NOW()";
sysinfo_json = '$sysinfoJson', last_seen = NOW()";
$sql_no_location_info = "INSERT INTO $sql_db_tbl(
wifi_mac_address, node, model, firmware_version, grid_square, ssid, chanbw, api_version, board_id,
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, olsrinfo_json, last_seen)
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, last_seen)
VALUES('$wifi_mac_address', '$node', '$model', '$firmware_version',
'$grid_square', '$ssid', '$chanbw', '$api_version', '$board_id',
'$tunnel_installed', '$active_tunnel_count', '$channel',
......@@ -562,7 +562,7 @@ if ($getNodeInfo) {
board_id = '$board_id', tunnel_installed = '$tunnel_installed',
active_tunnel_count = '$active_tunnel_count', channel = '$channel',
firmware_mfg = '$firmware_mfg', lan_ip = '$lan_ip', wlan_ip = '$wlan_ip',
sysinfo_json = '$sysinfoJson', olsrinfo_json = '$olsrdInfo', last_seen = NOW()";
sysinfo_json = '$sysinfoJson', last_seen = NOW()";
$sql_update_when_node_name_has_changed = "UPDATE $sql_db_tbl SET
node = '$node', model = '$model',
......
......@@ -85,7 +85,8 @@ function build_NodesAndLinks($NodeList, $TopoList, $MarkerList = null)
/*
* Find the Services for the node
********************************/
$node_ServiceList = load_ServiceList($node_info['olsrinfo_json']);
// $node_ServiceList = load_ServiceList($node_info['olsrinfo_json']);
$node_ServiceList = "";
/*
* Build the Nodes Marker
......
......@@ -261,31 +261,31 @@ if($sysinfoJson === FALSE) {
$sql = "INSERT INTO $sql_db_tbl(
wifi_mac_address, node, model, firmware_version, lat, lon, grid_square, ssid, chanbw, api_version, board_id,
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, olsrinfo_json, last_seen)
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, last_seen)
VALUES('$wifi_mac_address', '$node', '$model', '$firmware_version',
'$lat', '$lon', '$grid_square', '$ssid', '$chanbw', '$api_version', '$board_id',
'$tunnel_installed', '$active_tunnel_count', '$channel',
'$firmware_mfg', '$lan_ip', '$wlan_ip', '$sysinfoJson', '$olsrdInfo', NOW())
'$firmware_mfg', '$lan_ip', '$wlan_ip', '$sysinfoJson', NOW())
ON DUPLICATE KEY UPDATE wifi_mac_address = '$wifi_mac_address', node = '$node', model = '$model', firmware_version = '$firmware_version',
lat = '$lat', lon = '$lon', grid_square = '$grid_square', ssid = '$ssid', chanbw = '$chanbw', api_version = '$api_version',
board_id = '$board_id', tunnel_installed = '$tunnel_installed',
active_tunnel_count = '$active_tunnel_count', channel = '$channel',
firmware_mfg = '$firmware_mfg', lan_ip = '$lan_ip', wlan_ip = '$wlan_ip',
sysinfo_json = '$sysinfoJson', olsrinfo_json = '$olsrdInfo', last_seen = NOW()";
sysinfo_json = '$sysinfoJson', last_seen = NOW()";
$sql_no_location_info = "INSERT INTO $sql_db_tbl(
wifi_mac_address, node, model, firmware_version, grid_square, ssid, chanbw, api_version, board_id,
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, olsrinfo_json, last_seen)
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, last_seen)
VALUES('$wifi_mac_address', '$node', '$model', '$firmware_version',
'$grid_square', '$ssid', '$chanbw', '$api_version', '$board_id',
'$tunnel_installed', '$active_tunnel_count', '$channel',
'$firmware_mfg', '$lan_ip', '$wlan_ip', '$sysinfoJson', '$olsrdInfo', NOW())
'$firmware_mfg', '$lan_ip', '$wlan_ip', '$sysinfoJson', NOW())
ON DUPLICATE KEY UPDATE wifi_mac_address = '$wifi_mac_address', node = '$node', model = '$model', firmware_version = '$firmware_version',
grid_square = '$grid_square', ssid = '$ssid', chanbw = '$chanbw', api_version = '$api_version',
board_id = '$board_id', tunnel_installed = '$tunnel_installed',
active_tunnel_count = '$active_tunnel_count', channel = '$channel',
firmware_mfg = '$firmware_mfg', lan_ip = '$lan_ip', wlan_ip = '$wlan_ip',
sysinfo_json = '$sysinfoJson', olsrinfo_json = '$olsrdInfo', last_seen = NOW()";
sysinfo_json = '$sysinfoJson', last_seen = NOW()";
$sql_update_when_node_name_has_changed = "UPDATE $sql_db_tbl SET
node = '$node', model = '$model',
......
......@@ -452,7 +452,7 @@ function wxc_checkOldNodes() {
$oldNodeQuery =
"INSERT INTO removed_nodes (
wifi_mac_address, node, model, firmware_version, lat, lon, ssid, chanbw, api_version, board_id,
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, olsrinfo_json, last_seen, time_removed)
tunnel_installed, active_tunnel_count, channel, firmware_mfg, lan_ip, wlan_ip, sysinfo_json, last_seen, time_removed)
VALUES ";
$valuesArray = array();
foreach ($oldNodes as $row) {
......@@ -474,11 +474,11 @@ function wxc_checkOldNodes() {
$lan_ip = $row['lan_ip'];
$wlan_ip = $row['wlan_ip'];
$sysinfo_json = $row['sysinfo_json'];
$olsrinfo_json = $row['olsrinfo_json'];
//$olsrinfo_json = $row['olsrinfo_json'];
$last_seen = $row['last_seen'];
$valuesArray[] = "('$wifi_mac_address', '$node', '$model', '$firmware_version', '$lat', '$lon', '$ssid', '$chanbw', '$api_version', '$board_id',
'$tunnel_installed', '$active_tunnel_count', '$channel', '$firmware_mfg', '$lan_ip', '$wlan_ip', '$sysinfo_json', '$olsrinfo_json', '$last_seen', NOW())";
'$tunnel_installed', '$active_tunnel_count', '$channel', '$firmware_mfg', '$lan_ip', '$wlan_ip', '$sysinfo_json', '$last_seen', NOW())";
}
if ($valuesArray) {
......
<?php
if ($_POST['action'] == "add_non_mesh_station") {
echo "<form action=\"adminpage.php\" method=\"POST\">\n";
echo "Input a new \"Non-MESH\" station:<br>";
echo "Name: <input type=\"text\" name=\"new_station_name\" value=\"\"> ";
echo "Description: <input type=\"text\" name=\"new_station_description\" value=\"\"> ";
echo "Type: <select name=\"new_station_type\">";
echo "<option value=\"operator\">Radio Operator</option>";
echo "<option value=\"firedepartment\">Fire Department</option>";
echo "<option value=\"police\">Police Station</option>";
echo "</select>";
echo "Lat: <input type=\"text\" name=\"new_station_lat\" value=\"\"> ";
echo "Lon: <input type=\"text\" name=\"new_station_lon\" value=\"\"> ";
echo "<input type=\"hidden\" name=\"action\" value=\"add_non_mesh_station\">";
echo "<input type=\"hidden\" name=\"sub_action\" value=\"new_station\">";
echo "<input type=\"hidden\" name=\"user\" value=\"" . $user . "\">";
echo "<input type=\"hidden\" name=\"password\" value=\"" . $userInputPasswd . "\">";
echo "<input type=\"submit\" value=\"Add\">";
echo "</form>";
if (($_POST['sub_action'] == "new_station") && (isset($_POST['new_station_name'])) && (isset($_POST['new_station_description'])) &&
(isset($_POST['new_station_type'])) && (isset($_POST['new_station_lat'])) && (isset($_POST['new_station_lon']))) {
$newStationName = $_POST['new_station_name'];
$newStationDescription = $_POST['new_station_description'];
$newStationType = $_POST['new_station_type'];
$newStationLat = $_POST['new_station_lat'];
$newStationLon = $_POST['new_station_lon'];
$addedToSql = wxc_putMySQL("INSERT INTO marker_info (name, description, type, lat, lon) VALUES ('$newStationName', '$newStationDescription', '$newStationType', '$newStationLat', '$newStationLon')");
if ($addedToSql = 1) {
echo "Sucessfully added " . $newStationName . " to the database.<br>";
unset($_POST['new_station_name']);
unset($_POST['new_station_description']);
unset($_POST['new_station_type']);
unset($_POST['new_station_lat']);
unset($_POST['new_station_lon']);
unset($_POST['sub_action']);
session_start();
if (!isset($_SESSION['userLoggedIn'])) {
echo "You are not logged in!<br>\n";
echo "This page should be run from within the admin interface!\n";
exit;
}else {
if ($_POST['action'] == "add_non_mesh_station") {
echo "<form action=\"adminpage.php\" method=\"POST\">\n";
echo "Input a new \"Non-MESH\" station:<br>";
echo "Name: <input type=\"text\" name=\"new_station_name\" value=\"\"> ";
echo "Description: <input type=\"text\" name=\"new_station_description\" value=\"\"> ";
echo "Type: <select name=\"new_station_type\">";
echo "<option value=\"operator\">Radio Operator</option>";
echo "<option value=\"firedepartment\">Fire Department</option>";
echo "<option value=\"police\">Police Station</option>";
echo "</select>";
echo "Lat: <input type=\"text\" name=\"new_station_lat\" value=\"\"> ";
echo "Lon: <input type=\"text\" name=\"new_station_lon\" value=\"\"> ";
echo "<input type=\"hidden\" name=\"action\" value=\"add_non_mesh_station\">";
echo "<input type=\"hidden\" name=\"sub_action\" value=\"new_station\">";
echo "<input type=\"hidden\" name=\"user\" value=\"" . $user . "\">";
echo "<input type=\"hidden\" name=\"password\" value=\"" . $userInputPasswd . "\">";
echo "<input type=\"submit\" value=\"Add\">";
echo "</form>";
if (($_POST['sub_action'] == "new_station") && (isset($_POST['new_station_name'])) && (isset($_POST['new_station_description'])) &&
(isset($_POST['new_station_type'])) && (isset($_POST['new_station_lat'])) && (isset($_POST['new_station_lon']))) {
$newStationName = $_POST['new_station_name'];
$newStationDescription = $_POST['new_station_description'];
$newStationType = $_POST['new_station_type'];
$newStationLat = $_POST['new_station_lat'];
$newStationLon = $_POST['new_station_lon'];
$addedToSql = wxc_putMySQL("INSERT INTO marker_info (name, description, type, lat, lon) VALUES ('$newStationName', '$newStationDescription', '$newStationType', '$newStationLat', '$newStationLon')");
if ($addedToSql = 1) {
echo "Sucessfully added " . $newStationName . " to the database.<br>";
unset($_POST['new_station_name']);
unset($_POST['new_station_description']);
unset($_POST['new_station_type']);
unset($_POST['new_station_lat']);
unset($_POST['new_station_lon']);
unset($_POST['sub_action']);
}
}
}
$nonMeshStationsAndMarkers = mysqli_query($GLOBALS['sql_connection'], "SELECT name, description, type, lat, lon FROM marker_info") or die ("Could not get list of non mesh stations" . mysqli_error($GLOBALS['sql_connection']));
if ($nonMeshStationsAndMarkers) {
$nonMeshStationsAndMarkers = mysqli_fetch_all($nonMeshStationsAndMarkers, MYSQLI_ASSOC);
echo "This is what is in the database:<br>\n";
echo "<table>";
echo "<tr><th><b>Name</b></th><th><b>Description</b></th><th><b>Type</b></th><th><b>Lat</b></th><th><b>Lon</b></th></tr>";
foreach ($nonMeshStationsAndMarkers as $value) {
echo "<tr><td>" . $value['name'] . "</td>" .
"<td>" . $value['description'] . "</td>" .
"<td>" . $value['type'] . "</td>" .
"<td>" . $value['lat'] . "</td>" .
"<td>" . $value['lon'] . "</td></tr>";
$nonMeshStationsAndMarkers = mysqli_query($GLOBALS['sql_connection'], "SELECT name, description, type, lat, lon FROM marker_info") or die ("Could not get list of non mesh stations" . mysqli_error($GLOBALS['sql_connection']));
if ($nonMeshStationsAndMarkers) {
$nonMeshStationsAndMarkers = mysqli_fetch_all($nonMeshStationsAndMarkers, MYSQLI_ASSOC);
echo "This is what is in the database:<br>\n";
echo "<table>";
echo "<tr><th><b>Name</b></th><th><b>Description</b></th><th><b>Type</b></th><th><b>Lat</b></th><th><b>Lon</b></th></tr>";
foreach ($nonMeshStationsAndMarkers as $value) {
echo "<tr><td>" . $value['name'] . "</td>" .
"<td>" . $value['description'] . "</td>" .
"<td>" . $value['type'] . "</td>" .
"<td>" . $value['lat'] . "</td>" .
"<td>" . $value['lon'] . "</td></tr>";
}
echo "</table>";
}
echo "</table>";
}
}
}
?>
......@@ -64,7 +64,7 @@ a.normalTextLink {
}
#admin_header {
position: relative;
height: 4.9em;
height: 6.5em;
width: 100%;
/*testing*/
/*background-color: aqua;*/
......@@ -160,7 +160,7 @@ a.normalTextLink {
}
#admin_status {
position: absolute;
float: left;
float: right;
right: 0;
top: 0;
font-size: .75em;
......
This diff is collapsed.
<?php
session_start();
if (!isset($_SESSION['userLoggedIn'])) {
echo "You are not logged in!<br>\n";
echo "This page should be run from within the admin interface!\n";
exit;
}else {
$INCLUDE_DIR = "../..";
$USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini");
require $INCLUDE_DIR . "/scripts/wxc_functions.inc";
@include $INCLUDE_DIR . "/custom.inc";
//downloaded file name
$file_name = "meshmap_db_export-" . date('Y_m_d') . ".csv";
// export csv
function exportMysqlToCsv($filename = "meshmap-export.csv") {
// $conn = dbConnection();
$conn = wxc_connectToMySQL();
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql_query = "SELECT * FROM node_info";
// Gets the data from the database
$result = $conn->query($sql_query);
$f = fopen('php://memory', 'wt');
$first = true;
while ($row = $result->fetch_assoc()) {
if ($first) {
fputcsv($f, array_keys($row));
$first = false;
}
fputcsv($f, $row);
} // end while
$conn->close();
$size = ftell($f);
rewind($f);
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Length: $size");
// Output to browser with appropriate mime type, you choose ;)
header("Content-type: text/x-csv");
header("Content-type: text/csv");
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=$filename");
fpassthru($f);
exit;
}
// call export function
exportMysqlToCsv($file_name);
}
?>
<?php
$INCLUDE_DIR = "../..";
$USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini");
require $INCLUDE_DIR . "/scripts/wxc_functions.inc";
@include $INCLUDE_DIR . "/custom.inc";
$sql_connection = wxc_connectToMySQL();
$query = "update map_info set script_last_run = '2018-01-01 00:00:00' where id = 'NODEINFO'";
wxc_putMySql($query);
mysqli_close($sql_connection);
?>
<?php
session_start();
if (!isset($_SESSION['userLoggedIn'])) {
echo "You are not logged in!<br>\n";
echo "This page should be run from within the admin interface!\n";
exit;
}else {
$html = <<< EOD
<br>
<strong>Other Admin Tasks</strong>
<br>
<br>
<a href="export2csv.php">Download CSV file of the node database.</a>
<br>
<br>
<script>
var arname=''";
function other_loadThePage(div_id, script) {
if (script == "fixPolling" ) {
$.ajax({
type: "POST",
url: "fixStuckPolling.php",
data: "arname="+arname,
success: function(msg){
alert('Success!!\nPolling should now resume.');
// $("#"+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", "");
// $('#nav_link_other').css("background-color", "");
}
});