Project

General

Profile

Download (24.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	index.php
5
        Copyright (C) 2013-2014 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('functions.inc');
55
require_once('guiconfig.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
				header('Location: pkg_mgr_install.php?mode=reinstallall');
149
				exit;
150
			}
151
		} else {
152
			conf_mount_rw();
153
			@unlink('/conf/needs_package_sync');
154
			conf_mount_ro();
155
		}
156
	}
157

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

    
172
EOF;
173

    
174
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
175

    
176
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
177
			echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
178
		else
179
			echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
180

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

    
200

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

    
221
##build widget saved list information
222
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
223
	$pconfig['sequence'] = $config['widgets']['sequence'];
224

    
225
	$widgetlist = $pconfig['sequence'];
226
	$colpos = array();
227
	$savedwidgetfiles = array();
228
	$widgetname = "";
229
	$widgetlist = explode(",",$widgetlist);
230

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

    
242
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
243
	foreach ($widgetfiles as $defaultwidgets){
244
		if (!in_array($defaultwidgets, $savedwidgetfiles)){
245
			$savedwidgetfiles[] = $defaultwidgets;
246
		}
247
	}
248

    
249
	##find custom configurations of a particular widget and load its info to $pconfig
250
	foreach ($widgetnames as $widget){
251
		if ($config['widgets'][$widget . '-config']){
252
			$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
253
		}
254
	}
255

    
256
	$widgetlist = $savedwidgetfiles;
257
} else{
258
	// no saved widget sequence found, build default list.
259
	$widgetlist = $widgetfiles;
260
}
261

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

    
276
##begin AJAX
277
$jscriptstr = <<<EOD
278
<script type="text/javascript">
279
//<![CDATA[
280

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

    
308

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

    
325
function configureWidget(selectedDiv){
326
	selectIntLink = '#' + selectedDiv + "-settings";
327
	if (jQuery(selectIntLink).css('display') == "none")
328
		jQuery(selectIntLink).show();
329
	else
330
		jQuery(selectIntLink).hide();
331
}
332

    
333
function showWidget(selectedDiv,swapButtons){
334
	//appear element
335
	jQuery('#' + selectedDiv).show('blind');
336
	showSave();
337
	d = document;
338
	if (swapButtons){
339
		selectIntLink = selectedDiv + "-min";
340
		textlink = d.getElementById(selectIntLink);
341
		textlink.style.display = "inline";
342

    
343

    
344
		selectIntLink = selectedDiv + "-open";
345
		textlink = d.getElementById(selectIntLink);
346
		textlink.style.display = "none";
347

    
348
	}
349
	selectIntLink = selectedDiv + "-container-input";
350
	textlink = d.getElementById(selectIntLink);
351
	textlink.value = "show";
352

    
353
}
354

    
355
function minimizeWidget(selectedDiv,swapButtons){
356
	//fade element
357
	jQuery('#' + selectedDiv).hide('blind');
358
	showSave();
359
	d = document;
360
	if (swapButtons){
361
		selectIntLink = selectedDiv + "-open";
362
		textlink = d.getElementById(selectIntLink);
363
		textlink.style.display = "inline";
364

    
365
		selectIntLink = selectedDiv + "-min";
366
		textlink = d.getElementById(selectIntLink);
367
		textlink.style.display = "none";
368
	}
369
	selectIntLink = selectedDiv + "-container-input";
370
	textlink = d.getElementById(selectIntLink);
371
	textlink.value = "hide";
372

    
373
}
374

    
375
function closeWidget(selectedDiv){
376
	showSave();
377
	selectedDiv2 = "#" + selectedDiv + "-container";
378
	jQuery(selectedDiv2).hide('blind');
379
	selectIntLink = "#" + selectedDiv + "-container-input";
380
	jQuery(selectIntLink).val("close");
381
}
382

    
383
function showSave(){
384
	d = document;
385
	selectIntLink = "submit";
386
	textlink = d.getElementById(selectIntLink);
387
	textlink.style.display = "inline";
388
}
389

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

    
411
function hideAllWidgets(){
412
		jQuery('#niftyOutter').fadeTo('slow',0.2);
413
}
414

    
415
function showAllWidgets(){
416
		jQuery('#niftyOutter').fadeTo('slow',1.0);
417
}
418

    
419

    
420
function changeTabDIV(selectedDiv){
421
	var dashpos = selectedDiv.indexOf("-");
422
	var tabclass = selectedDiv.substring(0,dashpos);
423
	d = document;
424

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

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

    
453
			//hide sections we don't want to see
454
			tab2 = tab.substring(0,dashpos);
455
			tabmain = d.getElementById(tab2);
456
			tabmain.style.display = "none";
457

    
458
		}
459
	}
460
}
461
//]]>
462
</script>
463
EOD;
464

    
465

    
466
## Set Page Title and Include Header
467
$pgtitle = array(gettext("Status: Dashboard"));
468
include("head.inc");
469

    
470
?>
471

    
472
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
473

    
474
<script type="text/javascript">
475
//<![CDATA[
476
columns = ['col1','col2','col3','col4', 'col5','col6','col7','col8','col9','col10'];
477
//]]>
478
</script>
479

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

    
486
/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
487
if (!verify_all_package_servers())
488
	print_info_box(package_server_mismatch_message());
489

    
490
if ($savemsg)
491
	print_info_box($savemsg);
492

    
493
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
494

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

    
504
				$periodpos = strpos($widget, ".");
505
				$widgetname = substr($widget, 0, $periodpos);
506
				$nicename = $widgetname;
507
				$nicename = str_replace("_", " ", $nicename);
508
				//make the title look nice
509
				$nicename = ucwords($nicename);
510

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

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

    
549
<form action="index.php" method="post">
550
<input type="hidden" value="" name="sequence" id="sequence" />
551
<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');" />
552

    
553
<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');" />
554

    
555

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

    
572
	foreach($widgetlist as $widget) {
573

    
574
		if(!stristr($widget, "widget.php"))
575
					continue;
576
		$periodpos = strpos($widget, ".");
577
		$widgetname = substr($widget, 0, $periodpos);
578
		if ($widgetname != ""){
579
			$nicename = $widgetname;
580
			$nicename = str_replace("_", " ", $nicename);
581

    
582
			//make the title look nice
583
			$nicename = ucwords($nicename);
584
		}
585

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

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

    
686
		?>
687
		<div style="clear:both;"></div>
688
		<div  id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
689
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input" />
690
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
691
				<div style="float:left;">
692
					<?php
693

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

    
746
	}//end foreach
747
	?>
748
		</div>
749
	<div style="clear:both;"></div>
750
</div>
751

    
752
<?php include("fend.inc"); ?>
753

    
754
<script type="text/javascript">
755
//<![CDATA[
756
	jQuery(document).ready(function(in_event)
757
	{
758
			jQuery('.ui-sortable').sortable({connectWith: '.ui-sortable', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
759

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

    
783
</body>
784
</html>
(94-94/256)