1 |
2cd6010c
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
aaec5634
|
Renato Botelho
|
* index.php
|
4 |
|
|
*
|
5 |
|
|
* part of pfSense (https://www.pfsense.org)
|
6 |
2a2396a6
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
aaec5634
|
Renato Botelho
|
* All rights reserved.
|
8 |
|
|
*
|
9 |
|
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
* All rights reserved.
|
12 |
|
|
*
|
13 |
|
|
* Redistribution and use in source and binary forms, with or without
|
14 |
|
|
* modification, are permitted provided that the following conditions are met:
|
15 |
|
|
*
|
16 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
17 |
|
|
* this list of conditions and the following disclaimer.
|
18 |
|
|
*
|
19 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
20 |
|
|
* notice, this list of conditions and the following disclaimer in
|
21 |
|
|
* the documentation and/or other materials provided with the
|
22 |
|
|
* distribution.
|
23 |
|
|
*
|
24 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
25 |
|
|
* must display the following acknowledgment:
|
26 |
|
|
* "This product includes software developed by the pfSense Project
|
27 |
|
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
28 |
|
|
*
|
29 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
30 |
|
|
* endorse or promote products derived from this software without
|
31 |
|
|
* prior written permission. For written permission, please contact
|
32 |
|
|
* coreteam@pfsense.org.
|
33 |
|
|
*
|
34 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
35 |
|
|
* nor may "pfSense" appear in their names without prior written
|
36 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
37 |
|
|
*
|
38 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
39 |
|
|
* acknowledgment:
|
40 |
|
|
*
|
41 |
|
|
* "This product includes software developed by the pfSense Project
|
42 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
43 |
|
|
*
|
44 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
45 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
46 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
47 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
48 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
49 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
50 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
51 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
52 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
53 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
54 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
55 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
56 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
57 |
5b237745
|
Scott Ullrich
|
|
58 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
59 |
5d916fc7
|
Stephen Beaver
|
##|*IDENT=page-system-login-logout
|
60 |
5230f468
|
jim-p
|
##|*NAME=System: Login / Logout / Dashboard
|
61 |
b7ccf315
|
Erik Fonnesbeck
|
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
|
62 |
6b07c15a
|
Matthew Grooms
|
##|*MATCH=index.php*
|
63 |
|
|
##|-PRIV
|
64 |
|
|
|
65 |
acc5dd59
|
jim-p
|
// Turn on buffering to speed up rendering
|
66 |
6c07db48
|
Phil Davis
|
ini_set('output_buffering', 'true');
|
67 |
acc5dd59
|
jim-p
|
|
68 |
|
|
// Start buffering with a cache size of 100000
|
69 |
|
|
ob_start(null, "1000");
|
70 |
880637d2
|
Scott Ullrich
|
|
71 |
acc5dd59
|
jim-p
|
## Load Essential Includes
|
72 |
|
|
require_once('guiconfig.inc');
|
73 |
32e834ff
|
Ermal LUÇI
|
require_once('functions.inc');
|
74 |
acc5dd59
|
jim-p
|
require_once('notices.inc');
|
75 |
7c8f3711
|
jim-p
|
require_once("pkg-utils.inc");
|
76 |
acc5dd59
|
jim-p
|
|
77 |
329a1cd5
|
Stephen Beaver
|
if (isset($_POST['closenotice'])) {
|
78 |
|
|
close_notice($_POST['closenotice']);
|
79 |
|
|
sleep(1);
|
80 |
005ac3ca
|
Marcello Coutinho
|
exit;
|
81 |
|
|
}
|
82 |
|
|
|
83 |
0206483d
|
Stephen Beaver
|
if (isset($_GET['closenotice'])) {
|
84 |
|
|
close_notice($_GET['closenotice']);
|
85 |
|
|
sleep(1);
|
86 |
|
|
}
|
87 |
|
|
|
88 |
41b1ff89
|
Phil Davis
|
if ($g['disablecrashreporter'] != true) {
|
89 |
36365f49
|
Scott Ullrich
|
// Check to see if we have a crash report
|
90 |
eac584f3
|
Scott Ullrich
|
$x = 0;
|
91 |
41b1ff89
|
Phil Davis
|
if (file_exists("/tmp/PHP_errors.log")) {
|
92 |
3ce8097f
|
NewEraCracker
|
$total = `/bin/cat /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
|
93 |
41b1ff89
|
Phil Davis
|
if ($total > 0) {
|
94 |
a9ee006d
|
Scott Ullrich
|
$x++;
|
95 |
41b1ff89
|
Phil Davis
|
}
|
96 |
a9ee006d
|
Scott Ullrich
|
}
|
97 |
60e27eb0
|
Stephen Beaver
|
|
98 |
a9ee006d
|
Scott Ullrich
|
$crash = glob("/var/crash/*");
|
99 |
36365f49
|
Scott Ullrich
|
$skip_files = array(".", "..", "minfree", "");
|
100 |
60e27eb0
|
Stephen Beaver
|
|
101 |
41b1ff89
|
Phil Davis
|
if (is_array($crash)) {
|
102 |
|
|
foreach ($crash as $c) {
|
103 |
|
|
if (!in_array(basename($c), $skip_files)) {
|
104 |
36365f49
|
Scott Ullrich
|
$x++;
|
105 |
41b1ff89
|
Phil Davis
|
}
|
106 |
36365f49
|
Scott Ullrich
|
}
|
107 |
60e27eb0
|
Stephen Beaver
|
|
108 |
41b1ff89
|
Phil Davis
|
if ($x > 0) {
|
109 |
bc2b824d
|
Phil Davis
|
$savemsg = sprintf(gettext("%s has detected a crash report or programming bug."), $g['product_name']) . " ";
|
110 |
|
|
if (isAllowedPage("/crash_reporter.php")) {
|
111 |
|
|
$savemsg .= sprintf(gettext("Click <a href='crash_reporter.php'>here</a> for more information."));
|
112 |
|
|
} else {
|
113 |
063c02c9
|
Phil Davis
|
$savemsg .= sprintf(gettext("Contact a firewall administrator for more information."));
|
114 |
bc2b824d
|
Phil Davis
|
}
|
115 |
c8532336
|
Phil Davis
|
$class = "warning";
|
116 |
41b1ff89
|
Phil Davis
|
}
|
117 |
104faa07
|
Scott Ullrich
|
}
|
118 |
|
|
}
|
119 |
|
|
|
120 |
ef325a6c
|
Phil Davis
|
##build list of php include files
|
121 |
|
|
$phpincludefiles = array();
|
122 |
|
|
$directory = "/usr/local/www/widgets/include/";
|
123 |
|
|
$dirhandle = opendir($directory);
|
124 |
|
|
$filename = "";
|
125 |
|
|
|
126 |
|
|
while (false !== ($filename = readdir($dirhandle))) {
|
127 |
dffe24be
|
NewEraCracker
|
if (!stristr($filename, ".inc")) {
|
128 |
|
|
continue;
|
129 |
|
|
}
|
130 |
ef325a6c
|
Phil Davis
|
$phpincludefiles[] = $filename;
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
## Include each widget include file.
|
134 |
|
|
## These define vars that specify the widget title and title link.
|
135 |
|
|
foreach ($phpincludefiles as $includename) {
|
136 |
|
|
if (file_exists($directory . $includename)) {
|
137 |
6dfb6b27
|
Phil Davis
|
include_once($directory . $includename);
|
138 |
ef325a6c
|
Phil Davis
|
}
|
139 |
|
|
}
|
140 |
|
|
|
141 |
acc5dd59
|
jim-p
|
##build list of widgets
|
142 |
aa82505e
|
Phil Davis
|
foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file) {
|
143 |
41ea4cf3
|
Sjon Hortensius
|
$name = basename($file, '.widget.php');
|
144 |
ef325a6c
|
Phil Davis
|
// Get the widget title that should be in a var defined in the widget's inc file.
|
145 |
|
|
$widgettitle = ${$name . '_title'};
|
146 |
|
|
|
147 |
dffe24be
|
NewEraCracker
|
if (empty(trim($widgettitle))) {
|
148 |
ef325a6c
|
Phil Davis
|
// Fall back to constructing a title from the file name of the widget.
|
149 |
|
|
$widgettitle = ucwords(str_replace('_', ' ', $name));
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
$widgets[ $name ] = array('name' => $widgettitle, 'display' => 'none');
|
153 |
acc5dd59
|
jim-p
|
}
|
154 |
|
|
|
155 |
|
|
##if no config entry found, initialize config entry
|
156 |
|
|
if (!is_array($config['widgets'])) {
|
157 |
|
|
$config['widgets'] = array();
|
158 |
|
|
}
|
159 |
62630ddc
|
NewEraCracker
|
if (!is_array($user_settings['widgets'])) {
|
160 |
|
|
$user_settings['widgets'] = array();
|
161 |
|
|
}
|
162 |
d772ac32
|
Erik Kristensen
|
|
163 |
41ea4cf3
|
Sjon Hortensius
|
if ($_POST && $_POST['sequence']) {
|
164 |
60e27eb0
|
Stephen Beaver
|
|
165 |
be59d667
|
Phil Davis
|
// Start with the user's widget settings.
|
166 |
|
|
$widget_settings = $user_settings['widgets'];
|
167 |
c8faf384
|
Stephen Beaver
|
|
168 |
595b074d
|
Phil Davis
|
$widget_settings['sequence'] = rtrim($_POST['sequence'], ',');
|
169 |
8191b36e
|
Scott Ullrich
|
|
170 |
1c428d53
|
Phil Davis
|
foreach ($widgets as $widgetname => $widgetconfig) {
|
171 |
|
|
if ($_POST[$widgetname . '-config']) {
|
172 |
595b074d
|
Phil Davis
|
$widget_settings[$widgetname . '-config'] = $_POST[$widgetname . '-config'];
|
173 |
8191b36e
|
Scott Ullrich
|
}
|
174 |
|
|
}
|
175 |
|
|
|
176 |
595b074d
|
Phil Davis
|
save_widget_settings($_SESSION['Username'], $widget_settings);
|
177 |
69b397dd
|
Sjon Hortensius
|
header("Location: /");
|
178 |
1180e4f0
|
Sjon Hortensius
|
exit;
|
179 |
|
|
}
|
180 |
757733b5
|
Renato Botelho
|
|
181 |
1180e4f0
|
Sjon Hortensius
|
## Load Functions Files
|
182 |
|
|
require_once('includes/functions.inc.php');
|
183 |
d772ac32
|
Erik Kristensen
|
|
184 |
1180e4f0
|
Sjon Hortensius
|
## Check to see if we have a swap space,
|
185 |
|
|
## if true, display, if false, hide it ...
|
186 |
1c428d53
|
Phil Davis
|
if (file_exists("/usr/sbin/swapinfo")) {
|
187 |
1180e4f0
|
Sjon Hortensius
|
$swapinfo = `/usr/sbin/swapinfo`;
|
188 |
1c428d53
|
Phil Davis
|
if (stristr($swapinfo, '%') == true) $showswap=true;
|
189 |
1180e4f0
|
Sjon Hortensius
|
}
|
190 |
|
|
|
191 |
|
|
## User recently restored his config.
|
192 |
|
|
## If packages are installed lets resync
|
193 |
1c428d53
|
Phil Davis
|
if (file_exists('/conf/needs_package_sync')) {
|
194 |
|
|
if ($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
|
195 |
2344bed4
|
Renato Botelho
|
if ($g['platform'] == $g['product_name'] || $g['platform'] == "nanobsd") {
|
196 |
1180e4f0
|
Sjon Hortensius
|
## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
|
197 |
|
|
## the package reinstall page. That is about to be done by the boot script anyway.
|
198 |
31f03b6c
|
Sjon Hortensius
|
## The code in head.inc will put up a notice to the user.
|
199 |
1180e4f0
|
Sjon Hortensius
|
if (!platform_booting()) {
|
200 |
|
|
header('Location: pkg_mgr_install.php?mode=reinstallall');
|
201 |
|
|
exit;
|
202 |
6cc843c3
|
Scott Ullrich
|
}
|
203 |
1df0159c
|
Erik Kristensen
|
}
|
204 |
1180e4f0
|
Sjon Hortensius
|
} else {
|
205 |
|
|
conf_mount_rw();
|
206 |
|
|
@unlink('/conf/needs_package_sync');
|
207 |
|
|
conf_mount_ro();
|
208 |
1df0159c
|
Erik Kristensen
|
}
|
209 |
1180e4f0
|
Sjon Hortensius
|
}
|
210 |
8fecad11
|
Scott Ullrich
|
|
211 |
1180e4f0
|
Sjon Hortensius
|
## If it is the first time webConfigurator has been
|
212 |
|
|
## accessed since initial install show this stuff.
|
213 |
1c428d53
|
Phil Davis
|
if (file_exists('/conf/trigger_initial_wizard')) {
|
214 |
1180e4f0
|
Sjon Hortensius
|
?>
|
215 |
|
|
<!DOCTYPE html>
|
216 |
|
|
<html lang="en">
|
217 |
702b324e
|
Scott Ullrich
|
<head>
|
218 |
f0c5e7c1
|
Jared Dillard
|
<link rel="stylesheet" href="/css/pfSense.css" />
|
219 |
5bca8df4
|
Stephen Beaver
|
<title><?=$g['product_name']?>.localdomain - <?=$g['product_name']?> first time setup</title>
|
220 |
1180e4f0
|
Sjon Hortensius
|
<meta http-equiv="refresh" content="1;url=wizard.php?xml=setup_wizard.xml" />
|
221 |
|
|
</head>
|
222 |
|
|
<body id="loading-wizard" class="no-menu">
|
223 |
|
|
<div id="jumbotron">
|
224 |
|
|
<div class="container">
|
225 |
c7d61071
|
Sander van Leeuwen
|
<div class="col-sm-offset-3 col-sm-6 col-xs-12">
|
226 |
40547fe4
|
Stephen Beaver
|
<font color="white">
|
227 |
|
|
<p><h3><?=sprintf(gettext("Welcome to %s!\n"), $g['product_name'])?></h3></p>
|
228 |
12f22e9c
|
Stephen Beaver
|
<p><?=gettext("One moment while the initial setup wizard starts.")?></p>
|
229 |
c7d61071
|
Sander van Leeuwen
|
<p><?=gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.")?></p>
|
230 |
1c428d53
|
Phil Davis
|
<p><?=sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."), $g['product_name'])?></p>
|
231 |
40547fe4
|
Stephen Beaver
|
</font>
|
232 |
c7d61071
|
Sander van Leeuwen
|
</div>
|
233 |
1180e4f0
|
Sjon Hortensius
|
</div>
|
234 |
|
|
</div>
|
235 |
|
|
</body>
|
236 |
|
|
</html>
|
237 |
|
|
<?php
|
238 |
|
|
exit;
|
239 |
|
|
}
|
240 |
bf787c0a
|
Scott Ullrich
|
|
241 |
1180e4f0
|
Sjon Hortensius
|
## Find out whether there's hardware encryption or not
|
242 |
|
|
unset($hwcrypto);
|
243 |
|
|
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
|
244 |
|
|
if ($fd) {
|
245 |
|
|
while (!feof($fd)) {
|
246 |
|
|
$dmesgl = fgets($fd);
|
247 |
|
|
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
|
248 |
|
|
or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
|
249 |
|
|
or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
|
250 |
|
|
or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
|
251 |
|
|
or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
|
252 |
a2e6d7f8
|
Luiz Otavio O Souza
|
or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)) {
|
253 |
1180e4f0
|
Sjon Hortensius
|
$hwcrypto = $matches[1];
|
254 |
|
|
break;
|
255 |
5b237745
|
Scott Ullrich
|
}
|
256 |
|
|
}
|
257 |
1180e4f0
|
Sjon Hortensius
|
fclose($fd);
|
258 |
aa82505e
|
Phil Davis
|
if (!isset($hwcrypto) && get_single_sysctl("dev.aesni.0.%desc")) {
|
259 |
a2e6d7f8
|
Luiz Otavio O Souza
|
$hwcrypto = get_single_sysctl("dev.aesni.0.%desc");
|
260 |
aa82505e
|
Phil Davis
|
}
|
261 |
1180e4f0
|
Sjon Hortensius
|
}
|
262 |
45ee90ed
|
Matthew Grooms
|
|
263 |
7abf7db5
|
Scott Dale
|
##build widget saved list information
|
264 |
595b074d
|
Phil Davis
|
if ($user_settings['widgets']['sequence'] != "") {
|
265 |
|
|
$dashboardcolumns = isset($user_settings['webgui']['dashboardcolumns']) ? $user_settings['webgui']['dashboardcolumns'] : 2;
|
266 |
|
|
$pconfig['sequence'] = $user_settings['widgets']['sequence'];
|
267 |
1180e4f0
|
Sjon Hortensius
|
$widgetsfromconfig = array();
|
268 |
757733b5
|
Renato Botelho
|
|
269 |
aa82505e
|
Phil Davis
|
foreach (explode(',', $pconfig['sequence']) as $line) {
|
270 |
1180e4f0
|
Sjon Hortensius
|
list($file, $col, $display) = explode(':', $line);
|
271 |
|
|
|
272 |
|
|
// be backwards compatible
|
273 |
72eaefaf
|
Stephen Beaver
|
// If the display column information is missing, we will assign a temporary
|
274 |
|
|
// column here. Next time the user saves the dashboard it will fix itself
|
275 |
|
|
if ($col == "") {
|
276 |
|
|
if ($file == "system_information") {
|
277 |
|
|
$col = "col1";
|
278 |
|
|
} else {
|
279 |
|
|
$col = "col2";
|
280 |
|
|
}
|
281 |
|
|
}
|
282 |
|
|
|
283 |
ad51eb90
|
Phil Davis
|
// Limit the column to the current dashboard columns.
|
284 |
|
|
if (substr($col, 3) > $dashboardcolumns) {
|
285 |
|
|
$col = "col" . $dashboardcolumns;
|
286 |
|
|
}
|
287 |
|
|
|
288 |
1180e4f0
|
Sjon Hortensius
|
$offset = strpos($file, '-container');
|
289 |
94704bc6
|
Phil Davis
|
if (false !== $offset) {
|
290 |
1180e4f0
|
Sjon Hortensius
|
$file = substr($file, 0, $offset);
|
291 |
94704bc6
|
Phil Davis
|
}
|
292 |
1180e4f0
|
Sjon Hortensius
|
|
293 |
ef325a6c
|
Phil Davis
|
// Get the widget title that should be in a var defined in the widget's inc file.
|
294 |
|
|
$widgettitle = ${$file . '_title'};
|
295 |
|
|
|
296 |
dffe24be
|
NewEraCracker
|
if (empty(trim($widgettitle))) {
|
297 |
ef325a6c
|
Phil Davis
|
// Fall back to constructing a title from the file name of the widget.
|
298 |
|
|
$widgettitle = ucwords(str_replace('_', ' ', $file));
|
299 |
|
|
}
|
300 |
|
|
|
301 |
1180e4f0
|
Sjon Hortensius
|
$widgetsfromconfig[ $file ] = array(
|
302 |
ef325a6c
|
Phil Davis
|
'name' => $widgettitle,
|
303 |
1180e4f0
|
Sjon Hortensius
|
'col' => $col,
|
304 |
|
|
'display' => $display,
|
305 |
|
|
);
|
306 |
1db766df
|
Scott Dale
|
}
|
307 |
757733b5
|
Renato Botelho
|
|
308 |
5c7657d6
|
Renato Botelho
|
// add widgets that may not be in the saved configuration, in case they are to be displayed later
|
309 |
69b397dd
|
Sjon Hortensius
|
$widgets = $widgetsfromconfig + $widgets;
|
310 |
757733b5
|
Renato Botelho
|
|
311 |
019a94df
|
Scott Dale
|
##find custom configurations of a particular widget and load its info to $pconfig
|
312 |
1c428d53
|
Phil Davis
|
foreach ($widgets as $widgetname => $widgetconfig) {
|
313 |
75ae3d1c
|
Phil Davis
|
if ($config['widgets'][$widgetname . '-config']) {
|
314 |
|
|
$pconfig[$widgetname . '-config'] = $config['widgets'][$widgetname . '-config'];
|
315 |
757733b5
|
Renato Botelho
|
}
|
316 |
|
|
}
|
317 |
3e4e94ce
|
Scott Dale
|
}
|
318 |
|
|
|
319 |
c05363c8
|
NOYB
|
## Get the configured options for Show/Hide available widgets panel.
|
320 |
595b074d
|
Phil Davis
|
$dashboard_available_widgets_hidden = !$user_settings['webgui']['dashboardavailablewidgetspanel'];
|
321 |
c05363c8
|
NOYB
|
|
322 |
|
|
if ($dashboard_available_widgets_hidden) {
|
323 |
|
|
$panel_state = 'out';
|
324 |
|
|
$panel_body_state = 'in';
|
325 |
|
|
} else {
|
326 |
|
|
$panel_state = 'in';
|
327 |
|
|
$panel_body_state = 'out';
|
328 |
|
|
}
|
329 |
|
|
|
330 |
1db766df
|
Scott Dale
|
## Set Page Title and Include Header
|
331 |
2734d2db
|
Jared Dillard
|
$pgtitle = array(gettext("Status"), gettext("Dashboard"));
|
332 |
1db766df
|
Scott Dale
|
include("head.inc");
|
333 |
f6f6947e
|
Scott Ullrich
|
|
334 |
41b1ff89
|
Phil Davis
|
if ($savemsg) {
|
335 |
c8532336
|
Phil Davis
|
print_info_box($savemsg, $class);
|
336 |
41b1ff89
|
Phil Davis
|
}
|
337 |
fca795f8
|
Scott Ullrich
|
|
338 |
810a11bc
|
Scott Ullrich
|
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
|
339 |
c69c58e2
|
Vinicius Coque
|
|
340 |
0682e26b
|
Colin Smith
|
?>
|
341 |
1180e4f0
|
Sjon Hortensius
|
|
342 |
c05363c8
|
NOYB
|
<div class="panel panel-default collapse <?=$panel_state?>" id="widget-available">
|
343 |
95fa5cce
|
Phil Davis
|
<div class="panel-heading">
|
344 |
|
|
<h2 class="panel-title"><?=gettext("Available Widgets"); ?>
|
345 |
|
|
<span class="widget-heading-icon">
|
346 |
|
|
<a data-toggle="collapse" href="#widget-available_panel-body" id="widgets-available">
|
347 |
|
|
<i class="fa fa-plus-circle"></i>
|
348 |
|
|
</a>
|
349 |
|
|
</span>
|
350 |
|
|
</h2>
|
351 |
166b0099
|
Stephen Beaver
|
</div>
|
352 |
c05363c8
|
NOYB
|
<div id="widget-available_panel-body" class="panel-body collapse <?=$panel_body_state?>">
|
353 |
9239f765
|
Jared Dillard
|
<div class="content">
|
354 |
|
|
<div class="row">
|
355 |
60e27eb0
|
Stephen Beaver
|
<?php
|
356 |
e76931e2
|
Stephen Beaver
|
|
357 |
|
|
// Build the Available Widgets table using a sorted copy of the $widgets array
|
358 |
|
|
$available = $widgets;
|
359 |
dffe24be
|
NewEraCracker
|
uasort($available, function($a, $b){ return strcasecmp($a['name'], $b['name']); });
|
360 |
e76931e2
|
Stephen Beaver
|
|
361 |
|
|
foreach ($available as $widgetname => $widgetconfig):
|
362 |
60e27eb0
|
Stephen Beaver
|
if ($widgetconfig['display'] == 'none'):
|
363 |
|
|
?>
|
364 |
a508c6e4
|
NOYB
|
<div class="col-sm-3"><a href="#" id="btnadd-<?=$widgetname?>"><i class="fa fa-plus"></i> <?=$widgetconfig['name']?></a></div>
|
365 |
a2faa388
|
Sander van Leeuwen
|
<?php endif; ?>
|
366 |
|
|
<?php endforeach; ?>
|
367 |
9239f765
|
Jared Dillard
|
</div>
|
368 |
|
|
</div>
|
369 |
1db766df
|
Scott Dale
|
</div>
|
370 |
|
|
</div>
|
371 |
|
|
|
372 |
a2faa388
|
Sander van Leeuwen
|
<div class="hidden" id="widgetSequence">
|
373 |
a508c6e4
|
NOYB
|
<form action="/" method="post" id="widgetSequence_form" name="widgetForm">
|
374 |
41ea4cf3
|
Sjon Hortensius
|
<input type="hidden" name="sequence" value="" />
|
375 |
|
|
</form>
|
376 |
|
|
</div>
|
377 |
|
|
|
378 |
1180e4f0
|
Sjon Hortensius
|
<?php
|
379 |
41ea4cf3
|
Sjon Hortensius
|
$widgetColumns = array();
|
380 |
aa82505e
|
Phil Davis
|
foreach ($widgets as $widgetname => $widgetconfig) {
|
381 |
|
|
if ($widgetconfig['display'] == 'none') {
|
382 |
41ea4cf3
|
Sjon Hortensius
|
continue;
|
383 |
aa82505e
|
Phil Davis
|
}
|
384 |
41ea4cf3
|
Sjon Hortensius
|
|
385 |
e8bd1464
|
Renato Botelho
|
if (!file_exists('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php')) {
|
386 |
|
|
continue;
|
387 |
|
|
}
|
388 |
|
|
|
389 |
aa82505e
|
Phil Davis
|
if (!isset($widgetColumns[ $widgetconfig['col'] ])) {
|
390 |
41ea4cf3
|
Sjon Hortensius
|
$widgetColumns[ $widgetconfig['col'] ] = array();
|
391 |
aa82505e
|
Phil Davis
|
}
|
392 |
41ea4cf3
|
Sjon Hortensius
|
|
393 |
|
|
$widgetColumns[ $widgetconfig['col'] ][ $widgetname ] = $widgetconfig;
|
394 |
|
|
}
|
395 |
1180e4f0
|
Sjon Hortensius
|
?>
|
396 |
41ea4cf3
|
Sjon Hortensius
|
|
397 |
a2faa388
|
Sander van Leeuwen
|
<div class="row">
|
398 |
2063a534
|
Jared Dillard
|
<?php
|
399 |
63c0e334
|
Phil Davis
|
$columnWidth = (int) (12 / $numColumns);
|
400 |
a54d69c8
|
Stephen Beaver
|
|
401 |
e3843a08
|
Phil Davis
|
for ($currentColumnNumber = 1; $currentColumnNumber <= $numColumns; $currentColumnNumber++) {
|
402 |
cee365e6
|
Stephen Beaver
|
|
403 |
2063a534
|
Jared Dillard
|
|
404 |
e3843a08
|
Phil Davis
|
//if col$currentColumnNumber exists
|
405 |
|
|
if (isset($widgetColumns['col'.$currentColumnNumber])) {
|
406 |
caf897c8
|
Jared Dillard
|
echo '<div class="col-md-' . $columnWidth . '" id="widgets-col' . $currentColumnNumber . '">';
|
407 |
e3843a08
|
Phil Davis
|
$columnWidgets = $widgetColumns['col'.$currentColumnNumber];
|
408 |
2063a534
|
Jared Dillard
|
|
409 |
|
|
foreach ($columnWidgets as $widgetname => $widgetconfig) {
|
410 |
|
|
// Compose the widget title and include the title link if available
|
411 |
|
|
$widgetlink = ${$widgetname . '_title_link'};
|
412 |
|
|
|
413 |
|
|
if ((strlen($widgetlink) > 0)) {
|
414 |
|
|
$wtitle = '<a href="' . $widgetlink . '"> ' . $widgetconfig['name'] . '</a>';
|
415 |
|
|
} else {
|
416 |
|
|
$wtitle = $widgetconfig['name'];
|
417 |
|
|
}
|
418 |
|
|
?>
|
419 |
|
|
<div class="panel panel-default" id="widget-<?=$widgetname?>">
|
420 |
|
|
<div class="panel-heading">
|
421 |
95fa5cce
|
Phil Davis
|
<h2 class="panel-title">
|
422 |
|
|
<?=$wtitle?>
|
423 |
|
|
<span class="widget-heading-icon">
|
424 |
|
|
<a data-toggle="collapse" href="#widget-<?=$widgetname?>_panel-footer" class="config hidden">
|
425 |
|
|
<i class="fa fa-wrench"></i>
|
426 |
|
|
</a>
|
427 |
|
|
<a data-toggle="collapse" href="#widget-<?=$widgetname?>_panel-body">
|
428 |
|
|
<!-- actual icon is determined in css based on state of body -->
|
429 |
|
|
<i class="fa fa-plus-circle"></i>
|
430 |
|
|
</a>
|
431 |
|
|
<a data-toggle="close" href="#widget-<?=$widgetname?>">
|
432 |
|
|
<i class="fa fa-times-circle"></i>
|
433 |
|
|
</a>
|
434 |
|
|
</span>
|
435 |
|
|
</h2>
|
436 |
2063a534
|
Jared Dillard
|
</div>
|
437 |
|
|
<div id="widget-<?=$widgetname?>_panel-body" class="panel-body collapse<?=($widgetconfig['display'] == 'close' ? '' : ' in')?>">
|
438 |
6dfb6b27
|
Phil Davis
|
<?php include_once('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php'); ?>
|
439 |
2063a534
|
Jared Dillard
|
</div>
|
440 |
|
|
</div>
|
441 |
|
|
<?php
|
442 |
|
|
}
|
443 |
6fefbd48
|
Jared Dillard
|
echo "</div>";
|
444 |
a54d69c8
|
Stephen Beaver
|
} else {
|
445 |
caf897c8
|
Jared Dillard
|
echo '<div class="col-md-' . $columnWidth . '" id="widgets-col' . $currentColumnNumber . '"></div>';
|
446 |
a54d69c8
|
Stephen Beaver
|
}
|
447 |
cee365e6
|
Stephen Beaver
|
|
448 |
477db933
|
Jared Dillard
|
}
|
449 |
|
|
?>
|
450 |
2063a534
|
Jared Dillard
|
|
451 |
a2faa388
|
Sander van Leeuwen
|
</div>
|
452 |
561d55ff
|
Erik Kristensen
|
|
453 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
454 |
|
|
//<![CDATA[
|
455 |
eae6b58d
|
Stephen Beaver
|
|
456 |
|
|
dirty = false;
|
457 |
aa82505e
|
Phil Davis
|
function updateWidgets(newWidget) {
|
458 |
7f8f8808
|
Sjon Hortensius
|
var sequence = '';
|
459 |
|
|
|
460 |
aa82505e
|
Phil Davis
|
$('.container .col-md-<?=$columnWidth?>').each(function(idx, col) {
|
461 |
|
|
$('.panel', col).each(function(idx, widget) {
|
462 |
7f8f8808
|
Sjon Hortensius
|
var isOpen = $('.panel-body', widget).hasClass('in');
|
463 |
65bd77d4
|
Phil Davis
|
var widget_basename = widget.id.split('-')[1];
|
464 |
7f8f8808
|
Sjon Hortensius
|
|
465 |
65bd77d4
|
Phil Davis
|
// Only save details for panels that have id's like'widget-*'
|
466 |
|
|
// Some widgets create other panels, so ignore any of those.
|
467 |
|
|
if ((widget.id.split('-')[0] == 'widget') && (typeof widget_basename !== 'undefined')) {
|
468 |
|
|
sequence += widget_basename + ':' + col.id.split('-')[1] + ':' + (isOpen ? 'open' : 'close') + ',';
|
469 |
|
|
}
|
470 |
7f8f8808
|
Sjon Hortensius
|
});
|
471 |
|
|
});
|
472 |
|
|
|
473 |
aa82505e
|
Phil Davis
|
if (typeof newWidget !== 'undefined') {
|
474 |
b5ff58cf
|
Stephen Beaver
|
// The system_information widget is always added to column one. Others go in column two
|
475 |
|
|
if (newWidget == "system_information") {
|
476 |
|
|
sequence += newWidget + ':' + 'col1:open';
|
477 |
|
|
} else {
|
478 |
f4a15d29
|
Stephen Beaver
|
sequence += newWidget + ':' + 'col2:open';
|
479 |
b5ff58cf
|
Stephen Beaver
|
}
|
480 |
aa82505e
|
Phil Davis
|
}
|
481 |
60e27eb0
|
Stephen Beaver
|
|
482 |
a508c6e4
|
NOYB
|
$('input[name=sequence]', $('#widgetSequence_form')).val(sequence);
|
483 |
7f8f8808
|
Sjon Hortensius
|
}
|
484 |
|
|
|
485 |
14c6cfa0
|
Phil Davis
|
// Determine if all the checkboxes are checked
|
486 |
|
|
function are_all_checked(checkbox_panel_ref) {
|
487 |
|
|
var allBoxesChecked = true;
|
488 |
|
|
$(checkbox_panel_ref).each(function() {
|
489 |
|
|
if ((this.type == 'checkbox') && !this.checked) {
|
490 |
|
|
allBoxesChecked = false;
|
491 |
|
|
}
|
492 |
|
|
});
|
493 |
|
|
return allBoxesChecked;
|
494 |
|
|
}
|
495 |
|
|
|
496 |
|
|
// If the checkboxes are all checked, then clear them all.
|
497 |
|
|
// Otherwise set them all.
|
498 |
|
|
function set_clear_checkboxes(checkbox_panel_ref) {
|
499 |
|
|
checkTheBoxes = !are_all_checked(checkbox_panel_ref);
|
500 |
|
|
|
501 |
|
|
$(checkbox_panel_ref).each(function() {
|
502 |
|
|
$(this).prop("checked", checkTheBoxes);
|
503 |
|
|
});
|
504 |
|
|
}
|
505 |
|
|
|
506 |
|
|
// Set the given id to All or None button depending if the checkboxes are all checked.
|
507 |
|
|
function set_all_none_button(checkbox_panel_ref, all_none_button_id) {
|
508 |
|
|
if (are_all_checked(checkbox_panel_ref)) {
|
509 |
|
|
text = "<?=gettext('None')?>";
|
510 |
|
|
} else {
|
511 |
|
|
text = "<?=gettext('All')?>";
|
512 |
|
|
}
|
513 |
|
|
|
514 |
|
|
$("#" + all_none_button_id).html('<i class="fa fa-undo icon-embed-btn"></i>' + text);
|
515 |
|
|
}
|
516 |
|
|
|
517 |
|
|
// Setup the necessary events to manage the All/None button and included checkboxes
|
518 |
|
|
// used for selecting the items to show on a widget.
|
519 |
|
|
function set_widget_checkbox_events(checkbox_panel_ref, all_none_button_id) {
|
520 |
|
|
set_all_none_button(checkbox_panel_ref, all_none_button_id);
|
521 |
|
|
|
522 |
|
|
$(checkbox_panel_ref).change(function() {
|
523 |
|
|
set_all_none_button(checkbox_panel_ref, all_none_button_id);
|
524 |
|
|
});
|
525 |
|
|
|
526 |
|
|
$("#" + all_none_button_id).click(function() {
|
527 |
|
|
set_clear_checkboxes(checkbox_panel_ref);
|
528 |
|
|
set_all_none_button(checkbox_panel_ref, all_none_button_id);
|
529 |
|
|
});
|
530 |
|
|
}
|
531 |
|
|
|
532 |
8f3a49d7
|
Steve Beaver
|
// --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
|
533 |
|
|
// These need to live outsie of the events.push() function to enable the widgets to see them
|
534 |
|
|
var ajaxspecs = new Array(); // Array to hold widget refresh specifications (objects )
|
535 |
|
|
var ajaxidx = 0;
|
536 |
|
|
var ajaxmutex = false;
|
537 |
|
|
var ajaxcntr = 0;
|
538 |
|
|
|
539 |
|
|
// Add a widget refresh object to the array list
|
540 |
|
|
function register_ajax(ws) {
|
541 |
|
|
ajaxspecs.push(ws);
|
542 |
|
|
}
|
543 |
|
|
// ---------------------------------------------------------------------------------------------------
|
544 |
|
|
|
545 |
dc58b7b3
|
Sjon Hortensius
|
events.push(function() {
|
546 |
|
|
|
547 |
|
|
// Make panels destroyable
|
548 |
aa82505e
|
Phil Davis
|
$('.container .panel-heading a[data-toggle="close"]').each(function (idx, el) {
|
549 |
|
|
$(el).on('click', function(e) {
|
550 |
7f8f8808
|
Sjon Hortensius
|
$(el).parents('.panel').remove();
|
551 |
|
|
updateWidgets();
|
552 |
eae6b58d
|
Stephen Beaver
|
// Submit the form save/display all selected widgets
|
553 |
|
|
$('[name=widgetForm]').submit();
|
554 |
dc58b7b3
|
Sjon Hortensius
|
})
|
555 |
|
|
});
|
556 |
|
|
|
557 |
|
|
// Make panels sortable
|
558 |
477db933
|
Jared Dillard
|
$('.container .col-md-<?=$columnWidth?>').sortable({
|
559 |
dc58b7b3
|
Sjon Hortensius
|
handle: '.panel-heading',
|
560 |
|
|
cursor: 'grabbing',
|
561 |
477db933
|
Jared Dillard
|
connectWith: '.container .col-md-<?=$columnWidth?>',
|
562 |
91d59881
|
NOYB
|
update: function(){
|
563 |
|
|
dirty = true;
|
564 |
|
|
$('#btnstore').removeClass('invisible');
|
565 |
|
|
}
|
566 |
dc58b7b3
|
Sjon Hortensius
|
});
|
567 |
60e27eb0
|
Stephen Beaver
|
|
568 |
|
|
// On clicking a widget to install . .
|
569 |
a508c6e4
|
NOYB
|
$('[id^=btnadd-]').click(function(event) {
|
570 |
f4a15d29
|
Stephen Beaver
|
// Add the widget name to the list of displayed widgets
|
571 |
a508c6e4
|
NOYB
|
updateWidgets(this.id.replace('btnadd-', ''));
|
572 |
60e27eb0
|
Stephen Beaver
|
|
573 |
|
|
// Submit the form save/display all selected widgets
|
574 |
|
|
$('[name=widgetForm]').submit();
|
575 |
|
|
});
|
576 |
|
|
|
577 |
eae6b58d
|
Stephen Beaver
|
|
578 |
e94f260c
|
Stephen Beaver
|
$('#btnstore').click(function() {
|
579 |
|
|
updateWidgets();
|
580 |
|
|
dirty = false;
|
581 |
91d59881
|
NOYB
|
$(this).addClass('invisible');
|
582 |
e94f260c
|
Stephen Beaver
|
$('[name=widgetForm]').submit();
|
583 |
|
|
});
|
584 |
eae6b58d
|
Stephen Beaver
|
|
585 |
|
|
// provide a warning message if the user tries to change page before saving
|
586 |
|
|
$(window).bind('beforeunload', function(){
|
587 |
|
|
if (dirty) {
|
588 |
4a22d33f
|
Stephen Beaver
|
return ("<?=gettext('One or more widgets have been moved but have not yet been saved')?>");
|
589 |
eae6b58d
|
Stephen Beaver
|
} else {
|
590 |
|
|
return undefined;
|
591 |
|
|
}
|
592 |
|
|
});
|
593 |
cee365e6
|
Stephen Beaver
|
|
594 |
|
|
// Show the fa-save icon in the breadcrumb bar if the user opens or closes a panel (In case he/she wants to save the new state)
|
595 |
|
|
// (Sometimes this will cause us to see the icon when we don't need it, but better that than the other way round)
|
596 |
|
|
$('.panel').on('hidden.bs.collapse shown.bs.collapse', function (e) {
|
597 |
|
|
if (e.currentTarget.id != 'widget-available') {
|
598 |
|
|
$('#btnstore').removeClass("invisible");
|
599 |
|
|
}
|
600 |
|
|
});
|
601 |
8f3a49d7
|
Steve Beaver
|
|
602 |
|
|
// --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
|
603 |
|
|
function make_ajax_call(wd) {
|
604 |
|
|
ajaxmutex = true;
|
605 |
|
|
|
606 |
|
|
$.ajax({
|
607 |
|
|
type: 'POST',
|
608 |
|
|
url: wd.url,
|
609 |
|
|
dataType: 'html',
|
610 |
|
|
data: wd.parms,
|
611 |
|
|
|
612 |
|
|
success: function(data){
|
613 |
|
|
wd.callback(data);
|
614 |
|
|
ajaxmutex = false;
|
615 |
|
|
},
|
616 |
|
|
|
617 |
|
|
error: function(e){
|
618 |
|
|
// alert("Error: " + e);
|
619 |
|
|
ajaxmutex = false;
|
620 |
|
|
}
|
621 |
|
|
});
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
// Loop through each AJAX widget refresh object, make the AJAX call and pass the
|
625 |
|
|
// results back to the widget's callback function
|
626 |
|
|
function executewidget() {
|
627 |
|
|
if (ajaxspecs.length > 0) {
|
628 |
|
|
var freq = ajaxspecs[ajaxidx].freq; // widget can specifify it should be called freq times around hte loop
|
629 |
|
|
|
630 |
|
|
if (!ajaxmutex) {
|
631 |
|
|
if (((ajaxcntr % freq) === 0) && (typeof ajaxspecs[ajaxidx].callback === "function" )) {
|
632 |
|
|
make_ajax_call(ajaxspecs[ajaxidx]);
|
633 |
|
|
}
|
634 |
|
|
|
635 |
|
|
if (++ajaxidx >= ajaxspecs.length) {
|
636 |
|
|
ajaxidx = 0;
|
637 |
|
|
|
638 |
|
|
if (++ajaxcntr >= 4096) {
|
639 |
|
|
ajaxcntr = 0;
|
640 |
|
|
}
|
641 |
|
|
}
|
642 |
|
|
}
|
643 |
|
|
|
644 |
|
|
setTimeout(function() { executewidget(); }, 1000);
|
645 |
|
|
}
|
646 |
|
|
}
|
647 |
|
|
|
648 |
|
|
// Kick it off
|
649 |
|
|
executewidget();
|
650 |
dc58b7b3
|
Sjon Hortensius
|
});
|
651 |
8fd9052f
|
Colin Fleming
|
//]]>
|
652 |
dc58b7b3
|
Sjon Hortensius
|
</script>
|
653 |
41ea4cf3
|
Sjon Hortensius
|
<?php
|
654 |
1180e4f0
|
Sjon Hortensius
|
//build list of javascript include files
|
655 |
aa82505e
|
Phil Davis
|
foreach (glob('widgets/javascript/*.js') as $file) {
|
656 |
1180e4f0
|
Sjon Hortensius
|
echo '<script src="'.$file.'"></script>';
|
657 |
aa82505e
|
Phil Davis
|
}
|
658 |
927ea6e1
|
jim-p
|
|
659 |
1c428d53
|
Phil Davis
|
include("foot.inc");
|