Project

General

Profile

Download (10 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $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
// On the page, add in like so:
38
//   $shortcut_section = "relayd";
39

    
40
$shortcuts = array();
41

    
42
/* Load and process custom shortcuts. */
43
function get_shortcut_files($directory) {
44
	$dir_array = array();
45
	if (!is_dir($directory)) {
46
		return;
47
	}
48
	if ($dh = opendir($directory)) {
49
		while (($file = readdir($dh)) !== false) {
50
			$canadd = 0;
51
			if ($file == ".") {
52
				$canadd = 1;
53
			}
54
			if ($file == "..") {
55
				$canadd = 1;
56
			}
57
			if ($canadd == 0) {
58
				array_push($dir_array, $file);
59
			}
60
		}
61
		closedir($dh);
62
	}
63
	if (!is_array($dir_array)) {
64
		return;
65
	}
66
	return $dir_array;
67
}
68

    
69
function get_shortcut_by_service_name($servicename) {
70
	global $shortcuts;
71
	foreach ($shortcuts as $name => $shortcut) {
72
		if (!empty($shortcut['service']) && ($shortcut['service'] == $servicename)) {
73
			return $name;
74
		}
75
	}
76
	return null;
77
}
78

    
79
function get_shortcut_main_link($shortcut_section, $addspace = true, $service = array()) {
80
	global $g, $shortcuts;
81
	if (empty($shortcut_section)) {
82
		return "";
83
	}
84
	$space = ($addspace) ? "&nbsp;" : "" ;
85
	switch ($shortcut_section) {
86
		case "openvpn":
87
			if (!empty($service['mode']) && is_numeric($service['id'])) {
88
				$link = "vpn_openvpn_{$service['mode']}.php?act=edit&amp;id={$service['id']}";
89
			} else {
90
				$link = $shortcuts[$shortcut_section]['main'];
91
			}
92
			break;
93
		case "captiveportal":
94
			if (!empty($service['zone'])) {
95
				$link = "services_captiveportal.php?zone={$service['zone']}";
96
			} else {
97
				$link = $shortcuts[$shortcut_section]['main'];
98
			}
99
			break;
100
		default:
101
			$link = $shortcuts[$shortcut_section]['main'];
102
			break;
103
	}
104
	if (!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}")) {
105
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Main page for this section") . "\"><i class=\"icon-large icon-plus-sign\"></i></a>";
106
	}
107
}
108

    
109
function get_shortcut_status_link($shortcut_section, $addspace = true, $service = array()) {
110
	global $g, $shortcuts, $cpzone;
111
	if (empty($shortcut_section)) {
112
		return "";
113
	}
114
	$space = ($addspace) ? "&nbsp;" : "" ;
115
	if (!empty($cpzone)) {
116
		$zone = $cpzone;
117
	} elseif (!empty($service['zone'])) {
118
		$zone = $service['zone'];
119
	}
120
	switch ($shortcut_section) {
121
		case "captiveportal":
122
			if (!empty($zone)) {
123
				$link = "status_captiveportal.php?zone={$zone}";
124
			} else {
125
				$link = $shortcuts[$shortcut_section]['status'];
126
			}
127
			break;
128
		default:
129
			$link = $shortcuts[$shortcut_section]['status'];
130
			break;
131
	}
132
	if (!empty($link)) {
133
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Status of items on this page") . "\"><i class=\"icon-large icon-cog\"></i></a>";
134
	}
135
}
136

    
137
function get_shortcut_log_link($shortcut_section, $addspace = true) {
138
	global $g, $shortcuts;
139
	$space = ($addspace) ? "&nbsp;" : "" ;
140
	if (!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
141
		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>";
142
	}
143
}
144

    
145
// Load shortcuts
146
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
147
foreach ($dir_array as $file) {
148
	if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file, ".inc")) {
149
		include("/usr/local/www/shortcuts/{$file}");
150
	}
151
}
152
if (is_dir("/usr/local/pkg/shortcuts")) {
153
	$dir_array = get_shortcut_files("/usr/local/pkg/shortcuts");
154
	foreach ($dir_array as $file) {
155
		if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file, ".inc")) {
156
			include("/usr/local/pkg/shortcuts/{$file}");
157
		}
158
	}
159
}
160

    
161
$shortcuts['relayd'] = array();
162
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
163
$shortcuts['relayd']['log'] = "diag_logs.php?logfile=relayd";
164
$shortcuts['relayd']['status'] = "status_lb_pool.php";
165
$shortcuts['relayd']['service'] = "relayd";
166

    
167
$shortcuts['relayd-virtualservers'] = array();
168
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
169
$shortcuts['relayd-virtualservers']['log'] = "diag_logs.php?logfile=relayd";
170
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
171
$shortcuts['relayd-virtualservers']['service'] = "relayd";
172

    
173
$shortcuts['captiveportal'] = array();
174
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
175
$shortcuts['captiveportal']['log'] = "diag_logs.php?logfile=auth";
176
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
177
$shortcuts['captiveportal']['service'] = "captiveportal";
178

    
179
$shortcuts['captiveportal-vouchers'] = array();
180
$shortcuts['captiveportal-vouchers']['log'] = "diag_logs.php?logfile=auth";
181
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
182
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
183

    
184
$shortcuts['dhcp'] = array();
185
$shortcuts['dhcp']['main'] = "services_dhcp.php";
186
$shortcuts['dhcp']['log'] = "diag_logs.php?logfile=dhcp";
187
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
188
$shortcuts['dhcp']['service'] = "dhcpd";
189

    
190
$shortcuts['dhcp6'] = array();
191
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
192
$shortcuts['dhcp6']['log'] = "diag_logs.php?logfile=dhcp";
193
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
194

    
195

    
196
$shortcuts['ipsec'] = array();
197
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
198
$shortcuts['ipsec']['log'] = "diag_logs.php?logfile=ipsec";
199
$shortcuts['ipsec']['status'] = "diag_ipsec.php";
200
$shortcuts['ipsec']['service'] = "ipsec";
201

    
202
$shortcuts['openvpn'] = array();
203
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
204
$shortcuts['openvpn']['log'] = "diag_logs.php?logfile=openvpn";
205
$shortcuts['openvpn']['status'] = "status_openvpn.php";
206
$shortcuts['openvpn']['service'] = "openvpn";
207

    
208
$shortcuts['firewall'] = array();
209
$shortcuts['firewall']['main'] = "firewall_rules.php";
210
$shortcuts['firewall']['log'] = "diag_logs.php?logfile=filter";
211
$shortcuts['firewall']['status'] = "status_filter_reload.php";
212

    
213
$shortcuts['routing'] = array();
214
$shortcuts['routing']['main'] = "system_routes.php";
215
$shortcuts['routing']['log'] = "diag_logs.php?logfile=routing";
216
$shortcuts['routing']['status'] = "diag_routes.php";
217

    
218
$shortcuts['gateways'] = array();
219
$shortcuts['gateways']['main'] = "system_gateways.php";
220
$shortcuts['gateways']['log'] = "diag_logs.php?logfile=gateways";
221
$shortcuts['gateways']['status'] = "status_gateways.php";
222
$shortcuts['gateways']['service'] = "apinger";
223

    
224
$shortcuts['gateway-groups'] = array();
225
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
226
$shortcuts['gateway-groups']['log'] = "diag_logs.php?logfile=gateways";
227
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
228

    
229
$shortcuts['interfaces'] = array();
230
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
231
$shortcuts['interfaces']['status'] = "status_interfaces.php";
232

    
233
$shortcuts['trafficshaper'] = array();
234
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
235
$shortcuts['trafficshaper']['status'] = "status_queues.php";
236

    
237
$shortcuts['trafficshaper-limiters'] = array();
238
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
239
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
240

    
241
$shortcuts['forwarder'] = array();
242
$shortcuts['forwarder']['main'] = "services_dnsmasq.php";
243
$shortcuts['forwarder']['log'] = "diag_logs.php?logfile=resolver";
244
$shortcuts['forwarder']['service'] = "dnsmasq";
245

    
246
$shortcuts['resolver'] = array();
247
$shortcuts['resolver']['main'] = "services_unbound.php";
248
$shortcuts['resolver']['log'] = "diag_logs.php?logfile=resolver";
249
$shortcuts['resolver']['service'] = "unbound";
250

    
251
$shortcuts['wireless'] = array();
252
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
253
$shortcuts['wireless']['log'] = "diag_logs.php?logfile=wireless";
254
$shortcuts['wireless']['status'] = "status_wireless.php";
255

    
256
$shortcuts['ntp'] = array();
257
$shortcuts['ntp']['main'] = "services_ntpd.php";
258
$shortcuts['ntp']['log'] = "diag_logs.php?logfile=ntpd";
259
$shortcuts['ntp']['status'] = "status_ntpd.php";
260
$shortcuts['ntp']['service'] = "ntpd";
261

    
262
$shortcuts['pptps'] = array();
263
$shortcuts['pptps']['main'] = "vpn_pptp.php";
264
$shortcuts['pptps']['log'] = "diag_logs_vpn.php";
265

    
266
$shortcuts['pppoes'] = array();
267
$shortcuts['pppoes']['main'] = "vpn_pppoe.php";
268
$shortcuts['pppoes']['log'] = "diag_logs_vpn.php?vpntype=poes";
269

    
270
$shortcuts['l2tps'] = array();
271
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
272
$shortcuts['l2tps']['log'] = "diag_logs_vpn.php?vpntype=l2tp";
273

    
274
$shortcuts['carp'] = array();
275
$shortcuts['carp']['main'] = "system_hasync.php";
276
$shortcuts['carp']['status'] = "carp_status.php";
277

    
278
$shortcuts['snmp'] = array();
279
$shortcuts['snmp']['main'] = "services_snmp.php";
280
$shortcuts['snmp']['service'] = "bsnmpd";
281

    
282
$shortcuts['authentication'] = array();
283
$shortcuts['authentication']['main'] = "system_authservers.php";
284
$shortcuts['authentication']['status'] = "diag_authentication.php";
285

    
286
$shortcuts['aliases'] = array();
287
$shortcuts['aliases']['main'] = "firewall_aliases.php";
288
$shortcuts['aliases']['status'] = "diag_tables.php";
289
?>
(160-160/235)