1 |
76692ad2
|
jim-p
|
<?php
|
2 |
0f5d612a
|
jim-p
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
Copyright (C) 2012 Jim Pingle
|
5 |
|
|
All rights reserved.
|
6 |
|
|
|
7 |
|
|
Copyright (C) 2007, 2008 Scott Ullrich <sullrich@gmail.com>
|
8 |
|
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
|
31 |
|
|
*/
|
32 |
|
|
|
33 |
|
|
/*
|
34 |
|
|
pfSense_MODULE: system
|
35 |
|
|
*/
|
36 |
|
|
|
37 |
9990b70c
|
jim-p
|
// On the page, add in like so:
|
38 |
|
|
// $shortcut_section = "relayd";
|
39 |
|
|
|
40 |
e3ffa8d4
|
jim-p
|
$shortcuts = array();
|
41 |
|
|
|
42 |
0f5d612a
|
jim-p
|
/* Load and process custom shortcuts. */
|
43 |
|
|
function get_shortcut_files($directory) {
|
44 |
|
|
$dir_array = array();
|
45 |
0bf1e5fe
|
Sjon Hortensius
|
if(!is_dir($directory))
|
46 |
0f5d612a
|
jim-p
|
return;
|
47 |
|
|
if ($dh = opendir($directory)) {
|
48 |
|
|
while (($file = readdir($dh)) !== false) {
|
49 |
|
|
$canadd = 0;
|
50 |
0bf1e5fe
|
Sjon Hortensius
|
if($file == ".")
|
51 |
0f5d612a
|
jim-p
|
$canadd = 1;
|
52 |
0bf1e5fe
|
Sjon Hortensius
|
if($file == "..")
|
53 |
0f5d612a
|
jim-p
|
$canadd = 1;
|
54 |
|
|
if($canadd == 0)
|
55 |
|
|
array_push($dir_array, $file);
|
56 |
|
|
}
|
57 |
|
|
closedir($dh);
|
58 |
|
|
}
|
59 |
|
|
if(!is_array($dir_array))
|
60 |
|
|
return;
|
61 |
|
|
return $dir_array;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
391abfcf
|
jim-p
|
function get_shortcut_by_service_name($servicename) {
|
65 |
|
|
global $shortcuts;
|
66 |
|
|
foreach ($shortcuts as $name => $shortcut) {
|
67 |
|
|
if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename))
|
68 |
|
|
return $name;
|
69 |
|
|
}
|
70 |
|
|
return null;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
|
74 |
|
|
global $g, $shortcuts;
|
75 |
|
|
if(empty($shortcut_section))
|
76 |
|
|
return "";
|
77 |
|
|
$space = ($addspace) ? " " : "" ;
|
78 |
|
|
switch ($shortcut_section) {
|
79 |
|
|
case "openvpn":
|
80 |
|
|
if (!empty($service['mode']) && is_numeric($service['id']))
|
81 |
b3733e10
|
Colin Fleming
|
$link = "vpn_openvpn_{$service['mode']}.php?act=edit&id={$service['id']}";
|
82 |
391abfcf
|
jim-p
|
else
|
83 |
|
|
$link = $shortcuts[$shortcut_section]['main'];
|
84 |
|
|
break;
|
85 |
|
|
case "captiveportal":
|
86 |
|
|
if (!empty($service['zone']))
|
87 |
|
|
$link = "services_captiveportal.php?zone={$service['zone']}";
|
88 |
|
|
else
|
89 |
|
|
$link = $shortcuts[$shortcut_section]['main'];
|
90 |
|
|
break;
|
91 |
|
|
default:
|
92 |
|
|
$link = $shortcuts[$shortcut_section]['main'];
|
93 |
|
|
break;
|
94 |
|
|
}
|
95 |
be9c20c7
|
jim-p
|
if(!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}"))
|
96 |
0bf1e5fe
|
Sjon Hortensius
|
return "{$space}<a href=\"{$link}\" title=\"" . gettext("Main page for this section") . "\"><i class=\"icon icon-home\"></i></a>";
|
97 |
391abfcf
|
jim-p
|
}
|
98 |
|
|
|
99 |
|
|
function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
|
100 |
|
|
global $g, $shortcuts, $cpzone;
|
101 |
|
|
if(empty($shortcut_section))
|
102 |
|
|
return "";
|
103 |
|
|
$space = ($addspace) ? " " : "" ;
|
104 |
|
|
if (!empty($cpzone))
|
105 |
|
|
$zone = $cpzone;
|
106 |
|
|
elseif (!empty($service['zone']))
|
107 |
|
|
$zone = $service['zone'];
|
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 |
|
|
break;
|
115 |
|
|
default:
|
116 |
|
|
$link = $shortcuts[$shortcut_section]['status'];
|
117 |
|
|
break;
|
118 |
|
|
}
|
119 |
|
|
if(!empty($link))
|
120 |
0bf1e5fe
|
Sjon Hortensius
|
return "{$space}<a href=\"{$link}\" title=\"" . gettext("Status of items on this page") . "\"><i class=\"icon icon-wrench\"></i></a>";
|
121 |
391abfcf
|
jim-p
|
}
|
122 |
|
|
|
123 |
|
|
function get_shortcut_log_link($shortcut_section, $addspace = true) {
|
124 |
|
|
global $g, $shortcuts;
|
125 |
|
|
$space = ($addspace) ? " " : "" ;
|
126 |
|
|
if(!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
|
127 |
0bf1e5fe
|
Sjon Hortensius
|
return "{$space}<a href=\"{$shortcuts[$shortcut_section]['log']}\" title=\"" . gettext("Log entries for items on this page") . "\"><i class=\"icon icon-list-alt\"></i></a>";
|
128 |
391abfcf
|
jim-p
|
}
|
129 |
|
|
}
|
130 |
|
|
|
131 |
0f5d612a
|
jim-p
|
// Load shortcuts
|
132 |
|
|
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
|
133 |
0bf1e5fe
|
Sjon Hortensius
|
foreach ($dir_array as $file)
|
134 |
|
|
if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file,".inc"))
|
135 |
0f5d612a
|
jim-p
|
include("/usr/local/www/shortcuts/{$file}");
|
136 |
|
|
if(is_dir("/usr/local/pkg/shortcuts")) {
|
137 |
|
|
$dir_array = get_shortcut_files("/usr/local/pkg/shortcuts");
|
138 |
0bf1e5fe
|
Sjon Hortensius
|
foreach ($dir_array as $file)
|
139 |
|
|
if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file,".inc"))
|
140 |
0f5d612a
|
jim-p
|
include("/usr/local/pkg/shortcuts/{$file}");
|
141 |
|
|
}
|
142 |
|
|
|
143 |
79696dea
|
jim-p
|
$shortcuts['relayd'] = array();
|
144 |
226c43a5
|
jim-p
|
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
|
145 |
76692ad2
|
jim-p
|
$shortcuts['relayd']['log'] = "diag_logs_relayd.php";
|
146 |
|
|
$shortcuts['relayd']['status'] = "status_lb_pool.php";
|
147 |
|
|
$shortcuts['relayd']['service'] = "relayd";
|
148 |
|
|
|
149 |
79696dea
|
jim-p
|
$shortcuts['relayd-virtualservers'] = array();
|
150 |
226c43a5
|
jim-p
|
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
|
151 |
76692ad2
|
jim-p
|
$shortcuts['relayd-virtualservers']['log'] = "diag_logs_relayd.php";
|
152 |
|
|
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
|
153 |
79696dea
|
jim-p
|
$shortcuts['relayd-virtualservers']['service'] = "relayd";
|
154 |
76692ad2
|
jim-p
|
|
155 |
79696dea
|
jim-p
|
$shortcuts['captiveportal'] = array();
|
156 |
226c43a5
|
jim-p
|
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
|
157 |
76692ad2
|
jim-p
|
$shortcuts['captiveportal']['log'] = "diag_logs_auth.php";
|
158 |
|
|
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
|
159 |
e38d34b4
|
jim-p
|
$shortcuts['captiveportal']['service'] = "captiveportal";
|
160 |
79696dea
|
jim-p
|
|
161 |
|
|
$shortcuts['captiveportal-vouchers'] = array();
|
162 |
76692ad2
|
jim-p
|
$shortcuts['captiveportal-vouchers']['log'] = "diag_logs_auth.php";
|
163 |
|
|
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
|
164 |
e38d34b4
|
jim-p
|
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
|
165 |
76692ad2
|
jim-p
|
|
166 |
79696dea
|
jim-p
|
$shortcuts['dhcp'] = array();
|
167 |
226c43a5
|
jim-p
|
$shortcuts['dhcp']['main'] = "services_dhcp.php";
|
168 |
76692ad2
|
jim-p
|
$shortcuts['dhcp']['log'] = "diag_logs_dhcp.php";
|
169 |
|
|
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
|
170 |
|
|
$shortcuts['dhcp']['service'] = "dhcpd";
|
171 |
|
|
|
172 |
79696dea
|
jim-p
|
$shortcuts['dhcp6'] = array();
|
173 |
226c43a5
|
jim-p
|
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
|
174 |
76692ad2
|
jim-p
|
$shortcuts['dhcp6']['log'] = "diag_logs_dhcp.php";
|
175 |
|
|
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
|
176 |
|
|
|
177 |
79696dea
|
jim-p
|
|
178 |
|
|
$shortcuts['ipsec'] = array();
|
179 |
226c43a5
|
jim-p
|
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
|
180 |
76692ad2
|
jim-p
|
$shortcuts['ipsec']['log'] = "diag_logs_ipsec.php";
|
181 |
|
|
$shortcuts['ipsec']['status'] = "diag_ipsec.php";
|
182 |
fe3f3998
|
jim-p
|
$shortcuts['ipsec']['service'] = "ipsec";
|
183 |
76692ad2
|
jim-p
|
|
184 |
79696dea
|
jim-p
|
$shortcuts['openvpn'] = array();
|
185 |
226c43a5
|
jim-p
|
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
|
186 |
76692ad2
|
jim-p
|
$shortcuts['openvpn']['log'] = "diag_logs_openvpn.php";
|
187 |
|
|
$shortcuts['openvpn']['status'] = "status_openvpn.php";
|
188 |
6d9b1074
|
jim-p
|
$shortcuts['openvpn']['service'] = "openvpn";
|
189 |
76692ad2
|
jim-p
|
|
190 |
79696dea
|
jim-p
|
$shortcuts['firewall'] = array();
|
191 |
226c43a5
|
jim-p
|
$shortcuts['firewall']['main'] = "firewall_rules.php";
|
192 |
76692ad2
|
jim-p
|
$shortcuts['firewall']['log'] = "diag_logs_filter.php";
|
193 |
|
|
$shortcuts['firewall']['status'] = "status_filter_reload.php";
|
194 |
|
|
|
195 |
79696dea
|
jim-p
|
$shortcuts['routing'] = array();
|
196 |
226c43a5
|
jim-p
|
$shortcuts['routing']['main'] = "system_routes.php";
|
197 |
76692ad2
|
jim-p
|
$shortcuts['routing']['log'] = "diag_logs_routing.php";
|
198 |
|
|
$shortcuts['routing']['status'] = "diag_routes.php";
|
199 |
|
|
|
200 |
79696dea
|
jim-p
|
$shortcuts['gateways'] = array();
|
201 |
226c43a5
|
jim-p
|
$shortcuts['gateways']['main'] = "system_gateways.php";
|
202 |
76692ad2
|
jim-p
|
$shortcuts['gateways']['log'] = "diag_logs_gateways.php";
|
203 |
|
|
$shortcuts['gateways']['status'] = "status_gateways.php";
|
204 |
b05a8f35
|
jim-p
|
$shortcuts['gateways']['service'] = "apinger";
|
205 |
79696dea
|
jim-p
|
|
206 |
|
|
$shortcuts['gateway-groups'] = array();
|
207 |
226c43a5
|
jim-p
|
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
|
208 |
76692ad2
|
jim-p
|
$shortcuts['gateway-groups']['log'] = "diag_logs_gateways.php";
|
209 |
|
|
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
|
210 |
|
|
|
211 |
79696dea
|
jim-p
|
$shortcuts['interfaces'] = array();
|
212 |
226c43a5
|
jim-p
|
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
|
213 |
76692ad2
|
jim-p
|
$shortcuts['interfaces']['status'] = "status_interfaces.php";
|
214 |
|
|
|
215 |
79696dea
|
jim-p
|
$shortcuts['trafficshaper'] = array();
|
216 |
226c43a5
|
jim-p
|
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
|
217 |
76692ad2
|
jim-p
|
$shortcuts['trafficshaper']['status'] = "status_queues.php";
|
218 |
|
|
|
219 |
d71fc5d3
|
jim-p
|
$shortcuts['trafficshaper-limiters'] = array();
|
220 |
|
|
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
|
221 |
|
|
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
|
222 |
|
|
|
223 |
db88a3a2
|
Phil Davis
|
$shortcuts['forwarder'] = array();
|
224 |
|
|
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
|
225 |
|
|
$shortcuts['forwarder']['log'] = "diag_logs_resolver.php";
|
226 |
|
|
$shortcuts['forwarder']['service'] = "dnsmasq";
|
227 |
|
|
|
228 |
0143e77b
|
bcyrill
|
$shortcuts['resolver'] = array();
|
229 |
db88a3a2
|
Phil Davis
|
$shortcuts['resolver']['main'] = "services_unbound.php";
|
230 |
76692ad2
|
jim-p
|
$shortcuts['resolver']['log'] = "diag_logs_resolver.php";
|
231 |
db88a3a2
|
Phil Davis
|
$shortcuts['resolver']['service'] = "unbound";
|
232 |
6bb9db05
|
Renato Botelho
|
|
233 |
0143e77b
|
bcyrill
|
$shortcuts['wireless'] = array();
|
234 |
226c43a5
|
jim-p
|
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
|
235 |
76692ad2
|
jim-p
|
$shortcuts['wireless']['log'] = "diag_logs_wireless.php";
|
236 |
|
|
$shortcuts['wireless']['status'] = "status_wireless.php";
|
237 |
|
|
|
238 |
79696dea
|
jim-p
|
$shortcuts['ntp'] = array();
|
239 |
226c43a5
|
jim-p
|
$shortcuts['ntp']['main'] = "services_ntpd.php";
|
240 |
76692ad2
|
jim-p
|
$shortcuts['ntp']['log'] = "diag_logs_ntpd.php";
|
241 |
|
|
$shortcuts['ntp']['status'] = "status_ntpd.php";
|
242 |
|
|
$shortcuts['ntp']['service'] = "ntpd";
|
243 |
|
|
|
244 |
79696dea
|
jim-p
|
$shortcuts['pptps'] = array();
|
245 |
226c43a5
|
jim-p
|
$shortcuts['pptps']['main'] = "vpn_pptp.php";
|
246 |
76692ad2
|
jim-p
|
$shortcuts['pptps']['log'] = "diag_logs_vpn.php";
|
247 |
|
|
|
248 |
79696dea
|
jim-p
|
$shortcuts['pppoes'] = array();
|
249 |
226c43a5
|
jim-p
|
$shortcuts['pppoes']['main'] = "vpn_pppoe.php";
|
250 |
76692ad2
|
jim-p
|
$shortcuts['pppoes']['log'] = "diag_logs_vpn.php?vpntype=poes";
|
251 |
|
|
|
252 |
79696dea
|
jim-p
|
$shortcuts['l2tps'] = array();
|
253 |
226c43a5
|
jim-p
|
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
|
254 |
76692ad2
|
jim-p
|
$shortcuts['l2tps']['log'] = "diag_logs_vpn.php?vpntype=l2tp";
|
255 |
|
|
|
256 |
79696dea
|
jim-p
|
$shortcuts['carp'] = array();
|
257 |
226c43a5
|
jim-p
|
$shortcuts['carp']['main'] = "system_hasync.php";
|
258 |
76692ad2
|
jim-p
|
$shortcuts['carp']['status'] = "carp_status.php";
|
259 |
d71fc5d3
|
jim-p
|
|
260 |
|
|
$shortcuts['snmp'] = array();
|
261 |
|
|
$shortcuts['snmp']['main'] = "services_snmp.php";
|
262 |
|
|
$shortcuts['snmp']['service'] = "bsnmpd";
|
263 |
|
|
|
264 |
|
|
$shortcuts['authentication'] = array();
|
265 |
|
|
$shortcuts['authentication']['main'] = "system_authservers.php";
|
266 |
|
|
$shortcuts['authentication']['status'] = "diag_authentication.php";
|
267 |
|
|
|
268 |
|
|
$shortcuts['aliases'] = array();
|
269 |
|
|
$shortcuts['aliases']['main'] = "firewall_aliases.php";
|
270 |
|
|
$shortcuts['aliases']['status'] = "diag_tables.php";
|
271 |
6bb9db05
|
Renato Botelho
|
?>
|