Project

General

Profile

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