Example #1
0
function user_Add($mail, $node = 0)
{
    $key = userAuthKey_Gen();
    $id = db_QueryInsert("INSERT IGNORE INTO " . SH_TABLE_PREFIX . SH_TABLE_USER . " (\n\t\t\tnode, mail, created, auth_key, last_auth\n\t\t)\n\t\tVALUES ( \n\t\t\t?, ?, NOW(), ?, 0\n\t\t)", $node, $mail, $key);
    if ($id) {
        $ret = [];
        $ret['id'] = $id;
        $ret['auth_key'] = $key;
        return $ret;
    }
    return null;
}
Example #2
0
function user_AddStrike($reason, $node, $user)
{
    return db_QueryInsert("INSERT INTO " . CMW_TABLE_USER_STRIKE . " (\n\t\t\treason, node, user, `timestamp`\n\t\t)\n\t\tVALUES ( \n\t\t\t?, ?, ?, NOW()\n\t\t)", $reason, $node, $user);
}
Example #3
0
function _themeIdea_AddWithLimit($idea, $event_id, $user_id, $limit)
{
    global $db;
    _db_Connect();
    // Only because we're doing native DB ops, call connect //
    $db->begin_transaction();
    $count = 0;
    try {
        $count = themeIdea_Count($event_id, $user_id, " FOR UPDATE;");
        if ($count === false) {
            throw new Exception();
        }
        if ($count >= $limit) {
            throw new Exception();
        }
        $result = db_QueryInsert("INSERT INTO " . SH_TABLE_PREFIX . SH_TABLE_THEME_IDEA . " (\n\t\t\t\ttheme, node, user, timestamp\n\t\t\t)\n\t\t\tVALUES ( \n\t\t\t\t?, ?, ?, NOW()\n\t\t\t)", $idea, $event_id, $user_id);
        if (empty($result)) {
            throw new Exception();
        }
        $count = themeIdea_Count($event_id, $user_id);
        if ($count === false) {
            throw new Exception();
        }
        if ($count > $limit) {
            throw new Exception();
        }
        // We're good! Commit! We're finished //
        $db->commit();
        return ["id" => $result, "count" => $count];
    } catch (Exception $ex) {
        // Bad! Do a rollback! //
        $db->rollback();
        return ["id" => 0, "count" => $count];
    }
}
Example #4
0
function legacy_GenerateUserHash($id)
{
    $hash = bin2hex(openssl_random_pseudo_bytes(24));
    db_QueryInsert("INSERT IGNORE " . CMW_TABLE_LEGACY_USER . " (\n\t\t\tid, `hash`, `timestamp`\n\t\t)\n\t\tVALUES ( \n\t\t\t?, ?, NOW()\n\t\t)\n\t\tON DUPLICATE KEY UPDATE\n\t\t\t`hash`=VALUES(`hash`),\n\t\t\t`timestamp`=VALUES(`timestamp`)\n\t\t;", $id, $hash);
    return $hash;
}
Example #5
0
function access_LogUser($user, $ip)
{
    return db_QueryInsert("INSERT INTO " . CMW_TABLE_USER_ACCESS . " (\n\t\t\tuser, ip, first_timestamp, last_timestamp, total\n\t\t)\n\t\tVALUES ( \n\t\t\t?, " . (defined('CMW_USING_MARIADB') ? "INET6_ATON(?)" : "INET_ATON(?)") . ", NOW(), NOW(), 1\n\t\t)\n\t\tON DUPLICATE KEY UPDATE\n\t\t\tlast_timestamp=NOW(),\n\t\t\ttotal=total+1\n\t\t;", $user, $ip);
}
Example #6
0
function theme_AddFinalVote($node, $value, $user)
{
    return db_QueryInsert("INSERT INTO " . CMW_TABLE_THEME_FINAL_VOTE . " (\n\t\t\tnode, user, value, `timestamp`\n\t\t)\n\t\tVALUES ( \n\t\t\t?, ?, ?, NOW()\n\t\t)\n\t\tON DUPLICATE KEY UPDATE \n\t\t\tvalue=VALUES(value),\n\t\t\t`timestamp`=VALUES(`timestamp`)\n\t\t", $node, $user, $value);
}