Project

General

Profile

Download (9.85 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / shortcuts.inc @ a1b66bec

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
	if ($dh = opendir($directory)) {
48
		while (($file = readdir($dh)) !== false) {
49
			$canadd = 0;
50
			if($file == ".") 
51
				$canadd = 1;
52
			if($file == "..") 
53
				$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
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) ? "&nbsp;" : "" ;
78
	switch ($shortcut_section) {
79
		case "openvpn":
80
			if (!empty($service['mode']) && is_numeric($service['id']))
81
				$link = "vpn_openvpn_{$service['mode']}.php?act=edit&amp;id={$service['id']}";
82
			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
	if(!empty($link) && ($_SERVER['REQUEST_URI'] != "/{$link}"))
96
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Main page for this section") . "\"><img style=\"vertical-align:middle\" src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" border=\"0\" alt=\"plus\" /></a>";
97
}
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) ? "&nbsp;" : "" ;
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
		return "{$space}<a href=\"{$link}\" title=\"" . gettext("Status of items on this page") . "\"><img style=\"vertical-align:middle\" src=\"/themes/{$g['theme']}/images/icons/icon_service_status.gif\" border=\"0\" alt=\"status\" /></a>";
121
}
122

    
123
function get_shortcut_log_link($shortcut_section, $addspace = true) {
124
	global $g, $shortcuts;
125
	$space = ($addspace) ? "&nbsp;" : "" ;
126
	if(!empty($shortcut_section) && !empty($shortcuts[$shortcut_section]['log'])) {
127
		return "{$space}<a href=\"{$shortcuts[$shortcut_section]['log']}\" title=\"" . gettext("Log entries for items on this page") . "\"><img style=\"vertical-align:middle\" src=\"/themes/{$g['theme']}/images/icons/icon_logs.gif\" border=\"0\" alt=\"logs\" /></a>";
128
	}
129
}
130

    
131
// Load shortcuts
132
$dir_array = get_shortcut_files("/usr/local/www/shortcuts");
133
foreach ($dir_array as $file) 
134
	if (!is_dir("/usr/local/www/shortcuts/{$file}") && stristr($file,".inc")) 
135
		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
	foreach ($dir_array as $file) 
139
		if (!is_dir("/usr/local/pkg/shortcuts/{$file}") && stristr($file,".inc")) 
140
			include("/usr/local/pkg/shortcuts/{$file}");
141
}
142

    
143
$shortcuts['relayd'] = array();
144
$shortcuts['relayd']['main'] = "load_balancer_pool.php";
145
$shortcuts['relayd']['log'] = "diag_logs_relayd.php";
146
$shortcuts['relayd']['status'] = "status_lb_pool.php";
147
$shortcuts['relayd']['service'] = "relayd";
148

    
149
$shortcuts['relayd-virtualservers'] = array();
150
$shortcuts['relayd-virtualservers']['main'] = "load_balancer_virtual_server.php";
151
$shortcuts['relayd-virtualservers']['log'] = "diag_logs_relayd.php";
152
$shortcuts['relayd-virtualservers']['status'] = "status_lb_vs.php";
153
$shortcuts['relayd-virtualservers']['service'] = "relayd";
154

    
155
$shortcuts['captiveportal'] = array();
156
$shortcuts['captiveportal']['main'] = "services_captiveportal_zones.php";
157
$shortcuts['captiveportal']['log'] = "diag_logs_auth.php";
158
$shortcuts['captiveportal']['status'] = "status_captiveportal.php";
159
$shortcuts['captiveportal']['service'] = "captiveportal";
160

    
161
$shortcuts['captiveportal-vouchers'] = array();
162
$shortcuts['captiveportal-vouchers']['log'] = "diag_logs_auth.php";
163
$shortcuts['captiveportal-vouchers']['status'] = "status_captiveportal_vouchers.php";
164
$shortcuts['captiveportal-vouchers']['service'] = "captiveportal";
165

    
166
$shortcuts['dhcp'] = array();
167
$shortcuts['dhcp']['main'] = "services_dhcp.php";
168
$shortcuts['dhcp']['log'] = "diag_logs_dhcp.php";
169
$shortcuts['dhcp']['status'] = "status_dhcp_leases.php";
170
$shortcuts['dhcp']['service'] = "dhcpd";
171

    
172
$shortcuts['dhcp6'] = array();
173
$shortcuts['dhcp6']['main'] = "services_dhcpv6.php";
174
$shortcuts['dhcp6']['log'] = "diag_logs_dhcp.php";
175
$shortcuts['dhcp6']['status'] = "status_dhcpv6_leases.php";
176

    
177

    
178
$shortcuts['ipsec'] = array();
179
$shortcuts['ipsec']['main'] = "vpn_ipsec.php";
180
$shortcuts['ipsec']['log'] = "diag_logs_ipsec.php";
181
$shortcuts['ipsec']['status'] = "diag_ipsec.php";
182
$shortcuts['ipsec']['service'] = "ipsec";
183

    
184
$shortcuts['openvpn'] = array();
185
$shortcuts['openvpn']['main'] = "vpn_openvpn_server.php";
186
$shortcuts['openvpn']['log'] = "diag_logs_openvpn.php";
187
$shortcuts['openvpn']['status'] = "status_openvpn.php";
188
$shortcuts['openvpn']['service'] = "openvpn";
189

    
190
$shortcuts['firewall'] = array();
191
$shortcuts['firewall']['main'] = "firewall_rules.php";
192
$shortcuts['firewall']['log'] = "diag_logs_filter.php";
193
$shortcuts['firewall']['status'] = "status_filter_reload.php";
194

    
195
$shortcuts['routing'] = array();
196
$shortcuts['routing']['main'] = "system_routes.php";
197
$shortcuts['routing']['log'] = "diag_logs_routing.php";
198
$shortcuts['routing']['status'] = "diag_routes.php";
199

    
200
$shortcuts['gateways'] = array();
201
$shortcuts['gateways']['main'] = "system_gateways.php";
202
$shortcuts['gateways']['log'] = "diag_logs_gateways.php";
203
$shortcuts['gateways']['status'] = "status_gateways.php";
204
$shortcuts['gateways']['service'] = "apinger";
205

    
206
$shortcuts['gateway-groups'] = array();
207
$shortcuts['gateway-groups']['main'] = "system_gateway_groups.php";
208
$shortcuts['gateway-groups']['log'] = "diag_logs_gateways.php";
209
$shortcuts['gateway-groups']['status'] = "status_gateway_groups.php";
210

    
211
$shortcuts['interfaces'] = array();
212
$shortcuts['interfaces']['main'] = "interfaces_assign.php";
213
$shortcuts['interfaces']['status'] = "status_interfaces.php";
214

    
215
$shortcuts['trafficshaper'] = array();
216
$shortcuts['trafficshaper']['main'] = "firewall_shaper.php";
217
$shortcuts['trafficshaper']['status'] = "status_queues.php";
218

    
219
$shortcuts['trafficshaper-limiters'] = array();
220
$shortcuts['trafficshaper-limiters']['main'] = "firewall_shaper_vinterface.php";
221
$shortcuts['trafficshaper-limiters']['status'] = "diag_limiter_info.php";
222

    
223
$shortcuts['resolver'] = array();
224
$shortcuts['resolver']['main'] = "services_dnsmasq.php";
225
$shortcuts['resolver']['log'] = "diag_logs_resolver.php";
226
$shortcuts['resolver']['service'] = "dnsmasq";
227

    
228
$shortcuts['wireless'] = array();
229
$shortcuts['wireless']['main'] = "interfaces_wireless.php";
230
$shortcuts['wireless']['log'] = "diag_logs_wireless.php";
231
$shortcuts['wireless']['status'] = "status_wireless.php";
232

    
233
$shortcuts['ntp'] = array();
234
$shortcuts['ntp']['main'] = "services_ntpd.php";
235
$shortcuts['ntp']['log'] = "diag_logs_ntpd.php";
236
$shortcuts['ntp']['status'] = "status_ntpd.php";
237
$shortcuts['ntp']['service'] = "ntpd";
238

    
239
$shortcuts['pptps'] = array();
240
$shortcuts['pptps']['main'] = "vpn_pptp.php";
241
$shortcuts['pptps']['log'] = "diag_logs_vpn.php";
242

    
243
$shortcuts['pppoes'] = array();
244
$shortcuts['pppoes']['main'] = "vpn_pppoe.php";
245
$shortcuts['pppoes']['log'] = "diag_logs_vpn.php?vpntype=poes";
246

    
247
$shortcuts['l2tps'] = array();
248
$shortcuts['l2tps']['main'] = "vpn_l2tp.php";
249
$shortcuts['l2tps']['log'] = "diag_logs_vpn.php?vpntype=l2tp";
250

    
251
$shortcuts['carp'] = array();
252
$shortcuts['carp']['main'] = "system_hasync.php";
253
$shortcuts['carp']['status'] = "carp_status.php";
254

    
255
$shortcuts['snmp'] = array();
256
$shortcuts['snmp']['main'] = "services_snmp.php";
257
$shortcuts['snmp']['service'] = "bsnmpd";
258

    
259
$shortcuts['authentication'] = array();
260
$shortcuts['authentication']['main'] = "system_authservers.php";
261
$shortcuts['authentication']['status'] = "diag_authentication.php";
262

    
263
$shortcuts['aliases'] = array();
264
$shortcuts['aliases']['main'] = "firewall_aliases.php";
265
$shortcuts['aliases']['status'] = "diag_tables.php";
266
?>
(177-177/256)