Exemplo n.º 1
0
function create_status($req)
{
    $source = source_lookup_auth($req->authenticator);
    if (!$source) {
        error("auth failure");
        return;
    }
    $req->source_id = $source->id;
    if (!status_insert($req)) {
        error(db_error());
        return;
    }
    $reply = success();
    $reply->id = insert_id();
    echo json_encode($reply);
}
Exemplo n.º 2
0
function login_action()
{
    $auth = get_str("auth");
    $source = source_lookup_auth($auth);
    if ($source) {
        setcookie("auth", $auth, 0, "/");
        Header("Location: hl.php");
    } else {
        error_page("Invalid authenticator");
    }
}
Exemplo n.º 3
0
function recommended_store($req)
{
    $source = source_lookup_auth($req->authenticator);
    if (!$source) {
        error("auth failure");
        return;
    }
    $stores = store_enum('unavailable=0');
    foreach ($stores as $store) {
        $space = $store->capacity - $store->used;
        if ($req->file_size < $space) {
            $reply = success();
            $reply->store = $store;
            echo json_encode($reply);
            return;
        }
    }
    error("no store has sufficient free space");
    return;
}