Project

General

Profile

Download (24 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
if($g['disablecrashreporter'] != true) {
60
	// Check to see if we have a crash report
61
	$x = 0;
62
	if(file_exists("/tmp/PHP_errors.log")) {
63
		$total = `/bin/cat /tmp/PHP_errors.log | /usr/bin/grep -vi warning | wc -l | awk '{ print $1 }'`;
64
		if($total > 0) 
65
			$x++;
66
	}
67
	$crash = glob("/var/crash/*");
68
	$skip_files = array(".", "..", "minfree", "");
69
	if(is_array($crash)) {
70
		foreach($crash as $c) {
71
			if (!in_array(basename($c), $skip_files))
72
				$x++;
73
		}
74
		if($x > 0) 
75
			$savemsg = "{$g['product_name']} has detected a crash report or programming bug.  Click <a href='crash_reporter.php'>here</a> for more information.";
76
	}
77
}
78

    
79
##build list of widgets
80
$directory = "/usr/local/www/widgets/widgets/";
81
$dirhandle  = opendir($directory);
82
$filename = "";
83
$widgetnames = array();
84
$widgetfiles = array();
85
$widgetlist = array();
86

    
87
while (false !== ($filename = readdir($dirhandle))) {
88
	$periodpos = strpos($filename, ".");
89
	$widgetname = substr($filename, 0, $periodpos);
90
	$widgetnames[] = $widgetname;
91
	if ($widgetname != "system_information")
92
		$widgetfiles[] = $filename;
93
}
94

    
95
##sort widgets alphabetically
96
sort($widgetfiles);
97

    
98
##insert the system information widget as first, so as to be displayed first
99
array_unshift($widgetfiles, "system_information.widget.php");
100

    
101
##if no config entry found, initialize config entry
102
if (!is_array($config['widgets'])) {
103
	$config['widgets'] = array();
104
}
105

    
106
	if ($_POST && $_POST['submit']) {
107
		$config['widgets']['sequence'] = $_POST['sequence'];
108

    
109
		foreach ($widgetnames as $widget){
110
			if ($_POST[$widget . '-config']){
111
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
112
			}
113
		}
114

    
115
		write_config(gettext("Widget configuration has been changed."));
116
		header("Location: index.php");
117
		exit;
118
	}
119

    
120
	## Load Functions Files
121
	require_once('includes/functions.inc.php');
122
	
123
	## Check to see if we have a swap space,
124
	## if true, display, if false, hide it ...
125
	if(file_exists("/usr/sbin/swapinfo")) {
126
		$swapinfo = `/usr/sbin/swapinfo`;
127
		if(stristr($swapinfo,'%') == true) $showswap=true;
128
	}
129

    
130
	## User recently restored his config.
131
	## If packages are installed lets resync
132
	if(file_exists('/conf/needs_package_sync')) {
133
		if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
134
			if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
135
				header('Location: pkg_mgr_install.php?mode=reinstallall');
136
				exit;
137
			}
138
		} else {
139
			conf_mount_rw();
140
			@unlink('/conf/needs_package_sync');
141
			conf_mount_ro();
142
		}
143
	}
144

    
145
	## If it is the first time webConfigurator has been
146
	## accessed since initial install show this stuff.
147
	if(file_exists('/conf/trigger_initial_wizard')) {
148
		echo <<<EOF
149
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
150
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
151
<html>
152
<head>
153
	<title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title>
154
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
155
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
156
	<script type="text/javascript">var theme = "nervecenter"</script>
157
	<script type="text/javascript" src="/themes/nervecenter/loader.js"></script>
158
		
159
EOF;
160

    
161
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
162

    
163
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
164
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
165
		else 
166
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
167

    
168
		echo "<form>\n";
169
		echo "<center>\n";
170
		echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
171
		echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
172
		echo sprintf(gettext("Welcome to %s!\n"),$g['product_name']) . "<p>";
173
		echo gettext("One moment while we start the initial setup wizard.") . "<p>\n";
174
		echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n";
175
		echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name']) . "\n";
176
		echo "</div>\n";
177
		echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
178
		echo "<script type=\"text/javascript\">\n";
179
		echo "NiftyCheck();\n";
180
		echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
181
		echo "</script>\n";
182
		exit;
183
	}
184

    
185

    
186
	## Find out whether there's hardware encryption or not
187
	unset($hwcrypto);
188
	$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
189
	if ($fd) {
190
		while (!feof($fd)) {
191
			$dmesgl = fgets($fd);
192
			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)) {
193
				$hwcrypto = $matches[1];
194
				break;
195
			}
196
		}
197
		fclose($fd);
198
	}
199

    
200
##build widget saved list information
201
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
202
	$pconfig['sequence'] = $config['widgets']['sequence'];
203
	
204
	$widgetlist = $pconfig['sequence'];
205
	$colpos = array();
206
	$savedwidgetfiles = array();
207
	$widgetname = "";
208
	$widgetlist = explode(",",$widgetlist);
209
	
210
	##read the widget position and display information
211
	foreach ($widgetlist as $widget){
212
		$dashpos = strpos($widget, "-");		
213
		$widgetname = substr($widget, 0, $dashpos);
214
		$colposition = strpos($widget, ":");		
215
		$displayposition = strrpos($widget, ":");
216
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
217
		$displayarray[] = substr($widget,$displayposition+1);
218
		$savedwidgetfiles[] = $widgetname . ".widget.php";
219
	}
220
	
221
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
222
    foreach ($widgetfiles as $defaultwidgets){         
223
         if (!in_array($defaultwidgets, $savedwidgetfiles)){
224
             $savedwidgetfiles[] = $defaultwidgets;
225
         }
226
     }   
227
	
228
	##find custom configurations of a particular widget and load its info to $pconfig
229
	foreach ($widgetnames as $widget){
230
        if ($config['widgets'][$widget . '-config']){
231
            $pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
232
        }
233
    }   
234
	
235
	$widgetlist = $savedwidgetfiles;	
236
} else{
237
	// no saved widget sequence found, build default list.
238
	$widgetlist = $widgetfiles;
239
}
240

    
241
##build list of php include files
242
$phpincludefiles = array();
243
$directory = "/usr/local/www/widgets/include/";
244
$dirhandle  = opendir($directory);
245
$filename = "";
246
while (false !== ($filename = readdir($dirhandle))) {
247
	$phpincludefiles[] = $filename;
248
}
249
foreach($phpincludefiles as $includename) {
250
	if(!stristr($includename, ".inc"))
251
		continue;	
252
	include($directory . $includename);
253
}
254

    
255
##begin AJAX
256
$jscriptstr = <<<EOD
257
<script language="javascript" type="text/javascript">
258

    
259

    
260
function widgetAjax(widget) {	
261
	uri = "widgets/widgets/" + widget + ".widget.php";
262
	var opt = {
263
	    // Use GET
264
	    method: 'get',
265
		evalScripts: 'true',
266
	    asynchronous: true,
267
	    // Handle 404
268
	    on404: function(t) {
269
	        alert('Error 404: location "' + t.statusText + '" was not found.');
270
	    },
271
	    // Handle other errors
272
	    onFailure: function(t) {
273
	        alert('Error ' + t.status + ' -- ' + t.statusText);
274
	    },
275
		onSuccess: function(t) {
276
			widget2 = widget + "-loader";
277
			Effect.Fade(widget2, {queue:'front'});
278
			Effect.Appear(widget, {queue:'end'});			
279
	    }	
280
	}
281
	new Ajax.Updater(widget, uri, opt);
282
}
283

    
284

    
285
function addWidget(selectedDiv){	
286
	selectedDiv2 = selectedDiv + "-container";
287
	d = document;
288
	textlink = d.getElementById(selectedDiv2);
289
	Effect.Appear(selectedDiv2, {duration:1});
290
	if (textlink.style.display != "none")
291
	{
292
		Effect.Shake(selectedDiv2);	
293
	}
294
	else
295
	{
296
		widgetAjax(selectedDiv);
297
		selectIntLink = selectedDiv2 + "-input";
298
		textlink = d.getElementById(selectIntLink);
299
		textlink.value = "show";	
300
		showSave();
301
	}
302
}
303

    
304
function configureWidget(selectedDiv){
305
	selectIntLink = selectedDiv + "-settings";	
306
	d = document;
307
	textlink = d.getElementById(selectIntLink);
308
	if (textlink.style.display == "none")
309
		Effect.BlindDown(selectIntLink, {duration:1});
310
	else
311
		Effect.BlindUp(selectIntLink, {duration:1});
312
}
313

    
314
function showWidget(selectedDiv,swapButtons){
315
	//appear element
316
    Effect.BlindDown(selectedDiv, {duration:1});      
317
    showSave();    
318
	d = document;	
319
    if (swapButtons){
320
	    selectIntLink = selectedDiv + "-min";
321
		textlink = d.getElementById(selectIntLink);
322
		textlink.style.display = "inline";
323
	    
324
	    
325
	    selectIntLink = selectedDiv + "-open";
326
		textlink = d.getElementById(selectIntLink);
327
		textlink.style.display = "none";
328

    
329
    }
330
	selectIntLink = selectedDiv + "-container-input";
331
	textlink = d.getElementById(selectIntLink);
332
	textlink.value = "show";	
333
    
334
}
335
	
336
function minimizeWidget(selectedDiv,swapButtons){
337
	//fade element
338
    Effect.BlindUp(selectedDiv, {duration:1});      
339
    showSave();
340
	d = document;	
341
    if (swapButtons){
342
	    selectIntLink = selectedDiv + "-open";
343
		textlink = d.getElementById(selectIntLink);
344
		textlink.style.display = "inline";	    
345
	    
346
	    selectIntLink = selectedDiv + "-min";
347
		textlink = d.getElementById(selectIntLink);
348
		textlink.style.display = "none";
349
    }  		
350
	selectIntLink = selectedDiv + "-container-input";
351
	textlink = d.getElementById(selectIntLink);
352
	textlink.value = "hide";	  
353
    
354
}
355

    
356
function closeWidget(selectedDiv){	
357
	showSave();
358
	selectedDiv = selectedDiv + "-container";
359
	Effect.Fade(selectedDiv, {duration:1});
360
	d = document;
361
	selectIntLink = selectedDiv + "-input";
362
	textlink = d.getElementById(selectIntLink);
363
	textlink.value = "close";	
364
}
365

    
366
function showSave(){
367
	d = document;
368
	selectIntLink = "submit";
369
	textlink = d.getElementById(selectIntLink);
370
	textlink.style.display = "inline";	
371
}
372

    
373
function updatePref(){	
374
	var widgets = document.getElementsByClassName('widgetdiv');
375
	var widgetSequence = "";
376
	var firstprint = false;	
377
	d = document;
378
	for (i=0; i<widgets.length; i++){
379
		if (firstprint)
380
			widgetSequence += ",";
381
		var widget = widgets[i].id;
382
		widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
383
		widget = widget + "-input";
384
		textlink = d.getElementById(widget).value;
385
		widgetSequence += textlink;
386
		firstprint = true;		
387
	}
388
	selectLink = "sequence";
389
	textlink = d.getElementById(selectLink);
390
	textlink.value = widgetSequence;
391
	return true;	
392
}
393

    
394
function hideAllWidgets(){		
395
		Effect.Fade('niftyOutter', {to: 0.2});
396
}
397

    
398
function showAllWidgets(){		
399
		Effect.Fade('niftyOutter', {to: 1.0});
400
}
401

    
402

    
403
function changeTabDIV(selectedDiv){
404
	var dashpos = selectedDiv.indexOf("-");
405
	var tabclass = selectedDiv.substring(0,dashpos);
406
	d = document;
407

    
408
	//get deactive tabs first
409
	tabclass = tabclass + "-class-tabdeactive"; 
410
	var tabs = document.getElementsByClassName(tabclass);
411
	var incTabSelected = selectedDiv + "-deactive";
412
	for (i=0; i<tabs.length; i++){
413
		var tab = tabs[i].id;
414
		dashpos = tab.lastIndexOf("-");
415
		var tab2 = tab.substring(0,dashpos) + "-deactive";
416
		if (tab2 == incTabSelected){
417
			tablink = d.getElementById(tab2);
418
			tablink.style.display = "none";
419
			tab2 = tab.substring(0,dashpos) + "-active";
420
			tablink = d.getElementById(tab2);
421
			tablink.style.display = "table-cell";
422
			
423
			//now show main div associated with link clicked
424
			tabmain = d.getElementById(selectedDiv);
425
			tabmain.style.display = "block";
426
		}
427
		else
428
		{	
429
			tab2 = tab.substring(0,dashpos) + "-deactive";
430
			tablink = d.getElementById(tab2);
431
			tablink.style.display = "table-cell";
432
			tab2 = tab.substring(0,dashpos) + "-active";
433
			tablink = d.getElementById(tab2);
434
			tablink.style.display = "none";		
435
			
436
			//hide sections we don't want to see
437
			tab2 = tab.substring(0,dashpos);
438
			tabmain = d.getElementById(tab2);
439
			tabmain.style.display = "none";
440
				
441
		}
442
	}	
443
}
444

    
445
</script>
446
EOD;
447
$closehead = false;
448

    
449
## Set Page Title and Include Header
450
$pgtitle = array(gettext("Status: Dashboard"));
451
include("head.inc");
452

    
453
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n";
454
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domTT.js\"></script>\n";
455
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/behaviour.js\"></script>\n";
456
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/fadomatic.js\"></script>\n";
457

    
458
?>
459

    
460
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
461
<form action="index.php" method="post">
462
<script language="javascript" type="text/javascript">
463
// <![CDATA[
464
columns = ['col1','col2'];
465
// ]]>
466

    
467
</script>
468

    
469
<?php
470
include("fbegin.inc");
471
echo $jscriptstr;
472
	if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
473
		echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
474

    
475
if ($savemsg) 
476
	print_info_box($savemsg); 
477

    
478
?>
479
<div id="widgetcontainer" style="display:none">
480
		<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
481
			$widgetfiles_add = $widgetfiles;
482
			sort($widgetfiles_add);
483
			foreach($widgetfiles_add as $widget) {			
484
				if(!stristr($widget, "widget.php"))
485
					continue;		
486
				
487
				$periodpos = strpos($widget, ".");
488
				$widgetname = substr($widget, 0, $periodpos);
489
				$nicename = $widgetname;
490
				$nicename = str_replace("_", " ", $nicename);
491
				//make the title look nice
492
				$nicename = ucwords($nicename);
493
				
494
				$widgettitle = $widgetname . "_title";
495
				$widgettitlelink = $widgetname . "_title_link";
496
					if ($$widgettitle != "")
497
					{
498
						//echo widget title 
499
						?>
500
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
501
						<u><?php echo $$widgettitle; ?></u></span><br>
502
						<?php 
503
					}
504
					else {?>
505
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
506
						<u><?php echo $nicename; ?></u></span><br><?php
507
					}
508
			}
509
		?>
510
		</p>
511
	</div>
512
</div>
513

    
514
<div id="welcomecontainer" style="display:none">
515
		<div id="welcome-container">
516
			<h1>
517
				<div style="float:left;width:80%;padding: 2px">
518
					<?=gettext("Welcome to the Dashboard page"); ?>!
519
				</div>
520
				<div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" >
521
					<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" />
522
				</div>
523
				<div style="clear:both;"></div>
524
			</h1>
525
			<p>
526
			<?=gettext("This page allows you to customize the information you want to be displayed!");?><br/>
527
			<?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> <?=gettext("icon to add widgets.");?><br/>
528
			<br/>
529
			<?=gettext("You can move any widget around by clicking and dragging the title.");?>			
530
			</p>
531
	</div>
532
</div>
533

    
534
<input type="hidden" value="" name="sequence" id="sequence">
535
<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');" />
536

    
537
<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');" />
538

    
539

    
540
&nbsp;&nbsp;&nbsp;
541
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
542
</p>
543

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

    
716
<?php include("fend.inc"); ?>
717
	    
718
<script type="text/javascript">
719
	document.observe('dom:loaded', function(in_event)
720
	{		
721
			Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});	
722
			Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});		
723
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
724
			hideAllWidgets();		    
725
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
726
	<?php } ?>
727
	});
728
</script>
729
<?php
730
	//build list of javascript include files
731
	$jsincludefiles = array();
732
	$directory = "widgets/javascript/";
733
	$dirhandle  = opendir($directory);
734
	$filename = "";
735
	while (false !== ($filename = readdir($dirhandle))) {
736
   		$jsincludefiles[] = $filename;
737
	}
738
	foreach($jsincludefiles as $jsincludename) {
739
		if(!stristr($jsincludename, ".js"))
740
			continue;
741
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";	
742
	}
743
?>
744
</script>
745
</form>
746
</body>
747
</html>
(86-86/232)