Project

General

Profile

Download (22.5 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 1df0159c Erik Kristensen
	## Load Essential Includes
46
	require_once('guiconfig.inc');
47
	require_once('notices.inc');
48 d772ac32 Erik Kristensen
49 8191b36e Scott Ullrich
	if ($_POST && $_POST['submit']) {
50
		$config['widgets']['sequence'] = $_POST['sequence'];
51
52
		foreach ($widgetnames as $widget){
53
			if ($_POST[$widget . '-config']){
54
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
55
			}
56
		}
57
58
		write_config("Widget configuration has been changed.");
59
		header("Location: index.php");
60
		exit;
61
	}
62
63 1df0159c Erik Kristensen
	## Load Functions Files
64
	require_once('includes/functions.inc.php');
65 65d4de2e Scott Dale
	
66 1df0159c Erik Kristensen
	## Check to see if we have a swap space,
67
	## if true, display, if false, hide it ...
68 746ca58a Scott Ullrich
	if(file_exists("/usr/sbin/swapinfo")) {
69
		$swapinfo = `/usr/sbin/swapinfo`;
70
		if(stristr($swapinfo,'%') == true) $showswap=true;
71
	}
72 d772ac32 Erik Kristensen
73 f3e2c205 Scott Ullrich
74 1df0159c Erik Kristensen
	## User recently restored his config.
75
	## If packages are installed lets resync
76 1abb04ea Scott Ullrich
	if(file_exists('/conf/needs_package_sync')) {
77 1df0159c Erik Kristensen
		if($config['installedpackages'] <> '') {
78
			conf_mount_rw();
79 1abb04ea Scott Ullrich
			unlink('/conf/needs_package_sync');
80 6cc843c3 Scott Ullrich
			conf_mount_ro();
81
			if($g['platform'] == "pfSense") {
82
				header('Location: pkg_mgr_install.php?mode=reinstallall');
83
				exit;
84
			}
85 1df0159c Erik Kristensen
		}
86
	}
87 8fecad11 Scott Ullrich
88 1df0159c Erik Kristensen
89 709cc6e0 Bill Marquette
	## If it is the first time webConfigurator has been
90 1df0159c Erik Kristensen
	## accessed since initial install show this stuff.
91 1abb04ea Scott Ullrich
	if(file_exists('/conf/trigger_initial_wizard')) {
92 1df0159c Erik Kristensen
93 702b324e Scott Ullrich
94
		echo <<<EOF
95
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
96
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
97
<html>
98
<head>
99
	<title>pfSense.local - pfSense first time setup</title>
100
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
101
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
102
	<script type="text/javascript">var theme = "nervecenter"</script>
103
	<script type="text/javascript" src="/themes/nervecenter/loader.js"></script>
104
		
105
EOF;
106 1df0159c Erik Kristensen
107
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
108 5d9f9191 Scott Ullrich
109
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
110
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
111
		else 
112
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
113
114 1df0159c Erik Kristensen
		echo "<form>\n";
115
		echo "<center>\n";
116
		echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
117
		echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
118 36d0358b Scott Ullrich
		echo "Welcome to {$g['product_name']}!<p>\n";
119 1df0159c Erik Kristensen
		echo "One moment while we start the initial setup wizard.<p>\n";
120 42b8d9fb Chris Buechler
		echo "Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.<p>\n";
121
		echo "To bypass the wizard, click on the {$g['product_name']} logo on the initial page.\n";
122 1df0159c Erik Kristensen
		echo "</div>\n";
123
		echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
124
		echo "<script type=\"text/javascript\">\n";
125
		echo "NiftyCheck();\n";
126 702b324e Scott Ullrich
		echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
127 1df0159c Erik Kristensen
		echo "</script>\n";
128 1ca54f04 Scott Ullrich
		exit;
129
	}
130
131 bf787c0a Scott Ullrich
132 1df0159c Erik Kristensen
	## Find out whether there's hardware encryption or not
133
	unset($hwcrypto);
134
	$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
135
	if ($fd) {
136
		while (!feof($fd)) {
137
			$dmesgl = fgets($fd);
138 0f558379 Chris Buechler
			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)) {
139 1df0159c Erik Kristensen
				$hwcrypto = $matches[1];
140
				break;
141
			}
142 5b237745 Scott Ullrich
		}
143 1df0159c Erik Kristensen
		fclose($fd);
144 5b237745 Scott Ullrich
	}
145 45ee90ed Matthew Grooms
146 019a94df Scott Dale
##build list of widgets
147 8b06c9ff Scott Dale
$directory = "/usr/local/www/widgets/widgets/";
148 bf5ad142 Scott Dale
$dirhandle  = opendir($directory);
149
$filename = "";
150 8b06c9ff Scott Dale
$widgetnames = array();
151 bf5ad142 Scott Dale
$widgetfiles = array();
152 f617ecbd Scott Dale
$widgetlist = array();
153 bf5ad142 Scott Dale
while (false !== ($filename = readdir($dirhandle))) {
154
	$periodpos = strpos($filename, ".");
155 775d112b Scott Dale
	$widgetname = substr($filename, 0, $periodpos);
156
	$widgetnames[] = $widgetname;
157
	if ($widgetname != "system_information")
158 bf5ad142 Scott Dale
		$widgetfiles[] = $filename;   		
159
}
160 019a94df Scott Dale
161
162
##sort widgets alphabetically
163 bf5ad142 Scott Dale
sort($widgetfiles);
164 019a94df Scott Dale
165
##insert the system information widget as first, so as to be displayed first
166 775d112b Scott Dale
array_unshift($widgetfiles, "system_information.widget.php");
167
168 019a94df Scott Dale
##if no config entry found, initialize config entry
169 bf5ad142 Scott Dale
if (!is_array($config['widgets'])) {
170
	$config['widgets'] = array();
171
}
172
173 7abf7db5 Scott Dale
##build widget saved list information
174 019a94df Scott Dale
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
175
	$pconfig['sequence'] = $config['widgets']['sequence'];
176 3e4e94ce Scott Dale
	
177 bf5ad142 Scott Dale
	$widgetlist = $pconfig['sequence'];
178
	$colpos = array();
179
	$savedwidgetfiles = array();
180
	$widgetname = "";
181
	$widgetlist = explode(",",$widgetlist);
182 019a94df Scott Dale
	
183
	##read the widget position and display information
184 bf5ad142 Scott Dale
	foreach ($widgetlist as $widget){
185
		$dashpos = strpos($widget, "-");		
186
		$widgetname = substr($widget, 0, $dashpos);
187
		$colposition = strpos($widget, ":");		
188
		$displayposition = strrpos($widget, ":");
189
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
190
		$displayarray[] = substr($widget,$displayposition+1);
191
		$savedwidgetfiles[] = $widgetname . ".widget.php";
192 1db766df Scott Dale
	}
193 019a94df Scott Dale
	
194 7abf7db5 Scott Dale
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
195
    foreach ($widgetfiles as $defaultwidgets){         
196
         if (!in_array($defaultwidgets, $savedwidgetfiles)){
197
             $savedwidgetfiles[] = $defaultwidgets;
198
         }
199
     }   
200
	
201 019a94df Scott Dale
	##find custom configurations of a particular widget and load its info to $pconfig
202
	foreach ($widgetnames as $widget){
203
        if ($config['widgets'][$widget . '-config']){
204
            $pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
205
        }
206
    }   
207
	
208 f617ecbd Scott Dale
	$widgetlist = $savedwidgetfiles;	
209 7abf7db5 Scott Dale
} 
210
##no saved widget sequence found, build default list.
211
else{
212 8b06c9ff Scott Dale
	$widgetlist = $widgetfiles;
213 3e4e94ce Scott Dale
}
214
215 bf5ad142 Scott Dale
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
428
outputJavaScriptFileInline("javascript/domTT/domLib.js");
429
outputJavaScriptFileInline("javascript/domTT/domTT.js");
430
outputJavaScriptFileInline("javascript/domTT/behaviour.js");
431
outputJavaScriptFileInline("javascript/domTT/fadomatic.js");
432 a8726a3d Scott Ullrich
?>
433 8dbbc3ed Scott Ullrich
434 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
435 1db766df Scott Dale
<form action="index.php" method="post">
436
<script language="javascript" type="text/javascript">
437
// <![CDATA[
438
columns = ['col1','col2'];
439
// ]]>
440
441 670fe849 Scott Ullrich
</script>
442 1db766df Scott Dale
443 5ffe7500 Scott Ullrich
<?php
444
include("fbegin.inc");
445 f5cfdc98 Scott Dale
echo $jscriptstr;
446 5e237c18 Erik Kristensen
	if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
447
		echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
448 0682e26b Colin Smith
?>
449 1db766df Scott Dale
<div id="widgetcontainer" style="display:none">
450
		<div id="content1"><h1>Available Widgets</h1><p><?php
451 16f556c5 Scott Dale
			$widgetfiles_add = $widgetfiles;
452
			sort($widgetfiles_add);
453
			foreach($widgetfiles_add as $widget) {			
454 1db766df Scott Dale
				if(!stristr($widget, "widget.php"))
455
					continue;		
456
				
457
				$periodpos = strpos($widget, ".");
458
				$widgetname = substr($widget, 0, $periodpos);
459
				$nicename = $widgetname;
460 f69aa687 Scott Dale
				$nicename = str_replace("_", " ", $nicename);
461 1db766df Scott Dale
				//make the title look nice
462 16f556c5 Scott Dale
				$nicename = ucwords($nicename);
463
				
464
				$widgettitle = $widgetname . "_title";
465
				$widgettitlelink = $widgetname . "_title_link";
466
					if ($$widgettitle != "")
467
					{
468 88f71068 Scott Dale
						//echo widget title 
469
						?>
470 7abf7db5 Scott Dale
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
471 16f556c5 Scott Dale
						<u><?php echo $$widgettitle; ?></u></span><br>
472
						<?php 
473
					}
474
					else {?>
475 7abf7db5 Scott Dale
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
476 16f556c5 Scott Dale
						<u><?php echo $nicename; ?></u></span><br><?php
477
					}
478 1db766df Scott Dale
			}
479 f5cfdc98 Scott Dale
		?>
480 1db766df Scott Dale
		</p>
481
	</div>
482
</div>
483
484 d72fc17b Scott Dale
<div id="welcomecontainer" style="display:none">
485 65d4de2e Scott Dale
		<div id="welcome-container">
486 d72fc17b Scott Dale
			<h1>
487 16f556c5 Scott Dale
				<div style="float:left;width:80%;padding: 2px">
488 ea298b82 Scott Dale
					Welcome to the Dashboard page!
489 d72fc17b Scott Dale
				</div>
490 16f556c5 Scott Dale
				<div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" >
491 d72fc17b Scott Dale
					<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" />
492
				</div>
493
				<div style="clear:both;"></div>
494
			</h1>
495
			<p>
496
			This page allows you to customize the information you want to be displayed!<br/>
497 5eafc6de Scott Dale
			To get started click the <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> icon to add widgets.<br/>
498 d72fc17b Scott Dale
			<br/>
499
			You can move any widget around by clicking and dragging the title.			
500
			</p>
501
	</div>
502
</div>
503
504
505
506 bf5ad142 Scott Dale
<input type="hidden" value="" name="sequence" id="sequence">
507 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');" />
508
509 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');" />
510 5eafc6de Scott Dale
511
512 bf5ad142 Scott Dale
&nbsp;&nbsp;&nbsp;
513
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="Save Settings" />
514
</p>
515 1db766df Scott Dale
516
<div id="niftyOutter">
517
	<?php
518
	$totalwidgets = count($widgetfiles);
519 c9cfb807 Scott Dale
	$halftotal = $totalwidgets / 2 - 2;
520
	$widgetcounter = 0;
521 8b06c9ff Scott Dale
	$directory = "/usr/local/www/widgets/widgets/";
522 1db766df Scott Dale
	$printed = false;
523
	$firstprint = false;
524
	?> 
525 ea298b82 Scott Dale
	<div id="col1" style="float:left;width:49%;padding-bottom:40px">		
526 8b06c9ff Scott Dale
	<?php	
527 135e9b3b Scott Dale
		
528 bf5ad142 Scott Dale
	foreach($widgetlist as $widget) {
529 c9cfb807 Scott Dale
		
530 1db766df Scott Dale
		if(!stristr($widget, "widget.php"))
531 3f304727 Scott Dale
					continue;
532 1db766df Scott Dale
		$periodpos = strpos($widget, ".");
533
		$widgetname = substr($widget, 0, $periodpos);	
534 bf5ad142 Scott Dale
		if ($widgetname != ""){
535 3f304727 Scott Dale
			$nicename = $widgetname;
536
			$nicename = str_replace("_", " ", $nicename);
537
			
538
			//make the title look nice
539
			$nicename = ucwords($nicename);
540 8b06c9ff Scott Dale
		}
541 1db766df Scott Dale
		
542 135e9b3b Scott Dale
		if ($config['widgets'] && $pconfig['sequence'] != ""){
543 01da41cf Bill Marquette
			switch($displayarray[$widgetcounter]){
544
				case "show":
545 8b06c9ff Scott Dale
					$divdisplay = "block";
546
					$display = "block";
547
					$inputdisplay = "show";					
548 7abf7db5 Scott Dale
					$showWidget = "none";
549 8b06c9ff Scott Dale
					$mindiv = "inline";
550 01da41cf Bill Marquette
					break;
551
				case "hide":
552 8b06c9ff Scott Dale
					$divdisplay = "block";
553 01da41cf Bill Marquette
					$display = "none";
554
					$inputdisplay = "hide";		
555
					$showWidget = "inline";
556
					$mindiv = "none";
557
					berak;
558
				case "close":
559
					$divdisplay = "none";
560 8b06c9ff Scott Dale
					$display = "block";
561 01da41cf Bill Marquette
					$inputdisplay = "close";			
562 7abf7db5 Scott Dale
					$showWidget = "none";
563 8b06c9ff Scott Dale
					$mindiv = "inline";
564 01da41cf Bill Marquette
					break;
565
				default:
566 8b06c9ff Scott Dale
					$divdisplay = "none";
567
					$display = "block";
568 01da41cf Bill Marquette
					$inputdisplay = "none";
569 7abf7db5 Scott Dale
					$showWidget = "none";
570 8b06c9ff Scott Dale
					$mindiv = "inline";
571 01da41cf Bill Marquette
					break;
572
			}
573
		} else {
574
			if ($firstprint == false){
575
				$divdisplay = "block";
576
				$display = "block";
577
				$inputdisplay = "show";
578
				$showWidget = "none";
579
				$mindiv = "inline";
580
				$firstprint = true;
581
			} else {
582
				switch ($widget) {
583
					case "interfaces.widget.php":
584
					case "traffic_graphs.widget.php":
585
						$divdisplay = "block";
586
						$display = "block";
587
						$inputdisplay = "show";
588
						$showWidget = "none";
589
						$mindiv = "inline";
590
						break;
591
					default:
592
						$divdisplay = "none";
593
						$display = "block";
594
						$inputdisplay = "close";
595
						$showWidget = "none";
596
						$mindiv = "inline";
597
						break;
598 8b06c9ff Scott Dale
				}
599 775d112b Scott Dale
			}
600 bf5ad142 Scott Dale
		}
601 1db766df Scott Dale
		
602 135e9b3b Scott Dale
		if ($config['widgets'] && $pconfig['sequence'] != ""){
603 bf5ad142 Scott Dale
			if ($colpos[$widgetcounter] == "col2" && $printed == false)
604
			{
605
				$printed = true;
606
				?>
607
				</div>
608 ea298b82 Scott Dale
				<div id="col2" style="float:right;width:49%;padding-bottom:40px">		
609 bf5ad142 Scott Dale
				<?php
610
			}
611
		}
612
		else if ($widgetcounter >= $halftotal && $printed == false){
613 1db766df Scott Dale
			$printed = true;
614
			?>
615
			</div>
616 8b06c9ff Scott Dale
			<div id="col2" style="float:right;width:49%;padding-bottom:40px">		
617 1db766df Scott Dale
			<?php
618 bf5ad142 Scott Dale
		}
619 16f556c5 Scott Dale
		
620
		?>
621 1db766df Scott Dale
		<div style="clear:both;"></div>
622 65d4de2e Scott Dale
		<div  id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
623
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input">
624 3da0d006 Scott Dale
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
625 1db766df Scott Dale
				<div style="float:left;">
626 16f556c5 Scott Dale
					<?php 
627
					
628
					$widgettitle = $widgetname . "_title";
629
					$widgettitlelink = $widgetname . "_title_link";
630
					if ($$widgettitle != "")
631
					{
632
						//only show link if defined
633
						if ($$widgettitlelink != "") {?>						
634
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
635
						<?php }
636
							//echo widget title
637
							echo $$widgettitle; 
638
						if ($$widgettitlelink != "") { ?>
639
						</span></u>						
640
						<?php }
641
					}
642
					else{		
643
						if ($$widgettitlelink != "") {?>						
644
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
645
						<?php }
646
						echo $nicename;
647
							if ($$widgettitlelink != "") { ?>
648
						</span></u>						
649
						<?php }
650
					}
651
					?>
652 1db766df Scott Dale
				</div>
653 bf5ad142 Scott Dale
				<div align="right" style="float:right;">	
654 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>									
655
					<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>	
656
					<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>												
657
					<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>	
658 1db766df Scott Dale
				</div>
659
				<div style="clear:both;"></div>
660
			</div>
661 3da0d006 Scott Dale
			<?php if ($divdisplay != "block") { ?>
662
			<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;">
663
				<br>	
664
					<center>
665
						<img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width=25 height=25 alt="Loading selected widget...">
666
					</center>	
667
				<br>
668
			</div> <?php } if ($divdisplay != "block") $display = none; ?>
669 34eac803 Scott Dale
			<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">				
670 b9b45ddb Scott Dale
				<?php 
671 3da0d006 Scott Dale
					if ($divdisplay == "block")
672 b9b45ddb Scott Dale
					{
673
						include($directory . $widget);
674 34eac803 Scott Dale
					}	
675 b9b45ddb Scott Dale
				 ?>
676 1db766df Scott Dale
			</div>
677
			<div style="clear:both;"></div>
678
		</div>
679
		<?php 	
680
	$widgetcounter++;
681 8b06c9ff Scott Dale
		
682 1db766df Scott Dale
	}//end foreach	
683
	?>			
684 8b06c9ff Scott Dale
		</div>
685 1db766df Scott Dale
	<div style="clear:both;"></div>
686 d772ac32 Erik Kristensen
</div>
687 561d55ff Erik Kristensen
688 d72fc17b Scott Dale
689
690 d772ac32 Erik Kristensen
<?php include("fend.inc"); ?>
691 7f1f5492 Scott Ullrich
	    
692
<script type="text/javascript">
693 8bf02470 Bill Marquette
	document.observe('dom:loaded', function(in_event)
694 5eafc6de Scott Dale
	{		
695 24f53f5c Scott Ullrich
			Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});	
696
			Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});		
697
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
698 5eafc6de Scott Dale
			hideAllWidgets();		    
699 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');		
700 d72fc17b Scott Dale
	<?php } ?>
701 8bf02470 Bill Marquette
	});
702 1db766df Scott Dale
	<?php
703
	//build list of javascript include files
704 775d112b Scott Dale
	$jsincludefiles = array();
705 1db766df Scott Dale
	$directory = "widgets/javascript/";
706
	$dirhandle  = opendir($directory);
707
	$filename = "";
708
	while (false !== ($filename = readdir($dirhandle))) {
709
   		$jsincludefiles[] = $filename;
710
	}
711
	foreach($jsincludefiles as $jsincludename) {
712
		if(!stristr($jsincludename, ".js"))
713
			continue;	
714
		include($directory . $jsincludename);
715
	}
716
	?>
717
</script>
718
</form>
719 5b237745 Scott Ullrich
</body>
720 5d9f9191 Scott Ullrich
</html>