Project

General

Profile

Download (25 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
	$lang_code    = system_get_language_code();
174
	$lang_codeset = system_get_language_codeset();
175
	echo <<<EOF
176
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
177
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
178
<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang_code" xml:lang="$lang_code">
179
<head>
180
	<title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title>
181
	<meta http-equiv="Content-Type" content="text/html; charset=$lang_codeset" />
182
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
183
	<script type="text/javascript">var theme = "{$g['theme']}"</script>
184
	<script type="text/javascript" src="/themes/{$g['theme']}/loader.js"></script>
185

    
186
EOF;
187

    
188
	echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
189

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

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

    
215

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

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

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

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

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

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

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

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

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

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

    
324

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

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

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

    
360

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

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

    
370
}
371

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

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

    
390
}
391

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

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

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

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

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

    
437

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

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

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

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

    
476
		}
477
	}
478
}
479
//]]>
480
</script>
481
EOD;
482

    
483

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

    
488
?>
489

    
490
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
491

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

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

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

    
510
if ($savemsg) {
511
	print_info_box($savemsg);
512
}
513

    
514
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
515

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

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

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

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

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

    
575
	<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');" />
576

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

    
593
	foreach ($widgetlist as $widget) {
594

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

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

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

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

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

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

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

    
766
<?php include("fend.inc"); ?>
767

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

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

    
798
</body>
799
</html>
(94-94/252)