Project

General

Profile

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