Exemplo n.º 1
0
echo getRankBoxBottom();
?>
</td>
<td style="text-align:right;vertical-align:top"><a href="#byTeam">Standings by Team &darr;&nbsp;&nbsp;</a></td>
</tr>
<tr><td></td></tr>
<tr><td>Standings by team are calculated over ladder games played in the last 90 days.</td></tr>
<tr><td><a name="byTeam" /><br>
<?


// Team Standings
$columnTitlesArray = array ('Pos', 'Team', 'Points', 'Pts +','Pts -', 'W', 'D', 'L', 'Percentage');
$boxTitle = "Team Standings - By Team";

$teamStatSet = getTeamStandingsPerTeamArray();

?>
<?php 
echo getRankBoxTop($boxTitle, $columnTitlesArray);
?>
<? 
$cur = 0;

$ptsDiffOld = "";

foreach ($teamStatSet as $teamStat) {
	$cur++;
	$player1 = $teamStat->player1;
	$player2 = $teamStat->player2;
	
Exemplo n.º 2
0
function updateTeamladders()
{
    require 'variables.php';
    $playerLeader = "";
    $playerLeaderSaved = "";
    $teamLeader1 = "";
    $teamLeader1Saved = "";
    $teamLeader2 = "";
    $teamLeader2Saved = "";
    $time = time();
    // get current calculated leaders of both ladders
    // per player
    $sql = "SELECT player_id, teamWins/teamGames as percentage FROM {$playerstable} " . "WHERE teamGames > 0 AND approved='yes' ORDER BY teamPoints DESC, percentage DESC, teamLosses ASC";
    $result = mysql_query($sql);
    $num = mysql_num_rows($result);
    if ($num > 0) {
        $row = mysql_fetch_array($result);
        $playerLeader = $row["player_id"];
    }
    // per team
    $teamStatSet = getTeamStandingsPerTeamArray();
    if (count($teamStatSet) > 0) {
        $teamLeader1 = getIdForPlayer($teamStatSet[0]->player1);
        $teamLeader2 = getIdForPlayer($teamStatSet[0]->player2);
    }
    // check current entries of teamladder table
    $sql = "SELECT playerId from {$teamladdertable} where type='player' ORDER BY timestamp DESC LIMIT 0, 1";
    $result = mysql_query($sql);
    $num = mysql_num_rows($result);
    if ($num > 0) {
        $row = mysql_fetch_array($result);
        $playerLeaderSaved = $row["playerId"];
    }
    $sql = "SELECT playerId, playerId2 from {$teamladdertable} where type='team' ORDER BY timestamp DESC LIMIT 0, 1";
    $result = mysql_query($sql);
    $num = mysql_num_rows($result);
    if ($num > 0) {
        $row = mysql_fetch_array($result);
        $teamLeader1Saved = $row["playerId"];
        $teamLeader2Saved = $row["playerId2"];
    }
    // update teamladder table if neccessary
    if ($playerLeader != $playerLeaderSaved) {
        // save new entry
        $sql = "INSERT INTO {$teamladdertable} (playerId, type, timestamp) VALUES ('{$playerLeader}', 'player', '{$time}')";
        mysql_query($sql);
    }
    if ($teamLeader1 != $teamLeader1Saved || $teamLeader2 != $teamLeader2Saved) {
        $sql = "INSERT INTO {$teamladdertable} (playerId, playerId2, type, timestamp) VALUES ('{$teamLeader1}', '{$teamLeader2}', 'team', '{$time}')";
        mysql_query($sql);
    }
}