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
			Effect.Fade(widget2, {queue:'front'});
280
			Effect.Appear(widget, {queue:'end'});			
281
			jQuery('#' + widget).html(data);
282
	    }	
283
	}
284
	jQuery.ajax(uri, opt);
285
}
286

    
287

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

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

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

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

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

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

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

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

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

    
405

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

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

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

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

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

    
461
?>
462

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

    
470
</script>
471

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

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

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

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

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

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

    
544

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

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

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