Project

General

Profile

Download (10 KB) Statistics
| Branch: | Tag: | Revision:
1 76692ad2 jim-p
<?php
2 0f5d612a jim-p
/* $Id$ */
3
/*
4
	Copyright (C) 2012 Jim Pingle
5
	All rights reserved.
6
7
	Copyright (C) 2007, 2008 Scott Ullrich <sullrich@gmail.com>
8
	All rights reserved.
9
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
31
*/
32
33
/*
34
	pfSense_MODULE:	system
35
*/
36
37 9990b70c jim-p
// On the page, add in like so:
38
//   $shortcut_section = "relayd";
39
40 e3ffa8d4 jim-p
$shortcuts = array();
41
42 0f5d612a jim-p
/* Load and process custom shortcuts. */
43
function get_shortcut_files($directory) {
44
	$dir_array = array();
45 45b4ffc6 Phil Davis
	if (!is_dir($directory)) {
46 0f5d612a jim-p
		return;
47 45b4ffc6 Phil Davis
	}
48 0f5d612a jim-p
	if ($dh = opendir($directory)) {
49
		while (($file = readdir($dh)) !== false) {
50
			$canadd = 0;
51 45b4ffc6 Phil Davis
			if ($file == ".") {
52 0f5d612a jim-p
				$canadd = 1;
53 45b4ffc6 Phil Davis
			}
54
			if ($file == "..") {
55 0f5d612a jim-p
				$canadd = 1;
56 45b4ffc6 Phil Davis
			}
57
			if ($canadd == 0) {
58 0f5d612a jim-p
				array_push($dir_array, $file);
59 45b4ffc6 Phil Davis
			}
60 0f5d612a jim-p
		}
61
		closedir($dh);
62
	}
63 45b4ffc6 Phil Davis
	if (!is_array($dir_array)) {
64 0f5d612a jim-p
		return;
65 45b4ffc6 Phil Davis
	}
66 0f5d612a jim-p
	return $dir_array;
67
}
68
69 391abfcf jim-p
function get_shortcut_by_service_name($servicename) {
70
	global $shortcuts;
71
	foreach ($shortcuts as $name => $shortcut) {
72 45b4ffc6 Phil Davis
		if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename)) {
73 391abfcf jim-p
			return $name;
74 45b4ffc6 Phil Davis
		}
75 391abfcf jim-p
	}
76
	return null;
77
}
78
79
function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
80
	global $g, $shortcuts;
81 45b4ffc6 Phil Davis
	if (empty($shortcut_section)) {
82 391abfcf jim-p
		return "";
83 45b4ffc6 Phil Davis
	}
84 391abfcf jim-p
	$space = ($addspace) ? "&nbsp;" : "" ;
85
	switch ($shortcut_section) {
86
		case "openvpn":
87 45b4ffc6 Phil Davis
			if (!empty($service['mode']) && is_numeric($service['id'])) {
88 b3733e10 Colin Fleming
				$link = "vpn_openvpn_{$service['mode']}.php?act=edit&amp;id={$service['id']}";
89 45b4ffc6 Phil Davis
			} else {
90 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['main'];
91 45b4ffc6 Phil Davis
			}
92 391abfcf jim-p
			break;
93
		case "captiveportal":
94 45b4ffc6 Phil Davis
			if (!empty($service['zone'])) {
95 391abfcf jim-p
				$link = "services_captiveportal.php?zone={$service['zone']}";
96 45b4ffc6 Phil Davis
			} else {
97 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['main'];
98 45b4ffc6 Phil Davis
			}
99 391abfcf jim-p
			break;
100
		default:
101
			$link = $shortcuts[$shortcut_section]['main'];
102
			break;
103
	}
104 45b4ffc6 Phil Davis
	if (!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}")) {
105 a5ebda38 Jared Dillard
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Main page for this section") . "\"><i class=\"icon-large icon-plus-sign\"></i></a>";
106 45b4ffc6 Phil Davis
	}
107 391abfcf jim-p
}
108
109
function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
110
	global $g, $shortcuts, $cpzone;
111 45b4ffc6 Phil Davis
	if (empty($shortcut_section)) {
112 391abfcf jim-p
		return "";
113 45b4ffc6 Phil Davis
	}
114 391abfcf jim-p
	$space = ($addspace) ? "&nbsp;" : "" ;
115 45b4ffc6 Phil Davis
	if (!empty($cpzone)) {
116 391abfcf jim-p
		$zone = $cpzone;
117 45b4ffc6 Phil Davis
	} elseif (!empty($service['zone'])) {
118 391abfcf jim-p
		$zone = $service['zone'];
119 45b4ffc6 Phil Davis
	}
120 391abfcf jim-p
	switch ($shortcut_section) {
121
		case "captiveportal":
122 45b4ffc6 Phil Davis
			if (!empty($zone)) {
123 391abfcf jim-p
				$link = "status_captiveportal.php?zone={$zone}";
124 45b4ffc6 Phil Davis
			} else {
125 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['status'];
126 45b4ffc6 Phil Davis
			}
127 391abfcf jim-p
			break;
128
		default:
129
			$link = $shortcuts[$shortcut_section]['status'];
130
			break;
131
	}
132 45b4ffc6 Phil Davis
	if (!empty($link)) {
133 a5ebda38 Jared Dillard
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Status of items on this page") . "\"><i class=\"icon-large icon-cog\"></i></a>";
134 45b4ffc6 Phil Davis
	}
135 391abfcf jim-p
}
136
137
function get_shortcut_log_link($shortcut_section, $addspace = true) {
138
	global $g, $shortcuts;
139
	$space = ($addspace) ? "&nbsp;" : "" ;
140 45b4ffc6 Phil Davis
	if (!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
141 a5ebda38 Jared Dillard
		return "{$space}<a href=\"{$shortcuts[$shortcut_section]['log']}\" title=\"" . gettext("Log entries for items on this page") . "\"><i class=\"icon-large icon-list-alt\"></i></a>";
142 391abfcf jim-p
	}
143
}
144
145 0f5d612a jim-p
// Load shortcuts
146
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
147 45b4ffc6 Phil Davis
foreach ($dir_array as $file) {
148 6c07db48 Phil Davis
	if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file, ".inc")) {
149 0f5d612a jim-p
		include("/usr/local/www/shortcuts/{$file}");
150 45b4ffc6 Phil Davis
	}
151
}
152
if (is_dir("/usr/local/pkg/shortcuts")) {
153 0f5d612a jim-p
	$dir_array = get_shortcut_files("/usr/local/pkg/shortcuts");
154 45b4ffc6 Phil Davis
	foreach ($dir_array as $file) {
155 6c07db48 Phil Davis
		if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file, ".inc")) {
156 0f5d612a jim-p
			include("/usr/local/pkg/shortcuts/{$file}");
157 45b4ffc6 Phil Davis
		}
158
	}
159 0f5d612a jim-p
}
160
161 79696dea jim-p
$shortcuts['relayd'] = array();
162 226c43a5 jim-p
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
163 08d333ae Stephen Beaver
$shortcuts['relayd']['log'] = "diag_logs.php?logfile=relayd";
164 76692ad2 jim-p
$shortcuts['relayd']['status'] = "status_lb_pool.php";
165
$shortcuts['relayd']['service'] = "relayd";
166
167 79696dea jim-p
$shortcuts['relayd-virtualservers'] = array();
168 226c43a5 jim-p
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
169 08d333ae Stephen Beaver
$shortcuts['relayd-virtualservers']['log'] = "diag_logs.php?logfile=relayd";
170 76692ad2 jim-p
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
171 79696dea jim-p
$shortcuts['relayd-virtualservers']['service'] = "relayd";
172 76692ad2 jim-p
173 79696dea jim-p
$shortcuts['captiveportal'] = array();
174 226c43a5 jim-p
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
175 08d333ae Stephen Beaver
$shortcuts['captiveportal']['log'] = "diag_logs.php?logfile=auth";
176 76692ad2 jim-p
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
177 e38d34b4 jim-p
$shortcuts['captiveportal']['service'] = "captiveportal";
178 79696dea jim-p
179
$shortcuts['captiveportal-vouchers'] = array();
180 08d333ae Stephen Beaver
$shortcuts['captiveportal-vouchers']['log'] = "diag_logs.php?logfile=auth";
181 76692ad2 jim-p
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
182 e38d34b4 jim-p
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
183 76692ad2 jim-p
184 79696dea jim-p
$shortcuts['dhcp'] = array();
185 226c43a5 jim-p
$shortcuts['dhcp']['main'] = "services_dhcp.php";
186 08d333ae Stephen Beaver
$shortcuts['dhcp']['log'] = "diag_logs.php?logfile=dhcp";
187 76692ad2 jim-p
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
188
$shortcuts['dhcp']['service'] = "dhcpd";
189
190 79696dea jim-p
$shortcuts['dhcp6'] = array();
191 226c43a5 jim-p
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
192 08d333ae Stephen Beaver
$shortcuts['dhcp6']['log'] = "diag_logs.php?logfile=dhcp";
193 76692ad2 jim-p
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
194
195 79696dea jim-p
196
$shortcuts['ipsec'] = array();
197 226c43a5 jim-p
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
198 08d333ae Stephen Beaver
$shortcuts['ipsec']['log'] = "diag_logs.php?logfile=ipsec";
199 76692ad2 jim-p
$shortcuts['ipsec']['status'] = "diag_ipsec.php";
200 fe3f3998 jim-p
$shortcuts['ipsec']['service'] = "ipsec";
201 76692ad2 jim-p
202 79696dea jim-p
$shortcuts['openvpn'] = array();
203 226c43a5 jim-p
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
204 08d333ae Stephen Beaver
$shortcuts['openvpn']['log'] = "diag_logs.php?logfile=openvpn";
205 76692ad2 jim-p
$shortcuts['openvpn']['status'] = "status_openvpn.php";
206 6d9b1074 jim-p
$shortcuts['openvpn']['service'] = "openvpn";
207 76692ad2 jim-p
208 79696dea jim-p
$shortcuts['firewall'] = array();
209 226c43a5 jim-p
$shortcuts['firewall']['main'] = "firewall_rules.php";
210 13c9ff68 jim-p
$shortcuts['firewall']['log'] = "diag_logs_filter.php";
211 76692ad2 jim-p
$shortcuts['firewall']['status'] = "status_filter_reload.php";
212
213 79696dea jim-p
$shortcuts['routing'] = array();
214 226c43a5 jim-p
$shortcuts['routing']['main'] = "system_routes.php";
215 08d333ae Stephen Beaver
$shortcuts['routing']['log'] = "diag_logs.php?logfile=routing";
216 76692ad2 jim-p
$shortcuts['routing']['status'] = "diag_routes.php";
217
218 79696dea jim-p
$shortcuts['gateways'] = array();
219 226c43a5 jim-p
$shortcuts['gateways']['main'] = "system_gateways.php";
220 08d333ae Stephen Beaver
$shortcuts['gateways']['log'] = "diag_logs.php?logfile=gateways";
221 76692ad2 jim-p
$shortcuts['gateways']['status'] = "status_gateways.php";
222 b05a8f35 jim-p
$shortcuts['gateways']['service'] = "apinger";
223 79696dea jim-p
224
$shortcuts['gateway-groups'] = array();
225 226c43a5 jim-p
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
226 08d333ae Stephen Beaver
$shortcuts['gateway-groups']['log'] = "diag_logs.php?logfile=gateways";
227 76692ad2 jim-p
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
228
229 79696dea jim-p
$shortcuts['interfaces'] = array();
230 226c43a5 jim-p
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
231 76692ad2 jim-p
$shortcuts['interfaces']['status'] = "status_interfaces.php";
232
233 79696dea jim-p
$shortcuts['trafficshaper'] = array();
234 226c43a5 jim-p
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
235 76692ad2 jim-p
$shortcuts['trafficshaper']['status'] = "status_queues.php";
236
237 d71fc5d3 jim-p
$shortcuts['trafficshaper-limiters'] = array();
238
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
239
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
240
241 db88a3a2 Phil Davis
$shortcuts['forwarder'] = array();
242
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
243 08d333ae Stephen Beaver
$shortcuts['forwarder']['log'] = "diag_logs.php?logfile=resolver";
244 db88a3a2 Phil Davis
$shortcuts['forwarder']['service'] = "dnsmasq";
245
246 0143e77b bcyrill
$shortcuts['resolver'] = array();
247 db88a3a2 Phil Davis
$shortcuts['resolver']['main'] = "services_unbound.php";
248 08d333ae Stephen Beaver
$shortcuts['resolver']['log'] = "diag_logs.php?logfile=resolver";
249 db88a3a2 Phil Davis
$shortcuts['resolver']['service'] = "unbound";
250 6bb9db05 Renato Botelho
251 0143e77b bcyrill
$shortcuts['wireless'] = array();
252 226c43a5 jim-p
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
253 08d333ae Stephen Beaver
$shortcuts['wireless']['log'] = "diag_logs.php?logfile=wireless";
254 76692ad2 jim-p
$shortcuts['wireless']['status'] = "status_wireless.php";
255
256 79696dea jim-p
$shortcuts['ntp'] = array();
257 226c43a5 jim-p
$shortcuts['ntp']['main'] = "services_ntpd.php";
258 08d333ae Stephen Beaver
$shortcuts['ntp']['log'] = "diag_logs.php?logfile=ntpd";
259 76692ad2 jim-p
$shortcuts['ntp']['status'] = "status_ntpd.php";
260
$shortcuts['ntp']['service'] = "ntpd";
261
262 79696dea jim-p
$shortcuts['pptps'] = array();
263 226c43a5 jim-p
$shortcuts['pptps']['main'] = "vpn_pptp.php";
264 76692ad2 jim-p
$shortcuts['pptps']['log'] = "diag_logs_vpn.php";
265
266 79696dea jim-p
$shortcuts['pppoes'] = array();
267 226c43a5 jim-p
$shortcuts['pppoes']['main'] = "vpn_pppoe.php";
268 76692ad2 jim-p
$shortcuts['pppoes']['log'] = "diag_logs_vpn.php?vpntype=poes";
269
270 79696dea jim-p
$shortcuts['l2tps'] = array();
271 226c43a5 jim-p
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
272 76692ad2 jim-p
$shortcuts['l2tps']['log'] = "diag_logs_vpn.php?vpntype=l2tp";
273
274 79696dea jim-p
$shortcuts['carp'] = array();
275 226c43a5 jim-p
$shortcuts['carp']['main'] = "system_hasync.php";
276 76692ad2 jim-p
$shortcuts['carp']['status'] = "carp_status.php";
277 d71fc5d3 jim-p
278
$shortcuts['snmp'] = array();
279
$shortcuts['snmp']['main'] = "services_snmp.php";
280
$shortcuts['snmp']['service'] = "bsnmpd";
281
282
$shortcuts['authentication'] = array();
283
$shortcuts['authentication']['main'] = "system_authservers.php";
284
$shortcuts['authentication']['status'] = "diag_authentication.php";
285
286
$shortcuts['aliases'] = array();
287
$shortcuts['aliases']['main'] = "firewall_aliases.php";
288
$shortcuts['aliases']['status'] = "diag_tables.php";
289 6bb9db05 Renato Botelho
?>