1
|
<?php
|
2
|
/*
|
3
|
* shortcuts.inc
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* 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
|
*
|
15
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
*
|
17
|
* 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
|
*/
|
23
|
|
24
|
// On the page, add in like so:
|
25
|
// $shortcut_section = "ipsec";
|
26
|
|
27
|
$shortcuts = array();
|
28
|
|
29
|
/* Load and process custom shortcuts. */
|
30
|
function get_shortcut_files($directory) {
|
31
|
$dir_array = array();
|
32
|
if (!is_dir($directory)) {
|
33
|
return;
|
34
|
}
|
35
|
if ($dh = opendir($directory)) {
|
36
|
while (($file = readdir($dh)) !== false) {
|
37
|
$canadd = 0;
|
38
|
if ($file == ".") {
|
39
|
$canadd = 1;
|
40
|
}
|
41
|
if ($file == "..") {
|
42
|
$canadd = 1;
|
43
|
}
|
44
|
if ($canadd == 0) {
|
45
|
array_push($dir_array, $file);
|
46
|
}
|
47
|
}
|
48
|
closedir($dh);
|
49
|
}
|
50
|
if (!is_array($dir_array)) {
|
51
|
return;
|
52
|
}
|
53
|
return $dir_array;
|
54
|
}
|
55
|
|
56
|
function get_shortcut_by_service_name($servicename) {
|
57
|
global $shortcuts;
|
58
|
foreach ($shortcuts as $name => $shortcut) {
|
59
|
if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename)) {
|
60
|
return $name;
|
61
|
}
|
62
|
}
|
63
|
return null;
|
64
|
}
|
65
|
|
66
|
function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
|
67
|
global $g, $shortcuts;
|
68
|
if (empty($shortcut_section)) {
|
69
|
return "";
|
70
|
}
|
71
|
$space = ($addspace) ? " " : "" ;
|
72
|
switch ($shortcut_section) {
|
73
|
case "openvpn":
|
74
|
if (!empty($service['mode']) && is_numeric($service['id'])) {
|
75
|
$link = "vpn_openvpn_{$service['mode']}.php?act=edit&id={$service['id']}";
|
76
|
} else {
|
77
|
$link = $shortcuts[$shortcut_section]['main'];
|
78
|
}
|
79
|
break;
|
80
|
case "captiveportal":
|
81
|
if (!empty($service['zone'])) {
|
82
|
$link = "services_captiveportal.php?zone={$service['zone']}";
|
83
|
} else {
|
84
|
$link = $shortcuts[$shortcut_section]['main'];
|
85
|
}
|
86
|
break;
|
87
|
default:
|
88
|
$link = $shortcuts[$shortcut_section]['main'];
|
89
|
break;
|
90
|
}
|
91
|
if (!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}")) {
|
92
|
return "{$space}<a href=\"{$link}\" title=\"" . gettext("Related settings") . "\"><i class=\"fa fa-sliders\"></i></a>";
|
93
|
}
|
94
|
return "";
|
95
|
}
|
96
|
|
97
|
function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
|
98
|
global $g, $shortcuts, $cpzone;
|
99
|
if (empty($shortcut_section)) {
|
100
|
return "";
|
101
|
}
|
102
|
$space = ($addspace) ? " " : "" ;
|
103
|
if (!empty($cpzone)) {
|
104
|
$zone = $cpzone;
|
105
|
} elseif (!empty($service['zone'])) {
|
106
|
$zone = $service['zone'];
|
107
|
}
|
108
|
switch ($shortcut_section) {
|
109
|
case "captiveportal":
|
110
|
if (!empty($zone)) {
|
111
|
$link = "status_captiveportal.php?zone={$zone}";
|
112
|
} else {
|
113
|
$link = $shortcuts[$shortcut_section]['status'];
|
114
|
}
|
115
|
break;
|
116
|
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
|
default:
|
124
|
$link = $shortcuts[$shortcut_section]['status'];
|
125
|
break;
|
126
|
}
|
127
|
if (!empty($link)) {
|
128
|
return "{$space}<a href=\"{$link}\" title=\"" . gettext("Related status") . "\"><i class=\"fa fa-bar-chart\"></i></a>";
|
129
|
}
|
130
|
return "";
|
131
|
}
|
132
|
|
133
|
function get_shortcut_log_link($shortcut_section, $addspace = true) {
|
134
|
global $g, $shortcuts;
|
135
|
$space = ($addspace) ? " " : "" ;
|
136
|
if (!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
|
137
|
return "{$space}<a href=\"{$shortcuts[$shortcut_section]['log']}\" title=\"" . gettext("Related log entries") . "\"><i class=\"fa fa-list-alt\"></i></a>";
|
138
|
}
|
139
|
return "";
|
140
|
}
|
141
|
|
142
|
// Load shortcuts
|
143
|
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
|
144
|
foreach ($dir_array as $file) {
|
145
|
if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file, ".inc")) {
|
146
|
include_once("/usr/local/www/shortcuts/{$file}");
|
147
|
}
|
148
|
}
|
149
|
if (is_dir("/usr/local/pkg/shortcuts")) {
|
150
|
$dir_array = get_shortcut_files("/usr/local/pkg/shortcuts");
|
151
|
foreach ($dir_array as $file) {
|
152
|
if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file, ".inc")) {
|
153
|
include_once("/usr/local/pkg/shortcuts/{$file}");
|
154
|
}
|
155
|
}
|
156
|
}
|
157
|
|
158
|
$shortcuts['captiveportal'] = array();
|
159
|
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
|
160
|
$shortcuts['captiveportal']['log'] = "status_logs.php?logfile=portalauth";
|
161
|
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
|
162
|
$shortcuts['captiveportal']['service'] = "captiveportal";
|
163
|
|
164
|
$shortcuts['captiveportal-vouchers'] = array();
|
165
|
$shortcuts['captiveportal-vouchers']['log'] = "status_logs.php?logfile=auth";
|
166
|
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
|
167
|
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
|
168
|
|
169
|
$shortcuts['dhcp'] = array();
|
170
|
$shortcuts['dhcp']['main'] = "services_dhcp.php";
|
171
|
$shortcuts['dhcp']['log'] = "status_logs.php?logfile=dhcpd";
|
172
|
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
|
173
|
$shortcuts['dhcp']['service'] = "dhcpd";
|
174
|
|
175
|
$shortcuts['dhcp6'] = array();
|
176
|
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
|
177
|
$shortcuts['dhcp6']['log'] = "status_logs.php?logfile=dhcpd";
|
178
|
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
|
179
|
|
180
|
|
181
|
$shortcuts['ipsec'] = array();
|
182
|
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
|
183
|
$shortcuts['ipsec']['log'] = "status_logs.php?logfile=ipsec";
|
184
|
$shortcuts['ipsec']['status'] = "status_ipsec.php";
|
185
|
$shortcuts['ipsec']['service'] = "ipsec";
|
186
|
|
187
|
$shortcuts['openvpn'] = array();
|
188
|
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
|
189
|
$shortcuts['openvpn']['log'] = "status_logs.php?logfile=openvpn";
|
190
|
$shortcuts['openvpn']['status'] = "status_openvpn.php";
|
191
|
$shortcuts['openvpn']['service'] = "openvpn";
|
192
|
|
193
|
$shortcuts['firewall'] = array();
|
194
|
$shortcuts['firewall']['main'] = "firewall_rules.php";
|
195
|
$shortcuts['firewall']['log'] = "status_logs_filter.php";
|
196
|
$shortcuts['firewall']['status'] = "status_filter_reload.php";
|
197
|
|
198
|
$shortcuts['routing'] = array();
|
199
|
$shortcuts['routing']['main'] = "system_routes.php";
|
200
|
$shortcuts['routing']['log'] = "status_logs.php?logfile=routing";
|
201
|
$shortcuts['routing']['status'] = "diag_routes.php";
|
202
|
|
203
|
$shortcuts['gateways'] = array();
|
204
|
$shortcuts['gateways']['main'] = "system_gateways.php";
|
205
|
$shortcuts['gateways']['log'] = "status_logs.php?logfile=gateways";
|
206
|
$shortcuts['gateways']['status'] = "status_gateways.php";
|
207
|
$shortcuts['gateways']['service'] = "dpinger";
|
208
|
|
209
|
$shortcuts['gateway-groups'] = array();
|
210
|
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
|
211
|
$shortcuts['gateway-groups']['log'] = "status_logs.php?logfile=gateways";
|
212
|
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
|
213
|
|
214
|
$shortcuts['interfaces'] = array();
|
215
|
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
|
216
|
$shortcuts['interfaces']['status'] = "status_interfaces.php";
|
217
|
|
218
|
$shortcuts['trafficshaper'] = array();
|
219
|
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
|
220
|
$shortcuts['trafficshaper']['status'] = "status_queues.php";
|
221
|
|
222
|
$shortcuts['trafficshaper-limiters'] = array();
|
223
|
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
|
224
|
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
|
225
|
|
226
|
$shortcuts['forwarder'] = array();
|
227
|
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
|
228
|
$shortcuts['forwarder']['log'] = "status_logs.php?logfile=resolver";
|
229
|
$shortcuts['forwarder']['service'] = "dnsmasq";
|
230
|
|
231
|
$shortcuts['resolver'] = array();
|
232
|
$shortcuts['resolver']['main'] = "services_unbound.php";
|
233
|
$shortcuts['resolver']['log'] = "status_logs.php?logfile=resolver";
|
234
|
$shortcuts['resolver']['service'] = "unbound";
|
235
|
$shortcuts['resolver']['status'] = "status_unbound.php";
|
236
|
|
237
|
$shortcuts['wireless'] = array();
|
238
|
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
|
239
|
$shortcuts['wireless']['log'] = "status_logs.php?logfile=wireless";
|
240
|
$shortcuts['wireless']['status'] = "status_wireless.php";
|
241
|
|
242
|
$shortcuts['ntp'] = array();
|
243
|
$shortcuts['ntp']['main'] = "services_ntpd.php";
|
244
|
$shortcuts['ntp']['log'] = "status_logs.php?logfile=ntpd";
|
245
|
$shortcuts['ntp']['status'] = "status_ntpd.php";
|
246
|
$shortcuts['ntp']['service'] = "ntpd";
|
247
|
|
248
|
$shortcuts['pppoes'] = array();
|
249
|
$shortcuts['pppoes']['main'] = "services_pppoe.php";
|
250
|
$shortcuts['pppoes']['log'] = "status_logs_vpn.php?vpntype=poes";
|
251
|
|
252
|
$shortcuts['l2tps'] = array();
|
253
|
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
|
254
|
$shortcuts['l2tps']['log'] = "status_logs_vpn.php?logfile=l2tps&vpntype=l2tp";
|
255
|
|
256
|
$shortcuts['carp'] = array();
|
257
|
$shortcuts['carp']['main'] = "system_hasync.php";
|
258
|
$shortcuts['carp']['status'] = "status_carp.php";
|
259
|
|
260
|
$shortcuts['snmp'] = array();
|
261
|
$shortcuts['snmp']['main'] = "services_snmp.php";
|
262
|
$shortcuts['snmp']['service'] = "bsnmpd";
|
263
|
|
264
|
$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
|
$shortcuts['authentication'] = array();
|
270
|
$shortcuts['authentication']['main'] = "system_authservers.php";
|
271
|
// $shortcuts['authentication']['status'] = "diag_authentication.php";
|
272
|
|
273
|
$shortcuts['aliases'] = array();
|
274
|
$shortcuts['aliases']['main'] = "firewall_aliases.php";
|
275
|
$shortcuts['aliases']['status'] = "diag_tables.php";
|
276
|
|
277
|
?>
|