-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVarInclude.php
More file actions
120 lines (104 loc) · 4.77 KB
/
Copy pathVarInclude.php
File metadata and controls
120 lines (104 loc) · 4.77 KB
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
<?php
//Include database if not already done so
include_once "Database.php";
//API-KEY
$apiKey = include 'apikey.php';
//Include settings if not already done so
$settings = array();
updateSettings();
//Include Regions, since it is used by most scripts
$regions = query("SELECT `ID`, `Region` FROM regions");
//Check if it is time to fetch new games & fetch 'em
include 'DataProcessor.php';
//cURL
function cURLRequest($link){
//echo "<br />".$link;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
//echo $info['http_code']."<br />";
if($info['http_code'] == 429){
sleep(1);
return cURLRequest($link);
}
if($info['http_code'] != 200){
return "false";
}
return $data;
}
//Score Algorithm. WAAAAAY TOO SIMPLE, F*CKING UP THE WHOLE WEBSITE... IMPERATIVELY CHANGE THIS!!!!! IT MUST BE DONE!! TODO!!
function calcScore($k, $d, $a, $cs, $dragons, $barons, $largestKillingSpree, $wards){
return 30*$k - 50*$d + 22*$a + $cs + 10*$wards + 100*$dragons + 150*$barons + 5*$largestKillingSpree; //Calculate this in a more meaningful way
}
//Update the settings variable.
function updateSettings(){
global $settings, $conn;
$rs = $conn->query("SELECT `Setting`, `Value` FROM Settings;");
$arr = array();
while($row = $rs->fetch_assoc()){
$arr[$row['Setting']] = $row['Value'];
}
$settings = $arr;
}
//Save data for given arguments
function saveGame($participant, $match, $uid, $r){
global $conn;
//Get the gamemode-id (Tables are joined for performance reasons). If the gamemode isnt contained yet in the database table, dont save anything. And add it manually later. Damn.
$gm = query("SELECT id FROM Gamemodes WHERE Gamemode='".$match['queueType']."';");
if(empty($gm)) return;
//Somehow no league data? Don't save anything.
if(empty($participant['highestAchievedSeasonTier'])) return;
//Get all the data!
$team = $participant['teamId'];
$league = $participant['highestAchievedSeasonTier'];// echo $league;
$champ = $participant['championId'];
$sumSpell1 = $participant['spell1Id'];
$sumSpell2 = $participant['spell2Id'];
$ban1 = isset($match['teams'][$team==100?0:1]['bans'][0])?$match['teams'][$team==100?0:1]['bans'][0]['championId']:-1;
$ban2 = isset($match['teams'][$team==100?0:1]['bans'][1])?$match['teams'][$team==100?0:1]['bans'][1]['championId']:-1;
$ban3 = isset($match['teams'][$team==100?0:1]['bans'][2])?$match['teams'][$team==100?0:1]['bans'][2]['championId']:-1;
$item0 = $participant['stats']['item0'];
$item1 = $participant['stats']['item1'];
$item2 = $participant['stats']['item2'];
$item3 = $participant['stats']['item3'];
$item4 = $participant['stats']['item4'];
$item5 = $participant['stats']['item5'];
$wards = $participant['stats']['wardsPlaced'];
$kills = $participant['stats']['kills'];
$deaths = $participant['stats']['deaths'];
$assists = $participant['stats']['assists'];
$gold = $participant['stats']['goldEarned'];
$cs = $participant['stats']['minionsKilled'] + $participant['stats']['neutralMinionsKilled'];
$doubleKills = $participant['stats']['doubleKills'];
$tripleKills = $participant['stats']['tripleKills'];
$quadraKills = $participant['stats']['quadraKills'];
$pentaKills = $participant['stats']['pentaKills'];
$largestKillingSpree = $participant['stats']['largestKillingSpree'];
$dragons = $match['teams'][$team==100?0:1]['dragonKills'];
$barons = $match['teams'][$team==100?0:1]['baronKills'];
$score = calcScore($kills, $deaths, $assists, $cs, $dragons, $barons, $largestKillingSpree, $wards);
//Get the league in which the player is. Same as with gamemode: Performance reasons.
$l = query("SELECT id, League FROM Leagues WHERE League='".$league."';");
//Save that sht
$iq = "REPLACE INTO statistics (MatchId, Region, Gamemode, League, UserId, Score, Ban1, Ban2, Ban3, Pick, Spell1, Spell2, Item0, Item1, Item2, Item3, Item4, Item5, Kills, Deaths, Assists, Wards, Gold, CS, Doubles, Triples, Quadras, Pentas, LargestSpree, Drakes, Barons)"
." VALUES ('"
.$match['matchId']."', '"
.$r['ID']."', '"
.$gm[0]['id']."', '"
.$l[0]['id']."', '".$uid."', '".$score."', '".$ban1."', '".$ban2."', '".$ban3."', '".$champ."', '".$sumSpell1."', '".$sumSpell2."', '".$item0."', '".$item1."', '".$item2."', '".$item3."', '".$item4."', '".$item5."', '".$kills."', '".$deaths."', '".$assists."', '".$wards."', '".$gold."', '".$cs."', '".$doubleKills."', '".$tripleKills."', '".$quadraKills."', '".$pentaKills."', '".$largestKillingSpree."', '".$dragons."', '".$barons."');";
//... And query it! Dude it rhimes
$conn->query($iq);
}
function debug($msg, $var){
echo "-- Message --";
echo "<br />";
echo $msg.": ";
var_dump($var);
echo "<br />";
}
?>