Project

General

Profile

Download (23.8 KB) Statistics
| Branch: | Tag: | Revision:
1 2cd6010c Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 b49448ac Scott Ullrich
    index.php
5
    Copyright (C) 2004, 2005 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 0682e26b Colin Smith
    oR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 b49448ac Scott Ullrich
    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 5b237745 Scott Ullrich
*/
33 7ac5a4cb Scott Ullrich
/*
34
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
35
	pfSense_MODULE:	interfaces
36
*/
37 5b237745 Scott Ullrich
38 6b07c15a Matthew Grooms
##|+PRIV
39
##|*IDENT=page-system-login/logout
40 b7ccf315 Erik Fonnesbeck
##|*NAME=System: Login / Logout page / Dashboard
41
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
42 6b07c15a Matthew Grooms
##|*MATCH=index.php*
43
##|-PRIV
44
45 a1d3953f Scott Ullrich
// Turn off csrf for the dashboard
46
$nocsrf = true; 
47
48 acc5dd59 jim-p
// Turn on buffering to speed up rendering
49
ini_set('output_buffering','true');
50
51
// Start buffering with a cache size of 100000
52
ob_start(null, "1000");
53 880637d2 Scott Ullrich
54 acc5dd59 jim-p
## Load Essential Includes
55
require_once('functions.inc');
56
require_once('guiconfig.inc');
57
require_once('notices.inc');
58
59 36365f49 Scott Ullrich
if($g['disablecrashreporter'] != true) {
60
	// Check to see if we have a crash report
61 eac584f3 Scott Ullrich
	$x = 0;
62 a9ee006d Scott Ullrich
	if(file_exists("/tmp/PHP_errors.log")) {
63 dc43ff1e jim-p
		$total = `/usr/bin/grep -vi warning /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
64 a9ee006d Scott Ullrich
		if($total > 0) 
65
			$x++;
66
	}
67
	$crash = glob("/var/crash/*");
68 36365f49 Scott Ullrich
	$skip_files = array(".", "..", "minfree", "");
69
	if(is_array($crash)) {
70
		foreach($crash as $c) {
71
			if (!in_array(basename($c), $skip_files))
72
				$x++;
73
		}
74
		if($x > 0) 
75 a9ee006d Scott Ullrich
			$savemsg = "{$g['product_name']} has detected a crash report or programming bug.  Click <a href='crash_reporter.php'>here</a> for more information.";
76 104faa07 Scott Ullrich
	}
77
}
78
79 acc5dd59 jim-p
##build list of widgets
80
$directory = "/usr/local/www/widgets/widgets/";
81
$dirhandle  = opendir($directory);
82
$filename = "";
83
$widgetnames = array();
84
$widgetfiles = array();
85
$widgetlist = array();
86
87
while (false !== ($filename = readdir($dirhandle))) {
88
	$periodpos = strpos($filename, ".");
89
	$widgetname = substr($filename, 0, $periodpos);
90
	$widgetnames[] = $widgetname;
91
	if ($widgetname != "system_information")
92
		$widgetfiles[] = $filename;
93
}
94
95
##sort widgets alphabetically
96
sort($widgetfiles);
97
98
##insert the system information widget as first, so as to be displayed first
99
array_unshift($widgetfiles, "system_information.widget.php");
100
101
##if no config entry found, initialize config entry
102
if (!is_array($config['widgets'])) {
103
	$config['widgets'] = array();
104
}
105 d772ac32 Erik Kristensen
106 8191b36e Scott Ullrich
	if ($_POST && $_POST['submit']) {
107
		$config['widgets']['sequence'] = $_POST['sequence'];
108
109
		foreach ($widgetnames as $widget){
110
			if ($_POST[$widget . '-config']){
111
				$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
112
			}
113
		}
114
115 5493fad2 Rafael Lucas
		write_config(gettext("Widget configuration has been changed."));
116 8191b36e Scott Ullrich
		header("Location: index.php");
117
		exit;
118
	}
119
120 1df0159c Erik Kristensen
	## Load Functions Files
121
	require_once('includes/functions.inc.php');
122 65d4de2e Scott Dale
	
123 1df0159c Erik Kristensen
	## Check to see if we have a swap space,
124
	## if true, display, if false, hide it ...
125 746ca58a Scott Ullrich
	if(file_exists("/usr/sbin/swapinfo")) {
126
		$swapinfo = `/usr/sbin/swapinfo`;
127
		if(stristr($swapinfo,'%') == true) $showswap=true;
128
	}
129 d772ac32 Erik Kristensen
130 1df0159c Erik Kristensen
	## User recently restored his config.
131
	## If packages are installed lets resync
132 1abb04ea Scott Ullrich
	if(file_exists('/conf/needs_package_sync')) {
133 f9626e57 Erik Fonnesbeck
		if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
134 dc7c57ac Ermal Lu?i
			if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") {
135 6cc843c3 Scott Ullrich
				header('Location: pkg_mgr_install.php?mode=reinstallall');
136
				exit;
137
			}
138 f9626e57 Erik Fonnesbeck
		} else {
139
			conf_mount_rw();
140
			@unlink('/conf/needs_package_sync');
141
			conf_mount_ro();
142 1df0159c Erik Kristensen
		}
143
	}
144 8fecad11 Scott Ullrich
145 709cc6e0 Bill Marquette
	## If it is the first time webConfigurator has been
146 1df0159c Erik Kristensen
	## accessed since initial install show this stuff.
147 1abb04ea Scott Ullrich
	if(file_exists('/conf/trigger_initial_wizard')) {
148 702b324e Scott Ullrich
		echo <<<EOF
149
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
150
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
151
<html>
152
<head>
153 f99c6a23 Erik Fonnesbeck
	<title>{$g['product_name']}.localdomain - {$g['product_name']} first time setup</title>
154 702b324e Scott Ullrich
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
155
	<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
156
	<script type="text/javascript">var theme = "nervecenter"</script>
157
	<script type="text/javascript" src="/themes/nervecenter/loader.js"></script>
158
		
159
EOF;
160 1df0159c Erik Kristensen
161
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
162 5d9f9191 Scott Ullrich
163
		if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css")) 
164
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
165
		else 
166
			echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
167
168 1df0159c Erik Kristensen
		echo "<form>\n";
169
		echo "<center>\n";
170
		echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
171
		echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
172 fffbf46d Carlos Eduardo Ramos
		echo sprintf(gettext("Welcome to %s!\n"),$g['product_name']) . "<p>";
173
		echo gettext("One moment while we start the initial setup wizard.") . "<p>\n";
174
		echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n";
175 c0686139 Carlos Eduardo Ramos
		echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name']) . "\n";
176 1df0159c Erik Kristensen
		echo "</div>\n";
177
		echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
178
		echo "<script type=\"text/javascript\">\n";
179
		echo "NiftyCheck();\n";
180 702b324e Scott Ullrich
		echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
181 1df0159c Erik Kristensen
		echo "</script>\n";
182 1ca54f04 Scott Ullrich
		exit;
183
	}
184
185 bf787c0a Scott Ullrich
186 a5e9c284 Renato Botelho
	## Find out whether there's hardware encryption or not
187 1df0159c Erik Kristensen
	unset($hwcrypto);
188
	$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
189
	if ($fd) {
190
		while (!feof($fd)) {
191
			$dmesgl = fgets($fd);
192 6aa9ddce jim-p
			if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches) or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches) or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches) or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches) or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches) or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)) {
193 1df0159c Erik Kristensen
				$hwcrypto = $matches[1];
194
				break;
195
			}
196 5b237745 Scott Ullrich
		}
197 1df0159c Erik Kristensen
		fclose($fd);
198 5b237745 Scott Ullrich
	}
199 45ee90ed Matthew Grooms
200 7abf7db5 Scott Dale
##build widget saved list information
201 019a94df Scott Dale
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
202
	$pconfig['sequence'] = $config['widgets']['sequence'];
203 3e4e94ce Scott Dale
	
204 bf5ad142 Scott Dale
	$widgetlist = $pconfig['sequence'];
205
	$colpos = array();
206
	$savedwidgetfiles = array();
207
	$widgetname = "";
208
	$widgetlist = explode(",",$widgetlist);
209 019a94df Scott Dale
	
210
	##read the widget position and display information
211 bf5ad142 Scott Dale
	foreach ($widgetlist as $widget){
212
		$dashpos = strpos($widget, "-");		
213
		$widgetname = substr($widget, 0, $dashpos);
214
		$colposition = strpos($widget, ":");		
215
		$displayposition = strrpos($widget, ":");
216
		$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1);
217
		$displayarray[] = substr($widget,$displayposition+1);
218
		$savedwidgetfiles[] = $widgetname . ".widget.php";
219 1db766df Scott Dale
	}
220 019a94df Scott Dale
	
221 7abf7db5 Scott Dale
	##add widgets that may not be in the saved configuration, in case they are to be displayed later
222
    foreach ($widgetfiles as $defaultwidgets){         
223
         if (!in_array($defaultwidgets, $savedwidgetfiles)){
224
             $savedwidgetfiles[] = $defaultwidgets;
225
         }
226
     }   
227
	
228 019a94df Scott Dale
	##find custom configurations of a particular widget and load its info to $pconfig
229
	foreach ($widgetnames as $widget){
230
        if ($config['widgets'][$widget . '-config']){
231
            $pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
232
        }
233
    }   
234
	
235 f617ecbd Scott Dale
	$widgetlist = $savedwidgetfiles;	
236 483e6de8 Scott Ullrich
} else{
237
	// no saved widget sequence found, build default list.
238 8b06c9ff Scott Dale
	$widgetlist = $widgetfiles;
239 3e4e94ce Scott Dale
}
240
241 019a94df Scott Dale
##build list of php include files
242 8b06c9ff Scott Dale
$phpincludefiles = array();
243
$directory = "/usr/local/www/widgets/include/";
244 bf5ad142 Scott Dale
$dirhandle  = opendir($directory);
245
$filename = "";
246
while (false !== ($filename = readdir($dirhandle))) {
247
	$phpincludefiles[] = $filename;
248
}
249
foreach($phpincludefiles as $includename) {
250
	if(!stristr($includename, ".inc"))
251
		continue;	
252
	include($directory . $includename);
253
}
254 81db9b7b Scott Dale
255 019a94df Scott Dale
##begin AJAX
256 1db766df Scott Dale
$jscriptstr = <<<EOD
257
<script language="javascript" type="text/javascript">
258
259 65d4de2e Scott Dale
260 c69c58e2 Vinicius Coque
function widgetAjax(widget) {
261 34eac803 Scott Dale
	uri = "widgets/widgets/" + widget + ".widget.php";
262
	var opt = {
263
	    // Use GET
264 b1678e2d Vinicius Coque
	    type: 'get',
265
	    async: true,
266 34eac803 Scott Dale
	    // Handle 404
267 b1678e2d Vinicius Coque
	    statusCode: {
268
	        404: function(t) {
269
	            alert('Error 404: location "' + t.statusText + '" was not found.');
270
	        }
271 34eac803 Scott Dale
	    },
272
	    // Handle other errors
273 b1678e2d Vinicius Coque
	    error: function(t) {
274 34eac803 Scott Dale
	        alert('Error ' + t.status + ' -- ' + t.statusText);
275
	    },
276 b1678e2d Vinicius Coque
		success: function(data) {
277 f63932ca Vinicius Coque
			widget2 = '#' + widget + "-loader";
278
			jQuery(widget2).fadeOut(1000,function(){
279
				jQuery('#' + widget).show();
280
			});
281 b1678e2d Vinicius Coque
			jQuery('#' + widget).html(data);
282 c69c58e2 Vinicius Coque
	    }
283 34eac803 Scott Dale
	}
284 b1678e2d Vinicius Coque
	jQuery.ajax(uri, opt);
285 34eac803 Scott Dale
}
286 65d4de2e Scott Dale
287
288 c69c58e2 Vinicius Coque
function addWidget(selectedDiv){
289
	selectedDiv2 = '#' + selectedDiv + "-container";
290
	if (jQuery(selectedDiv2).css('display') != "none")
291 5eafc6de Scott Dale
	{
292 c69c58e2 Vinicius Coque
		jQuery(selectedDiv2).effect('shake',{times: 2}, 100);
293 5eafc6de Scott Dale
	}
294
	else
295
	{
296 c69c58e2 Vinicius Coque
		jQuery(selectedDiv2).show('blind');
297 65d4de2e Scott Dale
		widgetAjax(selectedDiv);
298
		selectIntLink = selectedDiv2 + "-input";
299 c69c58e2 Vinicius Coque
		jQuery(selectIntLink).val("show");
300 5eafc6de Scott Dale
		showSave();
301
	}
302 bf5ad142 Scott Dale
}
303 1db766df Scott Dale
304 7abf7db5 Scott Dale
function configureWidget(selectedDiv){
305 c69c58e2 Vinicius Coque
	selectIntLink = '#' + selectedDiv + "-settings";
306
	if (jQuery(selectIntLink).css('display') == "none")
307
		jQuery(selectIntLink).show();
308 25d2d037 Scott Dale
	else
309 c69c58e2 Vinicius Coque
		jQuery(selectIntLink).hide();
310 25d2d037 Scott Dale
}
311
312 7abf7db5 Scott Dale
function showWidget(selectedDiv,swapButtons){
313 65d4de2e Scott Dale
	//appear element
314 c69c58e2 Vinicius Coque
    jQuery('#' + selectedDiv).show('blind');
315 bf5ad142 Scott Dale
    showSave();    
316 c69c58e2 Vinicius Coque
	d = document;
317 1db766df Scott Dale
    if (swapButtons){
318
	    selectIntLink = selectedDiv + "-min";
319
		textlink = d.getElementById(selectIntLink);
320
		textlink.style.display = "inline";
321
	    
322
	    
323
	    selectIntLink = selectedDiv + "-open";
324
		textlink = d.getElementById(selectIntLink);
325
		textlink.style.display = "none";
326 bf5ad142 Scott Dale
327 1db766df Scott Dale
    }
328 65d4de2e Scott Dale
	selectIntLink = selectedDiv + "-container-input";
329 bf5ad142 Scott Dale
	textlink = d.getElementById(selectIntLink);
330 c69c58e2 Vinicius Coque
	textlink.value = "show";
331 bf5ad142 Scott Dale
    
332 f5cfdc98 Scott Dale
}
333 c69c58e2 Vinicius Coque
334 7abf7db5 Scott Dale
function minimizeWidget(selectedDiv,swapButtons){
335 1db766df Scott Dale
	//fade element
336 c69c58e2 Vinicius Coque
    jQuery('#' + selectedDiv).hide('blind');
337 bf5ad142 Scott Dale
    showSave();
338 c69c58e2 Vinicius Coque
	d = document;
339 1db766df Scott Dale
    if (swapButtons){
340
	    selectIntLink = selectedDiv + "-open";
341
		textlink = d.getElementById(selectIntLink);
342
		textlink.style.display = "inline";	    
343
	    
344
	    selectIntLink = selectedDiv + "-min";
345
		textlink = d.getElementById(selectIntLink);
346
		textlink.style.display = "none";
347 c69c58e2 Vinicius Coque
    }
348 65d4de2e Scott Dale
	selectIntLink = selectedDiv + "-container-input";
349 bf5ad142 Scott Dale
	textlink = d.getElementById(selectIntLink);
350
	textlink.value = "hide";	  
351
    
352 1db766df Scott Dale
}
353
354 c69c58e2 Vinicius Coque
function closeWidget(selectedDiv){
355 bf5ad142 Scott Dale
	showSave();
356 c69c58e2 Vinicius Coque
	selectedDiv2 = "#" + selectedDiv + "-container";
357
	jQuery(selectedDiv2).hide('blind');
358
	selectIntLink = "#" + selectedDiv + "-container-input";
359
	jQuery(selectIntLink).val("close");
360 1db766df Scott Dale
}
361
362 bf5ad142 Scott Dale
function showSave(){
363
	d = document;
364
	selectIntLink = "submit";
365
	textlink = d.getElementById(selectIntLink);
366 c69c58e2 Vinicius Coque
	textlink.style.display = "inline";
367 1db766df Scott Dale
}
368
369 c69c58e2 Vinicius Coque
function updatePref(){
370 bf5ad142 Scott Dale
	var widgets = document.getElementsByClassName('widgetdiv');
371
	var widgetSequence = "";
372 c69c58e2 Vinicius Coque
	var firstprint = false;
373 bf5ad142 Scott Dale
	d = document;
374
	for (i=0; i<widgets.length; i++){
375
		if (firstprint)
376
			widgetSequence += ",";
377
		var widget = widgets[i].id;
378
		widgetSequence += widget + ":" + widgets[i].parentNode.id + ":";
379
		widget = widget + "-input";
380
		textlink = d.getElementById(widget).value;
381
		widgetSequence += textlink;
382 c69c58e2 Vinicius Coque
		firstprint = true;
383 bf5ad142 Scott Dale
	}
384
	selectLink = "sequence";
385
	textlink = d.getElementById(selectLink);
386
	textlink.value = widgetSequence;
387 c69c58e2 Vinicius Coque
	return true;
388 bf5ad142 Scott Dale
}
389 1db766df Scott Dale
390 c69c58e2 Vinicius Coque
function hideAllWidgets(){
391
		jQuery('#niftyOutter').fadeTo('slow',0.2);
392 5eafc6de Scott Dale
}
393
394 c69c58e2 Vinicius Coque
function showAllWidgets(){
395
		jQuery('#niftyOutter').fadeTo('slow',1.0);
396 5eafc6de Scott Dale
}
397
398 b9b45ddb Scott Dale
399
function changeTabDIV(selectedDiv){
400
	var dashpos = selectedDiv.indexOf("-");
401
	var tabclass = selectedDiv.substring(0,dashpos);
402
	d = document;
403
404
	//get deactive tabs first
405
	tabclass = tabclass + "-class-tabdeactive"; 
406
	var tabs = document.getElementsByClassName(tabclass);
407
	var incTabSelected = selectedDiv + "-deactive";
408
	for (i=0; i<tabs.length; i++){
409
		var tab = tabs[i].id;
410
		dashpos = tab.lastIndexOf("-");
411
		var tab2 = tab.substring(0,dashpos) + "-deactive";
412
		if (tab2 == incTabSelected){
413
			tablink = d.getElementById(tab2);
414
			tablink.style.display = "none";
415
			tab2 = tab.substring(0,dashpos) + "-active";
416
			tablink = d.getElementById(tab2);
417
			tablink.style.display = "table-cell";
418 c69c58e2 Vinicius Coque
419 b9b45ddb Scott Dale
			//now show main div associated with link clicked
420
			tabmain = d.getElementById(selectedDiv);
421
			tabmain.style.display = "block";
422
		}
423
		else
424 c69c58e2 Vinicius Coque
		{
425 b9b45ddb Scott Dale
			tab2 = tab.substring(0,dashpos) + "-deactive";
426
			tablink = d.getElementById(tab2);
427
			tablink.style.display = "table-cell";
428
			tab2 = tab.substring(0,dashpos) + "-active";
429
			tablink = d.getElementById(tab2);
430 c69c58e2 Vinicius Coque
			tablink.style.display = "none";
431
432 b9b45ddb Scott Dale
			//hide sections we don't want to see
433
			tab2 = tab.substring(0,dashpos);
434
			tabmain = d.getElementById(tab2);
435
			tabmain.style.display = "none";
436 c69c58e2 Vinicius Coque
437 b9b45ddb Scott Dale
		}
438 c69c58e2 Vinicius Coque
	}
439 b9b45ddb Scott Dale
}
440
441 f5cfdc98 Scott Dale
</script>
442
EOD;
443 1db766df Scott Dale
$closehead = false;
444 3e4e94ce Scott Dale
445 1db766df Scott Dale
## Set Page Title and Include Header
446 a6e0e07b Scott Ullrich
$pgtitle = array(gettext("Status: Dashboard"));
447 1db766df Scott Dale
include("head.inc");
448 f6f6947e Scott Ullrich
449
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n";
450
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domTT.js\"></script>\n";
451
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/behaviour.js\"></script>\n";
452
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/fadomatic.js\"></script>\n";
453
454 a8726a3d Scott Ullrich
?>
455 8dbbc3ed Scott Ullrich
456 5b237745 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
457 927ea6e1 jim-p
458 1db766df Scott Dale
<script language="javascript" type="text/javascript">
459
// <![CDATA[
460
columns = ['col1','col2'];
461
// ]]>
462
463 670fe849 Scott Ullrich
</script>
464 1db766df Scott Dale
465 5ffe7500 Scott Ullrich
<?php
466
include("fbegin.inc");
467 f5cfdc98 Scott Dale
echo $jscriptstr;
468 5e237c18 Erik Kristensen
	if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
469
		echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
470 fca795f8 Scott Ullrich
471
if ($savemsg) 
472
	print_info_box($savemsg); 
473
474 810a11bc Scott Ullrich
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
475 c69c58e2 Vinicius Coque
476 0682e26b Colin Smith
?>
477 1db766df Scott Dale
<div id="widgetcontainer" style="display:none">
478 fffbf46d Carlos Eduardo Ramos
		<div id="content1"><h1><?=gettext("Available Widgets"); ?></h1><p><?php
479 16f556c5 Scott Dale
			$widgetfiles_add = $widgetfiles;
480
			sort($widgetfiles_add);
481 c69c58e2 Vinicius Coque
			foreach($widgetfiles_add as $widget) {	
482 1db766df Scott Dale
				if(!stristr($widget, "widget.php"))
483
					continue;		
484
				
485
				$periodpos = strpos($widget, ".");
486
				$widgetname = substr($widget, 0, $periodpos);
487
				$nicename = $widgetname;
488 f69aa687 Scott Dale
				$nicename = str_replace("_", " ", $nicename);
489 1db766df Scott Dale
				//make the title look nice
490 16f556c5 Scott Dale
				$nicename = ucwords($nicename);
491
				
492
				$widgettitle = $widgetname . "_title";
493
				$widgettitlelink = $widgetname . "_title_link";
494
					if ($$widgettitle != "")
495
					{
496 88f71068 Scott Dale
						//echo widget title 
497
						?>
498 7abf7db5 Scott Dale
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
499 16f556c5 Scott Dale
						<u><?php echo $$widgettitle; ?></u></span><br>
500
						<?php 
501
					}
502
					else {?>
503 7abf7db5 Scott Dale
						<span style="cursor: pointer;" onclick='return addWidget("<?php echo $widgetname; ?>")'>
504 16f556c5 Scott Dale
						<u><?php echo $nicename; ?></u></span><br><?php
505
					}
506 1db766df Scott Dale
			}
507 f5cfdc98 Scott Dale
		?>
508 1db766df Scott Dale
		</p>
509
	</div>
510
</div>
511
512 d72fc17b Scott Dale
<div id="welcomecontainer" style="display:none">
513 65d4de2e Scott Dale
		<div id="welcome-container">
514 d72fc17b Scott Dale
			<h1>
515 16f556c5 Scott Dale
				<div style="float:left;width:80%;padding: 2px">
516 fffbf46d Carlos Eduardo Ramos
					<?=gettext("Welcome to the Dashboard page"); ?>!
517 d72fc17b Scott Dale
				</div>
518 16f556c5 Scott Dale
				<div onclick="domTT_close(this);showAllWidgets();" style="float:right;width:8%; cursor:pointer;padding: 5px;" >
519 d72fc17b Scott Dale
					<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_close.gif" />
520
				</div>
521
				<div style="clear:both;"></div>
522
			</h1>
523
			<p>
524 5493fad2 Rafael Lucas
			<?=gettext("This page allows you to customize the information you want to be displayed!");?><br/>
525
			<?=gettext("To get started click the");?> <img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"> <?=gettext("icon to add widgets.");?><br/>
526 d72fc17b Scott Dale
			<br/>
527 5493fad2 Rafael Lucas
			<?=gettext("You can move any widget around by clicking and dragging the title.");?>			
528 d72fc17b Scott Dale
			</p>
529
	</div>
530
</div>
531
532 927ea6e1 jim-p
<form action="index.php" method="post">
533 bf5ad142 Scott Dale
<input type="hidden" value="" name="sequence" id="sequence">
534 fffbf46d Carlos Eduardo Ramos
<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');" />
535 5eafc6de Scott Dale
536 fffbf46d Carlos Eduardo Ramos
<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');" />
537 5eafc6de Scott Dale
538
539 bf5ad142 Scott Dale
&nbsp;&nbsp;&nbsp;
540 5493fad2 Rafael Lucas
		<input id="submit" name="submit" type="submit" style="display:none" onclick="return updatePref();" class="formbtn" value="<?=gettext("Save Settings");?>" />
541 bf5ad142 Scott Dale
</p>
542 927ea6e1 jim-p
</form>
543 1db766df Scott Dale
<div id="niftyOutter">
544
	<?php
545
	$totalwidgets = count($widgetfiles);
546 c9cfb807 Scott Dale
	$halftotal = $totalwidgets / 2 - 2;
547
	$widgetcounter = 0;
548 8b06c9ff Scott Dale
	$directory = "/usr/local/www/widgets/widgets/";
549 1db766df Scott Dale
	$printed = false;
550
	$firstprint = false;
551
	?> 
552 ea298b82 Scott Dale
	<div id="col1" style="float:left;width:49%;padding-bottom:40px">		
553 8b06c9ff Scott Dale
	<?php	
554 135e9b3b Scott Dale
		
555 bf5ad142 Scott Dale
	foreach($widgetlist as $widget) {
556 c9cfb807 Scott Dale
		
557 1db766df Scott Dale
		if(!stristr($widget, "widget.php"))
558 3f304727 Scott Dale
					continue;
559 1db766df Scott Dale
		$periodpos = strpos($widget, ".");
560
		$widgetname = substr($widget, 0, $periodpos);	
561 bf5ad142 Scott Dale
		if ($widgetname != ""){
562 3f304727 Scott Dale
			$nicename = $widgetname;
563
			$nicename = str_replace("_", " ", $nicename);
564
			
565
			//make the title look nice
566
			$nicename = ucwords($nicename);
567 8b06c9ff Scott Dale
		}
568 1db766df Scott Dale
		
569 135e9b3b Scott Dale
		if ($config['widgets'] && $pconfig['sequence'] != ""){
570 01da41cf Bill Marquette
			switch($displayarray[$widgetcounter]){
571
				case "show":
572 8b06c9ff Scott Dale
					$divdisplay = "block";
573
					$display = "block";
574
					$inputdisplay = "show";					
575 7abf7db5 Scott Dale
					$showWidget = "none";
576 8b06c9ff Scott Dale
					$mindiv = "inline";
577 01da41cf Bill Marquette
					break;
578
				case "hide":
579 8b06c9ff Scott Dale
					$divdisplay = "block";
580 01da41cf Bill Marquette
					$display = "none";
581
					$inputdisplay = "hide";		
582
					$showWidget = "inline";
583
					$mindiv = "none";
584 a6efee26 jim-p
					break;
585 01da41cf Bill Marquette
				case "close":
586
					$divdisplay = "none";
587 8b06c9ff Scott Dale
					$display = "block";
588 01da41cf Bill Marquette
					$inputdisplay = "close";			
589 7abf7db5 Scott Dale
					$showWidget = "none";
590 8b06c9ff Scott Dale
					$mindiv = "inline";
591 01da41cf Bill Marquette
					break;
592
				default:
593 8b06c9ff Scott Dale
					$divdisplay = "none";
594
					$display = "block";
595 01da41cf Bill Marquette
					$inputdisplay = "none";
596 7abf7db5 Scott Dale
					$showWidget = "none";
597 8b06c9ff Scott Dale
					$mindiv = "inline";
598 01da41cf Bill Marquette
					break;
599
			}
600
		} else {
601
			if ($firstprint == false){
602
				$divdisplay = "block";
603
				$display = "block";
604
				$inputdisplay = "show";
605
				$showWidget = "none";
606
				$mindiv = "inline";
607
				$firstprint = true;
608
			} else {
609
				switch ($widget) {
610
					case "interfaces.widget.php":
611
					case "traffic_graphs.widget.php":
612
						$divdisplay = "block";
613
						$display = "block";
614
						$inputdisplay = "show";
615
						$showWidget = "none";
616
						$mindiv = "inline";
617
						break;
618
					default:
619
						$divdisplay = "none";
620
						$display = "block";
621
						$inputdisplay = "close";
622
						$showWidget = "none";
623
						$mindiv = "inline";
624
						break;
625 8b06c9ff Scott Dale
				}
626 775d112b Scott Dale
			}
627 bf5ad142 Scott Dale
		}
628 1db766df Scott Dale
		
629 135e9b3b Scott Dale
		if ($config['widgets'] && $pconfig['sequence'] != ""){
630 bf5ad142 Scott Dale
			if ($colpos[$widgetcounter] == "col2" && $printed == false)
631
			{
632
				$printed = true;
633
				?>
634
				</div>
635 ea298b82 Scott Dale
				<div id="col2" style="float:right;width:49%;padding-bottom:40px">		
636 bf5ad142 Scott Dale
				<?php
637
			}
638
		}
639
		else if ($widgetcounter >= $halftotal && $printed == false){
640 1db766df Scott Dale
			$printed = true;
641
			?>
642
			</div>
643 8b06c9ff Scott Dale
			<div id="col2" style="float:right;width:49%;padding-bottom:40px">		
644 1db766df Scott Dale
			<?php
645 bf5ad142 Scott Dale
		}
646 16f556c5 Scott Dale
		
647
		?>
648 1db766df Scott Dale
		<div style="clear:both;"></div>
649 65d4de2e Scott Dale
		<div  id="<?php echo $widgetname;?>-container" class="widgetdiv" style="display:<?php echo $divdisplay; ?>;">
650
			<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-container-input" name="<?php echo $widgetname;?>-container-input">
651 3da0d006 Scott Dale
			<div id="<?php echo $widgetname;?>-topic" class="widgetheader" style="cursor:move">
652 1db766df Scott Dale
				<div style="float:left;">
653 16f556c5 Scott Dale
					<?php 
654
					
655
					$widgettitle = $widgetname . "_title";
656
					$widgettitlelink = $widgetname . "_title_link";
657
					if ($$widgettitle != "")
658
					{
659
						//only show link if defined
660
						if ($$widgettitlelink != "") {?>						
661
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
662
						<?php }
663
							//echo widget title
664
							echo $$widgettitle; 
665
						if ($$widgettitlelink != "") { ?>
666
						</span></u>						
667
						<?php }
668
					}
669
					else{		
670
						if ($$widgettitlelink != "") {?>						
671
						<u><span onClick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
672
						<?php }
673
						echo $nicename;
674
							if ($$widgettitlelink != "") { ?>
675
						</span></u>						
676
						<?php }
677
					}
678
					?>
679 1db766df Scott Dale
				</div>
680 bf5ad142 Scott Dale
				<div align="right" style="float:right;">	
681 7abf7db5 Scott Dale
					<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" /></div>									
682
					<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" /></div>	
683
					<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"/></div>												
684
					<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" /></div>	
685 1db766df Scott Dale
				</div>
686
				<div style="clear:both;"></div>
687
			</div>
688 3da0d006 Scott Dale
			<?php if ($divdisplay != "block") { ?>
689
			<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;">
690
				<br>	
691
					<center>
692 fffbf46d Carlos Eduardo Ramos
						<img src="./themes/<?= $g['theme']; ?>/images/misc/widget_loader.gif" width=25 height=25 alt="<?=gettext("Loading selected widget"); ?>...">
693 3da0d006 Scott Dale
					</center>	
694
				<br>
695
			</div> <?php } if ($divdisplay != "block") $display = none; ?>
696 34eac803 Scott Dale
			<div id="<?php echo $widgetname;?>" style="display:<?php echo $display; ?>;">				
697 b9b45ddb Scott Dale
				<?php 
698 3da0d006 Scott Dale
					if ($divdisplay == "block")
699 b9b45ddb Scott Dale
					{
700
						include($directory . $widget);
701 34eac803 Scott Dale
					}	
702 b9b45ddb Scott Dale
				 ?>
703 1db766df Scott Dale
			</div>
704
			<div style="clear:both;"></div>
705
		</div>
706
		<?php 	
707
	$widgetcounter++;
708 8b06c9ff Scott Dale
		
709 1db766df Scott Dale
	}//end foreach	
710
	?>			
711 8b06c9ff Scott Dale
		</div>
712 1db766df Scott Dale
	<div style="clear:both;"></div>
713 d772ac32 Erik Kristensen
</div>
714 561d55ff Erik Kristensen
715 d772ac32 Erik Kristensen
<?php include("fend.inc"); ?>
716 7f1f5492 Scott Ullrich
	    
717
<script type="text/javascript">
718 c69c58e2 Vinicius Coque
	jQuery(document).ready(function(in_event)
719 5eafc6de Scott Dale
	{		
720 c69c58e2 Vinicius Coque
			jQuery('#col1').sortable({connectWith: '#col2', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
721
			jQuery('#col2').sortable({connectWith: '#col1', dropOnEmpty: true, handle: '.widgetheader', change: showSave});
722
723 24f53f5c Scott Ullrich
	<?php if (!$config['widgets']  && $pconfig['sequence'] != ""){ ?>
724 5eafc6de Scott Dale
			hideAllWidgets();		    
725 65d4de2e Scott Dale
			domTT_activate('welcome1', null, 'x', 287, 'y', 107, 'content', document.getElementById('welcome-container'), 'type', 'sticky', 'closeLink', '','delay', 1000, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');		
726 d72fc17b Scott Dale
	<?php } ?>
727 8bf02470 Bill Marquette
	});
728 838fa668 Scott Ullrich
</script>
729
<?php
730 1db766df Scott Dale
	//build list of javascript include files
731 775d112b Scott Dale
	$jsincludefiles = array();
732 1db766df Scott Dale
	$directory = "widgets/javascript/";
733
	$dirhandle  = opendir($directory);
734
	$filename = "";
735
	while (false !== ($filename = readdir($dirhandle))) {
736
   		$jsincludefiles[] = $filename;
737
	}
738
	foreach($jsincludefiles as $jsincludename) {
739
		if(!stristr($jsincludename, ".js"))
740 838fa668 Scott Ullrich
			continue;
741
		echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";	
742 1db766df Scott Dale
	}
743 838fa668 Scott Ullrich
?>
744 1db766df Scott Dale
</script>
745 927ea6e1 jim-p
746 5b237745 Scott Ullrich
</body>
747 dc7c57ac Ermal Lu?i
</html>