Project

General

Profile

Download (23.6 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
##|+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
	## Load Essential Includes
43
	require_once('guiconfig.inc');
44
	require_once('notices.inc');
45

    
46
	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
	## Load Functions Files
61
	require_once('includes/functions.inc.php');
62

    
63
	## Load AJAX, Initiate Class ###############################################
64
	require_once('includes/sajax.class.php');
65

    
66
	## 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
	$oSajax->sajax_export("get_stats");
73
	$oSajax->sajax_handle_client_request();
74
	############################################################################
75
	
76
	
77
	## Check to see if we have a swap space,
78
	## if true, display, if false, hide it ...
79
	if(file_exists("/usr/sbin/swapinfo")) {
80
		$swapinfo = `/usr/sbin/swapinfo`;
81
		if(stristr($swapinfo,'%') == true) $showswap=true;
82
	}
83

    
84

    
85
	## User recently restored his config.
86
	## If packages are installed lets resync
87
	if(file_exists('/conf/needs_package_sync')) {
88
		if($config['installedpackages'] <> '') {
89
			conf_mount_rw();
90
			unlink('/conf/needs_package_sync');
91
			conf_mount_ro();
92
			if($g['platform'] == "pfSense") {
93
				header('Location: pkg_mgr_install.php?mode=reinstallall');
94
				exit;
95
			}
96
		}
97
	}
98

    
99

    
100
	## If it is the first time webConfigurator has been
101
	## accessed since initial install show this stuff.
102
	if(file_exists('/conf/trigger_initial_wizard')) {
103

    
104

    
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

    
118
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
119

    
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
		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
		echo "Welcome to {$g['product_name']}!<p>\n";
130
		echo "One moment while we start the initial setup wizard.<p>\n";
131
		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
		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
		echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
138
		echo "</script>\n";
139
		exit;
140
	}
141

    
142

    
143
	## 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
		}
154
		fclose($fd);
155
	}
156

    
157
##build list of widgets
158
$directory = "/usr/local/www/widgets/widgets/";
159
$dirhandle  = opendir($directory);
160
$filename = "";
161
$widgetnames = array();
162
$widgetfiles = array();
163
$widgetlist = array();
164
while (false !== ($filename = readdir($dirhandle))) {
165
	$periodpos = strpos($filename, ".");
166
	$widgetname = substr($filename, 0, $periodpos);
167
	$widgetnames[] = $widgetname;
168
	if ($widgetname != "system_information")
169
		$widgetfiles[] = $filename;   		
170
}
171

    
172

    
173
##sort widgets alphabetically
174
sort($widgetfiles);
175

    
176
##insert the system information widget as first, so as to be displayed first
177
array_unshift($widgetfiles, "system_information.widget.php");
178

    
179
##if no config entry found, initialize config entry
180
if (!is_array($config['widgets'])) {
181
	$config['widgets'] = array();
182
}
183

    
184
##build widget saved list information
185
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
186
	$pconfig['sequence'] = $config['widgets']['sequence'];
187
	
188
	$widgetlist = $pconfig['sequence'];
189
	$colpos = array();
190
	$savedwidgetfiles = array();
191
	$widgetname = "";
192
	$widgetlist = explode(",",$widgetlist);
193
	
194
	##read the widget position and display information
195
	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
	}
204
	
205
	##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
	##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
	$widgetlist = $savedwidgetfiles;	
220
} 
221
##no saved widget sequence found, build default list.
222
else{
223
	$widgetlist = $widgetfiles;
224
}
225

    
226

    
227
##build list of php include files
228
$phpincludefiles = array();
229
$directory = "/usr/local/www/widgets/include/";
230
$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

    
241
##begin AJAX
242
$jscriptstr = <<<EOD
243
<script language="javascript" type="text/javascript">
244

    
245

    
246
function widgetAjax(widget) {	
247
	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

    
270

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

    
290
function configureWidget(selectedDiv){
291
	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
function showWidget(selectedDiv,swapButtons){
301
	//appear element
302
    Effect.BlindDown(selectedDiv, {duration:1});      
303
    showSave();    
304
	d = document;	
305
    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

    
315
    }
316
	selectIntLink = selectedDiv + "-container-input";
317
	textlink = d.getElementById(selectIntLink);
318
	textlink.value = "show";	
319
    
320
}
321
	
322
function minimizeWidget(selectedDiv,swapButtons){
323
	//fade element
324
    Effect.BlindUp(selectedDiv, {duration:1});      
325
    showSave();
326
	d = document;	
327
    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
    }  		
336
	selectIntLink = selectedDiv + "-container-input";
337
	textlink = d.getElementById(selectIntLink);
338
	textlink.value = "hide";	  
339
    
340
}
341

    
342
function closeWidget(selectedDiv){	
343
	showSave();
344
	selectedDiv = selectedDiv + "-container";
345
	Effect.Fade(selectedDiv, {duration:1});
346
	d = document;
347
	selectIntLink = selectedDiv + "-input";
348
	textlink = d.getElementById(selectIntLink);
349
	textlink.value = "close";	
350
}
351

    
352
function showSave(){
353
	d = document;
354
	selectIntLink = "submit";
355
	textlink = d.getElementById(selectIntLink);
356
	textlink.style.display = "inline";	
357
}
358

    
359
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

    
380
function hideAllWidgets(){		
381
		Effect.Fade('niftyOutter', {to: 0.2});
382
}
383

    
384
function showAllWidgets(){		
385
		Effect.Fade('niftyOutter', {to: 1.0});
386
}
387

    
388

    
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
</script>
432
EOD;
433
$closehead = false;
434

    
435
## Set Page Title and Include Header
436
$pgtitle = array("{$g['product_name']} Dashboard");
437
include("head.inc");
438

    
439
outputJavaScriptFileInline("javascript/domTT/domLib.js");
440
outputJavaScriptFileInline("javascript/domTT/domTT.js");
441
outputJavaScriptFileInline("javascript/domTT/behaviour.js");
442
outputJavaScriptFileInline("javascript/domTT/fadomatic.js");
443
//echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domLib.js\"></script>";
444
//echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/domTT.js\"></script>";
445
//echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/behaviour.js\"></script>";
446
//echo "<script type=\"text/javascript\" language=\"javascript\" src=\"/javascript/domTT/fadomatic.js\"></script>";
447
?>
448

    
449
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
450
<form action="index.php" method="post">
451
<script language="javascript" type="text/javascript">
452
// <![CDATA[
453
columns = ['col1','col2'];
454
// ]]>
455

    
456
</script>
457

    
458
<script type="text/javascript" language="javascript" src="/javascript/scriptaculous/prototype.js"></script>
459
<script type="text/javascript" language="javascript" src="javascript/scriptaculous/scriptaculous.js"></script>
460

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

    
502
<div id="welcomecontainer" style="display:none">
503
		<div id="welcome-container">
504
			<h1>
505
				<div style="float:left;width:80%;padding: 2px">
506
					Welcome to the Dashboard page!
507
				</div>
508
				<div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" >
509
					<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" />
510
				</div>
511
				<div style="clear:both;"></div>
512
			</h1>
513
			<p>
514
			This page allows you to customize the information you want to be displayed!<br/>
515
			To get started click the <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> icon to add widgets.<br/>
516
			<br/>
517
			You can move any widget around by clicking and dragging the title.			
518
			</p>
519
	</div>
520
</div>
521

    
522

    
523

    
524
<input type="hidden" value="" name="sequence" id="sequence">
525
<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');" />
526

    
527
<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');" />
528

    
529

    
530
&nbsp;&nbsp;&nbsp;
531
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="Save Settings" />
532
</p>
533

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

    
714

    
715

    
716
<?php include("fend.inc"); ?>
717
	    
718
<script type="text/javascript">
719

    
720
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
721
	window.onload = function(in_event)
722
	{		
723
			hideAllWidgets();		    
724
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
725
	}
726
	<?php } ?>
727
	// <![CDATA[
728
	Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});	
729
	Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});		
730
	// ]]>	
731
	
732
	<?php
733
	//build list of javascript include files
734
	$jsincludefiles = array();
735
	$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
</body>
750
</html>
(73-73/211)