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 on buffering to speed up rendering
46
ini_set('output_buffering','true');
47

    
48
// Start buffering with a cache size of 100000
49
ob_start(null, "1000");
50

    
51

    
52
## Load Essential Includes
53
require_once('functions.inc');
54
require_once('guiconfig.inc');
55
require_once('notices.inc');
56

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

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

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

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

    
106
##sort widgets alphabetically
107
sort($widgetfiles);
108

    
109
##insert the system information widget as first, so as to be displayed first
110
array_unshift($widgetfiles, "system_information.widget.php");
111

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

    
117
	if ($_POST && $_POST['submit']) {
118
		$config['widgets']['sequence'] = $_POST['sequence'];
119

    
120
		foreach ($widgetnames as $widget){
121
			if ($_POST[$widget . '-config']){
122
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
123
			}
124
		}
125

    
126
		write_config(gettext("Widget configuration has been changed."));
127
		header("Location: index.php");
128
		exit;
129
	}
130

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

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

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

    
172
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
173

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

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

    
198

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

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

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

    
274
##begin AJAX
275
$jscriptstr = <<<EOD
276
<script type="text/javascript">
277
//<![CDATA[
278

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

    
306

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

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

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

    
346
    }
347
	selectIntLink = selectedDiv + "-container-input";
348
	textlink = d.getElementById(selectIntLink);
349
	textlink.value = "show";
350
    
351
}
352

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

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

    
381
function showSave(){
382
	d = document;
383
	selectIntLink = "submit";
384
	textlink = d.getElementById(selectIntLink);
385
	textlink.style.display = "inline";
386
}
387

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

    
409
function hideAllWidgets(){
410
		jQuery('#niftyOutter').fadeTo('slow',0.2);
411
}
412

    
413
function showAllWidgets(){
414
		jQuery('#niftyOutter').fadeTo('slow',1.0);
415
}
416

    
417

    
418
function changeTabDIV(selectedDiv){
419
	var dashpos = selectedDiv.indexOf("-");
420
	var tabclass = selectedDiv.substring(0,dashpos);
421
	d = document;
422

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

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

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

    
456
		}
457
	}
458
}
459
//]]>
460
</script>
461
EOD;
462

    
463

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

    
468
?>
469

    
470
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
471

    
472
<script type="text/javascript">
473
//<![CDATA[
474
columns = ['col1','col2'];
475
//]]>
476
</script>
477

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

    
484
if ($savemsg) 
485
	print_info_box($savemsg); 
486

    
487
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
488

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

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

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

    
547
<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');" />
548

    
549

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

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

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

    
755
</body>
756
</html>
(92-92/246)