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
	$x = 0;
62
	if(file_exists("/tmp/PHP_errors.log")) {
63
		$total = `/usr/bin/grep -vi warning /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/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
	    async: true,
266
	    // Handle 404
267
	    statusCode: {
268
	        404: function(t) {
269
	            alert('Error 404: location "' + t.statusText + '" was not found.');
270
	        }
271
	    },
272
	    // Handle other errors
273
	    error: function(t) {
274
	        alert('Error ' + t.status + ' -- ' + t.statusText);
275
	    },
276
		success: function(data) {
277
			widget2 = '#' + widget + "-loader";
278
			jQuery(widget2).fadeOut(1000,function(){
279
				jQuery('#' + widget).show();
280
			});
281
			jQuery('#' + widget).html(data);
282
	    }
283
	}
284
	jQuery.ajax(uri, opt);
285
}
286

    
287

    
288
function addWidget(selectedDiv){
289
	selectedDiv2 = '#' + selectedDiv + "-container";
290
	if (jQuery(selectedDiv2).css('display') != "none")
291
	{
292
		jQuery(selectedDiv2).effect('shake',{times: 2}, 100);
293
	}
294
	else
295
	{
296
		jQuery(selectedDiv2).show('blind');
297
		widgetAjax(selectedDiv);
298
		selectIntLink = selectedDiv2 + "-input";
299
		jQuery(selectIntLink).val("show");
300
		showSave();
301
	}
302
}
303

    
304
function configureWidget(selectedDiv){
305
	selectIntLink = '#' + selectedDiv + "-settings";
306
	if (jQuery(selectIntLink).css('display') == "none")
307
		jQuery(selectIntLink).show();
308
	else
309
		jQuery(selectIntLink).hide();
310
}
311

    
312
function showWidget(selectedDiv,swapButtons){
313
	//appear element
314
    jQuery('#' + selectedDiv).show('blind');
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
    jQuery('#' + selectedDiv).hide('blind');
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
	selectedDiv2 = "#" + selectedDiv + "-container";
357
	jQuery(selectedDiv2).hide('blind');
358
	selectIntLink = "#" + selectedDiv + "-container-input";
359
	jQuery(selectIntLink).val("close");
360
}
361

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

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

    
390
function hideAllWidgets(){
391
		jQuery('#niftyOutter').fadeTo('slow',0.2);
392
}
393

    
394
function showAllWidgets(){
395
		jQuery('#niftyOutter').fadeTo('slow',1.0);
396
}
397

    
398

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

    
404
	//get deactive tabs first
405
	tabclass = tabclass + "-class-tabdeactive"; 
406
	var tabs = document.getElementsByClassName(tabclass);
407
	var incTabSelected = selectedDiv + "-deactive";
408
	for (i=0; i<tabs.length; i++){
409
		var tab = tabs[i].id;
410
		dashpos = tab.lastIndexOf("-");
411
		var tab2 = tab.substring(0,dashpos) + "-deactive";
412
		if (tab2 == incTabSelected){
413
			tablink = d.getElementById(tab2);
414
			tablink.style.display = "none";
415
			tab2 = tab.substring(0,dashpos) + "-active";
416
			tablink = d.getElementById(tab2);
417
			tablink.style.display = "table-cell";
418

    
419
			//now show main div associated with link clicked
420
			tabmain = d.getElementById(selectedDiv);
421
			tabmain.style.display = "block";
422
		}
423
		else
424
		{
425
			tab2 = tab.substring(0,dashpos) + "-deactive";
426
			tablink = d.getElementById(tab2);
427
			tablink.style.display = "table-cell";
428
			tab2 = tab.substring(0,dashpos) + "-active";
429
			tablink = d.getElementById(tab2);
430
			tablink.style.display = "none";
431

    
432
			//hide sections we don't want to see
433
			tab2 = tab.substring(0,dashpos);
434
			tabmain = d.getElementById(tab2);
435
			tabmain.style.display = "none";
436

    
437
		}
438
	}
439
}
440

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

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

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

    
454
?>
455

    
456
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
457

    
458
<script language="javascript" type="text/javascript">
459
// <![CDATA[
460
columns = ['col1','col2'];
461
// ]]>
462

    
463
</script>
464

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

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

    
474
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
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
<form action="index.php" method="post">
533
<input type="hidden" value="" name="sequence" id="sequence">
534
<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');" />
535

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

    
538

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

    
715
<?php include("fend.inc"); ?>
716
	    
717
<script type="text/javascript">
718
	jQuery(document).ready(function(in_event)
719
	{		
720
			jQuery('#col1').sortable({connectWith: '#col2', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
721
			jQuery('#col2').sortable({connectWith: '#col1', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
722

    
723
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
724
			hideAllWidgets();		    
725
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
726
	<?php } ?>
727
	});
728
</script>
729
<?php
730
	//build list of javascript include files
731
	$jsincludefiles = array();
732
	$directory = "widgets/javascript/";
733
	$dirhandle  = opendir($directory);
734
	$filename = "";
735
	while (false !== ($filename = readdir($dirhandle))) {
736
   		$jsincludefiles[] = $filename;
737
	}
738
	foreach($jsincludefiles as $jsincludename) {
739
		if(!stristr($jsincludename, ".js"))
740
			continue;
741
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";	
742
	}
743
?>
744
</script>
745

    
746
</body>
747
</html>
(91-91/249)