Project

General

Profile

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