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