Project

General

Profile

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