Commit 29ec34c3 authored by Eric - kg6wxc's avatar Eric - kg6wxc
Browse files

added node_map.sql file for importing into mysql/mariaDB

parent 2fac9a6c
Alias /meshmap/ "/srv/meshmap/webpage/"
#
# This line creates the alias so that /meshmap can be put anywhere really
#
Alias /meshmap "/srv/meshmap/webpage/"
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
Require all denied
</Files>
#
# These lines deny access to the .ini or .inc files
# by web clients
#
<Files ~ "\.(inc|ini)$">
Require all denied
</Files>
#
# These lines should block access to the scripts directory
# by web clients
#
<Directory "/srv/meshmap/scripts/">
Require all denied
</Directory>
#
# These lines allow access to the webpage directory
#
<Directory "/srv/meshmap/webpage/">
AllowOverride None
Require all granted
</Directory>
</Directory>
\ No newline at end of file
-- --------------------------------------------------------
-- Host: camphost
-- Server version: 10.0.30-MariaDB - MariaDB Server
-- Server OS: Linux
-- HeidiSQL Version: 9.5.0.5264
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-- Dumping database structure for node_map
CREATE DATABASE IF NOT EXISTS `node_map` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;
USE `node_map`;
-- Dumping structure for table node_map.hosts_ignore
CREATE TABLE IF NOT EXISTS `hosts_ignore` (
`ip` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The name of the host, no domain',
`reason` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`timestamp` datetime DEFAULT NULL,
UNIQUE KEY `name_2` (`name`),
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_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,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Keeping track of some things about the map';
-- Data exporting was unselected.
-- Dumping structure for table node_map.marker_info
CREATE TABLE IF NOT EXISTS `marker_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`type` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`lat` double NOT NULL,
`lon` double NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- 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,
`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,
`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,
`firmware_mfg` 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',
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,
`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,
`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,
`firmware_mfg` 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,
`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';
-- Data exporting was unselected.
-- Dumping structure for table node_map.topology
CREATE TABLE IF NOT EXISTS `topology` (
`node` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`nodelat` double DEFAULT NULL,
`nodelon` double DEFAULT NULL,
`linkto` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`linklat` double DEFAULT NULL,
`linklon` double DEFAULT NULL,
`cost` double DEFAULT NULL,
`distance` double DEFAULT NULL,
`bearing` double DEFAULT NULL,
`lastupd` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- Data exporting was unselected.
-- 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',
`user` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`passwd` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_login` datetime DEFAULT NULL,
KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='a place to put users for the admin page(s)';
-- Data exporting was unselected.
-- Dumping structure for trigger node_map.node_info_after_insert
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
DELIMITER //
CREATE TRIGGER `node_info_after_insert` AFTER INSERT ON `node_info` FOR EACH ROW BEGIN
INSERT INTO map_info (id, table_or_script_name, table_records_num, table_last_update)
VALUES ('NODEINFO', 'node_info', (SELECT COUNT(*) FROM node_info), NOW())
ON DUPLICATE KEY UPDATE id = 'NODEINFO', table_or_script_name = 'node_info', table_records_num = (SELECT COUNT(*) FROM node_info), table_last_update = NOW();
END//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;
-- Dumping structure for trigger node_map.node_info_after_update
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='';
DELIMITER //
CREATE TRIGGER `node_info_after_update` AFTER UPDATE ON `node_info` FOR EACH ROW BEGIN
INSERT INTO map_info (id, table_or_script_name, table_records_num, table_last_update)
VALUES ('NODEINFO', 'node_info', (SELECT COUNT(*) FROM node_info), NOW())
ON DUPLICATE KEY UPDATE id = 'NODEINFO', table_or_script_name = 'node_info', table_records_num = (SELECT COUNT(*) FROM node_info), table_last_update = NOW();
END//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;
-- Dumping structure for trigger node_map.topology_after_insert
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='';
DELIMITER //
CREATE TRIGGER `topology_after_insert` AFTER INSERT ON `topology` FOR EACH ROW BEGIN
-- thanks go to K6GSE for making this trigger much cleaner and easier to read
IF (SELECT count(*) FROM map_info WHERE id='LINKINFO') =0 THEN
INSERT INTO map_info (id, table_or_script_name, table_records_num, table_last_update)
VALUES ('LINKINFO', 'topology', (SELECT COUNT(*) FROM topology), NOW());
-- ON DUPLICATE KEY UPDATE id = 'LINKINFO', table_or_script_name = 'topology', table_records_num = (SELECT COUNT(*) FROM topology), table_last_update = NOW();
ELSE
UPDATE map_info SET table_records_num = (SELECT count(*) FROM topology), table_last_update = NOW() WHERE id= 'LINKINFO';
END IF;
-- prune the hosts_ignore table
-- clear 404 errors after 26 hours
-- hopefully the user will update
-- also remove no_route errors after 90 min
-- PHP controlled now
-- DELETE FROM hosts_ignore WHERE HOUR(TIMEDIFF(NOW(), hosts_ignore.timestamp)) > 26 AND hosts_ignore.reason = '404';
-- DELETE FROM hosts_ignore WHERE TIMESTAMPDIFF(MINUTE, hosts_ignore.timestamp, NOW()) > 90 AND hosts_ignore.reason = 'no_route';
-- DELETE FROM hosts_ignore WHERE TIMESTAMPDIFF(MINUTE, hosts_ignore.timestamp, NOW()) > 30 AND hosts_ignore.reason = 'refused';
END//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;
-- Dumping structure for trigger node_map.topology_get_latlons_brg_dist
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='';
DELIMITER //
CREATE TRIGGER `topology_get_latlons_brg_dist` BEFORE INSERT ON `topology` FOR EACH ROW BEGIN
-- get locations and names for each end of the link
IF NEW.node IS NOT NULL THEN
SET NEW.nodelat = (SELECT lat FROM node_info WHERE wlan_ip = NEW.node AND (lat IS NOT NULL && lat != 0 && lat != 0.00));
SET NEW.nodelon = (SELECT lon FROM node_info WHERE wlan_ip = NEW.node AND (lon IS NOT NULL && lon != 0 && lon != 0.00));
SET NEW.node = (SELECT node FROM node_info WHERE wlan_ip = NEW.node);
END IF;
IF NEW.linkto IS NOT NULL THEN
SET NEW.linklat = (SELECT lat FROM node_info WHERE wlan_ip = NEW.linkto AND (lat IS NOT NULL && lat != 0 && lat != 0.00));
SET NEW.linklon = (SELECT lon FROM node_info WHERE wlan_ip = NEW.linkto AND (lon IS NOT NULL && lon != 0 && lon != 0.00));
SET NEW.linkto = (SELECT node FROM node_info WHERE wlan_ip = NEW.linkto);
END IF;
-- figure out distance and bearing
SET NEW.bearing = round(mod(degrees(atan2(sin(radians(NEW.linklon)-radians(NEW.nodelon))*cos(radians(NEW.linklat)), cos(radians(NEW.nodelat))*sin(radians(NEW.linklat))-sin(radians(NEW.nodelat))*cos(radians(NEW.linklat))*cos(radians(NEW.linklon)-radians(NEW.nodelon)))) + 360,360),1);
SET NEW.distance = round(2*asin(sqrt(pow(sin((radians(NEW.linklat)-radians(NEW.nodelat))/2),2)+cos(radians(NEW.nodelat))*cos(radians(NEW. linklat))*pow(sin((radians(NEW.linklon)-radians(NEW.nodelon))/2),2)))*3959,2);
END//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
#!/usr/bin/env php
<?php $mtimeStart = microtime(true);
//
/*************************************************************************************
* get-map-info script v2 by kg6wxc\eric satterlee kg6wxc@gmail.com
* This script is the heart of kg6wxcs' mesh map system.
......@@ -33,7 +34,7 @@
* OTHER NOTES HERE
******/
$INCLUDE_DIR = "/home/kg6wxc/MeshMap";
$INCLUDE_DIR = "/srv/meshmap";
//our user-settings file. (ALWAYS REQUIRED!, change path if you moved it!)
$USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini");
......@@ -44,7 +45,7 @@ require $INCLUDE_DIR . "/scripts/wxc_functions.inc";
//output only to console, nothing saved. (great to just see what it does)
$TEST_MODE_NO_SQL = 0;
//output to console, but *with* calls to the database. (see what it's doing while saving data)
$TEST_MODE_WITH_SQL = 0;
$TEST_MODE_WITH_SQL = 1;
//are we in either test mode?
if ($TEST_MODE_NO_SQL) {
......
......@@ -315,8 +315,13 @@ function load_LinkList($NodeList, $TopoList)
function load_LinkedTO($node_info, $TopoList)
{
$linkedToList = "";
$linkInfoForStationPopups = array($node_info['node'] => "");
$linkInfoForStationPopups = array($node_info['node'] => array());
//don't init what is going to be an array as a string!!
//$linkInfoForStationPopups = array($node_info['node'] => "");
$node = $node_info['node'];
//and build a big 3D array of it all
//like this:
//array
......@@ -330,6 +335,7 @@ function load_LinkedTO($node_info, $TopoList)
// "CostFrom"
// "CostTo"
//etc..etc..
if (isset($TopoList))
{
foreach ($TopoList as $value)
......@@ -337,14 +343,25 @@ function load_LinkedTO($node_info, $TopoList)
//if there's no location info (at each end of the link) ignore the entry
if ($value['nodelat'] && $value['linklon'])
{
//this is the section that is exploding in php7.2.3
if ($value['linkto'] == $node)
{
{
//this will be the cost FROM each linked station back TO the node we are currently looking at in the while loop
$linkInfoForStationPopups[$node_info['node']][$value['node']]["costFrom"] = $value['cost'];
//original line (leave for now)
//$linkInfoForStationPopups[$node_info['node']][$value['node']]["costFrom"] = $value['cost'];
//the new line
//had to create the array correctly! fixed 3-28-2018 - wxc
$linkInfoForStationPopups[$node_info['node']][$value['node']] = array('costFrom' => $value['cost'], 'costTo' => "", 'distance' => "", 'bearing' => "");
}
if ($value['node'] == $node)
{
//$linkedNodesKeyNameArray = array("costTo", "distance", "bearing");
//this will be the cost TO each linked station FROM the node we are currently looking at in the while loop
//distance and bearing added too for goo measure! :)
//$linkInfoForStationPopups[$node_info['node']][$value['linkto']] = array_fill_keys($linkedNodesKeyNameArray, "");
$linkInfoForStationPopups[$node_info['node']][$value['linkto']]["costTo"] = $value['cost'];
//add in the distance to that linked node
$linkInfoForStationPopups[$node_info['node']][$value['linkto']]["distance"] = $value['distance'];
......
......@@ -21,6 +21,14 @@
**************************************************************************/
/* Current version notes
*
* March 2018
* wow, it's been that long huh?
* now using git repo at https://mapping.kg6wxc.net/git/meshmap
* fixed issues with running the webpage on PHP 7.2.3, it should be good now.
* tested on PHP 5.6.30 7.0.27-0+deb9u1 and 7.2.3
* had to create an array properly and not let PHP fix my mistakes for me. :)
* more to come!
*
* June 2017
* -----------------
......@@ -178,7 +186,7 @@ echo "<script src='javascripts/leaflet-hash.js'></script>\n";
//we're just going to tell if we were called from a host that has ".local.mesh" in it and forget all this nonsense...
global $mesh;
$httpHostName = $_SERVER['HTTP_HOST'];
if (strpos($httpHostName, '.local.mesh') || strpos($httpHostName, '')) {
if (strpos($httpHostName, '.local.mesh')) { //|| strpos($httpHostName, '')) {
$mesh = 1;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment