Private GIT

Skip to content
Snippets Groups Projects
Unverified Commit d7d1e156 authored by Gary Allan's avatar Gary Allan
Browse files

Feature: Add config.php offline_mode. Fixes #3462

Add option to disable server-side Internet lookups. Timeouts on
servers with restricted Internet results in long page load times.
parent ec7160e1
No related branches found
No related tags found
No related merge requests found
......@@ -101,8 +101,10 @@ if($latlng['lat']!=NULL && $latlng['lng']!=NULL) {
$values['long'] = $latlng['lng'];
}
else {
if (!Config::ValueOf('offline_mode')) {
$Result->show("warning", _('Failed to update location lat/lng from Nominatim').".<br>".escape_input($latlng['error']), false);
}
}
// update customer
if(!$Admin->object_modify("customers", $customer['action'], "id", $values)) {}
......
......@@ -58,11 +58,13 @@ if($_POST['action']=="add" || $_POST['action']=="edit") {
$_POST['long'] = $latlng['lng'];
}
else {
if (!Config::ValueOf('offline_mode')) {
$Result->show("warning", _("Failed to update location lat/lng from Nominatim").".<br>".escape_input($latlng['error']), false);
}
}
}
}
}
# fetch custom fields
$custom = $Tools->fetch_custom_fields('locations');
......
......@@ -147,6 +147,8 @@ $proxy_user = 'USERNAME'; // Proxy Username
$proxy_pass = 'PASSWORD'; // Proxy Password
$proxy_use_auth = false; // Enable/Disable Proxy authentication
$offline_mode = false; // Offline mode, disable server-side Internet requests (proxy/OpenStreetMap)
/**
* Failed access
* Message to log into webserver logs in case of failed access, for further processing by tools like Fail2Ban
......
......@@ -58,6 +58,8 @@ $proxy_user = file_env('PROXY_USER', $proxy_user);
$proxy_pass = file_env('PROXY_PASS', $proxy_pass);
$proxy_use_auth = file_env('PROXY_USE_AUTH', $proxy_use_auth);
$offline_mode = filter_var(file_env('OFFLINE_MODE', $offline_mode), FILTER_VALIDATE_BOOLEAN);
/**
* php debugging on/off
*
......
......@@ -1419,6 +1419,11 @@ class Common_functions {
public function curl_fetch_url($url, $headers=false, $timeout=30) {
$result = ['result'=>false, 'result_code'=>503, 'error_msg'=>''];
if (Config::ValueOf('offline_mode')) {
$result['error_msg'] = _('Internet access disabled in config.php');
return $result;
}
try {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
......
......@@ -320,6 +320,11 @@ class OpenStreetMap extends Common_functions {
return $results;
}
if (Config::ValueOf('offline_mode')) {
$result['error'] = _('Internet access disabled in config.php');
return $result;
}
try {
// Obtain exclusive MySQL row lock
$Lock = new LockForUpdate($this->Database, 'nominatim', 1);
......
......@@ -10,6 +10,7 @@
+ Added subnet free space map for each possible subnet mask;
+ Added Vaults (Certificate andf password storing);
+ Added Tools->Duplicate subnets & IP page;
+ Added config.php offline_mode to disable server-side Internet lookups (#3462);
Enhancements, changes:
----------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment