-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
133 lines (125 loc) · 6.07 KB
/
search.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
require_once '../config.php';
require_once '../vendor/autoload.php';
$server = $_GET['server'];
$queue = $_GET['queue'];
$league = $_GET['league'];
$role = $_GET['role'];
?>
<div class="container">
<h1>SEARCH</h1>
<div class="row">
<div class="col-xs-12 col-md-4">
<form id="search_input" class="testing new stuff" action="index.php" method="get">
<input type="hidden" name="sida" value="search" />
<label class="search-label" for="server">Server</label>
<select class="form-control" name="server">
<option value="eune" <?php if($server=="eune"){echo "selected";}?> >EUNE</option>
<option value="euw" <?php if($server=="euw"){echo "selected";}?> >EUW</option>
<option value="na" <?php if($server=="na"){echo "selected";}?> >NA</option>
</select>
<label class="search-label" for="league">League</label>
<select class="form-control" name="league">
<option value="DIAMOND" <?php if($league=="DIAMOND"){echo "selected";}?> >Diamond</option>
<option value="PLATINUM" <?php if($league=="PLATINUM"){echo "selected";}?> >Platinum</option>
<option value="GOLD" <?php if($league=="GOLD"){echo "selected";}?> >Gold</option>
<option value="SILVER" <?php if($league=="SILVER"){echo "selected";}?> >Silver</option>
<option value="BRONZE" <?php if($league=="BRONZE"){echo "selected";}?> >Bronze</option>
</select>
<label class="search-label" for="queue">Queue</label>
<select class="form-control" name="queue">
<option value="ranked_solo_5x5" <?php if($queue=="ranked_solo_5x5"){echo "selected";}?> >Ranked Solo (Summoners Rift)</option>
<option value="ranked_flex_sr" <?php if($queue=="ranked_flex_sr"){echo "selected";}?> >Ranked Flex (Summoners Rift)</option>
<option value="ranked_flex_tt" <?php if($queue=="ranked_flex_tt"){echo "selected";}?> >Ranked Flex (Twisted Treeline)</option>
</select>
<label class="search-label" for="mainRole">Main Role</label>
<select class="form-control" name="role">
<option value="top" <?php if($role=="top"){echo "selected";}?> >Top</option>
<option value="jungle" <?php if($role=="jungle"){echo "selected";}?> >Jungle</option>
<option value="mid" <?php if($role=="mid"){echo "selected";}?> >Mid</option>
<option value="adc" <?php if($role=="adc"){echo "selected";}?> >Adc</option>
<option value="support" <?php if($role=="support"){echo "selected";}?> >Support</option>
</select>
<input type="submit" value="Submit" class="btn btn-primary search-button">
</div>
<div class="col-xs-12 col-md-8">
<div id="search_output">
<?php
$sth = $pdo->prepare("
SELECT
league.playerOrTeamId,
league.playerOrTeamName,
league.tier,
league.division,
league.leaguePoints,
league.wins,
league.losses,
stats.id,
stats.totalChampionKills,
stats.totalDeathsPerSession,
stats.totalAssists,
roles.id,
roles.mainRole,
ROUND(100 * stats.totalSessionsWon / (stats.totalSessionsWon + stats.totalSessionsLost)) as 'winPercentage',
ROUND((stats.totalChampionKills + stats.totalAssists) / stats.totalDeathsPerSession, 2) as 'kda'
FROM {$server}_{$queue} league
JOIN {$server}_ranked_stats stats
ON stats.id = league.playerOrTeamId
JOIN {$server}_roles roles
ON roles.id = stats.id
HAVING
league.tier = '$league' AND
roles.mainRole = '$role'
ORDER BY CASE
when league.tier = 'CHALLENGER' then 1
when league.tier = 'MASTER' then 2
when league.tier = 'DIAMOND' then 3
when league.tier = 'PLATINUM' then 4
when league.tier = 'GOLD' then 5
when league.tier = 'SILVER' then 6
when league.tier = 'BRONZE' then 7
End,
league.tier ASC, league.division ASC, league.leaguePoints DESC");
$sth->execute();
if ($row = $sth->rowCount() > 0) {
?>
<table id="table_search" class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th>Summoner</th>
<th>Main</th>
<th>Ranked</th>
<th>Wins/Losses</th>
<th>Win %</th>
</tr>
</thead>
<?php
$rank = 0;
while ($row = $sth->fetch()) {
?>
<tr>
<td><?php echo $rank += 1; ?></td>
<td><a href="http://<?php echo $server ?>.op.gg/summoner/userName=<?php echo $row['playerOrTeamName']; ?>"><?php echo $row['playerOrTeamName']; ?></a></td>
<td><?php echo strtoupper($row['mainRole']); ?></td>
<td><?php echo $row['tier']; ?> <?php echo $row['division']; ?> <span class="lp">(<?php echo $row['leaguePoints']; ?> LP)</span></td>
<td><span class="win"><?php echo $row['wins']; ?></span> / <span class="loss"><?php echo $row['losses']; ?></span></td>
<td><div class="progress"><div class="progress-bar progress-bar-info win_percentage" style="width: <?php echo $row['winPercentage'] ?>%"><?php echo $row['winPercentage'] ?>%</div></div></td>
</tr>
<?php
}
} else {
?>
<div class="jumbotron">
<h1>No players found</h1>
<p>Try changing the search parameters</p>
</div>
<?php
}
?>
</table>
</div>
</div>
</div>
</form>
</div>