2018-03-19 04:47:06 +01:00
< ? php
/* Copyright (C) 2014 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2019-12-30 12:11:26 +01:00
*
2018-03-19 04:47:06 +01:00
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
2019-12-30 12:11:26 +01:00
*
2018-03-19 04:47:06 +01:00
* You should have received a copy of the GNU General Public License
2021-02-09 00:29:04 +01:00
* along with this program. If not, see <https://www.gnu.org/licenses/>. */
2018-03-19 04:47:06 +01:00
/**
* Custom Frontpage
* @author f0o <f0o@devilcode.org>
* @copyright 2014 f0o, LibreNMS
* @license GPL
*/
/**
* Fullscreen variant
* I have mostly axed a lot of stuff and added a tiny bit of CSS
* To make use of this, your config.php needs to contain
* something like this:
2020-09-21 15:40:17 +02:00
* $config['front_page'] = "includes/html/pages/front/fullscreenmap.php";
* $config['map']['engine'] = 'leaflet';
* $config['leaflet']['default_zoom'] = 5;
* $config['leaflet']['default_lat'] = 65.3258792;
* $config['leaflet']['default_lng'] = 14.1115485;
* Dag B <dag@bakke.com>
2018-03-19 04:47:06 +01:00
*/
$pagetitle [] = 'Geographical Map' ;
2019-06-23 00:29:12 -05:00
if ( \LibreNMS\Config :: get ( 'map.engine' ) == 'leaflet' ) {
2019-04-11 23:26:42 -05:00
require_once 'includes/html/common/worldmap.inc.php' ;
2018-03-19 04:47:06 +01:00
echo implode ( '' , $common_output );
}
/* Yes, this code requires the leaflet map engine */
?>
<link href="css/fullscreenmap.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var isFullscreen = false;
window.addEventListener('resize', function () {
if (window.innerHeight > (screen.height - 10)) {
isFullscreen = true;
setStyle();
} else {
isFullscreen = false;
setStyle();
};
}, false);
2019-12-30 12:11:26 +01:00
2018-03-19 04:47:06 +01:00
function setStyle() {
if(isFullscreen) {
document.getElementsByClassName('navbar-fixed-top')[0].style.display = "none";
document.getElementsByTagName('body')[0].style.paddingTop = 0;
} else {
document.getElementsByClassName('navbar-fixed-top')[0].style.removeProperty("display");
document.getElementsByTagName('body')[0].style.paddingTop = "50px";
};
2019-12-30 12:11:26 +01:00
};
2018-03-19 04:47:06 +01:00
window.dispatchEvent(new Event('resize'));
</script>
<script src='js/jquery.mousewheel.min.js'></script>
<?php
2020-09-21 15:40:17 +02:00
$x = 0;
Refactored and update Location Geocoding (#9359)
- Fix location so it is a regular database relation (this allows multiple devices to be accurately linked to one location and saves api calls)
- Parse coordinates from the location more consistently
- Add settings to webui
- ~~Used [PHP Geocoder](http://geocoder-php.org/), which has lots of backends and is well tested. (also includes reverse and geoip)~~
- Google Maps, Bing, Mapquest, and OpenStreetMap supported initially.
- Default to OpenStreetMap, which doesn't require a key. They will liberally hand out bans if you exceed 1 query per second though.
- All other Geocoding APIs require an API key. (Google requires a credit card on file, but seems to be the most accurate)
- Update all (I think) sql queries to handle the new structure
- Remove final vestiges of override_sysLocation as a device attribute
- Update existing device groups and rules in DB
- Tested all APIs with good/bad location, no/bad/good key, and no connection.
- Cannot fix advanced queries that use location
This blocks #8868
DO NOT DELETE THIS TEXT
#### Please note
> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.
- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)
#### Testers
If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`. If there are schema changes, you can ask on discord how to revert.
2018-11-28 16:49:18 -06:00
foreach (dbFetchRows("SELECT `hostname`,`location`,`status`, COUNT(`status`) AS `total`,`lat`,`lng` FROM `devices` LEFT JOIN `locations` ON `devices`.`location_id`=`locations`.`id` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' GROUP BY `status`,`lat`,`lng` ORDER BY `status` ASC, `hostname`") as $map_devices) {
2020-09-21 15:59:34 +02:00
$color = '#29FF3B';
2018-03-19 04:47:06 +01:00
$size = 15;
$status = 'Up';
if ($map_devices['status'] == 0) {
2020-09-21 15:59:34 +02:00
$color = '#FF0000';
2018-03-19 04:47:06 +01:00
$size = 30;
$status = 'Down';
}
$data .= "\"$x\": {
2020-09-21 15:59:34 +02:00
value: \"" . $map_devices['total'] . '",
latitude: ' . $map_devices['lat'] . ',
longitude: ' . $map_devices['lng'] . ',
size: ' . $size . ',
2018-03-19 04:47:06 +01:00
attrs: {
2020-09-21 15:59:34 +02:00
fill: "' . $color . '",
2018-03-19 04:47:06 +01:00
opacity: 0.8
},
tooltip: {
2020-09-21 15:59:34 +02:00
content: "Devices ' . $status . ': ' . $map_devices['total'] . "\"
2018-03-19 04:47:06 +01:00
}
},\n";
$x++;
}
?>