Project

General

Profile

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