Projet

Général

Profil

Télécharger (23,4 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / index.php @ 7e736f38

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
	$crash = glob("/var/crash/*");
71
	$skip_files = array(".", "..", "minfree", "");
72
	if(is_array($crash)) {
73
		foreach($crash as $c) {
74
			if (!in_array(basename($c), $skip_files))
75
				$x++;
76
		}
77
		if($x > 0)
78
			$savemsg = "{$g['product_name']} has detected a crash report or programming bug.  Click <a href='crash_reporter.php'>here</a> for more information.";
79
	}
80
}
81

    
82
##build list of widgets
83
$directory = "/usr/local/www/widgets/widgets/";
84
$dirhandle  = opendir($directory);
85
$filename = "";
86
$widgetnames = array();
87
$widgetfiles = array();
88
$widgetlist = array();
89

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

    
101
##sort widgets alphabetically
102
sort($widgetfiles);
103

    
104
##insert the system information widget as first, so as to be displayed first
105
array_unshift($widgetfiles, "system_information.widget.php");
106

    
107
##if no config entry found, initialize config entry
108
if (!is_array($config['widgets'])) {
109
	$config['widgets'] = array();
110
}
111

    
112
	if ($_POST && $_POST['submit']) {
113
		$config['widgets']['sequence'] = $_POST['sequence'];
114

    
115
		foreach ($widgetnames as $widget){
116
			if ($_POST[$widget . '-config']){
117
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
118
			}
119
		}
120

    
121
		write_config(gettext("Widget configuration has been changed."));
122
		header("Location: index.php");
123
		exit;
124
	}
125

    
126
	## Load Functions Files
127
	require_once('includes/functions.inc.php');
128

    
129
	## Check to see if we have a swap space,
130
	## if true, display, if false, hide it ...
131
	if(file_exists("/usr/sbin/swapinfo")) {
132
		$swapinfo = `/usr/sbin/swapinfo`;
133
		if(stristr($swapinfo,'%') == true) $showswap=true;
134
	}
135

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

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

    
165
EOF;
166

    
167
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
168

    
169
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
170
			echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
171
		else
172
			echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
173

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

    
193

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

    
214
##build widget saved list information
215
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
216
	$pconfig['sequence'] = $config['widgets']['sequence'];
217

    
218
	$widgetlist = $pconfig['sequence'];
219
	$colpos = array();
220
	$savedwidgetfiles = array();
221
	$widgetname = "";
222
	$widgetlist = explode(",",$widgetlist);
223

    
224
	##read the widget position and display information
225
	foreach ($widgetlist as $widget){
226
		$dashpos = strpos($widget, "-");
227
		$widgetname = substr($widget, 0, $dashpos);
228
		$colposition = strpos($widget, ":");
229
		$displayposition = strrpos($widget, ":");
230
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
231
		$displayarray[] = substr($widget,$displayposition+1);
232
		$savedwidgetfiles[] = $widgetname . ".widget.php";
233
	}
234

    
235
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
236
	foreach ($widgetfiles as $defaultwidgets){
237
		if (!in_array($defaultwidgets, $savedwidgetfiles)){
238
			$savedwidgetfiles[] = $defaultwidgets;
239
		}
240
	}
241

    
242
	##find custom configurations of a particular widget and load its info to $pconfig
243
	foreach ($widgetnames as $widget){
244
		if ($config['widgets'][$widget . '-config']){
245
			$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
246
		}
247
	}
248

    
249
	$widgetlist = $savedwidgetfiles;
250
} else{
251
	// no saved widget sequence found, build default list.
252
	$widgetlist = $widgetfiles;
253
}
254

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

    
269
##begin AJAX
270
$jscriptstr = <<<EOD
271
<script type="text/javascript">
272
//<![CDATA[
273

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

    
301

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

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

    
326
function showWidget(selectedDiv,swapButtons){
327
	//appear element
328
	jQuery('#' + selectedDiv).show('blind');
329
	showSave();
330
	d = document;
331
	if (swapButtons){
332
		selectIntLink = selectedDiv + "-min";
333
		textlink = d.getElementById(selectIntLink);
334
		textlink.style.display = "inline";
335

    
336

    
337
		selectIntLink = selectedDiv + "-open";
338
		textlink = d.getElementById(selectIntLink);
339
		textlink.style.display = "none";
340

    
341
	}
342
	selectIntLink = selectedDiv + "-container-input";
343
	textlink = d.getElementById(selectIntLink);
344
	textlink.value = "show";
345

    
346
}
347

    
348
function minimizeWidget(selectedDiv,swapButtons){
349
	//fade element
350
	jQuery('#' + selectedDiv).hide('blind');
351
	showSave();
352
	d = document;
353
	if (swapButtons){
354
		selectIntLink = selectedDiv + "-open";
355
		textlink = d.getElementById(selectIntLink);
356
		textlink.style.display = "inline";
357

    
358
		selectIntLink = selectedDiv + "-min";
359
		textlink = d.getElementById(selectIntLink);
360
		textlink.style.display = "none";
361
	}
362
	selectIntLink = selectedDiv + "-container-input";
363
	textlink = d.getElementById(selectIntLink);
364
	textlink.value = "hide";
365

    
366
}
367

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

    
376
function showSave(){
377
	d = document;
378
	selectIntLink = "submit";
379
	textlink = d.getElementById(selectIntLink);
380
	textlink.style.display = "inline";
381
}
382

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

    
404
function hideAllWidgets(){
405
		jQuery('#niftyOutter').fadeTo('slow',0.2);
406
}
407

    
408
function showAllWidgets(){
409
		jQuery('#niftyOutter').fadeTo('slow',1.0);
410
}
411

    
412

    
413
function changeTabDIV(selectedDiv){
414
	var dashpos = selectedDiv.indexOf("-");
415
	var tabclass = selectedDiv.substring(0,dashpos);
416
	d = document;
417

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

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

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

    
451
		}
452
	}
453
}
454
//]]>
455
</script>
456
EOD;
457

    
458

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

    
463
?>
464

    
465
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
466

    
467
<script type="text/javascript">
468
//<![CDATA[
469
columns = ['col1','col2'];
470
//]]>
471
</script>
472

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

    
479
if ($savemsg)
480
	print_info_box($savemsg);
481

    
482
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
483

    
484
?>
485
<div id="widgetcontainer" style="display:none">
486
		<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
487
			$widgetfiles_add = $widgetfiles;
488
			sort($widgetfiles_add);
489
			foreach($widgetfiles_add as $widget) {
490
				if(!stristr($widget, "widget.php"))
491
					continue;
492

    
493
				$periodpos = strpos($widget, ".");
494
				$widgetname = substr($widget, 0, $periodpos);
495
				$nicename = $widgetname;
496
				$nicename = str_replace("_", " ", $nicename);
497
				//make the title look nice
498
				$nicename = ucwords($nicename);
499

    
500
				$widgettitle = $widgetname . "_title";
501
				$widgettitlelink = $widgetname . "_title_link";
502
					if ($$widgettitle != "")
503
					{
504
						//echo widget title
505
						?>
506
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
507
						<u><?php echo $$widgettitle; ?></u></span><br />
508
						<?php
509
					}
510
					else {?>
511
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
512
						<u><?php echo $nicename; ?></u></span><br /><?php
513
					}
514
			}
515
		?>
516
		</p>
517
	</div>
518
</div>
519

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

    
538
<form action="index.php" method="post">
539
<input type="hidden" value="" name="sequence" id="sequence" />
540
<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');" />
541

    
542
<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');" />
543

    
544

    
545
&nbsp;&nbsp;&nbsp;
546
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
547
</form>
548
<div id="niftyOutter">
549
	<?php
550
	$totalwidgets = count($widgetfiles);
551
	$halftotal = $totalwidgets / 2 - 2;
552
	$widgetcounter = 0;
553
	$directory = "/usr/local/www/widgets/widgets/";
554
	$printed = false;
555
	$firstprint = false;
556
	?>
557
	<div id="col1" style="float:left;width:49%;padding-bottom:40px">
558
	<?php
559

    
560
	foreach($widgetlist as $widget) {
561

    
562
		if(!stristr($widget, "widget.php"))
563
					continue;
564
		$periodpos = strpos($widget, ".");
565
		$widgetname = substr($widget, 0, $periodpos);
566
		if ($widgetname != ""){
567
			$nicename = $widgetname;
568
			$nicename = str_replace("_", " ", $nicename);
569

    
570
			//make the title look nice
571
			$nicename = ucwords($nicename);
572
		}
573

    
574
		if ($config['widgets'] && $pconfig['sequence'] != ""){
575
			switch($displayarray[$widgetcounter]){
576
				case "show":
577
					$divdisplay = "block";
578
					$display = "block";
579
					$inputdisplay = "show";
580
					$showWidget = "none";
581
					$mindiv = "inline";
582
					break;
583
				case "hide":
584
					$divdisplay = "block";
585
					$display = "none";
586
					$inputdisplay = "hide";
587
					$showWidget = "inline";
588
					$mindiv = "none";
589
					break;
590
				case "close":
591
					$divdisplay = "none";
592
					$display = "block";
593
					$inputdisplay = "close";
594
					$showWidget = "none";
595
					$mindiv = "inline";
596
					break;
597
				default:
598
					$divdisplay = "none";
599
					$display = "block";
600
					$inputdisplay = "none";
601
					$showWidget = "none";
602
					$mindiv = "inline";
603
					break;
604
			}
605
		} else {
606
			if ($firstprint == false){
607
				$divdisplay = "block";
608
				$display = "block";
609
				$inputdisplay = "show";
610
				$showWidget = "none";
611
				$mindiv = "inline";
612
				$firstprint = true;
613
			} else {
614
				switch ($widget) {
615
					case "interfaces.widget.php":
616
					case "traffic_graphs.widget.php":
617
						$divdisplay = "block";
618
						$display = "block";
619
						$inputdisplay = "show";
620
						$showWidget = "none";
621
						$mindiv = "inline";
622
						break;
623
					default:
624
						$divdisplay = "none";
625
						$display = "block";
626
						$inputdisplay = "close";
627
						$showWidget = "none";
628
						$mindiv = "inline";
629
						break;
630
				}
631
			}
632
		}
633

    
634
		if ($config['widgets'] && $pconfig['sequence'] != ""){
635
			if ($colpos[$widgetcounter] == "col2" && $printed == false)
636
			{
637
				$printed = true;
638
				?>
639
				</div>
640
				<div id="col2" style="float:right;width:49%;padding-bottom:40px">
641
				<?php
642
			}
643
		}
644
		else if ($widgetcounter >= $halftotal && $printed == false){
645
			$printed = true;
646
			?>
647
			</div>
648
			<div id="col2" style="float:right;width:49%;padding-bottom:40px">
649
			<?php
650
		}
651

    
652
		?>
653
		<div style="clear:both;"></div>
654
		<div  id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
655
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input" />
656
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
657
				<div style="float:left;">
658
					<?php
659

    
660
					$widgettitle = $widgetname . "_title";
661
					$widgettitlelink = $widgetname . "_title_link";
662
					if ($$widgettitle != "")
663
					{
664
						//only show link if defined
665
						if ($$widgettitlelink != "") {?>
666
						<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
667
						<?php }
668
							//echo widget title
669
							echo $$widgettitle;
670
						if ($$widgettitlelink != "") { ?>
671
						</span></u>
672
						<?php }
673
					}
674
					else{
675
						if ($$widgettitlelink != "") {?>
676
						<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
677
						<?php }
678
						echo $nicename;
679
							if ($$widgettitlelink != "") { ?>
680
						</span></u>
681
						<?php }
682
					}
683
					?>
684
				</div>
685
				<div align="right" style="float:right;">
686
					<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>
687
					<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>
688
					<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>
689
					<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>
690
				</div>
691
				<div style="clear:both;"></div>
692
			</div>
693
			<?php if ($divdisplay != "block") { ?>
694
			<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;" align="center">
695
				<br />
696
					<img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width="25" height="25" alt="<?=gettext("Loading selected widget"); ?>..." />
697
				<br />
698
			</div> <?php $display = "none"; } ?>
699
			<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">
700
				<?php
701
					if ($divdisplay == "block")
702
					{
703
						include($directory . $widget);
704
					}
705
				?>
706
			</div>
707
			<div style="clear:both;"></div>
708
		</div>
709
		<?php
710
	$widgetcounter++;
711

    
712
	}//end foreach
713
	?>
714
		</div>
715
	<div style="clear:both;"></div>
716
</div>
717

    
718
<?php include("fend.inc"); ?>
719

    
720
<script type="text/javascript">
721
//<![CDATA[
722
	jQuery(document).ready(function(in_event)
723
	{
724
			jQuery('#col1').sortable({connectWith: '#col2', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
725
			jQuery('#col2').sortable({connectWith: '#col1', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
726

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

    
750
</body>
751
</html>
(92-92/246)