From 1b697193305b07b35194148db84bfe329dcf2b5f Mon Sep 17 00:00:00 2001 From: camer0n Date: Wed, 15 Nov 2023 16:26:24 -0800 Subject: [PATCH] Closes #5106 - system notification consolidation. --- e107_admin/admin.php | 80 +++++++++++++++---- .../shortcodes/batch/admin_shortcodes.php | 79 ++++++++++++++++-- e107_core/templates/admin_template.php | 1 + e107_handlers/application.php | 35 ++++++++ e107_languages/English/admin/lan_admin.php | 8 +- e107_themes/bootstrap3/admin_style.css | 8 ++ e107_themes/bootstrap3/css/modern-dark.css | 2 +- 7 files changed, 190 insertions(+), 23 deletions(-) diff --git a/e107_admin/admin.php b/e107_admin/admin.php index fe7075c83a..ba6859fc0b 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -135,16 +135,20 @@ function __construct() return null; } + if(!e107::getDb()->isTable('admin_log')) // Upgrade from v1.x to v2.x required. { $this->upgradeRequiredFirst = true; } + // eHelper::clearSystemNotification(); // clear the notifications. + // Files that can cause comflicts and problems. $fileInspector = e107::getFileInspector(); $this->deprecated = $fileInspector::getCachedDeprecatedFiles(); $this->checkCoreVersion(); + $this->checkDependencies(); if(!empty($_POST['delete-deprecated'])) { @@ -205,7 +209,8 @@ function __construct() $this->checkDeveloperMode(); - if($this->refresh == true) + + if($this->refresh) { e107::getRedirect()->go(e_REQUEST_SELF); } @@ -213,7 +218,9 @@ function __construct() // delete half-completed user accounts. (previously called in header.php ) e107::getUserSession()->deleteExpired(); - } + } + + private function checkPaths() { @@ -232,9 +239,13 @@ private function checkPaths() else { $message = e107::getParser()->lanVars(ADLAN_187,$dr,true); - $mes->addWarning($message); + eHelper::addSystemNotification('check_paths_'.sha1($dr), $message); } } + else + { + eHelper::clearSystemNotification('check_paths_'.sha1($dr)); + } } } @@ -284,7 +295,7 @@ private function checkCoreUpdate() // auto db update if ('0' != ADMINPERMS) { - return null; + return; } if($this->upgradeRequiredFirst) @@ -488,13 +499,13 @@ private function checkWritable() if(deftrue('e_MEDIA') && is_dir(e_MEDIA) && !is_writable(e_MEDIA)) { $message = str_replace("[x]", e_MEDIA, ADLAN_193); - $mes->addWarning($message); + $mes->addWarning($message); } if(deftrue('e_SYSTEM') && is_dir(e_SYSTEM) && !is_writable(e_SYSTEM)) { $message = str_replace("[x]", e_SYSTEM, ADLAN_193); - $mes->addWarning($message); + $mes->addWarning($message); } $files = e107::getFile()->scandir(e_IMAGE."avatars",'jpg,gif,png,jpeg'); @@ -526,7 +537,8 @@ private function checkIncompatiblePlugins() { if($this->upgradeRequiredFirst) { - return null; + eHelper::clearSystemNotification('checkIncompatiblePlugins'); + return; } $mes = e107::getMessage(); @@ -543,15 +555,21 @@ private function checkIncompatiblePlugins() if(!empty($installedPlugs[$folder]) && ($version == $installedPlugs[$folder] || $version === '*')) { - $inCompatText .= "
  • ".$folder." v".$installedPlugs[$folder]."
  • "; + $url = e_ADMIN."plugin.php?searchquery=$folder&filter_options=&mode=installed&action=list&etrigger_filter=etrigger_filter"; + $inCompatText .= "
  • ".$folder." v".$installedPlugs[$folder]."
  • "; } } if($inCompatText) { $text = ""; - $mes->addWarning(ADLAN_189." 

    ".$text); - } + eHelper::addSystemNotification('checkIncompatiblePlugins', ADLAN_189." 

    ".$text); + // $mes->addWarning(ADLAN_189." 

    ".$text); + } + else + { + eHelper::clearSystemNotification('checkIncompatiblePlugins'); + } } @@ -560,7 +578,7 @@ private function checkPasswordEncryption() { if($this->upgradeRequiredFirst) { - return null; + return; } $us = e107::getUserSession(); @@ -570,8 +588,12 @@ private function checkPasswordEncryption() { $message = LAN_PASSWORD_WARNING; $srch = array('[',']'); - $repl = array("",""); - $mes->addWarning(str_replace($srch,$repl,$message)); + $repl = array("",""); + eHelper::addSystemNotification('checkPasswordEncryption', str_replace($srch,$repl,$message)); + } + else + { + eHelper::clearSystemNotification('checkPasswordEncryption'); } } @@ -583,7 +605,11 @@ private function checkDeveloperMode() if($pref['developer'] && (strpos(e_SELF,'localhost') === false) && (strpos(e_SELF,'127.0.0.1') === false)) { - e107::getMessage()->addWarning($tp->toHTML(LAN_DEVELOPERMODE_CHECK, true)); + eHelper::addSystemNotification('checkDeveloperMode', $tp->toHTML(LAN_DEVELOPERMODE_CHECK, true)); + } + else + { + eHelper::clearSystemNotification('checkDeveloperMode'); } } @@ -591,7 +617,27 @@ private function checkDeveloperMode() private function checkDependencies() { + if(PHP_MAJOR_VERSION < 8) + { + $lanFallback = 'Your website is currently running an [outdated version of PHP], which may pose a security risk. If your plugins will allow it, we recommend upgrading to [x] to ensure that your website is secure and up-to-date.'; + $lan = defset('LAN_PHP_OUTDATED', $lanFallback); + $url = e_ADMIN.'phpinfo.php'; + + $lan = e107::getParser()->lanVars($lan, 'PHP 8.2'); + $srch = array('[',']'); + $repl = [ + "", + "" + ]; + + $lan = str_replace($srch, $repl, $lan); + eHelper::addSystemNotification('checkDependencies', $lan); + } + else + { + eHelper::clearSystemNotification('checkDependencies'); + } } @@ -674,9 +720,13 @@ private function checkHtaccess() // upgrade scenario { if(rename(e_BASE."e107.htaccess", e_BASE.".htaccess")===false) { - e107::getMessage()->addWarning("Please rename your e107.htaccess file to .htaccess"); + eHelper::addSystemNotification('checkHtaccess', "Please rename your e107.htaccess file to .htaccess"); } } + else + { + eHelper::clearSystemNotification('checkDependencies'); + } } diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index 1856907d27..c8c40126ff 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -1699,7 +1699,55 @@ public function renderAddonUpdate($list) return $text; } + public function sc_admin_notifications() + { + // $content = @file_get_contents(e_SYSTEM."adminNotifications.json"); + if(!$array = eHelper::getSystemNotification()) + { + return ''; + } + + + /*return '';*/ + + $count = count($array); + $lanNotify = defset('LAN_SYSTEM_NOTIFICATIONS_X', '[x] System Notifications'); + $lan = e107::getParser()->lanVars($lanNotify, $count); + + + $text = ''; + + return $text; + + } + + + /** + * Checks for a new version of e107 that could be available for download. + * @return string|null + */ public function sc_admin_update() { if (!ADMIN) { return null; } @@ -1708,6 +1756,7 @@ public function sc_admin_update() if(empty($pref['check_updates'])) { + eHelper::clearSystemNotification('sc_admin_update'); return null; } @@ -1733,13 +1782,18 @@ public function sc_admin_update() } $data = e107::unserialize($cached); + $message = e107::getParser()->lanVars(LAN_NEWVERSION,$data['version']); + + eHelper::addSystemNotification('sc_admin_update', "$message"); if($data === false || isset($data['status'])) { + eHelper::clearSystemNotification('sc_admin_update'); return null; } + // Don't check for updates if running locally (comment out the next line to allow check - but // remember it can cause delays/errors if its not possible to access the Internet if(e_DEBUG !== true) @@ -1748,13 +1802,15 @@ public function sc_admin_update() } + + return '