Project

General

Profile

Download (24.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	index.php
5
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6
	Copyright (C) 2004-2012 Scott Ullrich
7
	All rights reserved.
8

    
9
	Originally part of m0n0wall (http://m0n0.ch/wall)
10
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12

    
13
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15

    
16
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18

    
19
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22

    
23
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	oR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34
/*
35
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
36
	pfSense_MODULE:	interfaces
37
*/
38

    
39
##|+PRIV
40
##|*IDENT=page-system-login/logout
41
##|*NAME=System: Login / Logout page / Dashboard
42
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
43
##|*MATCH=index.php*
44
##|-PRIV
45

    
46
// Turn on buffering to speed up rendering
47
ini_set('output_buffering','true');
48

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

    
52

    
53
## Load Essential Includes
54
require_once('guiconfig.inc');
55
require_once('functions.inc');
56
require_once('notices.inc');
57
require_once("pkg-utils.inc");
58

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

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

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

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

    
108
##sort widgets alphabetically
109
sort($widgetfiles);
110

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

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

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

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

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

    
133
	## Load Functions Files
134
	require_once('includes/functions.inc.php');
135

    
136
	## Check to see if we have a swap space,
137
	## if true, display, if false, hide it ...
138
	if(file_exists("/usr/sbin/swapinfo")) {
139
		$swapinfo = `/usr/sbin/swapinfo`;
140
		if(stristr($swapinfo,'%') == true) $showswap=true;
141
	}
142

    
143
	## User recently restored his config.
144
	## If packages are installed lets resync
145
	if(file_exists('/conf/needs_package_sync')) {
146
		if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
147
			if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
148
				## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
149
				## the package reinstall page. That is about to be done by the boot script anyway.
150
				## The code in fbegin.inc will put up a notice to the user.
151
				if (!platform_booting()) {
152
					header('Location: pkg_mgr_install.php?mode=reinstallall');
153
					exit;
154
				}
155
			}
156
		} else {
157
			conf_mount_rw();
158
			@unlink('/conf/needs_package_sync');
159
			conf_mount_ro();
160
		}
161
	}
162

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

    
177
EOF;
178

    
179
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
180

    
181
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
182
			echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
183
		else
184
			echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
185

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

    
205

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

    
226
##build widget saved list information
227
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
228
	$pconfig['sequence'] = $config['widgets']['sequence'];
229

    
230
	$widgetlist = $pconfig['sequence'];
231
	$colpos = array();
232
	$savedwidgetfiles = array();
233
	$widgetname = "";
234
	$widgetlist = explode(",",$widgetlist);
235

    
236
	##read the widget position and display information
237
	foreach ($widgetlist as $widget){
238
		$dashpos = strpos($widget, "-");
239
		$widgetname = substr($widget, 0, $dashpos);
240
		$colposition = strpos($widget, ":");
241
		$displayposition = strrpos($widget, ":");
242
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
243
		$displayarray[] = substr($widget,$displayposition+1);
244
		$savedwidgetfiles[] = $widgetname . ".widget.php";
245
	}
246

    
247
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
248
	foreach ($widgetfiles as $defaultwidgets){
249
		if (!in_array($defaultwidgets, $savedwidgetfiles)){
250
			$savedwidgetfiles[] = $defaultwidgets;
251
		}
252
	}
253

    
254
	##find custom configurations of a particular widget and load its info to $pconfig
255
	foreach ($widgetnames as $widget){
256
		if ($config['widgets'][$widget . '-config']){
257
			$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
258
		}
259
	}
260

    
261
	$widgetlist = $savedwidgetfiles;
262
} else{
263
	// no saved widget sequence found, build default list.
264
	$widgetlist = $widgetfiles;
265
}
266

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

    
281
##begin AJAX
282
$jscriptstr = <<<EOD
283
<script type="text/javascript">
284
//<![CDATA[
285

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

    
313

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

    
330
function configureWidget(selectedDiv){
331
	selectIntLink = '#' + selectedDiv + "-settings";
332
	if (jQuery(selectIntLink).css('display') == "none")
333
		jQuery(selectIntLink).show();
334
	else
335
		jQuery(selectIntLink).hide();
336
}
337

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

    
348

    
349
		selectIntLink = selectedDiv + "-open";
350
		textlink = d.getElementById(selectIntLink);
351
		textlink.style.display = "none";
352

    
353
	}
354
	selectIntLink = selectedDiv + "-container-input";
355
	textlink = d.getElementById(selectIntLink);
356
	textlink.value = "show";
357

    
358
}
359

    
360
function minimizeWidget(selectedDiv,swapButtons){
361
	//fade element
362
	jQuery('#' + selectedDiv).hide('blind');
363
	showSave();
364
	d = document;
365
	if (swapButtons){
366
		selectIntLink = selectedDiv + "-open";
367
		textlink = d.getElementById(selectIntLink);
368
		textlink.style.display = "inline";
369

    
370
		selectIntLink = selectedDiv + "-min";
371
		textlink = d.getElementById(selectIntLink);
372
		textlink.style.display = "none";
373
	}
374
	selectIntLink = selectedDiv + "-container-input";
375
	textlink = d.getElementById(selectIntLink);
376
	textlink.value = "hide";
377

    
378
}
379

    
380
function closeWidget(selectedDiv){
381
	showSave();
382
	selectedDiv2 = "#" + selectedDiv + "-container";
383
	jQuery(selectedDiv2).hide('blind');
384
	selectIntLink = "#" + selectedDiv + "-container-input";
385
	jQuery(selectIntLink).val("close");
386
}
387

    
388
function showSave(){
389
	d = document;
390
	selectIntLink = "submit";
391
	textlink = d.getElementById(selectIntLink);
392
	textlink.style.display = "inline";
393
}
394

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

    
416
function hideAllWidgets(){
417
		jQuery('#niftyOutter').fadeTo('slow',0.2);
418
}
419

    
420
function showAllWidgets(){
421
		jQuery('#niftyOutter').fadeTo('slow',1.0);
422
}
423

    
424

    
425
function changeTabDIV(selectedDiv){
426
	var dashpos = selectedDiv.indexOf("-");
427
	var tabclass = selectedDiv.substring(0,dashpos);
428
	d = document;
429

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

    
445
			//now show main div associated with link clicked
446
			tabmain = d.getElementById(selectedDiv);
447
			tabmain.style.display = "block";
448
		}
449
		else
450
		{
451
			tab2 = tab.substring(0,dashpos) + "-deactive";
452
			tablink = d.getElementById(tab2);
453
			tablink.style.display = "table-cell";
454
			tab2 = tab.substring(0,dashpos) + "-active";
455
			tablink = d.getElementById(tab2);
456
			tablink.style.display = "none";
457

    
458
			//hide sections we don't want to see
459
			tab2 = tab.substring(0,dashpos);
460
			tabmain = d.getElementById(tab2);
461
			tabmain.style.display = "none";
462

    
463
		}
464
	}
465
}
466
//]]>
467
</script>
468
EOD;
469

    
470

    
471
## Set Page Title and Include Header
472
$pgtitle = array(gettext("Status: Dashboard"));
473
include("head.inc");
474

    
475
?>
476

    
477
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
478

    
479
<script type="text/javascript">
480
//<![CDATA[
481
columns = ['col1','col2','col3','col4', 'col5','col6','col7','col8','col9','col10'];
482
//]]>
483
</script>
484

    
485
<?php
486
include("fbegin.inc");
487
echo $jscriptstr;
488
	if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
489
		echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\" alt=\"big logo\" /></center><br />";
490

    
491
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
492
if (!verify_all_package_servers())
493
	print_info_box(package_server_mismatch_message());
494

    
495
if ($savemsg)
496
	print_info_box($savemsg);
497

    
498
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
499

    
500
?>
501
<div id="widgetcontainer" style="display:none">
502
		<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
503
			$widgetfiles_add = $widgetfiles;
504
			sort($widgetfiles_add);
505
			foreach($widgetfiles_add as $widget) {
506
				if(!stristr($widget, "widget.php"))
507
					continue;
508

    
509
				$periodpos = strpos($widget, ".");
510
				$widgetname = substr($widget, 0, $periodpos);
511
				$nicename = $widgetname;
512
				$nicename = str_replace("_", " ", $nicename);
513
				//make the title look nice
514
				$nicename = ucwords($nicename);
515

    
516
				$widgettitle = $widgetname . "_title";
517
				$widgettitlelink = $widgetname . "_title_link";
518
					if ($$widgettitle != "")
519
					{
520
						//echo widget title
521
						?>
522
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
523
						<u><?php echo $$widgettitle; ?></u></span><br />
524
						<?php
525
					}
526
					else {?>
527
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
528
						<u><?php echo $nicename; ?></u></span><br /><?php
529
					}
530
			}
531
		?>
532
		</p>
533
	</div>
534
</div>
535

    
536
<div id="welcomecontainer" style="display:none">
537
		<div id="welcome-container">
538
			<div style="float:left;width:100%;padding: 2px">
539
				<h1><?=gettext("Welcome to the Dashboard page"); ?>!</h1>
540
			</div>
541
			<div onclick="domTT_close(this);showAllWidgets();" style="width:87%; position: absolute; cursor:pointer; padding: 10px;" >
542
				<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" alt="close" style="float:right" />
543
			</div>
544
			<div style="clear:both;"></div>
545
			<p>
546
			<?=gettext("This page allows you to customize the information you want to be displayed!");?><br />
547
			<?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="plus" /> <?=gettext("icon to add widgets.");?><br />
548
			<br />
549
			<?=gettext("You can move any widget around by clicking and dragging the title.");?>
550
			</p>
551
	</div>
552
</div>
553

    
554
<form action="index.php" method="post">
555
<input type="hidden" value="" name="sequence" id="sequence" />
556
<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');" />
557

    
558
<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');" />
559

    
560

    
561
&nbsp;&nbsp;&nbsp;
562
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
563
</form>
564
<!-- fakeClass contains no CSS but is used as an identifier in theme pfsense_ng_fs - loader.js -->
565
<div id="niftyOutter" class="fakeClass">
566
	<?php
567
	$totalwidgets = count($widgetfiles);
568
	$halftotal = $totalwidgets / 2 - 2;
569
	$widgetcounter = 0;
570
	$directory = "/usr/local/www/widgets/widgets/";
571
	$printed = false;
572
	$firstprint = false;
573
	?>
574
	<div id="col1" style="float:left;width:49%;padding-bottom:40px" class="ui-sortable">
575
	<?php
576

    
577
	foreach($widgetlist as $widget) {
578

    
579
		if(!stristr($widget, "widget.php"))
580
					continue;
581
		$periodpos = strpos($widget, ".");
582
		$widgetname = substr($widget, 0, $periodpos);
583
		if ($widgetname != ""){
584
			$nicename = $widgetname;
585
			$nicename = str_replace("_", " ", $nicename);
586

    
587
			//make the title look nice
588
			$nicename = ucwords($nicename);
589
		}
590

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

    
651
		if( substr($g['theme'], -3) != "_fs") {
652
			if ($config['widgets'] && $pconfig['sequence'] != ""){
653
				if ($colpos[$widgetcounter] == "col2" && $printed == false)
654
				{
655
					$printed = true;
656
					?>
657
					</div>
658
					<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
659
					<?php
660
				}
661
			}
662
			else if ($widgetcounter >= $halftotal && $printed == false){
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
		}
670
		else {
671
			if ($config['widgets'] && $pconfig['sequence'] != "") {
672
				if ($colpos[$widgetcounter] == "col2" && $printed == false)
673
				{
674
					$printed = true;
675
					?>
676
					</div>
677
					<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
678
					<?php
679
				}
680
				else { ?>
681
					<script type="text/javascript">
682
					//<![CDATA[
683
					var colpos = "<?=$colpos[$widgetcounter]?>";
684
					createColumn(colpos);
685
					//]]>
686
					</script>
687
				<?php }
688
			}		
689
		}
690

    
691
		?>
692
		<div style="clear:both;"></div>
693
		<div  id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
694
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input" />
695
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
696
				<div style="float:left;">
697
					<?php
698

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

    
751
	}//end foreach
752
	?>
753
		</div>
754
	<div style="clear:both;"></div>
755
</div>
756

    
757
<?php include("fend.inc"); ?>
758

    
759
<script type="text/javascript">
760
//<![CDATA[
761
	jQuery(document).ready(function(in_event)
762
	{
763
			jQuery('.ui-sortable').sortable({connectWith: '.ui-sortable', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
764

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

    
788
</body>
789
</html>
(94-94/256)