Project

General

Profile

Bug #6987 » ntopng.diff

Add Google Maps API key to ntopng - Kill Bill, 12/09/2016 03:50 PM

View differences:

/usr/local/pkg/ntopng.inc 2016-12-09 22:46:37.000000000 +0100
168 161
	/* Set up admin password */
169 162
	ntopng_set_redis_password();
170 163
	
164
	/* Set up Google Maps API Key */
165
	ntopng_set_googlemaps_apikey();
166
	
171 167
	/* (Re)start services if not booting */
172 168
	if (!platform_booting()) {
173 169
		ntopng_services_stop();
......
222 218
	}
223 219
}
224 220

  
221
function ntopng_set_googlemaps_apikey() {
222
	global $config, $ntopng_config, $redis_path;
223
	$ntopng_config = $config['installedpackages']['ntopng']['config'][0];
224

  
225
	if (!empty($ntopng_config['googlemaps_api_key'])) {
226
		$apikey = $ntopng_config['googlemaps_api_key'];
227
		if (ntopng_redis_started()) {
228
			mwexec("{$redis_path}/redis-cli SET ntopng.prefs.google_apis_browser_key " . escapeshellarg($apikey));
229
			mwexec("{$redis_path}/redis-cli save");
230
		} else {
231
			log_error(gettext("[ntopng] Cannot set Google Maps API Key - redis-server is not running."));
232
		}
233
	}
234
}
235

  
225 236
function ntopng_create_datadir() {
226 237
	safe_mkdir("/var/db/ntopng/rrd/graphics", 0755);
227 238
	mwexec("/bin/chmod -R 755 /var/db/ntopng");
228
-- /usr/local/pkg/ntopng.xml.orig	2016-11-28 14:15:00.000000000 +0100
239
++ /usr/local/pkg/ntopng.xml	2016-12-09 22:46:25.000000000 +0100
......
162 149
				The historical interface is considered <a href="http://www.gossamer-threads.com/lists/ntop/misc/37506#37506">abandoned by upstream</a>,
163 150
				pending more usable replacement.<br /><br />
164 151
				<input type="submit" name="Delete" value="Delete (Historical) Data" />
165
				<strong><span class="errmsg">WARNING:</span> This will delete all ntopng graphs, traffic data and historical dump flows!
152
				<strong><span class="errmsg">WARNING:</span> This will delete all ntopng graphs, traffic data and historical dump flows!</strong>
166 153
				]]>
167 154
			</sethelp>
168 155
			<type>checkbox</type>
......
173 160
			<description>Disables all alerts generated by ntopng, such as flooding notifications.</description>
174 161
			<type>checkbox</type>
175 162
		</field>
163
		<field>
164
			<fielddescr>Google Maps API Key</fielddescr>
165
			<fieldname>googlemaps_api_key</fieldname>
166
			<description>
167
				<![CDATA[
168
				Graphical hosts geomaps are based on Google Maps APIs. Google requires an API key to be sumbitted for every request.<br />
169
				Detailed information on how to obtain an API key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">can be found here</a>.<br />
170
				Once obtained, the API key can be placed in this field.
171
				]]>
172
			</description>
173
			<type>input</type>
174
			<size>40</size>
175
		</field>
176 176
	</fields>
177 177
	<custom_php_resync_config_command>
178 178
		ntopng_sync_package();
(1-1/2)