Project

General

Profile

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