Project

General

Profile

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