Project

General

Profile

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