Example #1
0
function StartSixserverSeason()
{
    $appRoot = realpath(dirname(__FILE__)) . '/';
    require $appRoot . './../variables.php';
    require $appRoot . './../variablesdb.php';
    require $appRoot . './../sixserver/functions.php';
    $msg = "";
    $pointsArray = GetStandingsArray(true);
    $sql = "SELECT season FROM six_stats";
    $sixSeason = mysql_fetch_array(mysql_query($sql))[0];
    $sql = "SELECT sp.id as profileId, sp.points, sp.disconnects, " . "weblm_players.player_id, weblm_players.name AS playerName, weblm_players.nationality, weblm_players.approved FROM six_profiles sp " . "LEFT JOIN weblm_players ON weblm_players.player_id=sp.user_id " . "ORDER BY sp.points DESC, playerName ASC";
    $msg .= "<p>" . $sql;
    $result = mysql_query($sql);
    $oldPoints = -1;
    $counter = 1;
    $pos = -1;
    while ($row = mysql_fetch_array($result)) {
        $profileId = $row['profileId'];
        $playerId = $row['player_id'];
        $points = $row['points'];
        $disconnects = $row['disconnects'];
        if (isset($pointsArray[$profileId]['w'])) {
            $wins = $pointsArray[$profileId]['w'];
        } else {
            $wins = 0;
        }
        if (isset($pointsArray[$profileId]['l'])) {
            $losses = $pointsArray[$profileId]['l'];
        } else {
            $losses = 0;
        }
        if (isset($pointsArray[$profileId]['d'])) {
            $draws = $pointsArray[$profileId]['d'];
        } else {
            $draws = 0;
        }
        $games = $wins + $losses + $draws;
        $approved = $row['approved'] == 'yes';
        if (!$approved) {
            $pos = 0;
        } else {
            if ($oldPoints != $points) {
                $pos = $counter;
                $oldPoints = $points;
            }
            $counter++;
        }
        if ($games > 0) {
            $percentage = $wins / $games;
            $sql = "INSERT INTO six_history (playerId, profileId, season, position, points, games, wins, losses, draws, DC) " . "VALUES ('{$playerId}', '{$profileId}', '{$sixSeason}', '{$pos}', '{$points}', '{$games}', '{$wins}', '{$losses}', '{$draws}', '{$disconnects}')";
            $msg .= "<p>" . $sql . "</p>" . PHP_EOL;
            mysql_query($sql);
        }
    }
    // set points and dc to zero
    $update_sql = "UPDATE six_profiles set points=0, disconnects=0";
    $result = mysql_query($update_sql);
    $msg .= "<p>set points to zero [" . mysql_affected_rows() . "]<p>" . PHP_EOL;
    // update season var
    $update_sql = "UPDATE six_stats set season=season+1";
    $result = mysql_query($update_sql);
    $msg .= "<p>update season var [" . mysql_affected_rows() . "]<p>" . PHP_EOL;
    return $msg;
}
Example #2
0
} else {
    if (!empty($_GET['group'])) {
        $group = mysql_real_escape_string($_GET['group']);
    }
}
if ($type == "points2") {
    $pointsArray = GetStandingsArray(true);
    $orderByField = "points2";
    $colTitle = "Points2";
} else {
    if ($type == "s") {
        $pointsArray = GetStandingsArray(true);
        $orderByField = "points";
        $colTitle = "Points";
    } else {
        $pointsArray = GetStandingsArray(false);
        $orderByField = "rating";
        $colTitle = "Rating";
    }
}
$left = $subNavText . getRaquo() . getSubNavigation($subpage, null);
$right = "our time is <b>" . date("m/d h:i a") . " " . $timezone . "</b>";
echo getOuterBoxTop($left, $right);
?>
<?
$columnTitlesArray = array ('Pos', 'Player', 'Profile', $colTitle, 'W', 'D', 'L', 'DC', 'Percentage');
	$boxTitle = "Sixserver Standings";
?>
<table width="900"><tr><td>

<table class="formtable"><tr><td nowrap>