Esempio n. 1
0
/**
 * Checks if server is ready to work with smt2 by comparing the server's $type version.
 * At least are required both PHP 5 and MySQL 5.
 * @param   string    $type       "php" or "mysql", by now
 * @param   string    $minReqVer  minimun system version (default: 5.0.0)
 * @return  boolean               TRUE on sucess, or FALSE on failure
 */
function check_systemversion($type, $minReqVer = "5.0.0")
{
    switch (strtolower($type)) {
        case 'mysql':
            // mysqli_get_client_info() doesn't require connection
            $ver = mysql_get_client_info();
            // mysql version numbers can be as weird as "mysqlnd 5.0.11-dev - 20120503 - $Id: ...$"
            $ver = version2int($ver);
            break;
        case 'php':
            // php version numbers work fine with version_compare
            $ver = phpversion();
            break;
        default:
            break;
    }
    // $ver must be >= $minReqVer
    $status = version_compare($ver, $minReqVer, ">=");
    return $status;
}
Esempio n. 2
0
$req->execute();
$arr = $req->fetchAll();
$nbVer = (int) $arr[0][0];
if ($nbVer === 0) {
    sendJson(JSON_PACKAGE_NOT_FOUND);
}
// Récup du paquet (à jour ou la version demandée)
$pack = null;
if (!isset($query["version"])) {
    $req = $bdd->prepare("SELECT * FROM package WHERE name = :name ORDER BY version DESC LIMIT 1");
    $req->bindValue(":name", $name);
    $req->execute();
    $arr = $req->fetchAll(PDO::FETCH_ASSOC);
    $pack = $arr[0];
} else {
    $version = version2int($query["version"]);
    $req = $bdd->prepare("SELECT * FROM package WHERE name = :name AND version = :version");
    $req->bindValue(":name", $name);
    $req->bindValue(":version", $version, PDO::PARAM_INT);
    $req->execute();
    $arr = $req->fetchAll(PDO::FETCH_ASSOC);
    if (count($arr) === 0) {
        sendJson(JSON_VERSION_NOT_FOUND);
    }
    $pack = $arr[0];
}
$pack["version"] = int2version($pack["version"]);
// Dépendances
$req = $bdd->prepare("SELECT * FROM lib JOIN package_lib ON package_lib.id_lib = lib.id_lib WHERE package_lib.id_package = :pack");
$req->bindValue(":pack", $pack["id_package"]);
$req->execute();