Project

General

Profile

Download (23.7 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
$crash = glob("/var/crash/*");
46
$x = 0;
47
if(is_array($crash)) {
48
	foreach($crash as $c) {
49
		if($c == "minfree")
50
			continue;
51
		if($c == ".")
52
			continue;
53
		if($c == "..")
54
			continue;
55
		if($c == "")
56
			continue;
57
		$x++;
58
	}
59
	if($x > 0) 
60
		$savemsg = "We have detected a crash report.  Click <a href='crash_reporter.php'>here</a> for more information.";
61
}
62

    
63
// Turn off csrf for the dashboard
64
$nocsrf = true; 
65

    
66
// Turn on buffering to speed up rendering
67
ini_set('output_buffering','true');
68

    
69
// Start buffering with a cache size of 100000
70
ob_start(null, "1000");
71

    
72
## Load Essential Includes
73
require_once('functions.inc');
74
require_once('guiconfig.inc');
75
require_once('notices.inc');
76

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

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

    
93
##sort widgets alphabetically
94
sort($widgetfiles);
95

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

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

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

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

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

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

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

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

    
159
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
160

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

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

    
183

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

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

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

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

    
257

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

    
282

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

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

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

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

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

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

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

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

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

    
400

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

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

    
443
</script>
444
EOD;
445
$closehead = false;
446

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

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

    
456
?>
457

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

    
465
</script>
466

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

    
473
if ($savemsg) 
474
	print_info_box($savemsg); 
475

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

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

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

    
535
<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');" />
536

    
537

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

    
542
<div id="niftyOutter">
543
	<?php
544
	$totalwidgets = count($widgetfiles);
545
	$halftotal = $totalwidgets / 2 - 2;
546
	$widgetcounter = 0;
547
	$directory = "/usr/local/www/widgets/widgets/";
548
	$printed = false;
549
	$firstprint = false;
550
	?> 
551
	<div id="col1" style="float:left;width:49%;padding-bottom:40px">		
552
	<?php	
553
		
554
	foreach($widgetlist as $widget) {
555
		
556
		if(!stristr($widget, "widget.php"))
557
					continue;
558
		$periodpos = strpos($widget, ".");
559
		$widgetname = substr($widget, 0, $periodpos);	
560
		if ($widgetname != ""){
561
			$nicename = $widgetname;
562
			$nicename = str_replace("_", " ", $nicename);
563
			
564
			//make the title look nice
565
			$nicename = ucwords($nicename);
566
		}
567
		
568
		if ($config['widgets'] && $pconfig['sequence'] != ""){
569
			switch($displayarray[$widgetcounter]){
570
				case "show":
571
					$divdisplay = "block";
572
					$display = "block";
573
					$inputdisplay = "show";					
574
					$showWidget = "none";
575
					$mindiv = "inline";
576
					break;
577
				case "hide":
578
					$divdisplay = "block";
579
					$display = "none";
580
					$inputdisplay = "hide";		
581
					$showWidget = "inline";
582
					$mindiv = "none";
583
					break;
584
				case "close":
585
					$divdisplay = "none";
586
					$display = "block";
587
					$inputdisplay = "close";			
588
					$showWidget = "none";
589
					$mindiv = "inline";
590
					break;
591
				default:
592
					$divdisplay = "none";
593
					$display = "block";
594
					$inputdisplay = "none";
595
					$showWidget = "none";
596
					$mindiv = "inline";
597
					break;
598
			}
599
		} else {
600
			if ($firstprint == false){
601
				$divdisplay = "block";
602
				$display = "block";
603
				$inputdisplay = "show";
604
				$showWidget = "none";
605
				$mindiv = "inline";
606
				$firstprint = true;
607
			} else {
608
				switch ($widget) {
609
					case "interfaces.widget.php":
610
					case "traffic_graphs.widget.php":
611
						$divdisplay = "block";
612
						$display = "block";
613
						$inputdisplay = "show";
614
						$showWidget = "none";
615
						$mindiv = "inline";
616
						break;
617
					default:
618
						$divdisplay = "none";
619
						$display = "block";
620
						$inputdisplay = "close";
621
						$showWidget = "none";
622
						$mindiv = "inline";
623
						break;
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="<?=gettext("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
<?php include("fend.inc"); ?>
715
	    
716
<script type="text/javascript">
717
	document.observe('dom:loaded', function(in_event)
718
	{		
719
			Sortable.create("col1", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});	
720
			Sortable.create("col2", {tag:'div',dropOnEmpty:true,containment:columns,handle:'widgetheader',constraint:false,only:'widgetdiv',onChange:showSave});		
721
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
722
			hideAllWidgets();		    
723
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
724
	<?php } ?>
725
	});
726
</script>
727
<?php
728
	//build list of javascript include files
729
	$jsincludefiles = array();
730
	$directory = "widgets/javascript/";
731
	$dirhandle  = opendir($directory);
732
	$filename = "";
733
	while (false !== ($filename = readdir($dirhandle))) {
734
   		$jsincludefiles[] = $filename;
735
	}
736
	foreach($jsincludefiles as $jsincludename) {
737
		if(!stristr($jsincludename, ".js"))
738
			continue;
739
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";	
740
	}
741
?>
742
</script>
743
</form>
744
</body>
745
</html>
(82-82/224)