예제 #1
0
function RestoreLadderGame($restoreGameId)
{
    $appRoot = realpath(dirname(__FILE__)) . '/';
    require $appRoot . './../variables.php';
    require $appRoot . './../variablesdb.php';
    require_once $appRoot . './../functions.php';
    $resultMsg = "Restoring Game #" . $restoreGameId . "<br>";
    $sql = "select * from {$gamestable} where game_id = '{$restoreGameId}'";
    $result = mysql_query($sql);
    $num = mysql_num_rows($result);
    if ($num != 1) {
        $resultMsg .= "Invalid query, found {$num} results for '{$sql}'";
    } else {
        $row = mysql_fetch_array($result);
        $deleted = $row['deleted'];
        $row_season = $row['season'];
        $isDraw = $row['isDraw'];
        if ($row_season != $season) {
            $resultMsg .= "<p>Game #" . $restoreGameId . " is not from this season!</p>";
        } else {
            if ($deleted == 'no') {
                $resultMsg .= "<p>Game #" . $restoreGameId . " is not deleted!</p>";
            } else {
                $ratingdiff = $row['ratingdiff'];
                $winpoints = $row['winpoints'];
                $losepoints = $row['losepoints'];
                $losepoints2 = $row['losepoints2'];
                $winner = $row['winner'];
                $winner2 = $row['winner2'];
                $loser = $row['loser'];
                $loser2 = $row['loser2'];
                $teamLadder = $row['teamLadder'];
                $sql = "UPDATE {$gamestable} SET deleted = 'no' where game_id = '{$restoreGameId}'";
                $result = mysql_query($sql);
                if ($result != 1) {
                    $resultMsg .= '<p>Error updating game!</p>';
                } else {
                    $resultMsg .= "<p>Game #{$restoreGameId} restored.</p>";
                }
                $sql = "select version from {$gamestable} where game_id ='{$restoreGameId}'";
                $result = mysql_query($sql);
                while ($row = mysql_fetch_array($result)) {
                    $version = $row["version"];
                }
                if ($teamLadder == 0) {
                    $pointsField = getPointsFieldForVersion($version);
                    $winsField = getWinsFieldForVersion($version);
                    $lossesField = getLossesFieldForVersion($version);
                    $gamesField = getGamesFieldForVersion($version);
                    $drawsField = "draws";
                } else {
                    $pointsField = "teamPoints";
                    $winsField = "teamWins";
                    $lossesField = "teamLosses";
                    $drawsField = "teamDraws";
                    $gamesField = "teamGames";
                }
                $winner_streakArray = getStreak($winner);
                $winner_winstreak = $winner_streakArray[0];
                $winner_losestreak = $winner_streakArray[1];
                $resultMsg .= "<p>New streak for {$winner}: Won " . $winner_winstreak . ", lost " . $winner_losestreak . "</p>";
                $loser_streakArray = getStreak($loser);
                $loser_winstreak = $loser_streakArray[0];
                $loser_losestreak = $loser_streakArray[1];
                $resultMsg .= "<p>New streak for {$loser}: Won " . $loser_winstreak . ", lost " . $loser_losestreak . "</p>";
                $sql = "SELECT {$pointsField} from {$playerstable} where name='{$loser}'";
                $result = mysql_query($sql);
                $row = mysql_fetch_array($result);
                $ra2ladder = $row[$pointsField];
                $newra2ladder = $ra2ladder - $losepoints;
                if ($newra2ladder < 0) {
                    $newra2ladder = 0;
                }
                if ($isDraw > 0) {
                    $winLoss = 0;
                    $draw = 1;
                } else {
                    $winLoss = 1;
                    $draw = 0;
                }
                $sql = "UPDATE {$playerstable} SET {$lossesField} = {$lossesField} + {$winLoss}," . "totallosses = totallosses + {$winLoss}, " . "{$drawsField}={$drawsField}+{$draw}, totaldraws = totaldraws + {$draw}, " . "{$gamesField} = {$gamesField} + 1, " . "totalgames = totalgames + 1, " . "streakwins = {$loser_winstreak}, " . "streaklosses = {$loser_losestreak}, " . "rating = rating - {$ratingdiff}, " . "{$pointsField} = {$newra2ladder} WHERE name='{$loser}'";
                $result = mysql_query($sql);
                if ($result != 1) {
                    $resultMsg .= '<p>Error updating loser: $result</p>';
                }
                $sql = "UPDATE {$playerstable} " . "SET {$winsField} = {$winsField}+ {$winLoss}, " . "totalwins = totalwins + {$winLoss}, " . "{$gamesField} = {$gamesField} + 1, " . "totalgames = totalgames + 1, " . "{$drawsField}={$drawsField}+{$draw}, totaldraws = totaldraws + {$draw}, " . "streakwins = {$winner_winstreak}, " . "streaklosses = {$winner_losestreak}, " . "rating = rating + {$ratingdiff}, " . "{$pointsField} = {$pointsField} + {$winpoints} " . "WHERE name='{$winner}'";
                $result = mysql_query($sql);
                if ($result != 1) {
                    $resultMsg .= '<p>Error updating winner: ' . $result . '</p>';
                }
                // Winner2 / Loser2
                if (!empty($loser2)) {
                    $loser2_streakArray = getStreak($loser2);
                    $loser2_winstreak = $loser2_streakArray[0];
                    $loser2_losestreak = $loser2_streakArray[1];
                    $resultMsg .= "<p>New streak for {$loser2}: Won " . $loser2_winstreak . ", lost " . $loser2_losestreak . "</p>";
                    $sql = "SELECT {$pointsField} from {$playerstable} where name='{$loser2}'";
                    $result = mysql_query($sql);
                    $row = mysql_fetch_array($result);
                    $ra2ladder = $row[$pointsField];
                    $newra2ladder = $ra2ladder - $losepoints2;
                    if ($newra2ladder < 0) {
                        $newra2ladder = 0;
                    }
                    $sql = "UPDATE {$playerstable} SET {$lossesField} = {$lossesField} + {$winLoss}," . "totallosses = totallosses + {$winLoss}, " . "{$gamesField} = {$gamesField} + 1, " . "totalgames = totalgames + 1, " . "{$drawsField} = {$drawsField} + {$draw}, totaldraws = totaldraws + {$draw}, " . "streakwins = {$loser_winstreak}, " . "streaklosses = {$loser_losestreak}, " . "rating = rating - {$ratingdiff}, " . "{$pointsField} = {$newra2ladder} WHERE name='{$loser2}'";
                    $result = mysql_query($sql);
                    if ($result != 1) {
                        $resultMsg .= '<p>Error updating loser2: $result</p>';
                    }
                }
                if (!empty($winner2)) {
                    $winner2_streakArray = getStreak($winner2);
                    $winner2_winstreak = $winner2_streakArray[0];
                    $winner2_losestreak = $winner2_streakArray[1];
                    $resultMsg .= "<p>New streak for {$winner2}: Won " . $winner2_winstreak . ", lost " . $winner2_losestreak . "</p>";
                    $sql = "UPDATE {$playerstable} " . "SET {$winsField} = {$winsField} + {$winLoss}, " . "totalwins = totalwins + {$winLoss}, " . "{$gamesField} = {$gamesField} + 1, " . "totalgames = totalgames + 1, " . "{$drawsField} = {$drawsField} + {$draw}, totaldraws = totaldraws + {$draw}, " . "streakwins = {$winner2_winstreak}, " . "streaklosses = {$winner2_losestreak}, " . "rating = rating + {$ratingdiff}, " . "{$pointsField} = {$pointsField} + {$winpoints} " . "WHERE name='{$winner2}'";
                    $result = mysql_query($sql);
                    if ($result != 1) {
                        $resultMsg .= '<p>Error updating winner: ' . $result . '</p>';
                    }
                }
            }
        }
    }
    return $resultMsg;
}
예제 #2
0
					"WHERE game_id = '$gameId'";
				$result = mysql_query($sql);
				
				$teamBonusNewArray = getTeamBonus($winnerteam, $loserteam, $draw, $winpoints-$teamBonusOld);
				$teamBonusNew = $teamBonusNewArray['bonusWinner'];
				$msg.= $teamBonusNewArray['msg'];
				if ($teamBonusOld != $teamBonusNew) {
					$teamBonusDiff = $teamBonusNew - $teamBonusOld;
					$msg.= "<p>Team bonus changed: <b>$teamBonusOld</b> -&gt; <b>$teamBonusNew</b></p>";
					
					$sql = "UPDATE $gamestable SET winpoints = winpoints + $teamBonusDiff, ".
						"teamBonus = '$teamBonusNew' WHERE game_id = '$gameId'";
					$msg.= "<p>Updating game - SQL: $sql</p>";
					$result = mysql_query($sql);

					$pointsField = getPointsFieldForVersion($version);
					
					$sqlp = "SELECT $pointsField from $playerstable where name = '$winner'";
					$resultp = mysql_query($sqlp);
					$rowp = mysql_fetch_array($resultp);
					$pointsOld = $rowp[$pointsField];
					$pointsNew = $pointsOld + $teamBonusDiff;						
					if ($pointsNew < 0) {
						$pointsNew = 0;
					}
					$sql = "UPDATE $playerstable SET $pointsField = $pointsNew ".
						"WHERE name = '$winner'";
					
					$msg.= "<p>Updating player - SQL: $sql</p>";
					$result = mysql_query($sql);
				}
예제 #3
0
파일: top.php 프로젝트: kinj1987/evo-league
        if ($row = mysql_fetch_array($result)) {
            $cookie_name = $row['name'];
        }
    }
}
$loggedIn = $cookie_name != "";
if ($maintenance == 'yes') {
    die($leaguename . " down for update. We're back in a bit.");
}
if ($loggedIn) {
    $defaultversion = $row['defaultversion'];
    $ladder = getLadderForVersion($defaultversion);
    $positionPlayer = getPlayerPosition($cookie_name, $defaultversion);
    $wins = $row[getWinsFieldForVersion($defaultversion)];
    $losses = $row[getLossesFieldForVersion($defaultversion)];
    $points = $row[getPointsFieldForVersion($defaultversion)];
    $draws = $row['draws'];
    $invalidEmail = $row['invalidEmail'] == 1;
    $mail = $row['mail'];
    $rejected = $row['rejected'];
    $rejectReason = $row['rejectReason'];
    $signup = $row['signup'];
    $signupSent = $row['signupSent'];
    $hash6 = $row['hash6'];
    $s_win = "";
    $s_loss = "";
    $s_draw = "";
    if ($wins != 1) {
        $s_win = "s";
    }
    if ($losses != 1) {
예제 #4
0
        $msnpic = "<img border='1' src='gfx/msn.gif' align='absmiddle'></a>";
    }
    $uploadSpeed = $row["uploadSpeed"];
    $downloadSpeed = $row["downloadSpeed"];
    
    $deductedPoints = $row["deductedPoints"];
    
    $country = $row["country"];
	$nationality = $row["nationality"];
	
	$message = $row["message"];
	
    $rating = $row["rating"];
    $wins = $row[getWinsFieldForVersion('A')] + $row[getWinsFieldForVersion('D')];
    $losses = $row[getLossesFieldForVersion('A')] + $row[getLossesFieldForVersion('D')];
    $points = $row[getPointsFieldForVersion($version)];
    $games = $row[getGamesFieldForVersion('A')] + $row[getGamesFieldForVersion('D')];
    $draws = $row['draws'];
    
    $teamWinsSql = "SELECT count(*) as count from $gamestable where season = $season ".
    	"AND deleted = 'no' AND teamLadder = 1 AND (winner = '$name' or winner2 = '$name') and isDraw = 0";
    $teamWnsRow = mysql_fetch_array(mysql_query($teamWinsSql));
    $teamWins = $teamWnsRow['count'];
    $wins += $teamWins;
    
    $teamLossesSql = "SELECT count(*) as count from $gamestable where season = $season ".
    	"AND deleted = 'no' AND teamLadder = 1 AND (loser = '$name' or loser2 = '$name') and isDraw = 0";
    $teamLossesRow = mysql_fetch_array(mysql_query($teamLossesSql));
    $teamLosses = $teamLossesRow['count'];
    $losses += $teamLosses;
	
예제 #5
0
function UpdateLadderGamePoints($game_id, $logRep) {
  
  $logRep->logInfo('UpdateLadderGamePoints: game_id='.$game_id);
  
  $sql = "SELECT * FROM weblm_games WHERE game_id = '$game_id'";
  
  $logRep->logInfo('UpdateLadderGamePoints: sql='.$sql);
  
  $result = mysql_query($sql);
  $row = mysql_fetch_array($result);

  $draw = $row['isDraw'];
  $teamBonusOld = $row['teamBonus']; 
  $winpoints = $row['winpoints'];
  $winner = $row['winner'];
  $winner2 = $row['winner2'];
  $sixGameId = $row['sixGameId'];
  $winTeamId = $row['winnerteam'];
  $loseTeamId = $row['loserteam'];
  
  $teamBonusNewArray = getTeamBonus($winTeamId, $loseTeamId, $draw, $winpoints-$teamBonusOld);
  $teamBonusNew = $teamBonusNewArray['bonusWinner'];

  $logRep->logInfo('UpdateLadderGamePoints: teamBonusNewArray[msg]='.$teamBonusNewArray['msg'].' teamBonusOld='.$teamBonusOld.' teamBonusNew='.$teamBonusNew);

  if ($teamBonusOld != $teamBonusNew) {
    $teamBonusDiff = $teamBonusNew - $teamBonusOld;

    $sql = "UPDATE weblm_games SET winpoints=winpoints+$teamBonusDiff, ".
      "teamBonus='$teamBonusNew' WHERE game_id=$game_id";
    $result = mysql_query($sql);
    
    $logRep->logInfo('UpdateLadderGamePoints: sql='.$sql.' affected='.mysql_affected_rows());
        
    $pointsField = getPointsFieldForVersion('H'); // PES6 PC
        
    $sql = "SELECT $pointsField from weblm_players where name = '$winner'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    $pointsOld = $row[$pointsField];
    $pointsNew = $pointsOld + $teamBonusDiff;						
    if ($pointsNew < 0) {
      $pointsNew = 0;
    }
    
    $sql = "UPDATE weblm_players SET $pointsField = $pointsNew WHERE name = '$winner'";
    $result = mysql_query($sql);
    
    $logRep->logInfo('UpdateLadderGamePoints: sql='.$sql.' affected='.mysql_affected_rows());
    
    if (!empty($winner2)) {
      $sql = "SELECT $pointsField FROM weblm_players WHERE name = '$winner2'";
      $result = mysql_query($sql);
      $row = mysql_fetch_array($result);
      $pointsOld = $row[$pointsField];
      $pointsNew = $pointsOld + $teamBonusDiff;						
      if ($pointsNew < 0) {
        $pointsNew = 0;
      }
      
      $sql = "UPDATE weblm_players SET $pointsField=$pointsNew WHERE name='$winner2'";
      $result = mysql_query($sql);
      
      $logRep->logInfo('UpdateLadderGamePoints: sql='.$sql.' affected='.mysql_affected_rows());
    }
  }
}
예제 #6
0
function getProposedPoints($user, $opponent, $version)
{
    require 'variables.php';
    require 'variablesdb.php';
    $error = "error";
    $pointsField = getPointsFieldForVersion($version);
    $sql = "SELECT {$pointsField} FROM {$playerstable} WHERE name = '{$user}' and approved = 'yes'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    $num = mysql_num_rows($result);
    if ($num == 0) {
        return $error;
    }
    $ra2olduser = $row[$pointsField];
    $sql = "SELECT {$pointsField} FROM {$playerstable} WHERE name = '{$opponent}' and approved = 'yes'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    $num = mysql_num_rows($result);
    if ($num == 0) {
        return $error;
    }
    $ra2oldopponent = $row[$pointsField];
    // <-- Ra2 -->
    $useradd = round(64 * (1 - 1 / (pow(10, ($ra2oldopponent - $ra2olduser) / 550) + 1)));
    $userlose = $useradd;
    $usertotallose = $ra2olduser - $userlose;
    if ($usertotallose < 0) {
        $userlose = $ra2olduser;
    }
    return array($useradd, $userlose);
}
예제 #7
0
		
		<td valign="top"><!-- standings --> <?
    
		$standingsLinksArray[] = array ('./standings.php', 'show_standings', 'show complete standings');

		// if (!stristr(getSupportedVersions(), $cookie_version)) {
		$showVersion = "H";
		// } else {
		// 	$showVersion = $cookie_version;
		// }
		$boxTitle = "Single Standings";
		echo getBoxTopImg($boxTitle, $boxheight, false, $standingsLinksArray, $box2Img, $box2Align);
		?>
		<table>
		<?php 
$pointsField = getPointsFieldForVersion($showVersion);
$winsField = getWinsFieldForVersion($showVersion);
$lossesField = getLossesFieldForVersion($showVersion);
$gamesField = getGamesFieldForVersion($showVersion);
$sortby = $pointsField . " DESC, percentage DESC, {$lossesField} ASC";
$sql = "SELECT *, {$winsField}/{$gamesField} as percentage FROM {$playerstable} WHERE {$gamesField} >= 1 AND approved = 'yes' ORDER BY {$sortby}, {$gamesField} ASC LIMIT 0, 10";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
$compteur = 1;
$col = "color:#555555";
while (10 >= $compteur) {
    $row = mysql_fetch_array($result);
    if (!empty($row["nationality"])) {
        $nationality = $row["nationality"];
    } else {
        $nationality = 'No country';