Exemplo n.º 1
0
<?php

include INSTALL_PATH . '/classes/ToolsInstall.php';
$resultDB = ToolsInstall::checkDB($_GET['server'], $_GET['login'], $_GET['password'], $_GET['name']);
die("<action result='" . ($resultDB === true ? "ok" : "fail") . "' error='" . ($resultDB === true ? "" : $resultDB) . "'/>\n");
    include_once INSTALL_PATH . '/../config/settings.inc.php';
    $oldversion = _PS_VERSION_;
} else {
    die('<action result="fail" error="30" />' . "\n");
}
$versionCompare = version_compare(INSTALL_VERSION, _PS_VERSION_);
if ($versionCompare == '-1') {
    die('<action result="fail" error="27" />' . "\n");
} elseif ($versionCompare == 0) {
    die('<action result="fail" error="28" />' . "\n");
} elseif ($versionCompare === false) {
    die('<action result="fail" error="29" />' . "\n");
}
//check DB access
include INSTALL_PATH . '/classes/ToolsInstall.php';
$resultDB = ToolsInstall::checkDB(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_, false);
if ($resultDB !== true) {
    die("<action result='fail' error='" . $resultDB . "'/>\n");
}
//custom sql file creation
$upgradeFiles = array();
if ($handle = opendir(INSTALL_PATH . '/sql/upgrade')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' and $file != '..') {
            $upgradeFiles[] = str_replace(".sql", "", $file);
        }
    }
    closedir($handle);
}
if (empty($upgradeFiles)) {
    die('<action result="fail" error="31" />' . "\n");