Project

General

Profile

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