Project

General

Profile

Download (27.3 KB) Statistics
| Branch: | Tag: | Revision:
1 56c100ab Erik Fonnesbeck
<?php
2 c5d81585 Renato Botelho
/*
3
 * head.inc
4 d7218f77 Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 b8f91b7c Luiz Souza
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 d7218f77 Stephen Beaver
 *
9 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12 d7218f77 Stephen Beaver
 *
13 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
14 d7218f77 Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20 d7218f77 Stephen Beaver
 */
21 888c3c1b Stephen Beaver
22 31f03b6c Sjon Hortensius
require_once("globals.inc");
23
require_once("functions.inc");
24
require_once("shortcuts.inc");
25
require_once("service-utils.inc");
26 8d3f3e34 Stephen Beaver
require_once('notices.inc');
27 31f03b6c Sjon Hortensius
28 9801e938 Sjon Hortensius
header('Content-Type: text/html; charset=utf-8');
29
30 ecffb0bb Phil Davis
$pagetitle = gentitle($pgtitle);
31 8ad8e9ab Phil Davis
$system_url = $config['system']['hostname'] . "." . $config['system']['domain'];
32 56c100ab Erik Fonnesbeck
33 8bab524e Phil Davis
if ($user_settings['webgui']['pagenamefirst']) {
34 8ad8e9ab Phil Davis
	$tabtitle = $pagetitle . " - " . htmlspecialchars($system_url);
35 e259607f Thane Gill
} else {
36 8ad8e9ab Phil Davis
	$tabtitle = htmlspecialchars($system_url) . " - " . $pagetitle;
37 e259607f Thane Gill
}
38 60571782 Stephen Beaver
39 9d1be24e Jared Dillard
$cssfile = "/css/pfSense.css";
40 60571782 Stephen Beaver
41 8bab524e Phil Davis
if (isset($user_settings['webgui']['webguicss'])) {
42
	if (file_exists("/usr/local/www/css/" . $user_settings['webgui']['webguicss'])) {
43
		$cssfile = "/css/" . $user_settings['webgui']['webguicss'];
44 60571782 Stephen Beaver
	}
45
}
46
47 e6367325 Phil Davis
// set default columns to two if unset
48 aa82505e Phil Davis
if (!isset($config['system']['webgui']['dashboardcolumns'])) {
49 477db933 Jared Dillard
	$config['system']['webgui']['dashboardcolumns'] = 2;
50
}
51
52 56c100ab Erik Fonnesbeck
?>
53 1180e4f0 Sjon Hortensius
<!DOCTYPE html>
54
<html lang="en">
55 56c100ab Erik Fonnesbeck
<head>
56 d41aeafc Stephen Beaver
	<meta name="viewport" content="width=device-width, initial-scale=1">
57 e7d63f56 Jared Dillard
58
	<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
59
	<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
60
	<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
61
	<link rel="manifest" href="/manifest.json">
62
	<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
63
	<meta name="theme-color" content="#ffffff">
64
65 09ba8bb7 Steve Beaver
	<link rel="stylesheet" href="/vendor/font-awesome/css/font-awesome.min.css?v=<?=filemtime('/usr/local/www/vendor/font-awesome/css/font-awesome.min.css')?>">
66
	<link rel="stylesheet" href="/vendor/sortable/sortable-theme-bootstrap.css?v=<?=filemtime('/usr/local/www/vendor/sortable/sortable-theme-bootstrap.css')?>">
67
	<link rel="stylesheet" href="<?=$cssfile?>?v=<?=filemtime('/usr/local/www/' . $cssfile)?>" />
68
69 e259607f Thane Gill
	<title><?=$tabtitle?></title>
70 8fd9052f Colin Fleming
	<script type="text/javascript">
71
	//<![CDATA[
72
	var events = events || [];
73
	//]]>
74
	</script>
75 1180e4f0 Sjon Hortensius
</head>
76 8d3f3e34 Stephen Beaver
77 31f03b6c Sjon Hortensius
<?php
78
79 e259607f Thane Gill
/* Determine automated help URL. Should output the page name and parameters
80
   separately */
81 31f03b6c Sjon Hortensius
$uri_split = "";
82
preg_match("/\/(.*)\?(.*)/", $_SERVER["REQUEST_URI"], $uri_split);
83
84
/* If there was no match, there were no parameters, just grab the filename
85
   Otherwise, use the matched filename from above. */
86
if (empty($uri_split[0])) {
87
	$pagename = ltrim($_SERVER["REQUEST_URI"], '/');
88
} else {
89
	$pagename = $uri_split[1];
90
}
91 239b5161 Stephen Beaver
92 31f03b6c Sjon Hortensius
/* If the page name is still empty, the user must have requested / (index.php) */
93
if (empty($pagename)) {
94
	$pagename = "index.php";
95
}
96
97
/* If the filename is pkg_edit.php or wizard.php, reparse looking
98
	for the .xml filename */
99
if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "wizard.php")) {
100
	$param_split = explode('&', $uri_split[2]);
101
	foreach ($param_split as $param) {
102
		if (substr($param, 0, 4) == "xml=") {
103
			$xmlfile = explode('=', $param);
104
			$pagename = $xmlfile[1];
105
		}
106
	}
107 f11871ca Phil Davis
} else if ($pagename == "status_logs.php") {
108
	$param_split = explode('&', $uri_split[2]);
109
	foreach ($param_split as $param) {
110
		if (substr($param, 0, 8) == "logfile=") {
111
			$logtype = explode('=', $param);
112
			$pagename .= '-' . $logtype[1];
113
		}
114
	}
115 31f03b6c Sjon Hortensius
}
116
117 567d7fd6 Stephen Beaver
// Build the full help URL.
118 31f03b6c Sjon Hortensius
$helpurl .= "{$g['help_base_url']}?page={$pagename}";
119
120 909a1954 Renato Botelho
/*
121
 * Read files from $g['ext_menu_path']/*.xml and fill an array with menu info
122
 */
123
function read_ext_menu_path_data() {
124
	global $g;
125
126
	$result = array();
127
128
	if (!is_dir($g['ext_menu_path'])) {
129
		return $result;
130
	}
131
132
	foreach (glob("{$g['ext_menu_path']}/*.xml") as $menu_xml) {
133
		$xml_data = parse_xml_config_pkg($menu_xml, "packagegui");
134
		if (empty($xml_data['menu'])) {
135
			continue;
136
		}
137
		foreach ($xml_data['menu'] as $menu) {
138
			$result[] = $menu;
139
		}
140
	}
141
142
	return $result;
143
}
144
145 567d7fd6 Stephen Beaver
// Create a menu entry of any installed packages in the specified category
146
// (Now reads the menu information from $config['installedpackages']['menu'] only)
147 31f03b6c Sjon Hortensius
function return_ext_menu($section) {
148 909a1954 Renato Botelho
	global $config, $ext_menu_path_data;
149 da4a4b9f Stephen Beaver
150 31f03b6c Sjon Hortensius
	$htmltext = "";
151
	$extarray = array();
152 909a1954 Renato Botelho
	$ext_menu_entries = array();
153 da4a4b9f Stephen Beaver
154 aa82505e Phil Davis
	if ((!empty($config['installedpackages']['package'])) && (!empty($config['installedpackages']['menu']))) {
155 567d7fd6 Stephen Beaver
		foreach ($config['installedpackages']['menu'] as $menu) {
156
//			print('Name: ' . $menu['name'] . ', Pkg category: ' . $menu['category'] . ', Section: ' . $section . '<br />');
157 909a1954 Renato Botelho
			if ($menu['section'] == $section) {
158
				$ext_menu_entries[] = $menu;
159 e259607f Thane Gill
			}
160 909a1954 Renato Botelho
		}
161
	}
162
163
	foreach ($ext_menu_path_data as $menu) {
164
		if ($menu['section'] == $section) {
165
			$ext_menu_entries[] = $menu;
166
		}
167
	}
168
169
	foreach ($ext_menu_entries as $menu) {
170
		if ($menu['url'] != "") {
171
			$test_url = $menu['url'];
172
			$addresswithport = getenv("HTTP_HOST");
173
			$colonpos = strpos($addresswithport, ":");
174 da4a4b9f Stephen Beaver
175 909a1954 Renato Botelho
			if ($colonpos !== false) {
176
				//my url is actually just the IP address of the pfsense box
177
				$myurl = substr($addresswithport, 0, $colonpos);
178 31f03b6c Sjon Hortensius
			} else {
179 909a1954 Renato Botelho
				$myurl = $addresswithport;
180 31f03b6c Sjon Hortensius
			}
181 909a1954 Renato Botelho
			$description = str_replace('$myurl', $myurl, $menu['url']);
182
		} else {
183
			$description = '/pkg.php?xml=' . $menu['configfile'];
184
			$test_url=$description;
185
		}
186 da4a4b9f Stephen Beaver
187 909a1954 Renato Botelho
		if (isAllowedPage($test_url)) {
188
			$extarray[] = array($menu['name'], $description);
189 31f03b6c Sjon Hortensius
		}
190
	}
191 567d7fd6 Stephen Beaver
192 31f03b6c Sjon Hortensius
	return $extarray;
193
}
194
195 8559c9d9 jim-p
function output_menu($arrayitem, $target = null, $section = "") {
196 7c3f1189 Phil Davis
	$output = "";
197
198 31f03b6c Sjon Hortensius
	foreach ($arrayitem as $item) {
199 24fc15e6 Steve Beaver
200 8559c9d9 jim-p
		/* If the user has access to help pages, also show the full help menu. See #5909 */
201 b29aa6e5 jim-p
		if (isAllowedPage($item[1]) || $item[1] == "/index.php?logout" ||
202
		    (($section == "Help") && isAllowedPage("help.php")) ||
203
		    (substr($item[1], 0, 8) == "https://")) {
204 31f03b6c Sjon Hortensius
			$attr = sprintf("href=\"%s\"", htmlentities($item[1]));
205 24fc15e6 Steve Beaver
206 31f03b6c Sjon Hortensius
			if ($target) {
207
				$attr .= sprintf(" target=\"%s\"", htmlentities($target));
208
			}
209 24fc15e6 Steve Beaver
210 31f03b6c Sjon Hortensius
			$class = "navlnk";
211 24fc15e6 Steve Beaver
212 31f03b6c Sjon Hortensius
			if ($item['class']) {
213
				$class .= " {$item['class']}";
214
			}
215 24fc15e6 Steve Beaver
216 31f03b6c Sjon Hortensius
			$attr .= sprintf(" class=\"%s\"", htmlentities($class));
217 24fc15e6 Steve Beaver
218 31f03b6c Sjon Hortensius
			if ($item['style']) {
219
				$attr .= sprintf(" style=\"%s\"", htmlentities($item['style']));
220
			}
221 898aa92c Steve Beaver
222 24fc15e6 Steve Beaver
223 898aa92c Steve Beaver
			if ($item[0] == '-DIVIDER-') {
224 7c3f1189 Phil Davis
				$output .= ' <li class="divider"></li>';
225 898aa92c Steve Beaver
			} else {
226 ce437697 Steve Beaver
				$output .= "<li>". sprintf("<a %s %s>%s</a>", $attr, ($item[1] == "/index.php?logout") ? "usepost":"",$item[0]) . "</li>\n";
227 898aa92c Steve Beaver
			}
228 31f03b6c Sjon Hortensius
		}
229
	}
230 7c3f1189 Phil Davis
231
	return $output;
232 31f03b6c Sjon Hortensius
}
233
234 909a1954 Renato Botelho
$ext_menu_path_data = read_ext_menu_path_data();
235
236 31f03b6c Sjon Hortensius
// System
237
$system_menu = array();
238 8ad8e9ab Phil Davis
$system_menu[] = array(gettext("Logout") . " (" . $_SESSION['Username'] . ")", "/index.php?logout");
239 31f03b6c Sjon Hortensius
$system_menu[] = array(gettext("Advanced"), "/system_advanced_admin.php");
240 440a30cf Stephen Beaver
$system_menu[] = array(gettext("Update"), "/pkg_mgr_install.php?id=firmware");
241 31f03b6c Sjon Hortensius
$system_menu[] = array(gettext("General Setup"), "/system.php");
242
$system_menu[] = array(gettext("High Avail. Sync"), "/system_hasync.php");
243 dc61252a Renato Botelho
$system_menu[] = array(gettext("Package Manager"), "/pkg_mgr_installed.php");
244 31f03b6c Sjon Hortensius
$system_menu[] = array(gettext("Setup Wizard"), "/wizard.php?xml=setup_wizard.xml");
245 d036bc07 Stephen Beaver
$system_menu[] = array(gettext("Routing"), "/system_gateways.php");
246 d4a744b2 k-paulius
$system_menu[] = array(gettext("Cert. Manager"), "/system_camanager.php");
247 e259607f Thane Gill
if (!isAllowedPage("system_usermanager.php*")) {
248 31f03b6c Sjon Hortensius
	$system_menu[] = array(gettext("User Manager"), "/system_usermanager_passwordmg.php");
249 e259607f Thane Gill
} else {
250 31f03b6c Sjon Hortensius
	$system_menu[] = array(gettext("User Manager"), "/system_usermanager.php");
251 e259607f Thane Gill
}
252 da4a4b9f Stephen Beaver
253 8bab524e Phil Davis
if ($user_settings['customsettings'] && isAllowedPage("system_user_settings.php*")) {
254
	$system_menu[] = array(gettext("User Settings"), "/system_user_settings.php");
255
}
256
257 ecffb0bb Phil Davis
$system_menu = msort(array_merge($system_menu, return_ext_menu("System")), 0);
258 31f03b6c Sjon Hortensius
259
// Interfaces
260 24fc15e6 Steve Beaver
// NOTE:
261
// Now that menus are sorted, adding a DIVIDER must be done after the sorting so an array is formed of the
262 eb6984fd Phil Davis
// items above the divider and another for below it. These are then sorted and combined with the divider
263 31f03b6c Sjon Hortensius
$interfaces_menu = array();
264 24fc15e6 Steve Beaver
$interfaces_top = array();
265
$interfaces_bottom = array();
266
267 e259607f Thane Gill
if (!isset($config['system']['webgui']['noassigninterfaces'])) {
268 24fc15e6 Steve Beaver
	$interfaces_top[] = array(gettext("Assignments"), "/interfaces_assign.php");
269 898aa92c Steve Beaver
	$div = true;
270 e259607f Thane Gill
}
271 898aa92c Steve Beaver
272
$platform = system_identify_specific_platform();
273
274
if ($platform['name'] == "uFW") {
275 24fc15e6 Steve Beaver
	$interfaces_top[] = array(gettext("Switches"), "/switch_system.php");
276 898aa92c Steve Beaver
}
277
278 f593f80b Phil Davis
$opts = get_configured_interface_with_descr(true);
279 24fc15e6 Steve Beaver
280 e259607f Thane Gill
foreach ($opts as $oif => $odescr) {
281
	if (!isset($config['interfaces'][$oif]['ovpn'])) {
282 24fc15e6 Steve Beaver
		$interfaces_bottom[] = array(htmlspecialchars($odescr), "/interfaces.php?if={$oif}");
283 e259607f Thane Gill
	}
284
}
285 24fc15e6 Steve Beaver
286 1d3510cf Phil Davis
$interfaces_bottom = array_merge($interfaces_bottom, return_ext_menu("Interfaces"));
287
288
if ($user_settings['webgui']['interfacessort']) {
289
	$interfaces_bottom = msort($interfaces_bottom, 0);
290
}
291
292 eb6984fd Phil Davis
// Combine the top section, the divider and the bottom section of this menu
293 1d3510cf Phil Davis
$interfaces_menu = array_merge($interfaces_top, [array(0 => "-DIVIDER-")], $interfaces_bottom);
294 31f03b6c Sjon Hortensius
295
// Firewall
296
$firewall_menu = array();
297
$firewall_menu[] = array(gettext("Aliases"), "/firewall_aliases.php");
298
$firewall_menu[] = array(gettext("NAT"), "/firewall_nat.php");
299
$firewall_menu[] = array(gettext("Rules"), "/firewall_rules.php");
300
$firewall_menu[] = array(gettext("Schedules"), "/firewall_schedule.php");
301
$firewall_menu[] = array(gettext("Traffic Shaper"), "/firewall_shaper.php");
302
$firewall_menu[] = array(gettext("Virtual IPs"), "/firewall_virtual_ip.php");
303 ecffb0bb Phil Davis
$firewall_menu = msort(array_merge($firewall_menu, return_ext_menu("Firewall")), 0);
304 31f03b6c Sjon Hortensius
305
// Services
306
$services_menu = array();
307
$services_menu[] = array(gettext("Captive Portal"), "/services_captiveportal.php");
308
$services_menu[] = array(gettext("DNS Forwarder"), "/services_dnsmasq.php");
309
$services_menu[] = array(gettext("DNS Resolver"), "/services_unbound.php");
310
$services_menu[] = array(gettext("DHCP Relay"), "/services_dhcp_relay.php");
311
$services_menu[] = array(gettext("DHCPv6 Relay"), "/services_dhcpv6_relay.php");
312 239b5161 Stephen Beaver
313 ecffb0bb Phil Davis
if ($g['services_dhcp_server_enable']) {
314 31f03b6c Sjon Hortensius
	$services_menu[] = array(gettext("DHCP Server"), "/services_dhcp.php");
315 46b7214c k-paulius
	$services_menu[] = array(htmlspecialchars(gettext("DHCPv6 Server & RA")), "/services_dhcpv6.php");
316 31f03b6c Sjon Hortensius
}
317 567d7fd6 Stephen Beaver
318 31f03b6c Sjon Hortensius
$services_menu[] = array(gettext("Dynamic DNS"), "/services_dyndns.php");
319 35e05b7f Phil Davis
$services_menu[] = array(gettext("IGMP Proxy"), "/services_igmpproxy.php");
320 31f03b6c Sjon Hortensius
$services_menu[] = array(gettext("Load Balancer"), "/load_balancer_pool.php");
321
$services_menu[] = array(gettext("NTP"), "/services_ntpd.php");
322 1af5edbf Stephen Beaver
$services_menu[] = array(gettext("PPPoE Server"), "/services_pppoe.php");
323 31f03b6c Sjon Hortensius
$services_menu[] = array(gettext("SNMP"), "/services_snmp.php");
324 239b5161 Stephen Beaver
325 ecffb0bb Phil Davis
if (count($config['interfaces']) > 1) {
326 31f03b6c Sjon Hortensius
	/* no use for UPnP in single-interface deployments
327
	remove to reduce user confusion
328
	*/
329
	$services_menu[] = array(gettext("UPnP &amp; NAT-PMP"), "/pkg_edit.php?xml=miniupnpd.xml");
330
}
331 239b5161 Stephen Beaver
332 7ca42d47 k-paulius
$services_menu[] = array(gettext("Wake-on-LAN"), "/services_wol.php");
333 ecffb0bb Phil Davis
$services_menu = msort(array_merge($services_menu, return_ext_menu("Services")), 0);
334 31f03b6c Sjon Hortensius
335
// VPN
336
$vpn_menu = array();
337
$vpn_menu[] = array(gettext("IPsec"), "/vpn_ipsec.php");
338
$vpn_menu[] = array(gettext("OpenVPN"), "/vpn_openvpn_server.php");
339 a4af095c Renato Botelho
//$vpn_menu[] = array(gettext("PPTP"), "/vpn_pptp.php");
340 31f03b6c Sjon Hortensius
$vpn_menu[] = array(gettext("L2TP"), "/vpn_l2tp.php");
341 ecffb0bb Phil Davis
$vpn_menu = msort(array_merge($vpn_menu, return_ext_menu("VPN")), 0);
342 31f03b6c Sjon Hortensius
343
// Status
344
$status_menu = array();
345 925817a7 Phil Davis
$status_menu[] = array(gettext("Captive Portal"), "/status_captiveportal.php");
346 1af5edbf Stephen Beaver
$status_menu[] = array(gettext("CARP (failover)"), "/status_carp.php");
347 31f03b6c Sjon Hortensius
$status_menu[] = array(gettext("Dashboard"), "/index.php");
348
$status_menu[] = array(gettext("Gateways"), "/status_gateways.php");
349
$status_menu[] = array(gettext("DHCP Leases"), "/status_dhcp_leases.php");
350
$status_menu[] = array(gettext("DHCPv6 Leases"), "/status_dhcpv6_leases.php");
351 4acef976 jim-p
$status_menu[] = array(gettext("DNS Resolver"), "/status_unbound.php");
352 d00157df Steve Beaver
$status_menu[] = array(gettext("Filter Reload"), "/status_filter_reload.php?user=true");
353 31f03b6c Sjon Hortensius
$status_menu[] = array(gettext("Interfaces"), "/status_interfaces.php");
354 1af5edbf Stephen Beaver
$status_menu[] = array(gettext("IPsec"), "/status_ipsec.php");
355 31f03b6c Sjon Hortensius
$status_menu[] = array(gettext("Load Balancer"), "/status_lb_pool.php");
356
$status_menu[] = array(gettext("NTP"), "/status_ntpd.php");
357
$status_menu[] = array(gettext("OpenVPN"), "/status_openvpn.php");
358 dc61252a Renato Botelho
$status_menu[] = array(gettext("Package Logs"), "/status_pkglogs.php");
359 31f03b6c Sjon Hortensius
$status_menu[] = array(gettext("Queues"), "/status_queues.php");
360
$status_menu[] = array(gettext("Services"), "/status_services.php");
361 1af5edbf Stephen Beaver
$status_menu[] = array(gettext("System Logs"), "/status_logs.php");
362 31f03b6c Sjon Hortensius
$status_menu[] = array(gettext("Traffic Graph"), "/status_graph.php?if=wan");
363 239b5161 Stephen Beaver
364 ecffb0bb Phil Davis
if (count($config['interfaces']) > 1) {
365 31f03b6c Sjon Hortensius
	$status_menu[] = array(gettext("UPnP &amp; NAT-PMP"), "/status_upnp.php");
366 e259607f Thane Gill
}
367 239b5161 Stephen Beaver
368 25e4c862 Renato Botelho
$wifdescrs = array();
369 31f03b6c Sjon Hortensius
$ifentries = get_configured_interface_with_descr();
370
foreach ($ifentries as $ent => $entdesc) {
371
	if (is_array($config['interfaces'][$ent]['wireless']) &&
372 aa82505e Phil Davis
	    preg_match($g['wireless_regex'], $config['interfaces'][$ent]['if'])) {
373 31f03b6c Sjon Hortensius
		$wifdescrs[$ent] = $entdesc;
374 e259607f Thane Gill
	}
375 31f03b6c Sjon Hortensius
}
376 239b5161 Stephen Beaver
377 e259607f Thane Gill
if (count($wifdescrs) > 0) {
378 31f03b6c Sjon Hortensius
	$status_menu[] = array(gettext("Wireless"), "/status_wireless.php");
379 e259607f Thane Gill
}
380 239b5161 Stephen Beaver
381 ecffb0bb Phil Davis
$status_menu = msort(array_merge($status_menu, return_ext_menu("Status")), 0);
382 31f03b6c Sjon Hortensius
383
// Diagnostics
384
$diagnostics_menu = array();
385
$diagnostics_menu[] = array(gettext("ARP Table"), "/diag_arp.php");
386
$diagnostics_menu[] = array(gettext("Authentication"), "/diag_authentication.php");
387 0f298138 k-paulius
$diagnostics_menu[] = array(htmlspecialchars(gettext("Backup & Restore")), "/diag_backup.php");
388 c7903f8e Stephen Beaver
$diagnostics_menu[] = array(gettext("Command Prompt"), "/diag_command.php");
389 31f03b6c Sjon Hortensius
$diagnostics_menu[] = array(gettext("DNS Lookup"), "/diag_dns.php");
390 36a844df Stephen Beaver
$diagnostics_menu[] = array(gettext("Edit File"), "/diag_edit.php");
391 31f03b6c Sjon Hortensius
$diagnostics_menu[] = array(gettext("Factory Defaults"), "/diag_defaults.php");
392 239b5161 Stephen Beaver
393 ecffb0bb Phil Davis
if (file_exists("/var/run/gmirror_active")) {
394
	$diagnostics_menu[] = array(gettext("GEOM Mirrors"), "/diag_gmirror.php");
395 e259607f Thane Gill
}
396 239b5161 Stephen Beaver
397 1af5edbf Stephen Beaver
$diagnostics_menu[] = array(gettext("Halt System"), "/diag_halt.php");
398 ecffb0bb Phil Davis
$diagnostics_menu[] = array(gettext("Limiter Info"), "/diag_limiter_info.php");
399
$diagnostics_menu[] = array(gettext("NDP Table"), "/diag_ndp.php");
400 31f03b6c Sjon Hortensius
$diagnostics_menu[] = array(gettext("Tables"), "/diag_tables.php");
401
$diagnostics_menu[] = array(gettext("Ping"), "/diag_ping.php");
402
$diagnostics_menu[] = array(gettext("Test Port"), "/diag_testport.php");
403
$diagnostics_menu[] = array(gettext("pfInfo"), "/diag_pf_info.php");
404 1af5edbf Stephen Beaver
$diagnostics_menu[] = array(gettext("pfTop"), "/diag_pftop.php");
405
$diagnostics_menu[] = array(gettext("Reboot"), "/diag_reboot.php");
406 31f03b6c Sjon Hortensius
$diagnostics_menu[] = array(gettext("Routes"), "/diag_routes.php");
407 9718847b k-paulius
$diagnostics_menu[] = array(gettext("S.M.A.R.T. Status"), "/diag_smart.php");
408 ecffb0bb Phil Davis
$diagnostics_menu[] = array(gettext("Sockets"), "/diag_sockets.php");
409 31f03b6c Sjon Hortensius
$diagnostics_menu[] = array(gettext("States"), "/diag_dump_states.php");
410
$diagnostics_menu[] = array(gettext("States Summary"), "/diag_states_summary.php");
411
$diagnostics_menu[] = array(gettext("System Activity"), "/diag_system_activity.php");
412
$diagnostics_menu[] = array(gettext("Traceroute"), "/diag_traceroute.php");
413
$diagnostics_menu[] = array(gettext("Packet Capture"), "/diag_packet_capture.php");
414 239b5161 Stephen Beaver
415 ecffb0bb Phil Davis
$diagnostics_menu = msort(array_merge($diagnostics_menu, return_ext_menu("Diagnostics")), 0);
416 31f03b6c Sjon Hortensius
417
$gold_menu = array();
418
$gold_menu[] = array(gettext("pfSense Gold"), "https://www.pfsense.org/gold");
419 ecffb0bb Phil Davis
$gold_menu = msort(array_merge($gold_menu, return_ext_menu("Gold")), 0);
420 31f03b6c Sjon Hortensius
421 ecffb0bb Phil Davis
if (!$g['disablehelpmenu']) {
422 31f03b6c Sjon Hortensius
	$help_menu = array();
423
	$help_menu[] = array(gettext("About this Page"), $helpurl);
424 ecffb0bb Phil Davis
	if ($g['product_name'] == "pfSense") {
425 31f03b6c Sjon Hortensius
		$help_menu[] = array(gettext("Bug Database"), "https://www.pfsense.org/j.php?jumpto=redmine");
426 e259607f Thane Gill
	}
427 d7218f77 Stephen Beaver
428 31f03b6c Sjon Hortensius
	$help_menu[] = array(gettext("User Forum"), "https://www.pfsense.org/j.php?jumpto=forum");
429
	$help_menu[] = array(gettext("Documentation"), "https://www.pfsense.org/j.php?jumpto=doc");
430 6b7b9d35 Steve Beaver
	$help_menu[] = array(gettext("Paid Support"), "https://www.netgate.com/support");
431 31f03b6c Sjon Hortensius
	$help_menu[] = array(gettext("pfSense Book"), "https://www.pfsense.org/j.php?jumpto=book");
432
	$help_menu[] = array(gettext("FreeBSD Handbook"), "https://www.pfsense.org/j.php?jumpto=fbsdhandbook");
433 ecffb0bb Phil Davis
	$help_menu = msort(array_merge($help_menu, return_ext_menu("Help")), 0);
434 31f03b6c Sjon Hortensius
}
435 3d29d2eb Jared Dillard
436
$menuclass = "static";
437 ddb84143 Stephen Beaver
438 8bab524e Phil Davis
if ($user_settings['webgui']['webguifixedmenu'] == "fixed") {
439 3d29d2eb Jared Dillard
	$menuclass = "fixed";
440
}
441 477db933 Jared Dillard
442 8bab524e Phil Davis
$numColumns = $user_settings['webgui']['dashboardcolumns'];
443 477db933 Jared Dillard
444
if (($pagename === "index.php") && ($numColumns > 2)) {
445 d349843c Jared Dillard
	$columnsContainer = 'style="max-width: ' . 585*$numColumns . 'px;width: 100%"';
446 477db933 Jared Dillard
}
447 5280f021 Phil Davis
448
$display_notices = false;
449
$allow_clear_notices = false;
450
451
if (are_notices_pending()) {
452
	// Evaluate user privs to determine if notices should be displayed, and if the user can clear them.
453
	$user_entry = getUserEntry($_SESSION['Username']);
454 b2daca76 Phil Davis
	if (isAdminUID($_SESSION['Username']) || userHasPrivilege($user_entry, "user-view-clear-notices") || userHasPrivilege($user_entry, "page-all")) {
455 5280f021 Phil Davis
		$display_notices = true;
456
		$allow_clear_notices = true;
457
	} elseif (userHasPrivilege($user_entry, "user-view-notices")) {
458
		$display_notices = true;
459
	}
460
}
461 31f03b6c Sjon Hortensius
?>
462 477db933 Jared Dillard
<body id="<?=$numColumns?>">
463 3d29d2eb Jared Dillard
<nav id="topmenu" class="navbar navbar-<?=$menuclass?>-top navbar-inverse">
464 31f03b6c Sjon Hortensius
	<div class="container">
465
		<div class="navbar-header">
466 2d26ee5e Sjon Hortensius
			<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#pf-navbar">
467 31f03b6c Sjon Hortensius
				<span class="sr-only">Toggle navigation</span>
468
				<span class="icon-bar"></span>
469
				<span class="icon-bar"></span>
470
				<span class="icon-bar"></span>
471
			</button>
472 be76c9d6 Jared Dillard
			<a class="navbar-brand" href="/">
473 f9a6637a Renato Botelho
				<?php include("/usr/local/www/logo.svg"); ?>
474 be76c9d6 Jared Dillard
				<span style="color:white;font-size:.5em;text-transform:uppercase;letter-spacing:1px;">Community Edition</span>
475
			</a>
476 31f03b6c Sjon Hortensius
		</div>
477 2d26ee5e Sjon Hortensius
		<div class="collapse navbar-collapse" id="pf-navbar">
478 31f03b6c Sjon Hortensius
			<ul class="nav navbar-nav">
479 1d129967 Christopher Fazendin
			<?php
480 8bab524e Phil Davis
                if ($user_settings['webgui']['webguihostnamemenu'] == 'hostonly') {
481 1d129967 Christopher Fazendin
                    $help_menu_title = htmlspecialchars($config['system']['hostname']);
482
                }
483 8bab524e Phil Davis
                elseif ($user_settings['webgui']['webguihostnamemenu'] == 'fqdn') {
484 8ad8e9ab Phil Davis
                    $help_menu_title = htmlspecialchars($system_url);
485 1d129967 Christopher Fazendin
                }
486
                else {
487
                    $help_menu_title = 'Help';
488
                }
489
                foreach ([
490
					['name' => 'System',	     'menu' => $system_menu,	  'href' => null],
491
					['name' => 'Interfaces',     'menu' => $interfaces_menu,  'href' => null],
492
					['name' => 'Firewall',	     'menu' => $firewall_menu,	  'href' => null],
493
					['name' => 'Services',	     'menu' => $services_menu,	  'href' => null],
494
					['name' => 'VPN',		     'menu' => $vpn_menu,		  'href' => null],
495
					['name' => 'Status',	     'menu' => $status_menu,	  'href' => null],
496
					['name' => 'Diagnostics',    'menu' => $diagnostics_menu, 'href' => null],
497 9968e384 Steve Beaver
//					['name' => 'Gold',		     'menu' => $gold_menu,		  'href' => '_blank'],
498 1d129967 Christopher Fazendin
                    ['name' => $help_menu_title, 'menu' => $help_menu,		  'href' => '_blank']
499 69a17c90 Thane Gill
				] as $item):
500
					if ($item['name'] == 'Help' && $g['disablehelpmenu']) {
501
						continue;
502 898aa92c Steve Beaver
					}
503 7c3f1189 Phil Davis
504
					$menu_output = output_menu($item['menu'], $item['href'], $item['name']);
505
506
					if (strlen($menu_output) > 0):
507 898aa92c Steve Beaver
?>
508 31f03b6c Sjon Hortensius
				<li class="dropdown">
509 e97e9aca Thane Gill
					<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
510
						<?=gettext($item['name'])?>
511 31f03b6c Sjon Hortensius
						<span class="caret"></span>
512
					</a>
513 7c3f1189 Phil Davis
					<ul class="dropdown-menu" role="menu"><?=$menu_output?></ul>
514 31f03b6c Sjon Hortensius
				</li>
515 898aa92c Steve Beaver
516
<?php
517 7c3f1189 Phil Davis
					endif;
518 898aa92c Steve Beaver
			 	endforeach?>
519 fc2ba7e2 k-paulius
			</ul>
520
			<ul class="nav navbar-nav navbar-right">
521 5280f021 Phil Davis
				<?php if ($display_notices):?>
522 e97e9aca Thane Gill
					<?php $notices = get_notices()?>
523 31f03b6c Sjon Hortensius
					<li class="dropdown">
524 2617a1bc Jared Dillard
						<a href="#" data-toggle="modal" data-target="#notices" role="button" aria-expanded="false">
525 aa82505e Phil Davis
							<i class="fa fa-bell text-danger" title="<?=gettext("Notices")?>"></i>
526 2617a1bc Jared Dillard
							<span class="badge bg-danger"><?=count($notices)?></span>
527 31f03b6c Sjon Hortensius
						</a>
528
					</li>
529 2617a1bc Jared Dillard
				<?php
530
					endif;
531
				?>
532 07edce6d Stephen Beaver
					<li class="dropdown">
533 ce437697 Steve Beaver
						<a href="/index.php?logout" usepost>
534 8ad8e9ab Phil Davis
							<i class="fa fa-sign-out" title="<?=gettext("Logout") . " (" . $_SESSION['Username'] . "@" . htmlspecialchars($system_url) . ")"?>"></i>
535 07edce6d Stephen Beaver
						</a>
536
					</li>
537 d7218f77 Stephen Beaver
			</ul>
538 6eeca0ef Sjon Hortensius
		</div>
539
	</div>
540 31f03b6c Sjon Hortensius
</nav>
541 d7218f77 Stephen Beaver
542 477db933 Jared Dillard
<div class="container <?=$menuclass?>" <?=$columnsContainer?>>
543 45eebe10 Sander van Leeuwen
	<header class="header">
544 89dcfa01 Stephen Beaver
545
<?php
546
	// If you set $notitle = true BEFORE including head.inc, the page title will be supressed
547 aa82505e Phil Davis
	if (isset($notitle)) {
548 89dcfa01 Stephen Beaver
		print('<br />');
549
		unset($notitle);
550
	} else {
551 edcd7535 Phil Davis
		if (isset($pglinks)) {
552 ce437697 Steve Beaver
			print(genhtmltitle($pgtitle, $pglinks));
553 edcd7535 Phil Davis
		} else {
554
			print(genhtmltitle($pgtitle));
555
		}
556 89dcfa01 Stephen Beaver
	}
557
?>
558 0bf1e5fe Sjon Hortensius
		<ul class="context-links">
559 89dcfa01 Stephen Beaver
560 91d59881 NOYB
	<?php if (isset($widgets)): ?>
561 c05363c8 NOYB
		<li>
562 cee365e6 Stephen Beaver
			<a href="#" title="<?=gettext("Save dashboard layout")?>" id="btnstore" class="invisible">
563 91d59881 NOYB
				<i class="fa fa-save icon-pointer"></i>
564 c05363c8 NOYB
			</a>
565
		</li>
566
	<?php endif?>
567
568 91d59881 NOYB
	<?php if ($dashboard_available_widgets_hidden): ?>
569 35d8d613 NOYB
		<li>
570 91d59881 NOYB
			<a onclick="$('#widget-available').toggle(360);" title="<?=gettext("Available widgets")?>">
571
				<i class="fa fa-plus icon-pointer"></i>
572 35d8d613 NOYB
			</a>
573
		</li>
574
	<?php endif?>
575 36a844df Stephen Beaver
576 c05363c8 NOYB
	<?php if ($system_logs_filter_form_hidden): ?>
577
		<li>
578 29c39b7c k-paulius
			<a onclick="$('#filter-form').toggle(360)" title="<?=gettext("Log filter")?>">
579 7bd42c09 NOYB
				<i class="fa fa-filter icon-pointer"></i>
580 c05363c8 NOYB
			</a>
581
		</li>
582
	<?php endif ?>
583
584 7076def1 Stephen Beaver
	<?php if ($system_logs_manage_log_form_hidden):
585 820780b5 NOYB
			/* If the user does not have access to status logs settings page, then exclude the manage log panel icon from the title bar. */
586
			if (isAllowedPage("status_logs_settings.php")) {
587
	?>
588 c05363c8 NOYB
		<li>
589 29c39b7c k-paulius
			<a onclick="$('#manage-log-form').toggle(360)" title="<?=gettext("Manage log")?>">
590 7bd42c09 NOYB
				<i class="fa fa-wrench icon-pointer"></i>
591 c05363c8 NOYB
			</a>
592
		</li>
593 820780b5 NOYB
	<?php	}
594
		endif
595
	?>
596 c05363c8 NOYB
597 b1b8784a NOYB
	<?php if ($monitoring_settings_form_hidden): ?>
598
		<li>
599
			<a onclick="$('#monitoring-settings-form').toggle(360);" title="<?=gettext("Settings")?>">
600
				<i class="fa fa-wrench icon-pointer"></i>
601
			</a>
602
		</li>
603
	<?php endif?>
604
605
	<?php if ($status_monitoring): ?>
606
		<li>
607 10485d3c Jared Dillard
			<a class="update-graph" title="<?=gettext("Refresh Graph")?>">
608 b1b8784a NOYB
				<i class="fa fa-repeat icon-pointer"></i>
609
			</a>
610
		</li>
611 726ebc65 Jared Dillard
		<li>
612
			<a class="export-graph" id="export-graph" title="<?=gettext("Export Graph")?>">
613
				<i class="fa fa-download icon-pointer"></i>
614
			</a>
615
		</li>
616 b1b8784a NOYB
	<?php endif?>
617
618 c05363c8 NOYB
<?php
619 38386fb4 NOYB
if (!$hide_service_status && !empty($shortcuts[$shortcut_section]['service']) && isAllowedPage('status_services.php')) {
620 649cde0b Sander van Leeuwen
	$ssvc = array();
621
	switch ($shortcut_section) {
622
		case "openvpn":
623
			$ssvc = find_service_by_openvpn_vpnid($vpnid);
624
			break;
625
		case "captiveportal":
626
			$ssvc = find_service_by_cp_zone($cpzone);
627
			break;
628
		default:
629
			$ssvc = find_service_by_name($shortcuts[$shortcut_section]['service']);
630 31f03b6c Sjon Hortensius
	}
631 649cde0b Sander van Leeuwen
	if (!empty($ssvc)) {
632 ee678e75 Sander van Leeuwen
		// echo '<li>'. get_service_status_icon($ssvc, false). '</li>'; TODO: Add missing function
633 29fda3d3 Stephen Beaver
		echo '<li>'. get_service_control_links($ssvc, false). '</li>';
634 649cde0b Sander van Leeuwen
	}
635
}
636 31f03b6c Sjon Hortensius
637 38386fb4 NOYB
if (('' != ($link = get_shortcut_main_link($shortcut_section, false))) && (isAllowedPage($shortcuts[$shortcut_section]['main']))) {
638 9014e27c k-paulius
	echo '<li>' . $link . '</li>';
639
}
640
641 38386fb4 NOYB
if (('' != ($link = get_shortcut_status_link($shortcut_section, false))) && (isAllowedPage($shortcuts[$shortcut_section]['status']))) {
642 9014e27c k-paulius
	echo '<li>' . $link . '</li>';
643
}
644
645 38386fb4 NOYB
if (('' != ($link = get_shortcut_log_link($shortcut_section, false))) && (isAllowedPage($shortcuts[$shortcut_section]['log']))) {
646 9014e27c k-paulius
	echo '<li>' . $link . '</li>';
647
}
648 45eebe10 Sander van Leeuwen
649 0bf1e5fe Sjon Hortensius
?>
650 7c3f1189 Phil Davis
	<?php if (!$g['disablehelpicon'] && isAllowedPage("help.php")): ?>
651 0bf1e5fe Sjon Hortensius
		<li>
652 20e108e0 NOYB
			<a href="<?=$helpurl?>" target="_blank" title="<?=gettext("Help for items on this page")?>">
653 7ea65674 Jared Dillard
				<i class="fa fa-question-circle"></i>
654 0bf1e5fe Sjon Hortensius
			</a>
655
		</li>
656 e259607f Thane Gill
	<?php endif?>
657 0bf1e5fe Sjon Hortensius
		</ul>
658 45eebe10 Sander van Leeuwen
	</header>
659 56c100ab Erik Fonnesbeck
<?php
660 31f03b6c Sjon Hortensius
/* if upgrade in progress, alert user */
661 c33a3c20 k-paulius
if (is_subsystem_dirty('packagelock') || (file_exists('/conf/needs_package_sync') && platform_booting())) {
662 31f03b6c Sjon Hortensius
	if (file_exists('/conf/needs_package_sync') && platform_booting()) {
663 f8a1be56 Phil Davis
		$warning_text = sprintf(gettext('%1$s%3$s is booting, then packages will be reinstalled in the background.%2$s%1$sDo not make changes in the GUI until this is complete.%2$s'), '<p>', '</p>', $g['product_name']);
664 31f03b6c Sjon Hortensius
	} else {
665 ecffb0bb Phil Davis
		$pgtitle = array(gettext("System"), gettext("Package Manager"));
666 f8a1be56 Phil Davis
		$warning_text = sprintf(gettext('%1$sPackages are currently being reinstalled in the background.%2$s%1$sDo not make changes in the GUI until this is complete.%2$s'), '<p>', '</p>');
667
		$warning_text .= sprintf(gettext('%1$sIf the above message is still displayed after a couple of hours, use the \'Clear Package Lock\' button on the %3$s page and reinstall packages manually.%2$s'), '<p>', '</p>', sprintf('<a href="diag_backup.php" title="%1$s &gt; %2$s">%1$s &gt; %2$s</a>', gettext('Diagnostics'), htmlspecialchars(gettext('Backup & Restore'))));
668 31f03b6c Sjon Hortensius
	}
669 180508d1 Stephen Beaver
670 f78bbe16 Phil Davis
	print_info_box($warning_text);
671 31f03b6c Sjon Hortensius
}
672
673 d7218f77 Stephen Beaver
/*	If this page is being remotely managed then do not allow the loading of the contents. */
674 1180e4f0 Sjon Hortensius
if ($config['remote_managed_pages']['item']) {
675 ecffb0bb Phil Davis
	foreach ($config['remote_managed_pages']['item'] as $rmp) {
676 1180e4f0 Sjon Hortensius
		if ($rmp == $_SERVER['SCRIPT_NAME']) {
677 3b3a95e5 Phil Davis
			print_info_box(gettext("This page is currently being managed by a remote machine."));
678 31f03b6c Sjon Hortensius
			include("foot.inc");
679 56c100ab Erik Fonnesbeck
			exit;
680
		}
681 1180e4f0 Sjon Hortensius
	}
682 e259607f Thane Gill
}
683 d7218f77 Stephen Beaver
684
// Modal notices window
685 a46c437d Stephen Beaver
// The notices modal needs to be outside of the page display div or things get messy
686 5280f021 Phil Davis
if ($display_notices):
687
?>
688 d7218f77 Stephen Beaver
689
<div id="notices" class="modal fade" role="dialog">
690 362642c1 Jared Dillard
	<div class="modal-dialog">
691 d7218f77 Stephen Beaver
		<div class="modal-content">
692
			<div class="modal-header">
693
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
694
					<span aria-hidden="true">&times;</span>
695
				</button>
696
697 f49cd725 Phil Davis
				<h3 class="modal-title" id="myModalLabel"><?=gettext("Notices")?></h3>
698 d7218f77 Stephen Beaver
			</div>
699
700
			<div class="modal-body">
701
<?php
702
	$noticeCategories = array();
703
704 aa82505e Phil Davis
	if (is_array($notices)) {
705
		foreach ($notices as $time => $notice) {
706
			if (!isset($noticeCategories[ $notice['category'] ])) {
707 d7218f77 Stephen Beaver
				$noticeCategories[ $notice['category'] ] = array();
708 aa82505e Phil Davis
			}
709 d7218f77 Stephen Beaver
710
			$notice['time'] = $time;
711
			array_push($noticeCategories[ $notice['category'] ], $notice);
712
		}
713
	}
714
715
	foreach ($noticeCategories as $category => $catNotices):?>
716
				<h4><?=$category?></h4>
717
				<ul>
718
<?php
719
	foreach ($catNotices as $notice):
720
?>
721
					<li>
722
						<b>
723
<?php if (!empty($notice['url'])):?>
724 e4710ed5 Chris Buechler
							<a href="<?=htmlspecialchars($notice['url'])?>"><?=htmlspecialchars($notice['id'])?></a> -
725 d7218f77 Stephen Beaver
<?php endif;?>
726
						</b>
727 348fae16 PiBa-NL
						<?=str_replace("\n", "<br/>", htmlspecialchars($notice['notice']))?>
728 d7218f77 Stephen Beaver
						<i>@ <?=date('Y-m-d H:i:s', $notice['time'])?></i>
729
					</li>
730
<?php	endforeach;?>
731
				</ul>
732
<?php endforeach;?>
733
			</div>
734
735
			<div class="modal-footer">
736 a77c2a23 Jared Dillard
				<button type="button" class="btn btn-info" data-dismiss="modal"><i class="fa fa-times icon-embed-btn"></i><?=gettext("Close")?></button>
737 5280f021 Phil Davis
<?php if ($allow_clear_notices && isAllowedPage("/index.php")):?>
738 b6786d45 Stephen Beaver
				<button type="button" id="clearallnotices" class="btn btn-primary"><i class="fa fa-trash-o icon-embed-btn"></i><?=gettext("Mark All as Read")?></button>
739 fe80b3aa Phil Davis
<?php endif;?>
740 d7218f77 Stephen Beaver
			</div>
741
		</div>
742
	</div>
743
</div>
744
745 8fd9052f Colin Fleming
<script type="text/javascript">
746 8d3f3e34 Stephen Beaver
//<![CDATA[
747 aa82505e Phil Davis
	events.push(function() {
748 8d3f3e34 Stephen Beaver
	    $('#clearallnotices').click(function() {
749 329a1cd5 Stephen Beaver
			ajaxRequest = $.ajax({
750
				url: "/index.php",
751
				type: "post",
752 0206483d Stephen Beaver
				data: { closenotice: "all"},
753 aa82505e Phil Davis
				success: function() {
754 0206483d Stephen Beaver
					window.location = window.location.href;
755
				},
756 aa82505e Phil Davis
				failure: function() {
757 1860c406 Phil Davis
					alert("Error clearing notices!");
758 0206483d Stephen Beaver
				}
759 329a1cd5 Stephen Beaver
			});
760 8d3f3e34 Stephen Beaver
		});
761
	});
762
//]]>
763 888c3c1b Stephen Beaver
</script>
764
765 5280f021 Phil Davis
<?php
766
endif; // ($display_notices)
767 0b87fcf5 bruno
768
// Get the flash Messages
769
get_flash_message();