Project

General

Profile

Download (9.29 KB) Statistics
| Branch: | Tag: | Revision:
1 76692ad2 jim-p
<?php
2 0f5d612a jim-p
/*
3 c5d81585 Renato Botelho
 * shortcuts.inc
4 919d91f9 Phil Davis
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 81299b5c Renato Botelho
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 919d91f9 Phil Davis
 *
9 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12 919d91f9 Phil Davis
 *
13 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
14 919d91f9 Phil Davis
 *
15 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20 919d91f9 Phil Davis
 */
21 0f5d612a jim-p
22 9990b70c jim-p
// On the page, add in like so:
23
//   $shortcut_section = "relayd";
24
25 e3ffa8d4 jim-p
$shortcuts = array();
26
27 0f5d612a jim-p
/* Load and process custom shortcuts. */
28
function get_shortcut_files($directory) {
29
	$dir_array = array();
30 45b4ffc6 Phil Davis
	if (!is_dir($directory)) {
31 0f5d612a jim-p
		return;
32 45b4ffc6 Phil Davis
	}
33 0f5d612a jim-p
	if ($dh = opendir($directory)) {
34
		while (($file = readdir($dh)) !== false) {
35
			$canadd = 0;
36 45b4ffc6 Phil Davis
			if ($file == ".") {
37 0f5d612a jim-p
				$canadd = 1;
38 45b4ffc6 Phil Davis
			}
39
			if ($file == "..") {
40 0f5d612a jim-p
				$canadd = 1;
41 45b4ffc6 Phil Davis
			}
42
			if ($canadd == 0) {
43 0f5d612a jim-p
				array_push($dir_array, $file);
44 45b4ffc6 Phil Davis
			}
45 0f5d612a jim-p
		}
46
		closedir($dh);
47
	}
48 45b4ffc6 Phil Davis
	if (!is_array($dir_array)) {
49 0f5d612a jim-p
		return;
50 45b4ffc6 Phil Davis
	}
51 0f5d612a jim-p
	return $dir_array;
52
}
53
54 391abfcf jim-p
function get_shortcut_by_service_name($servicename) {
55
	global $shortcuts;
56
	foreach ($shortcuts as $name => $shortcut) {
57 45b4ffc6 Phil Davis
		if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename)) {
58 391abfcf jim-p
			return $name;
59 45b4ffc6 Phil Davis
		}
60 391abfcf jim-p
	}
61
	return null;
62
}
63
64
function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
65
	global $g, $shortcuts;
66 45b4ffc6 Phil Davis
	if (empty($shortcut_section)) {
67 391abfcf jim-p
		return "";
68 45b4ffc6 Phil Davis
	}
69 391abfcf jim-p
	$space = ($addspace) ? "&nbsp;" : "" ;
70
	switch ($shortcut_section) {
71
		case "openvpn":
72 45b4ffc6 Phil Davis
			if (!empty($service['mode']) && is_numeric($service['id'])) {
73 b3733e10 Colin Fleming
				$link = "vpn_openvpn_{$service['mode']}.php?act=edit&amp;id={$service['id']}";
74 45b4ffc6 Phil Davis
			} else {
75 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['main'];
76 45b4ffc6 Phil Davis
			}
77 391abfcf jim-p
			break;
78
		case "captiveportal":
79 45b4ffc6 Phil Davis
			if (!empty($service['zone'])) {
80 391abfcf jim-p
				$link = "services_captiveportal.php?zone={$service['zone']}";
81 45b4ffc6 Phil Davis
			} else {
82 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['main'];
83 45b4ffc6 Phil Davis
			}
84 391abfcf jim-p
			break;
85
		default:
86
			$link = $shortcuts[$shortcut_section]['main'];
87
			break;
88
	}
89 45b4ffc6 Phil Davis
	if (!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}")) {
90 9c96aba4 jim-p
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Related settings") . "\"><i class=\"fa fa-sliders\"></i></a>";
91 45b4ffc6 Phil Davis
	}
92 9014e27c k-paulius
	return "";
93 391abfcf jim-p
}
94
95
function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
96
	global $g, $shortcuts, $cpzone;
97 45b4ffc6 Phil Davis
	if (empty($shortcut_section)) {
98 391abfcf jim-p
		return "";
99 45b4ffc6 Phil Davis
	}
100 391abfcf jim-p
	$space = ($addspace) ? "&nbsp;" : "" ;
101 45b4ffc6 Phil Davis
	if (!empty($cpzone)) {
102 391abfcf jim-p
		$zone = $cpzone;
103 45b4ffc6 Phil Davis
	} elseif (!empty($service['zone'])) {
104 391abfcf jim-p
		$zone = $service['zone'];
105 45b4ffc6 Phil Davis
	}
106 391abfcf jim-p
	switch ($shortcut_section) {
107
		case "captiveportal":
108 45b4ffc6 Phil Davis
			if (!empty($zone)) {
109 391abfcf jim-p
				$link = "status_captiveportal.php?zone={$zone}";
110 45b4ffc6 Phil Davis
			} else {
111 391abfcf jim-p
				$link = $shortcuts[$shortcut_section]['status'];
112 45b4ffc6 Phil Davis
			}
113 391abfcf jim-p
			break;
114
		default:
115
			$link = $shortcuts[$shortcut_section]['status'];
116
			break;
117
	}
118 45b4ffc6 Phil Davis
	if (!empty($link)) {
119 19d5cc63 jim-p
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Related status") . "\"><i class=\"fa fa-bar-chart\"></i></a>";
120 45b4ffc6 Phil Davis
	}
121 9014e27c k-paulius
	return "";
122 391abfcf jim-p
}
123
124
function get_shortcut_log_link($shortcut_section, $addspace = true) {
125
	global $g, $shortcuts;
126
	$space = ($addspace) ? "&nbsp;" : "" ;
127 45b4ffc6 Phil Davis
	if (!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
128 9c96aba4 jim-p
		return "{$space}<a href=\"{$shortcuts[$shortcut_section]['log']}\" title=\"" . gettext("Related log entries") . "\"><i class=\"fa fa-list-alt\"></i></a>";
129 391abfcf jim-p
	}
130 9014e27c k-paulius
	return "";
131 391abfcf jim-p
}
132
133 0f5d612a jim-p
// Load shortcuts
134
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
135 45b4ffc6 Phil Davis
foreach ($dir_array as $file) {
136 6c07db48 Phil Davis
	if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file, ".inc")) {
137 86573bb9 Phil Davis
		include_once("/usr/local/www/shortcuts/{$file}");
138 45b4ffc6 Phil Davis
	}
139
}
140
if (is_dir("/usr/local/pkg/shortcuts")) {
141 0f5d612a jim-p
	$dir_array = get_shortcut_files("/usr/local/pkg/shortcuts");
142 45b4ffc6 Phil Davis
	foreach ($dir_array as $file) {
143 6c07db48 Phil Davis
		if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file, ".inc")) {
144 86573bb9 Phil Davis
			include_once("/usr/local/pkg/shortcuts/{$file}");
145 45b4ffc6 Phil Davis
		}
146
	}
147 0f5d612a jim-p
}
148
149 79696dea jim-p
$shortcuts['relayd'] = array();
150 226c43a5 jim-p
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
151 1af5edbf Stephen Beaver
$shortcuts['relayd']['log'] = "status_logs.php?logfile=relayd";
152 76692ad2 jim-p
$shortcuts['relayd']['status'] = "status_lb_pool.php";
153
$shortcuts['relayd']['service'] = "relayd";
154
155 79696dea jim-p
$shortcuts['relayd-virtualservers'] = array();
156 226c43a5 jim-p
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
157 1af5edbf Stephen Beaver
$shortcuts['relayd-virtualservers']['log'] = "status_logs.php?logfile=relayd";
158 76692ad2 jim-p
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
159 79696dea jim-p
$shortcuts['relayd-virtualservers']['service'] = "relayd";
160 76692ad2 jim-p
161 79696dea jim-p
$shortcuts['captiveportal'] = array();
162 226c43a5 jim-p
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
163 1af5edbf Stephen Beaver
$shortcuts['captiveportal']['log'] = "status_logs.php?logfile=portalauth";
164 76692ad2 jim-p
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
165 e38d34b4 jim-p
$shortcuts['captiveportal']['service'] = "captiveportal";
166 79696dea jim-p
167
$shortcuts['captiveportal-vouchers'] = array();
168 1af5edbf Stephen Beaver
$shortcuts['captiveportal-vouchers']['log'] = "status_logs.php?logfile=auth";
169 76692ad2 jim-p
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
170 e38d34b4 jim-p
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
171 76692ad2 jim-p
172 79696dea jim-p
$shortcuts['dhcp'] = array();
173 226c43a5 jim-p
$shortcuts['dhcp']['main'] = "services_dhcp.php";
174 1af5edbf Stephen Beaver
$shortcuts['dhcp']['log'] = "status_logs.php?logfile=dhcpd";
175 76692ad2 jim-p
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
176
$shortcuts['dhcp']['service'] = "dhcpd";
177
178 79696dea jim-p
$shortcuts['dhcp6'] = array();
179 226c43a5 jim-p
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
180 40eca7e3 Stephen Beaver
$shortcuts['dhcp6']['log'] = "status_logs.php?logfile=dhcpd";
181 76692ad2 jim-p
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
182
183 79696dea jim-p
184
$shortcuts['ipsec'] = array();
185 226c43a5 jim-p
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
186 1af5edbf Stephen Beaver
$shortcuts['ipsec']['log'] = "status_logs.php?logfile=ipsec";
187
$shortcuts['ipsec']['status'] = "status_ipsec.php";
188 fe3f3998 jim-p
$shortcuts['ipsec']['service'] = "ipsec";
189 76692ad2 jim-p
190 79696dea jim-p
$shortcuts['openvpn'] = array();
191 226c43a5 jim-p
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
192 1af5edbf Stephen Beaver
$shortcuts['openvpn']['log'] = "status_logs.php?logfile=openvpn";
193 76692ad2 jim-p
$shortcuts['openvpn']['status'] = "status_openvpn.php";
194 6d9b1074 jim-p
$shortcuts['openvpn']['service'] = "openvpn";
195 76692ad2 jim-p
196 79696dea jim-p
$shortcuts['firewall'] = array();
197 226c43a5 jim-p
$shortcuts['firewall']['main'] = "firewall_rules.php";
198 1af5edbf Stephen Beaver
$shortcuts['firewall']['log'] = "status_logs_filter.php";
199 76692ad2 jim-p
$shortcuts['firewall']['status'] = "status_filter_reload.php";
200
201 79696dea jim-p
$shortcuts['routing'] = array();
202 226c43a5 jim-p
$shortcuts['routing']['main'] = "system_routes.php";
203 1af5edbf Stephen Beaver
$shortcuts['routing']['log'] = "status_logs.php?logfile=routing";
204 76692ad2 jim-p
$shortcuts['routing']['status'] = "diag_routes.php";
205
206 79696dea jim-p
$shortcuts['gateways'] = array();
207 226c43a5 jim-p
$shortcuts['gateways']['main'] = "system_gateways.php";
208 1af5edbf Stephen Beaver
$shortcuts['gateways']['log'] = "status_logs.php?logfile=gateways";
209 76692ad2 jim-p
$shortcuts['gateways']['status'] = "status_gateways.php";
210 69eefb50 Renato Botelho
$shortcuts['gateways']['service'] = "dpinger";
211 79696dea jim-p
212
$shortcuts['gateway-groups'] = array();
213 226c43a5 jim-p
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
214 1af5edbf Stephen Beaver
$shortcuts['gateway-groups']['log'] = "status_logs.php?logfile=gateways";
215 76692ad2 jim-p
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
216
217 79696dea jim-p
$shortcuts['interfaces'] = array();
218 226c43a5 jim-p
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
219 76692ad2 jim-p
$shortcuts['interfaces']['status'] = "status_interfaces.php";
220
221 79696dea jim-p
$shortcuts['trafficshaper'] = array();
222 226c43a5 jim-p
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
223 76692ad2 jim-p
$shortcuts['trafficshaper']['status'] = "status_queues.php";
224
225 d71fc5d3 jim-p
$shortcuts['trafficshaper-limiters'] = array();
226
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
227
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
228
229 db88a3a2 Phil Davis
$shortcuts['forwarder'] = array();
230
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
231 1af5edbf Stephen Beaver
$shortcuts['forwarder']['log'] = "status_logs.php?logfile=resolver";
232 db88a3a2 Phil Davis
$shortcuts['forwarder']['service'] = "dnsmasq";
233
234 0143e77b bcyrill
$shortcuts['resolver'] = array();
235 db88a3a2 Phil Davis
$shortcuts['resolver']['main'] = "services_unbound.php";
236 1af5edbf Stephen Beaver
$shortcuts['resolver']['log'] = "status_logs.php?logfile=resolver";
237 db88a3a2 Phil Davis
$shortcuts['resolver']['service'] = "unbound";
238 6bb9db05 Renato Botelho
239 0143e77b bcyrill
$shortcuts['wireless'] = array();
240 226c43a5 jim-p
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
241 1af5edbf Stephen Beaver
$shortcuts['wireless']['log'] = "status_logs.php?logfile=wireless";
242 76692ad2 jim-p
$shortcuts['wireless']['status'] = "status_wireless.php";
243
244 79696dea jim-p
$shortcuts['ntp'] = array();
245 226c43a5 jim-p
$shortcuts['ntp']['main'] = "services_ntpd.php";
246 1af5edbf Stephen Beaver
$shortcuts['ntp']['log'] = "status_logs.php?logfile=ntpd";
247 76692ad2 jim-p
$shortcuts['ntp']['status'] = "status_ntpd.php";
248
$shortcuts['ntp']['service'] = "ntpd";
249
250 79696dea jim-p
$shortcuts['pppoes'] = array();
251 1af5edbf Stephen Beaver
$shortcuts['pppoes']['main'] = "services_pppoe.php";
252
$shortcuts['pppoes']['log'] = "status_logs_vpn.php?vpntype=poes";
253 76692ad2 jim-p
254 79696dea jim-p
$shortcuts['l2tps'] = array();
255 226c43a5 jim-p
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
256 1af5edbf Stephen Beaver
$shortcuts['l2tps']['log'] = "status_logs_vpn.php?vpntype=l2tp";
257 76692ad2 jim-p
258 79696dea jim-p
$shortcuts['carp'] = array();
259 226c43a5 jim-p
$shortcuts['carp']['main'] = "system_hasync.php";
260 cfc44298 Chris Buechler
$shortcuts['carp']['status'] = "status_carp.php";
261 d71fc5d3 jim-p
262
$shortcuts['snmp'] = array();
263
$shortcuts['snmp']['main'] = "services_snmp.php";
264
$shortcuts['snmp']['service'] = "bsnmpd";
265
266
$shortcuts['authentication'] = array();
267
$shortcuts['authentication']['main'] = "system_authservers.php";
268 03fd538e Stephen Beaver
// $shortcuts['authentication']['status'] = "diag_authentication.php";
269 d71fc5d3 jim-p
270
$shortcuts['aliases'] = array();
271
$shortcuts['aliases']['main'] = "firewall_aliases.php";
272
$shortcuts['aliases']['status'] = "diag_tables.php";
273 6bb9db05 Renato Botelho
?>