Project

General

Profile

Download (23.3 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    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
    oR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
    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
*/
33
/*
34
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
35
	pfSense_MODULE:	interfaces
36
*/
37

    
38
##|+PRIV
39
##|*IDENT=page-system-login/logout
40
##|*NAME=System: Login / Logout page / Dashboard
41
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
42
##|*MATCH=index.php*
43
##|-PRIV
44

    
45
// Turn off csrf for the dashboard
46
$nocsrf = true; 
47

    
48
// Turn on buffering to speed up rendering
49
ini_set('output_buffering','true');
50

    
51
// Start buffering with a cache size of 100000
52
ob_start(null, "1000");
53

    
54
## Load Essential Includes
55
require_once('functions.inc');
56
require_once('guiconfig.inc');
57
require_once('notices.inc');
58

    
59
##build list of widgets
60
$directory = "/usr/local/www/widgets/widgets/";
61
$dirhandle  = opendir($directory);
62
$filename = "";
63
$widgetnames = array();
64
$widgetfiles = array();
65
$widgetlist = array();
66

    
67
while (false !== ($filename = readdir($dirhandle))) {
68
	$periodpos = strpos($filename, ".");
69
	$widgetname = substr($filename, 0, $periodpos);
70
	$widgetnames[] = $widgetname;
71
	if ($widgetname != "system_information")
72
		$widgetfiles[] = $filename;
73
}
74

    
75
##sort widgets alphabetically
76
sort($widgetfiles);
77

    
78
##insert the system information widget as first, so as to be displayed first
79
array_unshift($widgetfiles, "system_information.widget.php");
80

    
81
##if no config entry found, initialize config entry
82
if (!is_array($config['widgets'])) {
83
	$config['widgets'] = array();
84
}
85

    
86
	if ($_POST && $_POST['submit']) {
87
		$config['widgets']['sequence'] = $_POST['sequence'];
88

    
89
		foreach ($widgetnames as $widget){
90
			if ($_POST[$widget . '-config']){
91
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
92
			}
93
		}
94

    
95
		write_config(gettext("Widget configuration has been changed."));
96
		header("Location: index.php");
97
		exit;
98
	}
99

    
100
	## Load Functions Files
101
	require_once('includes/functions.inc.php');
102
	
103
	## Check to see if we have a swap space,
104
	## if true, display, if false, hide it ...
105
	if(file_exists("/usr/sbin/swapinfo")) {
106
		$swapinfo = `/usr/sbin/swapinfo`;
107
		if(stristr($swapinfo,'%') == true) $showswap=true;
108
	}
109

    
110
	## User recently restored his config.
111
	## If packages are installed lets resync
112
	if(file_exists('/conf/needs_package_sync')) {
113
		if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
114
			if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
115
				header('Location: pkg_mgr_install.php?mode=reinstallall');
116
				exit;
117
			}
118
		} else {
119
			conf_mount_rw();
120
			@unlink('/conf/needs_package_sync');
121
			conf_mount_ro();
122
		}
123
	}
124

    
125
	## If it is the first time webConfigurator has been
126
	## accessed since initial install show this stuff.
127
	if(file_exists('/conf/trigger_initial_wizard')) {
128
		echo <<<EOF
129
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
130
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
131
<html>
132
<head>
133
	<title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title>
134
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
135
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
136
	<script type="text/javascript">var theme = "nervecenter"</script>
137
	<script type="text/javascript" src="/themes/nervecenter/loader.js"></script>
138
		
139
EOF;
140

    
141
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
142

    
143
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
144
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
145
		else 
146
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
147

    
148
		echo "<form>\n";
149
		echo "<center>\n";
150
		echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
151
		echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
152
		echo sprintf(gettext("Welcome to %s!\n"),$g['product_name']) . "<p>";
153
		echo gettext("One moment while we start the initial setup wizard.") . "<p>\n";
154
		echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n";
155
		echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name']) . "\n";
156
		echo "</div>\n";
157
		echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
158
		echo "<script type=\"text/javascript\">\n";
159
		echo "NiftyCheck();\n";
160
		echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
161
		echo "</script>\n";
162
		exit;
163
	}
164

    
165

    
166
	## Find out whether there's hardware encryption or not
167
	unset($hwcrypto);
168
	$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
169
	if ($fd) {
170
		while (!feof($fd)) {
171
			$dmesgl = fgets($fd);
172
			if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches) or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches) or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches) or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches) or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches) or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)) {
173
				$hwcrypto = $matches[1];
174
				break;
175
			}
176
		}
177
		fclose($fd);
178
	}
179

    
180
##build widget saved list information
181
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
182
	$pconfig['sequence'] = $config['widgets']['sequence'];
183
	
184
	$widgetlist = $pconfig['sequence'];
185
	$colpos = array();
186
	$savedwidgetfiles = array();
187
	$widgetname = "";
188
	$widgetlist = explode(",",$widgetlist);
189
	
190
	##read the widget position and display information
191
	foreach ($widgetlist as $widget){
192
		$dashpos = strpos($widget, "-");		
193
		$widgetname = substr($widget, 0, $dashpos);
194
		$colposition = strpos($widget, ":");		
195
		$displayposition = strrpos($widget, ":");
196
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
197
		$displayarray[] = substr($widget,$displayposition+1);
198
		$savedwidgetfiles[] = $widgetname . ".widget.php";
199
	}
200
	
201
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
202
    foreach ($widgetfiles as $defaultwidgets){         
203
         if (!in_array($defaultwidgets, $savedwidgetfiles)){
204
             $savedwidgetfiles[] = $defaultwidgets;
205
         }
206
     }   
207
	
208
	##find custom configurations of a particular widget and load its info to $pconfig
209
	foreach ($widgetnames as $widget){
210
        if ($config['widgets'][$widget . '-config']){
211
            $pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
212
        }
213
    }   
214
	
215
	$widgetlist = $savedwidgetfiles;	
216
} else{
217
	// no saved widget sequence found, build default list.
218
	$widgetlist = $widgetfiles;
219
}
220

    
221
##build list of php include files
222
$phpincludefiles = array();
223
$directory = "/usr/local/www/widgets/include/";
224
$dirhandle  = opendir($directory);
225
$filename = "";
226
while (false !== ($filename = readdir($dirhandle))) {
227
	$phpincludefiles[] = $filename;
228
}
229
foreach($phpincludefiles as $includename) {
230
	if(!stristr($includename, ".inc"))
231
		continue;	
232
	include($directory . $includename);
233
}
234

    
235
##begin AJAX
236
$jscriptstr = <<<EOD
237
<script language="javascript" type="text/javascript">
238

    
239

    
240
function widgetAjax(widget) {	
241
	uri = "widgets/widgets/" + widget + ".widget.php";
242
	var opt = {
243
	    // Use GET
244
	    method: 'get',
245
		evalScripts: 'true',
246
	    asynchronous: true,
247
	    // Handle 404
248
	    on404: function(t) {
249
	        alert('Error 404: location "' + t.statusText + '" was not found.');
250
	    },
251
	    // Handle other errors
252
	    onFailure: function(t) {
253
	        alert('Error ' + t.status + ' -- ' + t.statusText);
254
	    },
255
		onSuccess: function(t) {
256
			widget2 = widget + "-loader";
257
			Effect.Fade(widget2, {queue:'front'});
258
			Effect.Appear(widget, {queue:'end'});			
259
	    }	
260
	}
261
	new Ajax.Updater(widget, uri, opt);
262
}
263

    
264

    
265
function addWidget(selectedDiv){	
266
	selectedDiv2 = selectedDiv + "-container";
267
	d = document;
268
	textlink = d.getElementById(selectedDiv2);
269
	Effect.Appear(selectedDiv2, {duration:1});
270
	if (textlink.style.display != "none")
271
	{
272
		Effect.Shake(selectedDiv2);	
273
	}
274
	else
275
	{
276
		widgetAjax(selectedDiv);
277
		selectIntLink = selectedDiv2 + "-input";
278
		textlink = d.getElementById(selectIntLink);
279
		textlink.value = "show";	
280
		showSave();
281
	}
282
}
283

    
284
function configureWidget(selectedDiv){
285
	selectIntLink = selectedDiv + "-settings";	
286
	d = document;
287
	textlink = d.getElementById(selectIntLink);
288
	if (textlink.style.display == "none")
289
		Effect.BlindDown(selectIntLink, {duration:1});
290
	else
291
		Effect.BlindUp(selectIntLink, {duration:1});
292
}
293

    
294
function showWidget(selectedDiv,swapButtons){
295
	//appear element
296
    Effect.BlindDown(selectedDiv, {duration:1});      
297
    showSave();    
298
	d = document;	
299
    if (swapButtons){
300
	    selectIntLink = selectedDiv + "-min";
301
		textlink = d.getElementById(selectIntLink);
302
		textlink.style.display = "inline";
303
	    
304
	    
305
	    selectIntLink = selectedDiv + "-open";
306
		textlink = d.getElementById(selectIntLink);
307
		textlink.style.display = "none";
308

    
309
    }
310
	selectIntLink = selectedDiv + "-container-input";
311
	textlink = d.getElementById(selectIntLink);
312
	textlink.value = "show";	
313
    
314
}
315
	
316
function minimizeWidget(selectedDiv,swapButtons){
317
	//fade element
318
    Effect.BlindUp(selectedDiv, {duration:1});      
319
    showSave();
320
	d = document;	
321
    if (swapButtons){
322
	    selectIntLink = selectedDiv + "-open";
323
		textlink = d.getElementById(selectIntLink);
324
		textlink.style.display = "inline";	    
325
	    
326
	    selectIntLink = selectedDiv + "-min";
327
		textlink = d.getElementById(selectIntLink);
328
		textlink.style.display = "none";
329
    }  		
330
	selectIntLink = selectedDiv + "-container-input";
331
	textlink = d.getElementById(selectIntLink);
332
	textlink.value = "hide";	  
333
    
334
}
335

    
336
function closeWidget(selectedDiv){	
337
	showSave();
338
	selectedDiv = selectedDiv + "-container";
339
	Effect.Fade(selectedDiv, {duration:1});
340
	d = document;
341
	selectIntLink = selectedDiv + "-input";
342
	textlink = d.getElementById(selectIntLink);
343
	textlink.value = "close";	
344
}
345

    
346
function showSave(){
347
	d = document;
348
	selectIntLink = "submit";
349
	textlink = d.getElementById(selectIntLink);
350
	textlink.style.display = "inline";	
351
}
352

    
353
function updatePref(){	
354
	var widgets = document.getElementsByClassName('widgetdiv');
355
	var widgetSequence = "";
356
	var firstprint = false;	
357
	d = document;
358
	for (i=0; i<widgets.length; i++){
359
		if (firstprint)
360
			widgetSequence += ",";
361
		var widget = widgets[i].id;
362
		widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
363
		widget = widget + "-input";
364
		textlink = d.getElementById(widget).value;
365
		widgetSequence += textlink;
366
		firstprint = true;		
367
	}
368
	selectLink = "sequence";
369
	textlink = d.getElementById(selectLink);
370
	textlink.value = widgetSequence;
371
	return true;	
372
}
373

    
374
function hideAllWidgets(){		
375
		Effect.Fade('niftyOutter', {to: 0.2});
376
}
377

    
378
function showAllWidgets(){		
379
		Effect.Fade('niftyOutter', {to: 1.0});
380
}
381

    
382

    
383
function changeTabDIV(selectedDiv){
384
	var dashpos = selectedDiv.indexOf("-");
385
	var tabclass = selectedDiv.substring(0,dashpos);
386
	d = document;
387

    
388
	//get deactive tabs first
389
	tabclass = tabclass + "-class-tabdeactive"; 
390
	var tabs = document.getElementsByClassName(tabclass);
391
	var incTabSelected = selectedDiv + "-deactive";
392
	for (i=0; i<tabs.length; i++){
393
		var tab = tabs[i].id;
394
		dashpos = tab.lastIndexOf("-");
395
		var tab2 = tab.substring(0,dashpos) + "-deactive";
396
		if (tab2 == incTabSelected){
397
			tablink = d.getElementById(tab2);
398
			tablink.style.display = "none";
399
			tab2 = tab.substring(0,dashpos) + "-active";
400
			tablink = d.getElementById(tab2);
401
			tablink.style.display = "table-cell";
402
			
403
			//now show main div associated with link clicked
404
			tabmain = d.getElementById(selectedDiv);
405
			tabmain.style.display = "block";
406
		}
407
		else
408
		{	
409
			tab2 = tab.substring(0,dashpos) + "-deactive";
410
			tablink = d.getElementById(tab2);
411
			tablink.style.display = "table-cell";
412
			tab2 = tab.substring(0,dashpos) + "-active";
413
			tablink = d.getElementById(tab2);
414
			tablink.style.display = "none";		
415
			
416
			//hide sections we don't want to see
417
			tab2 = tab.substring(0,dashpos);
418
			tabmain = d.getElementById(tab2);
419
			tabmain.style.display = "none";
420
				
421
		}
422
	}	
423
}
424

    
425
</script>
426
EOD;
427
$closehead = false;
428

    
429
## Set Page Title and Include Header
430
$pgtitle = array(gettext("Status: Dashboard"));
431
include("head.inc");
432

    
433
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n";
434
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domTT.js\"></script>\n";
435
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/behaviour.js\"></script>\n";
436
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/fadomatic.js\"></script>\n";
437

    
438
?>
439

    
440
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
441
<form action="index.php" method="post">
442
<script language="javascript" type="text/javascript">
443
// <![CDATA[
444
columns = ['col1','col2'];
445
// ]]>
446

    
447
</script>
448

    
449
<?php
450
include("fbegin.inc");
451
echo $jscriptstr;
452
	if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
453
		echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
454
?>
455
<div id="widgetcontainer" style="display:none">
456
		<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
457
			$widgetfiles_add = $widgetfiles;
458
			sort($widgetfiles_add);
459
			foreach($widgetfiles_add as $widget) {			
460
				if(!stristr($widget, "widget.php"))
461
					continue;		
462
				
463
				$periodpos = strpos($widget, ".");
464
				$widgetname = substr($widget, 0, $periodpos);
465
				$nicename = $widgetname;
466
				$nicename = str_replace("_", " ", $nicename);
467
				//make the title look nice
468
				$nicename = ucwords($nicename);
469
				
470
				$widgettitle = $widgetname . "_title";
471
				$widgettitlelink = $widgetname . "_title_link";
472
					if ($$widgettitle != "")
473
					{
474
						//echo widget title 
475
						?>
476
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
477
						<u><?php echo $$widgettitle; ?></u></span><br>
478
						<?php 
479
					}
480
					else {?>
481
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
482
						<u><?php echo $nicename; ?></u></span><br><?php
483
					}
484
			}
485
		?>
486
		</p>
487
	</div>
488
</div>
489

    
490
<div id="welcomecontainer" style="display:none">
491
		<div id="welcome-container">
492
			<h1>
493
				<div style="float:left;width:80%;padding: 2px">
494
					<?=gettext("Welcome to the Dashboard page"); ?>!
495
				</div>
496
				<div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" >
497
					<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" />
498
				</div>
499
				<div style="clear:both;"></div>
500
			</h1>
501
			<p>
502
			<?=gettext("This page allows you to customize the information you want to be displayed!");?><br/>
503
			<?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> <?=gettext("icon to add widgets.");?><br/>
504
			<br/>
505
			<?=gettext("You can move any widget around by clicking and dragging the title.");?>			
506
			</p>
507
	</div>
508
</div>
509

    
510
<input type="hidden" value="" name="sequence" id="sequence">
511
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="<?=gettext("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');" />
512

    
513
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_info_pkg.gif" alt="<?=gettext("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');" />
514

    
515

    
516
&nbsp;&nbsp;&nbsp;
517
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
518
</p>
519

    
520
<div id="niftyOutter">
521
	<?php
522
	$totalwidgets = count($widgetfiles);
523
	$halftotal = $totalwidgets / 2 - 2;
524
	$widgetcounter = 0;
525
	$directory = "/usr/local/www/widgets/widgets/";
526
	$printed = false;
527
	$firstprint = false;
528
	?> 
529
	<div id="col1" style="float:left;width:49%;padding-bottom:40px">		
530
	<?php	
531
		
532
	foreach($widgetlist as $widget) {
533
		
534
		if(!stristr($widget, "widget.php"))
535
					continue;
536
		$periodpos = strpos($widget, ".");
537
		$widgetname = substr($widget, 0, $periodpos);	
538
		if ($widgetname != ""){
539
			$nicename = $widgetname;
540
			$nicename = str_replace("_", " ", $nicename);
541
			
542
			//make the title look nice
543
			$nicename = ucwords($nicename);
544
		}
545
		
546
		if ($config['widgets'] && $pconfig['sequence'] != ""){
547
			switch($displayarray[$widgetcounter]){
548
				case "show":
549
					$divdisplay = "block";
550
					$display = "block";
551
					$inputdisplay = "show";					
552
					$showWidget = "none";
553
					$mindiv = "inline";
554
					break;
555
				case "hide":
556
					$divdisplay = "block";
557
					$display = "none";
558
					$inputdisplay = "hide";		
559
					$showWidget = "inline";
560
					$mindiv = "none";
561
					break;
562
				case "close":
563
					$divdisplay = "none";
564
					$display = "block";
565
					$inputdisplay = "close";			
566
					$showWidget = "none";
567
					$mindiv = "inline";
568
					break;
569
				default:
570
					$divdisplay = "none";
571
					$display = "block";
572
					$inputdisplay = "none";
573
					$showWidget = "none";
574
					$mindiv = "inline";
575
					break;
576
			}
577
		} else {
578
			if ($firstprint == false){
579
				$divdisplay = "block";
580
				$display = "block";
581
				$inputdisplay = "show";
582
				$showWidget = "none";
583
				$mindiv = "inline";
584
				$firstprint = true;
585
			} else {
586
				switch ($widget) {
587
					case "interfaces.widget.php":
588
					case "traffic_graphs.widget.php":
589
						$divdisplay = "block";
590
						$display = "block";
591
						$inputdisplay = "show";
592
						$showWidget = "none";
593
						$mindiv = "inline";
594
						break;
595
					default:
596
						$divdisplay = "none";
597
						$display = "block";
598
						$inputdisplay = "close";
599
						$showWidget = "none";
600
						$mindiv = "inline";
601
						break;
602
				}
603
			}
604
		}
605
		
606
		if ($config['widgets'] && $pconfig['sequence'] != ""){
607
			if ($colpos[$widgetcounter] == "col2" && $printed == false)
608
			{
609
				$printed = true;
610
				?>
611
				</div>
612
				<div id="col2" style="float:right;width:49%;padding-bottom:40px">		
613
				<?php
614
			}
615
		}
616
		else if ($widgetcounter >= $halftotal && $printed == false){
617
			$printed = true;
618
			?>
619
			</div>
620
			<div id="col2" style="float:right;width:49%;padding-bottom:40px">		
621
			<?php
622
		}
623
		
624
		?>
625
		<div style="clear:both;"></div>
626
		<div  id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
627
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input">
628
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
629
				<div style="float:left;">
630
					<?php 
631
					
632
					$widgettitle = $widgetname . "_title";
633
					$widgettitlelink = $widgetname . "_title_link";
634
					if ($$widgettitle != "")
635
					{
636
						//only show link if defined
637
						if ($$widgettitlelink != "") {?>						
638
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
639
						<?php }
640
							//echo widget title
641
							echo $$widgettitle; 
642
						if ($$widgettitlelink != "") { ?>
643
						</span></u>						
644
						<?php }
645
					}
646
					else{		
647
						if ($$widgettitlelink != "") {?>						
648
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
649
						<?php }
650
						echo $nicename;
651
							if ($$widgettitlelink != "") { ?>
652
						</span></u>						
653
						<?php }
654
					}
655
					?>
656
				</div>
657
				<div align="right" style="float:right;">	
658
					<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>									
659
					<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>	
660
					<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>												
661
					<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>	
662
				</div>
663
				<div style="clear:both;"></div>
664
			</div>
665
			<?php if ($divdisplay != "block") { ?>
666
			<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;">
667
				<br>	
668
					<center>
669
						<img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width=25 height=25 alt="<?=gettext("Loading selected widget"); ?>...">
670
					</center>	
671
				<br>
672
			</div> <?php } if ($divdisplay != "block") $display = none; ?>
673
			<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">				
674
				<?php 
675
					if ($divdisplay == "block")
676
					{
677
						include($directory . $widget);
678
					}	
679
				 ?>
680
			</div>
681
			<div style="clear:both;"></div>
682
		</div>
683
		<?php 	
684
	$widgetcounter++;
685
		
686
	}//end foreach	
687
	?>			
688
		</div>
689
	<div style="clear:both;"></div>
690
</div>
691

    
692
<?php include("fend.inc"); ?>
693
	    
694
<script type="text/javascript">
695
	document.observe('dom:loaded', function(in_event)
696
	{		
697
			Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});	
698
			Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});		
699
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
700
			hideAllWidgets();		    
701
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
702
	<?php } ?>
703
	});
704
</script>
705
<?php
706
	//build list of javascript include files
707
	$jsincludefiles = array();
708
	$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
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";	
718
	}
719
?>
720
</script>
721
</form>
722
</body>
723
</html>
(82-82/224)