Project

General

Profile

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