diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index 668a44f8cfd0c..b084904295547 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -343,9 +343,10 @@ protected function updateManifestCaches() array('plugin', 'updatenotification', 'system', 0), array('plugin', 'module', 'editors-xtd', 0), array('plugin', 'stats', 'system', 0), - array('plugin', 'packageinstaller','installer',0), - array('plugin', 'folderinstaller','installer', 0), - array('plugin', 'urlinstaller','installer', 0), + array('plugin', 'packageinstaller', 'installer', 0), + array('plugin', 'folderinstaller', 'installer', 0), + array('plugin', 'urlinstaller', 'installer', 0), + array('plugin', 'phpversioncheck', 'quickicon', 0), // Templates array('template', 'beez3', '', 0), diff --git a/administrator/components/com_admin/sql/updates/mysql/3.7.0-2016-08-06.sql b/administrator/components/com_admin/sql/updates/mysql/3.7.0-2016-08-06.sql new file mode 100644 index 0000000000000..1a861d18009bd --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/3.7.0-2016-08-06.sql @@ -0,0 +1,2 @@ +INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES +(458, 'plg_quickicon_phpversioncheck', 'plugin', 'phpversioncheck', 'quickicon', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0); diff --git a/administrator/components/com_admin/sql/updates/postgresql/3.7.0-2016-08-06.sql b/administrator/components/com_admin/sql/updates/postgresql/3.7.0-2016-08-06.sql new file mode 100644 index 0000000000000..9d4e415850218 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/3.7.0-2016-08-06.sql @@ -0,0 +1,2 @@ +INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES +(458, 'plg_quickicon_phpversioncheck', 'plugin', 'phpversioncheck', 'quickicon', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0); diff --git a/administrator/components/com_admin/sql/updates/sqlazure/3.7.0-2016-08-06.sql b/administrator/components/com_admin/sql/updates/sqlazure/3.7.0-2016-08-06.sql new file mode 100644 index 0000000000000..feec2ca85b9fe --- /dev/null +++ b/administrator/components/com_admin/sql/updates/sqlazure/3.7.0-2016-08-06.sql @@ -0,0 +1,6 @@ +SET IDENTITY_INSERT #__extensions ON; + +INSERT INTO #__extensions ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state]) +SELECT 458, 'plg_quickicon_phpversioncheck', 'plugin', 'phpversioncheck', 'quickicon', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0; + +SET IDENTITY_INSERT #__extensions OFF; diff --git a/administrator/language/en-GB/en-GB.plg_quickicon_phpversioncheck.ini b/administrator/language/en-GB/en-GB.plg_quickicon_phpversioncheck.ini new file mode 100644 index 0000000000000..9a3280f80f7ad --- /dev/null +++ b/administrator/language/en-GB/en-GB.plg_quickicon_phpversioncheck.ini @@ -0,0 +1,11 @@ +; Joomla! Project +; Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved. +; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php +; Note : All ini files need to be saved as UTF-8 + +PLG_QUICKICON_PHPVERSIONCHECK="Quick Icon - PHP Version Check" +; Key 1 is the server's current PHP version, key 2 is the date at which support will end for the current PHP version +PLG_QUICKICON_PHPVERSIONCHECK_SECURITY_ONLY="Your PHP version, %1$s, is only receiving security fixes at this time from the PHP project. This means your PHP version will soon no longer be supported. We recommend planning to upgrade to a newer PHP version before it reaches end of support on %2$s. Joomla will be faster and more secure if you upgrade to a newer PHP version (PHP 7.x is recommended). Please contact your host for upgrade instructions." +; Key 1 is the server's current PHP version, key 2 is the recommended PHP version, and key 3 is the date at which support will end for the recommended PHP version +PLG_QUICKICON_PHPVERSIONCHECK_UNSUPPORTED="We have detected that your server is using PHP %1$s which is obsolete and no longer receives official security updates by its developers. The Joomla project recommends upgrading your site to PHP %2$s or later which will receive security updates at least until %3$s. Please ask your host to make PHP %2$s or a later version the default version for your site. If your host is already PHP %2$s ready please enable PHP %2$s on your site's root and 'administrator' directories – typically you can do this yourself through a tool in your hosting control panel, but it's best to ask your host if you are unsure." +PLG_QUICKICON_PHPVERSIONCHECK_XML_DESCRIPTION="Checks the support status of your installation's PHP version and raises a warning if not fully supported." diff --git a/administrator/language/en-GB/en-GB.plg_quickicon_phpversioncheck.sys.ini b/administrator/language/en-GB/en-GB.plg_quickicon_phpversioncheck.sys.ini new file mode 100644 index 0000000000000..bae32945de9e0 --- /dev/null +++ b/administrator/language/en-GB/en-GB.plg_quickicon_phpversioncheck.sys.ini @@ -0,0 +1,7 @@ +; Joomla! Project +; Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved. +; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php +; Note : All ini files need to be saved as UTF-8 + +PLG_QUICKICON_PHPVERSIONCHECK="Quick Icon - PHP Version Check" +PLG_QUICKICON_PHPVERSIONCHECK_XML_DESCRIPTION="Checks the support status of your installation's PHP version and raises a warning if not fully supported." diff --git a/administrator/language/en-GB/install.xml b/administrator/language/en-GB/install.xml index 7f26c90a9d76a..939d05ba7faac 100644 --- a/administrator/language/en-GB/install.xml +++ b/administrator/language/en-GB/install.xml @@ -173,6 +173,8 @@ en-GB.plg_quickicon_extensionupdate.sys.ini en-GB.plg_quickicon_joomlaupdate.ini en-GB.plg_quickicon_joomlaupdate.sys.ini + en-GB.plg_quickicon_phpversioncheck.ini + en-GB.plg_quickicon_phpversioncheck.sys.ini en-GB.plg_search_categories.ini en-GB.plg_search_categories.sys.ini en-GB.plg_search_contacts.ini diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 5fbfe52d4586f..b2e4d3d8706ff 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -614,6 +614,7 @@ INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder` (455, 'plg_installer_packageinstaller', 'plugin', 'packageinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 1, 0), (456, 'plg_installer_folderinstaller', 'plugin', 'folderinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 2, 0), (457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 3, 0), +(458, 'plg_quickicon_phpversioncheck', 'plugin', 'phpversioncheck', 'quickicon', 0, 1, 1, 1, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0), (503, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (504, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), (506, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0), diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index 132b3c0c24351..c7bb17c47c635 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -613,7 +613,8 @@ INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder" (454, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0), (455, 'plg_installer_packageinstaller', 'plugin', 'packageinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 1, 0), (456, 'plg_installer_folderinstaller', 'plugin', 'folderinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 2, 0), -(457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 3, 0); +(457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 3, 0), +(458, 'plg_quickicon_phpversioncheck', 'plugin', 'phpversioncheck', 'quickicon', 0, 1, 1, 1, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0); -- Templates INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES diff --git a/installation/sql/sqlazure/joomla.sql b/installation/sql/sqlazure/joomla.sql index 567ee8b313462..c45fb5ec0c723 100644 --- a/installation/sql/sqlazure/joomla.sql +++ b/installation/sql/sqlazure/joomla.sql @@ -1007,7 +1007,9 @@ SELECT 455, 'plg_installer_packageinstaller', 'plugin', 'packageinstaller', 'ins UNION ALL SELECT 456, 'plg_installer_folderinstaller', 'plugin', 'folderinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 2, 0 UNION ALL -SELECT 457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 3, 0; +SELECT 457, 'plg_installer_urlinstaller', 'plugin', 'urlinstaller', 'installer', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 3, 0 +UNION ALL +SELECT 458, 'plg_quickicon_phpversioncheck', 'plugin', 'phpversioncheck', 'quickicon', 0, 1, 1, 1, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0; INSERT [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state]) SELECT 503, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '1900-01-01 00:00:00', 0, 0 diff --git a/plugins/quickicon/phpversioncheck/phpversioncheck.php b/plugins/quickicon/phpversioncheck/phpversioncheck.php new file mode 100644 index 0000000000000..8389c5181695d --- /dev/null +++ b/plugins/quickicon/phpversioncheck/phpversioncheck.php @@ -0,0 +1,230 @@ +shouldDisplayMessage()) + { + return; + } + + $supportStatus = $this->getPhpSupport(); + + if ($supportStatus['status'] !== self::PHP_SUPPORTED) + { + // Enqueue the notification message; set a warning if receiving security support or "error" if unsupported + switch ($supportStatus['status']) + { + case self::PHP_SECURITY_ONLY: + $this->app->enqueueMessage($supportStatus['message'], 'warning'); + + break; + + case self::PHP_UNSUPPORTED: + $this->app->enqueueMessage($supportStatus['message'], 'error'); + + break; + } + } + } + + /** + * Gets PHP support status. + * + * @return array Array of PHP support data + * + * @since __DEPLOY_VERSION__ + * @note The dates used in this method should correspond to the dates given on PHP.net + * @see https://secure.php.net/supported-versions.php + * @see https://secure.php.net/eol.php + */ + private function getPhpSupport() + { + $phpSupportData = array( + '5.3' => array( + 'security' => '2013-07-11', + 'eos' => '2014-08-14', + ), + '5.4' => array( + 'security' => '2014-09-14', + 'eos' => '2015-09-14', + ), + '5.5' => array( + 'security' => '2015-07-10', + 'eos' => '2016-07-21' + ), + '5.6' => array( + 'security' => '2016-12-31', + 'eos' => '2018-12-31' + ), + '7.0' => array( + 'security' => '2017-12-03', + 'eos' => '2018-12-03' + ), + ); + + // Fill our return array with default values + $supportStatus = array( + 'status' => self::PHP_SUPPORTED, + 'message' => null, + ); + + // Check the PHP version's support status using the minor version + $activePhpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION; + + // Do we have the PHP version's data? + if (isset($phpSupportData[$activePhpVersion])) + { + // First check if the version has reached end of support + $today = new JDate; + $phpEndOfSupport = new JDate($phpSupportData[$activePhpVersion]['eos']); + + if ($phpNotSupported = $today > $phpEndOfSupport) + { + /* + * Find the oldest PHP version still supported that is newer than the current version, + * this is our recommendation for users on unsupported platforms + */ + foreach ($phpSupportData as $version => $versionData) + { + $versionEndOfSupport = new JDate($versionData['eos']); + + if (version_compare($version, $activePhpVersion, 'ge') && ($today < $versionEndOfSupport)) + { + $recommendedVersion = $version; + $recommendedVersionEndOfSupport = $versionEndOfSupport; + + break; + } + } + + $supportStatus['status'] = self::PHP_UNSUPPORTED; + $supportStatus['message'] = JText::sprintf( + 'PLG_QUICKICON_PHPVERSIONCHECK_UNSUPPORTED', + PHP_VERSION, + $recommendedVersion, + $recommendedVersionEndOfSupport->format(JText::_('DATE_FORMAT_LC4')) + ); + } + + // If the version is still supported, check if it has reached security support only + $phpSecurityOnlyDate = new JDate($phpSupportData[$activePhpVersion]['security']); + + if (!$phpNotSupported && $today > $phpSecurityOnlyDate) + { + $supportStatus['status'] = self::PHP_SECURITY_ONLY; + $supportStatus['message'] = JText::sprintf( + 'PLG_QUICKICON_PHPVERSIONCHECK_SECURITY_ONLY', PHP_VERSION, $phpEndOfSupport->format(JText::_('DATE_FORMAT_LC4')) + ); + } + } + + return $supportStatus; + } + + /** + * Determines if the message should be displayed + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + private function shouldDisplayMessage() + { + // Only on admin app + if (!$this->app->isAdmin()) + { + return false; + } + + // Only if authenticated + if (JFactory::getUser()->guest) + { + return false; + } + + // Only on HTML documents + if ($this->app->getDocument()->getType() !== 'html') + { + return false; + } + + // Only on full page requests + if ($this->app->input->getCmd('tmpl', 'index') === 'component') + { + return false; + } + + // Only to com_cpanel + if ($this->app->input->get('option') != 'com_cpanel') + { + return false; + } + + return true; + } +} diff --git a/plugins/quickicon/phpversioncheck/phpversioncheck.xml b/plugins/quickicon/phpversioncheck/phpversioncheck.xml new file mode 100644 index 0000000000000..59842f57883df --- /dev/null +++ b/plugins/quickicon/phpversioncheck/phpversioncheck.xml @@ -0,0 +1,19 @@ + + + plg_quickicon_phpversioncheck + Joomla! Project + August 2016 + Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved. + GNU General Public License version 2 or later; see LICENSE.txt + admin@joomla.org + www.joomla.org + 3.7.0 + PLG_QUICKICON_PHPVERSIONCHECK_XML_DESCRIPTION + + phpversioncheck.php + + + en-GB.plg_quickicon_phpversioncheck.ini + en-GB.plg_quickicon_phpversioncheck.sys.ini + +