Project

General

Profile

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