Project

General

Profile

Download (23.8 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
	$crash = glob("/var/crash/*");
62
	$x = 0;
63
	$skip_files = array(".", "..", "minfree", "");
64
	if(is_array($crash)) {
65
		foreach($crash as $c) {
66
			if (!in_array(basename($c), $skip_files))
67
				$x++;
68
		}
69
		if($x > 0) 
70
			$savemsg = "{$g['product_name']} has detected a crash report.  Click <a href='crash_reporter.php'>here</a> for more information.";
71
	}
72
}
73

    
74
##build list of widgets
75
$directory = "/usr/local/www/widgets/widgets/";
76
$dirhandle  = opendir($directory);
77
$filename = "";
78
$widgetnames = array();
79
$widgetfiles = array();
80
$widgetlist = array();
81

    
82
while (false !== ($filename = readdir($dirhandle))) {
83
	$periodpos = strpos($filename, ".");
84
	$widgetname = substr($filename, 0, $periodpos);
85
	$widgetnames[] = $widgetname;
86
	if ($widgetname != "system_information")
87
		$widgetfiles[] = $filename;
88
}
89

    
90
##sort widgets alphabetically
91
sort($widgetfiles);
92

    
93
##insert the system information widget as first, so as to be displayed first
94
array_unshift($widgetfiles, "system_information.widget.php");
95

    
96
##if no config entry found, initialize config entry
97
if (!is_array($config['widgets'])) {
98
	$config['widgets'] = array();
99
}
100

    
101
	if ($_POST && $_POST['submit']) {
102
		$config['widgets']['sequence'] = $_POST['sequence'];
103

    
104
		foreach ($widgetnames as $widget){
105
			if ($_POST[$widget . '-config']){
106
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
107
			}
108
		}
109

    
110
		write_config(gettext("Widget configuration has been changed."));
111
		header("Location: index.php");
112
		exit;
113
	}
114

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

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

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

    
156
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
157

    
158
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
159
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
160
		else 
161
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
162

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

    
180

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

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

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

    
250
##begin AJAX
251
$jscriptstr = <<<EOD
252
<script language="javascript" type="text/javascript">
253

    
254

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

    
279

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

    
299
function configureWidget(selectedDiv){
300
	selectIntLink = selectedDiv + "-settings";	
301
	d = document;
302
	textlink = d.getElementById(selectIntLink);
303
	if (textlink.style.display == "none")
304
		Effect.BlindDown(selectIntLink, {duration:1});
305
	else
306
		Effect.BlindUp(selectIntLink, {duration:1});
307
}
308

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

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

    
351
function closeWidget(selectedDiv){	
352
	showSave();
353
	selectedDiv = selectedDiv + "-container";
354
	Effect.Fade(selectedDiv, {duration:1});
355
	d = document;
356
	selectIntLink = selectedDiv + "-input";
357
	textlink = d.getElementById(selectIntLink);
358
	textlink.value = "close";	
359
}
360

    
361
function showSave(){
362
	d = document;
363
	selectIntLink = "submit";
364
	textlink = d.getElementById(selectIntLink);
365
	textlink.style.display = "inline";	
366
}
367

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

    
389
function hideAllWidgets(){		
390
		Effect.Fade('niftyOutter', {to: 0.2});
391
}
392

    
393
function showAllWidgets(){		
394
		Effect.Fade('niftyOutter', {to: 1.0});
395
}
396

    
397

    
398
function changeTabDIV(selectedDiv){
399
	var dashpos = selectedDiv.indexOf("-");
400
	var tabclass = selectedDiv.substring(0,dashpos);
401
	d = document;
402

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

    
440
</script>
441
EOD;
442
$closehead = false;
443

    
444
## Set Page Title and Include Header
445
$pgtitle = array(gettext("Status: Dashboard"));
446
include("head.inc");
447

    
448
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n";
449
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domTT.js\"></script>\n";
450
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/behaviour.js\"></script>\n";
451
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/fadomatic.js\"></script>\n";
452

    
453
?>
454

    
455
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
456
<form action="index.php" method="post">
457
<script language="javascript" type="text/javascript">
458
// <![CDATA[
459
columns = ['col1','col2'];
460
// ]]>
461

    
462
</script>
463

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

    
470
if ($savemsg) 
471
	print_info_box($savemsg); 
472

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

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

    
529
<input type="hidden" value="" name="sequence" id="sequence">
530
<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');" />
531

    
532
<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');" />
533

    
534

    
535
&nbsp;&nbsp;&nbsp;
536
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
537
</p>
538

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

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