Project

General

Profile

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