Project

General

Profile

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