Example #1
0
$nav = "upgrade";
$returnLocation = './index.php';
// Instead of include environment.php (because maybe database connection doesn't exists)
define("OPEN_THEME_NAME", "OpenClinic");
define("OPEN_THEME_CSS_FILE", "openclinic.css");
require_once "../config/i18n.php";
require_once "../config/session_info.php";
require_once "../lib/FlashMsg.php";
require_once "../model/Query/Setting.php";
require_once "../lib/File.php";
// File::getDirContent()
$setQ = new Query_Setting();
$setQ->captureError(true);
$setQ->select();
if ($setQ->isError()) {
    FlashMsg::add(sprintf(_("The connection to the database failed with the following error: %s"), $setQ->getDbError()), OPEN_MSG_ERROR);
    $setQ->close();
    // after getDbError
    header("Location: " . $returnLocation);
    exit;
}
$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;