Project

General

Profile

Download (21.7 KB) Statistics
| Branch: | Tag: | Revision:
1 2cd6010c Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 b49448ac Scott Ullrich
    index.php
5
    Copyright (C) 2004, 2005 Scott Ullrich
6
    All rights reserved.
7
8
    Originally part of m0n0wall (http://m0n0.ch/wall)
9
    Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
    All rights reserved.
11
12
    Redistribution and use in source and binary forms, with or without
13
    modification, are permitted provided that the following conditions are met:
14
15
    1. Redistributions of source code must retain the above copyright notice,
16
       this list of conditions and the following disclaimer.
17
18
    2. Redistributions in binary form must reproduce the above copyright
19
       notice, this list of conditions and the following disclaimer in the
20
       documentation and/or other materials provided with the distribution.
21
22
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26 0682e26b Colin Smith
    oR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 b49448ac Scott Ullrich
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
    POSSIBILITY OF SUCH DAMAGE.
32 5b237745 Scott Ullrich
*/
33
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 d772ac32 Erik Kristensen
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 d88c6a9f Scott Ullrich
		$pgtitle = array("pfSense 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
		echo "Welcome to pfSense!<p>\n";
89
		echo "One moment while we start the initial setup wizard.<p>\n";
90
		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 pfSense wizard on the initial page.\n";
92
		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
$directory = "widgets/widgets/";
118
$dirhandle  = opendir($directory);
119
$filename = "";
120 775d112b 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 bf5ad142 Scott Dale
	$widgetlist = $pconfig['sequence'];
158
	
159
	$colpos = array();
160
	$savedwidgetfiles = array();
161
	$widgetname = "";
162
	$widgetlist = explode(",",$widgetlist);
163
	foreach ($widgetlist as $widget){
164
		$dashpos = strpos($widget, "-");		
165
		$widgetname = substr($widget, 0, $dashpos);
166
		$colposition = strpos($widget, ":");		
167
		$displayposition = strrpos($widget, ":");
168
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
169
		$displayarray[] = substr($widget,$displayposition+1);
170
		$savedwidgetfiles[] = $widgetname . ".widget.php";
171 1db766df Scott Dale
	}
172 bf5ad142 Scott Dale
	foreach ($widgetnames as $widget){
173
		if ($config['widgets'][$widget . '-config']){
174
			$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
175
		}
176
	}	
177 3e4e94ce Scott Dale
}
178
179 bf5ad142 Scott Dale
180
//build list of php include files
181
$phpincludefiles = Array();
182
$directory = "widgets/include/";
183
$dirhandle  = opendir($directory);
184
$filename = "";
185
while (false !== ($filename = readdir($dirhandle))) {
186
	$phpincludefiles[] = $filename;
187
}
188
foreach($phpincludefiles as $includename) {
189
	if(!stristr($includename, ".inc"))
190
		continue;	
191
	include($directory . $includename);
192
}
193 81db9b7b Scott Dale
194
//function to create widget tabs when called
195
function display_widget_tabs(& $tab_array) {	
196
	echo "<div id='tabs'>";
197
	$tabscounter = 0;
198
	foreach ($tab_array as $ta) {
199
	$dashpos = strpos($ta[2],'-');
200
	$tabname = $ta[2] . "-tab";
201
	$tabclass = substr($ta[2],0,$dashpos);
202
	$tabclass = $tabclass . "-class";
203
		if ($ta[1] == true) {
204
			$tabActive = "table-cell";
205
			$tabNonActive = "none";
206
		} 
207
		else {
208
			$tabActive = "none";
209
			$tabNonActive = "table-cell";
210
		}
211
		echo "<div id='{$ta[2]}-active' class='{$tabclass}-tabactive' style='display:{$tabActive}; background-color:#EEEEEE; color:black;'>";
212
		echo "<B>&nbsp;&nbsp;&nbsp;{$ta[0]}";
213
		echo "&nbsp;&nbsp;&nbsp;</B>";
214
		echo "</div>";
215
		
216
		echo "<div id='{$ta[2]}-deactive' class='{$tabclass}-tabdeactive' style='display:{$tabNonActive}; background-color:#777777; color:white; cursor: pointer;' onClick=\"return changeTabDIV('{$ta[2]}')\">";
217
		echo "<B>&nbsp;&nbsp;&nbsp;{$ta[0]}";
218
		echo "&nbsp;&nbsp;&nbsp;</B>";
219
		echo "</div>";
220
	}
221 1db766df Scott Dale
	
222 81db9b7b Scott Dale
	echo "<script type=\"text/javascript\">";
223
	echo "NiftyCheck();\n";
224
	echo "Rounded(\"div.{$tabclass}-tabactive\",\"top\",\"#CCCCCC\",\"#EEEEEE\",\"smooth\");\n";
225
	echo "Rounded(\"div.{$tabclass}-tabdeactive\",\"top\",\"#CCCCCC\",\"#777777\",\"smooth\");\n";
226
	echo "</script>";
227
	echo "</div>";
228
}
229 1db766df Scott Dale
230
$jscriptstr = <<<EOD
231
<script language="javascript" type="text/javascript">
232
233 5eafc6de Scott Dale
function addDiv(selectedDiv){	
234 bf5ad142 Scott Dale
	selectedDiv = selectedDiv + "-div";
235 5eafc6de Scott Dale
	textlink = d.getElementById(selectedDiv);
236
	if (textlink.style.display != "none")
237
	{
238
		Effect.Shake(selectedDiv);	
239
	}
240
	else
241
	{
242
		Effect.Appear(selectedDiv, {duration:1});
243
		d = document;	
244
		selectIntLink = selectedDiv + "-input";
245
		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
		//appear element
263
    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 bf5ad142 Scott Dale
	selectIntLink = selectedDiv + "-div-input";
278
	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
	selectIntLink = selectedDiv + "-div-input";
298
	textlink = d.getElementById(selectIntLink);
299
	textlink.value = "hide";	  
300
    
301 1db766df Scott Dale
}
302
303 bf5ad142 Scott Dale
function closeDiv(selectedDiv){	
304
	showSave();
305
	selectedDiv = selectedDiv + "-div";
306
	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 28b1cc39 Scott Ullrich
$pgtitle = array("pfSense webConfigurator");
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 561d55ff Erik Kristensen
427 1db766df Scott Dale
<?php 
428
	?>
429
<div id="widgetcontainer" style="display:none">
430
		<div id="content1"><h1>Available Widgets</h1><p><?php
431 16f556c5 Scott Dale
			$widgetfiles_add = $widgetfiles;
432
			sort($widgetfiles_add);
433
			foreach($widgetfiles_add as $widget) {			
434 1db766df Scott Dale
				if(!stristr($widget, "widget.php"))
435
					continue;		
436
				
437
				$periodpos = strpos($widget, ".");
438
				$widgetname = substr($widget, 0, $periodpos);
439
				$nicename = $widgetname;
440 f69aa687 Scott Dale
				$nicename = str_replace("_", " ", $nicename);
441 1db766df Scott Dale
				//make the title look nice
442 16f556c5 Scott Dale
				$nicename = ucwords($nicename);
443
				
444
				$widgettitle = $widgetname . "_title";
445
				$widgettitlelink = $widgetname . "_title_link";
446
					if ($$widgettitle != "")
447
					{
448 88f71068 Scott Dale
						//echo widget title 
449
						?>
450 16f556c5 Scott Dale
						<span style="cursor: pointer;" onclick='return addDiv("<?php echo $widgetname; ?>")'>
451
						<u><?php echo $$widgettitle; ?></u></span><br>
452
						<?php 
453
					}
454
					else {?>
455
						<span style="cursor: pointer;" onclick='return addDiv("<?php echo $widgetname; ?>")'>
456
						<u><?php echo $nicename; ?></u></span><br><?php
457
					}
458 1db766df Scott Dale
			}
459 f5cfdc98 Scott Dale
		?>
460 1db766df Scott Dale
		</p>
461
	</div>
462
</div>
463
464 d72fc17b Scott Dale
<div id="welcomecontainer" style="display:none">
465
		<div id="welcome-div">
466
			<h1>
467 16f556c5 Scott Dale
				<div style="float:left;width:80%;padding: 2px">
468 d72fc17b Scott Dale
					Welcome to the New Dashboard page!
469
				</div>
470 16f556c5 Scott Dale
				<div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" >
471 d72fc17b Scott Dale
					<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" />
472
				</div>
473
				<div style="clear:both;"></div>
474
			</h1>
475
			<p>
476
			This page allows you to customize the information you want to be displayed!<br/>
477 5eafc6de Scott Dale
			To get started click the <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> icon to add widgets.<br/>
478 d72fc17b Scott Dale
			<br/>
479
			You can move any widget around by clicking and dragging the title.			
480
			</p>
481
	</div>
482
</div>
483
484
485
486 bf5ad142 Scott Dale
<input type="hidden" value="" name="sequence" id="sequence">
487 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');" />
488
489
<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-div'), 'type', 'sticky', 'closeLink', '','delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
490
491
492 bf5ad142 Scott Dale
&nbsp;&nbsp;&nbsp;
493
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="Save Settings" />
494
</p>
495 1db766df Scott Dale
496
<div id="niftyOutter">
497
	<?php
498
	$totalwidgets = count($widgetfiles);
499 bf5ad142 Scott Dale
	$halftotal = $totalwidgets / 2 -1;
500
	$widgetcounter = 0;
501 1db766df Scott Dale
	$directory = "widgets/widgets/";
502
	$printed = false;
503
	$firstprint = false;
504
	?> 
505
	<div id="col1" style="float:left;width:49%;padding: 2px;padding-bottom:40px">		
506
	<?php
507
	
508 3ee9cb77 Scott Dale
	if ($config['widgets']){
509 bf5ad142 Scott Dale
		$widgetlist = $savedwidgetfiles;
510 3ee9cb77 Scott Dale
		
511
		//add widgets that may not be in the saved configuration, in case they want to be added later
512
		foreach ($widgetfiles as $defaultwidgets){
513
			
514
			if (!in_array($defaultwidgets, $savedwidgetfiles)){
515
				$widgetlist[] = $defaultwidgets;
516
			}
517
		}		
518
		
519
	}
520 bf5ad142 Scott Dale
	else
521 3ee9cb77 Scott Dale
		$widgetlist = $widgetfiles;	
522 bf5ad142 Scott Dale
	
523
	foreach($widgetlist as $widget) {
524 1db766df Scott Dale
	
525
		if(!stristr($widget, "widget.php"))
526
			continue;		
527
		
528
		$periodpos = strpos($widget, ".");
529
		$widgetname = substr($widget, 0, $periodpos);	
530 bf5ad142 Scott Dale
		if ($widgetname != ""){
531 1db766df Scott Dale
		$nicename = $widgetname;
532 f69aa687 Scott Dale
		$nicename = str_replace("_", " ", $nicename);
533 1db766df Scott Dale
			
534
		//make the title look nice
535
		$nicename = ucwords($nicename);
536
		
537 775d112b Scott Dale
		if ($config['widgets']){
538
			if ($displayarray[$widgetcounter] == "show"){
539
				$divdisplay = "block";
540
				$display = "block";
541
				$inputdisplay = "show";					
542
				$showdiv = "none";
543
				$mindiv = "inline";
544
			}
545
			else if ($displayarray[$widgetcounter] == "hide") {
546
				$divdisplay = "block";
547
				$display = "none";
548
				$inputdisplay = "hide";		
549
				$showdiv = "inline";
550
				$mindiv = "none";
551
			}
552
			else if ($displayarray[$widgetcounter] == "close"){
553
				$divdisplay = "none";
554
				$display = "block";
555
				$inputdisplay = "close";			
556
				$showdiv = "none";
557
				$mindiv = "inline";
558
			}
559
			else{
560 3ee9cb77 Scott Dale
				$divdisplay = "none";
561 775d112b Scott Dale
				$display = "block";
562 3ee9cb77 Scott Dale
				$inputdisplay = "none";
563 775d112b Scott Dale
				$showdiv = "none";
564
				$mindiv = "inline";
565
			}
566 bf5ad142 Scott Dale
		}
567 775d112b Scott Dale
		else
568
		{
569
			if ($firstprint == false){
570
				$divdisplay = "block";
571
				$display = "block";
572
				$inputdisplay = "show";					
573
				$showdiv = "none";
574
				$mindiv = "inline";
575
				$firstprint = true;
576
			}
577
			else
578
			{
579
				$divdisplay = "none";
580
				$display = "block";
581
				$inputdisplay = "close";			
582
				$showdiv = "none";
583
				$mindiv = "inline";
584
			}
585 bf5ad142 Scott Dale
		}
586
			
587 1db766df Scott Dale
		
588 bf5ad142 Scott Dale
		if ($config['widgets']){
589
			if ($colpos[$widgetcounter] == "col2" && $printed == false)
590
			{
591
				$printed = true;
592
				?>
593
				</div>
594
				<div id="col2" style="float:right;width:49%;padding: 2px;padding-bottom:40px">		
595
				<?php
596
			}
597
		}
598
		else if ($widgetcounter >= $halftotal && $printed == false){
599 1db766df Scott Dale
			$printed = true;
600
			?>
601
			</div>
602
			<div id="col2" style="float:right;width:49%;padding: 2px;padding-bottom:40px">		
603
			<?php
604 bf5ad142 Scott Dale
		}
605 16f556c5 Scott Dale
		
606
		?>
607 1db766df Scott Dale
		<div style="clear:both;"></div>
608 bf5ad142 Scott Dale
		<div  id="<?php echo $widgetname;?>-div" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
609
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-div-input" name="<?php echo $widgetname;?>-div-input">
610 1db766df Scott Dale
			<div id="<?php echo $widgetname;?>topic" class="widgetheader" style="cursor:move">
611
				<div style="float:left;">
612 16f556c5 Scott Dale
					<?php 
613
					
614
					$widgettitle = $widgetname . "_title";
615
					$widgettitlelink = $widgetname . "_title_link";
616
					if ($$widgettitle != "")
617
					{
618
						//only show link if defined
619
						if ($$widgettitlelink != "") {?>						
620
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
621
						<?php }
622
							//echo widget title
623
							echo $$widgettitle; 
624
						if ($$widgettitlelink != "") { ?>
625
						</span></u>						
626
						<?php }
627
					}
628
					else{		
629
						if ($$widgettitlelink != "") {?>						
630
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
631
						<?php }
632
						echo $nicename;
633
							if ($$widgettitlelink != "") { ?>
634
						</span></u>						
635
						<?php }
636
					}
637
					?>
638 1db766df Scott Dale
				</div>
639 bf5ad142 Scott Dale
				<div align="right" style="float:right;">	
640 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>									
641 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>	
642
					<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>												
643 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>	
644
				</div>
645
				<div style="clear:both;"></div>
646
			</div>
647 bf5ad142 Scott Dale
			<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">
648 b9b45ddb Scott Dale
				<?php 
649
					if (file_exists($directory . $widget))
650
					{
651
						include($directory . $widget);
652
					}
653
					else 
654
					{
655
						echo "Widget does not exists in the widget folder. <br>Please reinstall the dashboard package to correct this issue.";	
656
					}				
657
				 ?>
658 1db766df Scott Dale
			</div>
659
			<div style="clear:both;"></div>
660
		</div>
661
		<?php 	
662
	$widgetcounter++;
663 bf5ad142 Scott Dale
		}
664 1db766df Scott Dale
	}//end foreach	
665
	?>			
666
	</div><!-- end col -->
667 bf5ad142 Scott Dale
	<?php  if ($printed == false){
668
			$printed = true;
669
			?>
670
			</div>
671
			<div id="col2" style="float:right;width:49%;padding: 2px;padding-bottom:40px"></div>
672
		
673
			<?php } ?>
674 1db766df Scott Dale
	<div style="clear:both;"></div>
675 d772ac32 Erik Kristensen
</div>
676 561d55ff Erik Kristensen
677 d72fc17b Scott Dale
678
679 d772ac32 Erik Kristensen
<?php include("fend.inc"); ?>
680 7f1f5492 Scott Ullrich
	    
681
<script type="text/javascript">
682
683 d72fc17b Scott Dale
	<?php if (!$config['widgets']){ ?>
684
	window.onload = function(in_event)
685 5eafc6de Scott Dale
	{		
686
			hideAllWidgets();		    
687
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-div'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
688 d72fc17b Scott Dale
	}
689
	<?php } ?>
690 1db766df Scott Dale
	// <![CDATA[
691 bf5ad142 Scott Dale
	Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});	
692
	Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});		
693 1db766df Scott Dale
	// ]]>	
694
	
695
	<?php
696
	//build list of javascript include files
697 775d112b Scott Dale
	$jsincludefiles = array();
698 1db766df Scott Dale
	$directory = "widgets/javascript/";
699
	$dirhandle  = opendir($directory);
700
	$filename = "";
701
	while (false !== ($filename = readdir($dirhandle))) {
702
   		$jsincludefiles[] = $filename;
703
	}
704
	foreach($jsincludefiles as $jsincludename) {
705
		if(!stristr($jsincludename, ".js"))
706
			continue;	
707
		include($directory . $jsincludename);
708
	}
709
	?>
710
</script>
711
</form>
712 5b237745 Scott Ullrich
</body>
713 1db766df Scott Dale
</html>