Project

General

Profile

Download (24.6 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / index.php @ a1b66bec

1
<?php
2
/* $Id$ */
3
/*
4
	index.php
5
	Copyright (C) 2004-2012 Scott Ullrich
6
	All rights reserved.
7

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

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

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

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

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

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

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

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

    
51

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

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

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

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

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

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

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

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

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

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

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

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

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

    
142
	## User recently restored his config.
143
	## If packages are installed lets resync
144
	if(file_exists('/conf/needs_package_sync')) {
145
		if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
146
			if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
147
				header('Location: pkg_mgr_install.php?mode=reinstallall');
148
				exit;
149
			}
150
		} else {
151
			conf_mount_rw();
152
			@unlink('/conf/needs_package_sync');
153
			conf_mount_ro();
154
		}
155
	}
156

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

    
171
EOF;
172

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

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

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

    
199

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

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

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

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

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

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

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

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

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

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

    
307

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

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

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

    
342

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

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

    
352
}
353

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

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

    
372
}
373

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

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

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

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

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

    
418

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

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

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

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

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

    
464

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

    
469
?>
470

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

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

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

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

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

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

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

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

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

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

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

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

    
554

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

    
571
	foreach($widgetlist as $widget) {
572

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

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

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

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

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

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

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

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

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

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

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