Project

General

Profile

Download (25 KB) Statistics
| Branch: | Tag: | Revision:
1 2cd6010c Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 757733b5 Renato Botelho
	index.php
5 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6 757733b5 Renato Botelho
	Copyright (C) 2004-2012 Scott Ullrich
7
	All rights reserved.
8
9
	Originally part of 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 the
21
	   documentation and/or other materials provided with the distribution.
22
23
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	oR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33 5b237745 Scott Ullrich
*/
34 7ac5a4cb Scott Ullrich
/*
35
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
36
	pfSense_MODULE:	interfaces
37
*/
38 5b237745 Scott Ullrich
39 6b07c15a Matthew Grooms
##|+PRIV
40
##|*IDENT=page-system-login/logout
41 b7ccf315 Erik Fonnesbeck
##|*NAME=System: Login / Logout page / Dashboard
42
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
43 6b07c15a Matthew Grooms
##|*MATCH=index.php*
44
##|-PRIV
45
46 acc5dd59 jim-p
// Turn on buffering to speed up rendering
47 6c07db48 Phil Davis
ini_set('output_buffering', 'true');
48 acc5dd59 jim-p
49
// Start buffering with a cache size of 100000
50
ob_start(null, "1000");
51 880637d2 Scott Ullrich
52 005ac3ca Marcello Coutinho
53 acc5dd59 jim-p
## Load Essential Includes
54
require_once('guiconfig.inc');
55 32e834ff Ermal LUÇI
require_once('functions.inc');
56 acc5dd59 jim-p
require_once('notices.inc');
57 7c8f3711 jim-p
require_once("pkg-utils.inc");
58 acc5dd59 jim-p
59 41b1ff89 Phil Davis
if (isset($_REQUEST['closenotice'])) {
60 005ac3ca Marcello Coutinho
	close_notice($_REQUEST['closenotice']);
61
	echo get_menu_messages();
62
	exit;
63
}
64 6c07db48 Phil Davis
if ($_REQUEST['act'] == 'alias_info_popup' && !preg_match("/\D/", $_REQUEST['aliasid'])) {
65 4e8854c6 Charlie Root
	alias_info_popup($_REQUEST['aliasid']);
66
	exit;
67
}
68 005ac3ca Marcello Coutinho
69 41b1ff89 Phil Davis
if ($g['disablecrashreporter'] != true) {
70 36365f49 Scott Ullrich
	// Check to see if we have a crash report
71 eac584f3 Scott Ullrich
	$x = 0;
72 41b1ff89 Phil Davis
	if (file_exists("/tmp/PHP_errors.log")) {
73 dc43ff1e jim-p
		$total = `/usr/bin/grep -vi warning /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
74 41b1ff89 Phil Davis
		if ($total > 0) {
75 a9ee006d Scott Ullrich
			$x++;
76 41b1ff89 Phil Davis
		}
77 a9ee006d Scott Ullrich
	}
78
	$crash = glob("/var/crash/*");
79 36365f49 Scott Ullrich
	$skip_files = array(".", "..", "minfree", "");
80 41b1ff89 Phil Davis
	if (is_array($crash)) {
81
		foreach ($crash as $c) {
82
			if (!in_array(basename($c), $skip_files)) {
83 36365f49 Scott Ullrich
				$x++;
84 41b1ff89 Phil Davis
			}
85 36365f49 Scott Ullrich
		}
86 41b1ff89 Phil Davis
		if ($x > 0) {
87 a9ee006d Scott Ullrich
			$savemsg = "{$g['product_name']} has detected a crash report or programming bug.  Click <a href='crash_reporter.php'>here</a> for more information.";
88 41b1ff89 Phil Davis
		}
89 104faa07 Scott Ullrich
	}
90
}
91
92 acc5dd59 jim-p
##build list of widgets
93
$directory = "/usr/local/www/widgets/widgets/";
94 6c07db48 Phil Davis
$dirhandle = opendir($directory);
95 acc5dd59 jim-p
$filename = "";
96
$widgetnames = array();
97
$widgetfiles = array();
98
$widgetlist = array();
99
100
while (false !== ($filename = readdir($dirhandle))) {
101
	$periodpos = strpos($filename, ".");
102 2dde9989 Renato Botelho
	/* Ignore files not ending in .php */
103 41b1ff89 Phil Davis
	if (substr($filename, -4, 4) != ".php") {
104 2dde9989 Renato Botelho
		continue;
105 41b1ff89 Phil Davis
	}
106 acc5dd59 jim-p
	$widgetname = substr($filename, 0, $periodpos);
107
	$widgetnames[] = $widgetname;
108 41b1ff89 Phil Davis
	if ($widgetname != "system_information") {
109 acc5dd59 jim-p
		$widgetfiles[] = $filename;
110 41b1ff89 Phil Davis
	}
111 acc5dd59 jim-p
}
112
113
##sort widgets alphabetically
114
sort($widgetfiles);
115
116
##insert the system information widget as first, so as to be displayed first
117
array_unshift($widgetfiles, "system_information.widget.php");
118
119
##if no config entry found, initialize config entry
120
if (!is_array($config['widgets'])) {
121
	$config['widgets'] = array();
122
}
123 d772ac32 Erik Kristensen
124 41b1ff89 Phil Davis
if ($_POST && $_POST['submit']) {
125
	$config['widgets']['sequence'] = $_POST['sequence'];
126 8191b36e Scott Ullrich
127 41b1ff89 Phil Davis
	foreach ($widgetnames as $widget) {
128
		if ($_POST[$widget . '-config']) {
129
			$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
130 8191b36e Scott Ullrich
		}
131
	}
132
133 41b1ff89 Phil Davis
	write_config(gettext("Widget configuration has been changed."));
134
	header("Location: index.php");
135
	exit;
136
}
137
138
## Load Functions Files
139
require_once('includes/functions.inc.php');
140 757733b5 Renato Botelho
141 41b1ff89 Phil Davis
## Check to see if we have a swap space,
142
## if true, display, if false, hide it ...
143
if (file_exists("/usr/sbin/swapinfo")) {
144
	$swapinfo = `/usr/sbin/swapinfo`;
145 6c07db48 Phil Davis
	if (stristr($swapinfo, '%') == true) {
146 41b1ff89 Phil Davis
		$showswap=true;
147 746ca58a Scott Ullrich
	}
148 41b1ff89 Phil Davis
}
149 d772ac32 Erik Kristensen
150 41b1ff89 Phil Davis
## User recently restored his config.
151
## If packages are installed lets resync
152
if (file_exists('/conf/needs_package_sync')) {
153
	if ($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
154
		if ($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
155
			## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
156
			## the package reinstall page. That is about to be done by the boot script anyway.
157
			## The code in fbegin.inc will put up a notice to the user.
158
			if (!platform_booting()) {
159
				header('Location: pkg_mgr_install.php?mode=reinstallall');
160
				exit;
161 6cc843c3 Scott Ullrich
			}
162 1df0159c Erik Kristensen
		}
163 41b1ff89 Phil Davis
	} else {
164
		conf_mount_rw();
165
		@unlink('/conf/needs_package_sync');
166
		conf_mount_ro();
167 1df0159c Erik Kristensen
	}
168 41b1ff89 Phil Davis
}
169 8fecad11 Scott Ullrich
170 41b1ff89 Phil Davis
## If it is the first time webConfigurator has been
171
## accessed since initial install show this stuff.
172
if (file_exists('/conf/trigger_initial_wizard')) {
173 1a1d9a8c Aydın Yakar
	$lang_code    = system_get_language_code();
174
	$lang_codeset = system_get_language_codeset();
175 41b1ff89 Phil Davis
	echo <<<EOF
176 702b324e Scott Ullrich
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
177 b779511e Colin Fleming
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
178 c4b85119 Aydın Yakar
<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang_code" xml:lang="$lang_code">
179 702b324e Scott Ullrich
<head>
180 f99c6a23 Erik Fonnesbeck
	<title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title>
181 1a1d9a8c Aydın Yakar
	<meta http-equiv="Content-Type" content="text/html; charset=$lang_codeset" />
182 702b324e Scott Ullrich
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
183 7bc1b968 Renato Botelho
	<script type="text/javascript">var theme = "{$g['theme']}"</script>
184
	<script type="text/javascript" src="/themes/{$g['theme']}/loader.js"></script>
185 757733b5 Renato Botelho
186 702b324e Scott Ullrich
EOF;
187 1df0159c Erik Kristensen
188 41b1ff89 Phil Davis
	echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
189 5d9f9191 Scott Ullrich
190 41b1ff89 Phil Davis
	if (file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) {
191
		echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
192
	} else {
193
		echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
194 1ca54f04 Scott Ullrich
	}
195
196 41b1ff89 Phil Davis
	echo "<form>\n";
197
	echo "<center>\n";
198
	echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\" alt=\"logo\" /><p>\n";
199
	echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
200 6c07db48 Phil Davis
	echo sprintf(gettext("Welcome to %s!\n"), $g['product_name']) . "<p>";
201 41b1ff89 Phil Davis
	echo gettext("One moment while we start the initial setup wizard.") . "<p>\n";
202
	echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n";
203 6c07db48 Phil Davis
	echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."), $g['product_name']) . "\n";
204 41b1ff89 Phil Davis
	echo "</div>\n";
205
	echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
206
	echo "<script type=\"text/javascript\">\n";
207
	echo "//<![CDATA[\n";
208
	echo "NiftyCheck();\n";
209
	echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
210
	echo "//]]>\n";
211
	echo "</script>\n";
212
	exit;
213
}
214 bf787c0a Scott Ullrich
215 41b1ff89 Phil Davis
216
## Find out whether there's hardware encryption or not
217
unset($hwcrypto);
218
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
219
if ($fd) {
220
	while (!feof($fd)) {
221
		$dmesgl = fgets($fd);
222
		if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches) or
223
		    preg_match("/.*(VIA Padlock)/", $dmesgl, $matches) or
224
		    preg_match("/^safe.: (\w.*)/", $dmesgl, $matches) or
225
		    preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches) or
226
		    preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches) or
227
		    preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches) or
228 f2265d88 Chris Buechler
		    preg_match("/^aesni.: <(.*?)>/", $dmesgl, $matches)) {
229 41b1ff89 Phil Davis
			$hwcrypto = $matches[1];
230
			break;
231 5b237745 Scott Ullrich
		}
232
	}
233 41b1ff89 Phil Davis
	fclose($fd);
234
}
235 45ee90ed Matthew Grooms
236 7abf7db5 Scott Dale
##build widget saved list information
237 019a94df Scott Dale
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
238
	$pconfig['sequence'] = $config['widgets']['sequence'];
239 757733b5 Renato Botelho
240 bf5ad142 Scott Dale
	$widgetlist = $pconfig['sequence'];
241
	$colpos = array();
242
	$savedwidgetfiles = array();
243
	$widgetname = "";
244 6c07db48 Phil Davis
	$widgetlist = explode(",", $widgetlist);
245 757733b5 Renato Botelho
246 019a94df Scott Dale
	##read the widget position and display information
247 41b1ff89 Phil Davis
	foreach ($widgetlist as $widget) {
248 757733b5 Renato Botelho
		$dashpos = strpos($widget, "-");
249 bf5ad142 Scott Dale
		$widgetname = substr($widget, 0, $dashpos);
250 757733b5 Renato Botelho
		$colposition = strpos($widget, ":");
251 bf5ad142 Scott Dale
		$displayposition = strrpos($widget, ":");
252 6c07db48 Phil Davis
		$colpos[] = substr($widget, $colposition + 1, $displayposition - $colposition - 1);
253
		$displayarray[] = substr($widget, $displayposition + 1);
254 bf5ad142 Scott Dale
		$savedwidgetfiles[] = $widgetname . ".widget.php";
255 1db766df Scott Dale
	}
256 757733b5 Renato Botelho
257 7abf7db5 Scott Dale
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
258 41b1ff89 Phil Davis
	foreach ($widgetfiles as $defaultwidgets) {
259
		if (!in_array($defaultwidgets, $savedwidgetfiles)) {
260 757733b5 Renato Botelho
			$savedwidgetfiles[] = $defaultwidgets;
261
		}
262
	}
263
264 019a94df Scott Dale
	##find custom configurations of a particular widget and load its info to $pconfig
265 41b1ff89 Phil Davis
	foreach ($widgetnames as $widget) {
266
		if ($config['widgets'][$widget . '-config']) {
267 757733b5 Renato Botelho
			$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
268
		}
269
	}
270
271
	$widgetlist = $savedwidgetfiles;
272 41b1ff89 Phil Davis
} else {
273 483e6de8 Scott Ullrich
	// no saved widget sequence found, build default list.
274 8b06c9ff Scott Dale
	$widgetlist = $widgetfiles;
275 3e4e94ce Scott Dale
}
276
277 019a94df Scott Dale
##build list of php include files
278 8b06c9ff Scott Dale
$phpincludefiles = array();
279
$directory = "/usr/local/www/widgets/include/";
280 6c07db48 Phil Davis
$dirhandle = opendir($directory);
281 bf5ad142 Scott Dale
$filename = "";
282
while (false !== ($filename = readdir($dirhandle))) {
283
	$phpincludefiles[] = $filename;
284
}
285 41b1ff89 Phil Davis
foreach ($phpincludefiles as $includename) {
286
	if (!stristr($includename, ".inc")) {
287 757733b5 Renato Botelho
		continue;
288 41b1ff89 Phil Davis
	}
289 bf5ad142 Scott Dale
	include($directory . $includename);
290
}
291 81db9b7b Scott Dale
292 019a94df Scott Dale
##begin AJAX
293 1db766df Scott Dale
$jscriptstr = <<<EOD
294 b779511e Colin Fleming
<script type="text/javascript">
295
//<![CDATA[
296 65d4de2e Scott Dale
297 c69c58e2 Vinicius Coque
function widgetAjax(widget) {
298 34eac803 Scott Dale
	uri = "widgets/widgets/" + widget + ".widget.php";
299
	var opt = {
300 757733b5 Renato Botelho
		// Use GET
301
		type: 'get',
302
		async: true,
303
		// Handle 404
304
		statusCode: {
305
		404: function(t) {
306
			alert('Error 404: location "' + t.statusText + '" was not found.');
307
		}
308
		},
309
		// Handle other errors
310
		error: function(t) {
311
			alert('Error ' + t.status + ' -- ' + t.statusText);
312
		},
313 b1678e2d Vinicius Coque
		success: function(data) {
314 f63932ca Vinicius Coque
			widget2 = '#' + widget + "-loader";
315 41b1ff89 Phil Davis
			jQuery(widget2).fadeOut(1000,function() {
316 f63932ca Vinicius Coque
				jQuery('#' + widget).show();
317
			});
318 b1678e2d Vinicius Coque
			jQuery('#' + widget).html(data);
319 757733b5 Renato Botelho
		}
320 34eac803 Scott Dale
	}
321 b1678e2d Vinicius Coque
	jQuery.ajax(uri, opt);
322 34eac803 Scott Dale
}
323 65d4de2e Scott Dale
324
325 41b1ff89 Phil Davis
function addWidget(selectedDiv) {
326 c69c58e2 Vinicius Coque
	selectedDiv2 = '#' + selectedDiv + "-container";
327
	if (jQuery(selectedDiv2).css('display') != "none")
328 5eafc6de Scott Dale
	{
329 c69c58e2 Vinicius Coque
		jQuery(selectedDiv2).effect('shake',{times: 2}, 100);
330 5eafc6de Scott Dale
	}
331
	else
332
	{
333 c69c58e2 Vinicius Coque
		jQuery(selectedDiv2).show('blind');
334 65d4de2e Scott Dale
		widgetAjax(selectedDiv);
335
		selectIntLink = selectedDiv2 + "-input";
336 c69c58e2 Vinicius Coque
		jQuery(selectIntLink).val("show");
337 5eafc6de Scott Dale
		showSave();
338
	}
339 bf5ad142 Scott Dale
}
340 1db766df Scott Dale
341 41b1ff89 Phil Davis
function configureWidget(selectedDiv) {
342 c69c58e2 Vinicius Coque
	selectIntLink = '#' + selectedDiv + "-settings";
343 41b1ff89 Phil Davis
	if (jQuery(selectIntLink).css('display') == "none") {
344 c69c58e2 Vinicius Coque
		jQuery(selectIntLink).show();
345 41b1ff89 Phil Davis
	} else {
346 c69c58e2 Vinicius Coque
		jQuery(selectIntLink).hide();
347 41b1ff89 Phil Davis
	}
348 25d2d037 Scott Dale
}
349
350 6c07db48 Phil Davis
function showWidget(selectedDiv, swapButtons) {
351 65d4de2e Scott Dale
	//appear element
352 757733b5 Renato Botelho
	jQuery('#' + selectedDiv).show('blind');
353
	showSave();
354 c69c58e2 Vinicius Coque
	d = document;
355 41b1ff89 Phil Davis
	if (swapButtons) {
356 757733b5 Renato Botelho
		selectIntLink = selectedDiv + "-min";
357 1db766df Scott Dale
		textlink = d.getElementById(selectIntLink);
358
		textlink.style.display = "inline";
359 757733b5 Renato Botelho
360
361
		selectIntLink = selectedDiv + "-open";
362 1db766df Scott Dale
		textlink = d.getElementById(selectIntLink);
363
		textlink.style.display = "none";
364 bf5ad142 Scott Dale
365 757733b5 Renato Botelho
	}
366 65d4de2e Scott Dale
	selectIntLink = selectedDiv + "-container-input";
367 bf5ad142 Scott Dale
	textlink = d.getElementById(selectIntLink);
368 c69c58e2 Vinicius Coque
	textlink.value = "show";
369 757733b5 Renato Botelho
370 f5cfdc98 Scott Dale
}
371 c69c58e2 Vinicius Coque
372 6c07db48 Phil Davis
function minimizeWidget(selectedDiv, swapButtons) {
373 1db766df Scott Dale
	//fade element
374 757733b5 Renato Botelho
	jQuery('#' + selectedDiv).hide('blind');
375
	showSave();
376 c69c58e2 Vinicius Coque
	d = document;
377 41b1ff89 Phil Davis
	if (swapButtons) {
378 757733b5 Renato Botelho
		selectIntLink = selectedDiv + "-open";
379 1db766df Scott Dale
		textlink = d.getElementById(selectIntLink);
380 757733b5 Renato Botelho
		textlink.style.display = "inline";
381
382
		selectIntLink = selectedDiv + "-min";
383 1db766df Scott Dale
		textlink = d.getElementById(selectIntLink);
384
		textlink.style.display = "none";
385 757733b5 Renato Botelho
	}
386 65d4de2e Scott Dale
	selectIntLink = selectedDiv + "-container-input";
387 bf5ad142 Scott Dale
	textlink = d.getElementById(selectIntLink);
388 757733b5 Renato Botelho
	textlink.value = "hide";
389
390 1db766df Scott Dale
}
391
392 41b1ff89 Phil Davis
function closeWidget(selectedDiv) {
393 bf5ad142 Scott Dale
	showSave();
394 c69c58e2 Vinicius Coque
	selectedDiv2 = "#" + selectedDiv + "-container";
395
	jQuery(selectedDiv2).hide('blind');
396
	selectIntLink = "#" + selectedDiv + "-container-input";
397
	jQuery(selectIntLink).val("close");
398 1db766df Scott Dale
}
399
400 41b1ff89 Phil Davis
function showSave() {
401 bf5ad142 Scott Dale
	d = document;
402
	selectIntLink = "submit";
403
	textlink = d.getElementById(selectIntLink);
404 c69c58e2 Vinicius Coque
	textlink.style.display = "inline";
405 1db766df Scott Dale
}
406
407 41b1ff89 Phil Davis
function updatePref() {
408 bf5ad142 Scott Dale
	var widgets = document.getElementsByClassName('widgetdiv');
409
	var widgetSequence = "";
410 c69c58e2 Vinicius Coque
	var firstprint = false;
411 bf5ad142 Scott Dale
	d = document;
412 6c07db48 Phil Davis
	for (i = 0; i < widgets.length; i++) {
413 41b1ff89 Phil Davis
		if (firstprint) {
414 bf5ad142 Scott Dale
			widgetSequence += ",";
415 41b1ff89 Phil Davis
		}
416 bf5ad142 Scott Dale
		var widget = widgets[i].id;
417
		widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
418
		widget = widget + "-input";
419
		textlink = d.getElementById(widget).value;
420
		widgetSequence += textlink;
421 c69c58e2 Vinicius Coque
		firstprint = true;
422 bf5ad142 Scott Dale
	}
423
	selectLink = "sequence";
424
	textlink = d.getElementById(selectLink);
425
	textlink.value = widgetSequence;
426 c69c58e2 Vinicius Coque
	return true;
427 bf5ad142 Scott Dale
}
428 1db766df Scott Dale
429 41b1ff89 Phil Davis
function hideAllWidgets() {
430 6c07db48 Phil Davis
	jQuery('#niftyOutter').fadeTo('slow', 0.2);
431 5eafc6de Scott Dale
}
432
433 41b1ff89 Phil Davis
function showAllWidgets() {
434 6c07db48 Phil Davis
	jQuery('#niftyOutter').fadeTo('slow', 1.0);
435 5eafc6de Scott Dale
}
436
437 b9b45ddb Scott Dale
438 41b1ff89 Phil Davis
function changeTabDIV(selectedDiv) {
439 b9b45ddb Scott Dale
	var dashpos = selectedDiv.indexOf("-");
440 6c07db48 Phil Davis
	var tabclass = selectedDiv.substring(0, dashpos);
441 b9b45ddb Scott Dale
	d = document;
442
443
	//get deactive tabs first
444 757733b5 Renato Botelho
	tabclass = tabclass + "-class-tabdeactive";
445 b9b45ddb Scott Dale
	var tabs = document.getElementsByClassName(tabclass);
446
	var incTabSelected = selectedDiv + "-deactive";
447 6c07db48 Phil Davis
	for (i = 0; i < tabs.length; i++) {
448 b9b45ddb Scott Dale
		var tab = tabs[i].id;
449
		dashpos = tab.lastIndexOf("-");
450 6c07db48 Phil Davis
		var tab2 = tab.substring(0, dashpos) + "-deactive";
451 41b1ff89 Phil Davis
		if (tab2 == incTabSelected) {
452 b9b45ddb Scott Dale
			tablink = d.getElementById(tab2);
453
			tablink.style.display = "none";
454 6c07db48 Phil Davis
			tab2 = tab.substring(0, dashpos) + "-active";
455 b9b45ddb Scott Dale
			tablink = d.getElementById(tab2);
456
			tablink.style.display = "table-cell";
457 c69c58e2 Vinicius Coque
458 b9b45ddb Scott Dale
			//now show main div associated with link clicked
459
			tabmain = d.getElementById(selectedDiv);
460
			tabmain.style.display = "block";
461
		}
462
		else
463 c69c58e2 Vinicius Coque
		{
464 6c07db48 Phil Davis
			tab2 = tab.substring(0, dashpos) + "-deactive";
465 b9b45ddb Scott Dale
			tablink = d.getElementById(tab2);
466
			tablink.style.display = "table-cell";
467 6c07db48 Phil Davis
			tab2 = tab.substring(0, dashpos) + "-active";
468 b9b45ddb Scott Dale
			tablink = d.getElementById(tab2);
469 c69c58e2 Vinicius Coque
			tablink.style.display = "none";
470
471 b9b45ddb Scott Dale
			//hide sections we don't want to see
472 6c07db48 Phil Davis
			tab2 = tab.substring(0, dashpos);
473 b9b45ddb Scott Dale
			tabmain = d.getElementById(tab2);
474
			tabmain.style.display = "none";
475 c69c58e2 Vinicius Coque
476 b9b45ddb Scott Dale
		}
477 c69c58e2 Vinicius Coque
	}
478 b9b45ddb Scott Dale
}
479 b779511e Colin Fleming
//]]>
480 f5cfdc98 Scott Dale
</script>
481
EOD;
482 b779511e Colin Fleming
483 3e4e94ce Scott Dale
484 1db766df Scott Dale
## Set Page Title and Include Header
485 a6e0e07b Scott Ullrich
$pgtitle = array(gettext("Status: Dashboard"));
486 1db766df Scott Dale
include("head.inc");
487 f6f6947e Scott Ullrich
488 a8726a3d Scott Ullrich
?>
489 8dbbc3ed Scott Ullrich
490 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
491 927ea6e1 jim-p
492 b779511e Colin Fleming
<script type="text/javascript">
493
//<![CDATA[
494 6c07db48 Phil Davis
columns = ['col1', 'col2', 'col3', 'col4', 'col5', 'col6', 'col7', 'col8', 'col9', 'col10'];
495 b779511e Colin Fleming
//]]>
496 670fe849 Scott Ullrich
</script>
497 1db766df Scott Dale
498 5ffe7500 Scott Ullrich
<?php
499
include("fbegin.inc");
500 f5cfdc98 Scott Dale
echo $jscriptstr;
501 41b1ff89 Phil Davis
if (!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo")) {
502
	echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\" alt=\"big logo\" /></center><br />";
503
}
504 fca795f8 Scott Ullrich
505 7c8f3711 jim-p
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
506 41b1ff89 Phil Davis
if (!verify_all_package_servers()) {
507 7c8f3711 jim-p
	print_info_box(package_server_mismatch_message());
508 41b1ff89 Phil Davis
}
509 7c8f3711 jim-p
510 41b1ff89 Phil Davis
if ($savemsg) {
511 757733b5 Renato Botelho
	print_info_box($savemsg);
512 41b1ff89 Phil Davis
}
513 fca795f8 Scott Ullrich
514 810a11bc Scott Ullrich
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
515 c69c58e2 Vinicius Coque
516 0682e26b Colin Smith
?>
517 1db766df Scott Dale
<div id="widgetcontainer" style="display:none">
518 41b1ff89 Phil Davis
	<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
519
		$widgetfiles_add = $widgetfiles;
520
		sort($widgetfiles_add);
521
		foreach ($widgetfiles_add as $widget) {
522
			if (!stristr($widget, "widget.php")) {
523
				continue;
524
			}
525
526
			$periodpos = strpos($widget, ".");
527
			$widgetname = substr($widget, 0, $periodpos);
528
			$nicename = $widgetname;
529
			$nicename = str_replace("_", " ", $nicename);
530
			//make the title look nice
531
			$nicename = ucwords($nicename);
532
533
			$widgettitle = $widgetname . "_title";
534
			$widgettitlelink = $widgetname . "_title_link";
535
			if ($$widgettitle != "") {
536
				//echo widget title
537
				?>
538
				<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
539
				<u><?php echo $$widgettitle; ?></u></span><br />
540
				<?php
541
			} else {
542
				?>
543
				<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
544
				<u><?php echo $nicename; ?></u></span><br /><?php
545 1db766df Scott Dale
			}
546 41b1ff89 Phil Davis
		}
547 f5cfdc98 Scott Dale
		?>
548 1db766df Scott Dale
		</p>
549
	</div>
550
</div>
551
552 d72fc17b Scott Dale
<div id="welcomecontainer" style="display:none">
553 41b1ff89 Phil Davis
	<div id="welcome-container">
554
		<div style="float:left;width:100%;padding: 2px">
555
			<h1><?=gettext("Welcome to the Dashboard page"); ?>!</h1>
556
		</div>
557
		<div onclick="domTT_close(this);showAllWidgets();" style="width:87%; position: absolute; cursor:pointer; padding: 10px;" >
558
			<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" alt="close" style="float:right" />
559
		</div>
560
		<div style="clear:both;">
561
		</div>
562
		<p>
563
		<?=gettext("This page allows you to customize the information you want to be displayed!");?><br />
564
		<?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="plus" /> <?=gettext("icon to add widgets.");?><br />
565
		<br />
566
		<?=gettext("You can move any widget around by clicking and dragging the title.");?>
567
		</p>
568 d72fc17b Scott Dale
	</div>
569
</div>
570
571 927ea6e1 jim-p
<form action="index.php" method="post">
572 41b1ff89 Phil Davis
	<input type="hidden" value="" name="sequence" id="sequence" />
573
	<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="<?=gettext("Click here to add widgets"); ?>" style="cursor: pointer;" onmouseup="domTT_activate(this, event, 'content', document.getElementById('content1'), 'type', 'velcro', 'delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
574 5eafc6de Scott Dale
575 6c07db48 Phil Davis
	<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_info_pkg.gif" alt="<?=gettext("Click here for help"); ?>" style="cursor: help;" onmouseup="hideAllWidgets();domTT_activate(this, event, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '', 'delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
576 5eafc6de Scott Dale
577 bf5ad142 Scott Dale
&nbsp;&nbsp;&nbsp;
578 41b1ff89 Phil Davis
	<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
579 927ea6e1 jim-p
</form>
580 08a97fe0 Charlie Marshall
<!-- fakeClass contains no CSS but is used as an identifier in theme pfsense_ng_fs - loader.js -->
581 bb38e8e5 Charlie Marshall
<div id="niftyOutter" class="fakeClass">
582 1db766df Scott Dale
	<?php
583
	$totalwidgets = count($widgetfiles);
584 c9cfb807 Scott Dale
	$halftotal = $totalwidgets / 2 - 2;
585
	$widgetcounter = 0;
586 8b06c9ff Scott Dale
	$directory = "/usr/local/www/widgets/widgets/";
587 1db766df Scott Dale
	$printed = false;
588
	$firstprint = false;
589 757733b5 Renato Botelho
	?>
590 cafb7dfe Charlie Marshall
	<div id="col1" style="float:left;width:49%;padding-bottom:40px" class="ui-sortable">
591 757733b5 Renato Botelho
	<?php
592
593 41b1ff89 Phil Davis
	foreach ($widgetlist as $widget) {
594 757733b5 Renato Botelho
595 41b1ff89 Phil Davis
		if (!stristr($widget, "widget.php")) {
596
			continue;
597
		}
598 1db766df Scott Dale
		$periodpos = strpos($widget, ".");
599 757733b5 Renato Botelho
		$widgetname = substr($widget, 0, $periodpos);
600 41b1ff89 Phil Davis
		if ($widgetname != "") {
601 3f304727 Scott Dale
			$nicename = $widgetname;
602
			$nicename = str_replace("_", " ", $nicename);
603 757733b5 Renato Botelho
604 3f304727 Scott Dale
			//make the title look nice
605
			$nicename = ucwords($nicename);
606 8b06c9ff Scott Dale
		}
607 757733b5 Renato Botelho
608 41b1ff89 Phil Davis
		if ($config['widgets'] && $pconfig['sequence'] != "") {
609
			switch ($displayarray[$widgetcounter]) {
610 01da41cf Bill Marquette
				case "show":
611 8b06c9ff Scott Dale
					$divdisplay = "block";
612
					$display = "block";
613 757733b5 Renato Botelho
					$inputdisplay = "show";
614 7abf7db5 Scott Dale
					$showWidget = "none";
615 8b06c9ff Scott Dale
					$mindiv = "inline";
616 01da41cf Bill Marquette
					break;
617
				case "hide":
618 8b06c9ff Scott Dale
					$divdisplay = "block";
619 01da41cf Bill Marquette
					$display = "none";
620 757733b5 Renato Botelho
					$inputdisplay = "hide";
621 01da41cf Bill Marquette
					$showWidget = "inline";
622
					$mindiv = "none";
623 a6efee26 jim-p
					break;
624 01da41cf Bill Marquette
				case "close":
625
					$divdisplay = "none";
626 8b06c9ff Scott Dale
					$display = "block";
627 757733b5 Renato Botelho
					$inputdisplay = "close";
628 7abf7db5 Scott Dale
					$showWidget = "none";
629 8b06c9ff Scott Dale
					$mindiv = "inline";
630 01da41cf Bill Marquette
					break;
631
				default:
632 8b06c9ff Scott Dale
					$divdisplay = "none";
633
					$display = "block";
634 01da41cf Bill Marquette
					$inputdisplay = "none";
635 7abf7db5 Scott Dale
					$showWidget = "none";
636 8b06c9ff Scott Dale
					$mindiv = "inline";
637 01da41cf Bill Marquette
					break;
638
			}
639
		} else {
640 41b1ff89 Phil Davis
			if ($firstprint == false) {
641 01da41cf Bill Marquette
				$divdisplay = "block";
642
				$display = "block";
643
				$inputdisplay = "show";
644
				$showWidget = "none";
645
				$mindiv = "inline";
646
				$firstprint = true;
647
			} else {
648
				switch ($widget) {
649
					case "interfaces.widget.php":
650
					case "traffic_graphs.widget.php":
651
						$divdisplay = "block";
652
						$display = "block";
653
						$inputdisplay = "show";
654
						$showWidget = "none";
655
						$mindiv = "inline";
656
						break;
657
					default:
658
						$divdisplay = "none";
659
						$display = "block";
660
						$inputdisplay = "close";
661
						$showWidget = "none";
662
						$mindiv = "inline";
663
						break;
664 8b06c9ff Scott Dale
				}
665 775d112b Scott Dale
			}
666 bf5ad142 Scott Dale
		}
667 757733b5 Renato Botelho
668 41b1ff89 Phil Davis
		if (substr($g['theme'], -3) != "_fs") {
669
			if ($config['widgets'] && $pconfig['sequence'] != "") {
670
				if ($colpos[$widgetcounter] == "col2" && $printed == false) {
671 cafb7dfe Charlie Marshall
					$printed = true;
672
					?>
673
					</div>
674
					<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
675
					<?php
676
				}
677 41b1ff89 Phil Davis
			} else if ($widgetcounter >= $halftotal && $printed == false) {
678 bf5ad142 Scott Dale
				$printed = true;
679
				?>
680
				</div>
681 cafb7dfe Charlie Marshall
				<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
682 bf5ad142 Scott Dale
				<?php
683
			}
684 41b1ff89 Phil Davis
		} else {
685 cafb7dfe Charlie Marshall
			if ($config['widgets'] && $pconfig['sequence'] != "") {
686 41b1ff89 Phil Davis
				if ($colpos[$widgetcounter] == "col2" && $printed == false) {
687 cafb7dfe Charlie Marshall
					$printed = true;
688
					?>
689
					</div>
690
					<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
691
					<?php
692 41b1ff89 Phil Davis
				} else { ?>
693 07130afe ayvis
					<script type="text/javascript">
694 1b244d38 Colin Fleming
					//<![CDATA[
695 cafb7dfe Charlie Marshall
					var colpos = "<?=$colpos[$widgetcounter]?>";
696 1b244d38 Colin Fleming
					createColumn(colpos);
697
					//]]>
698 cafb7dfe Charlie Marshall
					</script>
699
				<?php }
700 41b1ff89 Phil Davis
			}
701 bf5ad142 Scott Dale
		}
702 757733b5 Renato Botelho
703 16f556c5 Scott Dale
		?>
704 1db766df Scott Dale
		<div style="clear:both;"></div>
705 41b1ff89 Phil Davis
		<div id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
706 b779511e Colin Fleming
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input" />
707 3da0d006 Scott Dale
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
708 1db766df Scott Dale
				<div style="float:left;">
709 757733b5 Renato Botelho
					<?php
710
711 16f556c5 Scott Dale
					$widgettitle = $widgetname . "_title";
712
					$widgettitlelink = $widgetname . "_title_link";
713 41b1ff89 Phil Davis
					if ($$widgettitle != "") {
714 16f556c5 Scott Dale
						//only show link if defined
715 757733b5 Renato Botelho
						if ($$widgettitlelink != "") {?>
716 b779511e Colin Fleming
						<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
717 16f556c5 Scott Dale
						<?php }
718 41b1ff89 Phil Davis
						//echo widget title
719
						echo $$widgettitle;
720 16f556c5 Scott Dale
						if ($$widgettitlelink != "") { ?>
721 757733b5 Renato Botelho
						</span></u>
722 16f556c5 Scott Dale
						<?php }
723 41b1ff89 Phil Davis
					} else {
724 757733b5 Renato Botelho
						if ($$widgettitlelink != "") {?>
725 b779511e Colin Fleming
						<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
726 16f556c5 Scott Dale
						<?php }
727
						echo $nicename;
728 41b1ff89 Phil Davis
						if ($$widgettitlelink != "") { ?>
729 757733b5 Renato Botelho
						</span></u>
730 16f556c5 Scott Dale
						<?php }
731
					}
732
					?>
733 1db766df Scott Dale
				</div>
734 757733b5 Renato Botelho
				<div align="right" style="float:right;">
735 b779511e Colin Fleming
					<div id="<?php echo $widgetname;?>-configure" onclick='return configureWidget("<?php echo $widgetname;?>")' style="display:none; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_configure.gif" alt="configure" /></div>
736 6c07db48 Phil Davis
					<div id="<?php echo $widgetname;?>-open" onclick='return showWidget("<?php echo $widgetname;?>", true)' style="display:<?php echo $showWidget;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" alt="open" /></div>
737
					<div id="<?php echo $widgetname;?>-min" onclick='return minimizeWidget("<?php echo $widgetname;?>", true)' style="display:<?php echo $mindiv;?>; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif" alt="minimize" /></div>
738
					<div id="<?php echo $widgetname;?>-close" onclick='return closeWidget("<?php echo $widgetname;?>", true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" alt="close" /></div>
739 1db766df Scott Dale
				</div>
740
				<div style="clear:both;"></div>
741
			</div>
742 3da0d006 Scott Dale
			<?php if ($divdisplay != "block") { ?>
743 b779511e Colin Fleming
			<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;" align="center">
744
				<br />
745
					<img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width="25" height="25" alt="<?=gettext("Loading selected widget"); ?>..." />
746
				<br />
747 f9df0509 Charlie Marshall
			</div> <?php $display = "none"; } ?>
748 757733b5 Renato Botelho
			<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">
749
				<?php
750 41b1ff89 Phil Davis
					if ($divdisplay == "block") {
751 b9b45ddb Scott Dale
						include($directory . $widget);
752 757733b5 Renato Botelho
					}
753
				?>
754 1db766df Scott Dale
			</div>
755
			<div style="clear:both;"></div>
756
		</div>
757 757733b5 Renato Botelho
		<?php
758 1db766df Scott Dale
	$widgetcounter++;
759 757733b5 Renato Botelho
760
	}//end foreach
761
	?>
762 8b06c9ff Scott Dale
		</div>
763 1db766df Scott Dale
	<div style="clear:both;"></div>
764 d772ac32 Erik Kristensen
</div>
765 561d55ff Erik Kristensen
766 d772ac32 Erik Kristensen
<?php include("fend.inc"); ?>
767 757733b5 Renato Botelho
768 7f1f5492 Scott Ullrich
<script type="text/javascript">
769 b779511e Colin Fleming
//<![CDATA[
770 c69c58e2 Vinicius Coque
	jQuery(document).ready(function(in_event)
771 757733b5 Renato Botelho
	{
772 cafb7dfe Charlie Marshall
			jQuery('.ui-sortable').sortable({connectWith: '.ui-sortable', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
773 c69c58e2 Vinicius Coque
774 6c07db48 Phil Davis
	<?php if (!$config['widgets'] && $pconfig['sequence'] != "") { ?>
775 757733b5 Renato Botelho
			hideAllWidgets();
776 6c07db48 Phil Davis
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '', 'delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');
777 d72fc17b Scott Dale
	<?php } ?>
778 8bf02470 Bill Marquette
	});
779 b779511e Colin Fleming
//]]>
780 838fa668 Scott Ullrich
</script>
781
<?php
782 1db766df Scott Dale
	//build list of javascript include files
783 775d112b Scott Dale
	$jsincludefiles = array();
784 1db766df Scott Dale
	$directory = "widgets/javascript/";
785 6c07db48 Phil Davis
	$dirhandle = opendir($directory);
786 1db766df Scott Dale
	$filename = "";
787
	while (false !== ($filename = readdir($dirhandle))) {
788 757733b5 Renato Botelho
		$jsincludefiles[] = $filename;
789 1db766df Scott Dale
	}
790 41b1ff89 Phil Davis
	foreach ($jsincludefiles as $jsincludename) {
791
		if (!preg_match('/\.js$/', $jsincludename)) {
792 838fa668 Scott Ullrich
			continue;
793 41b1ff89 Phil Davis
		}
794 757733b5 Renato Botelho
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";
795 1db766df Scott Dale
	}
796 838fa668 Scott Ullrich
?>
797 927ea6e1 jim-p
798 5b237745 Scott Ullrich
</body>
799 8760cbbc Ermal
</html>