diff --git a/plist b/plist index 2cfe99c61..63b357930 100644 --- a/plist +++ b/plist @@ -2197,42 +2197,6 @@ /usr/local/www/vpn_ipsec_settings.php /usr/local/www/vpn_openvpn_client.php /usr/local/www/vpn_openvpn_server.php -/usr/local/www/widgets/api/get.php -/usr/local/www/widgets/api/plugins/system.inc -/usr/local/www/widgets/api/plugins/temperature.inc -/usr/local/www/widgets/include/carp_status.inc -/usr/local/www/widgets/include/cpu_usage.inc -/usr/local/www/widgets/include/gateways.inc -/usr/local/www/widgets/include/interface_list.inc -/usr/local/www/widgets/include/interface_statistics.inc -/usr/local/www/widgets/include/ipsec.inc -/usr/local/www/widgets/include/log.inc -/usr/local/www/widgets/include/monit.inc -/usr/local/www/widgets/include/ntp_status.inc -/usr/local/www/widgets/include/openvpn.inc -/usr/local/www/widgets/include/services_status.inc -/usr/local/www/widgets/include/system_log.inc -/usr/local/www/widgets/include/thermal_sensors.inc -/usr/local/www/widgets/include/traffic_graph.inc -/usr/local/www/widgets/include/wireguard.inc -/usr/local/www/widgets/widgets/carp_status.widget.php -/usr/local/www/widgets/widgets/cpu_usage.widget.php -/usr/local/www/widgets/widgets/gateways.widget.php -/usr/local/www/widgets/widgets/interface_list.widget.php -/usr/local/www/widgets/widgets/interface_statistics.widget.php -/usr/local/www/widgets/widgets/ipsec.widget.php -/usr/local/www/widgets/widgets/log.widget.php -/usr/local/www/widgets/widgets/monit.widget.php -/usr/local/www/widgets/widgets/ntp_status.widget.php -/usr/local/www/widgets/widgets/openvpn.widget.php -/usr/local/www/widgets/widgets/picture.widget.php -/usr/local/www/widgets/widgets/rss.widget.php -/usr/local/www/widgets/widgets/services_status.widget.php -/usr/local/www/widgets/widgets/system_information.widget.php -/usr/local/www/widgets/widgets/system_log.widget.php -/usr/local/www/widgets/widgets/thermal_sensors.widget.php -/usr/local/www/widgets/widgets/traffic_graphs.widget.php -/usr/local/www/widgets/widgets/wireguard.widget.php /usr/local/www/wizard.php /usr/local/www/xmlrpc.php @sample /usr/local/etc/bogons.sample diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/SystemController.php b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/SystemController.php index dcd38cb1b..e20e75a92 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/SystemController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/SystemController.php @@ -41,28 +41,6 @@ use OPNsense\Core\Config; */ class SystemController extends ApiControllerBase { - private function formatUptime($uptime) - { - $days = floor($uptime / (3600 * 24)); - $hours = floor(($uptime % (3600 * 24)) / 3600); - $minutes = floor(($uptime % 3600) / 60); - $seconds = $uptime % 60; - - if ($days > 0) { - $plural = $days > 1 ? gettext("days") : gettext("day"); - return sprintf( - "%d %s, %02d:%02d:%02d", - $days, - $plural, - $hours, - $minutes, - $seconds - ); - } else { - return sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds); - } - } - public function haltAction() { if ($this->request->isPost()) { @@ -208,154 +186,4 @@ class SystemController extends ApiControllerBase return ["status" => "failed"]; } - - public function systemInformationAction() - { - $config = Config::getInstance()->object(); - $backend = new Backend(); - - $product = json_decode($backend->configdRun('firmware product'), true); - $current = explode('_', $product['product_version'])[0]; - /* information from changelog, more accurate for production release */ - $from_changelog = strpos($product['product_id'], '-devel') === false && - !empty($product['product_latest']) && - $product['product_latest'] != $current; - - /* update status from last check, also includes major releases */ - $from_check = !empty($product['product_check']['upgrade_sets']) || - !empty($product['product_check']['downgrade_packages']) || - !empty($product['product_check']['new_packages']) || - !empty($product['product_check']['reinstall_packages']) || - !empty($product['product_check']['remove_packages']) || - !empty($product['product_check']['upgrade_packages']); - - $versions = [ - sprintf('%s %s-%s', $product['product_name'], $product['product_version'], $product['product_arch']), - php_uname('s') . ' ' . php_uname('r'), - trim($backend->configdRun('system openssl version')), - ]; - - if (!empty($product['product_license']['valid_to'])) { - $versions[] = sprintf(gettext('Licensed until %s'), $product['product_license']['valid_to']); - } - - $response = [ - 'name' => $config->system->hostname . '.' . $config->system->domain, - 'versions' => $versions, - 'updates' => ($from_changelog || $from_check) - ? gettext('Click to view pending updates.') - : gettext('Click to check for updates.'), - ]; - - return $response; - } - - public function systemTimeAction() - { - $config = Config::getInstance()->object(); - $boottime = json_decode((new Backend())->configdRun('system sysctl values kern.boottime'), true); - preg_match("/sec = (\d+)/", $boottime['kern.boottime'], $matches); - - $last_change = date("D M j G:i:s T Y", !empty($config->revision->time) ? intval($config->revision->time) : 0); - - $response = [ - 'uptime' => $this->formatUptime(time() - $matches[1]), - 'datetime' => date("D M j G:i:s T Y"), - 'config' => $last_change, - ]; - - return $response; - } - - public function systemResourcesAction() - { - $result = []; - - $mem = json_decode((new Backend())->configdpRun('system sysctl values', implode(',', [ - 'hw.physmem', - 'vm.stats.vm.v_page_count', - 'vm.stats.vm.v_inactive_count', - 'vm.stats.vm.v_cache_count', - 'vm.stats.vm.v_free_count', - 'kstat.zfs.misc.arcstats.size' - ])), true); - - if (!empty($mem['vm.stats.vm.v_page_count'])) { - $pc = $mem['vm.stats.vm.v_page_count']; - $ic = $mem['vm.stats.vm.v_inactive_count']; - $cc = $mem['vm.stats.vm.v_cache_count']; - $fc = $mem['vm.stats.vm.v_free_count']; - $result['memory']['total'] = $mem['hw.physmem']; - $result['memory']['total_frmt'] = sprintf('%d', $mem['hw.physmem'] / 1024 / 1024); - $result['memory']['used'] = round(((($pc - ($ic + $cc + $fc))) / $pc) * $mem['hw.physmem'], 0); - $result['memory']['used_frmt'] = sprintf('%d', $result['memory']['used'] / 1024 / 1024); - if (!empty($mem['kstat.zfs.misc.arcstats.size'])) { - $arc_size = $mem['kstat.zfs.misc.arcstats.size']; - $result['memory']['arc'] = $arc_size; - $result['memory']['arc_frmt'] = sprintf('%d', $arc_size / 1024 / 1024); - $result['memory']['arc_txt'] = sprintf(gettext('ARC size %d MB'), $arc_size / 1024 / 1024); - } - } else { - $result['memory']['used'] = gettext('N/A'); - } - - return $result; - } - - public function systemDiskAction() - { - $result = []; - - $disk_info = json_decode((new Backend())->configdRun('system diag disk'), true); - - if (!empty($disk_info['storage-system-information'])) { - foreach ($disk_info['storage-system-information']['filesystem'] as $fs) { - if (!in_array(trim($fs['type']), ['cd9660', 'msdosfs', 'tmpfs', 'ufs', 'zfs'])) { - continue; - } - - $result['devices'][] = [ - 'device' => $fs['name'], - 'type' => trim($fs['type']), - 'blocks' => $fs['blocks'], - 'used' => $fs['used'], - 'available' => $fs['available'], - 'used_pct' => $fs['used-percent'], - 'mountpoint' => $fs['mounted-on'], - ]; - } - } - - return $result; - } - - public function systemMbufAction() - { - return json_decode((new Backend())->configdRun('system show mbuf'), true); - } - - public function systemSwapAction() - { - return json_decode((new Backend())->configdRun('system show swapinfo'), true); - } - - public function systemTemperatureAction() - { - $result = []; - - foreach (explode("\n", (new Backend())->configdRun('system temp')) as $temp) { - $parts = explode('=', $temp); - if (count($parts) >= 2) { - $tempItem = array(); - $tempItem['device'] = $parts[0]; - $tempItem['device_seq'] = filter_var($tempItem['device'], FILTER_SANITIZE_NUMBER_INT); - $tempItem['temperature'] = trim(str_replace('C', '', $parts[1])); - $tempItem['type'] = strpos($tempItem['device'], 'hw.acpi') !== false ? "zone" : "core"; - $tempItem['type_translated'] = $tempItem['type'] == "zone" ? gettext("Zone") : gettext("Core"); - $result[] = $tempItem; - } - } - - return $result; - } } diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/SystemController.php b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/SystemController.php index 97a632d08..23f301546 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/SystemController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/SystemController.php @@ -38,6 +38,28 @@ use OPNsense\Core\Backend; */ class SystemController extends ApiControllerBase { + private function formatUptime($uptime) + { + $days = floor($uptime / (3600 * 24)); + $hours = floor(($uptime % (3600 * 24)) / 3600); + $minutes = floor(($uptime % 3600) / 60); + $seconds = $uptime % 60; + + if ($days > 0) { + $plural = $days > 1 ? gettext("days") : gettext("day"); + return sprintf( + "%d %s, %02d:%02d:%02d", + $days, + $plural, + $hours, + $minutes, + $seconds + ); + } else { + return sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds); + } + } + public function memoryAction() { $data = json_decode((new Backend())->configdRun('system show vmstat_mem'), true); @@ -64,4 +86,154 @@ class SystemController extends ApiControllerBase } return $data; } + + public function systemInformationAction() + { + $config = Config::getInstance()->object(); + $backend = new Backend(); + + $product = json_decode($backend->configdRun('firmware product'), true); + $current = explode('_', $product['product_version'])[0]; + /* information from changelog, more accurate for production release */ + $from_changelog = strpos($product['product_id'], '-devel') === false && + !empty($product['product_latest']) && + $product['product_latest'] != $current; + + /* update status from last check, also includes major releases */ + $from_check = !empty($product['product_check']['upgrade_sets']) || + !empty($product['product_check']['downgrade_packages']) || + !empty($product['product_check']['new_packages']) || + !empty($product['product_check']['reinstall_packages']) || + !empty($product['product_check']['remove_packages']) || + !empty($product['product_check']['upgrade_packages']); + + $versions = [ + sprintf('%s %s-%s', $product['product_name'], $product['product_version'], $product['product_arch']), + php_uname('s') . ' ' . php_uname('r'), + trim($backend->configdRun('system openssl version')), + ]; + + if (!empty($product['product_license']['valid_to'])) { + $versions[] = sprintf(gettext('Licensed until %s'), $product['product_license']['valid_to']); + } + + $response = [ + 'name' => $config->system->hostname . '.' . $config->system->domain, + 'versions' => $versions, + 'updates' => ($from_changelog || $from_check) + ? gettext('Click to view pending updates.') + : gettext('Click to check for updates.'), + ]; + + return $response; + } + + public function systemTimeAction() + { + $config = Config::getInstance()->object(); + $boottime = json_decode((new Backend())->configdRun('system sysctl values kern.boottime'), true); + preg_match("/sec = (\d+)/", $boottime['kern.boottime'], $matches); + + $last_change = date("D M j G:i:s T Y", !empty($config->revision->time) ? intval($config->revision->time) : 0); + + $response = [ + 'uptime' => $this->formatUptime(time() - $matches[1]), + 'datetime' => date("D M j G:i:s T Y"), + 'config' => $last_change, + ]; + + return $response; + } + + public function systemResourcesAction() + { + $result = []; + + $mem = json_decode((new Backend())->configdpRun('system sysctl values', implode(',', [ + 'hw.physmem', + 'vm.stats.vm.v_page_count', + 'vm.stats.vm.v_inactive_count', + 'vm.stats.vm.v_cache_count', + 'vm.stats.vm.v_free_count', + 'kstat.zfs.misc.arcstats.size' + ])), true); + + if (!empty($mem['vm.stats.vm.v_page_count'])) { + $pc = $mem['vm.stats.vm.v_page_count']; + $ic = $mem['vm.stats.vm.v_inactive_count']; + $cc = $mem['vm.stats.vm.v_cache_count']; + $fc = $mem['vm.stats.vm.v_free_count']; + $result['memory']['total'] = $mem['hw.physmem']; + $result['memory']['total_frmt'] = sprintf('%d', $mem['hw.physmem'] / 1024 / 1024); + $result['memory']['used'] = round(((($pc - ($ic + $cc + $fc))) / $pc) * $mem['hw.physmem'], 0); + $result['memory']['used_frmt'] = sprintf('%d', $result['memory']['used'] / 1024 / 1024); + if (!empty($mem['kstat.zfs.misc.arcstats.size'])) { + $arc_size = $mem['kstat.zfs.misc.arcstats.size']; + $result['memory']['arc'] = $arc_size; + $result['memory']['arc_frmt'] = sprintf('%d', $arc_size / 1024 / 1024); + $result['memory']['arc_txt'] = sprintf(gettext('ARC size %d MB'), $arc_size / 1024 / 1024); + } + } else { + $result['memory']['used'] = gettext('N/A'); + } + + return $result; + } + + public function systemDiskAction() + { + $result = []; + + $disk_info = json_decode((new Backend())->configdRun('system diag disk'), true); + + if (!empty($disk_info['storage-system-information'])) { + foreach ($disk_info['storage-system-information']['filesystem'] as $fs) { + if (!in_array(trim($fs['type']), ['cd9660', 'msdosfs', 'tmpfs', 'ufs', 'zfs'])) { + continue; + } + + $result['devices'][] = [ + 'device' => $fs['name'], + 'type' => trim($fs['type']), + 'blocks' => $fs['blocks'], + 'used' => $fs['used'], + 'available' => $fs['available'], + 'used_pct' => $fs['used-percent'], + 'mountpoint' => $fs['mounted-on'], + ]; + } + } + + return $result; + } + + public function systemMbufAction() + { + return json_decode((new Backend())->configdRun('system show mbuf'), true); + } + + public function systemSwapAction() + { + return json_decode((new Backend())->configdRun('system show swapinfo'), true); + } + + public function systemTemperatureAction() + { + $result = []; + + foreach (explode("\n", (new Backend())->configdRun('system temp')) as $temp) { + $parts = explode('=', $temp); + if (count($parts) >= 2) { + $tempItem = array(); + $tempItem['device'] = $parts[0]; + $tempItem['device_seq'] = filter_var($tempItem['device'], FILTER_SANITIZE_NUMBER_INT); + $tempItem['temperature'] = trim(str_replace('C', '', $parts[1])); + $tempItem['type'] = strpos($tempItem['device'], 'hw.acpi') !== false ? "zone" : "core"; + $tempItem['type_translated'] = $tempItem['type'] == "zone" ? gettext("Zone") : gettext("Core"); + $result[] = $tempItem; + } + } + + return $result; + } } diff --git a/src/opnsense/mvc/app/models/OPNsense/Core/ACL/ACL.xml b/src/opnsense/mvc/app/models/OPNsense/Core/ACL/ACL.xml index 8beb16b24..c3a3c8699 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Core/ACL/ACL.xml +++ b/src/opnsense/mvc/app/models/OPNsense/Core/ACL/ACL.xml @@ -12,6 +12,9 @@ Lobby: Login / Logout / Dashboard index.php* + ui/core/dashboard + api/core/dashboard/* + api/core/system/systemInformation @@ -51,43 +54,98 @@ Dashboard (all) index.php* - widgets/widgets/*.widget.php* - widgets/api/get.php* - ui/core/dashboard - ui/js/widgets/* + ui/core/dashboard* api/core/dashboard/* - api/diagnostics/dns/reverse_lookup* - api/routes/gateway/status* + api/diagnostics/interface/get_vip_status + api/diagnostics/cpu_usage/* + api/diagnostics/firewall/streamLog api/diagnostics/interface/getInterfaceNames - api/diagnostics/firewall/log + api/diagnostics/firewall/pf_states + api/routes/gateway/status + api/interfaces/overview/interfacesInfo + api/diagnostics/traffic/* + api/diagnostics/system/systemDisk + api/diagnostics/system/system_mbuf + api/diagnostics/system/systemResources + api/diagnostics/system/system_swap + api/diagnostics/system/systemInformation + api/diagnostics/system/systemTemperature api/monit/status/get/xml - api/diagnostics/traffic/interface + api/diagnostics/log/core/* + api/ipsec/connections/* + api/ipsec/leases/* + api/ipsec/sessions/* - - Dashboard (widgets only) - - widgets/widgets/*.widget.php* - api/routes/gateway/status* - api/diagnostics/interface/getInterfaceNames - api/diagnostics/firewall/log - api/monit/status/get/xml - - - - Dashboard: Interfaces overview widget + Diagnostics: Authentication @@ -315,6 +373,7 @@ Diagnostics: Logs: Firewall: Live View ui/diagnostics/firewall/log* + api/diagnostics/firewall/streamLog api/diagnostics/firewall/log* api/diagnostics/interface/getInterfaceNames* api/diagnostics/dns/reverse_lookup* @@ -607,6 +666,7 @@ ui/routing/configuration api/routing/settings/* + api/routes/gateway/status diff --git a/src/opnsense/mvc/app/models/OPNsense/Core/Menu/Menu.xml b/src/opnsense/mvc/app/models/OPNsense/Core/Menu/Menu.xml index 3186c3644..4670d3bdb 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Core/Menu/Menu.xml +++ b/src/opnsense/mvc/app/models/OPNsense/Core/Menu/Menu.xml @@ -1,16 +1,15 @@ - + - - - + + - + diff --git a/src/opnsense/www/js/widgets/Disk.js b/src/opnsense/www/js/widgets/Disk.js index d99ae4662..d3dc5a637 100644 --- a/src/opnsense/www/js/widgets/Disk.js +++ b/src/opnsense/www/js/widgets/Disk.js @@ -152,7 +152,7 @@ export default class Disk extends BaseGaugeWidget { } async onWidgetTick() { - const data = await this.ajaxGet('/api/core/system/systemDisk'); + const data = await this.ajaxGet('/api/diagnostics/system/systemDisk'); if (data.devices !== undefined) { let set = this.detailed_chart.config.data; let init = set.labels.length === 0; diff --git a/src/opnsense/www/js/widgets/Mbuf.js b/src/opnsense/www/js/widgets/Mbuf.js index c194be48b..8fbe5e79d 100644 --- a/src/opnsense/www/js/widgets/Mbuf.js +++ b/src/opnsense/www/js/widgets/Mbuf.js @@ -41,7 +41,7 @@ export default class Mbuf extends BaseGaugeWidget { } async onWidgetTick() { - const data = await this.ajaxGet('/api/core/system/system_mbuf'); + const data = await this.ajaxGet('/api/diagnostics/system/system_mbuf'); let current = parseInt(data['mbuf-statistics']['cluster-total']); let limit = parseInt(data['mbuf-statistics']['cluster-max']); super.updateChart([current, (limit - current)]); diff --git a/src/opnsense/www/js/widgets/Memory.js b/src/opnsense/www/js/widgets/Memory.js index 731db6dc1..3b4077982 100644 --- a/src/opnsense/www/js/widgets/Memory.js +++ b/src/opnsense/www/js/widgets/Memory.js @@ -50,7 +50,7 @@ export default class Memory extends BaseGaugeWidget { } async onWidgetTick() { - const data = await this.ajaxGet('/api/core/system/systemResources'); + const data = await this.ajaxGet('/api/diagnostics/system/systemResources'); if (data.memory.total !== undefined) { let used = parseInt(data.memory.used_frmt); let arc = data.memory.hasOwnProperty('arc') ? parseInt(data.memory.arc_frmt) : 0; diff --git a/src/opnsense/www/js/widgets/Metadata/Core.xml b/src/opnsense/www/js/widgets/Metadata/Core.xml index 457b2d8c4..a31aafd62 100644 --- a/src/opnsense/www/js/widgets/Metadata/Core.xml +++ b/src/opnsense/www/js/widgets/Metadata/Core.xml @@ -12,7 +12,7 @@ SystemInformation.js - /api/core/system/systemInformation + /api/diagnostics/system/systemInformation System Information @@ -27,7 +27,7 @@ Interfaces.js - /api/interfaces/overview/* + /api/interfaces/overview/interfacesInfo Interfaces @@ -49,7 +49,7 @@ InterfaceStatistics.js - /api/interfaces/statistics/* + /api/diagnostics/traffic/interface Interface Statistics @@ -76,7 +76,7 @@ Memory.js - /api/core/system/systemResources + /api/diagnostics/system/systemResources Memory usage @@ -88,7 +88,7 @@ Disk.js - /api/core/system/systemDisk + /api/diagnostics/system/systemDisk Disk usage @@ -133,7 +133,7 @@ Mbuf.js - /api/core/system/system_mbuf + /api/diagnostics/system/system_mbuf Mbuf Usage @@ -144,7 +144,7 @@ Swap.js - /api/core/system/system_swap + /api/diagnostics/system/system_swap Swap Usage @@ -180,7 +180,7 @@ ThermalSensors.js - /api/core/system/systemTemperature + /api/diagnostics/system/systemTemperature Thermal Sensors @@ -215,7 +215,7 @@ LiveLog.js - /api/diagnostics/log/* + /api/diagnostics/log/core/* Live Log @@ -228,7 +228,8 @@ IpsecLeases.js - /api/ipsec/* + /api/ipsec/connections/* + /api/ipsec/leases/* IPsec Leases @@ -242,7 +243,8 @@ IpsecTunnels.js - /api/ipsec/* + /api/ipsec/connections/* + /api/ipsec/sessions/* IPsec Tunnels diff --git a/src/opnsense/www/js/widgets/Swap.js b/src/opnsense/www/js/widgets/Swap.js index d92a6b26e..f74119756 100644 --- a/src/opnsense/www/js/widgets/Swap.js +++ b/src/opnsense/www/js/widgets/Swap.js @@ -42,14 +42,13 @@ export default class Swap extends BaseGaugeWidget { } async onWidgetTick() { - const data = await this.ajaxGet('/api/core/system/system_swap'); + const data = await this.ajaxGet('/api/diagnostics/system/system_swap'); let total = 0; let used = 0; for (const swapDevice of data['swap']) { total += parseInt(swapDevice.total); used += parseInt(swapDevice.used); } - super.updateChart([(used / 1024), (total - used) / 1024]); } } diff --git a/src/opnsense/www/js/widgets/SystemInformation.js b/src/opnsense/www/js/widgets/SystemInformation.js index ddeec69b7..42fc3d0f7 100644 --- a/src/opnsense/www/js/widgets/SystemInformation.js +++ b/src/opnsense/www/js/widgets/SystemInformation.js @@ -42,14 +42,14 @@ export default class SystemInformation extends BaseTableWidget { } async onWidgetTick() { - const data = await this.ajaxGet('/api/core/system/systemTime'); + const data = await this.ajaxGet('/api/diagnostics/system/systemTime'); $('#datetime').text(data['datetime']); $('#uptime').text(data['uptime']); $('#config').text(data['config']); } async onMarkupRendered() { - const data = await this.ajaxGet('/api/core/system/systemInformation'); + const data = await this.ajaxGet('/api/diagnostics/system/systemInformation'); let rows = []; for (let [key, value] of Object.entries(data)) { if (!key in this.translations) { diff --git a/src/opnsense/www/js/widgets/ThermalSensors.js b/src/opnsense/www/js/widgets/ThermalSensors.js index 4584097d4..3547929de 100644 --- a/src/opnsense/www/js/widgets/ThermalSensors.js +++ b/src/opnsense/www/js/widgets/ThermalSensors.js @@ -179,7 +179,7 @@ export default class ThermalSensors extends BaseWidget { } async onWidgetTick() { - const data = await this.ajaxGet('/api/core/system/systemTemperature'); + const data = await this.ajaxGet('/api/diagnostics/system/systemTemperature'); if (!data || !data.length) { $(`.${this.id}-chart-container`).html(` ${this.translations.unconfigured} diff --git a/src/www/index.php b/src/www/index.php index b88104138..ce91fe589 100644 --- a/src/www/index.php +++ b/src/www/index.php @@ -30,404 +30,73 @@ 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"); -?> - - - - - - -
-
- -

- -

- -
-
-
-
-
-
-
-
- - logo - - logo - -
-
- ' . 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"; - } - ?> -
-
-
-
+if (isset($config['trigger_initial_wizard']) || isset($_GET['wizard_done'])): + include("head.inc"); + ?> + + + +
+
+ +

+ +

+
-
-
- - - - - - - - - - -
-
- - - -
-
-
-
- - -
-
-
- + + + name(); -// available plugins -$result['plugins'] = []; -// collected data -$result['data'] = []; - -// probe plugins -foreach (glob(__DIR__."/plugins/*.inc") as $filename) { - $pluginName = basename($filename, '.inc'); - $result['plugins'][] = $pluginName; - if (in_array($pluginName, $loadPluginsList)) { - require $filename; - $pluginFunctionName = $pluginName."_api"; - if (function_exists($pluginName."_api")) { - $result['data'][$pluginName] = $pluginFunctionName(); - } - } -} -// output result -legacy_html_escape_form_data($result); -echo json_encode($result); diff --git a/src/www/widgets/api/plugins/system.inc b/src/www/widgets/api/plugins/system.inc deleted file mode 100644 index e637b5419..000000000 --- a/src/www/widgets/api/plugins/system.inc +++ /dev/null @@ -1,222 +0,0 @@ -/dev/null', $states); - $result['pf']['states'] = count($states) > 0 ? filter_var($states[0], FILTER_SANITIZE_NUMBER_INT) : 0; - - $result['mbuf'] = array(); - exec('/usr/bin/netstat -mb | /usr/bin/grep "mbuf clusters in use"', $mbufs); - $result['mbuf']['total'] = count($mbufs) > 0 ? explode('/', $mbufs[0])[2] : 0; - $result['mbuf']['max'] = count($mbufs) > 0 ? explode(' ', explode('/', $mbufs[0])[3])[0] : 0; - - $totalMem = get_single_sysctl("vm.stats.vm.v_page_count"); - $inactiveMem = get_single_sysctl("vm.stats.vm.v_inactive_count"); - $cachedMem = get_single_sysctl("vm.stats.vm.v_cache_count"); - $freeMem = get_single_sysctl("vm.stats.vm.v_free_count"); - $result['memory']['total'] = get_single_sysctl('hw.physmem'); - if ($totalMem != 0) { - $result['memory']['used'] = round(((($totalMem - ($inactiveMem + $cachedMem + $freeMem))) / $totalMem)*$result['memory']['total'], 0); - $arcMem = get_single_sysctl('kstat.zfs.misc.arcstats.size'); - if (!empty($arcMem)) { - $result['memory']['arc'] = $arcMem; - $result['memory']['arc_txt'] = sprintf(gettext("ARC size %d MB"), $arcMem/1024/1024); - } - - } else { - $result['memory']['used'] = gettext('N/A'); - } - - return $result; -} - -function system_api_disk() -{ - $result = array(); - $result['swap'] = array(); - exec("/usr/sbin/swapinfo -k", $swap_info); - foreach ($swap_info as $line) { - if (strpos($line,'/dev/') !== false) { - $parts = preg_split('/\s+/', $line); - $swapItem = array(); - $swapItem['device'] = $parts[0]; - $swapItem['total'] = $parts[1]; - $swapItem['used'] = $parts[2]; - $result['swap'][] = $swapItem; - } - } - - $types = [ 'cd9660', 'msdosfs', 'tmpfs', 'ufs', 'zfs' ]; - $result['devices'] = []; - exec('/bin/df -ahT', $disk_info); - foreach ($disk_info as $line) { - if (strpos($line, 'Filesystem') !== 0) { - $parts = preg_split('/\s+/', $line); - $diskItem = []; - $diskItem['device'] = $parts[0]; - $diskItem['type'] = $parts[1]; - $diskItem['size'] = $parts[2]; - $diskItem['used'] = $parts[3]; - $diskItem['available'] = $parts[4]; - $diskItem['capacity'] = $parts[5]; - $diskItem['mountpoint'] = $parts[6]; - if (in_array($diskItem['type'], $types)) { - $result['devices'][] = $diskItem; - } - } - } - - return $result; -} - -function system_api_versions($product) -{ - $result = []; - - $result[] = sprintf('%s %s-%s', $product['product_name'], $product['product_version'], $product['product_arch']); - $result[] = php_uname('s') . ' ' . php_uname('r'); - $result[] = shell_safe('/usr/local/bin/openssl version | cut -f -2 -d \' \''); - - if (!empty($product['product_license']['valid_to'])) { - $result[] = gettext('Licensed until') . ' ' . $product['product_license']['valid_to']; - } - - return $result; -} - -function system_api_firmware($product) -{ - $ret = gettext('Click to check for updates.'); - - $current = explode('_', $product['product_version'])[0]; - - /* information from changelog, more accurate for production release */ - $from_changelog = strpos($product['product_id'], '-devel') === false && - !empty($product['product_latest']) && - $product['product_latest'] != $current; - - /* update status from last check, also includes major releases */ - $from_check = !empty($product['product_check']['upgrade_sets']) || - !empty($product['product_check']['downgrade_packages']) || - !empty($product['product_check']['new_packages']) || - !empty($product['product_check']['reinstall_packages']) || - !empty($product['product_check']['remove_packages']) || - !empty($product['product_check']['upgrade_packages']); - - if ($from_changelog || $from_check) { - $ret = gettext('Click to view pending updates.'); - } - - return $ret; -} - -/** - * widget system data - */ -function system_api() -{ - $result = array(); - $product = json_decode(configd_run('firmware product'), true); - $result['versions'] = system_api_versions($product); - $result['cpu'] = system_api_cpu_stats(); - $result['date_frmt'] = date("D M j G:i:s T Y"); - $result['date_time'] = time(); - preg_match("/sec = (\d+)/", get_single_sysctl("kern.boottime"), $matches); - $result['uptime'] = $result['date_time'] - $matches[1]; - $result['config'] = system_api_config(); - $result['kernel'] = system_api_kernel(); - $result['disk'] = system_api_disk(); - $result['firmware'] = system_api_firmware($product); - - return $result; -} diff --git a/src/www/widgets/api/plugins/temperature.inc b/src/www/widgets/api/plugins/temperature.inc deleted file mode 100644 index af32ce51e..000000000 --- a/src/www/widgets/api/plugins/temperature.inc +++ /dev/null @@ -1,54 +0,0 @@ -= 2) { - $tempItem = array(); - $tempItem['device'] = $parts[0]; - $tempItem['device_seq'] = filter_var($tempItem['device'], FILTER_SANITIZE_NUMBER_INT); - $tempItem['temperature'] = trim(str_replace('C', '', $parts[1])); - $tempItem['type'] = strpos($tempItem['device'], 'hw.acpi') !== false ? "zone" : "core"; - $tempItem['type_translated'] = $tempItem['type'] == "zone" ? gettext("Zone") : gettext("Core"); - $result[] = $tempItem; - } - } - - usort($result, function ($item1, $item2) { - return strcmp(strtolower($item1['device']), strtolower($item2['device'])); - }); - - return $result; -} diff --git a/src/www/widgets/include/carp_status.inc b/src/www/widgets/include/carp_status.inc deleted file mode 100644 index c5649f4bb..000000000 --- a/src/www/widgets/include/carp_status.inc +++ /dev/null @@ -1,4 +0,0 @@ - - - - - - - - - - - - -
- - - - - - - -"; - } elseif ($status == "MASTER") { - $status_i18n = gettext("MASTER"); - echo ""; - } elseif ($status == "BACKUP") { - $status_i18n = gettext("BACKUP"); - echo ""; - } elseif ($status == "INIT") { - $status_i18n = gettext("INIT"); - echo ""; - } else { - $status_i18n = ""; - } - if (!empty($carp['subnet'])):?> -   -   - - -
- ', ''); ?> -
diff --git a/src/www/widgets/widgets/cpu_usage.widget.php b/src/www/widgets/widgets/cpu_usage.widget.php deleted file mode 100644 index fba742537..000000000 --- a/src/www/widgets/widgets/cpu_usage.widget.php +++ /dev/null @@ -1,105 +0,0 @@ - - * Copyright (C) 2004-2005 Manuel Kasper - * Copyright (C) 2004-2005 Jonathan Watt - * 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"); -require_once("system.inc"); - -?> - - - - - - - - - -
-
- -
-
diff --git a/src/www/widgets/widgets/gateways.widget.php b/src/www/widgets/widgets/gateways.widget.php deleted file mode 100644 index 5aee46b3f..000000000 --- a/src/www/widgets/widgets/gateways.widget.php +++ /dev/null @@ -1,161 +0,0 @@ - - * - * 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 ($_SERVER['REQUEST_METHOD'] === 'GET') { - $pconfig = array(); - $pconfig['gatewaysfilter'] = !empty($config['widgets']['gatewaysfilter']) ? - explode(',', $config['widgets']['gatewaysfilter']) : array(); - $pconfig['gatewaysinvert'] = !empty($config['widgets']['gatewaysinvert']) ? '1' : ''; -} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { - $pconfig = $_POST; - if (!empty($pconfig['gatewaysfilter'])) { - $config['widgets']['gatewaysfilter'] = implode(',', $pconfig['gatewaysfilter']); - } elseif (isset($config['widgets']['gatewaysfilter'])) { - unset($config['widgets']['gatewaysfilter']); - } - if (!empty($pconfig['gatewaysinvert'])) { - $config['widgets']['gatewaysinvert'] = 1; - } elseif (isset($config['widgets']['gatewaysinvert'])) { - unset($config['widgets']['gatewaysinvert']); - } - write_config("Saved Gateways Filter via Dashboard"); - header(url_safe('Location: /index.php')); - exit; -} - -$gateways = (new \OPNsense\Routing\Gateways())->gatewaysIndexedByName(); -?> - - - - - - - - - - - - - - -
- - - diff --git a/src/www/widgets/widgets/interface_list.widget.php b/src/www/widgets/widgets/interface_list.widget.php deleted file mode 100644 index 7d1ec266e..000000000 --- a/src/www/widgets/widgets/interface_list.widget.php +++ /dev/null @@ -1,179 +0,0 @@ - - * Copyright (C) 2004-2005 Manuel Kasper - * Copyright (C) 2004-2005 Jonathan Watt - * 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"); -require_once("widgets/include/interface_list.inc"); -require_once("interfaces.inc"); - -$interfaces = get_configured_interface_with_descr(); - -if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $pconfig = array(); - $pconfig['interfaceslistfilter'] = !empty($config['widgets']['interfaceslistfilter']) ? - explode(',', $config['widgets']['interfaceslistfilter']) : array(); - $pconfig['interfaceslistinvert'] = !empty($config['widgets']['interfaceslistinvert']) ? '1' : ''; -} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { - $pconfig = $_POST; - if (!empty($pconfig['interfaceslistfilter'])) { - $config['widgets']['interfaceslistfilter'] = implode(',', $pconfig['interfaceslistfilter']); - } elseif (isset($config['widgets']['interfaceslistfilter'])) { - unset($config['widgets']['interfaceslistfilter']); - } - if (!empty($pconfig['interfaceslistinvert'])) { - $config['widgets']['interfaceslistinvert'] = 1; - } elseif (isset($config['widgets']['interfaceslistinvert'])) { - unset($config['widgets']['interfaceslistinvert']); - } - write_config("Saved Interface List Filter via Dashboard"); - header(url_safe('Location: /index.php')); - exit; -} - -?> - - - - - - - $ifname): - $listed = in_array($ident, $pconfig['interfaceslistfilter']); - $listed = !empty($pconfig['interfaceslistinvert']) ? $listed : !$listed; - if (!$listed) { - continue; - } - - list($primary4,, $bits4) = interfaces_primary_address($ident); - list($primary6,, $bits6) = interfaces_primary_address6($ident); -?> - - - - - - - - -
- - ' : '' ?> - -
- - - diff --git a/src/www/widgets/widgets/interface_statistics.widget.php b/src/www/widgets/widgets/interface_statistics.widget.php deleted file mode 100644 index 298dc13bd..000000000 --- a/src/www/widgets/widgets/interface_statistics.widget.php +++ /dev/null @@ -1,164 +0,0 @@ - - * Copyright (C) 2004-2005 Manuel Kasper - * Copyright (C) 2004-2005 Jonathan Watt - * 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"); -require_once("widgets/include/interface_list.inc"); -require_once("interfaces.inc"); - -$interfaces = get_configured_interface_with_descr(); - -if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $pconfig = array(); - $pconfig['interfacesstatisticsfilter'] = !empty($config['widgets']['interfacesstatisticsfilter']) ? - explode(',', $config['widgets']['interfacesstatisticsfilter']) : array(); - $pconfig['interfacesstatisticsinvert'] = !empty($config['widgets']['interfacesstatisticsinvert']) ? '1' : ''; -} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { - $pconfig = $_POST; - if (!empty($pconfig['interfacesstatisticsfilter'])) { - $config['widgets']['interfacesstatisticsfilter'] = implode(',', $pconfig['interfacesstatisticsfilter']); - } elseif (isset($config['widgets']['interfacesstatisticsfilter'])) { - unset($config['widgets']['interfacesstatisticsfilter']); - } - if (!empty($pconfig['interfacesstatisticsinvert'])) { - $config['widgets']['interfacesstatisticsinvert'] = 1; - } elseif (isset($config['widgets']['interfacesstatisticsinvert'])) { - unset($config['widgets']['interfacesstatisticsinvert']); - } - write_config("Saved Interface Statistics Filter via Dashboard"); - header(url_safe('Location: /index.php')); - exit; -} - -$ifvalues = array( - 'pkg_in' => gettext('Packets In'), - 'pkg_out' => gettext('Packets Out'), - 'bytes_in' => gettext('Bytes In'), - 'bytes_out' => gettext('Bytes Out'), - 'errors_in' => gettext('Errors In'), - 'errors_out' => gettext('Errors Out'), - 'collisions' => gettext('Collisions'), -); - -?> - - - - - - - - - $iflabel): ?> - - - - $ifname): - $listed = in_array($ifdescr, $pconfig['interfacesstatisticsfilter']); - $listed = !empty($pconfig['interfacesstatisticsinvert']) ? $listed : !$listed; - if (!$listed) { - continue; - } ?> - - - - - - - -
 
~
- - - diff --git a/src/www/widgets/widgets/ipsec.widget.php b/src/www/widgets/widgets/ipsec.widget.php deleted file mode 100644 index 59f3a4562..000000000 --- a/src/www/widgets/widgets/ipsec.widget.php +++ /dev/null @@ -1,235 +0,0 @@ - - Copyright (C) 2004-2005 Manuel Kasper - Copyright (C) 2004-2005 Jonathan Watt - 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"); - -$ipsec_detail_array = []; -$ipsec_tunnels = []; -$ipsec_leases = []; - -$ipsec_leases = json_decode(configd_run("ipsec list leases"), true); -if (!is_array($ipsec_leases) || empty($ipsec_leases['leases'])) { - $ipsec_leases = []; -} else { - $ipsec_leases = $ipsec_leases['leases']; -} -$ipsec_status = json_decode(configd_run("ipsec list status"), true) ?? []; - -// parse configured tunnels -foreach ($ipsec_status as $status_key => $status_value) { - if (isset($status_value['children']) && is_array($status_value['children'])) { - foreach($status_value['children'] as $child_status_key => $child_status_value) { - $ipsec_tunnels[$child_status_key] = array('active' => false, - 'local-addrs' => $status_value['local-addrs'], - 'remote-addrs' => $status_value['remote-addrs'], - ); - $ipsec_tunnels[$child_status_key]['local-ts'] = implode(', ', $child_status_value['local-ts']); - $ipsec_tunnels[$child_status_key]['remote-ts'] = implode(', ', $child_status_value['remote-ts']); - } - } - foreach ($status_value['sas'] as $sas_key => $sas_value) { - foreach ($sas_value['child-sas'] as $child_sa_key => $child_sa_value) { - if (!isset($ipsec_tunnels[$child_sa_key])) { - /* XXX bug on strongSwan 5.5.2 appends -3 and -4 here? */ - $child_sa_key = preg_replace('/-[^-]+$/', '', $child_sa_key); - } - if (isset($ipsec_tunnels[$child_sa_key])) { - $ipsec_tunnels[$child_sa_key]['active'] = true; - } - } - } -} -// Initialize variable aggregated_data and loop through the ipsec_leases array to fetch the data for user, address and online status. Used later for div ipsec-mobile. Additionally count the unique_users in the same foreach loop, used for mobile_users count. -$aggregated_data = []; -$unique_users = []; - -foreach ($ipsec_leases as $lease) { - // For each unique user, initialize an empty array - if (!isset($aggregated_data[$lease['user']])) { - $aggregated_data[$lease['user']] = []; - } - // Add the lease data to this user's array of leases - $aggregated_data[$lease['user']][] = [ - 'address' => $lease['address'], - 'online' => $lease['online'] - ]; - - // Count unique users in ipsec_leases array if lease is online - if ($lease['online']) { - $unique_users[$lease['user']] = true; - } -} - -// Return the number of unique_users as mobile_users -$mobile_users = count($unique_users); - -?> - - -
-
-      -
-
-      -
-
-      -
-
- -
- - - - - - - - - - - - - - - -
- $ipsec) { - $activetunnels += $ipsec['active'] === true; - } - echo $activetunnels; -?> - - - -
-
- - - - diff --git a/src/www/widgets/widgets/log.widget.php b/src/www/widgets/widgets/log.widget.php deleted file mode 100644 index 24b3a2e99..000000000 --- a/src/www/widgets/widgets/log.widget.php +++ /dev/null @@ -1,246 +0,0 @@ - - * Copyright (C) 2004-2005 T. Lechat - * Copyright (C) 2004-2005 Manuel Kasper - * Copyright (C) 2004-2005 Jonathan Watt - * 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"); -require_once("interfaces.inc"); - -$pconfig = $_POST; - -if (is_numeric($pconfig['filterlogentries'] ?? null)) { - $config['widgets']['filterlogentries'] = $pconfig['filterlogentries']; - $config['widgets']['filterlogentriesupdateinterval'] = $pconfig['filterlogentriesupdateinterval']; - - $acts = array(); - if ($pconfig['actpass']) { - $acts[] = 'Pass'; - } - if ($pconfig['actblock']) { - $acts[] = 'Block'; - } - if ($pconfig['actreject']) { - $acts[] = 'Reject'; - } - - if (!empty($acts)) { - $config['widgets']['filterlogentriesacts'] = implode(' ', $acts); - } elseif (isset($config['widgets']['filterlogentriesacts'])) { - unset($config['widgets']['filterlogentriesacts']); - } - - if (!empty($pconfig['filterlogentriesinterfaces'])) { - $config['widgets']['filterlogentriesinterfaces'] = implode(',', $pconfig['filterlogentriesinterfaces']); - } elseif (isset($config['widgets']['filterlogentriesinterfaces'])) { - unset($config['widgets']['filterlogentriesinterfaces']); - } - - write_config('Saved Filter Log Entries via Dashboard'); - header(url_safe('Location: /index.php')); - exit; -} - -$nentries = isset($config['widgets']['filterlogentries']) ? $config['widgets']['filterlogentries'] : 5; -$updateinterval = isset($config['widgets']['filterlogentriesupdateinterval']) ? $config['widgets']['filterlogentriesupdateinterval'] : 2; -$nentriesacts = isset($config['widgets']['filterlogentriesacts']) ? explode(" ", $config['widgets']['filterlogentriesacts']) : array('Pass', 'Block', 'Reject'); -$nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ? $config['widgets']['filterlogentriesinterfaces'] : ''; - -?> - - - - - - - - - - - - - - - - - - - -
diff --git a/src/www/widgets/widgets/monit.widget.php b/src/www/widgets/widgets/monit.widget.php deleted file mode 100644 index 557b0e1ed..000000000 --- a/src/www/widgets/widgets/monit.widget.php +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -
- - - diff --git a/src/www/widgets/widgets/ntp_status.widget.php b/src/www/widgets/widgets/ntp_status.widget.php deleted file mode 100644 index 2960ba7a0..000000000 --- a/src/www/widgets/widgets/ntp_status.widget.php +++ /dev/null @@ -1,510 +0,0 @@ - - Copyright (C) 2004-2005 Manuel Kasper - Copyright (C) 2004-2005 Jonathan Watt - 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"); -require_once("widgets/include/ntp_status.inc"); - -if ($_REQUEST['updateme']) { -//this block displays only on ajax refresh - exec("/usr/local/sbin/ntpq -pn | /usr/bin/tail +3", $ntpq_output); - $ntpq_counter = 0; - foreach ($ntpq_output as $line) { - if (substr($line, 0, 1) == "*") { - //Active NTP Peer - $line = substr($line, 1); - $peerinfo = preg_split("/[\s\t]+/", $line); - if ($peerinfo[2] == "1") { - $syncsource = $peerinfo[0] . " (stratum " . $peerinfo[2] . ", " . $peerinfo[1] . ")"; - } else { - $syncsource = $peerinfo[0] . " (stratum " . $peerinfo[2] . ")"; - } - $ntpq_counter++; - } elseif (substr($line, 0, 1) == "o") { - //Local PPS Peer - $line = substr($line, 1); - $peerinfo = preg_split("/[\s\t]+/", $line); - $syncsource = $peerinfo[1] . " (stratum " . $peerinfo[2] . ", PPS)"; - $ntpq_counter++; - } - } - - exec("/usr/local/sbin/ntpq -c clockvar", $ntpq_clockvar_output); - foreach ($ntpq_clockvar_output as $line) { - if (substr($line, 0, 9) == "timecode=") { - $tmp = explode('"', $line); - $tmp = $tmp[1]; - if (substr($tmp, 0, 6) == '$GPRMC') { - $gps_vars = explode(",", $tmp); - $gps_ok = ($gps_vars[2] == "A"); - if ($gps_ok) { - $gps_lat_deg = substr($gps_vars[3], 0, 2); - $gps_lat_min = substr($gps_vars[3], 2) / 60.0; - $gps_lon_deg = substr($gps_vars[5], 0, 3); - $gps_lon_min = substr($gps_vars[5], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; - $gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; - $gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1); - } - $gps_la = $gps_vars[4]; - $gps_lo = $gps_vars[6]; - } elseif (substr($tmp, 0, 6) == '$GPGGA') { - $gps_vars = explode(",", $tmp); - $gps_ok = $gps_vars[6]; - if ($gps_ok) { - $gps_lat_deg = substr($gps_vars[2], 0, 2); - $gps_lat_min = substr($gps_vars[2], 2) / 60.0; - $gps_lon_deg = substr($gps_vars[4], 0, 3); - $gps_lon_min = substr($gps_vars[4], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; - $gps_lat = $gps_lat * (($gps_vars[3] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; - $gps_lon = $gps_lon * (($gps_vars[5] == "E") ? 1 : -1); - } - $gps_alt = $gps_vars[9]; - $gps_alt_unit = $gps_vars[10]; - $gps_sat = $gps_vars[7]; - $gps_la = $gps_vars[3]; - $gps_lo = $gps_vars[5]; - } elseif (substr($tmp, 0, 6) == '$GPGLL') { - $gps_vars = explode(",", $tmp); - $gps_ok = ($gps_vars[6] == "A"); - if ($gps_ok) { - $gps_lat_deg = substr($gps_vars[1], 0, 2); - $gps_lat_min = substr($gps_vars[1], 2) / 60.0; - $gps_lon_deg = substr($gps_vars[3], 0, 3); - $gps_lon_min = substr($gps_vars[3], 3) / 60.0; - $gps_lat = $gps_lat_deg + $gps_lat_min; - $gps_lat = $gps_lat * (($gps_vars[2] == "N") ? 1 : -1); - $gps_lon = $gps_lon_deg + $gps_lon_min; - $gps_lon = $gps_lon * (($gps_vars[4] == "E") ? 1 : -1); - } - $gps_la = $gps_vars[2]; - $gps_lo = $gps_vars[4]; - } - } - } - - if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && (isset($gps_ok))) { - //GSV message is only enabled by init commands in services_ntpd_gps.php for SureGPS board - $gpsport = fopen("/dev/gps0", "r+"); - while ($gpsport) { - $buffer = fgets($gpsport); - if (substr($buffer, 0, 6)=='$GPGSV') { - //echo $buffer."\n"; - $gpgsv = explode(',', $buffer); - $gps_satview = $gpgsv[3]; - break; - } - } - } -?> - - - - - - - - - - - - - - - - - - - - -
Sync Source - - - - - -
- - - - -
- -
-. ***/ - -/* Prevent this page from being cached (though some browsers still - cache the page anyway, which is why we use cookies). This is - only important if the cookie is deleted while the page is still - cached (and for ancient browsers that don't know about Cache-Control). - If that's not an issue, you may be able to get away with - "Cache-Control: private" instead. */ - -/* Grab the current server time. */ -$gDate = time(); -/* Are the seconds shown by default? When changing this, also change the - JavaScript client code's definition of clockShowsSeconds below to match. */ -$gClockShowsSeconds = true; - -function getServerDateItems($inDate) -{ - return date('Y,n,j,G,', $inDate).intval(date('i', $inDate)).','.intval(date('s', $inDate)); - // year (4-digit),month,day,hours (0-23),minutes,seconds - // use intval to strip leading zero from minutes and seconds - // so JavaScript won't try to interpret them in octal - // (use intval instead of ltrim, which translates '00' to '') -} - -function clockTimeString($inDate, $showSeconds) -{ - return date($showSeconds ? 'G:i:s' : 'g:i', $inDate).' '; -} -/*** Clock -- end of server-side support code ***/ -?> - - - - - - - - - - - - - - - - - -
Server Time -
- -
-
- -
- - - diff --git a/src/www/widgets/widgets/openvpn.widget.php b/src/www/widgets/widgets/openvpn.widget.php deleted file mode 100644 index c14c46bc8..000000000 --- a/src/www/widgets/widgets/openvpn.widget.php +++ /dev/null @@ -1,187 +0,0 @@ -Instances->Instance->iterateItems() as $key => $node) { - if (!empty((string)$node->enabled)) { - $section = "openvpn-{$node->role}"; - $default_port = ($section == 'openvpn-server') ? 1194 : ''; - $default_desc = ($section == 'openvpn-server') ? 'Server' : 'Client'; - $server = [ - 'port' => !empty((string)$node->port) ? (string)$node->port : $default_port, - 'mode' => (string)$node->role, - 'description' => !empty((string)$node->description) ? (string)$node->description : $default_desc, - 'name' => "{$node->description} {$node->proto}:{$node->port}", - 'vpnid' => $key - ]; - $result[$section][] = $server; - } - } - - return $result; -} - -$openvpn_status = json_decode(configd_run('openvpn connections client,server'), true) ?? []; -$openvpn_cfg = openvpn_config(); -foreach ($openvpn_cfg as $section => &$ovpncfg) { - foreach ($ovpncfg as &$item) { - $opt = ($section == 'openvpn-server') ? 'server' : 'client'; - if (!empty($openvpn_status[$opt][$item['vpnid']])) { - $item = array_merge($openvpn_status[$opt][$item['vpnid']], $item); - } - } -} - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

', array_filter([$conn['real_address'] ?? '', $conn['virtual_address'] ?? '', $conn['virtual_ipv6_address'] ?? ''])) ?> - '> - -
', array_filter([$server['real_address'] ?? '', $server['virtual_address'] ?? '', $server['virtual_ipv6_address'] ?? ''])) ?> - '> -
-
- - - - - - - - - - - - - - - - - - - - - - - - -

', array_filter([$client['real_address'] ?? '', $client['virtual_address'] ?? '', $client['virtual_ipv6_address'] ?? ''])) ?> - '> -
- - - - - - -
- - * - * 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 ($_GET['getpic']=="true") { - $pic_type_s = explode(".", $config['widgets']['picturewidget_filename']); - $pic_type = $pic_type_s[1]; - if ($config['widgets']['picturewidget']) { - $data = base64_decode($config['widgets']['picturewidget']); - } - header("Content-Disposition: inline; filename=\"{$config['widgets']['picturewidget_filename']}\""); - header("Content-Type: image/{$pic_type}"); - header("Content-Length: " . strlen($data)); - echo $data; - exit; -} - -if ($_POST) { - if (is_uploaded_file($_FILES['pictfile']['tmp_name'])) { - /* read the file contents */ - $fd_pic = fopen($_FILES['pictfile']['tmp_name'], "rb"); - while (($buf=fread($fd_pic, 8192)) != '') { - // Here, $buf is guaranteed to contain data - $data .= $buf; - } - fclose($fd_pic); - if (!$data) { - die("Could not read temporary file"); - } else { - $picname = basename($_FILES['uploadedfile']['name']); - $config['widgets']['picturewidget'] = base64_encode($data); - $config['widgets']['picturewidget_filename'] = $_FILES['pictfile']['name']; - write_config("Picture widget saved via Dashboard."); - header(url_safe('Location: /index.php')); - exit; - } - } -} - -?> - - - - - -
- - picture - -
- - - diff --git a/src/www/widgets/widgets/rss.widget.php b/src/www/widgets/widgets/rss.widget.php deleted file mode 100644 index 5648beda9..000000000 --- a/src/www/widgets/widgets/rss.widget.php +++ /dev/null @@ -1,178 +0,0 @@ - - * - * 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"); -require_once("simplepie/autoloader.php"); -require_once("simplepie/idn/idna_convert.class.php"); - -function textLimit($string, $length, $replacer = '...') -{ - if (strlen($string) > $length) { - return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer; - } - return $string; -} - -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $pconfig = $_POST; - $config['widgets']['rssfeed'] = str_replace("\n", ",", htmlspecialchars($pconfig['rssfeed'], ENT_QUOTES | ENT_HTML401)); - $config['widgets']['rssmaxitems'] = str_replace("\n", ",", htmlspecialchars($pconfig['rssmaxitems'], ENT_QUOTES | ENT_HTML401)); - $config['widgets']['rsswidgetheight'] = htmlspecialchars($pconfig['rsswidgetheight'], ENT_QUOTES | ENT_HTML401); - $config['widgets']['rsswidgettextlength'] = htmlspecialchars($pconfig['rsswidgettextlength'], ENT_QUOTES | ENT_HTML401); - write_config("Saved RSS Widget feed via Dashboard"); - header(url_safe('Location: /index.php')); - exit; -} - -// Use saved feed and max items -if (!empty($config['widgets']['rssfeed'])) { - $rss_feed_s = explode(",", $config['widgets']['rssfeed']); - $textarea_txt = str_replace(",", "\n", $config['widgets']['rssfeed']); -} else { - // Set a default feed if none exists - $rss_feed_s = 'https://forum.opnsense.org/index.php?board=11.0&action=.xml;limit=20;type=rss2'; - $config['widgets']['rssfeed'] = $rss_feed_s; - $textarea_txt = ''; -} - -if (!empty($config['widgets']['rssmaxitems']) && is_numeric($config['widgets']['rssmaxitems'])) { - $max_items = $config['widgets']['rssmaxitems']; -} else { - $max_items = 10; -} - -if (!empty($config['widgets']['rsswidgetheight']) && is_numeric($config['widgets']['rsswidgetheight'])) { - $rsswidgetheight = $config['widgets']['rsswidgetheight']; -} else { - $rsswidgetheight = 300; -} - -if (!empty($config['widgets']['rsswidgettextlength']) && is_numeric($config['widgets']['rsswidgettextlength'])) { - $rsswidgettextlength = $config['widgets']['rsswidgettextlength']; -} else { - $rsswidgettextlength = 140; // oh twitter, how do we love thee? -} -?> - - - -
-set_cache_location("/tmp/simplepie/"); - $feed->set_feed_url($rss_feed_s); - $feed->init(); - $feed->handle_content_type(); - $feed->strip_htmltags(); - $counter = 1; - try { - foreach ($feed->get_items() as $item) { - echo "" . $item->get_title() . "
"; - $content = $item->get_content(); - $content = strip_tags($content); - echo textLimit($content, $rsswidgettextlength) . "
"; - echo "Source: ".$feed->get_title()."
"; - $counter++; - if ($counter > $max_items) { - break; - } - echo "
"; - } - } catch (Error $e) { - echo gettext("Unable to fetch rss feed"); - } -?> -
- - - diff --git a/src/www/widgets/widgets/services_status.widget.php b/src/www/widgets/widgets/services_status.widget.php deleted file mode 100644 index bef9af4f3..000000000 --- a/src/www/widgets/widgets/services_status.widget.php +++ /dev/null @@ -1,153 +0,0 @@ - - * Copyright (C) 2004-2005 Scott Ullrich - * 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"); -require_once("system.inc"); -require_once("interfaces.inc"); - -if (isset($_POST['servicestatusfilter'])) { - $config['widgets']['servicestatusfilter'] = $_POST['servicestatusfilter']; - write_config("Saved Service Status Filter via Dashboard"); - header(url_safe('Location: /index.php')); - exit; -} - -?> - - - - - - - - - - - - - - - - - -
- - - diff --git a/src/www/widgets/widgets/system_information.widget.php b/src/www/widgets/widgets/system_information.widget.php deleted file mode 100644 index 716d1f2ff..000000000 --- a/src/www/widgets/widgets/system_information.widget.php +++ /dev/null @@ -1,289 +0,0 @@ - - * Copyright (C) 2004-2005 Manuel Kasper - * Copyright (C) 2004-2005 Jonathan Watt - * 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"); -require_once("system.inc"); - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
- -
-
-
- -
-
-
diff --git a/src/www/widgets/widgets/system_log.widget.php b/src/www/widgets/widgets/system_log.widget.php deleted file mode 100644 index 4c40ffaed..000000000 --- a/src/www/widgets/widgets/system_log.widget.php +++ /dev/null @@ -1,199 +0,0 @@ - - * Copyright (C) 2015 S. Linke - * 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 ($_SERVER['REQUEST_METHOD'] === 'POST') { - $input_errors = array(); - if (is_numeric($_POST['systemlogfiltercount'])) { - $config['widgets']['systemlogfiltercount'] = $_POST['systemlogfiltercount']; - } - if (is_numeric($_POST['systemlogentriesupdateinterval'])) { - $config['widgets']['systemlogupdateinterval'] = $_POST['systemlogentriesupdateinterval']; - } - - if (!empty($_POST['systemlogentriesfilter'])) { - if (!preg_match('/^[0-9,a-z,A-Z *\-_.\#]*$/', $_POST['systemlogentriesfilter'])) { - $input_errors[] = gettext("Query filter string is invalid"); - } - } - - if (!empty($_POST['systemlogseverity'])) { - $config['widgets']['systemlogseverity'] = $_POST['systemlogseverity']; - } - - if (count($input_errors) == 0) { - $config['widgets']['systemlogentriesfilter'] = $_POST['systemlogentriesfilter']; - write_config("System Log Widget settings saved"); - header(url_safe('Location: /index.php')); - exit; - } - - for ($i = 0; $i < count($input_errors); $i++) { - setcookie("inputerrors[$i]", $input_errors[$i], 0, '/'); - } - - header(url_safe('Location: /index.php')); - exit; -} - -$systemlogEntriesToFetch = isset($config['widgets']['systemlogfiltercount']) ? $config['widgets']['systemlogfiltercount'] : 20; -$systemlogupdateinterval = isset($config['widgets']['systemlogupdateinterval']) ? $config['widgets']['systemlogupdateinterval'] : 10; -$systemlogseverity = isset($config['widgets']['systemlogseverity']) ? $config['widgets']['systemlogseverity'] : "Debug"; -$systemlogentriesfilter = isset($config['widgets']['systemlogentriesfilter']) ? $config['widgets']['systemlogentriesfilter'] : ""; -if (isset($_COOKIE['inputerrors'])) { - foreach ($_COOKIE['inputerrors'] as $i => $value) { - $input_errors[] = $value; - setcookie("inputerrors[$i]", "", time() - 3600); - } -} -$prios = array('Emergency', 'Alert', 'Critical', 'Error', 'Warning', 'Notice', 'Informational', 'Debug'); - -?> - - -
- 0) { - print_input_errors($input_errors); - } -?> -
-
- - -
-
- - diff --git a/src/www/widgets/widgets/thermal_sensors.widget.php b/src/www/widgets/widgets/thermal_sensors.widget.php deleted file mode 100644 index 0238252cf..000000000 --- a/src/www/widgets/widgets/thermal_sensors.widget.php +++ /dev/null @@ -1,228 +0,0 @@ -= 0 and $value <= 100) { - return (int)$value; - } else { - return $default; - } -} - -function fix_checkbox_value($value): bool -{ - if ($value !== '') { - return true; - } else { - return false; - } -} - -$fields = [ - ['name' => 'thermal_sensors_widget_zone_warning_threshold', 'default' => 70, 'processFunc' => 'fix_temp_value'], - ['name' => 'thermal_sensors_widget_zone_critical_threshold', 'default' => 80, 'processFunc' => 'fix_temp_value'], - ['name' => 'thermal_sensors_widget_core_warning_threshold', 'default' => 70, 'processFunc' => 'fix_temp_value'], - ['name' => 'thermal_sensors_widget_core_critical_threshold', 'default' => 80, 'processFunc' => 'fix_temp_value'], - ['name' => 'thermal_sensors_widget_show_one_core_temp', 'default' => false, 'processFunc' => 'fix_checkbox_value'], - ['name' => 'thermal_sensors_widget_show_temp_in_fahrenheit', 'default' => false, 'processFunc' => 'fix_checkbox_value'], -]; -if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $pconfig = []; - foreach ($fields as $field) { - $pconfig[$field['name']] = !empty($config['widgets']['thermal_sensors_widget'][$field['name']]) ? $config['widgets']['thermal_sensors_widget'][$field['name']] : $field['default']; - } -} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { - foreach ($fields as $field) { - $newValue = $field['processFunc']($_POST[$field['name']] ?? '', $field['default']); - $config['widgets']['thermal_sensors_widget'][$field['name']] = $newValue; - } - write_config("Thermal sensors widget saved via Dashboard."); - header(url_safe('Location: /index.php')); - exit; -} - -?> - - - - - - - - - - -
- - - diff --git a/src/www/widgets/widgets/traffic_graphs.widget.php b/src/www/widgets/widgets/traffic_graphs.widget.php deleted file mode 100644 index 39ed1bc82..000000000 --- a/src/www/widgets/widgets/traffic_graphs.widget.php +++ /dev/null @@ -1,272 +0,0 @@ - - * Copyright (C) 2004-2005 Manuel Kasper - * Copyright (C) 2004-2005 Jonathan Watt - * 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"); -require_once("widgets/include/interface_list.inc"); -require_once("interfaces.inc"); - -$interfaces = get_configured_interface_with_descr(); - -if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $pconfig = array(); - $pconfig['traffic_graphs_interfaces'] = !empty($config['widgets']['traffic_graphs_interfaces']) ? - explode(',', $config['widgets']['traffic_graphs_interfaces']) : ['lan', 'wan']; -} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { - $pconfig = $_POST; - if (!empty($pconfig['traffic_graphs_interfaces'])) { - $config['widgets']['traffic_graphs_interfaces'] = implode(',', $pconfig['traffic_graphs_interfaces']); - } elseif (isset($config['widgets']['traffic_graphs_interfaces'])) { - unset($config['widgets']['traffic_graphs_interfaces']); - } - write_config("Saved Widget Interface List via Dashboard"); - header(url_safe('Location: /index.php')); - exit; -} - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- -
-
diff --git a/src/www/widgets/widgets/wireguard.widget.php b/src/www/widgets/widgets/wireguard.widget.php deleted file mode 100644 index a4927a813..000000000 --- a/src/www/widgets/widgets/wireguard.widget.php +++ /dev/null @@ -1,95 +0,0 @@ - - * 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. - */ -?> - - - - - - - - - - - - - - - - - -
- - - - -