Projet

Général

Profil

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

univnautes / usr / local / www / index.php @ 1b244d38

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="<?=system_get_language_code();?>" xml:lang="<?=system_get_language_code();?>">
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=<?=system_get_language_codeset();?>" />
166
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
167
	<script type="text/javascript">var theme = "{$g['theme']}"</script>
168
	<script type="text/javascript" src="/themes/{$g['theme']}/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','col3','col4', 'col5','col6','col7','col8','col9','col10'];
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:100%;padding: 2px">
528
				<h1><?=gettext("Welcome to the Dashboard page"); ?>!</h1>
529
			</div>
530
			<div onclick="domTT_close(this);showAllWidgets();" style="width:87%; position: absolute; cursor:pointer; padding: 10px;" >
531
				<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" alt="close" style="float:right" />
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
<!-- fakeClass contains no CSS but is used as an identifier in theme pfsense_ng_fs - loader.js -->
554
<div id="niftyOutter" class="fakeClass">
555
	<?php
556
	$totalwidgets = count($widgetfiles);
557
	$halftotal = $totalwidgets / 2 - 2;
558
	$widgetcounter = 0;
559
	$directory = "/usr/local/www/widgets/widgets/";
560
	$printed = false;
561
	$firstprint = false;
562
	?>
563
	<div id="col1" style="float:left;width:49%;padding-bottom:40px" class="ui-sortable">
564
	<?php
565

    
566
	foreach($widgetlist as $widget) {
567

    
568
		if(!stristr($widget, "widget.php"))
569
					continue;
570
		$periodpos = strpos($widget, ".");
571
		$widgetname = substr($widget, 0, $periodpos);
572
		if ($widgetname != ""){
573
			$nicename = $widgetname;
574
			$nicename = str_replace("_", " ", $nicename);
575

    
576
			//make the title look nice
577
			$nicename = ucwords($nicename);
578
		}
579

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

    
640
		if( substr($g['theme'], -3) != "_fs") {
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" class="ui-sortable">
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" class="ui-sortable">
656
				<?php
657
			}
658
		}
659
		else {
660
			if ($config['widgets'] && $pconfig['sequence'] != "") {
661
				if ($colpos[$widgetcounter] == "col2" && $printed == false)
662
				{
663
					$printed = true;
664
					?>
665
					</div>
666
					<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
667
					<?php
668
				}
669
				else { ?>
670
					<script type="text/javascript">
671
					//<![CDATA[
672
					var colpos = "<?=$colpos[$widgetcounter]?>";
673
					createColumn(colpos);
674
					//]]>
675
					</script>
676
				<?php }
677
			}		
678
		}
679

    
680
		?>
681
		<div style="clear:both;"></div>
682
		<div  id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
683
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input" />
684
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
685
				<div style="float:left;">
686
					<?php
687

    
688
					$widgettitle = $widgetname . "_title";
689
					$widgettitlelink = $widgetname . "_title_link";
690
					if ($$widgettitle != "")
691
					{
692
						//only show link if defined
693
						if ($$widgettitlelink != "") {?>
694
						<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
695
						<?php }
696
							//echo widget title
697
							echo $$widgettitle;
698
						if ($$widgettitlelink != "") { ?>
699
						</span></u>
700
						<?php }
701
					}
702
					else{
703
						if ($$widgettitlelink != "") {?>
704
						<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
705
						<?php }
706
						echo $nicename;
707
							if ($$widgettitlelink != "") { ?>
708
						</span></u>
709
						<?php }
710
					}
711
					?>
712
				</div>
713
				<div align="right" style="float:right;">
714
					<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>
715
					<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>
716
					<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>
717
					<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>
718
				</div>
719
				<div style="clear:both;"></div>
720
			</div>
721
			<?php if ($divdisplay != "block") { ?>
722
			<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;" align="center">
723
				<br />
724
					<img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width="25" height="25" alt="<?=gettext("Loading selected widget"); ?>..." />
725
				<br />
726
			</div> <?php $display = "none"; } ?>
727
			<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">
728
				<?php
729
					if ($divdisplay == "block")
730
					{
731
						include($directory . $widget);
732
					}
733
				?>
734
			</div>
735
			<div style="clear:both;"></div>
736
		</div>
737
		<?php
738
	$widgetcounter++;
739

    
740
	}//end foreach
741
	?>
742
		</div>
743
	<div style="clear:both;"></div>
744
</div>
745

    
746
<?php include("fend.inc"); ?>
747

    
748
<script type="text/javascript">
749
//<![CDATA[
750
	jQuery(document).ready(function(in_event)
751
	{
752
			jQuery('.ui-sortable').sortable({connectWith: '.ui-sortable', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
753

    
754
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
755
			hideAllWidgets();
756
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');
757
	<?php } ?>
758
	});
759
//]]>
760
</script>
761
<?php
762
	//build list of javascript include files
763
	$jsincludefiles = array();
764
	$directory = "widgets/javascript/";
765
	$dirhandle  = opendir($directory);
766
	$filename = "";
767
	while (false !== ($filename = readdir($dirhandle))) {
768
		$jsincludefiles[] = $filename;
769
	}
770
	foreach($jsincludefiles as $jsincludename) {
771
		if(!preg_match('/\.js$/', $jsincludename))
772
			continue;
773
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";
774
	}
775
?>
776

    
777
</body>
778
</html>
(92-92/254)