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
	pfSense_MODULE:	system
57
*/
58
59 9990b70c jim-p
// On the page, add in like so:
60
//   $shortcut_section = "relayd";
61
62 e3ffa8d4 jim-p
$shortcuts = array();
63
64 0f5d612a jim-p
/* Load and process custom shortcuts. */
65
function get_shortcut_files($directory) {
66
	$dir_array = array();
67 45b4ffc6 Phil Davis
	if (!is_dir($directory)) {
68 0f5d612a jim-p
		return;
69 45b4ffc6 Phil Davis
	}
70 0f5d612a jim-p
	if ($dh = opendir($directory)) {
71
		while (($file = readdir($dh)) !== false) {
72
			$canadd = 0;
73 45b4ffc6 Phil Davis
			if ($file == ".") {
74 0f5d612a jim-p
				$canadd = 1;
75 45b4ffc6 Phil Davis
			}
76
			if ($file == "..") {
77 0f5d612a jim-p
				$canadd = 1;
78 45b4ffc6 Phil Davis
			}
79
			if ($canadd == 0) {
80 0f5d612a jim-p
				array_push($dir_array, $file);
81 45b4ffc6 Phil Davis
			}
82 0f5d612a jim-p
		}
83
		closedir($dh);
84
	}
85 45b4ffc6 Phil Davis
	if (!is_array($dir_array)) {
86 0f5d612a jim-p
		return;
87 45b4ffc6 Phil Davis
	}
88 0f5d612a jim-p
	return $dir_array;
89
}
90
91 391abfcf jim-p
function get_shortcut_by_service_name($servicename) {
92
	global $shortcuts;
93
	foreach ($shortcuts as $name => $shortcut) {
94 45b4ffc6 Phil Davis
		if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename)) {
95 391abfcf jim-p
			return $name;
96 45b4ffc6 Phil Davis
		}
97 391abfcf jim-p
	}
98
	return null;
99
}
100
101
function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
102
	global $g, $shortcuts;
103 45b4ffc6 Phil Davis
	if (empty($shortcut_section)) {
104 391abfcf jim-p
		return "";
105 45b4ffc6 Phil Davis
	}
106 391abfcf jim-p
	$space = ($addspace) ? "&nbsp;" : "" ;
107
	switch ($shortcut_section) {
108
		case "openvpn":
109 45b4ffc6 Phil Davis
			if (!empty($service['mode']) && is_numeric($service['id'])) {
110 b3733e10 Colin Fleming
				$link = "vpn_openvpn_{$service['mode']}.php?act=edit&amp;id={$service['id']}";
111 45b4ffc6 Phil Davis
			} else {
112 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['main'];
113 45b4ffc6 Phil Davis
			}
114 391abfcf jim-p
			break;
115
		case "captiveportal":
116 45b4ffc6 Phil Davis
			if (!empty($service['zone'])) {
117 391abfcf jim-p
				$link = "services_captiveportal.php?zone={$service['zone']}";
118 45b4ffc6 Phil Davis
			} else {
119 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['main'];
120 45b4ffc6 Phil Davis
			}
121 391abfcf jim-p
			break;
122
		default:
123
			$link = $shortcuts[$shortcut_section]['main'];
124
			break;
125
	}
126 45b4ffc6 Phil Davis
	if (!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}")) {
127 a5ebda38 Jared Dillard
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Main page for this section") . "\"><i class=\"icon-large icon-plus-sign\"></i></a>";
128 45b4ffc6 Phil Davis
	}
129 391abfcf jim-p
}
130
131
function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
132
	global $g, $shortcuts, $cpzone;
133 45b4ffc6 Phil Davis
	if (empty($shortcut_section)) {
134 391abfcf jim-p
		return "";
135 45b4ffc6 Phil Davis
	}
136 391abfcf jim-p
	$space = ($addspace) ? "&nbsp;" : "" ;
137 45b4ffc6 Phil Davis
	if (!empty($cpzone)) {
138 391abfcf jim-p
		$zone = $cpzone;
139 45b4ffc6 Phil Davis
	} elseif (!empty($service['zone'])) {
140 391abfcf jim-p
		$zone = $service['zone'];
141 45b4ffc6 Phil Davis
	}
142 391abfcf jim-p
	switch ($shortcut_section) {
143
		case "captiveportal":
144 45b4ffc6 Phil Davis
			if (!empty($zone)) {
145 391abfcf jim-p
				$link = "status_captiveportal.php?zone={$zone}";
146 45b4ffc6 Phil Davis
			} else {
147 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['status'];
148 45b4ffc6 Phil Davis
			}
149 391abfcf jim-p
			break;
150
		default:
151
			$link = $shortcuts[$shortcut_section]['status'];
152
			break;
153
	}
154 45b4ffc6 Phil Davis
	if (!empty($link)) {
155 a5ebda38 Jared Dillard
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Status of items on this page") . "\"><i class=\"icon-large icon-cog\"></i></a>";
156 45b4ffc6 Phil Davis
	}
157 391abfcf jim-p
}
158
159
function get_shortcut_log_link($shortcut_section, $addspace = true) {
160
	global $g, $shortcuts;
161
	$space = ($addspace) ? "&nbsp;" : "" ;
162 45b4ffc6 Phil Davis
	if (!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
163 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>";
164 391abfcf jim-p
	}
165
}
166
167 0f5d612a jim-p
// Load shortcuts
168
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
169 45b4ffc6 Phil Davis
foreach ($dir_array as $file) {
170 6c07db48 Phil Davis
	if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file, ".inc")) {
171 0f5d612a jim-p
		include("/usr/local/www/shortcuts/{$file}");
172 45b4ffc6 Phil Davis
	}
173
}
174
if (is_dir("/usr/local/pkg/shortcuts")) {
175 0f5d612a jim-p
	$dir_array = get_shortcut_files("/usr/local/pkg/shortcuts");
176 45b4ffc6 Phil Davis
	foreach ($dir_array as $file) {
177 6c07db48 Phil Davis
		if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file, ".inc")) {
178 0f5d612a jim-p
			include("/usr/local/pkg/shortcuts/{$file}");
179 45b4ffc6 Phil Davis
		}
180
	}
181 0f5d612a jim-p
}
182
183 79696dea jim-p
$shortcuts['relayd'] = array();
184 226c43a5 jim-p
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
185 08d333ae Stephen Beaver
$shortcuts['relayd']['log'] = "diag_logs.php?logfile=relayd";
186 76692ad2 jim-p
$shortcuts['relayd']['status'] = "status_lb_pool.php";
187
$shortcuts['relayd']['service'] = "relayd";
188
189 79696dea jim-p
$shortcuts['relayd-virtualservers'] = array();
190 226c43a5 jim-p
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
191 08d333ae Stephen Beaver
$shortcuts['relayd-virtualservers']['log'] = "diag_logs.php?logfile=relayd";
192 76692ad2 jim-p
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
193 79696dea jim-p
$shortcuts['relayd-virtualservers']['service'] = "relayd";
194 76692ad2 jim-p
195 79696dea jim-p
$shortcuts['captiveportal'] = array();
196 226c43a5 jim-p
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
197 08d333ae Stephen Beaver
$shortcuts['captiveportal']['log'] = "diag_logs.php?logfile=auth";
198 76692ad2 jim-p
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
199 e38d34b4 jim-p
$shortcuts['captiveportal']['service'] = "captiveportal";
200 79696dea jim-p
201
$shortcuts['captiveportal-vouchers'] = array();
202 08d333ae Stephen Beaver
$shortcuts['captiveportal-vouchers']['log'] = "diag_logs.php?logfile=auth";
203 76692ad2 jim-p
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
204 e38d34b4 jim-p
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
205 76692ad2 jim-p
206 79696dea jim-p
$shortcuts['dhcp'] = array();
207 226c43a5 jim-p
$shortcuts['dhcp']['main'] = "services_dhcp.php";
208 08d333ae Stephen Beaver
$shortcuts['dhcp']['log'] = "diag_logs.php?logfile=dhcp";
209 76692ad2 jim-p
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
210
$shortcuts['dhcp']['service'] = "dhcpd";
211
212 79696dea jim-p
$shortcuts['dhcp6'] = array();
213 226c43a5 jim-p
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
214 08d333ae Stephen Beaver
$shortcuts['dhcp6']['log'] = "diag_logs.php?logfile=dhcp";
215 76692ad2 jim-p
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
216
217 79696dea jim-p
218
$shortcuts['ipsec'] = array();
219 226c43a5 jim-p
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
220 08d333ae Stephen Beaver
$shortcuts['ipsec']['log'] = "diag_logs.php?logfile=ipsec";
221 76692ad2 jim-p
$shortcuts['ipsec']['status'] = "diag_ipsec.php";
222 fe3f3998 jim-p
$shortcuts['ipsec']['service'] = "ipsec";
223 76692ad2 jim-p
224 79696dea jim-p
$shortcuts['openvpn'] = array();
225 226c43a5 jim-p
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
226 08d333ae Stephen Beaver
$shortcuts['openvpn']['log'] = "diag_logs.php?logfile=openvpn";
227 76692ad2 jim-p
$shortcuts['openvpn']['status'] = "status_openvpn.php";
228 6d9b1074 jim-p
$shortcuts['openvpn']['service'] = "openvpn";
229 76692ad2 jim-p
230 79696dea jim-p
$shortcuts['firewall'] = array();
231 226c43a5 jim-p
$shortcuts['firewall']['main'] = "firewall_rules.php";
232 13c9ff68 jim-p
$shortcuts['firewall']['log'] = "diag_logs_filter.php";
233 76692ad2 jim-p
$shortcuts['firewall']['status'] = "status_filter_reload.php";
234
235 79696dea jim-p
$shortcuts['routing'] = array();
236 226c43a5 jim-p
$shortcuts['routing']['main'] = "system_routes.php";
237 08d333ae Stephen Beaver
$shortcuts['routing']['log'] = "diag_logs.php?logfile=routing";
238 76692ad2 jim-p
$shortcuts['routing']['status'] = "diag_routes.php";
239
240 79696dea jim-p
$shortcuts['gateways'] = array();
241 226c43a5 jim-p
$shortcuts['gateways']['main'] = "system_gateways.php";
242 08d333ae Stephen Beaver
$shortcuts['gateways']['log'] = "diag_logs.php?logfile=gateways";
243 76692ad2 jim-p
$shortcuts['gateways']['status'] = "status_gateways.php";
244 b05a8f35 jim-p
$shortcuts['gateways']['service'] = "apinger";
245 79696dea jim-p
246
$shortcuts['gateway-groups'] = array();
247 226c43a5 jim-p
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
248 08d333ae Stephen Beaver
$shortcuts['gateway-groups']['log'] = "diag_logs.php?logfile=gateways";
249 76692ad2 jim-p
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
250
251 79696dea jim-p
$shortcuts['interfaces'] = array();
252 226c43a5 jim-p
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
253 76692ad2 jim-p
$shortcuts['interfaces']['status'] = "status_interfaces.php";
254
255 79696dea jim-p
$shortcuts['trafficshaper'] = array();
256 226c43a5 jim-p
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
257 76692ad2 jim-p
$shortcuts['trafficshaper']['status'] = "status_queues.php";
258
259 d71fc5d3 jim-p
$shortcuts['trafficshaper-limiters'] = array();
260
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
261
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
262
263 db88a3a2 Phil Davis
$shortcuts['forwarder'] = array();
264
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
265 08d333ae Stephen Beaver
$shortcuts['forwarder']['log'] = "diag_logs.php?logfile=resolver";
266 db88a3a2 Phil Davis
$shortcuts['forwarder']['service'] = "dnsmasq";
267
268 0143e77b bcyrill
$shortcuts['resolver'] = array();
269 db88a3a2 Phil Davis
$shortcuts['resolver']['main'] = "services_unbound.php";
270 08d333ae Stephen Beaver
$shortcuts['resolver']['log'] = "diag_logs.php?logfile=resolver";
271 db88a3a2 Phil Davis
$shortcuts['resolver']['service'] = "unbound";
272 6bb9db05 Renato Botelho
273 0143e77b bcyrill
$shortcuts['wireless'] = array();
274 226c43a5 jim-p
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
275 08d333ae Stephen Beaver
$shortcuts['wireless']['log'] = "diag_logs.php?logfile=wireless";
276 76692ad2 jim-p
$shortcuts['wireless']['status'] = "status_wireless.php";
277
278 79696dea jim-p
$shortcuts['ntp'] = array();
279 226c43a5 jim-p
$shortcuts['ntp']['main'] = "services_ntpd.php";
280 08d333ae Stephen Beaver
$shortcuts['ntp']['log'] = "diag_logs.php?logfile=ntpd";
281 76692ad2 jim-p
$shortcuts['ntp']['status'] = "status_ntpd.php";
282
$shortcuts['ntp']['service'] = "ntpd";
283
284 79696dea jim-p
$shortcuts['pptps'] = array();
285 226c43a5 jim-p
$shortcuts['pptps']['main'] = "vpn_pptp.php";
286 76692ad2 jim-p
$shortcuts['pptps']['log'] = "diag_logs_vpn.php";
287
288 79696dea jim-p
$shortcuts['pppoes'] = array();
289 226c43a5 jim-p
$shortcuts['pppoes']['main'] = "vpn_pppoe.php";
290 76692ad2 jim-p
$shortcuts['pppoes']['log'] = "diag_logs_vpn.php?vpntype=poes";
291
292 79696dea jim-p
$shortcuts['l2tps'] = array();
293 226c43a5 jim-p
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
294 76692ad2 jim-p
$shortcuts['l2tps']['log'] = "diag_logs_vpn.php?vpntype=l2tp";
295
296 79696dea jim-p
$shortcuts['carp'] = array();
297 226c43a5 jim-p
$shortcuts['carp']['main'] = "system_hasync.php";
298 76692ad2 jim-p
$shortcuts['carp']['status'] = "carp_status.php";
299 d71fc5d3 jim-p
300
$shortcuts['snmp'] = array();
301
$shortcuts['snmp']['main'] = "services_snmp.php";
302
$shortcuts['snmp']['service'] = "bsnmpd";
303
304
$shortcuts['authentication'] = array();
305
$shortcuts['authentication']['main'] = "system_authservers.php";
306
$shortcuts['authentication']['status'] = "diag_authentication.php";
307
308
$shortcuts['aliases'] = array();
309
$shortcuts['aliases']['main'] = "firewall_aliases.php";
310
$shortcuts['aliases']['status'] = "diag_tables.php";
311 6bb9db05 Renato Botelho
?>