next version in history * * @var array */ var $versions = array( '1.0.2' => '1.1.0', '1.1.0' => '1.1.1', '1.1.1' => '1.1.2', '1.1.2' => '1.1.3' ); function JlogUpdater() { require_once(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."settings.class.php"); } function getOldVersion() { return JLOG_INSTALLED_VERSION; } function getNewVersion() { return JLOG_SOFTWARE_VERSION; } function isUp2Date() { if (version_compare($this->getOldVersion(), $this->getNewVersion(), '<')) { return false; } return true; } function prepareForm($l) { $html = '
'; return $html; } function performUpdate($l) { if (JLOG_AMDIN_PASSWORD !== md5($_POST['jlog_password']) and JLOG_ADMIN_PASSWORD !== md5(utf8_decode($_POST['jlog_password']))) { return '' . $l['admin']['login_false_pw'] . '
'; } require_once(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."settings.class.php"); // read current settings from environment $settings = new Settings($l); $settings->importDataByConstants(); $error = false; $html = ''; $version = $this->getOldVersion(); while (isset($this->versions[$version])) { $class = $this->_loadUpdateClass($version, $this->versions[$version]); $html .= sprintf("' . $l['admin']['update_successfull_part'] . '
'; } } else { $html .= $this->_renderErrors($result); break; } $version = $this->versions[$version]; } if ($error) { $html .= '' . $l['admin']['update_failure'] . '
'; } else { $html .= '' . $l['admin']['update_successfull'] . '
'; } return $html; } function _getUpdateFile($oldver, $newver) { $oldver = str_replace('.', '', $oldver); $newver = str_replace('.', '', $newver); return "{$oldver}To{$newver}.php"; } function _getUpdateClass($oldver, $newver) { $oldver = str_replace('.', '', $oldver); $newver = str_replace('.', '', $newver); return "JlogUpdate_{$oldver}To{$newver}"; } function _loadUpdateClass($oldver, $newver) { $file = $this->_getUpdateFile($oldver, $newver); $class = $this->_getUpdateClass($oldver, $newver); require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . $file); return new $class(); } function _renderErrors($errors) { $html = '