2010-06-20 17:21:35 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
									
										
										
										
											2018-04-07 15:55:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-30 16:58:38 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								use  App\Models\Device ;  
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								use  App\Models\Location ;  
						 
					
						
							
								
									
										
										
										
											2018-04-07 15:55:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$device_model  =  Device :: find ( $device [ 'device_id' ]);  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $_POST [ 'editing' ])  {  
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( Auth :: user () -> hasGlobalAdmin ())  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-20 17:17:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( isset ( $_POST [ 'parent_id' ]))  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-30 16:58:38 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $parents  =  array_diff (( array ) $_POST [ 'parent_id' ],  [ '0' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // TODO avoid loops!
 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $device_model -> parents () -> sync ( $parents ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-20 17:17:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $override_sysLocation  =  ( int ) isset ( $_POST [ 'override_sysLocation' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $override_sysLocation_string  =  isset ( $_POST [ 'sysLocation' ])  ?  $_POST [ 'sysLocation' ]  :  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-31 17:19:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( $override_sysLocation )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $override_sysLocation_string )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $location  =  Location :: firstOrCreate ([ 'location'  =>  $override_sysLocation_string ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $device_model -> location () -> associate ( $location ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $device_model -> location () -> dissociate (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  elseif  ( $device_model -> override_sysLocation )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // no longer overridden, clear location
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $device_model -> location () -> dissociate (); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-20 16:52:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $device_model -> override_sysLocation  =  $override_sysLocation ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $device_model -> purpose  =  $_POST [ 'descr' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-27 13:19:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $device_model -> poller_group  =  $_POST [ 'poller_group' ]; 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $device_model -> ignore  =  ( int ) isset ( $_POST [ 'ignore' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $device_model -> disabled  =  ( int ) isset ( $_POST [ 'disabled' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-10 01:46:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $device_model -> disable_notify  =  ( int ) isset ( $_POST [ 'disable_notify' ]); 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $device_model -> type  =  $_POST [ 'type' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-30 13:20:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $device_model -> overwrite_ip  =  $_POST [ 'overwrite_ip' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-31 17:19:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( $device_model -> isDirty ( 'type' ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            set_dev_attrib ( $device ,  'override_device_type' ,  true ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-22 09:49:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( $device_model -> isDirty ())  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $device_model -> save ())  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                Toastr :: success ( __ ( 'Device record updated' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                Toastr :: error ( __ ( 'Device record update error' )); 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-22 09:49:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-12-08 04:16:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( isset ( $_POST [ 'hostname' ])  &&  $_POST [ 'hostname' ]  !==  ''  &&  $_POST [ 'hostname' ]  !==  $device [ 'hostname' ])  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 14:16:05 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( Auth :: user () -> hasGlobalAdmin ())  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-12 17:19:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $result  =  renamehost ( $device [ 'device_id' ],  $_POST [ 'hostname' ],  'webui' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( $result  ==  " " )  { 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    Toastr :: success ( " Hostname updated from  { $device [ 'hostname' ] }  to  { $_POST [ 'hostname' ] } " ); 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-12 17:19:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    echo  ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        < script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            var  loc  =  window . location ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            window . location . replace ( loc . protocol  +  " // "  +  loc . host  +  loc . pathname  +  loc . search ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        </ script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    Toastr :: error ( $result  .  " .  Does your web server have permission to modify the rrd files? " ); 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-12 17:19:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                Toastr :: error ( 'Only administrative users may update the device hostname' ); 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-12 17:19:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-09 13:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $override_sysContact_bool  =  mres ( $_POST [ 'override_sysContact' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( isset ( $_POST [ 'sysContact' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $override_sysContact_string  =  mres ( $_POST [ 'sysContact' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $override_sysContact_bool )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            set_dev_attrib ( $device ,  'override_sysContact_bool' ,  '1' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            set_dev_attrib ( $device ,  'override_sysContact_bool' ,  '0' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( isset ( $override_sysContact_string ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            set_dev_attrib ( $device ,  'override_sysContact_string' ,  $override_sysContact_string ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-18 20:28:22 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-11 23:26:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        include  'includes/html/error-no-perm.inc.php' ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-18 15:30:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-20 17:21:35 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-09 13:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$override_sysContact_bool    =  get_dev_attrib ( $device ,  'override_sysContact_bool' );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$override_sysContact_string  =  get_dev_attrib ( $device ,  'override_sysContact_string' );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$disable_notify              =  get_dev_attrib ( $device ,  'disable_notify' );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-03-31 17:19:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								?> 
  
						 
					
						
							
								
									
										
										
										
											2020-01-09 13:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-10 19:01:59 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< h3 >  Device  Settings  </ h3 >  
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< div  class = " row " >  
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " col-md-1 col-md-offset-2 " > 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < form  id = " delete_host "  name = " delete_host "  method = " post "  action = " delhost/ "  role = " form " > 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-17 07:20:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            < ? php  echo  csrf_field ()  ?> 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            < input  type = " hidden "  name = " id "  value = " <?php echo( $device['device_id'] ); ?> " > 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-15 01:41:39 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            < button  type = " submit "  class = " btn btn-danger "  name = " Submit " >< i  class = " fa fa-trash " ></ i >  Delete  device </ button > 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        </ form > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " col-md-1 col-md-offset-2 " > 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-15 01:41:39 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < ? php 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-23 00:29:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( \LibreNMS\Config :: get ( 'enable_clear_discovery' )  ==  1  &&  ! $device [ 'snmp_disable' ])  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-15 01:41:39 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < button  type = " submit "  id = " rediscover "  data - device_id = " <?php echo( $device['device_id'] ); ?> "  class = " btn btn-primary "  name = " rediscover " >< i  class = " fa fa-retweet " ></ i >  Rediscover  device </ button > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ?> 
 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</ div >  
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< br >  
						 
					
						
							
								
									
										
										
										
											2014-06-16 23:06:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< form  id = " edit "  name = " edit "  method = " post "  action = " "  role = " form "  class = " form-horizontal " >  
						 
					
						
							
								
									
										
										
										
											2019-07-17 07:20:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< ? php  echo  csrf_field ()  ?> 
  
						 
					
						
							
								
									
										
										
										
											2014-06-16 23:06:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< input  type = hidden  name = " editing "  value = " yes " >  
						 
					
						
							
								
									
										
										
										
											2016-11-12 17:19:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " form-group "  data - toggle = " tooltip "  data - container = " body "  data - placement = " bottom "  title = " Change the hostname used for name resolution "  > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < label  for = " edit-hostname-input "  class = " col-sm-2 control-label "  > Hostname :</ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < input  type = " text "  id = " edit-hostname-input "  name = " hostname "  class = " form-control "  disabled  value =< ? php  echo ( display ( $device [ 'hostname' ]));  ?>  />
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-sm-2 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < button  name = " hostname-edit-button "  id = " hostname-edit-button "  class = " btn btn-danger " >  < i  class = " fa fa-pencil " ></ i >  </ button > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-30 13:20:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < div  class = " form-group "  data - toggle = " tooltip "  data - container = " body "  data - placement = " bottom "  title = " Use this IP instead of resolved one for polling "  > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < label  for = " edit-overwrite_ip-input "  class = " col-sm-2 control-label "  > Overwrite  IP :</ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < input  type = " text "  id = " edit-overwrite_up-input "  name = " overwrite_ip "  class = " form-control "  value =< ? php  echo ( $device_model -> overwrite_ip );  ?> >
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-12 17:19:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     < div  class = " form-group " > 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < label  for = " descr "  class = " col-sm-2 control-label " > Description :</ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            < textarea  id = " descr "  name = " descr "  class = " form-control " >< ? php  echo ( display ( $device_model -> purpose ));  ?> </textarea>
 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-16 23:06:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " form-group " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < label  for = " type "  class = " col-sm-2 control-label " > Type :</ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < select  id = " type "  name = " type "  class = " form-control " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $unknown  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-23 00:29:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                foreach  ( \LibreNMS\Config :: get ( 'device_types' )  as  $type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    echo ( '          <option value="' . $type [ 'type' ] . '"' ); 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( $device_model -> type  ==  $type [ 'type' ])  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        echo ( ' selected="1"' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        $unknown  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    echo ( ' >'  .  ucfirst ( $type [ 'type' ])  .  '</option>' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( $unknown )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    echo ( '          <option value="other">Other</option>' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            </ select > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " form-group " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < label  for = " sysLocation "  class = " col-sm-2 control-label " > Override  sysLocation :</ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-05 00:02:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          < input  onChange = " edit.sysLocation.disabled=!edit.override_sysLocation.checked; edit.sysLocation.select() "  type = " checkbox "  name = " override_sysLocation "  data - size = " small " 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( $device_model -> override_sysLocation )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    echo ( ' checked="1"' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ?>  />
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-16 23:06:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " form-group "  title = " To set coordinates, include [latitude,longitude] " > 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < div  class = " col-sm-2 " ></ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          < input  id = " sysLocation "  name = " sysLocation "  class = " form-control " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( ! $device_model -> override_sysLocation )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    echo ( ' disabled="1"' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-19 22:52:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ?>  value="<?php echo display($device_model->location); ?>" />
 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-16 23:06:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-09 13:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " form-group " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < label  for = " override_sysContact "  class = " col-sm-2 control-label " > Override  sysContact </ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < input  onChange = " edit.sysContact.disabled=!edit.override_sysContact.checked "  type = " checkbox "  id = " override_sysContact "  name = " override_sysContact "  data - size = " small " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( $override_sysContact_bool )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        echo  ' checked="1"' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								   /> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < div  class = " form-group " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < div  class = " col-sm-2 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < input  id = " sysContact "  class = " form-control "  name = " sysContact "  size = " 32 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! $override_sysContact_bool )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        echo  ' disabled="1"' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    value = " <?php echo  $override_sysContact_string ; ?> "  /> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " form-group " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < label  for = " parent_id "  class = " col-sm-2 control-label " > This  device  depends  on :</ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < select  multiple  name = " parent_id[] "  id = " parent_id "  class = " form-control " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $dev_parents  =  dbFetchColumn ( 'SELECT device_id from devices WHERE device_id IN (SELECT dr.parent_device_id from devices as d, device_relationships as dr WHERE d.device_id = dr.child_device_id AND d.device_id = ?)' ,  array ( $device [ 'device_id' ])); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ! $dev_parents )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-20 17:17:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    $selected  =  'selected="selected"' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $selected  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < option  value = " 0 "  < ? = $selected ?> >None</option>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-10 16:18:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $available_devs  =  dbFetchRows ( 'SELECT `device_id`,`hostname`,`sysName` FROM `devices` WHERE `device_id` <> ? ORDER BY `hostname` ASC' ,  array ( $device [ 'device_id' ])); 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                foreach  ( $available_devs  as  $dev )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( in_array ( $dev [ 'device_id' ],  $dev_parents ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        $selected  =  'selected="selected"' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        $selected  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-10 16:18:53 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    echo  " <option value= " .  $dev [ 'device_id' ] .  "   "  .  $selected  .  " > "  .  $dev [ 'hostname' ]  .  "  ( "  .  $dev [ 'sysName' ]  . " )</option> " ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ?> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            </ select > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-20 17:17:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-27 13:19:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  ( \LibreNMS\Config :: get ( 'distributed_poller' )  ===  true )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								?> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								   < div  class = " form-group " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       < label  for = " poller_group "  class = " col-sm-2 control-label " > Poller  Group </ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           < select  name = " poller_group "  id = " poller_group "  class = " form-control input-sm " > 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-18 13:26:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								           < option  value = " 0 " > General < ? = \LibreNMS\Config :: get ( 'distributed_poller_group' )  ==  0  ?  ' (default Poller)' :  '' ?> </option>
 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-27 13:19:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								foreach  ( dbFetchRows ( 'SELECT `id`,`group_name` FROM `poller_groups` ORDER BY `group_name`' )  as  $group )  {  
						 
					
						
							
								
									
										
										
										
											2020-02-18 13:26:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    echo  ( '<option value="' . $group [ 'id' ] . '"' . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( $device_model -> poller_group  ==  $group [ 'id' ]  ?  "  selected " :  " " ) . '>' . $group [ 'group_name' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    echo  ( \LibreNMS\Config :: get ( 'distributed_poller_group' )  ==  $group [ 'id' ]  ?  ' (default Poller)' :  '' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    echo  ( '</option>' ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-27 13:19:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								?> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								           </ select > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								   </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} //endif
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								?> 
  
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " form-group " > 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-09 13:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < label  for = " disabled "  class = " col-sm-2 control-label " > Disable  polling  and  alerting :</ label > 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-05 00:02:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          < input  name = " disabled "  type = " checkbox "  id = " disabled "  value = " 1 "  data - size = " small " 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( $device_model -> disabled )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    echo ( " checked=checked " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ?>  />
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-16 23:06:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " form-group " > 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-09 13:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      < label  for = " disable_notify "  class = " col-sm-2 control-label " > Disable  alerting :</ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < input  id = " disable_notify "  type = " checkbox "  name = " disable_notify "  data - size = " small " 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-10 01:46:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( $device_model -> disable_notify )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    echo ( " checked=checked " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ?>  />
 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-09 13:07:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < div  class = " form-group " > 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-09 23:55:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < label  for = " ignore "  class = " col-sm-2 control-label "  title = " Tag device to ignore alerts. Alert checks will still run.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								However ,  ignore  tag  can  be  read  in  alert  rules .  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								If  `devices.ignore = 0`  or  `macros.device = 1`  condition  is  is  set  and  ignore  alert  tag  is  on ,  the  alert  rule  won ' t  match . " >Ignore alert tag:</label>
  
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < div  class = " col-sm-6 " > 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-05 00:02:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								           < input  name = " ignore "  type = " checkbox "  id = " ignore "  value = " 1 "  data - size = " small " 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                < ? php 
							 
						 
					
						
							
								
									
										
											 
										
											
												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 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( $device_model -> ignore )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    echo ( " checked=checked " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ?>  />
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 15:59:57 +05:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-07 06:35:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = " row " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " col-md-1 col-md-offset-2 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < button  type = " submit "  name = " Submit "   class = " btn btn-default " >< i  class = " fa fa-check " ></ i >  Save </ button > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2014-06-16 23:06:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</ form >  
						 
					
						
							
								
									
										
										
										
											2011-09-23 10:16:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< br  />  
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< script >  
						 
					
						
							
								
									
										
										
										
											2019-11-05 00:02:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( '[type="checkbox"]' ) . bootstrapSwitch (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( " #rediscover " ) . click ( function ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        var  device_id  =  $ ( this ) . data ( " device_id " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $ . ajax ({ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            type :  'POST' , 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-11 14:54:05 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            url :  'ajax_form.php' , 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            data :  {  type :  " rediscover-device " ,  device_id :  device_id  }, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            dataType :  " json " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            success :  function ( data ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if ( data [ 'status' ]  ==  'ok' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    toastr . success ( data [ 'message' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    toastr . error ( data [ 'message' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            error : function (){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                toastr . error ( 'An error occured setting this device to be rediscovered' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }); 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-12 17:19:22 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( '#hostname-edit-button' ) . click ( function ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        e . preventDefault (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        disabled_state  =  document . getElementById ( 'edit-hostname-input' ) . disabled ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( disabled_state  ==  true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            document . getElementById ( 'edit-hostname-input' ) . disabled  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            document . getElementById ( 'edit-hostname-input' ) . disabled  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }); 
							 
						 
					
						
							
								
									
										
										
										
											2018-12-05 07:33:32 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( '#sysLocation' ) . keypress ( function  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if ( e . keyCode  ===  13 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            e . preventDefault (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $ ( '#edit' ) . submit (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }); 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-20 17:17:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( '#parent_id' ) . select2 ({ 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-17 13:11:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        width :  'resolve' 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-20 17:17:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }); 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-02 20:17:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								</ script >  
						 
					
						
							
								
									
										
										
										
											2011-09-23 10:16:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								print_optionbar_start ();  
						 
					
						
							
								
									
										
										
										
											2017-09-02 20:45:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								list ( $sizeondisk ,  $numrrds )  =  foldersize ( get_rrd_dir ( $device [ 'hostname' ]));  
						 
					
						
							
								
									
										
										
										
											2011-09-23 10:16:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								echo ( " Size on Disk: <b> "  .  formatStorage ( $sizeondisk )  .  " </b> in <b> "  .  $numrrds  .  "  RRD files</b>. " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								print_optionbar_end ();  
						 
					
						
							
								
									
										
										
										
											2019-12-02 13:15:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								echo ( " <small> " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								echo ( " Last polled: <b> "  .  $device [ 'last_polled' ]  .  " </b> " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  ( $device [ 'last_discovered' ])  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    echo ( " <br>Last discovered: <b> "  .  $device [ 'last_discovered' ]  .  " </b> " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								echo ( " </small> " );  
						 
					
						
							
								
									
										
										
										
											2011-09-23 10:16:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								?>