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
	}
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
		}
86
		if ($x > 0) {
87
			$savemsg = "{$g['product_name']} has detected a crash report or programming bug.  Click <a href='crash_reporter.php'>here</a> for more information.";
88
		}
89
	}
90
}
91

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

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

    
113
##sort widgets alphabetically
114
sort($widgetfiles);
115

    
116
##insert the system information widget as first, so as to be displayed first
117
array_unshift($widgetfiles, "system_information.widget.php");
118

    
119
##if no config entry found, initialize config entry
120
if (!is_array($config['widgets'])) {
121
	$config['widgets'] = array();
122
}
123

    
124
if ($_POST && $_POST['submit']) {
125
	$config['widgets']['sequence'] = $_POST['sequence'];
126

    
127
	foreach ($widgetnames as $widget) {
128
		if ($_POST[$widget . '-config']) {
129
			$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
130
		}
131
	}
132

    
133
	write_config(gettext("Widget configuration has been changed."));
134
	header("Location: index.php");
135
	exit;
136
}
137

    
138
## Load Functions Files
139
require_once('includes/functions.inc.php');
140

    
141
## Check to see if we have a swap space,
142
## if true, display, if false, hide it ...
143
if (file_exists("/usr/sbin/swapinfo")) {
144
	$swapinfo = `/usr/sbin/swapinfo`;
145
	if (stristr($swapinfo,'%') == true) {
146
		$showswap=true;
147
	}
148
}
149

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

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

    
184
EOF;
185

    
186
	echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
187

    
188
	if (file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) {
189
		echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
190
	} else {
191
		echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
192
	}
193

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

    
213

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

    
234
##build widget saved list information
235
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
236
	$pconfig['sequence'] = $config['widgets']['sequence'];
237

    
238
	$widgetlist = $pconfig['sequence'];
239
	$colpos = array();
240
	$savedwidgetfiles = array();
241
	$widgetname = "";
242
	$widgetlist = explode(",",$widgetlist);
243

    
244
	##read the widget position and display information
245
	foreach ($widgetlist as $widget) {
246
		$dashpos = strpos($widget, "-");
247
		$widgetname = substr($widget, 0, $dashpos);
248
		$colposition = strpos($widget, ":");
249
		$displayposition = strrpos($widget, ":");
250
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
251
		$displayarray[] = substr($widget,$displayposition+1);
252
		$savedwidgetfiles[] = $widgetname . ".widget.php";
253
	}
254

    
255
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
256
	foreach ($widgetfiles as $defaultwidgets) {
257
		if (!in_array($defaultwidgets, $savedwidgetfiles)) {
258
			$savedwidgetfiles[] = $defaultwidgets;
259
		}
260
	}
261

    
262
	##find custom configurations of a particular widget and load its info to $pconfig
263
	foreach ($widgetnames as $widget) {
264
		if ($config['widgets'][$widget . '-config']) {
265
			$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
266
		}
267
	}
268

    
269
	$widgetlist = $savedwidgetfiles;
270
} else {
271
	// no saved widget sequence found, build default list.
272
	$widgetlist = $widgetfiles;
273
}
274

    
275
##build list of php include files
276
$phpincludefiles = array();
277
$directory = "/usr/local/www/widgets/include/";
278
$dirhandle  = opendir($directory);
279
$filename = "";
280
while (false !== ($filename = readdir($dirhandle))) {
281
	$phpincludefiles[] = $filename;
282
}
283
foreach ($phpincludefiles as $includename) {
284
	if (!stristr($includename, ".inc")) {
285
		continue;
286
	}
287
	include($directory . $includename);
288
}
289

    
290
##begin AJAX
291
$jscriptstr = <<<EOD
292
<script type="text/javascript">
293
//<![CDATA[
294

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

    
322

    
323
function addWidget(selectedDiv) {
324
	selectedDiv2 = '#' + selectedDiv + "-container";
325
	if (jQuery(selectedDiv2).css('display') != "none")
326
	{
327
		jQuery(selectedDiv2).effect('shake',{times: 2}, 100);
328
	}
329
	else
330
	{
331
		jQuery(selectedDiv2).show('blind');
332
		widgetAjax(selectedDiv);
333
		selectIntLink = selectedDiv2 + "-input";
334
		jQuery(selectIntLink).val("show");
335
		showSave();
336
	}
337
}
338

    
339
function configureWidget(selectedDiv) {
340
	selectIntLink = '#' + selectedDiv + "-settings";
341
	if (jQuery(selectIntLink).css('display') == "none") {
342
		jQuery(selectIntLink).show();
343
	} else {
344
		jQuery(selectIntLink).hide();
345
	}
346
}
347

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

    
358

    
359
		selectIntLink = selectedDiv + "-open";
360
		textlink = d.getElementById(selectIntLink);
361
		textlink.style.display = "none";
362

    
363
	}
364
	selectIntLink = selectedDiv + "-container-input";
365
	textlink = d.getElementById(selectIntLink);
366
	textlink.value = "show";
367

    
368
}
369

    
370
function minimizeWidget(selectedDiv,swapButtons) {
371
	//fade element
372
	jQuery('#' + selectedDiv).hide('blind');
373
	showSave();
374
	d = document;
375
	if (swapButtons) {
376
		selectIntLink = selectedDiv + "-open";
377
		textlink = d.getElementById(selectIntLink);
378
		textlink.style.display = "inline";
379

    
380
		selectIntLink = selectedDiv + "-min";
381
		textlink = d.getElementById(selectIntLink);
382
		textlink.style.display = "none";
383
	}
384
	selectIntLink = selectedDiv + "-container-input";
385
	textlink = d.getElementById(selectIntLink);
386
	textlink.value = "hide";
387

    
388
}
389

    
390
function closeWidget(selectedDiv) {
391
	showSave();
392
	selectedDiv2 = "#" + selectedDiv + "-container";
393
	jQuery(selectedDiv2).hide('blind');
394
	selectIntLink = "#" + selectedDiv + "-container-input";
395
	jQuery(selectIntLink).val("close");
396
}
397

    
398
function showSave() {
399
	d = document;
400
	selectIntLink = "submit";
401
	textlink = d.getElementById(selectIntLink);
402
	textlink.style.display = "inline";
403
}
404

    
405
function updatePref() {
406
	var widgets = document.getElementsByClassName('widgetdiv');
407
	var widgetSequence = "";
408
	var firstprint = false;
409
	d = document;
410
	for (i=0; i<widgets.length; i++) {
411
		if (firstprint) {
412
			widgetSequence += ",";
413
		}
414
		var widget = widgets[i].id;
415
		widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
416
		widget = widget + "-input";
417
		textlink = d.getElementById(widget).value;
418
		widgetSequence += textlink;
419
		firstprint = true;
420
	}
421
	selectLink = "sequence";
422
	textlink = d.getElementById(selectLink);
423
	textlink.value = widgetSequence;
424
	return true;
425
}
426

    
427
function hideAllWidgets() {
428
	jQuery('#niftyOutter').fadeTo('slow',0.2);
429
}
430

    
431
function showAllWidgets() {
432
	jQuery('#niftyOutter').fadeTo('slow',1.0);
433
}
434

    
435

    
436
function changeTabDIV(selectedDiv) {
437
	var dashpos = selectedDiv.indexOf("-");
438
	var tabclass = selectedDiv.substring(0,dashpos);
439
	d = document;
440

    
441
	//get deactive tabs first
442
	tabclass = tabclass + "-class-tabdeactive";
443
	var tabs = document.getElementsByClassName(tabclass);
444
	var incTabSelected = selectedDiv + "-deactive";
445
	for (i=0; i<tabs.length; i++) {
446
		var tab = tabs[i].id;
447
		dashpos = tab.lastIndexOf("-");
448
		var tab2 = tab.substring(0,dashpos) + "-deactive";
449
		if (tab2 == incTabSelected) {
450
			tablink = d.getElementById(tab2);
451
			tablink.style.display = "none";
452
			tab2 = tab.substring(0,dashpos) + "-active";
453
			tablink = d.getElementById(tab2);
454
			tablink.style.display = "table-cell";
455

    
456
			//now show main div associated with link clicked
457
			tabmain = d.getElementById(selectedDiv);
458
			tabmain.style.display = "block";
459
		}
460
		else
461
		{
462
			tab2 = tab.substring(0,dashpos) + "-deactive";
463
			tablink = d.getElementById(tab2);
464
			tablink.style.display = "table-cell";
465
			tab2 = tab.substring(0,dashpos) + "-active";
466
			tablink = d.getElementById(tab2);
467
			tablink.style.display = "none";
468

    
469
			//hide sections we don't want to see
470
			tab2 = tab.substring(0,dashpos);
471
			tabmain = d.getElementById(tab2);
472
			tabmain.style.display = "none";
473

    
474
		}
475
	}
476
}
477
//]]>
478
</script>
479
EOD;
480

    
481

    
482
## Set Page Title and Include Header
483
$pgtitle = array(gettext("Status: Dashboard"));
484
include("head.inc");
485

    
486
?>
487

    
488
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
489

    
490
<script type="text/javascript">
491
//<![CDATA[
492
columns = ['col1','col2','col3','col4', 'col5','col6','col7','col8','col9','col10'];
493
//]]>
494
</script>
495

    
496
<?php
497
include("fbegin.inc");
498
echo $jscriptstr;
499
if (!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo")) {
500
	echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\" alt=\"big logo\" /></center><br />";
501
}
502

    
503
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
504
if (!verify_all_package_servers()) {
505
	print_info_box(package_server_mismatch_message());
506
}
507

    
508
if ($savemsg) {
509
	print_info_box($savemsg);
510
}
511

    
512
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
513

    
514
?>
515
<div id="widgetcontainer" style="display:none">
516
	<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
517
		$widgetfiles_add = $widgetfiles;
518
		sort($widgetfiles_add);
519
		foreach ($widgetfiles_add as $widget) {
520
			if (!stristr($widget, "widget.php")) {
521
				continue;
522
			}
523

    
524
			$periodpos = strpos($widget, ".");
525
			$widgetname = substr($widget, 0, $periodpos);
526
			$nicename = $widgetname;
527
			$nicename = str_replace("_", " ", $nicename);
528
			//make the title look nice
529
			$nicename = ucwords($nicename);
530

    
531
			$widgettitle = $widgetname . "_title";
532
			$widgettitlelink = $widgetname . "_title_link";
533
			if ($$widgettitle != "") {
534
				//echo widget title
535
				?>
536
				<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
537
				<u><?php echo $$widgettitle; ?></u></span><br />
538
				<?php
539
			} else {
540
				?>
541
				<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
542
				<u><?php echo $nicename; ?></u></span><br /><?php
543
			}
544
		}
545
		?>
546
		</p>
547
	</div>
548
</div>
549

    
550
<div id="welcomecontainer" style="display:none">
551
	<div id="welcome-container">
552
		<div style="float:left;width:100%;padding: 2px">
553
			<h1><?=gettext("Welcome to the Dashboard page"); ?>!</h1>
554
		</div>
555
		<div onclick="domTT_close(this);showAllWidgets();" style="width:87%; position: absolute; cursor:pointer; padding: 10px;" >
556
			<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" alt="close" style="float:right" />
557
		</div>
558
		<div style="clear:both;">
559
		</div>
560
		<p>
561
		<?=gettext("This page allows you to customize the information you want to be displayed!");?><br />
562
		<?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="plus" /> <?=gettext("icon to add widgets.");?><br />
563
		<br />
564
		<?=gettext("You can move any widget around by clicking and dragging the title.");?>
565
		</p>
566
	</div>
567
</div>
568

    
569
<form action="index.php" method="post">
570
	<input type="hidden" value="" name="sequence" id="sequence" />
571
	<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');" />
572

    
573
	<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');" />
574

    
575
&nbsp;&nbsp;&nbsp;
576
	<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
577
</form>
578
<!-- fakeClass contains no CSS but is used as an identifier in theme pfsense_ng_fs - loader.js -->
579
<div id="niftyOutter" class="fakeClass">
580
	<?php
581
	$totalwidgets = count($widgetfiles);
582
	$halftotal = $totalwidgets / 2 - 2;
583
	$widgetcounter = 0;
584
	$directory = "/usr/local/www/widgets/widgets/";
585
	$printed = false;
586
	$firstprint = false;
587
	?>
588
	<div id="col1" style="float:left;width:49%;padding-bottom:40px" class="ui-sortable">
589
	<?php
590

    
591
	foreach ($widgetlist as $widget) {
592

    
593
		if (!stristr($widget, "widget.php")) {
594
			continue;
595
		}
596
		$periodpos = strpos($widget, ".");
597
		$widgetname = substr($widget, 0, $periodpos);
598
		if ($widgetname != "") {
599
			$nicename = $widgetname;
600
			$nicename = str_replace("_", " ", $nicename);
601

    
602
			//make the title look nice
603
			$nicename = ucwords($nicename);
604
		}
605

    
606
		if ($config['widgets'] && $pconfig['sequence'] != "") {
607
			switch ($displayarray[$widgetcounter]) {
608
				case "show":
609
					$divdisplay = "block";
610
					$display = "block";
611
					$inputdisplay = "show";
612
					$showWidget = "none";
613
					$mindiv = "inline";
614
					break;
615
				case "hide":
616
					$divdisplay = "block";
617
					$display = "none";
618
					$inputdisplay = "hide";
619
					$showWidget = "inline";
620
					$mindiv = "none";
621
					break;
622
				case "close":
623
					$divdisplay = "none";
624
					$display = "block";
625
					$inputdisplay = "close";
626
					$showWidget = "none";
627
					$mindiv = "inline";
628
					break;
629
				default:
630
					$divdisplay = "none";
631
					$display = "block";
632
					$inputdisplay = "none";
633
					$showWidget = "none";
634
					$mindiv = "inline";
635
					break;
636
			}
637
		} else {
638
			if ($firstprint == false) {
639
				$divdisplay = "block";
640
				$display = "block";
641
				$inputdisplay = "show";
642
				$showWidget = "none";
643
				$mindiv = "inline";
644
				$firstprint = true;
645
			} else {
646
				switch ($widget) {
647
					case "interfaces.widget.php":
648
					case "traffic_graphs.widget.php":
649
						$divdisplay = "block";
650
						$display = "block";
651
						$inputdisplay = "show";
652
						$showWidget = "none";
653
						$mindiv = "inline";
654
						break;
655
					default:
656
						$divdisplay = "none";
657
						$display = "block";
658
						$inputdisplay = "close";
659
						$showWidget = "none";
660
						$mindiv = "inline";
661
						break;
662
				}
663
			}
664
		}
665

    
666
		if (substr($g['theme'], -3) != "_fs") {
667
			if ($config['widgets'] && $pconfig['sequence'] != "") {
668
				if ($colpos[$widgetcounter] == "col2" && $printed == false) {
669
					$printed = true;
670
					?>
671
					</div>
672
					<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
673
					<?php
674
				}
675
			} else if ($widgetcounter >= $halftotal && $printed == false) {
676
				$printed = true;
677
				?>
678
				</div>
679
				<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
680
				<?php
681
			}
682
		} else {
683
			if ($config['widgets'] && $pconfig['sequence'] != "") {
684
				if ($colpos[$widgetcounter] == "col2" && $printed == false) {
685
					$printed = true;
686
					?>
687
					</div>
688
					<div id="col2" style="float:right;width:49%;padding-bottom:40px" class="ui-sortable">
689
					<?php
690
				} else { ?>
691
					<script type="text/javascript">
692
					//<![CDATA[
693
					var colpos = "<?=$colpos[$widgetcounter]?>";
694
					createColumn(colpos);
695
					//]]>
696
					</script>
697
				<?php }
698
			}
699
		}
700

    
701
		?>
702
		<div style="clear:both;"></div>
703
		<div id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
704
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input" />
705
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
706
				<div style="float:left;">
707
					<?php
708

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

    
758
	}//end foreach
759
	?>
760
		</div>
761
	<div style="clear:both;"></div>
762
</div>
763

    
764
<?php include("fend.inc"); ?>
765

    
766
<script type="text/javascript">
767
//<![CDATA[
768
	jQuery(document).ready(function(in_event)
769
	{
770
			jQuery('.ui-sortable').sortable({connectWith: '.ui-sortable', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
771

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

    
796
</body>
797
</html>
(94-94/256)