Project

General

Profile

Download (24.1 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
	    type: 'get',
265
		evalScripts: 'true',
266
	    async: true,
267
	    // Handle 404
268
	    statusCode: {
269
	        404: function(t) {
270
	            alert('Error 404: location "' + t.statusText + '" was not found.');
271
	        }
272
	    },
273
	    // Handle other errors
274
	    error: function(t) {
275
	        alert('Error ' + t.status + ' -- ' + t.statusText);
276
	    },
277
		success: function(data) {
278
			widget2 = '#' + widget + "-loader";
279
			jQuery(widget2).fadeOut(1000,function(){
280
				jQuery('#' + widget).show();
281
			});
282
			jQuery('#' + widget).html(data);
283
	    }	
284
	}
285
	jQuery.ajax(uri, opt);
286
}
287

    
288

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

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

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

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

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

    
370
function showSave(){
371
	d = document;
372
	selectIntLink = "submit";
373
	textlink = d.getElementById(selectIntLink);
374
	textlink.style.display = "inline";	
375
}
376

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

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

    
402
function showAllWidgets(){		
403
		Effect.Fade('niftyOutter', {to: 1.0});
404
}
405

    
406

    
407
function changeTabDIV(selectedDiv){
408
	var dashpos = selectedDiv.indexOf("-");
409
	var tabclass = selectedDiv.substring(0,dashpos);
410
	d = document;
411

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

    
449
</script>
450
EOD;
451
$closehead = false;
452

    
453
## Set Page Title and Include Header
454
$pgtitle = array(gettext("Status: Dashboard"));
455
include("head.inc");
456

    
457
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n";
458
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domTT.js\"></script>\n";
459
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/behaviour.js\"></script>\n";
460
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/fadomatic.js\"></script>\n";
461

    
462
?>
463

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

    
471
</script>
472

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

    
479
if ($savemsg) 
480
	print_info_box($savemsg); 
481

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

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

    
540
<input type="hidden" value="" name="sequence" id="sequence">
541
<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');" />
542

    
543
<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');" />
544

    
545

    
546
&nbsp;&nbsp;&nbsp;
547
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
548
</p>
549

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

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