コード例 #1
0
foreach ($profiles as $userId => $userArray) {
    foreach ($userArray as $profileId => $profileArray) {
        $sql = "SELECT six_profiles.name AS profileName, six_profiles.points, six_profiles.rating, six_profiles.disconnects " . "FROM six_profiles " . "WHERE six_profiles.id=" . $profileArray['profileId'];
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result);
        $dcOld = $row['disconnects'];
        $dcChange = $profileArray['seasonDC'] - $dcOld;
        if ($dcChange != 0) {
            $sql = "UPDATE six_profiles SET disconnects=" . $profileArray['seasonDC'] . " WHERE id=" . $profileId;
            mysql_query($sql);
            $log->logInfo('setDisconnects: sql=' . $sql);
            $log->logInfo('setDisconnects: ' . $row['profileName'] . ' (' . $profileId . '): disconnects=' . $profileArray['seasonDC'] . ' dcOld=' . $dcOld . ' affected=' . mysql_affected_rows());
            // recalculate points and rating
            $wins = getSixserverWins($profileId);
            $draws = getSixserverDraws($profileId);
            $losses = getSixserverLosses($profileId);
            $dc = $profileArray['seasonDC'];
            $pointsOld = $row['points'];
            $pointsCalcOld = getSixserverPoints($wins, $draws, $losses + $dcOld);
            $pointsNew = getSixserverPoints($wins, $draws, $losses + $dc);
            $log->logInfo("wins={$wins} draws={$draws} losses={$losses} dc={$dc}");
            $log->logInfo("setDisconnects: pointsOld={$pointsOld} pointsCalcOld={$pointsCalcOld} pointsNew={$pointsNew}");
            $sql2 = "SELECT sum(wins), sum(draws), sum(losses), sum(dc) FROM six_history WHERE profileId=" . $profileId;
            $result2 = mysql_query($sql2);
            $row2 = mysql_fetch_array($result2);
            $wins = $wins + $row2[0];
            $draws = $draws + $row2[1];
            $losses = $losses + $row2[2];
            $dc = $dc + $row2[3];
            $ratingOld = $row['rating'];
            $ratingCalcOld = getSixserverPoints($wins, $draws, $losses + $dcOld + $row2[3]);
コード例 #2
0
ファイル: fixSixHistory.php プロジェクト: kinj1987/evo-league
  }
  echo "ok";
  */
  
  $sql = "SELECT * FROM six_profiles WHERE id=6624 ORDER BY points DESC";
  $result = mysql_query($sql);
  while ($row = mysql_fetch_array($result)) {
    $id = $row['id'];
    
    $sql2 = "SELECT sum(wins), sum(draws), sum(losses), sum(dc) FROM six_history WHERE profileId=".$id;
    $result2 = mysql_query($sql2);
    $row2 = mysql_fetch_array($result2);
    
    $wins = getSixserverWins($id);
    $draws = getSixserverDraws($id);
    $losses = getSixserverLosses($id);
    
    $dc = $row['disconnects'];
    $pts = $row['points'];

    $ptsNew = getSixserverPoints($wins, $draws, $losses+$dc);
    echo "<p>";
    echo "<br>$sql2";
    echo "<br>".$row2[0]."-".$row2[1]."-".$row2[2]."-".$row2[3];
    echo "<br>wins=$wins draws=$draws losses=$losses dc=$dc id=$id pts=$pts ptsNew=$ptsNew";
    
    $sql = "UPDATE six_profiles SET points2=points WHERE id=$id";
    echo "<br>$sql";
    mysql_query($sql);

    $sql = "UPDATE six_profiles SET points=$ptsNew WHERE id=$id";
コード例 #3
0
ファイル: functions.php プロジェクト: kinj1987/evo-league
function RecalculatePointsForProfile($id, $dc, $pts, $rating)
{
    // current season
    $wins = getSixserverWins($id);
    $draws = getSixserverDraws($id);
    $losses = getSixserverLosses($id);
    $ptsNew = getSixserverPoints($wins, $draws, $losses + $dc);
    $msg .= "<br>This season: wins={$wins} draws={$draws} losses={$losses} dc={$dc} id={$id} pts={$pts} ptsNew={$ptsNew}";
    $sql = "UPDATE six_profiles SET points2=points WHERE id={$id}";
    $msg .= "<br>{$sql}";
    mysql_query($sql);
    $sql = "UPDATE six_profiles SET points={$ptsNew} WHERE id={$id}";
    $msg .= "<br>{$sql}";
    mysql_query($sql);
    // rating: all seasons
    $sql2 = "SELECT sum(dc) FROM six_history WHERE profileId=" . $id;
    $result2 = mysql_query($sql2);
    $row2 = mysql_fetch_array($result2);
    $wins = getSixserverWinsAllTime($id);
    $draws = getSixserverDrawsAllTime($id);
    $losses = getSixserverLossesAllTime($id);
    $dc = $dc + $row2[0];
    $ratingNew = getSixserverPoints($wins, $draws, $losses + $dc);
    $msg .= "<br>All time: wins={$wins} draws={$draws} losses={$losses} dc={$dc} id={$id} rating={$rating} ratingNew={$ratingNew}";
    $sql = "UPDATE six_profiles SET rating={$ratingNew} WHERE id={$id}";
    $msg .= "<br>{$sql}";
    mysql_query($sql);
    return $msg;
}