. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ ##|+PRIV ##|*IDENT=page-system-login-logout ##|*NAME=System: Login / Logout / Dashboard ##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard. ##|*MATCH=index.php* ##|-PRIV // Turn on buffering to speed up rendering ini_set('output_buffering', 'true'); // Start buffering with a cache size of 100000 ob_start(null, "1000"); ## Load Essential Includes require_once('guiconfig.inc'); require_once('functions.inc'); require_once('notices.inc'); require_once("pkg-utils.inc"); if (isset($_POST['closenotice'])) { close_notice($_POST['closenotice']); sleep(1); exit; } if (isset($_REQUEST['closenotice'])) { close_notice($_REQUEST['closenotice']); sleep(1); } if ($g['disablecrashreporter'] != true) { // Check to see if we have a crash report $x = 0; if (file_exists("/tmp/PHP_errors.log")) { $total = `/bin/cat /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`; if ($total > 0) { $x++; } } $crash = glob("/var/crash/*"); $skip_files = array(".", "..", "minfree", ""); if (is_array($crash)) { foreach ($crash as $c) { if (!in_array(basename($c), $skip_files)) { $x++; } } if ($x > 0) { $savemsg = sprintf(gettext("%s has detected a crash report or programming bug."), $g['product_name']) . " "; if (isAllowedPage("/crash_reporter.php")) { $savemsg .= sprintf(gettext('Click %1$shere%2$s for more information.'), '', ''); } else { $savemsg .= sprintf(gettext("Contact a firewall administrator for more information.")); } $class = "warning"; } } } ## Include each widget php include file. ## These define vars that specify the widget title and title link. $directory = "/usr/local/www/widgets/include/"; $dirhandle = opendir($directory); $filename = ""; while (($filename = readdir($dirhandle)) !== false) { if (strtolower(substr($filename, -4)) == ".inc" && file_exists($directory . $filename)) { include_once($directory . $filename); } } ##build list of widgets foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file) { $basename = basename($file, '.widget.php'); // Get the widget title that should be in a var defined in the widget's inc file. $widgettitle = ${$basename . '_title'}; if (empty(trim($widgettitle))) { // Fall back to constructing a title from the file name of the widget. $widgettitle = ucwords(str_replace('_', ' ', $basename)); } $known_widgets[$basename . '-0'] = array( 'basename' => $basename, 'title' => $widgettitle, 'display' => 'none', 'multicopy' => ${$basename . '_allow_multiple_widget_copies'} ); } ##if no config entry found, initialize config entry if (!is_array($config['widgets'])) { $config['widgets'] = array(); } if (!is_array($user_settings['widgets'])) { $user_settings['widgets'] = array(); } if ($_POST && $_POST['sequence']) { // Start with the user's widget settings. $widget_settings = $user_settings['widgets']; $widget_sep = ','; $widget_seq_array = explode($widget_sep, rtrim($_POST['sequence'], $widget_sep)); $widget_counter_array = array(); $widget_sep = ''; // Make a record of the counter of each widget that is in use. foreach ($widget_seq_array as $widget_seq_data) { list($basename, $col, $display, $widget_counter) = explode(':', $widget_seq_data); if ($widget_counter != 'next') { $widget_counter_array[$basename][$widget_counter] = true; $widget_sequence .= $widget_sep . $widget_seq_data; $widget_sep = ','; } } // Find any new entry (and do not assume there is only 1 new entry) foreach ($widget_seq_array as $widget_seq_data) { list($basename, $col, $display, $widget_counter) = explode(':', $widget_seq_data); if ($widget_counter == 'next') { // Construct the widget counter of the new widget instance by finding // the first non-negative integer that is not in use. // The reasoning here is that if you just deleted a widget instance, // e.g. had System Information 0,1,2 and deleted 1, // then when you add System Information again it will become instance 1, // which will bring back whatever filter selections happened to be on // the previous instance 1. $instance_num = 0; while (isset($widget_counter_array[$basename][$instance_num])) { $instance_num++; } $widget_sequence .= $widget_sep . $basename . ':' . $col . ':' . $display . ':' . $instance_num; $widget_counter_array[$basename][$instance_num] = true; $widget_sep = ','; } } $widget_settings['sequence'] = $widget_sequence; foreach ($widget_counter_array as $basename => $instances) { foreach ($instances as $instance => $value) { $widgetconfigname = $basename . '-' . $instance . '-config'; if ($_POST[$widgetconfigname]) { $widget_settings[$widgetconfigname] = $_POST[$widgetconfigname]; } } } save_widget_settings($_SESSION['Username'], $widget_settings); header("Location: /"); exit; } ## Load Functions Files require_once('includes/functions.inc.php'); ## Check to see if we have a swap space, ## if true, display, if false, hide it ... if (file_exists("/usr/sbin/swapinfo")) { $swapinfo = `/usr/sbin/swapinfo`; if (stristr($swapinfo, '%') == true) $showswap=true; } ## User recently restored his config. ## If packages are installed lets resync if (file_exists('/conf/needs_package_sync')) { if ($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) { ## If the user has logged into webGUI quickly while the system is booting then do not redirect them to ## the package reinstall page. That is about to be done by the boot script anyway. ## The code in head.inc will put up a notice to the user. if (!platform_booting()) { header('Location: pkg_mgr_install.php?mode=reinstallall'); exit; } } else { @unlink('/conf/needs_package_sync'); } } ## If it is the first time webConfigurator has been ## accessed since initial install show this stuff. if (file_exists('/conf/trigger_initial_wizard')) { ?> <?=$g['product_name']?>.localdomain - <?=$g['product_name']?> first time setup

,/", $dmesgl, $matches)) { $hwcrypto = $matches[1]; break; } } fclose($fd); if (!isset($hwcrypto) && get_single_sysctl("dev.aesni.0.%desc")) { $hwcrypto = get_single_sysctl("dev.aesni.0.%desc"); } } ##build widget saved list information if ($user_settings['widgets']['sequence'] != "") { $dashboardcolumns = isset($user_settings['webgui']['dashboardcolumns']) ? $user_settings['webgui']['dashboardcolumns'] : 2; $pconfig['sequence'] = $user_settings['widgets']['sequence']; $widgetsfromconfig = array(); foreach (explode(',', $pconfig['sequence']) as $line) { $line_items = explode(':', $line); if (count($line_items) == 3) { // There can be multiple copies of a widget on the dashboard. // Default the copy number if it is not present (e.g. from old configs) $line_items[] = 0; } list($basename, $col, $display, $copynum) = $line_items; // be backwards compatible // If the display column information is missing, we will assign a temporary // column here. Next time the user saves the dashboard it will fix itself if ($col == "") { if ($basename == "system_information") { $col = "col1"; } else { $col = "col2"; } } // Limit the column to the current dashboard columns. if (substr($col, 3) > $dashboardcolumns) { $col = "col" . $dashboardcolumns; } $offset = strpos($basename, '-container'); if (false !== $offset) { $basename = substr($basename, 0, $offset); } $widgetkey = $basename . '-' . $copynum; if (isset($user_settings['widgets'][$widgetkey]['descr'])) { $widgettitle = htmlentities($user_settings['widgets'][$widgetkey]['descr']); } else { // Get the widget title that should be in a var defined in the widget's inc file. $widgettitle = ${$basename . '_title'}; if (empty(trim($widgettitle))) { // Fall back to constructing a title from the file name of the widget. $widgettitle = ucwords(str_replace('_', ' ', $basename)); } } $widgetsfromconfig[$widgetkey] = array( 'basename' => $basename, 'title' => $widgettitle, 'col' => $col, 'display' => $display, 'copynum' => $copynum, 'multicopy' => ${$basename . '_allow_multiple_widget_copies'} ); // Update the known_widgets entry so we know if any copy of the widget is being displayed $known_widgets[$basename . '-0']['display'] = $display; } // add widgets that may not be in the saved configuration, in case they are to be displayed later $widgets = $widgetsfromconfig + $known_widgets; ##find custom configurations of a particular widget and load its info to $pconfig foreach ($widgets as $widgetname => $widgetconfig) { if ($config['widgets'][$widgetname . '-config']) { $pconfig[$widgetname . '-config'] = $config['widgets'][$widgetname . '-config']; } } } ## Get the configured options for Show/Hide available widgets panel. $dashboard_available_widgets_hidden = !$user_settings['webgui']['dashboardavailablewidgetspanel']; if ($dashboard_available_widgets_hidden) { $panel_state = 'out'; $panel_body_state = 'in'; } else { $panel_state = 'in'; $panel_body_state = 'out'; } ## Set Page Title and Include Header $pgtitle = array(gettext("Status"), gettext("Dashboard")); include("head.inc"); if ($savemsg) { print_info_box($savemsg, $class); } pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard"); ?>

$widgetconfig): // If the widget supports multiple copies, or no copies are displayed yet, then it is available to add if (($widgetconfig['multicopy']) || ($widgetconfig['display'] == 'none')): ?>

General Setup page.'), '/system.php')?>

$widgetconfig) { if ($widgetconfig['display'] != 'none' && file_exists("/usr/local/www/widgets/widgets/{$widgetconfig['basename']}.widget.php")) { if (!isset($widgetColumns[$widgetconfig['col']])) { $widgetColumns[$widgetconfig['col']] = array(); } $widgetColumns[$widgetconfig['col']][$widgetkey] = $widgetconfig; } } ?>
'; $columnWidgets = $widgetColumns['col'.$currentColumnNumber]; foreach ($columnWidgets as $widgetkey => $widgetconfig) { // Construct some standard names for the ids this widget will use for its commonly-used elements. // Included widget.php code can rely on and use these, so the format does not have to be repeated in every widget.php $widget_panel_body_id = 'widget-' . $widgetkey . '_panel-body'; $widget_panel_footer_id = 'widget-' . $widgetkey . '_panel-footer'; $widget_showallnone_id = 'widget-' . $widgetkey . '_showallnone'; // Compose the widget title and include the title link if available $widgetlink = ${$widgetconfig['basename'] . '_title_link'}; if ((strlen($widgetlink) > 0)) { $wtitle = ' ' . $widgetconfig['title'] . ''; } else { $wtitle = $widgetconfig['title']; } ?>
"; } else { echo '
'; } } ?>
'; } include("foot.inc");