Project

General

Profile

Download (23.8 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
	$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>
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 rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
176
		else 
177
			echo "<link 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\"><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 "NiftyCheck();\n";
191
		echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
192
		echo "</script>\n";
193
		exit;
194
	}
195

    
196

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

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

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

    
272
##begin AJAX
273
$jscriptstr = <<<EOD
274
<script language="javascript" type="text/javascript">
275

    
276

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

    
304

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

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

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

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

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

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

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

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

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

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

    
415

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

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

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

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

    
454
		}
455
	}
456
}
457

    
458
</script>
459
EOD;
460
$closehead = false;
461

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

    
466
?>
467

    
468
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
469

    
470
<script language="javascript" type="text/javascript">
471
// <![CDATA[
472
columns = ['col1','col2'];
473
// ]]>
474

    
475
</script>
476

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

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

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

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

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

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

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

    
550

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

    
727
<?php include("fend.inc"); ?>
728
	    
729
<script type="text/javascript">
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
</script>
741
<?php
742
	//build list of javascript include files
743
	$jsincludefiles = array();
744
	$directory = "widgets/javascript/";
745
	$dirhandle  = opendir($directory);
746
	$filename = "";
747
	while (false !== ($filename = readdir($dirhandle))) {
748
   		$jsincludefiles[] = $filename;
749
	}
750
	foreach($jsincludefiles as $jsincludename) {
751
		if(!stristr($jsincludename, ".js"))
752
			continue;
753
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";	
754
	}
755
?>
756
</script>
757

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