Project

General

Profile

Download (28.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * head.inc
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23

    
24
require_once("globals.inc");
25
require_once("functions.inc");
26
require_once("shortcuts.inc");
27
require_once("service-utils.inc");
28
require_once('notices.inc');
29

    
30
header('Content-Type: text/html; charset=utf-8');
31

    
32
$pagetitle = gentitle($pgtitle);
33
$system_url = $config['system']['hostname'] . "." . $config['system']['domain'];
34

    
35
if ($user_settings['webgui']['pagenamefirst']) {
36
	$tabtitle = $pagetitle . " - " . htmlspecialchars($system_url);
37
} else {
38
	$tabtitle = htmlspecialchars($system_url) . " - " . $pagetitle;
39
}
40

    
41
$cssfile = "/css/pfSense.css";
42

    
43
if (isset($user_settings['webgui']['webguicss'])) {
44
	if (file_exists("/usr/local/www/css/" . $user_settings['webgui']['webguicss'])) {
45
		$cssfile = "/css/" . $user_settings['webgui']['webguicss'];
46
	}
47
}
48

    
49
// set default columns to two if unset
50
if (!isset($config['system']['webgui']['dashboardcolumns'])) {
51
	$config['system']['webgui']['dashboardcolumns'] = 2;
52
}
53

    
54
?>
55
<!DOCTYPE html>
56
<html lang="en">
57
<head>
58
	<meta name="viewport" content="width=device-width, initial-scale=1">
59

    
60
	<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
61
	<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
62
	<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
63
	<link rel="manifest" href="/manifest.json">
64
	<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
65
	<meta name="theme-color" content="#ffffff">
66

    
67
	<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')?>">
68
	<link rel="stylesheet" href="/vendor/sortable/sortable-theme-bootstrap.css?v=<?=filemtime('/usr/local/www/vendor/sortable/sortable-theme-bootstrap.css')?>">
69
	<link rel="stylesheet" href="<?=$cssfile?>?v=<?=filemtime('/usr/local/www/' . $cssfile)?>" />
70

    
71
	<title><?=$tabtitle?></title>
72
	<script type="text/javascript">
73
	//<![CDATA[
74
	var events = events || [];
75
	var newSeperator = false;
76
	//]]>
77
	</script>
78
</head>
79

    
80
<?php
81

    
82
/* Determine automated help URL. Should output the page name and parameters
83
   separately */
84
$uri_split = "";
85
preg_match("/\/(.*)\?(.*)/", $_SERVER["REQUEST_URI"], $uri_split);
86

    
87
/* If there was no match, there were no parameters, just grab the filename
88
   Otherwise, use the matched filename from above. */
89
if (empty($uri_split[0])) {
90
	$pagename = ltrim($_SERVER["REQUEST_URI"], '/');
91
} else {
92
	$pagename = $uri_split[1];
93
}
94

    
95
/* If the page name is still empty, the user must have requested / (index.php) */
96
if (empty($pagename)) {
97
	$pagename = "index.php";
98
}
99

    
100
/* If the filename is pkg_edit.php or wizard.php, reparse looking
101
	for the .xml filename */
102
if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "wizard.php")) {
103
	$param_split = explode('&', $uri_split[2]);
104
	foreach ($param_split as $param) {
105
		if (substr($param, 0, 4) == "xml=") {
106
			$xmlfile = explode('=', $param);
107
			$pagename = $xmlfile[1];
108
		}
109
	}
110
} else if ($pagename == "status_logs.php") {
111
	$param_split = explode('&', $uri_split[2]);
112
	foreach ($param_split as $param) {
113
		if (substr($param, 0, 8) == "logfile=") {
114
			$logtype = explode('=', $param);
115
			$pagename .= '-' . $logtype[1];
116
		}
117
	}
118
}
119

    
120
// Build the full help URL.
121
$helpurl .= "{$g['help_base_url']}?page={$pagename}";
122

    
123
/*
124
 * Read files from $g['ext_menu_path']/*.xml and fill an array with menu info
125
 */
126
function read_ext_menu_path_data() {
127
	global $g;
128

    
129
	$result = array();
130

    
131
	if (!is_dir($g['ext_menu_path'])) {
132
		return $result;
133
	}
134

    
135
	foreach (glob("{$g['ext_menu_path']}/*.xml") as $menu_xml) {
136
		$xml_data = parse_xml_config_pkg($menu_xml, "packagegui");
137
		if (empty($xml_data['menu'])) {
138
			continue;
139
		}
140
		foreach ($xml_data['menu'] as $menu) {
141
			$result[] = $menu;
142
		}
143
	}
144

    
145
	return $result;
146
}
147

    
148
// Create a menu entry of any installed packages in the specified category
149
// (Now reads the menu information from $config['installedpackages']['menu'] only)
150
function return_ext_menu($section) {
151
	global $config, $ext_menu_path_data;
152

    
153
	$htmltext = "";
154
	$extarray = array();
155
	$ext_menu_entries = array();
156

    
157
	if ((!empty($config['installedpackages']['package'])) && (!empty($config['installedpackages']['menu']))) {
158
		foreach ($config['installedpackages']['menu'] as $menu) {
159
			if (isset($menu['name']) && ($menu['name'] != "AutoConfigBackup")) { // AutoConfigBackup was moved to a built-in function
160
	//			print('Name: ' . $menu['name'] . ', Pkg category: ' . $menu['category'] . ', Section: ' . $section . '<br />');
161
				if (isset($menu['section']) && ($menu['section'] == $section)) {
162
					$ext_menu_entries[] = $menu;
163
				}
164
			}
165
		}
166
	}
167

    
168
	foreach ($ext_menu_path_data as $menu) {
169
		if ($menu['section'] == $section) {
170
			$ext_menu_entries[] = $menu;
171
		}
172
	}
173

    
174
	foreach ($ext_menu_entries as $menu) {
175
		if ($menu['url'] != "") {
176
			$test_url = $menu['url'];
177
			$addresswithport = getenv("HTTP_HOST");
178
			$colonpos = strpos($addresswithport, ":");
179

    
180
			if ($colonpos !== false) {
181
				//my url is actually just the IP address of the pfsense box
182
				$myurl = substr($addresswithport, 0, $colonpos);
183
			} else {
184
				$myurl = $addresswithport;
185
			}
186
			$description = str_replace('$myurl', $myurl, $menu['url']);
187
		} else {
188
			$description = '/pkg.php?xml=' . $menu['configfile'];
189
			$test_url=$description;
190
		}
191

    
192
		if (isAllowedPage($test_url)) {
193
			$extarray[] = array($menu['name'], $description);
194
		}
195
	}
196

    
197
	return $extarray;
198
}
199

    
200
function output_menu($arrayitem, $target = null, $section = "") {
201
	$output = "";
202

    
203
	foreach ($arrayitem as $item) {
204

    
205
		/* If the user has access to help pages, also show the full help menu. See #5909 */
206
		if (isAllowedPage($item[1]) || $item[1] == "/index.php?logout" ||
207
		    (($section == "Help") && isAllowedPage("help.php")) ||
208
		    (substr($item[1], 0, 8) == "https://")) {
209
			$attr = sprintf("href=\"%s\"", htmlentities($item[1]));
210

    
211
			if ($target) {
212
				$attr .= sprintf(" target=\"%s\"", htmlentities($target));
213
			}
214

    
215
			$class = "navlnk";
216

    
217
			if ($item['class']) {
218
				$class .= " {$item['class']}";
219
			}
220

    
221
			$attr .= sprintf(" class=\"%s\"", htmlentities($class));
222

    
223
			if ($item['style']) {
224
				$attr .= sprintf(" style=\"%s\"", htmlentities($item['style']));
225
			}
226

    
227

    
228
			if ($item[0] == '-DIVIDER-') {
229
				$output .= ' <li class="divider"></li>';
230
			} else {
231
				$output .= "<li>". sprintf("<a %s %s>%s</a>", $attr, ($item[1] == "/index.php?logout") ? "usepost":"",$item[0]) . "</li>\n";
232
			}
233
		}
234
	}
235

    
236
	return $output;
237
}
238

    
239
$ext_menu_path_data = read_ext_menu_path_data();
240

    
241
// System
242
$system_menu = array();
243
$system_menu[] = array(gettext("Logout") . " (" . $_SESSION['Username'] . ")", "/index.php?logout");
244
$system_menu[] = array(gettext("Advanced"), "/system_advanced_admin.php");
245
$system_menu[] = array(gettext("Update"), "/pkg_mgr_install.php?id=firmware");
246
$system_menu[] = array(gettext("General Setup"), "/system.php");
247
$system_menu[] = array(gettext("High Avail. Sync"), "/system_hasync.php");
248
$system_menu[] = array(gettext("Package Manager"), "/pkg_mgr_installed.php");
249
$system_menu[] = array(gettext("Setup Wizard"), "/wizard.php?xml=setup_wizard.xml");
250
$system_menu[] = array(gettext("Routing"), "/system_gateways.php");
251
$system_menu[] = array(gettext("Cert. Manager"), "/system_camanager.php");
252
if (!isAllowedPage("system_usermanager.php")) {
253
	$system_menu[] = array(gettext("User Manager"), "/system_usermanager_passwordmg.php");
254
} else {
255
	$system_menu[] = array(gettext("User Manager"), "/system_usermanager.php");
256
}
257

    
258
if ($user_settings['customsettings'] && isAllowedPage("system_user_settings.php")) {
259
	$system_menu[] = array(gettext("User Settings"), "/system_user_settings.php");
260
}
261

    
262
$system_menu = msort(array_merge($system_menu, return_ext_menu("System")), 0);
263

    
264
// Interfaces
265
// NOTE:
266
// Now that menus are sorted, adding a DIVIDER must be done after the sorting so an array is formed of the
267
// items above the divider and another for below it. These are then sorted and combined with the divider
268
$interfaces_menu = array();
269
$interfaces_top = array();
270
$interfaces_bottom = array();
271

    
272
if (!isset($config['system']['webgui']['noassigninterfaces'])) {
273
	$interfaces_top[] = array(gettext("Assignments"), "/interfaces_assign.php");
274
	$div = true;
275
}
276

    
277
$platform = system_identify_specific_platform();
278

    
279
if ($platform['name'] == "uFW") {
280
	$interfaces_top[] = array(gettext("Switches"), "/switch_system.php");
281
}
282

    
283
$opts = get_configured_interface_with_descr(true);
284

    
285
foreach ($opts as $oif => $odescr) {
286
	if (!isset($config['interfaces'][$oif]['ovpn'])) {
287
		$interfaces_bottom[] = array(htmlspecialchars($odescr), "/interfaces.php?if={$oif}");
288
	}
289
}
290

    
291
$interfaces_bottom = array_merge($interfaces_bottom, return_ext_menu("Interfaces"));
292

    
293
if ($user_settings['webgui']['interfacessort']) {
294
	$interfaces_bottom = msort($interfaces_bottom, 0);
295
}
296

    
297
// Combine the top section, the divider and the bottom section of this menu
298
$interfaces_menu = array_merge($interfaces_top, [array(0 => "-DIVIDER-")], $interfaces_bottom);
299

    
300
// Firewall
301
$firewall_menu = array();
302
$firewall_menu[] = array(gettext("Aliases"), "/firewall_aliases.php");
303
$firewall_menu[] = array(gettext("NAT"), "/firewall_nat.php");
304
$firewall_menu[] = array(gettext("Rules"), "/firewall_rules.php");
305
$firewall_menu[] = array(gettext("Schedules"), "/firewall_schedule.php");
306
$firewall_menu[] = array(gettext("Traffic Shaper"), "/firewall_shaper.php");
307
$firewall_menu[] = array(gettext("Virtual IPs"), "/firewall_virtual_ip.php");
308
$firewall_menu = msort(array_merge($firewall_menu, return_ext_menu("Firewall")), 0);
309

    
310
// Services
311
$services_menu = array();
312
$services_menu[] = array(gettext("Auto Config Backup"), "/services_acb.php");
313
$services_menu[] = array(gettext("Captive Portal"), "/services_captiveportal.php");
314
$services_menu[] = array(gettext("DNS Forwarder"), "/services_dnsmasq.php");
315
$services_menu[] = array(gettext("DNS Resolver"), "/services_unbound.php");
316
$services_menu[] = array(gettext("DHCP Relay"), "/services_dhcp_relay.php");
317
$services_menu[] = array(gettext("DHCPv6 Relay"), "/services_dhcpv6_relay.php");
318

    
319
if ($g['services_dhcp_server_enable']) {
320
	$services_menu[] = array(gettext("DHCP Server"), "/services_dhcp.php");
321
	$services_menu[] = array(htmlspecialchars(gettext("DHCPv6 Server & RA")), "/services_dhcpv6.php");
322
}
323

    
324
$services_menu[] = array(gettext("Dynamic DNS"), "/services_dyndns.php");
325
$services_menu[] = array(gettext("IGMP Proxy"), "/services_igmpproxy.php");
326
$services_menu[] = array(gettext("NTP"), "/services_ntpd.php");
327
$services_menu[] = array(gettext("PPPoE Server"), "/services_pppoe.php");
328
$services_menu[] = array(gettext("SNMP"), "/services_snmp.php");
329

    
330
if (count($config['interfaces']) > 1) {
331
	/* no use for UPnP in single-interface deployments
332
	remove to reduce user confusion
333
	*/
334
	$services_menu[] = array(gettext("UPnP &amp; NAT-PMP"), "/pkg_edit.php?xml=miniupnpd.xml");
335
}
336

    
337
$services_menu[] = array(gettext("Wake-on-LAN"), "/services_wol.php");
338
$services_menu = msort(array_merge($services_menu, return_ext_menu("Services")), 0);
339

    
340
// VPN
341
$vpn_menu = array();
342
$vpn_menu[] = array(gettext("IPsec"), "/vpn_ipsec.php");
343
$vpn_menu[] = array(gettext("OpenVPN"), "/vpn_openvpn_server.php");
344
//$vpn_menu[] = array(gettext("PPTP"), "/vpn_pptp.php");
345
$vpn_menu[] = array(gettext("L2TP"), "/vpn_l2tp.php");
346
$vpn_menu = msort(array_merge($vpn_menu, return_ext_menu("VPN")), 0);
347

    
348
// Status
349
$status_menu = array();
350
$status_menu[] = array(gettext("Captive Portal"), "/status_captiveportal.php");
351
$status_menu[] = array(gettext("CARP (failover)"), "/status_carp.php");
352
$status_menu[] = array(gettext("Dashboard"), "/index.php");
353
$status_menu[] = array(gettext("Gateways"), "/status_gateways.php");
354
$status_menu[] = array(gettext("DHCP Leases"), "/status_dhcp_leases.php");
355
$status_menu[] = array(gettext("DHCPv6 Leases"), "/status_dhcpv6_leases.php");
356
$status_menu[] = array(gettext("DNS Resolver"), "/status_unbound.php");
357
$status_menu[] = array(gettext("Filter Reload"), "/status_filter_reload.php?user=true");
358
$status_menu[] = array(gettext("Interfaces"), "/status_interfaces.php");
359
$status_menu[] = array(gettext("IPsec"), "/status_ipsec.php");
360
$status_menu[] = array(gettext("NTP"), "/status_ntpd.php");
361
$status_menu[] = array(gettext("OpenVPN"), "/status_openvpn.php");
362
$status_menu[] = array(gettext("Queues"), "/status_queues.php");
363
$status_menu[] = array(gettext("Services"), "/status_services.php");
364
$status_menu[] = array(gettext("System Logs"), "/status_logs.php");
365
$status_menu[] = array(gettext("Traffic Graph"), "/status_graph.php");
366

    
367
if (count($config['interfaces']) > 1) {
368
	$status_menu[] = array(gettext("UPnP &amp; NAT-PMP"), "/status_upnp.php");
369
}
370

    
371
$wifdescrs = array();
372
$ifentries = get_configured_interface_with_descr();
373
foreach ($ifentries as $ent => $entdesc) {
374
	if (is_array($config['interfaces'][$ent]['wireless']) &&
375
	    preg_match($g['wireless_regex'], $config['interfaces'][$ent]['if'])) {
376
		$wifdescrs[$ent] = $entdesc;
377
	}
378
}
379

    
380
if (count($wifdescrs) > 0) {
381
	$status_menu[] = array(gettext("Wireless"), "/status_wireless.php");
382
}
383

    
384
$status_menu = msort(array_merge($status_menu, return_ext_menu("Status")), 0);
385

    
386
// Diagnostics
387
$diagnostics_menu = array();
388
$diagnostics_menu[] = array(gettext("ARP Table"), "/diag_arp.php");
389
$diagnostics_menu[] = array(gettext("Authentication"), "/diag_authentication.php");
390
$diagnostics_menu[] = array(htmlspecialchars(gettext("Backup & Restore")), "/diag_backup.php");
391
$diagnostics_menu[] = array(gettext("Command Prompt"), "/diag_command.php");
392
$diagnostics_menu[] = array(gettext("DNS Lookup"), "/diag_dns.php");
393
$diagnostics_menu[] = array(gettext("Edit File"), "/diag_edit.php");
394
$diagnostics_menu[] = array(gettext("Factory Defaults"), "/diag_defaults.php");
395

    
396
if (file_exists("/var/run/gmirror_active")) {
397
	$diagnostics_menu[] = array(gettext("GEOM Mirrors"), "/diag_gmirror.php");
398
}
399

    
400
$diagnostics_menu[] = array(gettext("Halt System"), "/diag_halt.php");
401
$diagnostics_menu[] = array(gettext("Limiter Info"), "/diag_limiter_info.php");
402
$diagnostics_menu[] = array(gettext("NDP Table"), "/diag_ndp.php");
403
$diagnostics_menu[] = array(gettext("Tables"), "/diag_tables.php");
404
$diagnostics_menu[] = array(gettext("Ping"), "/diag_ping.php");
405
$diagnostics_menu[] = array(gettext("Test Port"), "/diag_testport.php");
406
$diagnostics_menu[] = array(gettext("pfInfo"), "/diag_pf_info.php");
407
$diagnostics_menu[] = array(gettext("pfTop"), "/diag_pftop.php");
408
$diagnostics_menu[] = array(gettext("Reboot"), "/diag_reboot.php");
409
$diagnostics_menu[] = array(gettext("Routes"), "/diag_routes.php");
410
$diagnostics_menu[] = array(gettext("S.M.A.R.T. Status"), "/diag_smart.php");
411
$diagnostics_menu[] = array(gettext("Sockets"), "/diag_sockets.php");
412
$diagnostics_menu[] = array(gettext("States"), "/diag_dump_states.php");
413
$diagnostics_menu[] = array(gettext("States Summary"), "/diag_states_summary.php");
414
$diagnostics_menu[] = array(gettext("System Activity"), "/diag_system_activity.php");
415
$diagnostics_menu[] = array(gettext("Traceroute"), "/diag_traceroute.php");
416
$diagnostics_menu[] = array(gettext("Packet Capture"), "/diag_packet_capture.php");
417

    
418
$diagnostics_menu = msort(array_merge($diagnostics_menu, return_ext_menu("Diagnostics")), 0);
419

    
420
if (!$g['disablehelpmenu']) {
421
	$help_menu = array();
422
	$help_menu[] = array(gettext("About this Page"), $helpurl);
423
	if ($g['product_name'] == "pfSense") {
424
		$help_menu[] = array(gettext("Bug Database"), "https://redirects.netgate.com/issues");
425
	}
426

    
427
	$help_menu[] = array(gettext("User Forum"), "https://redirects.netgate.com/forum");
428
	$help_menu[] = array(gettext("Documentation"), "https://redirects.netgate.com/docs");
429
	$help_menu[] = array(gettext("Paid Support"), "https://redirects.netgate.com/support");
430
	$help_menu[] = array(gettext("pfSense Book"), "https://redirects.netgate.com/book");
431
	$help_menu[] = array(gettext("FreeBSD Handbook"), "https://redirects.netgate.com/fbsdhandbook");
432
	$help_menu[] = array(gettext("User survey"), "https://redirects.netgate.com/survey_1");
433
	$help_menu = msort(array_merge($help_menu, return_ext_menu("Help")), 0);
434
}
435

    
436
$menuclass = "static";
437

    
438
if ($user_settings['webgui']['webguifixedmenu'] == "fixed") {
439
	$menuclass = "fixed";
440
}
441

    
442
$numColumns = (int) $user_settings['webgui']['dashboardcolumns'];
443

    
444
if (($pagename === "index.php") && ($numColumns > 2)) {
445
	$columnsContainer = 'style="max-width: ' . 585*$numColumns . 'px;width: 100%"';
446
}
447

    
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
	if (isAdminUID($_SESSION['Username']) || userHasPrivilege($user_entry, "user-view-clear-notices") || userHasPrivilege($user_entry, "page-all")) {
455
		$display_notices = true;
456
		$allow_clear_notices = true;
457
	} elseif (userHasPrivilege($user_entry, "user-view-notices")) {
458
		$display_notices = true;
459
	}
460
}
461
?>
462
<body id="<?=$numColumns?>">
463
<nav id="topmenu" class="navbar navbar-<?=$menuclass?>-top navbar-inverse">
464
	<div class="container">
465
		<div class="navbar-header">
466
			<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#pf-navbar">
467
				<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
			<a class="navbar-brand" href="/">
473
				<?php include("/usr/local/www/logo.svg"); ?>
474
				<span style="color:white;font-size:.5em;text-transform:uppercase;letter-spacing:1px;">Community Edition</span>
475
			</a>
476
		</div>
477
		<div class="collapse navbar-collapse" id="pf-navbar">
478
			<ul class="nav navbar-nav">
479
			<?php
480
                if ($user_settings['webgui']['webguihostnamemenu'] == 'hostonly') {
481
                    $help_menu_title = htmlspecialchars($config['system']['hostname']);
482
                }
483
                elseif ($user_settings['webgui']['webguihostnamemenu'] == 'fqdn') {
484
                    $help_menu_title = htmlspecialchars($system_url);
485
                }
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
                    ['name' => $help_menu_title, 'menu' => $help_menu,		  'href' => '_blank']
498
				] as $item):
499
					if ($item['name'] == 'Help' && $g['disablehelpmenu']) {
500
						continue;
501
					}
502

    
503
					$menu_output = output_menu($item['menu'], $item['href'], $item['name']);
504

    
505
					if (strlen($menu_output) > 0):
506
?>
507
				<li class="dropdown">
508
					<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
509
						<?=gettext($item['name'])?>
510
						<span class="caret"></span>
511
					</a>
512
					<ul class="dropdown-menu" role="menu"><?=$menu_output?></ul>
513
				</li>
514

    
515
<?php
516
					endif;
517
			 	endforeach?>
518
			</ul>
519
			<ul class="nav navbar-nav navbar-right">
520
				<?php if ($display_notices):?>
521
					<?php $notices = get_notices()?>
522
					<li class="dropdown">
523
						<a href="#" data-toggle="modal" data-target="#notices" role="button" aria-expanded="false">
524
							<i class="fa fa-bell text-danger" title="<?=gettext("Notices")?>"></i>
525
							<span class="badge bg-danger"><?=count($notices)?></span>
526
						</a>
527
					</li>
528
				<?php
529
					endif;
530
				?>
531
					<li class="dropdown">
532
						<a href="/index.php?logout" usepost>
533
							<i class="fa fa-sign-out" title="<?=gettext("Logout") . " (" . $_SESSION['Username'] . "@" . htmlspecialchars($system_url) . ")"?>"></i>
534
						</a>
535
					</li>
536
			</ul>
537
		</div>
538
	</div>
539
</nav>
540

    
541
<div class="container <?=$menuclass?>" <?=$columnsContainer?>>
542

    
543
<?php
544
	// Print a warning if current user = admin and the password hash is still set to the default value
545
	if ($_SESSION['Username'] == "admin") {
546
		$cu = getUserEntry("admin");
547

    
548
		$hash = (empty($cu['bcrypt-hash']) ? $cu['password'] : $cu['bcrypt-hash']);
549

    
550
		if (password_verify($g['factory_shipped_password'], $hash)) {
551
			print('<div class="alert alert-danger">' .
552
				sprintf(gettext('%sWARNING:%s The \'admin\' account password is set to the default value. ' .
553
				' %s Change the password in the User Manager.%s'),
554
				'<strong>', '</strong>', '<a href="/system_usermanager.php?act=edit&userid=' . $cu['uid'] . '">', '</a>') .
555
				'</div>');
556
		}
557
	}
558
?>
559

    
560
	<header class="header">
561

    
562
<?php
563
	// If you set $notitle = true BEFORE including head.inc, the page title will be supressed
564
	if (isset($notitle)) {
565
		print('<br />');
566
		unset($notitle);
567
	} else {
568
		if (isset($pglinks)) {
569
			print(genhtmltitle($pgtitle, $pglinks));
570
		} else {
571
			print(genhtmltitle($pgtitle));
572
		}
573
	}
574
?>
575
		<ul class="context-links">
576

    
577
	<?php if (isset($widgets)): ?>
578
		<li>
579
			<a href="#" title="<?=gettext("Save dashboard layout")?>" id="btnstore" class="invisible">
580
				<i class="fa fa-save icon-pointer"></i>
581
			</a>
582
		</li>
583
	<?php endif?>
584

    
585
	<?php if ($dashboard_available_widgets_hidden): ?>
586
		<li>
587
			<a onclick="$('#widget-available').toggle(360);" title="<?=gettext("Available widgets")?>">
588
				<i class="fa fa-plus icon-pointer"></i>
589
			</a>
590
		</li>
591
	<?php endif?>
592

    
593
	<?php if ($system_logs_filter_form_hidden): ?>
594
		<li>
595
			<a onclick="$('#filter-form').toggle(360)" title="<?=gettext("Log filter")?>">
596
				<i class="fa fa-filter icon-pointer"></i>
597
			</a>
598
		</li>
599
	<?php endif ?>
600

    
601
	<?php if ($system_logs_manage_log_form_hidden):
602
			/* If the user does not have access to status logs settings page, then exclude the manage log panel icon from the title bar. */
603
			if (isAllowedPage("status_logs_settings.php")) {
604
	?>
605
		<li>
606
			<a onclick="$('#manage-log-form').toggle(360)" title="<?=gettext("Manage log")?>">
607
				<i class="fa fa-wrench icon-pointer"></i>
608
			</a>
609
		</li>
610
	<?php	}
611
		endif
612
	?>
613

    
614
	<?php if ($monitoring_settings_form_hidden): ?>
615
		<li>
616
			<a onclick="$('#monitoring-settings-form').toggle(360);" title="<?=gettext("Settings")?>">
617
				<i class="fa fa-wrench icon-pointer"></i>
618
			</a>
619
		</li>
620
	<?php endif?>
621

    
622
	<?php if ($status_monitoring): ?>
623
		<li>
624
			<a class="update-graph" title="<?=gettext("Refresh Graph")?>">
625
				<i class="fa fa-repeat icon-pointer"></i>
626
			</a>
627
		</li>
628
		<li>
629
			<a class="export-graph" id="export-graph" title="<?=gettext("Export Graph")?>">
630
				<i class="fa fa-download icon-pointer"></i>
631
			</a>
632
		</li>
633
	<?php endif?>
634

    
635
<?php
636
/* Determine shortcut section for XML-based packages */
637
if (empty($shortcut_section) && !empty($xmlfile)) {
638
	$shortcut_section = basename($pagename, '.xml');
639
}
640

    
641
if (!$hide_service_status && !empty($shortcuts[$shortcut_section]['service']) && isAllowedPage('status_services.php')) {
642
	$ssvc = array();
643
	switch ($shortcut_section) {
644
		case "openvpn":
645
			$ssvc = find_service_by_openvpn_vpnid($vpnid);
646
			break;
647
		case "captiveportal":
648
			$ssvc = find_service_by_cp_zone($cpzone);
649
			break;
650
		default:
651
			$ssvc = find_service_by_name($shortcuts[$shortcut_section]['service']);
652
	}
653
	if (!empty($ssvc)) {
654
		// echo '<li>'. get_service_status_icon($ssvc, false). '</li>'; TODO: Add missing function
655
		echo '<li>'. get_service_control_links($ssvc, false). '</li>';
656
	}
657
}
658

    
659
if (('' != ($link = get_shortcut_main_link($shortcut_section, false))) && (isAllowedPage($shortcuts[$shortcut_section]['main']))) {
660
	echo '<li>' . $link . '</li>';
661
}
662

    
663
if (('' != ($link = get_shortcut_status_link($shortcut_section, false))) && (isAllowedPage($shortcuts[$shortcut_section]['status']))) {
664
	echo '<li>' . $link . '</li>';
665
}
666

    
667
if (('' != ($link = get_shortcut_log_link($shortcut_section, false))) && (isAllowedPage($shortcuts[$shortcut_section]['log']))) {
668
	echo '<li>' . $link . '</li>';
669
}
670

    
671
?>
672
	<?php if (!$g['disablehelpicon'] && isAllowedPage("help.php")): ?>
673
		<li>
674
			<a href="<?=$helpurl?>" target="_blank" title="<?=gettext("Help for items on this page")?>">
675
				<i class="fa fa-question-circle"></i>
676
			</a>
677
		</li>
678
	<?php endif?>
679
		</ul>
680
	</header>
681
<?php
682
/* if upgrade in progress, alert user */
683
$warning_text = "";
684
if (file_exists('/conf/needs_package_sync') && platform_booting()) {
685
	$warning_text = sprintf(gettext(
686
	    '%1$s%3$s is booting, then packages will be reinstalled in the ' .
687
	    'background.%2$s%1$sDo not make changes in the GUI until this is ' .
688
	    'complete.%2$s'), '<p>', '</p>', $g['product_name']);
689
} elseif (is_subsystem_dirty('packagelock')) {
690
	$pgtitle = array(gettext("System"), gettext("Package Manager"));
691
	$warning_text = sprintf(gettext('%1$sPackages are currently being ' .
692
	    'reinstalled in the background.%2$s%1$sDo not make changes in ' .
693
	    'the GUI until this is complete.%2$s'), '<p>', '</p>');
694
	$warning_text .= sprintf(gettext('%1$sIf the above message is still ' .
695
	    'displayed after a couple of hours, use the \'Clear Package ' .
696
	    'Lock\' button on the %3$s page and reinstall packages manually.' .
697
	    '%2$s'), '<p>', '</p>', sprintf('<a href="diag_backup.php" ' .
698
	    'title="%1$s &gt; %2$s">%1$s &gt; %2$s</a>', gettext('Diagnostics'),
699
	    htmlspecialchars(gettext('Backup & Restore'))));
700
}
701

    
702
if (!empty($warning_text)) {
703
	print_info_box($warning_text);
704
}
705

    
706
/*	If this page is being remotely managed then do not allow the loading of the contents. */
707
if ($config['remote_managed_pages']['item']) {
708
	foreach ($config['remote_managed_pages']['item'] as $rmp) {
709
		if ($rmp == $_SERVER['SCRIPT_NAME']) {
710
			print_info_box(gettext("This page is currently being managed by a remote machine."));
711
			include("foot.inc");
712
			exit;
713
		}
714
	}
715
}
716

    
717
// Modal notices window
718
// The notices modal needs to be outside of the page display div or things get messy
719
if ($display_notices):
720
?>
721

    
722
<div id="notices" class="modal fade" role="dialog">
723
	<div class="modal-dialog">
724
		<div class="modal-content">
725
			<div class="modal-header">
726
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
727
					<span aria-hidden="true">&times;</span>
728
				</button>
729

    
730
				<h3 class="modal-title" id="myModalLabel"><?=gettext("Notices")?></h3>
731
			</div>
732

    
733
			<div class="modal-body">
734
<?php
735
	$noticeCategories = array();
736

    
737
	if (is_array($notices)) {
738
		foreach ($notices as $time => $notice) {
739
			if (!isset($noticeCategories[ $notice['category'] ])) {
740
				$noticeCategories[ $notice['category'] ] = array();
741
			}
742

    
743
			$notice['time'] = $time;
744
			array_push($noticeCategories[ $notice['category'] ], $notice);
745
		}
746
	}
747

    
748
	foreach ($noticeCategories as $category => $catNotices):?>
749
				<h4><?=$category?></h4>
750
				<ul>
751
<?php
752
	foreach ($catNotices as $notice):
753
?>
754
					<li>
755
						<b>
756
<?php if (!empty($notice['url'])):?>
757
							<a href="<?=htmlspecialchars($notice['url'])?>"><?=htmlspecialchars($notice['id'])?></a> -
758
<?php endif;?>
759
						</b>
760
						<?=str_replace("\n", "<br/>", htmlspecialchars($notice['notice']))?>
761
						<i>@ <?=date('Y-m-d H:i:s', $notice['time'])?></i>
762
					</li>
763
<?php	endforeach;?>
764
				</ul>
765
<?php endforeach;?>
766
			</div>
767

    
768
			<div class="modal-footer">
769
				<button type="button" class="btn btn-info" data-dismiss="modal"><i class="fa fa-times icon-embed-btn"></i><?=gettext("Close")?></button>
770
<?php if ($allow_clear_notices && isAllowedPage("/index.php")):?>
771
				<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>
772
<?php endif;?>
773
			</div>
774
		</div>
775
	</div>
776
</div>
777

    
778
<script type="text/javascript">
779
//<![CDATA[
780
	events.push(function() {
781
	    $('#clearallnotices').click(function() {
782
			ajaxRequest = $.ajax({
783
				url: "/index.php",
784
				type: "post",
785
				data: { closenotice: "all"},
786
				success: function() {
787
					window.location = window.location.href;
788
				},
789
				failure: function() {
790
					alert("Error clearing notices!");
791
				}
792
			});
793
		});
794
	});
795
//]]>
796
</script>
797

    
798
<?php
799
endif; // ($display_notices)
800

    
801
// Get the flash Messages
802
get_flash_message();
(68-68/228)