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