* Copyright (C) 2003-2004 Manuel Kasper * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ require_once('guiconfig.inc'); // if no config entry found, initialize config entry config_read_array('widgets'); $widgetCollection = array(); if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig = $config['widgets']; legacy_html_escape_form_data($pconfig); // set default dashboard view $pconfig['sequence'] = !empty($pconfig['sequence']) ? $pconfig['sequence'] : ''; $pconfig['column_count'] = !empty($pconfig['column_count']) ? $pconfig['column_count'] : 2; // build list of widgets $widgetSeqParts = explode(",", $pconfig['sequence']); foreach (glob('/usr/local/www/widgets/widgets/*.widget.php') as $php_file) { $widgetItem = array(); $widgetItem['name'] = basename($php_file, '.widget.php'); $widgetItem['display_name'] = ucwords(str_replace("_", " ", $widgetItem['name'])); $widgetItem['filename'] = $php_file; $widgetItem['state'] = "none"; /// default sort order $widgetItem['sortKey'] = $widgetItem['name'] == 'system_information' ? "00000000" : "99999999" . $widgetItem['name']; foreach ($widgetSeqParts as $seqPart) { $tmp = explode(':', $seqPart); if (count($tmp) == 3 && explode('-', $tmp[0])[0] == $widgetItem['name']) { $widgetItem['state'] = $tmp[2]; $widgetItem['sortKey'] = $tmp[1]; } } $widgetCollection[] = $widgetItem; } // sort widgets usort($widgetCollection, function ($item1, $item2) { return strcmp(strtolower($item1['sortKey']), strtolower($item2['sortKey'])); }); } elseif ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['origin']) && $_POST['origin'] == 'dashboard') { if (!empty($_POST['sequence'])) { $config['widgets']['sequence'] = $_POST['sequence']; } elseif (isset($config['widgets']['sequence'])) { unset($config['widgets']['sequence']); } if (!empty($_POST['column_count'])) { $config['widgets']['column_count'] = filter_var($_POST['column_count'], FILTER_SANITIZE_NUMBER_INT); } elseif(isset($config['widgets']['column_count'])) { unset($config['widgets']['column_count']); } write_config('Widget configuration has been changed'); header(url_safe('Location: /index.php')); exit; } // handle widget includes foreach (glob("/usr/local/www/widgets/include/*.inc") as $filename) { include($filename); } $product = product::getInstance(); include("head.inc"); ?>

" border="0" alt="logo" style="max-width:380px;" /> " border="0" alt="logo" style="max-width:380px;" />
' . sprintf(gettext('Welcome to %s!'), $product->name()) . "

\n"; echo '

' . gettext('One moment while we start the initial setup wizard.') . "

\n"; echo '

' . gettext('To bypass the wizard, click on the logo in the upper left corner.') . "

\n"; } else { echo '

' . sprintf(gettext('Congratulations! %s is now configured.'), $product->name()) . "

\n"; echo '

' . sprintf(gettext( 'Please consider donating to the project to help us with our overhead costs. ' . 'See %sour website%s to donate or purchase available %s support services.'), '', '', $product->name()) . "

\n"; echo '

' . sprintf(gettext('Click to %scontinue to the dashboard%s.'), '', '') . ' '; echo sprintf(gettext('Or click to %scheck for updates%s.'), '', ''). "

\n"; } ?>