Project

General

Profile

« Previous | Next » 

Revision d0ca7530

Added by Reid Linnemann about 3 years ago

Replace direct config accesses in status_graph.php, status_ntpd.php

View differences:

src/usr/local/www/status_graph.php
35 35
##|*MATCH=ifstats.php*
36 36
##|-PRIV
37 37

  
38
require_once("guiconfig.inc");
39
require_once("ipsec.inc");
38
require_once('config.inc');
39
require_once('config.lib.inc');
40
require_once('guiconfig.inc');
41
require_once('ipsec.inc');
42

  
43

  
44
$pconfig = config_get_path('traffic_graphs');
40 45

  
41
if (is_array($config["traffic_graphs"])){
42
	$pconfig = $config["traffic_graphs"];
43
}
44 46
// Get configured interface list
45 47
$ifdescrs = get_configured_interface_with_descr();
46 48
if (ipsec_enabled()) {
......
48 50
}
49 51

  
50 52
foreach (array('server', 'client') as $mode) {
51
	if (!is_array($config['openvpn']["openvpn-{$mode}"])) {
52
		continue;
53
	}
54
	foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
53
	foreach (config_get_path("openvpn/openvpn-{$mode}", []) as $id => $setting) {
55 54
		if (isset($setting['disable'])) {
56 55
			continue;
57 56
		}
......
96 95
		$pconfig["smoothfactor"] = $cursmoothing;
97 96
		$pconfig["invert"] = $curinvert;
98 97
		$pconfig["mode"] = $curmode;
99
		$config["traffic_graphs"] = array();
100
		$config["traffic_graphs"] = $pconfig;
98
		config_set_path("traffic_graphs", $pconfig);
101 99
		write_config("Traffic Graphs settings updated");
102 100
	}
103 101
} else {
src/usr/local/www/status_ntpd.php
33 33
##|*MATCH=status_ntpd.php*
34 34
##|-PRIV
35 35

  
36
require_once("guiconfig.inc");
37

  
38
$allow_query = !isset($config['ntpd']['noquery']);
39
if (!empty($config['ntpd']['restrictions']['row']) && is_array($config['ntpd']['restrictions']['row'])) {
40
	foreach ($config['ntpd']['restrictions']['row'] as $v) {
41
		if (ip_in_subnet('127.0.0.1', "{$v['acl_network']}/{$v['mask']}") || 
42
		    ip_in_subnet('::1', "{$v['acl_network']}/{$v['mask']}")) {
43
			$allow_query = !isset($v['noquery']);
44
		}
36
require_once('confib.inc');
37
require_once('config.lib.inc');
38
require_once('guiconfig.inc');
39

  
40
$allow_query = !config_path_enabled('ntpd','noquery');
41
foreach (config_get_path('ntpd/restrictions/row') as $v) {
42
	if (ip_in_subnet('127.0.0.1', "{$v['acl_network']}/{$v['mask']}") || 
43
		ip_in_subnet('::1', "{$v['acl_network']}/{$v['mask']}")) {
44
		$allow_query = !isset($v['noquery']);
45 45
	}
46 46
}
47 47

  
48
if ($allow_query && ($config['ntpd']['enable'] != 'disabled')) {
49
	if (isset($config['system']['ipv6allow'])) {
48
if ($allow_query && (config_get_path('ntpd/enable') != 'disabled')) {
49
	if (config_path_enabled('system','ipv6allow')) {
50 50
		$inet_version = "";
51 51
	} else {
52 52
		$inet_version = " -4";
......
171 171
	}
172 172
}
173 173

  
174
if (isset($gps_ok) && isset($config['ntpd']['gps']['extstatus']) && ($config['ntpd']['gps']['nmeaset']['gpgsv'] || $config['ntpd']['gps']['nmeaset']['gpgga'])) {
175
	$lookfor['GPGSV'] = $config['ntpd']['gps']['nmeaset']['gpgsv'];
176
	$lookfor['GPGGA'] = !isset($gps_sat) && $config['ntpd']['gps']['nmeaset']['gpgga'];
174
if (isset($gps_ok) && config_path_enabled('ntpd/gps','extstatus') &&
175
	(config_path_enabled('ntpd/gps/nmeaset','gpgsv') ||
176
	 config_path_enabled('ntpd/gps/nmeaset','gpgga'))) {
177
	$lookfor['GPGSV'] = config_path_enabled('ntpd/gps/nmeaset','gpgsv');
178
	$lookfor['GPGGA'] = !isset($gps_sat) && config_path_enabled('ntpd/gps/nmeaset','gpgga');
177 179
	$gpsport = fopen('/dev/gps0', 'r+');
178 180
	while ($gpsport && ($lookfor['GPGSV'] || $lookfor['GPGGA'])) {
179 181
		$buffer = fgets($gpsport);
180 182
		if ($lookfor['GPGSV'] && substr($buffer, 0, 6) == '$GPGSV') {
181 183
			$gpgsv = explode(',', $buffer);
182 184
			$gps_satview = (int)$gpgsv[3];
183
			$lookfor['GPGSV'] = 0;
185
			$lookfor['GPGSV'] = false;
184 186
		} elseif ($lookfor['GPGGA'] && substr($buffer, 0, 6) == '$GPGGA') {
185 187
			$gpgga = explode(',', $buffer);
186 188
			$gps_sat = (int)$gpgga[7];
187 189
			$gps_alt = $gpgga[9];
188 190
			$gps_alt_unit = $gpgga[10];
189
			$lookfor['GPGGA'] = 0;
191
			$lookfor['GPGGA'] = false;
190 192
		}
191 193
	}
192 194
}
......
204 206
}
205 207

  
206 208
function print_status() {
207
	global $config, $ntpq_servers, $allow_query;
209
	global $ntpq_servers, $allow_query;
208 210

  
209
	if ($config['ntpd']['enable'] == 'disabled'):
211
	if (config_get_path('ntpd/enable') == 'disabled'):
210 212
		print("<tr>\n");
211 213
		print('<td class="warning" colspan="11">');
212 214
		printf(gettext('NTP Server is disabled'));

Also available in: Unified diff