fbegin.inc 8.18 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
	Copyright (C) 2014 Deciso B.V.
	Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:

	1. Redistributions of source code must retain the above copyright notice,
	   this list of conditions and the following disclaimer.

	2. Redistributions in binary form must reproduce the above copyright
	   notice, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.

	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
Ad Schellevis's avatar
Ad Schellevis committed
28 29 30
*/

require_once("globals.inc");
31
require_once("functions.inc");
Ad Schellevis's avatar
Ad Schellevis committed
32
require_once("shortcuts.inc");
33
require_once("service-utils.inc");
34
require_once("script/load_phalcon.php");
Ad Schellevis's avatar
Ad Schellevis committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

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

/* If there was no match, there were no parameters, just grab the filename
   Otherwise, use the matched filename from above. */
if (empty($uri_split[0])) {
	$pagename = ltrim($_SERVER["REQUEST_URI"], '/');
} else {
	$pagename = $uri_split[1];
}
/* If the page name is still empty, the user must have requested / (index.php) */
if (empty($pagename)) {
	$pagename = "index.php";
}

/* If the filename is pkg_edit.php or wizard.php, reparse looking
	for the .xml filename */
if (($pagename == "pkg.php") || ($pagename == "pkg_edit.php") || ($pagename == "wizard.php")) {
	$param_split = explode('&', $uri_split[2]);
	foreach ($param_split as $param) {
		if (substr($param, 0, 4) == "xml=") {
			$xmlfile = explode('=', $param);
			$pagename = $xmlfile[1];
		}
	}
}

/* Build the full help URL. */
66
$helpurl .= "/help.php?page={$pagename}";
Ad Schellevis's avatar
Ad Schellevis committed
67

68 69
// link menu system
$menu = new OPNsense\Base\Menu\MenuSystem();
Ad Schellevis's avatar
Ad Schellevis committed
70

71 72 73 74 75 76
// add interfaces to "Interfaces" menu tab... kind of a hack, may need some improvement.
$cnf = OPNsense\Core\Config::getInstance();
$ordid = 0;
foreach ($cnf->object()->interfaces->children() as $key => $node) {
    $menu->appendItem("Interfaces", $key, array("url"=>"/interfaces.php?if=".$key,"order"=>($ordid++),
                      "visiblename"=>$node->descr?$node->descr:strtoupper($key)));
Ad Schellevis's avatar
Ad Schellevis committed
77
}
78
$menuSystem = $menu->getItems($_SERVER['REQUEST_URI']);
79

80
$aclObj = new \OPNsense\Core\ACL();
Ad Schellevis's avatar
Ad Schellevis committed
81

82 83 84 85 86 87 88 89
/* display a top alert bar if need be */
$need_alert_display = false;
$found_notices = are_notices_pending();
if($found_notices == true) {
	$notices = get_notices();
	if(!$notices) {
		$need_alert_display = true;
		$display_text = print_notices($notices) . "<br />";
Ad Schellevis's avatar
Ad Schellevis committed
90 91
	}
}
92
if($need_alert_display == true) {
Ad Schellevis's avatar
Ad Schellevis committed
93
    echo "<div class=\"col-xs-12\"><div class=\"alert alert-info\"><p>".$display_text."</p></div></div>";
Ad Schellevis's avatar
Ad Schellevis committed
94 95
}

Ad Schellevis's avatar
Ad Schellevis committed
96
$pgtitle_output = true;
Ad Schellevis's avatar
Ad Schellevis committed
97
?>
98 99

<header class="page-head">
100

101
	<nav class="navbar navbar-default" role="navigation">
102

103 104
		<div class="container-fluid">
			<div class="navbar-header">
105
				<a class="navbar-brand" href="/index.php">
106 107
				<img class="brand-logo" src="/themes/<?=$g['theme'];?>/assets/images/default-logo.png" height="30" width="150"/>
				<img class="brand-icon" src="/themes/<?=$g['theme'];?>/assets/images/icon-logo.png" height="30" width="29"/>
Ad Schellevis's avatar
Ad Schellevis committed
108
				</a>
109 110 111 112 113 114 115
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navigation">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
			</div>
116 117 118

			<div class="collapse navbar-collapse">
				<ul class="nav navbar-nav navbar-right">
Ad Schellevis's avatar
Ad Schellevis committed
119 120 121 122 123
					<li id="menu_messages">
					<?php
						echo get_menu_messages();
					?>
					</li>
124
					<?php
125 126


127 128 129
						echo '<li>'.get_shortcut_main_link($shortcut_section, false).'</li>';
						echo '<li>'.get_shortcut_status_link($shortcut_section, false).'</li>';
						echo '<li>'.get_shortcut_log_link($shortcut_section, false).'</li>';
130

131
					?>
Ad Schellevis's avatar
Ad Schellevis committed
132
					<li><a href="<?php echo $helpurl; ?>" target="_blank" title="<?php echo gettext("Help for items on this page"); ?>">Help</a></li>
Ad Schellevis's avatar
Ad Schellevis committed
133
					<li class="active"><a href="/index.php?logout">Logout</a></li>
134
				</ul>
135

136 137 138
			</div>
		</div>
	</nav>
139

140 141
</header>

142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
<main class="page-content col-sm-10 col-sm-push-2">

    <aside id="navigation" class="page-side col-xs-12 col-sm-2 hidden-xs">
        <div class="row">
            <nav class="page-side-nav" role="navigation">
                <div id="mainmenu" class="panel" style="border:0px" >
                    <div class="panel list-group" style="border:0px">
                        <?php foreach($menuSystem as $topMenuItem): ?>
                            <a href="#<?php echo $topMenuItem->Id;?>" class="list-group-item <?php if ($topMenuItem->Selected) echo 'active-menu-title'; ?>" data-toggle="collapse" data-parent="#mainmenu"><span class="<?php echo $topMenuItem->CssClass;?> __iconspacer"></span><?php echo $topMenuItem->VisibleName;?>  </a>
                            <div class="collapse <?php if ($topMenuItem->Selected) echo 'active-menu in';?>" id="<?php echo $topMenuItem->Id;?>">
			    <?php foreach($topMenuItem->Children as $subMenuItem): ?>
				<?php if ($subMenuItem->IsExternal == "Y" ):?>
					<a href="<?php echo $subMenuItem->Url;?>" target="_new" class="list-group-item <?php if ($subMenuItem->Selected ) echo "active";?>"><?php echo $subMenuItem->VisibleName ?></a>
				<?php elseif ($aclObj->isPageAccessible($_SESSION['Username'],$subMenuItem->Url)):?>
					<a href="<?php echo $subMenuItem->Url;?>" class="list-group-item <?php if ($subMenuItem->Selected) echo "active";?>"><?php echo $subMenuItem->VisibleName;?></a>
				<?php endif;?>
			    <?php endforeach; ?>
159
		            </div>
160 161 162 163 164 165
		        <?php endforeach; ?>
                    </div>
                </div>
            </nav>
        </div>
    </aside>
166

167
	<div class="row">
168

169 170
		<header class="page-content-head">
			<div class="container-fluid">
Ad Schellevis's avatar
Ad Schellevis committed
171
			    <form action="<?=$_SERVER['REQUEST_URI'];?>" method="post">
172 173
				<ul class="list-inline">
					<li class="__mb"><h1><?=genhtmltitle($pgtitle);?></h1></li>
174

175
					<li class="btn-group-container">
176

177
						<?php
178

179 180 181 182 183 184 185 186 187 188 189
						if (!$hide_service_status && !empty($shortcuts[$shortcut_section]['service'])) {
							$ssvc = array();
							switch ($shortcut_section) {
								case "openvpn":
									$ssvc = find_service_by_openvpn_vpnid($vpnid);
									break;
								case "captiveportal":
									$ssvc = find_service_by_cp_zone($cpzone);
									break;
								default:
									$ssvc = find_service_by_name($shortcuts[$shortcut_section]['service']);
190

191 192 193 194 195 196
							}
							if (!empty($ssvc)) {
								echo get_service_status_icon($ssvc, false);
								echo get_service_control_links($ssvc, false);
							}
						}
197

198
						?>
199 200 201

						<? if (!empty($main_buttons)): foreach ($main_buttons as $button): ?>
							<a href="<?=$button['href'];?>" class="btn btn-primary"><span class="glyphicon glyphicon-plus-sign __iconspacer"></span><?=$button['label'];?></a>
202
						<? endforeach; endif; ?>
203

Ad Schellevis's avatar
Ad Schellevis committed
204
						<? if (isset($widgetfiles)): ?>
205 206


Ad Schellevis's avatar
Ad Schellevis committed
207
							<a href="#" id="updatepref" style="display:none" onclick="return updatePref();" class="btn btn-primary"><?=gettext("Save Settings");?></a>
208

Ad Schellevis's avatar
Ad Schellevis committed
209 210
							<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal_widgets"><span class="glyphicon glyphicon-plus-sign __iconspacer"></span>Add widget</button>
						<? endif; ?>
211

212 213 214
						<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal_widgets"><span class="glyphicon glyphicon-plus-sign __iconspacer"></span>Add widget</button> -->
					</li>
				</ul>
215
			    </form>
216
			</div>
217
		</header>