Project

General

Profile

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