/
processing.php
73 lines (56 loc) · 3.28 KB
/
processing.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/*
**********************************************************************
Take the following two lines out when we push this to production!!!
**********************************************************************
*/
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
include 'jsonHelper.php';
$user = htmlspecialchars($_POST['user']);
$duoPartner = htmlspecialchars($_POST['duoPartner']);
$region = $_POST['region'];
define("regionUrl", "https://" . $region . ".api.pvp.net/api/lol/" . $region);
$userId = getSummonerId($user);
$duoPartnerId = ($duoPartner != "") ? getSummonerId($duoPartner) : "";
//Processing result
if($userId != 'N/A' && $duoPartnerId != 'N/A' && authenticateRegion($region)) {
echo "<br><div class='results-card card-margin'><h1 class='align-center'><b><span id='light-title'>Solo</span> " . $user . "</b></h1>";
//Gets user's match list using jsonHelper
$userMatchList = getMatchList($userId);
$matchCount = 50;
$arrayOfMatchData = individualMatchData($matchCount, $userMatchList, $userId, $duoPartnerId);
$numberOfSoloGames = $arrayOfMatchData[$matchCount-1]["numberOfSoloGames"];
$soloWinLostArray = MatchesWon($arrayOfMatchData, $matchCount, true);
$soloWins = $soloWinLostArray["gamesWon"];
$soloLosses = $soloWinLostArray["gamesLost"];
$soloWinRate = calculateWinrate($soloWins, $numberOfSoloGames);
$winRateColor = winRateColor($soloWinRate);
echo "<h2>Wins: <span class='won-message'>" . $soloWins . "</span> Losses: <span class='lost-message'>"
. $soloLosses . "</span></h2>";
echo "<h1>Solo winrate: <span id='" . $winRateColor . "'>" . $soloWinRate . "%</span></h1></div>";
echo "<div class='results-card card-margin'>";
if ($duoPartner != "")
echo "<h1 id='align-center'><span id='light-title'>Duo with</span><b> " . $duoPartner . "</h1></b>";
else
echo "<h1 class='align-center'><span id='light-title'>No duo partner specified</h1></b>";
$duoWinLostArray = MatchesWon($arrayOfMatchData, $matchCount, false);
$numberOfDuoGames = $matchCount - $numberOfSoloGames;
$duoWins = $duoWinLostArray["gamesWon"];
$duoLosses = $duoWinLostArray["gamesLost"];
$duoWinRate = calculateWinrate($duoWins, $numberOfDuoGames);
$winRateColor = winRateColor($duoWinRate);
echo "<h2>Wins: <span class='won-message'>" . $duoWins . "</span> Losses: <span class='lost-message'>"
. $duoLosses . "</span></h2>";
echo "<h1>Duo winrate: <span id='" . $winRateColor . "'>" . $duoWinRate . "%</span></h1></div>";
echo "</div>";
}
else {
$pictureFilePath = "css/img/ErrorAmumu.png";
$img = '<img id="errorAmumu" src="' . $pictureFilePath . '">';
echo "<div class='container'><div class='starter-template'><div class='start-card'>";
echo "<h2 class='align-center'>Uh Oh</h2>";
echo "<div>" . $img . "</div>";
echo "<h3>There was an error in your submission. Try again.<h3>";
echo "</div></div></div>";
}