$set = $setQ->fetch(); if (!$set) { $setQ->close(); Error::fetch($setQ); } $version = $set->getVersion(); if (!preg_match("/\\d+(\\.\\d+){1,2}/", $version)) { FlashMsg::add(sprintf(_("Version field doesn't have a valid format (%s)."), $version), OPEN_MSG_ERROR); header("Location: " . $returnLocation); exit; } if (substr_count($version, '.') == 2) { $version = substr($version, 0, strrpos($version, '.')); // only 2 groups of ciphers: <number>.<number> } $upgrades = File::getDirContent('./upgrades', false, array('sql')); if (!is_array($upgrades)) { FlashMsg::add(_("There aren't upgrade files."), OPEN_MSG_ERROR); header("Location: " . $returnLocation); exit; } $title = _("Upgrade Database"); require_once "../layout/header.php"; require_once dirname(__FILE__) . "/parse_sql_file.php"; echo HTML::section(1, $title); echo HTML::para(sprintf(_("Finded version: %s"), $version)); foreach ($upgrades as $value) { $file = $value; // upgrade<initial_version>-<final_version>.sql $value = substr($value, strlen('upgrade')); // <initial_version>-<final_version>.sql