Exemplo n.º 1
0
<?php

require "api/utils/teams.php";
$app->group('/teams', function () {
    //get teams list
    $this->get('', function ($req, $res, $args) {
        $teams = getAllTeams();
        if ($teams) {
            return $res->withStatus(200)->write(json_encode($teams));
        } else {
            return $res->withStatus(400)->write($e->getMessage());
        }
    })->setName('teams');
    //get team with id
    $this->get('/{id}', function ($req, $res, $args) {
        $team = getTeam($args['id']);
        if ($team) {
            return $res->withStatus(200)->write(json_encode($team));
        } else {
            return $res->withStatus(400)->write($e->getMessage());
        }
    });
    //post new team
    $this->post('', function ($req, $res, $args) {
        $team = $req->getParsedBody();
        $sql = "INSERT INTO teams (region, name, logo, games, wins) VALUES (:region, :name, :logo, 0, 0)";
        try {
            $db = getConnection();
            $stmt = $db->prepare($sql);
            $stmt->bindParam("region", $team['region']);
            $stmt->bindParam("name", $team['name']);
Exemplo n.º 2
0
    echo '<td>' . ($row['paid'] ? "Yes" : "No") . '</td></tr>';
}
?>
								</table>
								<br />
								<br />
								<table class="table table-hover table-condensed">
									<tr>
										<th>Id</th>
										<th>Name</th>
										<th>Members</th>
										<th>Founder</th>
										<th># Paid</th>
									</tr>
									<?php 
$result = getAllTeams();
while ($row = mysql_fetch_array($result)) {
    $admin = getUser($row['admin_id']);
    echo '<tr><td>' . $row['id'] * 7 . '</td>';
    echo '<td>' . $row['name'] . '</td>';
    echo '<td>' . getTeamCount($row['id']) . '</td>';
    echo '<td>' . $admin['name'] . '</td>';
    echo '<td>' . getTeamCountPaid($row['id']) . '</td></tr>';
}
?>
								</table>
							</div>
						</div>
					</div>
					<h6 style="margin-bottom: 10px;">Philip Bale is the shit. Faz is ugly.</h6>
				</div>
Exemplo n.º 3
0
function getAllGWTeams($userid)
{
    $returnArray = array();
    if (isset($userid) && is_numeric($userid)) {
        $fix = getCurrentFixtureForManager($userid);
        if ($fix->home == $userid) {
            $opponentid = $fix->away;
        } else {
            $opponentid = $fix->home;
        }
        //first add the current user to the array
        $returnArray[] = getGWTeam($userid);
        //secondly add the opponent
        $returnArray[] = getGWTeam($opponentid);
        foreach (getAllTeams() as $team) {
            if ($team->id != $userid && $team->id != $opponentid) {
                $returnArray[] = getGWTeam($team->id);
            }
        }
    } else {
        foreach (getAllTeams() as $team) {
            $returnArray[] = getGWTeam($team->id);
        }
    }
    return $returnArray;
}