$page = "report"; require('variables.php'); require('variablesdb.php'); require('top.php'); ?>
Report.
$date = date("M d, Y"); if ($_POST[submit]) { if ($report == "winner") { $reportname = "$_POST[winnername]"; } else { $reportname = "$_POST[losername]"; } $sql="SELECT * FROM $playerstable WHERE name = '$reportname'"; $result=mysql_query($sql,$db); $row = mysql_fetch_array($result); if ($row[passworddb] == "$_POST[passworduser]") { $sql="SELECT * FROM $gamestable WHERE winner = '$_POST[winnername]' and loser = '$_POST[losername]' and date = '$date'"; $result=mysql_query($sql,$db); $oneway = mysql_num_rows($result); $sql="SELECT * FROM $gamestable WHERE winner = '$_POST[losername]' and loser = '$_POST[winnername]' and date = '$date'"; $result=mysql_query($sql,$db); $otherway = mysql_num_rows($result); $num = $oneway + $otherway; if ($num < $gamesmaxdayplayer) { if ($_POST[winnername] == $_POST[losername]) { echo "You can't play against yourself."; }else{ if ($approvegames != "yes") { $sql="SELECT * FROM $playerstable WHERE name = '$_POST[winnername]'"; $result=mysql_query($sql,$db); $row = mysql_fetch_array($result); $ratingoldwinner = $row["rating"]; $rankoldwinner = $row["rank"]; $sql="SELECT * FROM $playerstable WHERE name = '$_POST[losername]'"; $result=mysql_query($sql,$db); $row = mysql_fetch_array($result); $ratingoldloser = $row["rating"]; $rankoldloser = $row["rank"]; $constant = 32; $rw1 = ratingoldwinner - $ratingoldloser; $rw2 = -$rw1/400; $rw3 = pow(10,$rw2); $rw4 = $rw3 + 1; $rw5 = 1/$rw4; $rw6 = 1 - $rw5; $rw7 = $constant * $rw6; $ratingdifferent = round($rw7); if ($rankoldwinner < 1) { $sql="SELECT * FROM $playerstable ORDER BY rank DESC LIMIT 0,1"; $result=mysql_query($sql,$db); $num = mysql_num_rows($result); $row = mysql_fetch_array($result); $rankoldwinner = $row["rank"]; $rankoldwinner++; } if ($rankoldloser < 1) { $sql="SELECT * FROM $playerstable ORDER BY rank DESC LIMIT 0,1"; $result=mysql_query($sql,$db); $num = mysql_num_rows($result); $row = mysql_fetch_array($result); $rankoldloser = $row["rank"]; $rankoldloser++; } if ($rankoldwinner > $rankoldloser) { $difference = $rankoldwinner - $rankoldloser; $rise = round($difference/2); $ranknewwinner = $rankoldwinner - $rise; $ranknewloser = $rankoldloser; if ($ranknewwinner == $ranknewloser) { $ranknewloser++; } $sql = "UPDATE $playerstable SET rank = rank + 1 WHERE rank > $ranknewwinner - 1 AND rank < $rankoldwinner"; $result = mysql_query($sql); } else if ($rankoldwinner == $rankoldloser) { $ranknewwinner = $rankoldwinner; $ranknewloser = $rankoldloser + 1; } else { $ranknewwinner = $rankoldwinner; $ranknewloser = $rankoldloser; } $sql = "UPDATE $playerstable SET wins = wins, losses = losses + 1, totalwins = totalwins, totallosses = totallosses + 1, points = points + $pointsloss, totalpoints = totalpoints + $pointsloss, games = games + 1, totalgames = totalgames + 1, streakwins = 0, streaklosses = streaklosses + 1, rating = rating - $ratingdifferent, rank = $ranknewloser WHERE name='$_POST[losername]'"; $result = mysql_query($sql); $sql = "UPDATE $playerstable SET wins = wins + 1, losses = losses, totalwins = totalwins + 1, totallosses= totallosses, points = points + $pointswin, totalpoints = totalpoints + $pointswin, games = games + 1, totalgames = totalgames + 1, streakwins = streakwins + 1, streaklosses = 0, rating = rating + $ratingdifferent, rank = $ranknewwinner WHERE name='$_POST[winnername]'"; $result = mysql_query($sql); $sql = "INSERT INTO $gamestable (winner, loser, date, recorded) VALUES ('$_POST[winnername]', '$_POST[losername]', '$date', 'yes')"; $result = mysql_query($sql); } else { $sql = "INSERT INTO $gamestable (winner, loser, date, recorded) VALUES ('$_POST[winnername]', '$_POST[losername]', '$date', 'no')"; $result = mysql_query($sql); } echo "Thank you! Information entered."; } } else { echo "You can't play more than $gamesmaxdayplayer games a day against the same player."; } } else { echo "Incorrect password. Try again."; } } else { ?>
} ?> require('bottom.php'); ?>