Project

General

Profile

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