1 |
2cd6010c
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* index.php
|
4 |
|
|
*
|
5 |
|
|
* 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 |
|
|
*
|
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 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
14 |
|
|
* you may not use this file except in compliance with the License.
|
15 |
|
|
* You may obtain a copy of the License at
|
16 |
c5d81585
|
Renato Botelho
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
18 |
c5d81585
|
Renato Botelho
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
20 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
21 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22 |
|
|
* See the License for the specific language governing permissions and
|
23 |
|
|
* limitations under the License.
|
24 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
25 |
5b237745
|
Scott Ullrich
|
|
26 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
27 |
5d916fc7
|
Stephen Beaver
|
##|*IDENT=page-system-login-logout
|
28 |
5230f468
|
jim-p
|
##|*NAME=System: Login / Logout / Dashboard
|
29 |
b7ccf315
|
Erik Fonnesbeck
|
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
|
30 |
6b07c15a
|
Matthew Grooms
|
##|*MATCH=index.php*
|
31 |
|
|
##|-PRIV
|
32 |
|
|
|
33 |
c0339bdc
|
Steve Beaver
|
// Message to display if the session times out and an AJAX call is made
|
34 |
edd492df
|
Steve Beaver
|
$timeoutmessage = gettext("The dashboard web session has timed out.\\n" .
|
35 |
|
|
"It will not update until you refresh the page and log-in again.");
|
36 |
c0339bdc
|
Steve Beaver
|
|
37 |
acc5dd59
|
jim-p
|
// Turn on buffering to speed up rendering
|
38 |
6c07db48
|
Phil Davis
|
ini_set('output_buffering', 'true');
|
39 |
acc5dd59
|
jim-p
|
|
40 |
|
|
// Start buffering with a cache size of 100000
|
41 |
|
|
ob_start(null, "1000");
|
42 |
880637d2
|
Scott Ullrich
|
|
43 |
acc5dd59
|
jim-p
|
## Load Essential Includes
|
44 |
|
|
require_once('guiconfig.inc');
|
45 |
32e834ff
|
Ermal LUÇI
|
require_once('functions.inc');
|
46 |
acc5dd59
|
jim-p
|
require_once('notices.inc');
|
47 |
7c8f3711
|
jim-p
|
require_once("pkg-utils.inc");
|
48 |
acc5dd59
|
jim-p
|
|
49 |
329a1cd5
|
Stephen Beaver
|
if (isset($_POST['closenotice'])) {
|
50 |
|
|
close_notice($_POST['closenotice']);
|
51 |
|
|
sleep(1);
|
52 |
005ac3ca
|
Marcello Coutinho
|
exit;
|
53 |
|
|
}
|
54 |
|
|
|
55 |
cbb82e6b
|
Steve Beaver
|
if (isset($_REQUEST['closenotice'])) {
|
56 |
|
|
close_notice($_REQUEST['closenotice']);
|
57 |
0206483d
|
Stephen Beaver
|
sleep(1);
|
58 |
|
|
}
|
59 |
|
|
|
60 |
41b1ff89
|
Phil Davis
|
if ($g['disablecrashreporter'] != true) {
|
61 |
36365f49
|
Scott Ullrich
|
// Check to see if we have a crash report
|
62 |
eac584f3
|
Scott Ullrich
|
$x = 0;
|
63 |
41b1ff89
|
Phil Davis
|
if (file_exists("/tmp/PHP_errors.log")) {
|
64 |
918f0a94
|
NewEraCracker
|
$total = `/bin/cat /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
|
65 |
41b1ff89
|
Phil Davis
|
if ($total > 0) {
|
66 |
a9ee006d
|
Scott Ullrich
|
$x++;
|
67 |
41b1ff89
|
Phil Davis
|
}
|
68 |
a9ee006d
|
Scott Ullrich
|
}
|
69 |
60e27eb0
|
Stephen Beaver
|
|
70 |
a9ee006d
|
Scott Ullrich
|
$crash = glob("/var/crash/*");
|
71 |
36365f49
|
Scott Ullrich
|
$skip_files = array(".", "..", "minfree", "");
|
72 |
60e27eb0
|
Stephen Beaver
|
|
73 |
41b1ff89
|
Phil Davis
|
if (is_array($crash)) {
|
74 |
|
|
foreach ($crash as $c) {
|
75 |
|
|
if (!in_array(basename($c), $skip_files)) {
|
76 |
36365f49
|
Scott Ullrich
|
$x++;
|
77 |
41b1ff89
|
Phil Davis
|
}
|
78 |
36365f49
|
Scott Ullrich
|
}
|
79 |
60e27eb0
|
Stephen Beaver
|
|
80 |
41b1ff89
|
Phil Davis
|
if ($x > 0) {
|
81 |
c87eeb08
|
Phil Davis
|
$savemsg = sprintf(gettext("%s has detected a crash report or programming bug."), $g['product_name']) . " ";
|
82 |
|
|
if (isAllowedPage("/crash_reporter.php")) {
|
83 |
7ae1b34f
|
Phil Davis
|
$savemsg .= sprintf(gettext('Click %1$shere%2$s for more information.'), '<a href="crash_reporter.php">', '</a>');
|
84 |
c87eeb08
|
Phil Davis
|
} else {
|
85 |
6f4323f3
|
Phil Davis
|
$savemsg .= sprintf(gettext("Contact a firewall administrator for more information."));
|
86 |
c87eeb08
|
Phil Davis
|
}
|
87 |
c8532336
|
Phil Davis
|
$class = "warning";
|
88 |
41b1ff89
|
Phil Davis
|
}
|
89 |
104faa07
|
Scott Ullrich
|
}
|
90 |
|
|
}
|
91 |
|
|
|
92 |
8452bfc2
|
stilez
|
## Include each widget php include file.
|
93 |
|
|
## These define vars that specify the widget title and title link.
|
94 |
|
|
|
95 |
ef325a6c
|
Phil Davis
|
$directory = "/usr/local/www/widgets/include/";
|
96 |
|
|
$dirhandle = opendir($directory);
|
97 |
|
|
$filename = "";
|
98 |
|
|
|
99 |
8452bfc2
|
stilez
|
while (($filename = readdir($dirhandle)) !== false) {
|
100 |
|
|
if (strtolower(substr($filename, -4)) == ".inc" && file_exists($directory . $filename)) {
|
101 |
|
|
include_once($directory . $filename);
|
102 |
ef325a6c
|
Phil Davis
|
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
acc5dd59
|
jim-p
|
##build list of widgets
|
106 |
aa82505e
|
Phil Davis
|
foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file) {
|
107 |
0172a197
|
Phil Davis
|
$basename = basename($file, '.widget.php');
|
108 |
ef325a6c
|
Phil Davis
|
// Get the widget title that should be in a var defined in the widget's inc file.
|
109 |
0172a197
|
Phil Davis
|
$widgettitle = ${$basename . '_title'};
|
110 |
ef325a6c
|
Phil Davis
|
|
111 |
dffe24be
|
NewEraCracker
|
if (empty(trim($widgettitle))) {
|
112 |
ef325a6c
|
Phil Davis
|
// Fall back to constructing a title from the file name of the widget.
|
113 |
0172a197
|
Phil Davis
|
$widgettitle = ucwords(str_replace('_', ' ', $basename));
|
114 |
ef325a6c
|
Phil Davis
|
}
|
115 |
|
|
|
116 |
f14e891d
|
Phil Davis
|
$known_widgets[$basename . '-0'] = array(
|
117 |
|
|
'basename' => $basename,
|
118 |
|
|
'title' => $widgettitle,
|
119 |
|
|
'display' => 'none',
|
120 |
|
|
'multicopy' => ${$basename . '_allow_multiple_widget_copies'}
|
121 |
|
|
);
|
122 |
acc5dd59
|
jim-p
|
}
|
123 |
|
|
|
124 |
|
|
##if no config entry found, initialize config entry
|
125 |
|
|
if (!is_array($config['widgets'])) {
|
126 |
|
|
$config['widgets'] = array();
|
127 |
|
|
}
|
128 |
d7c2f4fe
|
Steve Beaver
|
|
129 |
5aad7323
|
NewEraCracker
|
if (!is_array($user_settings['widgets'])) {
|
130 |
|
|
$user_settings['widgets'] = array();
|
131 |
|
|
}
|
132 |
d772ac32
|
Erik Kristensen
|
|
133 |
41ea4cf3
|
Sjon Hortensius
|
if ($_POST && $_POST['sequence']) {
|
134 |
60e27eb0
|
Stephen Beaver
|
|
135 |
2b7d0520
|
Phil Davis
|
// Start with the user's widget settings.
|
136 |
|
|
$widget_settings = $user_settings['widgets'];
|
137 |
236e6a54
|
Stephen Beaver
|
|
138 |
0172a197
|
Phil Davis
|
$widget_sep = ',';
|
139 |
|
|
$widget_seq_array = explode($widget_sep, rtrim($_POST['sequence'], $widget_sep));
|
140 |
|
|
$widget_counter_array = array();
|
141 |
|
|
$widget_sep = '';
|
142 |
8191b36e
|
Scott Ullrich
|
|
143 |
0172a197
|
Phil Davis
|
// Make a record of the counter of each widget that is in use.
|
144 |
|
|
foreach ($widget_seq_array as $widget_seq_data) {
|
145 |
|
|
list($basename, $col, $display, $widget_counter) = explode(':', $widget_seq_data);
|
146 |
|
|
|
147 |
|
|
if ($widget_counter != 'next') {
|
148 |
7b973ceb
|
jim-p
|
if (!is_numeric($widget_counter)) {
|
149 |
|
|
continue;
|
150 |
|
|
}
|
151 |
0172a197
|
Phil Davis
|
$widget_counter_array[$basename][$widget_counter] = true;
|
152 |
|
|
$widget_sequence .= $widget_sep . $widget_seq_data;
|
153 |
|
|
$widget_sep = ',';
|
154 |
|
|
}
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
// Find any new entry (and do not assume there is only 1 new entry)
|
158 |
|
|
foreach ($widget_seq_array as $widget_seq_data) {
|
159 |
|
|
list($basename, $col, $display, $widget_counter) = explode(':', $widget_seq_data);
|
160 |
|
|
|
161 |
|
|
if ($widget_counter == 'next') {
|
162 |
|
|
// Construct the widget counter of the new widget instance by finding
|
163 |
|
|
// the first non-negative integer that is not in use.
|
164 |
|
|
// The reasoning here is that if you just deleted a widget instance,
|
165 |
|
|
// e.g. had System Information 0,1,2 and deleted 1,
|
166 |
|
|
// then when you add System Information again it will become instance 1,
|
167 |
|
|
// which will bring back whatever filter selections happened to be on
|
168 |
|
|
// the previous instance 1.
|
169 |
|
|
$instance_num = 0;
|
170 |
|
|
|
171 |
|
|
while (isset($widget_counter_array[$basename][$instance_num])) {
|
172 |
|
|
$instance_num++;
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
$widget_sequence .= $widget_sep . $basename . ':' . $col . ':' . $display . ':' . $instance_num;
|
176 |
|
|
$widget_counter_array[$basename][$instance_num] = true;
|
177 |
|
|
$widget_sep = ',';
|
178 |
|
|
}
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
$widget_settings['sequence'] = $widget_sequence;
|
182 |
|
|
|
183 |
|
|
foreach ($widget_counter_array as $basename => $instances) {
|
184 |
|
|
foreach ($instances as $instance => $value) {
|
185 |
|
|
$widgetconfigname = $basename . '-' . $instance . '-config';
|
186 |
|
|
if ($_POST[$widgetconfigname]) {
|
187 |
|
|
$widget_settings[$widgetconfigname] = $_POST[$widgetconfigname];
|
188 |
|
|
}
|
189 |
8191b36e
|
Scott Ullrich
|
}
|
190 |
|
|
}
|
191 |
|
|
|
192 |
8bab524e
|
Phil Davis
|
save_widget_settings($_SESSION['Username'], $widget_settings);
|
193 |
69b397dd
|
Sjon Hortensius
|
header("Location: /");
|
194 |
1180e4f0
|
Sjon Hortensius
|
exit;
|
195 |
|
|
}
|
196 |
757733b5
|
Renato Botelho
|
|
197 |
1180e4f0
|
Sjon Hortensius
|
## Load Functions Files
|
198 |
|
|
require_once('includes/functions.inc.php');
|
199 |
d772ac32
|
Erik Kristensen
|
|
200 |
1180e4f0
|
Sjon Hortensius
|
## Check to see if we have a swap space,
|
201 |
|
|
## if true, display, if false, hide it ...
|
202 |
1c428d53
|
Phil Davis
|
if (file_exists("/usr/sbin/swapinfo")) {
|
203 |
1180e4f0
|
Sjon Hortensius
|
$swapinfo = `/usr/sbin/swapinfo`;
|
204 |
1c428d53
|
Phil Davis
|
if (stristr($swapinfo, '%') == true) $showswap=true;
|
205 |
1180e4f0
|
Sjon Hortensius
|
}
|
206 |
|
|
|
207 |
|
|
## User recently restored his config.
|
208 |
|
|
## If packages are installed lets resync
|
209 |
1c428d53
|
Phil Davis
|
if (file_exists('/conf/needs_package_sync')) {
|
210 |
|
|
if ($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
|
211 |
dc61252a
|
Renato Botelho
|
## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
|
212 |
|
|
## the package reinstall page. That is about to be done by the boot script anyway.
|
213 |
|
|
## The code in head.inc will put up a notice to the user.
|
214 |
|
|
if (!platform_booting()) {
|
215 |
|
|
header('Location: pkg_mgr_install.php?mode=reinstallall');
|
216 |
|
|
exit;
|
217 |
1df0159c
|
Erik Kristensen
|
}
|
218 |
1180e4f0
|
Sjon Hortensius
|
} else {
|
219 |
|
|
@unlink('/conf/needs_package_sync');
|
220 |
1df0159c
|
Erik Kristensen
|
}
|
221 |
1180e4f0
|
Sjon Hortensius
|
}
|
222 |
8fecad11
|
Scott Ullrich
|
|
223 |
1180e4f0
|
Sjon Hortensius
|
## If it is the first time webConfigurator has been
|
224 |
|
|
## accessed since initial install show this stuff.
|
225 |
1c428d53
|
Phil Davis
|
if (file_exists('/conf/trigger_initial_wizard')) {
|
226 |
1180e4f0
|
Sjon Hortensius
|
?>
|
227 |
|
|
<!DOCTYPE html>
|
228 |
|
|
<html lang="en">
|
229 |
f3c5f4c5
|
Steve Beaver
|
<head>
|
230 |
|
|
<link rel="stylesheet" href="/css/pfSense.css" />
|
231 |
|
|
<title><?=$g['product_name']?>.localdomain - <?=$g['product_name']?> first time setup</title>
|
232 |
|
|
<meta http-equiv="refresh" content="1;url=wizard.php?xml=setup_wizard.xml" />
|
233 |
|
|
</head>
|
234 |
|
|
<body id="loading-wizard" class="no-menu">
|
235 |
|
|
<div id="jumbotron">
|
236 |
|
|
<div class="container">
|
237 |
|
|
<div class="col-sm-offset-3 col-sm-6 col-xs-12">
|
238 |
|
|
<font color="white">
|
239 |
|
|
<p><h3><?=sprintf(gettext("Welcome to %s!") . "\n", $g['product_name'])?></h3></p>
|
240 |
|
|
<p><?=gettext("One moment while the initial setup wizard starts.")?></p>
|
241 |
|
|
<p><?=gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.")?></p>
|
242 |
|
|
<p><?=sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."), $g['product_name'])?></p>
|
243 |
|
|
</font>
|
244 |
|
|
</div>
|
245 |
c7d61071
|
Sander van Leeuwen
|
</div>
|
246 |
1180e4f0
|
Sjon Hortensius
|
</div>
|
247 |
f3c5f4c5
|
Steve Beaver
|
</body>
|
248 |
1180e4f0
|
Sjon Hortensius
|
</html>
|
249 |
|
|
<?php
|
250 |
|
|
exit;
|
251 |
|
|
}
|
252 |
bf787c0a
|
Scott Ullrich
|
|
253 |
1180e4f0
|
Sjon Hortensius
|
## Find out whether there's hardware encryption or not
|
254 |
|
|
unset($hwcrypto);
|
255 |
|
|
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
|
256 |
|
|
if ($fd) {
|
257 |
|
|
while (!feof($fd)) {
|
258 |
|
|
$dmesgl = fgets($fd);
|
259 |
|
|
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
|
260 |
|
|
or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
|
261 |
|
|
or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
|
262 |
|
|
or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
|
263 |
2ce5cd33
|
jim-p
|
or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)) {
|
264 |
1180e4f0
|
Sjon Hortensius
|
$hwcrypto = $matches[1];
|
265 |
|
|
break;
|
266 |
5b237745
|
Scott Ullrich
|
}
|
267 |
|
|
}
|
268 |
1180e4f0
|
Sjon Hortensius
|
fclose($fd);
|
269 |
aa82505e
|
Phil Davis
|
if (!isset($hwcrypto) && get_single_sysctl("dev.aesni.0.%desc")) {
|
270 |
a2e6d7f8
|
Luiz Otavio O Souza
|
$hwcrypto = get_single_sysctl("dev.aesni.0.%desc");
|
271 |
aa82505e
|
Phil Davis
|
}
|
272 |
1180e4f0
|
Sjon Hortensius
|
}
|
273 |
45ee90ed
|
Matthew Grooms
|
|
274 |
7abf7db5
|
Scott Dale
|
##build widget saved list information
|
275 |
8bab524e
|
Phil Davis
|
if ($user_settings['widgets']['sequence'] != "") {
|
276 |
db7f2719
|
jim-p
|
$dashboardcolumns = isset($user_settings['webgui']['dashboardcolumns']) ? (int) $user_settings['webgui']['dashboardcolumns'] : 2;
|
277 |
8bab524e
|
Phil Davis
|
$pconfig['sequence'] = $user_settings['widgets']['sequence'];
|
278 |
1180e4f0
|
Sjon Hortensius
|
$widgetsfromconfig = array();
|
279 |
757733b5
|
Renato Botelho
|
|
280 |
aa82505e
|
Phil Davis
|
foreach (explode(',', $pconfig['sequence']) as $line) {
|
281 |
0172a197
|
Phil Davis
|
$line_items = explode(':', $line);
|
282 |
|
|
if (count($line_items) == 3) {
|
283 |
|
|
// There can be multiple copies of a widget on the dashboard.
|
284 |
|
|
// Default the copy number if it is not present (e.g. from old configs)
|
285 |
|
|
$line_items[] = 0;
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
list($basename, $col, $display, $copynum) = $line_items;
|
289 |
7b973ceb
|
jim-p
|
if (!is_numeric($copynum)) {
|
290 |
|
|
continue;
|
291 |
|
|
}
|
292 |
1180e4f0
|
Sjon Hortensius
|
|
293 |
|
|
// be backwards compatible
|
294 |
72eaefaf
|
Stephen Beaver
|
// If the display column information is missing, we will assign a temporary
|
295 |
|
|
// column here. Next time the user saves the dashboard it will fix itself
|
296 |
|
|
if ($col == "") {
|
297 |
0172a197
|
Phil Davis
|
if ($basename == "system_information") {
|
298 |
72eaefaf
|
Stephen Beaver
|
$col = "col1";
|
299 |
|
|
} else {
|
300 |
|
|
$col = "col2";
|
301 |
|
|
}
|
302 |
|
|
}
|
303 |
|
|
|
304 |
ad51eb90
|
Phil Davis
|
// Limit the column to the current dashboard columns.
|
305 |
|
|
if (substr($col, 3) > $dashboardcolumns) {
|
306 |
|
|
$col = "col" . $dashboardcolumns;
|
307 |
|
|
}
|
308 |
|
|
|
309 |
0172a197
|
Phil Davis
|
$offset = strpos($basename, '-container');
|
310 |
94704bc6
|
Phil Davis
|
if (false !== $offset) {
|
311 |
0172a197
|
Phil Davis
|
$basename = substr($basename, 0, $offset);
|
312 |
94704bc6
|
Phil Davis
|
}
|
313 |
0fc6d49d
|
Phil Davis
|
$widgetkey = $basename . '-' . $copynum;
|
314 |
1180e4f0
|
Sjon Hortensius
|
|
315 |
0fc6d49d
|
Phil Davis
|
if (isset($user_settings['widgets'][$widgetkey]['descr'])) {
|
316 |
|
|
$widgettitle = htmlentities($user_settings['widgets'][$widgetkey]['descr']);
|
317 |
|
|
} else {
|
318 |
|
|
// Get the widget title that should be in a var defined in the widget's inc file.
|
319 |
|
|
$widgettitle = ${$basename . '_title'};
|
320 |
ef325a6c
|
Phil Davis
|
|
321 |
0fc6d49d
|
Phil Davis
|
if (empty(trim($widgettitle))) {
|
322 |
|
|
// Fall back to constructing a title from the file name of the widget.
|
323 |
|
|
$widgettitle = ucwords(str_replace('_', ' ', $basename));
|
324 |
|
|
}
|
325 |
ef325a6c
|
Phil Davis
|
}
|
326 |
|
|
|
327 |
0172a197
|
Phil Davis
|
$widgetsfromconfig[$widgetkey] = array(
|
328 |
|
|
'basename' => $basename,
|
329 |
|
|
'title' => $widgettitle,
|
330 |
1180e4f0
|
Sjon Hortensius
|
'col' => $col,
|
331 |
|
|
'display' => $display,
|
332 |
0172a197
|
Phil Davis
|
'copynum' => $copynum,
|
333 |
f14e891d
|
Phil Davis
|
'multicopy' => ${$basename . '_allow_multiple_widget_copies'}
|
334 |
1180e4f0
|
Sjon Hortensius
|
);
|
335 |
f14e891d
|
Phil Davis
|
|
336 |
|
|
// Update the known_widgets entry so we know if any copy of the widget is being displayed
|
337 |
|
|
$known_widgets[$basename . '-0']['display'] = $display;
|
338 |
1db766df
|
Scott Dale
|
}
|
339 |
757733b5
|
Renato Botelho
|
|
340 |
5c7657d6
|
Renato Botelho
|
// add widgets that may not be in the saved configuration, in case they are to be displayed later
|
341 |
0172a197
|
Phil Davis
|
$widgets = $widgetsfromconfig + $known_widgets;
|
342 |
757733b5
|
Renato Botelho
|
|
343 |
019a94df
|
Scott Dale
|
##find custom configurations of a particular widget and load its info to $pconfig
|
344 |
1c428d53
|
Phil Davis
|
foreach ($widgets as $widgetname => $widgetconfig) {
|
345 |
75ae3d1c
|
Phil Davis
|
if ($config['widgets'][$widgetname . '-config']) {
|
346 |
|
|
$pconfig[$widgetname . '-config'] = $config['widgets'][$widgetname . '-config'];
|
347 |
757733b5
|
Renato Botelho
|
}
|
348 |
|
|
}
|
349 |
3e4e94ce
|
Scott Dale
|
}
|
350 |
|
|
|
351 |
c05363c8
|
NOYB
|
## Get the configured options for Show/Hide available widgets panel.
|
352 |
8bab524e
|
Phil Davis
|
$dashboard_available_widgets_hidden = !$user_settings['webgui']['dashboardavailablewidgetspanel'];
|
353 |
c05363c8
|
NOYB
|
|
354 |
|
|
if ($dashboard_available_widgets_hidden) {
|
355 |
|
|
$panel_state = 'out';
|
356 |
|
|
$panel_body_state = 'in';
|
357 |
|
|
} else {
|
358 |
|
|
$panel_state = 'in';
|
359 |
|
|
$panel_body_state = 'out';
|
360 |
|
|
}
|
361 |
|
|
|
362 |
1db766df
|
Scott Dale
|
## Set Page Title and Include Header
|
363 |
2734d2db
|
Jared Dillard
|
$pgtitle = array(gettext("Status"), gettext("Dashboard"));
|
364 |
1db766df
|
Scott Dale
|
include("head.inc");
|
365 |
f6f6947e
|
Scott Ullrich
|
|
366 |
41b1ff89
|
Phil Davis
|
if ($savemsg) {
|
367 |
c8532336
|
Phil Davis
|
print_info_box($savemsg, $class);
|
368 |
41b1ff89
|
Phil Davis
|
}
|
369 |
fca795f8
|
Scott Ullrich
|
|
370 |
810a11bc
|
Scott Ullrich
|
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
|
371 |
c69c58e2
|
Vinicius Coque
|
|
372 |
0682e26b
|
Colin Smith
|
?>
|
373 |
1180e4f0
|
Sjon Hortensius
|
|
374 |
c05363c8
|
NOYB
|
<div class="panel panel-default collapse <?=$panel_state?>" id="widget-available">
|
375 |
95fa5cce
|
Phil Davis
|
<div class="panel-heading">
|
376 |
|
|
<h2 class="panel-title"><?=gettext("Available Widgets"); ?>
|
377 |
|
|
<span class="widget-heading-icon">
|
378 |
|
|
<a data-toggle="collapse" href="#widget-available_panel-body" id="widgets-available">
|
379 |
|
|
<i class="fa fa-plus-circle"></i>
|
380 |
|
|
</a>
|
381 |
|
|
</span>
|
382 |
|
|
</h2>
|
383 |
166b0099
|
Stephen Beaver
|
</div>
|
384 |
c05363c8
|
NOYB
|
<div id="widget-available_panel-body" class="panel-body collapse <?=$panel_body_state?>">
|
385 |
9239f765
|
Jared Dillard
|
<div class="content">
|
386 |
|
|
<div class="row">
|
387 |
60e27eb0
|
Stephen Beaver
|
<?php
|
388 |
e76931e2
|
Stephen Beaver
|
|
389 |
0172a197
|
Phil Davis
|
// Build the Available Widgets table using a sorted copy of the $known_widgets array
|
390 |
|
|
$available = $known_widgets;
|
391 |
|
|
uasort($available, function($a, $b){ return strcasecmp($a['title'], $b['title']); });
|
392 |
e76931e2
|
Stephen Beaver
|
|
393 |
0172a197
|
Phil Davis
|
foreach ($available as $widgetkey => $widgetconfig):
|
394 |
f14e891d
|
Phil Davis
|
// If the widget supports multiple copies, or no copies are displayed yet, then it is available to add
|
395 |
|
|
if (($widgetconfig['multicopy']) || ($widgetconfig['display'] == 'none')):
|
396 |
60e27eb0
|
Stephen Beaver
|
?>
|
397 |
0172a197
|
Phil Davis
|
<div class="col-sm-3"><a href="#" id="btnadd-<?=$widgetconfig['basename']?>"><i class="fa fa-plus"></i> <?=$widgetconfig['title']?></a></div>
|
398 |
f14e891d
|
Phil Davis
|
<?php endif; ?>
|
399 |
d7c2f4fe
|
Steve Beaver
|
<?php
|
400 |
8452bfc2
|
stilez
|
endforeach;
|
401 |
|
|
?>
|
402 |
9239f765
|
Jared Dillard
|
</div>
|
403 |
8452bfc2
|
stilez
|
<p style="text-align:center"><?=sprintf(gettext('Other dashboard settings are available from the <a href="%s">General Setup</a> page.'), '/system.php')?></p>
|
404 |
9239f765
|
Jared Dillard
|
</div>
|
405 |
1db766df
|
Scott Dale
|
</div>
|
406 |
|
|
</div>
|
407 |
|
|
|
408 |
a2faa388
|
Sander van Leeuwen
|
<div class="hidden" id="widgetSequence">
|
409 |
a508c6e4
|
NOYB
|
<form action="/" method="post" id="widgetSequence_form" name="widgetForm">
|
410 |
41ea4cf3
|
Sjon Hortensius
|
<input type="hidden" name="sequence" value="" />
|
411 |
|
|
</form>
|
412 |
|
|
</div>
|
413 |
|
|
|
414 |
1180e4f0
|
Sjon Hortensius
|
<?php
|
415 |
41ea4cf3
|
Sjon Hortensius
|
$widgetColumns = array();
|
416 |
0172a197
|
Phil Davis
|
foreach ($widgets as $widgetkey => $widgetconfig) {
|
417 |
8452bfc2
|
stilez
|
if ($widgetconfig['display'] != 'none' && file_exists("/usr/local/www/widgets/widgets/{$widgetconfig['basename']}.widget.php")) {
|
418 |
|
|
if (!isset($widgetColumns[$widgetconfig['col']])) {
|
419 |
|
|
$widgetColumns[$widgetconfig['col']] = array();
|
420 |
|
|
}
|
421 |
|
|
$widgetColumns[$widgetconfig['col']][$widgetkey] = $widgetconfig;
|
422 |
aa82505e
|
Phil Davis
|
}
|
423 |
41ea4cf3
|
Sjon Hortensius
|
}
|
424 |
1180e4f0
|
Sjon Hortensius
|
?>
|
425 |
41ea4cf3
|
Sjon Hortensius
|
|
426 |
a2faa388
|
Sander van Leeuwen
|
<div class="row">
|
427 |
2063a534
|
Jared Dillard
|
<?php
|
428 |
d86cff7f
|
Phil Davis
|
$columnWidth = (int) (12 / $numColumns);
|
429 |
a54d69c8
|
Stephen Beaver
|
|
430 |
e3843a08
|
Phil Davis
|
for ($currentColumnNumber = 1; $currentColumnNumber <= $numColumns; $currentColumnNumber++) {
|
431 |
cee365e6
|
Stephen Beaver
|
|
432 |
2063a534
|
Jared Dillard
|
|
433 |
e3843a08
|
Phil Davis
|
//if col$currentColumnNumber exists
|
434 |
|
|
if (isset($widgetColumns['col'.$currentColumnNumber])) {
|
435 |
caf897c8
|
Jared Dillard
|
echo '<div class="col-md-' . $columnWidth . '" id="widgets-col' . $currentColumnNumber . '">';
|
436 |
e3843a08
|
Phil Davis
|
$columnWidgets = $widgetColumns['col'.$currentColumnNumber];
|
437 |
2063a534
|
Jared Dillard
|
|
438 |
0172a197
|
Phil Davis
|
foreach ($columnWidgets as $widgetkey => $widgetconfig) {
|
439 |
|
|
// Construct some standard names for the ids this widget will use for its commonly-used elements.
|
440 |
|
|
// Included widget.php code can rely on and use these, so the format does not have to be repeated in every widget.php
|
441 |
|
|
$widget_panel_body_id = 'widget-' . $widgetkey . '_panel-body';
|
442 |
|
|
$widget_panel_footer_id = 'widget-' . $widgetkey . '_panel-footer';
|
443 |
|
|
$widget_showallnone_id = 'widget-' . $widgetkey . '_showallnone';
|
444 |
|
|
|
445 |
2063a534
|
Jared Dillard
|
// Compose the widget title and include the title link if available
|
446 |
0172a197
|
Phil Davis
|
$widgetlink = ${$widgetconfig['basename'] . '_title_link'};
|
447 |
2063a534
|
Jared Dillard
|
|
448 |
|
|
if ((strlen($widgetlink) > 0)) {
|
449 |
0172a197
|
Phil Davis
|
$wtitle = '<a href="' . $widgetlink . '"> ' . $widgetconfig['title'] . '</a>';
|
450 |
2063a534
|
Jared Dillard
|
} else {
|
451 |
0172a197
|
Phil Davis
|
$wtitle = $widgetconfig['title'];
|
452 |
2063a534
|
Jared Dillard
|
}
|
453 |
|
|
?>
|
454 |
0172a197
|
Phil Davis
|
<div class="panel panel-default" id="widget-<?=$widgetkey?>">
|
455 |
2063a534
|
Jared Dillard
|
<div class="panel-heading">
|
456 |
95fa5cce
|
Phil Davis
|
<h2 class="panel-title">
|
457 |
|
|
<?=$wtitle?>
|
458 |
|
|
<span class="widget-heading-icon">
|
459 |
0172a197
|
Phil Davis
|
<a data-toggle="collapse" href="#<?=$widget_panel_footer_id?>" class="config hidden">
|
460 |
95fa5cce
|
Phil Davis
|
<i class="fa fa-wrench"></i>
|
461 |
|
|
</a>
|
462 |
0172a197
|
Phil Davis
|
<a data-toggle="collapse" href="#<?=$widget_panel_body_id?>">
|
463 |
95fa5cce
|
Phil Davis
|
<!-- actual icon is determined in css based on state of body -->
|
464 |
|
|
<i class="fa fa-plus-circle"></i>
|
465 |
|
|
</a>
|
466 |
0172a197
|
Phil Davis
|
<a data-toggle="close" href="#widget-<?=$widgetkey?>">
|
467 |
95fa5cce
|
Phil Davis
|
<i class="fa fa-times-circle"></i>
|
468 |
|
|
</a>
|
469 |
|
|
</span>
|
470 |
|
|
</h2>
|
471 |
2063a534
|
Jared Dillard
|
</div>
|
472 |
0172a197
|
Phil Davis
|
<div id="<?=$widget_panel_body_id?>" class="panel-body collapse<?=($widgetconfig['display'] == 'close' ? '' : ' in')?>">
|
473 |
|
|
<?php
|
474 |
|
|
// For backward compatibility, included *.widget.php code needs the var $widgetname
|
475 |
|
|
$widgetname = $widgetkey;
|
476 |
|
|
// Determine if this is the first instance of this particular widget.
|
477 |
|
|
// Provide the $widget_first_instance var, to make it easy for the included widget code
|
478 |
|
|
// to be able to know if it is being included for the first time.
|
479 |
|
|
if ($widgets_found[$widgetconfig['basename']]) {
|
480 |
|
|
$widget_first_instance = false;
|
481 |
|
|
} else {
|
482 |
|
|
$widget_first_instance = true;
|
483 |
|
|
$widgets_found[$widgetconfig['basename']] = true;
|
484 |
|
|
}
|
485 |
|
|
include('/usr/local/www/widgets/widgets/' . $widgetconfig['basename'] . '.widget.php');
|
486 |
|
|
?>
|
487 |
2063a534
|
Jared Dillard
|
</div>
|
488 |
|
|
</div>
|
489 |
|
|
<?php
|
490 |
|
|
}
|
491 |
6fefbd48
|
Jared Dillard
|
echo "</div>";
|
492 |
a54d69c8
|
Stephen Beaver
|
} else {
|
493 |
caf897c8
|
Jared Dillard
|
echo '<div class="col-md-' . $columnWidth . '" id="widgets-col' . $currentColumnNumber . '"></div>';
|
494 |
a54d69c8
|
Stephen Beaver
|
}
|
495 |
cee365e6
|
Stephen Beaver
|
|
496 |
477db933
|
Jared Dillard
|
}
|
497 |
|
|
?>
|
498 |
2063a534
|
Jared Dillard
|
|
499 |
a2faa388
|
Sander van Leeuwen
|
</div>
|
500 |
561d55ff
|
Erik Kristensen
|
|
501 |
f3c5f4c5
|
Steve Beaver
|
<?php
|
502 |
31c8b40b
|
Renato Botelho
|
/*
|
503 |
|
|
* Import the modal form used to display the copyright/usage information
|
504 |
|
|
* when trigger file exists. Trigger file is created during upgrade process
|
505 |
|
|
* when /etc/version changes
|
506 |
|
|
*/
|
507 |
3a910ee1
|
Steve Beaver
|
require_once("copyget.inc");
|
508 |
|
|
|
509 |
31c8b40b
|
Renato Botelho
|
if (file_exists("{$g['cf_conf_path']}/copynotice_display")) {
|
510 |
3a910ee1
|
Steve Beaver
|
require_once("copynotice.inc");
|
511 |
31c8b40b
|
Renato Botelho
|
@unlink("{$g['cf_conf_path']}/copynotice_display");
|
512 |
f3c5f4c5
|
Steve Beaver
|
}
|
513 |
8ba87e85
|
Steve Beaver
|
|
514 |
|
|
/*
|
515 |
|
|
* Import the modal form used to display any HTML text a package may want to display
|
516 |
|
|
* on installation or removal
|
517 |
|
|
*/
|
518 |
|
|
$ui_notice = "/tmp/package_ui_notice";
|
519 |
|
|
if (file_exists($ui_notice)) {
|
520 |
|
|
require_once("{$g['www_path']}/upgrnotice.inc");
|
521 |
|
|
}
|
522 |
f3c5f4c5
|
Steve Beaver
|
?>
|
523 |
|
|
|
524 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
525 |
|
|
//<![CDATA[
|
526 |
eae6b58d
|
Stephen Beaver
|
|
527 |
|
|
dirty = false;
|
528 |
aa82505e
|
Phil Davis
|
function updateWidgets(newWidget) {
|
529 |
7f8f8808
|
Sjon Hortensius
|
var sequence = '';
|
530 |
|
|
|
531 |
aa82505e
|
Phil Davis
|
$('.container .col-md-<?=$columnWidth?>').each(function(idx, col) {
|
532 |
|
|
$('.panel', col).each(function(idx, widget) {
|
533 |
7f8f8808
|
Sjon Hortensius
|
var isOpen = $('.panel-body', widget).hasClass('in');
|
534 |
621dd536
|
Phil Davis
|
var widget_basename = widget.id.split('-')[1];
|
535 |
7f8f8808
|
Sjon Hortensius
|
|
536 |
621dd536
|
Phil Davis
|
// Only save details for panels that have id's like'widget-*'
|
537 |
|
|
// Some widgets create other panels, so ignore any of those.
|
538 |
|
|
if ((widget.id.split('-')[0] == 'widget') && (typeof widget_basename !== 'undefined')) {
|
539 |
0172a197
|
Phil Davis
|
sequence += widget_basename + ':' + col.id.split('-')[1] + ':' + (isOpen ? 'open' : 'close') + ':' + widget.id.split('-')[2] + ',';
|
540 |
621dd536
|
Phil Davis
|
}
|
541 |
7f8f8808
|
Sjon Hortensius
|
});
|
542 |
|
|
});
|
543 |
|
|
|
544 |
aa82505e
|
Phil Davis
|
if (typeof newWidget !== 'undefined') {
|
545 |
b5ff58cf
|
Stephen Beaver
|
// The system_information widget is always added to column one. Others go in column two
|
546 |
|
|
if (newWidget == "system_information") {
|
547 |
0172a197
|
Phil Davis
|
sequence += newWidget.split('-')[0] + ':' + 'col1:open:next';
|
548 |
b5ff58cf
|
Stephen Beaver
|
} else {
|
549 |
0172a197
|
Phil Davis
|
sequence += newWidget.split('-')[0] + ':' + 'col2:open:next';
|
550 |
b5ff58cf
|
Stephen Beaver
|
}
|
551 |
aa82505e
|
Phil Davis
|
}
|
552 |
60e27eb0
|
Stephen Beaver
|
|
553 |
a508c6e4
|
NOYB
|
$('input[name=sequence]', $('#widgetSequence_form')).val(sequence);
|
554 |
7f8f8808
|
Sjon Hortensius
|
}
|
555 |
|
|
|
556 |
fba53b43
|
Phil Davis
|
// Determine if all the checkboxes are checked
|
557 |
|
|
function are_all_checked(checkbox_panel_ref) {
|
558 |
|
|
var allBoxesChecked = true;
|
559 |
|
|
$(checkbox_panel_ref).each(function() {
|
560 |
|
|
if ((this.type == 'checkbox') && !this.checked) {
|
561 |
|
|
allBoxesChecked = false;
|
562 |
|
|
}
|
563 |
|
|
});
|
564 |
|
|
return allBoxesChecked;
|
565 |
|
|
}
|
566 |
|
|
|
567 |
|
|
// If the checkboxes are all checked, then clear them all.
|
568 |
|
|
// Otherwise set them all.
|
569 |
|
|
function set_clear_checkboxes(checkbox_panel_ref) {
|
570 |
|
|
checkTheBoxes = !are_all_checked(checkbox_panel_ref);
|
571 |
|
|
|
572 |
|
|
$(checkbox_panel_ref).each(function() {
|
573 |
|
|
$(this).prop("checked", checkTheBoxes);
|
574 |
|
|
});
|
575 |
|
|
}
|
576 |
|
|
|
577 |
|
|
// Set the given id to All or None button depending if the checkboxes are all checked.
|
578 |
|
|
function set_all_none_button(checkbox_panel_ref, all_none_button_id) {
|
579 |
|
|
if (are_all_checked(checkbox_panel_ref)) {
|
580 |
|
|
text = "<?=gettext('None')?>";
|
581 |
|
|
} else {
|
582 |
|
|
text = "<?=gettext('All')?>";
|
583 |
|
|
}
|
584 |
|
|
|
585 |
|
|
$("#" + all_none_button_id).html('<i class="fa fa-undo icon-embed-btn"></i>' + text);
|
586 |
|
|
}
|
587 |
|
|
|
588 |
|
|
// Setup the necessary events to manage the All/None button and included checkboxes
|
589 |
|
|
// used for selecting the items to show on a widget.
|
590 |
|
|
function set_widget_checkbox_events(checkbox_panel_ref, all_none_button_id) {
|
591 |
|
|
set_all_none_button(checkbox_panel_ref, all_none_button_id);
|
592 |
|
|
|
593 |
|
|
$(checkbox_panel_ref).change(function() {
|
594 |
|
|
set_all_none_button(checkbox_panel_ref, all_none_button_id);
|
595 |
|
|
});
|
596 |
|
|
|
597 |
|
|
$("#" + all_none_button_id).click(function() {
|
598 |
|
|
set_clear_checkboxes(checkbox_panel_ref);
|
599 |
|
|
set_all_none_button(checkbox_panel_ref, all_none_button_id);
|
600 |
|
|
});
|
601 |
|
|
}
|
602 |
|
|
|
603 |
f3c5f4c5
|
Steve Beaver
|
// ---------------------Centralized widget refresh system -------------------------------------------
|
604 |
d7c2f4fe
|
Steve Beaver
|
// These need to live outsie of the events.push() function to enable the widgets to see them
|
605 |
53547a05
|
Steve Beaver
|
var ajaxspecs = new Array(); // Array to hold widget refresh specifications (objects )
|
606 |
d7c2f4fe
|
Steve Beaver
|
var ajaxidx = 0;
|
607 |
|
|
var ajaxmutex = false;
|
608 |
67dd6c11
|
Steve Beaver
|
var ajaxcntr = 0;
|
609 |
d7c2f4fe
|
Steve Beaver
|
|
610 |
|
|
// Add a widget refresh object to the array list
|
611 |
|
|
function register_ajax(ws) {
|
612 |
|
|
ajaxspecs.push(ws);
|
613 |
|
|
}
|
614 |
|
|
// ---------------------------------------------------------------------------------------------------
|
615 |
dc58b7b3
|
Sjon Hortensius
|
|
616 |
d7c2f4fe
|
Steve Beaver
|
events.push(function() {
|
617 |
dc58b7b3
|
Sjon Hortensius
|
// Make panels destroyable
|
618 |
aa82505e
|
Phil Davis
|
$('.container .panel-heading a[data-toggle="close"]').each(function (idx, el) {
|
619 |
|
|
$(el).on('click', function(e) {
|
620 |
7f8f8808
|
Sjon Hortensius
|
$(el).parents('.panel').remove();
|
621 |
|
|
updateWidgets();
|
622 |
eae6b58d
|
Stephen Beaver
|
// Submit the form save/display all selected widgets
|
623 |
|
|
$('[name=widgetForm]').submit();
|
624 |
dc58b7b3
|
Sjon Hortensius
|
})
|
625 |
|
|
});
|
626 |
|
|
|
627 |
|
|
// Make panels sortable
|
628 |
477db933
|
Jared Dillard
|
$('.container .col-md-<?=$columnWidth?>').sortable({
|
629 |
dc58b7b3
|
Sjon Hortensius
|
handle: '.panel-heading',
|
630 |
|
|
cursor: 'grabbing',
|
631 |
477db933
|
Jared Dillard
|
connectWith: '.container .col-md-<?=$columnWidth?>',
|
632 |
91d59881
|
NOYB
|
update: function(){
|
633 |
|
|
dirty = true;
|
634 |
|
|
$('#btnstore').removeClass('invisible');
|
635 |
|
|
}
|
636 |
dc58b7b3
|
Sjon Hortensius
|
});
|
637 |
60e27eb0
|
Stephen Beaver
|
|
638 |
|
|
// On clicking a widget to install . .
|
639 |
a508c6e4
|
NOYB
|
$('[id^=btnadd-]').click(function(event) {
|
640 |
f4a15d29
|
Stephen Beaver
|
// Add the widget name to the list of displayed widgets
|
641 |
a508c6e4
|
NOYB
|
updateWidgets(this.id.replace('btnadd-', ''));
|
642 |
60e27eb0
|
Stephen Beaver
|
|
643 |
|
|
// Submit the form save/display all selected widgets
|
644 |
|
|
$('[name=widgetForm]').submit();
|
645 |
|
|
});
|
646 |
|
|
|
647 |
eae6b58d
|
Stephen Beaver
|
|
648 |
e94f260c
|
Stephen Beaver
|
$('#btnstore').click(function() {
|
649 |
|
|
updateWidgets();
|
650 |
|
|
dirty = false;
|
651 |
91d59881
|
NOYB
|
$(this).addClass('invisible');
|
652 |
e94f260c
|
Stephen Beaver
|
$('[name=widgetForm]').submit();
|
653 |
|
|
});
|
654 |
eae6b58d
|
Stephen Beaver
|
|
655 |
|
|
// provide a warning message if the user tries to change page before saving
|
656 |
|
|
$(window).bind('beforeunload', function(){
|
657 |
|
|
if (dirty) {
|
658 |
530c7ccf
|
NOYB
|
return ("<?=gettext('One or more widgets have been moved but have not yet been saved')?>");
|
659 |
eae6b58d
|
Stephen Beaver
|
} else {
|
660 |
|
|
return undefined;
|
661 |
|
|
}
|
662 |
|
|
});
|
663 |
cee365e6
|
Stephen Beaver
|
|
664 |
|
|
// 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)
|
665 |
|
|
// (Sometimes this will cause us to see the icon when we don't need it, but better that than the other way round)
|
666 |
|
|
$('.panel').on('hidden.bs.collapse shown.bs.collapse', function (e) {
|
667 |
|
|
if (e.currentTarget.id != 'widget-available') {
|
668 |
|
|
$('#btnstore').removeClass("invisible");
|
669 |
|
|
}
|
670 |
|
|
});
|
671 |
d7c2f4fe
|
Steve Beaver
|
|
672 |
c0339bdc
|
Steve Beaver
|
// --------------------- Centralized widget refresh system ------------------------------
|
673 |
|
|
ajaxtimeout = false;
|
674 |
|
|
|
675 |
d7c2f4fe
|
Steve Beaver
|
function make_ajax_call(wd) {
|
676 |
|
|
ajaxmutex = true;
|
677 |
|
|
|
678 |
|
|
$.ajax({
|
679 |
|
|
type: 'POST',
|
680 |
|
|
url: wd.url,
|
681 |
|
|
dataType: 'html',
|
682 |
|
|
data: wd.parms,
|
683 |
|
|
|
684 |
|
|
success: function(data){
|
685 |
7a813102
|
Steve Beaver
|
if (data.length > 0 ) {
|
686 |
c0339bdc
|
Steve Beaver
|
// If the session has timed out, display a pop-up
|
687 |
|
|
if (data.indexOf("SESSION_TIMEOUT") === -1) {
|
688 |
|
|
wd.callback(data);
|
689 |
|
|
} else {
|
690 |
|
|
if (ajaxtimeout === false) {
|
691 |
|
|
ajaxtimeout = true;
|
692 |
edd492df
|
Steve Beaver
|
alert("<?=$timeoutmessage?>");
|
693 |
c0339bdc
|
Steve Beaver
|
}
|
694 |
|
|
}
|
695 |
7a813102
|
Steve Beaver
|
}
|
696 |
|
|
|
697 |
d7c2f4fe
|
Steve Beaver
|
ajaxmutex = false;
|
698 |
|
|
},
|
699 |
|
|
|
700 |
|
|
error: function(e){
|
701 |
8bf4cf1f
|
Steve Beaver
|
// alert("Error: " + e);
|
702 |
d7c2f4fe
|
Steve Beaver
|
ajaxmutex = false;
|
703 |
|
|
}
|
704 |
|
|
});
|
705 |
|
|
}
|
706 |
|
|
|
707 |
|
|
// Loop through each AJAX widget refresh object, make the AJAX call and pass the
|
708 |
53547a05
|
Steve Beaver
|
// results back to the widget's callback function
|
709 |
d7c2f4fe
|
Steve Beaver
|
function executewidget() {
|
710 |
|
|
if (ajaxspecs.length > 0) {
|
711 |
67dd6c11
|
Steve Beaver
|
var freq = ajaxspecs[ajaxidx].freq; // widget can specifify it should be called freq times around hte loop
|
712 |
|
|
|
713 |
d7c2f4fe
|
Steve Beaver
|
if (!ajaxmutex) {
|
714 |
e78d5940
|
Steve Beaver
|
if (((ajaxcntr % freq) === 0) && (typeof ajaxspecs[ajaxidx].callback === "function" )) {
|
715 |
67dd6c11
|
Steve Beaver
|
make_ajax_call(ajaxspecs[ajaxidx]);
|
716 |
|
|
}
|
717 |
|
|
|
718 |
|
|
if (++ajaxidx >= ajaxspecs.length) {
|
719 |
|
|
ajaxidx = 0;
|
720 |
|
|
|
721 |
|
|
if (++ajaxcntr >= 4096) {
|
722 |
|
|
ajaxcntr = 0;
|
723 |
|
|
}
|
724 |
|
|
}
|
725 |
d7c2f4fe
|
Steve Beaver
|
}
|
726 |
|
|
|
727 |
8bf4cf1f
|
Steve Beaver
|
setTimeout(function() { executewidget(); }, 1000);
|
728 |
d7c2f4fe
|
Steve Beaver
|
}
|
729 |
|
|
}
|
730 |
|
|
|
731 |
|
|
// Kick it off
|
732 |
|
|
executewidget();
|
733 |
|
|
|
734 |
|
|
//----------------------------------------------------------------------------------------------------
|
735 |
dc58b7b3
|
Sjon Hortensius
|
});
|
736 |
8fd9052f
|
Colin Fleming
|
//]]>
|
737 |
dc58b7b3
|
Sjon Hortensius
|
</script>
|
738 |
d7c2f4fe
|
Steve Beaver
|
|
739 |
41ea4cf3
|
Sjon Hortensius
|
<?php
|
740 |
1180e4f0
|
Sjon Hortensius
|
//build list of javascript include files
|
741 |
aa82505e
|
Phil Davis
|
foreach (glob('widgets/javascript/*.js') as $file) {
|
742 |
d8837d57
|
PiBa-NL
|
$mtime = filemtime("/usr/local/www/{$file}");
|
743 |
|
|
echo '<script src="'.$file.'?v='.$mtime.'"></script>';
|
744 |
aa82505e
|
Phil Davis
|
}
|
745 |
927ea6e1
|
jim-p
|
|
746 |
1c428d53
|
Phil Davis
|
include("foot.inc");
|