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