Exemplo n.º 1
0
function isActiveUserHasAccessToDuel($duel)
{
    $link = getDBConnection();
    if (!mysqli_select_db($link, getDBName())) {
        return false;
    }
    if (isAdmin()) {
        return true;
    }
    $userId = intval(getActiveUserID());
    $duel = intval($duel);
    $duelParams = mysqli_query($link, "SELECT round, strategy1, strategy2 FROM duels WHERE id = {$duel}");
    $round = mysqli_result($duelParams, 0, 0);
    $s1 = mysqli_result($duelParams, 0, 1);
    $s2 = mysqli_result($duelParams, 0, 2);
    if ($round != -1) {
        if (mysqli_result(mysqli_query($link, "SELECT visible FROM rounds WHERE id={$round}"), 0) != true) {
            return false;
        } else {
            return true;
        }
    }
    if (getUserIdByStrategy($s1) == $userId || getUserIdByStrategy($s2) == $userId) {
        return true;
    }
    return false;
}
Exemplo n.º 2
0
function getNicknameByStrategy($strategyId)
{
    return getNicknameById(getUserIdByStrategy($strategyId));
}
                if ($_POST['mode'] == "acceptFirstNthUsers") {
                    $possibleUsers = $_POST['users'];
                    $value = intval($_POST['value']);
                    $counter = 0;
                    if ($counter < $value) {
                        foreach ($possibleUsers as $strategyId) {
                            $userId = intval(getUserIdByStrategy($strategyId));
                            mysqli_query($link, "INSERT INTO roundActivity SET round = {$roundId}, user = {$userId}, state = 'ACT'");
                            $counter = $counter + 1;
                            if ($counter == $value) {
                                break;
                            }
                        }
                    }
                } else {
                    if ($_POST['mode'] == "declineLastUsers") {
                        $acceptedUsers = $_POST['users'];
                        $value = intval($_POST['value']);
                        $previousRound = intval($_POST['previousRound']);
                        foreach ($acceptedUsers as $strategyId) {
                            if (getScoreByStrategy($previousRound, $strategyId) > $value) {
                                $userId = getUserIdByStrategy($strategyId);
                                mysqli_query($link, "INSERT INTO roundActivity SET round = {$roundId}, user = {$userId}, state = 'ACT'");
                            }
                        }
                    }
                }
            }
        }
    }
}