diff --git a/administrator/components/com_installer/controllers/database.php b/administrator/components/com_installer/controllers/service.php similarity index 60% rename from administrator/components/com_installer/controllers/database.php rename to administrator/components/com_installer/controllers/service.php index 0808a807ff97d..8d2bab72cb325 100644 --- a/administrator/components/com_installer/controllers/database.php +++ b/administrator/components/com_installer/controllers/service.php @@ -10,13 +10,13 @@ defined('_JEXEC') or die; /** - * Installer Database Controller + * Installer Service Controller * * @package Joomla.Administrator * @subpackage com_installer - * @since 2.5 + * @since 3.4 */ -class InstallerControllerDatabase extends JControllerLegacy +class InstallerControllerService extends JControllerLegacy { /** * Tries to fix missing database updates @@ -28,7 +28,7 @@ class InstallerControllerDatabase extends JControllerLegacy */ public function fix() { - $model = $this->getModel('database'); + $model = $this->getModel('service'); $model->fix(); // Purge updates @@ -39,6 +39,25 @@ public function fix() // Refresh versionable assets cache JFactory::getApplication()->flushAssets(); - $this->setRedirect(JRoute::_('index.php?option=com_installer&view=database', false)); + $this->setRedirect(JRoute::_('index.php?option=com_installer&view=service', false)); + } + + /** + * Tries to fix missing database updates + * + * @return void + * + * @since 2.5 + * @todo Purge updates has to be replaced with an events system + */ + public function checkFiles() + { + $model = $this->getModel('service'); + $result = $model->checkFiles(); + + $app = JFactory::getApplication(); + $app->setUserState('com_installer.service.files', $result); + + $this->setRedirect(JRoute::_('index.php?option=com_installer&view=service', false)); } } diff --git a/administrator/components/com_installer/helpers/installer.php b/administrator/components/com_installer/helpers/installer.php index 2a30c544f05b4..53ba21379972c 100644 --- a/administrator/components/com_installer/helpers/installer.php +++ b/administrator/components/com_installer/helpers/installer.php @@ -48,13 +48,8 @@ public static function addSubmenu($vName = 'install') $vName == 'discover' ); JHtmlSidebar::addEntry( - JText::_('COM_INSTALLER_SUBMENU_DATABASE'), - 'index.php?option=com_installer&view=database', - $vName == 'database' - ); - JHtmlSidebar::addEntry( - JText::_('COM_INSTALLER_SUBMENU_WARNINGS'), - 'index.php?option=com_installer&view=warnings', + JText::_('COM_INSTALLER_SUBMENU_SERVICE'), + 'index.php?option=com_installer&view=service', $vName == 'warnings' ); JHtmlSidebar::addEntry( diff --git a/administrator/components/com_installer/models/database.php b/administrator/components/com_installer/models/service.php similarity index 54% rename from administrator/components/com_installer/models/database.php rename to administrator/components/com_installer/models/service.php index 3a19f8a90deec..cb43ac61ddeb8 100644 --- a/administrator/components/com_installer/models/database.php +++ b/administrator/components/com_installer/models/service.php @@ -13,15 +13,48 @@ JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php'); /** - * Installer Manage Model + * Extension Manager Templates Model * * @package Joomla.Administrator * @subpackage com_installer * @since 1.6 */ -class InstallerModelDatabase extends InstallerModel +class InstallerModelService extends InstallerModel { - protected $_context = 'com_installer.discover'; + protected $_context = 'com_installer.service'; + + /** + * Extension Type + * @var string + */ + public $type = 'warnings'; + + /** + * Return the byte value of a particular string. + * + * @param string $val String optionally with G, M or K suffix + * + * @return integer size in bytes + * + * @since 1.6 + */ + public function return_bytes($val) + { + $val = trim($val); + $last = strtolower($val{strlen($val) - 1}); + switch ($last) + { + // The 'G' modifier is available since PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + return $val; + } /** * Method to auto-populate the model state. @@ -52,7 +85,7 @@ protected function populateState($ordering = null, $direction = null) */ public function fix() { - if (!$changeSet = $this->getItems()) + if (!$changeSet = $this->getChangeset()) { return false; } @@ -64,12 +97,160 @@ public function fix() $this->fixDefaultTextFilters(); } + /** + * Checks files against MD5 sums for broken files + * + * @return array Broken files + */ + public function checkFiles() + { + $result = array(); + + if (!file_exists(JPATH_ADMINISTRATOR.'/checksums/joomla.md5')) + { + $result[] = JText::_('COM_INSTALLER_MSG_SERVICE_MD5_FILE_MISSING'); + return $result; + } + + $content = file_get_contents(JPATH_ADMINISTRATOR.'/checksums/joomla.md5'); + + $files = explode("\n", $content); + + foreach($files as $line) + { + if (trim($line) == '' || substr($line, 0, 1) == '#') + { + continue; + } + + list($hash, $file) = explode(' ', $line, 2); + if (md5_file(JPATH_ROOT.$file) != $hash) + { + $result[] = $file; + } + } + + return $result; + } + + /** + * Get broken files + * + * @return array Broken files + * + * @since 3.4 + */ + public function getFiles() + { + $app = JFactory::getApplication(); + + $files = $app->getUserState('com_installer.service.files', false); + if ($files) + { + $app->setUserState('com_installer.service.files', false); + } + + return $files; + } + + /** + * Load the data. + * + * @return array Messages + * + * @since 1.6 + */ + public function getItems() + { + static $messages; + if ($messages) + { + return $messages; + } + $messages = array(); + + $file_uploads = ini_get('file_uploads'); + if (!$file_uploads) + { + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADSDISABLED'), + 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADISDISABLEDDESC')); + } + + $upload_dir = ini_get('upload_tmp_dir'); + if (!$upload_dir) + { + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSET'), + 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSETDESC')); + } + else + { + if (!is_writeable($upload_dir)) + { + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTWRITEABLE'), + 'description' => JText::sprintf('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTWRITEABLEDESC', $upload_dir)); + } + } + + $config = JFactory::getConfig(); + $tmp_path = $config->get('tmp_path'); + if (!$tmp_path) + { + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTSET'), + 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTSETDESC')); + } + else + { + if (!is_writeable($tmp_path)) + { + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTWRITEABLE'), + 'description' => JText::sprintf('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTWRITEABLEDESC', $tmp_path)); + } + } + + $memory_limit = $this->return_bytes(ini_get('memory_limit')); + if ($memory_limit < (8 * 1024 * 1024) && $memory_limit != -1) + { + // 8MB + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_LOWMEMORYWARN'), + 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_LOWMEMORYDESC')); + } + elseif ($memory_limit < (16 * 1024 * 1024) && $memory_limit != -1) + { + // 16MB + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_MEDMEMORYWARN'), + 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_MEDMEMORYDESC')); + } + + $post_max_size = $this->return_bytes(ini_get('post_max_size')); + $upload_max_filesize = $this->return_bytes(ini_get('upload_max_filesize')); + + if ($post_max_size < $upload_max_filesize) + { + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADBIGGERTHANPOST'), + 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADBIGGERTHANPOSTDESC')); + } + + if ($post_max_size < (8 * 1024 * 1024)) // 8MB + { + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLPOSTSIZE'), + 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLPOSTSIZEDESC')); + } + + if ($upload_max_filesize < (8 * 1024 * 1024)) // 8MB + { + $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZE'), + 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZEDESC')); + } + + return $messages; + } + /** * Gets the changeset object * * @return JSchemaChangeset */ - public function getItems() + public function getChangeset() { $folder = JPATH_ADMINISTRATOR . '/components/com_admin/sql/updates/'; @@ -85,18 +266,6 @@ public function getItems() return $changeSet; } - /** - * Method to get a JPagination object for the data set. - * - * @return boolean - * - * @since 12.2 - */ - public function getPagination() - { - return true; - } - /** * Get version from #__schemas table * diff --git a/administrator/components/com_installer/models/warnings.php b/administrator/components/com_installer/models/warnings.php deleted file mode 100644 index 41e10e23d8249..0000000000000 --- a/administrator/components/com_installer/models/warnings.php +++ /dev/null @@ -1,144 +0,0 @@ - JText::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADSDISABLED'), - 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_FILEUPLOADISDISABLEDDESC')); - } - - $upload_dir = ini_get('upload_tmp_dir'); - if (!$upload_dir) - { - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSET'), - 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTSETDESC')); - } - else - { - if (!is_writeable($upload_dir)) - { - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTWRITEABLE'), - 'description' => JText::sprintf('COM_INSTALLER_MSG_WARNINGS_PHPUPLOADNOTWRITEABLEDESC', $upload_dir)); - } - } - - $config = JFactory::getConfig(); - $tmp_path = $config->get('tmp_path'); - if (!$tmp_path) - { - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTSET'), - 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTSETDESC')); - } - else - { - if (!is_writeable($tmp_path)) - { - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTWRITEABLE'), - 'description' => JText::sprintf('COM_INSTALLER_MSG_WARNINGS_JOOMLATMPNOTWRITEABLEDESC', $tmp_path)); - } - } - - $memory_limit = $this->return_bytes(ini_get('memory_limit')); - if ($memory_limit < (8 * 1024 * 1024) && $memory_limit != -1) - { - // 8MB - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_LOWMEMORYWARN'), - 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_LOWMEMORYDESC')); - } - elseif ($memory_limit < (16 * 1024 * 1024) && $memory_limit != -1) - { - // 16MB - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_MEDMEMORYWARN'), - 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_MEDMEMORYDESC')); - } - - $post_max_size = $this->return_bytes(ini_get('post_max_size')); - $upload_max_filesize = $this->return_bytes(ini_get('upload_max_filesize')); - - if ($post_max_size < $upload_max_filesize) - { - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADBIGGERTHANPOST'), - 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_UPLOADBIGGERTHANPOSTDESC')); - } - - if ($post_max_size < (8 * 1024 * 1024)) // 8MB - { - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLPOSTSIZE'), - 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLPOSTSIZEDESC')); - } - - if ($upload_max_filesize < (8 * 1024 * 1024)) // 8MB - { - $messages[] = array('message' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZE'), - 'description' => JText::_('COM_INSTALLER_MSG_WARNINGS_SMALLUPLOADSIZEDESC')); - } - - return $messages; - } -} diff --git a/administrator/components/com_installer/views/database/tmpl/default.php b/administrator/components/com_installer/views/database/tmpl/default.php deleted file mode 100644 index 10f95f4a370f0..0000000000000 --- a/administrator/components/com_installer/views/database/tmpl/default.php +++ /dev/null @@ -1,85 +0,0 @@ - -