Project

General

Profile

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