Exemple #1
0
        } else {
            $game->selectAdd($user, $tag, $selected);
            $game->setUserScore($user, -1);
            echo json_encode('add');
        }
    }
}
// 获取用户基本信息,根据名称,且快速登录
if ($key == 'get_user_byname') {
    $uid = $request['uid'];
    $old = $request['old'];
    $info = $game->getUser($uid);
    $time = 60;
    // 登录钥匙有效时间(秒)
    if ($old) {
        $game->setUserStatus($old, 0);
    }
    // 获取原有账户
    if ($info) {
        // 未登录状态
        if ($info['status'] <= time() - $time) {
            $value = array('status' => 1, 'msg' => '登录成功', 'name' => $uid, 'score' => $info['score'], 'key' => $game->setUserStatus($uid, time()), 'token' => $info['token'], 'valid' => $time);
            // 如果是登录状态
        } else {
            $value = array('status' => 0, 'msg' => '账号正在使用中。');
        }
        // 新建账户
    } else {
        $info = $game->userAdd('', $uid);
        $value = array('status' => 2, 'msg' => '创建用户且登录成功', 'name' => $uid, 'score' => 10, 'key' => $info['key'], 'token' => $info['token'], 'valid' => $time);
    }