/** * Test the MD5 for certian files like UMIL and xsl * * @access private * @return bool */ protected function test_files() { $error = false; $found_umil = false; if (sizeof($this->validator->xsl_files) > 0) { foreach ($this->validator->xsl_files as $file) { $md5 = md5_file($this->validator->temp_dir . $file); if (!in_array($md5, $this->valid_md5_xsl)) { $error = true; $this->push_error(mpv::ERROR_WARNING, 'MODIFIED_XSL', $file, array($md5, $this->valid_md5_xsl[0])); } else { if ($md5 != $this->valid_md5_xsl[0]) { $error = true; $this->push_error(mpv::ERROR_FAIL, 'OLD_XSL', $file, array($md5)); } } } foreach ($this->validator->package_files as $file) { if (strpos($file, 'license.txt') !== false) { $md5 = md5_file($this->validator->temp_dir . $file); if (!in_array($md5, $this->license_md5)) { $this->push_error(mpv::ERROR_FAIL, 'LICENSE_MD5', $file, array($md5, implode(', ', $this->license_md5))); } } $tmp = explode('/', $file); if (isset($tmp[sizeof($tmp) - 2]) && isset($tmp[sizeof($tmp) - 1]) && $tmp[sizeof($tmp) - 2] == 'umil' && $tmp[sizeof($tmp) - 1] == 'umil.php') { $md5 = md5_file($this->validator->temp_dir . $file); if ($found_umil) { $this->push_error(mpv::ERROR_WARNING, 'POSSIBLE_TWO_UMIL', null, array($file, $found_umil)); continue; } if (!defined('IN_PHPBB')) { define('IN_PHPBB', true); } include $this->validator->temp_dir . $file; if (!defined('UMIL_VERSION')) { $this->push_error(mpv::ERROR_FAIL, 'NO_UMIL_VERSION', $file); continue; } else { if (version_compare(UMIL_VERSION, mpv::get_current_version('umil'), '<')) { $this->push_error(mpv::ERROR_FAIL, 'UMIL_OUTDATED', $file); // Check to see if the md5 still exists if (isset($this->valid_md5_umil[UMIL_VERSION]) && $this->valid_md5_umil[UMIL_VERSION] != $md5) { // Invalid MD5 for version as well :) $this->push_error(mpv::ERROR_WARNING, 'INCORRECT_UMIL_MD5', $file); } } else { if (!isset($this->valid_md5_umil[UMIL_VERSION])) { $this->push_error(mpv::ERROR_FAIL, 'UNKNOWN_VERSION_UMIL', $file); } else { if ($this->valid_md5_umil[UMIL_VERSION] != $md5) { $this->push_error(mpv::ERROR_WARNING, 'INCORRECT_UMIL_MD5', $file); } } } } $found_umil = $file; } } } }
/** * Test the phpBB version */ protected function test_phpbb_version() { $return = true; $phpbb_version = $this->modx_object->get_by_name('target-version', true); //If we're only going to be local then we get the version from the config file $current_phpbb_version = mpv::get_current_version('phpbb'); if (!is_object($phpbb_version)) { $this->push_error(mpv::ERROR_FAIL, 'TARGET_VERSION_NOT_FOUND'); $return = false; } else { if (version_compare(strtolower(trim($phpbb_version->value)), strtolower($current_phpbb_version), '<')) { if (mpv::$mod_dir . '/' . basename($this->modx_filename) == $this->modx_filename) { $this->push_error(mpv::ERROR_FAIL, 'NOT_LATEST_PHPBB', array($phpbb_version->value, $current_phpbb_version)); } else { $this->push_error(mpv::ERROR_WARNING, 'NOT_LATEST_PHPBB', array($phpbb_version->value, $current_phpbb_version)); } $return = false; } } return $return; }