Project

General

Profile

Download (11.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	shortcuts.inc
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *
8
 *	Redistribution and use in source and binary forms, with or without modification,
9
 *	are permitted provided that the following conditions are met:
10
 *
11
 *	1. Redistributions of source code must retain the above copyright notice,
12
 *		this list of conditions and the following disclaimer.
13
 *
14
 *	2. Redistributions in binary form must reproduce the above copyright
15
 *		notice, this list of conditions and the following disclaimer in
16
 *		the documentation and/or other materials provided with the
17
 *		distribution.
18
 *
19
 *	3. All advertising materials mentioning features or use of this software
20
 *		must display the following acknowledgment:
21
 *		"This product includes software developed by the pfSense Project
22
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
23
 *
24
 *	4. The names "pfSense" and "pfSense Project" must not be used to
25
 *		 endorse or promote products derived from this software without
26
 *		 prior written permission. For written permission, please contact
27
 *		 coreteam@pfsense.org.
28
 *
29
 *	5. Products derived from this software may not be called "pfSense"
30
 *		nor may "pfSense" appear in their names without prior written
31
 *		permission of the Electric Sheep Fencing, LLC.
32
 *
33
 *	6. Redistributions of any form whatsoever must retain the following
34
 *		acknowledgment:
35
 *
36
 *	"This product includes software developed by the pfSense Project
37
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
38
 *
39
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
40
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
43
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
51
 *
52
 *	====================================================================
53
 *
54
 */
55

    
56
// On the page, add in like so:
57
//   $shortcut_section = "relayd";
58

    
59
$shortcuts = array();
60

    
61
/* Load and process custom shortcuts. */
62
function get_shortcut_files($directory) {
63
	$dir_array = array();
64
	if (!is_dir($directory)) {
65
		return;
66
	}
67
	if ($dh = opendir($directory)) {
68
		while (($file = readdir($dh)) !== false) {
69
			$canadd = 0;
70
			if ($file == ".") {
71
				$canadd = 1;
72
			}
73
			if ($file == "..") {
74
				$canadd = 1;
75
			}
76
			if ($canadd == 0) {
77
				array_push($dir_array, $file);
78
			}
79
		}
80
		closedir($dh);
81
	}
82
	if (!is_array($dir_array)) {
83
		return;
84
	}
85
	return $dir_array;
86
}
87

    
88
function get_shortcut_by_service_name($servicename) {
89
	global $shortcuts;
90
	foreach ($shortcuts as $name => $shortcut) {
91
		if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename)) {
92
			return $name;
93
		}
94
	}
95
	return null;
96
}
97

    
98
function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
99
	global $g, $shortcuts;
100
	if (empty($shortcut_section)) {
101
		return "";
102
	}
103
	$space = ($addspace) ? "&nbsp;" : "" ;
104
	switch ($shortcut_section) {
105
		case "openvpn":
106
			if (!empty($service['mode']) && is_numeric($service['id'])) {
107
				$link = "vpn_openvpn_{$service['mode']}.php?act=edit&amp;id={$service['id']}";
108
			} else {
109
				$link = $shortcuts[$shortcut_section]['main'];
110
			}
111
			break;
112
		case "captiveportal":
113
			if (!empty($service['zone'])) {
114
				$link = "services_captiveportal.php?zone={$service['zone']}";
115
			} else {
116
				$link = $shortcuts[$shortcut_section]['main'];
117
			}
118
			break;
119
		default:
120
			$link = $shortcuts[$shortcut_section]['main'];
121
			break;
122
	}
123
	if (!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}")) {
124
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Related settings") . "\"><i class=\"fa fa-sliders\"></i></a>";
125
	}
126
}
127

    
128
function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
129
	global $g, $shortcuts, $cpzone;
130
	if (empty($shortcut_section)) {
131
		return "";
132
	}
133
	$space = ($addspace) ? "&nbsp;" : "" ;
134
	if (!empty($cpzone)) {
135
		$zone = $cpzone;
136
	} elseif (!empty($service['zone'])) {
137
		$zone = $service['zone'];
138
	}
139
	switch ($shortcut_section) {
140
		case "captiveportal":
141
			if (!empty($zone)) {
142
				$link = "status_captiveportal.php?zone={$zone}";
143
			} else {
144
				$link = $shortcuts[$shortcut_section]['status'];
145
			}
146
			break;
147
		default:
148
			$link = $shortcuts[$shortcut_section]['status'];
149
			break;
150
	}
151
	if (!empty($link)) {
152
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Related status") . "\"><i class=\"fa fa-cog\"></i></a>";
153
	}
154
}
155

    
156
function get_shortcut_log_link($shortcut_section, $addspace = true) {
157
	global $g, $shortcuts;
158
	$space = ($addspace) ? "&nbsp;" : "" ;
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
}
163

    
164
// Load shortcuts
165
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
166
foreach ($dir_array as $file) {
167
	if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file, ".inc")) {
168
		include("/usr/local/www/shortcuts/{$file}");
169
	}
170
}
171
if (is_dir("/usr/local/pkg/shortcuts")) {
172
	$dir_array = get_shortcut_files("/usr/local/pkg/shortcuts");
173
	foreach ($dir_array as $file) {
174
		if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file, ".inc")) {
175
			include("/usr/local/pkg/shortcuts/{$file}");
176
		}
177
	}
178
}
179

    
180
$shortcuts['relayd'] = array();
181
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
182
$shortcuts['relayd']['log'] = "status_logs.php?logfile=relayd";
183
$shortcuts['relayd']['status'] = "status_lb_pool.php";
184
$shortcuts['relayd']['service'] = "relayd";
185

    
186
$shortcuts['relayd-virtualservers'] = array();
187
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
188
$shortcuts['relayd-virtualservers']['log'] = "status_logs.php?logfile=relayd";
189
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
190
$shortcuts['relayd-virtualservers']['service'] = "relayd";
191

    
192
$shortcuts['captiveportal'] = array();
193
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
194
$shortcuts['captiveportal']['log'] = "status_logs.php?logfile=portalauth";
195
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
196
$shortcuts['captiveportal']['service'] = "captiveportal";
197

    
198
$shortcuts['captiveportal-vouchers'] = array();
199
$shortcuts['captiveportal-vouchers']['log'] = "status_logs.php?logfile=auth";
200
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
201
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
202

    
203
$shortcuts['dhcp'] = array();
204
$shortcuts['dhcp']['main'] = "services_dhcp.php";
205
$shortcuts['dhcp']['log'] = "status_logs.php?logfile=dhcpd";
206
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
207
$shortcuts['dhcp']['service'] = "dhcpd";
208

    
209
$shortcuts['dhcp6'] = array();
210
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
211
$shortcuts['dhcp6']['log'] = "status_logs.php?logfile=dhcp";
212
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
213

    
214

    
215
$shortcuts['ipsec'] = array();
216
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
217
$shortcuts['ipsec']['log'] = "status_logs.php?logfile=ipsec";
218
$shortcuts['ipsec']['status'] = "status_ipsec.php";
219
$shortcuts['ipsec']['service'] = "ipsec";
220

    
221
$shortcuts['openvpn'] = array();
222
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
223
$shortcuts['openvpn']['log'] = "status_logs.php?logfile=openvpn";
224
$shortcuts['openvpn']['status'] = "status_openvpn.php";
225
$shortcuts['openvpn']['service'] = "openvpn";
226

    
227
$shortcuts['firewall'] = array();
228
$shortcuts['firewall']['main'] = "firewall_rules.php";
229
$shortcuts['firewall']['log'] = "status_logs_filter.php";
230
$shortcuts['firewall']['status'] = "status_filter_reload.php";
231

    
232
$shortcuts['routing'] = array();
233
$shortcuts['routing']['main'] = "system_routes.php";
234
$shortcuts['routing']['log'] = "status_logs.php?logfile=routing";
235
$shortcuts['routing']['status'] = "diag_routes.php";
236

    
237
$shortcuts['gateways'] = array();
238
$shortcuts['gateways']['main'] = "system_gateways.php";
239
$shortcuts['gateways']['log'] = "status_logs.php?logfile=gateways";
240
$shortcuts['gateways']['status'] = "status_gateways.php";
241
$shortcuts['gateways']['service'] = "dpinger";
242

    
243
$shortcuts['gateway-groups'] = array();
244
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
245
$shortcuts['gateway-groups']['log'] = "status_logs.php?logfile=gateways";
246
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
247

    
248
$shortcuts['interfaces'] = array();
249
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
250
$shortcuts['interfaces']['status'] = "status_interfaces.php";
251

    
252
$shortcuts['trafficshaper'] = array();
253
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
254
$shortcuts['trafficshaper']['status'] = "status_queues.php";
255

    
256
$shortcuts['trafficshaper-limiters'] = array();
257
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
258
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
259

    
260
$shortcuts['forwarder'] = array();
261
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
262
$shortcuts['forwarder']['log'] = "status_logs.php?logfile=resolver";
263
$shortcuts['forwarder']['service'] = "dnsmasq";
264

    
265
$shortcuts['resolver'] = array();
266
$shortcuts['resolver']['main'] = "services_unbound.php";
267
$shortcuts['resolver']['log'] = "status_logs.php?logfile=resolver";
268
$shortcuts['resolver']['service'] = "unbound";
269

    
270
$shortcuts['wireless'] = array();
271
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
272
$shortcuts['wireless']['log'] = "status_logs.php?logfile=wireless";
273
$shortcuts['wireless']['status'] = "status_wireless.php";
274

    
275
$shortcuts['ntp'] = array();
276
$shortcuts['ntp']['main'] = "services_ntpd.php";
277
$shortcuts['ntp']['log'] = "status_logs.php?logfile=ntpd";
278
$shortcuts['ntp']['status'] = "status_ntpd.php";
279
$shortcuts['ntp']['service'] = "ntpd";
280

    
281
$shortcuts['pptps'] = array();
282
$shortcuts['pptps']['main'] = "vpn_pptp.php";
283
$shortcuts['pptps']['log'] = "status_logs_vpn.php";
284

    
285
$shortcuts['pppoes'] = array();
286
$shortcuts['pppoes']['main'] = "services_pppoe.php";
287
$shortcuts['pppoes']['log'] = "status_logs_vpn.php?vpntype=poes";
288

    
289
$shortcuts['l2tps'] = array();
290
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
291
$shortcuts['l2tps']['log'] = "status_logs_vpn.php?vpntype=l2tp";
292

    
293
$shortcuts['carp'] = array();
294
$shortcuts['carp']['main'] = "system_hasync.php";
295
$shortcuts['carp']['status'] = "carp_status.php";
296

    
297
$shortcuts['snmp'] = array();
298
$shortcuts['snmp']['main'] = "services_snmp.php";
299
$shortcuts['snmp']['service'] = "bsnmpd";
300

    
301
$shortcuts['authentication'] = array();
302
$shortcuts['authentication']['main'] = "system_authservers.php";
303
$shortcuts['authentication']['status'] = "diag_authentication.php";
304

    
305
$shortcuts['aliases'] = array();
306
$shortcuts['aliases']['main'] = "firewall_aliases.php";
307
$shortcuts['aliases']['status'] = "diag_tables.php";
308
?>
(147-147/229)