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
	pfSense_MODULE:	system
57
*/
58

    
59
// On the page, add in like so:
60
//   $shortcut_section = "relayd";
61

    
62
$shortcuts = array();
63

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

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

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

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

    
159
function get_shortcut_log_link($shortcut_section, $addspace = true) {
160
	global $g, $shortcuts;
161
	$space = ($addspace) ? "&nbsp;" : "" ;
162
	if (!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
163
		return "{$space}<a href=\"{$shortcuts[$shortcut_section]['log']}\" title=\"" . gettext("Log entries for items on this page") . "\"><i class=\"icon-large icon-list-alt\"></i></a>";
164
	}
165
}
166

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

    
183
$shortcuts['relayd'] = array();
184
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
185
$shortcuts['relayd']['log'] = "diag_logs.php?logfile=relayd";
186
$shortcuts['relayd']['status'] = "status_lb_pool.php";
187
$shortcuts['relayd']['service'] = "relayd";
188

    
189
$shortcuts['relayd-virtualservers'] = array();
190
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
191
$shortcuts['relayd-virtualservers']['log'] = "diag_logs.php?logfile=relayd";
192
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
193
$shortcuts['relayd-virtualservers']['service'] = "relayd";
194

    
195
$shortcuts['captiveportal'] = array();
196
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
197
$shortcuts['captiveportal']['log'] = "diag_logs.php?logfile=auth";
198
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
199
$shortcuts['captiveportal']['service'] = "captiveportal";
200

    
201
$shortcuts['captiveportal-vouchers'] = array();
202
$shortcuts['captiveportal-vouchers']['log'] = "diag_logs.php?logfile=auth";
203
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
204
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
205

    
206
$shortcuts['dhcp'] = array();
207
$shortcuts['dhcp']['main'] = "services_dhcp.php";
208
$shortcuts['dhcp']['log'] = "diag_logs.php?logfile=dhcp";
209
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
210
$shortcuts['dhcp']['service'] = "dhcpd";
211

    
212
$shortcuts['dhcp6'] = array();
213
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
214
$shortcuts['dhcp6']['log'] = "diag_logs.php?logfile=dhcp";
215
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
216

    
217

    
218
$shortcuts['ipsec'] = array();
219
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
220
$shortcuts['ipsec']['log'] = "diag_logs.php?logfile=ipsec";
221
$shortcuts['ipsec']['status'] = "diag_ipsec.php";
222
$shortcuts['ipsec']['service'] = "ipsec";
223

    
224
$shortcuts['openvpn'] = array();
225
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
226
$shortcuts['openvpn']['log'] = "diag_logs.php?logfile=openvpn";
227
$shortcuts['openvpn']['status'] = "status_openvpn.php";
228
$shortcuts['openvpn']['service'] = "openvpn";
229

    
230
$shortcuts['firewall'] = array();
231
$shortcuts['firewall']['main'] = "firewall_rules.php";
232
$shortcuts['firewall']['log'] = "diag_logs_filter.php";
233
$shortcuts['firewall']['status'] = "status_filter_reload.php";
234

    
235
$shortcuts['routing'] = array();
236
$shortcuts['routing']['main'] = "system_routes.php";
237
$shortcuts['routing']['log'] = "diag_logs.php?logfile=routing";
238
$shortcuts['routing']['status'] = "diag_routes.php";
239

    
240
$shortcuts['gateways'] = array();
241
$shortcuts['gateways']['main'] = "system_gateways.php";
242
$shortcuts['gateways']['log'] = "diag_logs.php?logfile=gateways";
243
$shortcuts['gateways']['status'] = "status_gateways.php";
244
$shortcuts['gateways']['service'] = "apinger";
245

    
246
$shortcuts['gateway-groups'] = array();
247
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
248
$shortcuts['gateway-groups']['log'] = "diag_logs.php?logfile=gateways";
249
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
250

    
251
$shortcuts['interfaces'] = array();
252
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
253
$shortcuts['interfaces']['status'] = "status_interfaces.php";
254

    
255
$shortcuts['trafficshaper'] = array();
256
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
257
$shortcuts['trafficshaper']['status'] = "status_queues.php";
258

    
259
$shortcuts['trafficshaper-limiters'] = array();
260
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
261
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
262

    
263
$shortcuts['forwarder'] = array();
264
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
265
$shortcuts['forwarder']['log'] = "diag_logs.php?logfile=resolver";
266
$shortcuts['forwarder']['service'] = "dnsmasq";
267

    
268
$shortcuts['resolver'] = array();
269
$shortcuts['resolver']['main'] = "services_unbound.php";
270
$shortcuts['resolver']['log'] = "diag_logs.php?logfile=resolver";
271
$shortcuts['resolver']['service'] = "unbound";
272

    
273
$shortcuts['wireless'] = array();
274
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
275
$shortcuts['wireless']['log'] = "diag_logs.php?logfile=wireless";
276
$shortcuts['wireless']['status'] = "status_wireless.php";
277

    
278
$shortcuts['ntp'] = array();
279
$shortcuts['ntp']['main'] = "services_ntpd.php";
280
$shortcuts['ntp']['log'] = "diag_logs.php?logfile=ntpd";
281
$shortcuts['ntp']['status'] = "status_ntpd.php";
282
$shortcuts['ntp']['service'] = "ntpd";
283

    
284
$shortcuts['pptps'] = array();
285
$shortcuts['pptps']['main'] = "vpn_pptp.php";
286
$shortcuts['pptps']['log'] = "diag_logs_vpn.php";
287

    
288
$shortcuts['pppoes'] = array();
289
$shortcuts['pppoes']['main'] = "vpn_pppoe.php";
290
$shortcuts['pppoes']['log'] = "diag_logs_vpn.php?vpntype=poes";
291

    
292
$shortcuts['l2tps'] = array();
293
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
294
$shortcuts['l2tps']['log'] = "diag_logs_vpn.php?vpntype=l2tp";
295

    
296
$shortcuts['carp'] = array();
297
$shortcuts['carp']['main'] = "system_hasync.php";
298
$shortcuts['carp']['status'] = "carp_status.php";
299

    
300
$shortcuts['snmp'] = array();
301
$shortcuts['snmp']['main'] = "services_snmp.php";
302
$shortcuts['snmp']['service'] = "bsnmpd";
303

    
304
$shortcuts['authentication'] = array();
305
$shortcuts['authentication']['main'] = "system_authservers.php";
306
$shortcuts['authentication']['status'] = "diag_authentication.php";
307

    
308
$shortcuts['aliases'] = array();
309
$shortcuts['aliases']['main'] = "firewall_aliases.php";
310
$shortcuts['aliases']['status'] = "diag_tables.php";
311
?>
(159-159/234)