1
|
<?php
|
2
|
/*
|
3
|
* shortcuts.inc
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* Redistribution and use in source and binary forms, with or without
|
10
|
* modification, are permitted provided that the following conditions are met:
|
11
|
*
|
12
|
* 1. Redistributions of source code must retain the above copyright notice,
|
13
|
* this list of conditions and the following disclaimer.
|
14
|
*
|
15
|
* 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
|
*
|
20
|
* 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
|
*
|
25
|
* 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
|
*
|
30
|
* 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
|
*
|
34
|
* 6. Redistributions of any form whatsoever must retain the following
|
35
|
* acknowledgment:
|
36
|
*
|
37
|
* "This product includes software developed by the pfSense Project
|
38
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
39
|
*
|
40
|
* 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
|
*/
|
53
|
|
54
|
// On the page, add in like so:
|
55
|
// $shortcut_section = "relayd";
|
56
|
|
57
|
$shortcuts = array();
|
58
|
|
59
|
/* Load and process custom shortcuts. */
|
60
|
function get_shortcut_files($directory) {
|
61
|
$dir_array = array();
|
62
|
if (!is_dir($directory)) {
|
63
|
return;
|
64
|
}
|
65
|
if ($dh = opendir($directory)) {
|
66
|
while (($file = readdir($dh)) !== false) {
|
67
|
$canadd = 0;
|
68
|
if ($file == ".") {
|
69
|
$canadd = 1;
|
70
|
}
|
71
|
if ($file == "..") {
|
72
|
$canadd = 1;
|
73
|
}
|
74
|
if ($canadd == 0) {
|
75
|
array_push($dir_array, $file);
|
76
|
}
|
77
|
}
|
78
|
closedir($dh);
|
79
|
}
|
80
|
if (!is_array($dir_array)) {
|
81
|
return;
|
82
|
}
|
83
|
return $dir_array;
|
84
|
}
|
85
|
|
86
|
function get_shortcut_by_service_name($servicename) {
|
87
|
global $shortcuts;
|
88
|
foreach ($shortcuts as $name => $shortcut) {
|
89
|
if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename)) {
|
90
|
return $name;
|
91
|
}
|
92
|
}
|
93
|
return null;
|
94
|
}
|
95
|
|
96
|
function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
|
97
|
global $g, $shortcuts;
|
98
|
if (empty($shortcut_section)) {
|
99
|
return "";
|
100
|
}
|
101
|
$space = ($addspace) ? " " : "" ;
|
102
|
switch ($shortcut_section) {
|
103
|
case "openvpn":
|
104
|
if (!empty($service['mode']) && is_numeric($service['id'])) {
|
105
|
$link = "vpn_openvpn_{$service['mode']}.php?act=edit&id={$service['id']}";
|
106
|
} else {
|
107
|
$link = $shortcuts[$shortcut_section]['main'];
|
108
|
}
|
109
|
break;
|
110
|
case "captiveportal":
|
111
|
if (!empty($service['zone'])) {
|
112
|
$link = "services_captiveportal.php?zone={$service['zone']}";
|
113
|
} else {
|
114
|
$link = $shortcuts[$shortcut_section]['main'];
|
115
|
}
|
116
|
break;
|
117
|
default:
|
118
|
$link = $shortcuts[$shortcut_section]['main'];
|
119
|
break;
|
120
|
}
|
121
|
if (!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}")) {
|
122
|
return "{$space}<a href=\"{$link}\" title=\"" . gettext("Related settings") . "\"><i class=\"fa fa-sliders\"></i></a>";
|
123
|
}
|
124
|
return "";
|
125
|
}
|
126
|
|
127
|
function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
|
128
|
global $g, $shortcuts, $cpzone;
|
129
|
if (empty($shortcut_section)) {
|
130
|
return "";
|
131
|
}
|
132
|
$space = ($addspace) ? " " : "" ;
|
133
|
if (!empty($cpzone)) {
|
134
|
$zone = $cpzone;
|
135
|
} elseif (!empty($service['zone'])) {
|
136
|
$zone = $service['zone'];
|
137
|
}
|
138
|
switch ($shortcut_section) {
|
139
|
case "captiveportal":
|
140
|
if (!empty($zone)) {
|
141
|
$link = "status_captiveportal.php?zone={$zone}";
|
142
|
} else {
|
143
|
$link = $shortcuts[$shortcut_section]['status'];
|
144
|
}
|
145
|
break;
|
146
|
default:
|
147
|
$link = $shortcuts[$shortcut_section]['status'];
|
148
|
break;
|
149
|
}
|
150
|
if (!empty($link)) {
|
151
|
return "{$space}<a href=\"{$link}\" title=\"" . gettext("Related status") . "\"><i class=\"fa fa-bar-chart\"></i></a>";
|
152
|
}
|
153
|
return "";
|
154
|
}
|
155
|
|
156
|
function get_shortcut_log_link($shortcut_section, $addspace = true) {
|
157
|
global $g, $shortcuts;
|
158
|
$space = ($addspace) ? " " : "" ;
|
159
|
if (!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
|
160
|
return "{$space}<a href=\"{$shortcuts[$shortcut_section]['log']}\" title=\"" . gettext("Related log entries") . "\"><i class=\"fa fa-list-alt\"></i></a>";
|
161
|
}
|
162
|
return "";
|
163
|
}
|
164
|
|
165
|
// Load shortcuts
|
166
|
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
|
167
|
foreach ($dir_array as $file) {
|
168
|
if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file, ".inc")) {
|
169
|
include_once("/usr/local/www/shortcuts/{$file}");
|
170
|
}
|
171
|
}
|
172
|
if (is_dir("/usr/local/pkg/shortcuts")) {
|
173
|
$dir_array = get_shortcut_files("/usr/local/pkg/shortcuts");
|
174
|
foreach ($dir_array as $file) {
|
175
|
if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file, ".inc")) {
|
176
|
include_once("/usr/local/pkg/shortcuts/{$file}");
|
177
|
}
|
178
|
}
|
179
|
}
|
180
|
|
181
|
$shortcuts['relayd'] = array();
|
182
|
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
|
183
|
$shortcuts['relayd']['log'] = "status_logs.php?logfile=relayd";
|
184
|
$shortcuts['relayd']['status'] = "status_lb_pool.php";
|
185
|
$shortcuts['relayd']['service'] = "relayd";
|
186
|
|
187
|
$shortcuts['relayd-virtualservers'] = array();
|
188
|
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
|
189
|
$shortcuts['relayd-virtualservers']['log'] = "status_logs.php?logfile=relayd";
|
190
|
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
|
191
|
$shortcuts['relayd-virtualservers']['service'] = "relayd";
|
192
|
|
193
|
$shortcuts['captiveportal'] = array();
|
194
|
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
|
195
|
$shortcuts['captiveportal']['log'] = "status_logs.php?logfile=portalauth";
|
196
|
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
|
197
|
$shortcuts['captiveportal']['service'] = "captiveportal";
|
198
|
|
199
|
$shortcuts['captiveportal-vouchers'] = array();
|
200
|
$shortcuts['captiveportal-vouchers']['log'] = "status_logs.php?logfile=auth";
|
201
|
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
|
202
|
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
|
203
|
|
204
|
$shortcuts['dhcp'] = array();
|
205
|
$shortcuts['dhcp']['main'] = "services_dhcp.php";
|
206
|
$shortcuts['dhcp']['log'] = "status_logs.php?logfile=dhcpd";
|
207
|
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
|
208
|
$shortcuts['dhcp']['service'] = "dhcpd";
|
209
|
|
210
|
$shortcuts['dhcp6'] = array();
|
211
|
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
|
212
|
$shortcuts['dhcp6']['log'] = "status_logs.php?logfile=dhcpd";
|
213
|
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
|
214
|
|
215
|
|
216
|
$shortcuts['ipsec'] = array();
|
217
|
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
|
218
|
$shortcuts['ipsec']['log'] = "status_logs.php?logfile=ipsec";
|
219
|
$shortcuts['ipsec']['status'] = "status_ipsec.php";
|
220
|
$shortcuts['ipsec']['service'] = "ipsec";
|
221
|
|
222
|
$shortcuts['openvpn'] = array();
|
223
|
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
|
224
|
$shortcuts['openvpn']['log'] = "status_logs.php?logfile=openvpn";
|
225
|
$shortcuts['openvpn']['status'] = "status_openvpn.php";
|
226
|
$shortcuts['openvpn']['service'] = "openvpn";
|
227
|
|
228
|
$shortcuts['firewall'] = array();
|
229
|
$shortcuts['firewall']['main'] = "firewall_rules.php";
|
230
|
$shortcuts['firewall']['log'] = "status_logs_filter.php";
|
231
|
$shortcuts['firewall']['status'] = "status_filter_reload.php";
|
232
|
|
233
|
$shortcuts['routing'] = array();
|
234
|
$shortcuts['routing']['main'] = "system_routes.php";
|
235
|
$shortcuts['routing']['log'] = "status_logs.php?logfile=routing";
|
236
|
$shortcuts['routing']['status'] = "diag_routes.php";
|
237
|
|
238
|
$shortcuts['gateways'] = array();
|
239
|
$shortcuts['gateways']['main'] = "system_gateways.php";
|
240
|
$shortcuts['gateways']['log'] = "status_logs.php?logfile=gateways";
|
241
|
$shortcuts['gateways']['status'] = "status_gateways.php";
|
242
|
$shortcuts['gateways']['service'] = "dpinger";
|
243
|
|
244
|
$shortcuts['gateway-groups'] = array();
|
245
|
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
|
246
|
$shortcuts['gateway-groups']['log'] = "status_logs.php?logfile=gateways";
|
247
|
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
|
248
|
|
249
|
$shortcuts['interfaces'] = array();
|
250
|
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
|
251
|
$shortcuts['interfaces']['status'] = "status_interfaces.php";
|
252
|
|
253
|
$shortcuts['trafficshaper'] = array();
|
254
|
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
|
255
|
$shortcuts['trafficshaper']['status'] = "status_queues.php";
|
256
|
|
257
|
$shortcuts['trafficshaper-limiters'] = array();
|
258
|
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
|
259
|
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
|
260
|
|
261
|
$shortcuts['forwarder'] = array();
|
262
|
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
|
263
|
$shortcuts['forwarder']['log'] = "status_logs.php?logfile=resolver";
|
264
|
$shortcuts['forwarder']['service'] = "dnsmasq";
|
265
|
|
266
|
$shortcuts['resolver'] = array();
|
267
|
$shortcuts['resolver']['main'] = "services_unbound.php";
|
268
|
$shortcuts['resolver']['log'] = "status_logs.php?logfile=resolver";
|
269
|
$shortcuts['resolver']['service'] = "unbound";
|
270
|
|
271
|
$shortcuts['wireless'] = array();
|
272
|
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
|
273
|
$shortcuts['wireless']['log'] = "status_logs.php?logfile=wireless";
|
274
|
$shortcuts['wireless']['status'] = "status_wireless.php";
|
275
|
|
276
|
$shortcuts['ntp'] = array();
|
277
|
$shortcuts['ntp']['main'] = "services_ntpd.php";
|
278
|
$shortcuts['ntp']['log'] = "status_logs.php?logfile=ntpd";
|
279
|
$shortcuts['ntp']['status'] = "status_ntpd.php";
|
280
|
$shortcuts['ntp']['service'] = "ntpd";
|
281
|
|
282
|
$shortcuts['pppoes'] = array();
|
283
|
$shortcuts['pppoes']['main'] = "services_pppoe.php";
|
284
|
$shortcuts['pppoes']['log'] = "status_logs_vpn.php?vpntype=poes";
|
285
|
|
286
|
$shortcuts['l2tps'] = array();
|
287
|
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
|
288
|
$shortcuts['l2tps']['log'] = "status_logs_vpn.php?vpntype=l2tp";
|
289
|
|
290
|
$shortcuts['carp'] = array();
|
291
|
$shortcuts['carp']['main'] = "system_hasync.php";
|
292
|
$shortcuts['carp']['status'] = "status_carp.php";
|
293
|
|
294
|
$shortcuts['snmp'] = array();
|
295
|
$shortcuts['snmp']['main'] = "services_snmp.php";
|
296
|
$shortcuts['snmp']['service'] = "bsnmpd";
|
297
|
|
298
|
$shortcuts['syslogd'] = array();
|
299
|
$shortcuts['syslogd']['main'] = "status_logs_settings.php";
|
300
|
$shortcuts['syslogd']['log'] = "status_logs.php";
|
301
|
$shortcuts['syslogd']['service'] = "syslogd";
|
302
|
|
303
|
$shortcuts['authentication'] = array();
|
304
|
$shortcuts['authentication']['main'] = "system_authservers.php";
|
305
|
// $shortcuts['authentication']['status'] = "diag_authentication.php";
|
306
|
|
307
|
$shortcuts['aliases'] = array();
|
308
|
$shortcuts['aliases']['main'] = "firewall_aliases.php";
|
309
|
$shortcuts['aliases']['status'] = "diag_tables.php";
|
310
|
?>
|