Project

General

Profile

Download (24 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    index.php
5
    Copyright (C) 2004-2012 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

    
55
## Load Essential Includes
56
require_once('functions.inc');
57
require_once('guiconfig.inc');
58
require_once('notices.inc');
59

    
60
if(isset($_REQUEST['closenotice'])){
61
	close_notice($_REQUEST['closenotice']);
62
	echo get_menu_messages();
63
	exit;
64
}
65
if ($_REQUEST['act'] == 'alias_info_popup' && !preg_match("/\D/",$_REQUEST['aliasid'])){
66
	alias_info_popup($_REQUEST['aliasid']);
67
	exit;
68
}
69

    
70
if($g['disablecrashreporter'] != true) {
71
	// Check to see if we have a crash report
72
	$x = 0;
73
	if(file_exists("/tmp/PHP_errors.log")) {
74
		$total = `/usr/bin/grep -vi warning /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
75
		if($total > 0) 
76
			$x++;
77
	}
78
	$crash = glob("/var/crash/*");
79
	$skip_files = array(".", "..", "minfree", "");
80
	if(is_array($crash)) {
81
		foreach($crash as $c) {
82
			if (!in_array(basename($c), $skip_files))
83
				$x++;
84
		}
85
		if($x > 0) 
86
			$savemsg = "{$g['product_name']} has detected a crash report or programming bug.  Click <a href='crash_reporter.php'>here</a> for more information.";
87
	}
88
}
89

    
90
##build list of widgets
91
$directory = "/usr/local/www/widgets/widgets/";
92
$dirhandle  = opendir($directory);
93
$filename = "";
94
$widgetnames = array();
95
$widgetfiles = array();
96
$widgetlist = array();
97

    
98
while (false !== ($filename = readdir($dirhandle))) {
99
	$periodpos = strpos($filename, ".");
100
	/* Ignore files not ending in .php */
101
	if (substr($filename, -4, 4) != ".php")
102
		continue;
103
	$widgetname = substr($filename, 0, $periodpos);
104
	$widgetnames[] = $widgetname;
105
	if ($widgetname != "system_information")
106
		$widgetfiles[] = $filename;
107
}
108

    
109
##sort widgets alphabetically
110
sort($widgetfiles);
111

    
112
##insert the system information widget as first, so as to be displayed first
113
array_unshift($widgetfiles, "system_information.widget.php");
114

    
115
##if no config entry found, initialize config entry
116
if (!is_array($config['widgets'])) {
117
	$config['widgets'] = array();
118
}
119

    
120
	if ($_POST && $_POST['submit']) {
121
		$config['widgets']['sequence'] = $_POST['sequence'];
122

    
123
		foreach ($widgetnames as $widget){
124
			if ($_POST[$widget . '-config']){
125
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
126
			}
127
		}
128

    
129
		write_config(gettext("Widget configuration has been changed."));
130
		header("Location: index.php");
131
		exit;
132
	}
133

    
134
	## Load Functions Files
135
	require_once('includes/functions.inc.php');
136
	
137
	## Check to see if we have a swap space,
138
	## if true, display, if false, hide it ...
139
	if(file_exists("/usr/sbin/swapinfo")) {
140
		$swapinfo = `/usr/sbin/swapinfo`;
141
		if(stristr($swapinfo,'%') == true) $showswap=true;
142
	}
143

    
144
	## User recently restored his config.
145
	## If packages are installed lets resync
146
	if(file_exists('/conf/needs_package_sync')) {
147
		if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
148
			if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
149
				header('Location: pkg_mgr_install.php?mode=reinstallall');
150
				exit;
151
			}
152
		} else {
153
			conf_mount_rw();
154
			@unlink('/conf/needs_package_sync');
155
			conf_mount_ro();
156
		}
157
	}
158

    
159
	## If it is the first time webConfigurator has been
160
	## accessed since initial install show this stuff.
161
	if(file_exists('/conf/trigger_initial_wizard')) {
162
		echo <<<EOF
163
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
164
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
165
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
166
<head>
167
	<title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title>
168
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
169
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
170
	<script type="text/javascript">var theme = "nervecenter"</script>
171
	<script type="text/javascript" src="/themes/nervecenter/loader.js"></script>
172
		
173
EOF;
174

    
175
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
176

    
177
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
178
			echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
179
		else 
180
			echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
181

    
182
		echo "<form>\n";
183
		echo "<center>\n";
184
		echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\" alt=\"logo\" /><p>\n";
185
		echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
186
		echo sprintf(gettext("Welcome to %s!\n"),$g['product_name']) . "<p>";
187
		echo gettext("One moment while we start the initial setup wizard.") . "<p>\n";
188
		echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n";
189
		echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name']) . "\n";
190
		echo "</div>\n";
191
		echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
192
		echo "<script type=\"text/javascript\">\n";
193
		echo "//<![CDATA[\n";
194
		echo "NiftyCheck();\n";
195
		echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
196
		echo "//]]>\n";
197
		echo "</script>\n";
198
		exit;
199
	}
200

    
201

    
202
	## Find out whether there's hardware encryption or not
203
	unset($hwcrypto);
204
	$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
205
	if ($fd) {
206
		while (!feof($fd)) {
207
			$dmesgl = fgets($fd);
208
			if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
209
				or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
210
				or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
211
				or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
212
				or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
213
				or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
214
				or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
215
				$hwcrypto = $matches[1];
216
				break;
217
			}
218
		}
219
		fclose($fd);
220
	}
221

    
222
##build widget saved list information
223
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
224
	$pconfig['sequence'] = $config['widgets']['sequence'];
225
	
226
	$widgetlist = $pconfig['sequence'];
227
	$colpos = array();
228
	$savedwidgetfiles = array();
229
	$widgetname = "";
230
	$widgetlist = explode(",",$widgetlist);
231
	
232
	##read the widget position and display information
233
	foreach ($widgetlist as $widget){
234
		$dashpos = strpos($widget, "-");		
235
		$widgetname = substr($widget, 0, $dashpos);
236
		$colposition = strpos($widget, ":");		
237
		$displayposition = strrpos($widget, ":");
238
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
239
		$displayarray[] = substr($widget,$displayposition+1);
240
		$savedwidgetfiles[] = $widgetname . ".widget.php";
241
	}
242
	
243
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
244
    foreach ($widgetfiles as $defaultwidgets){         
245
         if (!in_array($defaultwidgets, $savedwidgetfiles)){
246
             $savedwidgetfiles[] = $defaultwidgets;
247
         }
248
     }   
249
	
250
	##find custom configurations of a particular widget and load its info to $pconfig
251
	foreach ($widgetnames as $widget){
252
        if ($config['widgets'][$widget . '-config']){
253
            $pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
254
        }
255
    }   
256
	
257
	$widgetlist = $savedwidgetfiles;	
258
} else{
259
	// no saved widget sequence found, build default list.
260
	$widgetlist = $widgetfiles;
261
}
262

    
263
##build list of php include files
264
$phpincludefiles = array();
265
$directory = "/usr/local/www/widgets/include/";
266
$dirhandle  = opendir($directory);
267
$filename = "";
268
while (false !== ($filename = readdir($dirhandle))) {
269
	$phpincludefiles[] = $filename;
270
}
271
foreach($phpincludefiles as $includename) {
272
	if(!stristr($includename, ".inc"))
273
		continue;	
274
	include($directory . $includename);
275
}
276

    
277
##begin AJAX
278
$jscriptstr = <<<EOD
279
<script type="text/javascript">
280
//<![CDATA[
281

    
282
function widgetAjax(widget) {
283
	uri = "widgets/widgets/" + widget + ".widget.php";
284
	var opt = {
285
	    // Use GET
286
	    type: 'get',
287
	    async: true,
288
	    // Handle 404
289
	    statusCode: {
290
	        404: function(t) {
291
	            alert('Error 404: location "' + t.statusText + '" was not found.');
292
	        }
293
	    },
294
	    // Handle other errors
295
	    error: function(t) {
296
	        alert('Error ' + t.status + ' -- ' + t.statusText);
297
	    },
298
		success: function(data) {
299
			widget2 = '#' + widget + "-loader";
300
			jQuery(widget2).fadeOut(1000,function(){
301
				jQuery('#' + widget).show();
302
			});
303
			jQuery('#' + widget).html(data);
304
	    }
305
	}
306
	jQuery.ajax(uri, opt);
307
}
308

    
309

    
310
function addWidget(selectedDiv){
311
	selectedDiv2 = '#' + selectedDiv + "-container";
312
	if (jQuery(selectedDiv2).css('display') != "none")
313
	{
314
		jQuery(selectedDiv2).effect('shake',{times: 2}, 100);
315
	}
316
	else
317
	{
318
		jQuery(selectedDiv2).show('blind');
319
		widgetAjax(selectedDiv);
320
		selectIntLink = selectedDiv2 + "-input";
321
		jQuery(selectIntLink).val("show");
322
		showSave();
323
	}
324
}
325

    
326
function configureWidget(selectedDiv){
327
	selectIntLink = '#' + selectedDiv + "-settings";
328
	if (jQuery(selectIntLink).css('display') == "none")
329
		jQuery(selectIntLink).show();
330
	else
331
		jQuery(selectIntLink).hide();
332
}
333

    
334
function showWidget(selectedDiv,swapButtons){
335
	//appear element
336
    jQuery('#' + selectedDiv).show('blind');
337
    showSave();    
338
	d = document;
339
    if (swapButtons){
340
	    selectIntLink = selectedDiv + "-min";
341
		textlink = d.getElementById(selectIntLink);
342
		textlink.style.display = "inline";
343
	    
344
	    
345
	    selectIntLink = selectedDiv + "-open";
346
		textlink = d.getElementById(selectIntLink);
347
		textlink.style.display = "none";
348

    
349
    }
350
	selectIntLink = selectedDiv + "-container-input";
351
	textlink = d.getElementById(selectIntLink);
352
	textlink.value = "show";
353
    
354
}
355

    
356
function minimizeWidget(selectedDiv,swapButtons){
357
	//fade element
358
    jQuery('#' + selectedDiv).hide('blind');
359
    showSave();
360
	d = document;
361
    if (swapButtons){
362
	    selectIntLink = selectedDiv + "-open";
363
		textlink = d.getElementById(selectIntLink);
364
		textlink.style.display = "inline";	    
365
	    
366
	    selectIntLink = selectedDiv + "-min";
367
		textlink = d.getElementById(selectIntLink);
368
		textlink.style.display = "none";
369
    }
370
	selectIntLink = selectedDiv + "-container-input";
371
	textlink = d.getElementById(selectIntLink);
372
	textlink.value = "hide";	  
373
    
374
}
375

    
376
function closeWidget(selectedDiv){
377
	showSave();
378
	selectedDiv2 = "#" + selectedDiv + "-container";
379
	jQuery(selectedDiv2).hide('blind');
380
	selectIntLink = "#" + selectedDiv + "-container-input";
381
	jQuery(selectIntLink).val("close");
382
}
383

    
384
function showSave(){
385
	d = document;
386
	selectIntLink = "submit";
387
	textlink = d.getElementById(selectIntLink);
388
	textlink.style.display = "inline";
389
}
390

    
391
function updatePref(){
392
	var widgets = document.getElementsByClassName('widgetdiv');
393
	var widgetSequence = "";
394
	var firstprint = false;
395
	d = document;
396
	for (i=0; i<widgets.length; i++){
397
		if (firstprint)
398
			widgetSequence += ",";
399
		var widget = widgets[i].id;
400
		widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
401
		widget = widget + "-input";
402
		textlink = d.getElementById(widget).value;
403
		widgetSequence += textlink;
404
		firstprint = true;
405
	}
406
	selectLink = "sequence";
407
	textlink = d.getElementById(selectLink);
408
	textlink.value = widgetSequence;
409
	return true;
410
}
411

    
412
function hideAllWidgets(){
413
		jQuery('#niftyOutter').fadeTo('slow',0.2);
414
}
415

    
416
function showAllWidgets(){
417
		jQuery('#niftyOutter').fadeTo('slow',1.0);
418
}
419

    
420

    
421
function changeTabDIV(selectedDiv){
422
	var dashpos = selectedDiv.indexOf("-");
423
	var tabclass = selectedDiv.substring(0,dashpos);
424
	d = document;
425

    
426
	//get deactive tabs first
427
	tabclass = tabclass + "-class-tabdeactive"; 
428
	var tabs = document.getElementsByClassName(tabclass);
429
	var incTabSelected = selectedDiv + "-deactive";
430
	for (i=0; i<tabs.length; i++){
431
		var tab = tabs[i].id;
432
		dashpos = tab.lastIndexOf("-");
433
		var tab2 = tab.substring(0,dashpos) + "-deactive";
434
		if (tab2 == incTabSelected){
435
			tablink = d.getElementById(tab2);
436
			tablink.style.display = "none";
437
			tab2 = tab.substring(0,dashpos) + "-active";
438
			tablink = d.getElementById(tab2);
439
			tablink.style.display = "table-cell";
440

    
441
			//now show main div associated with link clicked
442
			tabmain = d.getElementById(selectedDiv);
443
			tabmain.style.display = "block";
444
		}
445
		else
446
		{
447
			tab2 = tab.substring(0,dashpos) + "-deactive";
448
			tablink = d.getElementById(tab2);
449
			tablink.style.display = "table-cell";
450
			tab2 = tab.substring(0,dashpos) + "-active";
451
			tablink = d.getElementById(tab2);
452
			tablink.style.display = "none";
453

    
454
			//hide sections we don't want to see
455
			tab2 = tab.substring(0,dashpos);
456
			tabmain = d.getElementById(tab2);
457
			tabmain.style.display = "none";
458

    
459
		}
460
	}
461
}
462
//]]>
463
</script>
464
EOD;
465

    
466

    
467
## Set Page Title and Include Header
468
$pgtitle = array(gettext("Status: Dashboard"));
469
include("head.inc");
470

    
471
?>
472

    
473
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
474

    
475
<script type="text/javascript">
476
//<![CDATA[
477
columns = ['col1','col2'];
478
//]]>
479
</script>
480

    
481
<?php
482
include("fbegin.inc");
483
echo $jscriptstr;
484
	if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
485
		echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\" alt=\"big logo\" /></center><br />";
486

    
487
if ($savemsg) 
488
	print_info_box($savemsg); 
489

    
490
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
491

    
492
?>
493
<div id="widgetcontainer" style="display:none">
494
		<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
495
			$widgetfiles_add = $widgetfiles;
496
			sort($widgetfiles_add);
497
			foreach($widgetfiles_add as $widget) {	
498
				if(!stristr($widget, "widget.php"))
499
					continue;		
500
				
501
				$periodpos = strpos($widget, ".");
502
				$widgetname = substr($widget, 0, $periodpos);
503
				$nicename = $widgetname;
504
				$nicename = str_replace("_", " ", $nicename);
505
				//make the title look nice
506
				$nicename = ucwords($nicename);
507
				
508
				$widgettitle = $widgetname . "_title";
509
				$widgettitlelink = $widgetname . "_title_link";
510
					if ($$widgettitle != "")
511
					{
512
						//echo widget title 
513
						?>
514
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
515
						<u><?php echo $$widgettitle; ?></u></span><br />
516
						<?php 
517
					}
518
					else {?>
519
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
520
						<u><?php echo $nicename; ?></u></span><br /><?php
521
					}
522
			}
523
		?>
524
		</p>
525
	</div>
526
</div>
527

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

    
546
<form action="index.php" method="post">
547
<input type="hidden" value="" name="sequence" id="sequence" />
548
<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');" />
549

    
550
<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');" />
551

    
552

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

    
726
<?php include("fend.inc"); ?>
727
	    
728
<script type="text/javascript">
729
//<![CDATA[
730
	jQuery(document).ready(function(in_event)
731
	{		
732
			jQuery('#col1').sortable({connectWith: '#col2', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
733
			jQuery('#col2').sortable({connectWith: '#col1', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
734

    
735
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
736
			hideAllWidgets();		    
737
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
738
	<?php } ?>
739
	});
740
//]]>
741
</script>
742
<?php
743
	//build list of javascript include files
744
	$jsincludefiles = array();
745
	$directory = "widgets/javascript/";
746
	$dirhandle  = opendir($directory);
747
	$filename = "";
748
	while (false !== ($filename = readdir($dirhandle))) {
749
   		$jsincludefiles[] = $filename;
750
	}
751
	foreach($jsincludefiles as $jsincludename) {
752
		if(!stristr($jsincludename, ".js"))
753
			continue;
754
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";	
755
	}
756
?>
757

    
758
</body>
759
</html>
(92-92/246)