Project

General

Profile

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

    
199

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

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

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

    
275
##begin AJAX
276
$jscriptstr = <<<EOD
277
<script language="javascript" type="text/javascript">
278

    
279

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

    
307

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

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

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

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

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

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

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

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

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

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

    
418

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

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

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

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

    
457
		}
458
	}
459
}
460

    
461
</script>
462
EOD;
463
$closehead = false;
464

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

    
469
?>
470

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

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

    
478
</script>
479

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

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

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

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

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

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

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

    
553

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

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

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

    
761
</body>
762
</html>
(92-92/246)