Esempio n. 1
0
function getKey($username)
{
    //Get their chat key, or generate a new one if we need to
    $query = pdo_prepare("SELECT `chatkey` FROM `users` WHERE `username` = :username");
    $query->bind(":username", $username);
    $chatkey = $query->execute()->fetchIdx(0);
    if ($chatkey == "" || $chatkey == false) {
        //No key found, make them a new one
        $chatkey = strRand(32);
        $query = pdo_prepare("UPDATE `users` SET `chatkey` = :key WHERE `username` = :username");
        $query->bind(":key", $chatkey);
        $query->bind(":username", $username);
        $query->execute();
    }
    return $chatkey;
}
Esempio n. 2
0
function get_current_version()
{
    global $version_db_table_name;
    $query = "SELECT version FROM " . $version_db_table_name . " ORDER BY updated DESC, version DESC LIMIT 1";
    $statement = pdo_prepare($query);
    $result = $statement->execute();
    if ($result === false || $statement->rowCount() <= 0) {
        return '(none)';
    }
    $row = $statement->fetch();
    return $row['version'];
}