Skip to content

Instantly share code, notes, and snippets.

@Tafonath
Last active April 23, 2017 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tafonath/a135f9e5e47ca16f1d3521b17cadbdb5 to your computer and use it in GitHub Desktop.
Save Tafonath/a135f9e5e47ca16f1d3521b17cadbdb5 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Legendarny ranking torga</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4"><h1>Dodaj gnide</h1></div>
</div>
<form class="form-horizontal" action="" method="post">
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label">Nick na torgu</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="inputEmail3" name="nick_torg" placeholder="Nick na torgu" maxlength="30" required>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-4 control-label">Nick na lidze</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="inputPassword3" name="nick_lol" placeholder="Nick na lidze" maxlength="25" required>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-4 control-label">Serwer</label>
<div class="col-sm-2">
<select class="form-control" name="server">
<option selected>eune</option>
<option>euw</option>
<option>na</option>
<option>tr</option>
<option>ru</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-4">
<button type="submit" class="btn btn-default">Dodaj</button>
</div>
</div>
</form>
</body>
</html>
<?php
require_once('config.php');
// form takes action on same page, so post cant be empty to initialize code
if(!empty($_POST)){
try
{
$DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name};charset=utf8",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// prepare sql and bind parameters
$stmt = $DB_con ->prepare("INSERT INTO players (nick_torg, nick_lol, server, player_id, summonerLevel, tier, division_name, division, leaguePoints, wins, losses)
VALUES (:nick_torg, :nick_lol, :server, :player_id, :summonerLevel, :tier, :division_name, :division, :leaguePoints, :wins, :losses)");
$stmt->bindParam(':nick_torg', $nick_torg);
$stmt->bindParam(':nick_lol', $nick_lol);
$stmt->bindParam(':server', $server);
$stmt->bindParam(':player_id', $player_id);
$stmt->bindParam(':summonerLevel', $summonerLevel);
$stmt->bindParam(':tier', $tier);
$stmt->bindParam(':division_name', $division_name);
$stmt->bindParam(':division', $division);
$stmt->bindParam(':leaguePoints', $leaguePoints);
$stmt->bindParam(':wins', $wins);
$stmt->bindParam(':losses', $losses);
// data from form
$nick_torg = $_POST["nick_torg"];
$nick_lol = $_POST["nick_lol"];
$server = $_POST["server"];
// get id and level, required to get other data
$url = "https://".$server.".api.riotgames.com/api/lol/".strtoupper($server)."/v1.4/summoner/by-name/".str_replace(' ', '_', $nick_lol)."?api_key=".$api_key."";
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Decode to json->arrays
$result = json_decode($result, true);
// set nick to lowercase and strip spaces to get json obj
$nick_lol_lc = mb_strtolower(str_replace(' ', '', $nick_lol), 'UTF-8');
$player_id = $result[$nick_lol_lc]['id'];
$summonerLevel = $result[$nick_lol_lc]['summonerLevel'];
// get rest of data
$url = "https://".$server.".api.riotgames.com/api/lol/".strtoupper($server)."/v2.5/league/by-summoner/".$player_id."/entry?api_key=".$api_key."";
// set new url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
curl_close($ch);
// Decode to json->arrays
$result = json_decode($result, true);
$tier = $result[$player_id][0]['tier'];
$division_name = $result[$player_id][0]['name'];
$division = $result[$player_id][0]['entries'][0]['division'];
$leaguePoints = $result[$player_id][0]['entries'][0]['leaguePoints'];
$wins = $result[$player_id][0]['entries'][0]['wins'];
$losses = $result[$player_id][0]['entries'][0]['losses'];
// insert a row
$stmt->execute();
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
?>
<?php
$DB_host = "localhost";
$DB_user = "root";
$DB_pass = "";
$DB_name = "torg-ranking";
$api_key = "RGAPI-6e141e03-ccb1-45a3-af6a-b4f49ae9a785";
$staff = array(
array("#0000FF", // Blue
"Crus", "Meo", "Mistrzu Dragon", "Xijeg"),
array("#008000", // Green
"Decretis", "Haan", "Nebula", "piccolo", "Vadim", "zakius"),
array("#FF0000", // Red
"Grimekk", "Przemo", "Rafix"),
array("#8B4513", // Brown
"2Fast4You", "Aboroth", "Aien", "Ald", "Andaryel", "Apode", "Aqualek", "Astinus", "Avarion", "Azazel", "bikstopa", "Bobek", "Boryna", "Burian", "Celestian hunter", "Cybuch", "darkan", "Deep", "DoDo", "Don Corleone", "Dzid", "Ene", "Exploodeex", "Faweziw", "Fejfer", "flo", "Freon", "Gollum", "Gray", "Halius", "Honestus", "jacket", "Jerem", "JoGi86", "Kalarepa", "Killavus", "Kiveev", "Korzeń", "kuba", "Lerek", "Mandarke", "Masaker", "Messer", "Miczel", "Minsafo", "Neels", "Nethar", "ogf-carl", "Omen", "Palladni", "paweł", "Pejot", "Pekezu", "Pluton", "Pox", "ProEda", "Pushek", "Radgos", "raweks", "Remios", "Robson", "Shaft", "shineq", "Silnikos", "smakosz", "Takeya", "test_user", "Tomix", "Trickhor", "vax", "Woju", "xerax", "Xolo", "Yenio", "zaghi", "ZinC "),
array("#FFB845", // Yellow
"alien", "Archarius", "Klos", "spleen")
);
?>
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Czas generowania: 23 Kwi 2017, 01:03
-- Wersja serwera: 10.1.21-MariaDB
-- Wersja PHP: 7.1.1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Baza danych: `torg-ranking`
--
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `players`
--
CREATE TABLE `players` (
`nick_torg` text CHARACTER SET utf8 NOT NULL,
`nick_lol` text CHARACTER SET utf8 NOT NULL,
`server` text CHARACTER SET utf8 NOT NULL,
`player_id` int(11) NOT NULL,
`summonerLevel` int(11) NOT NULL,
`tier` text CHARACTER SET utf8 NOT NULL,
`division_name` text CHARACTER SET utf8 NOT NULL,
`division` text CHARACTER SET utf8 NOT NULL,
`leaguePoints` int(11) NOT NULL,
`wins` int(11) NOT NULL,
`losses` int(11) NOT NULL,
`id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Zrzut danych tabeli `players`
--
INSERT INTO `players` (`nick_torg`, `nick_lol`, `server`, `player_id`, `summonerLevel`, `tier`, `division_name`, `division`, `leaguePoints`, `wins`, `losses`, `id`) VALUES
('kubsar', 'KTL Kubsar', 'eune', 39738916, 30, 'DIAMOND', 'Ezreal\'s Sheriffs', 'II', 25, 150, 130, 1),
('Arhatan', 'Tabasko', 'euw', 19670314, 30, 'MASTER', 'Zilean\'s Urfriders', 'I', 250, 339, 307, 2),
('Sebiq', 'SEBIQQQQQQQQQQQQ', 'eune', 20839779, 30, 'DIAMOND', 'Soraka\'s Urfriders', 'I', 52, 136, 116, 3),
('Meo', 'Mr Meo', 'eune', 38347535, 30, 'DIAMOND', 'Soraka\'s Urfriders', 'III', 80, 167, 165, 4),
('Carian', 'Carian', 'eune', 39903824, 30, 'DIAMOND', 'Rumble\'s Wardens', 'III', 0, 117, 113, 5),
('pitotrek1997', 'Pray4Tryndamere', 'eune', 28893056, 30, 'DIAMOND', 'LeBlanc\'s Brutes', 'III', 81, 157, 156, 6),
('Arktos', 'Arktoz', 'eune', 21497380, 30, 'DIAMOND', 'Sejuani\'s Iceborn', 'IV', 19, 212, 197, 7),
('Lord Xivan', 'Xivan', 'eune', 31507864, 30, 'PLATINUM', 'Vayne\'s Butchers', 'IV', 75, 66, 75, 8),
('LizZy', 'ZD Danielq', 'eune', 24302887, 30, 'PLATINUM', 'Ashe\'s Heralds', 'II', 75, 228, 251, 9),
('rycekrox21', 'Wizak', 'eune', 28664746, 30, 'DIAMOND', 'Lux\'s Spellbreakers', 'I', 0, 68, 46, 10),
('Nervarien', 'NERVARlEN', 'eune', 45837593, 30, 'CHALLENGER', 'Urgot\'s Patriots', 'I', 539, 112, 82, 11),
('Mistrzu Dragon', 'lvl9squirtle', 'eune', 45966466, 30, 'DIAMOND', 'Galio\'s Brutes', 'I', 72, 34, 14, 12),
('tsude', 'j0nsy', 'eune', 33273317, 30, 'DIAMOND', 'Nidalee\'s Oracles', 'V', 57, 100, 105, 13),
('Radgos', 'Jack Boba', 'eune', 20864827, 30, 'PLATINUM', 'Vayne\'s Butchers', 'III', 62, 167, 172, 14),
('RaZoR', 'Eldred', 'eune', 19839165, 30, 'PLATINUM', 'Vayne\'s Butchers', 'II', 69, 143, 159, 15),
('woturn', 'Laissez Faire', 'eune', 24515932, 30, 'DIAMOND', 'Elise\'s Masterminds', 'IV', 9, 261, 263, 16),
('evelay', 'top201eukebab', 'eune', 34023216, 30, 'PLATINUM', 'Vayne\'s Butchers', 'II', 37, 41, 54, 17),
('matizioom', 'Dr D2RE', 'eune', 34323152, 30, 'PLATINUM', 'Vayne\'s Butchers', 'II', 93, 33, 35, 18),
('Mezuren', 'Mezuren', 'eune', 21872022, 30, 'PLATINUM', 'Vayne\'s Butchers', 'I', 0, 51, 60, 19),
('Mentoll', 'Marcin DZK', 'eune', 23453113, 30, 'PLATINUM', 'Jax\'s Oracles', 'II', 0, 119, 140, 20),
('Dandrok Shadow', 'R3dz0r', 'euw', 20611297, 30, 'GOLD', 'Olaf\'s Justicars', 'I', 75, 6, 14, 21),
('VeryL', 'top cute', 'eune', 19872945, 30, 'PLATINUM', 'Vayne\'s Butchers', 'IV', 40, 163, 187, 22),
('Dark Hunter', 'Tesmilon', 'eune', 33000622, 30, 'DIAMOND', 'Graves\'s Captains', 'V', 16, 53, 49, 23),
('Filia the Dragon', 'Aerionix', 'eune', 34456883, 30, 'PLATINUM', 'Vayne\'s Butchers', 'III', 48, 19, 21, 24),
('Pawelek212', 'Aranaktu', 'eune', 29171798, 30, 'DIAMOND', 'Sejuani\'s Captains', 'IV', 29, 67, 49, 25),
('GaryTroy', 'Madragor', 'euw', 19899933, 30, 'GOLD', 'Akali\'s Blades', 'I', 58, 107, 129, 26),
('Devil\'ek', 'the Tilt', 'eune', 24408311, 30, 'PLATINUM', 'Vayne\'s Butchers', 'IV', 100, 24, 32, 27),
('Shany', 'MIKUS 10TH DAN', 'eune', 38276412, 30, 'PLATINUM', 'Vayne\'s Butchers', 'II', 5, 66, 49, 28),
('jodlak', 'Call Me Jodla', 'eune', 22125993, 30, 'PLATINUM', 'Volibear\'s Blades', 'II', 32, 25, 24, 29),
('Szafus', 'rMckay', 'eune', 48153259, 30, 'DIAMOND', 'Shen\'s Deceivers', 'V', 16, 80, 79, 30),
('dright', 'jacai', 'euw', 52503180, 30, 'DIAMOND', 'Kassadin\'s Blightlords', 'V', 0, 146, 152, 31),
('Stepcio95', 'nayaranny', 'eune', 23921826, 30, 'PLATINUM', 'Renekton\'s Enforcers', 'II', 47, 206, 187, 32),
('Aquzlies', 'nslevin', 'eune', 30343013, 30, 'GOLD', 'Cho\'Gath\'s Weaponmasters', 'I', 75, 9, 5, 33),
('Taca', 'KoooKooo', 'euw', 44249246, 30, 'GOLD', 'Nami\'s Privateers', 'II', 75, 164, 175, 34),
('Niebo Było Czarne', 'Himlen Blev Sort', 'eune', 23260005, 30, 'PLATINUM', 'Tryndamere\'s Zealots', 'III', 100, 217, 234, 35),
('LubiePlacki', 'God Help ADC', 'eune', 24605114, 30, 'PLATINUM', 'Galio\'s Sorcerers', 'II', 21, 96, 78, 36),
('Nosikamyk', 'Kamyck', 'eune', 23921915, 30, 'PLATINUM', 'Vayne\'s Butchers', 'II', 39, 63, 55, 37),
('Kobra1253', 'Ipomme', 'eune', 20890129, 30, 'GOLD', 'Karthus\'s Masterminds', 'I', 60, 6, 7, 38),
('Changuzza', 'Spoderman', 'eune', 20976756, 30, 'DIAMOND', 'Anivia\'s Dervish', 'V', 12, 128, 119, 39),
('durel', 'H5F IronWeed', 'eune', 27065363, 30, 'PLATINUM', 'Taric\'s Commandos', 'IV', 40, 48, 44, 40),
('Elaiden', 'Elaideη', 'eune', 42357982, 30, 'DIAMOND', 'Brand\'s Legion', 'V', 38, 113, 103, 41),
('Gruby', 'Danos v2', 'eune', 19810097, 30, 'PLATINUM', 'Viktor\'s Outriders', 'II', 92, 88, 67, 42),
('Gaba', 'One Man Legion', 'eune', 21760560, 30, 'GOLD', 'Katarina\'s Army', 'II', 52, 7, 6, 43),
('FoX-x', 'Foxek', 'eune', 20197306, 30, 'PLATINUM', 'Vayne\'s Butchers', 'II', 0, 96, 87, 44),
('kisiel', 'Ounhulo', 'euw', 29510368, 30, 'GOLD', 'Fizz\'s Zealots', 'II', 0, 14, 19, 45),
('Deziom', 'Thomaszewsky', 'eune', 20416327, 30, 'PLATINUM', 'Vayne\'s Butchers', 'IV', 46, 362, 345, 46),
('Thaz', 'Potockyy', 'eune', 26445502, 30, 'PLATINUM', 'Vayne\'s Butchers', 'III', 24, 113, 101, 47),
('>>Krzy25<<', 'novviko', 'eune', 31817026, 30, 'GOLD', 'Malphite\'s Giants', 'I', 31, 30, 25, 48),
('Radziu', 'Cohanec', 'eune', 26919489, 30, 'GOLD', 'Syndra\'s Warmongers', 'III', 14, 127, 139, 49),
('MikalCronin', 'Rhys Webb', 'eune', 35023711, 30, 'GOLD', 'Rammus\'s Spellbreakers', 'I', 25, 37, 25, 50),
('Aureos', 'Alden', 'eune', 24452659, 30, 'GOLD', 'Yorick\'s Commanders', 'III', 17, 65, 82, 51),
('orjannilsen1', 'Hard Driv3r', 'eune', 34058237, 30, 'GOLD', 'Blitzcrank\'s Dervish', 'V', 38, 32, 50, 52),
('Lanca', 'accualy iz gooby', 'eune', 24019064, 30, 'PLATINUM', 'Vayne\'s Butchers', 'V', 23, 91, 88, 53),
('Moveric', 'AnaI Sasquatch', 'eune', 24600502, 30, 'GOLD', 'Kayle\'s Knights', 'II', 14, 108, 115, 54),
('Kyouraku', 'Kyouraku san', 'eune', 22258136, 30, 'GOLD', 'Brand\'s Spellswords', 'III', 19, 62, 57, 55),
('Adrino', 'Adrino', 'eune', 348639, 30, 'PLATINUM', 'Diana\'s Urfriders', 'V', 0, 119, 107, 56),
('Hibo', 'DEMON PIEKNOSCI', 'eune', 46687237, 30, 'GOLD', 'Teemo\'s Spellbreakers', 'III', 73, 45, 51, 57),
('zizou', 'zizou', 'eune', 34805002, 30, 'PLATINUM', 'Zed\'s Infiltrators', 'V', 13, 275, 280, 58),
('Zodiakk', 'JebacCieDoDupy', 'euw', 23904261, 30, 'PLATINUM', 'Elise\'s Legion', 'II', 0, 45, 35, 59),
('..::Danielek::..', 'Werewolfix', 'eune', 26937070, 30, 'GOLD', 'Katarina\'s Army', 'IV', 93, 69, 76, 60),
('MacTavish', 'Pejłil', 'eune', 23868801, 30, 'GOLD', 'Syndra\'s Warriors', 'I', 75, 82, 60, 61),
('EK from Azura', 'Melvar', 'eune', 24400280, 30, 'GOLD', 'Elise\'s Captains', 'V', 73, 49, 44, 62),
('Fivechełm', 'Boski Alvaro', 'eune', 28080832, 30, 'GOLD', 'Zilean\'s Demolishers', 'V', 0, 60, 71, 63),
('Serllo', 'ayachuyasca', 'eune', 40733696, 30, 'GOLD', 'Miss Fortune\'s Cutthroats', 'V', 27, 14, 13, 64),
('Egi', 'Shemsi', 'eune', 33444348, 30, 'GOLD', 'Fiddlesticks\'s Shadowdancers', 'V', 36, 49, 59, 65),
('Dzzej', 'Dzzej', 'eune', 31574887, 30, 'SILVER', 'Maokai\'s Marauders', 'I', 71, 21, 19, 66),
('Misiekrazdwatrzy', 'Aratesso', 'eune', 29918528, 30, 'PLATINUM', 'Ahri\'s Warriors', 'V', 5, 154, 159, 67),
('E.R', 'krul wekarjus', 'eune', 19365113, 30, 'PLATINUM', 'Vayne\'s Butchers', 'IV', 100, 86, 72, 68),
('Endryu', 'Endryuzwa', 'eune', 37443914, 30, 'SILVER', 'Darius\'s Blackguards', 'I', 39, 10, 15, 69),
('Dzid', 'The Libertines', 'eune', 34735402, 30, 'GOLD', 'Volibear\'s Host', 'V', 6, 22, 28, 70),
('Hotarti', 'Hotarti', 'eune', 29597378, 30, 'PLATINUM', 'Vayne\'s Butchers', 'V', 18, 113, 109, 71),
('Oryks', 'Oryksio', 'eune', 26036336, 30, 'GOLD', 'Gragas\'s Runemasters', 'III', 0, 111, 116, 72),
('Rassori', 'Rassori', 'eune', 22680574, 30, 'SILVER', 'Karthus\'s Berserkers', 'I', 16, 61, 68, 73),
('Toxic', 'Kiryuuin', 'eune', 36794542, 30, 'SILVER', 'Ezreal\'s Shadehunters', 'I', 0, 23, 31, 74),
('Tyren', 'Tyren', 'eune', 35100555, 30, 'GOLD', 'Volibear\'s Witch Hunters', 'II', 0, 32, 21, 75),
('maselkolubie', 'K5 Prophet', 'eune', 22669566, 30, 'GOLD', 'Zed\'s Mercenaries', 'IV', 32, 98, 108, 76),
('Blubby', 'DawajNaDensflor', 'eune', 36473412, 30, 'GOLD', 'Ziggs\'s Spellswords', 'IV', 98, 79, 67, 77),
('Kmati', 'RadosnyWiking', 'eune', 20278455, 30, 'GOLD', 'Vi\'s Duelists', 'V', 0, 48, 56, 78),
('beny', 'blyzgajacy', 'eune', 30458048, 30, 'GOLD', 'Nami\'s Commanders', 'V', 50, 31, 33, 79),
('Chaku', 'Flaiga', 'eune', 45434128, 30, 'PLATINUM', 'Darius\'s Brood', 'V', 33, 216, 208, 80),
('Archangels', 'Rudy Przegryw', 'eune', 24658620, 30, 'PLATINUM', 'Zed\'s Infiltrators', 'V', 0, 182, 182, 81),
('Nextpro', 'Kierowca Czolgu', 'eune', 35480398, 30, 'GOLD', 'Soraka\'s Liberators', 'II', 78, 97, 83, 82),
('Xeanix', 'Dwukropek Fał', 'eune', 26297936, 30, 'GOLD', 'Caitlyn\'s Enforcers', 'IV', 20, 160, 154, 83),
('Rikimaru Uh', 'TwieIV', 'eune', 25578965, 30, 'PLATINUM', 'Renekton\'s Enforcers', 'V', 46, 73, 59, 84),
('Wenzel', 'Pyszny Stolec', 'eune', 26558679, 30, 'GOLD', 'Ezreal\'s Giants', 'V', 57, 153, 169, 85),
('MiRO', 'ZbieramNaTrynde', 'eune', 28919450, 30, 'SILVER', 'Draven\'s Dreadborne', 'III', 86, 17, 13, 86),
('ejj_ ', 'Feelhip', 'eune', 38001434, 30, 'GOLD', 'Nidalee\'s Highborn', 'IV', 15, 157, 153, 87),
('FearO', 'fearo01', 'eune', 33858848, 30, 'GOLD', 'Shen\'s Infiltrators', 'V', 100, 61, 57, 88),
('Zapomnialem', 'Yavk', 'eune', 22459441, 30, 'SILVER', 'Zed\'s Enlightened', 'I', 20, 117, 120, 89),
('Lyszczu', 'Butch Queen', 'eune', 23194188, 30, 'SILVER', 'Nunu\'s Masterminds', 'III', 0, 3, 12, 90),
('Mortress', 'Riffkiller', 'eune', 35062884, 30, 'SILVER', 'Urgot\'s Shadows', 'IV', 37, 20, 29, 91),
('Mazakowaty Flamaster ', 'SKT T1 SaiyajiN', 'euw', 73307267, 30, 'SILVER', 'Twitch\'s Wizards', 'II', 39, 42, 51, 92),
('dargonn', 'Czoopakabra', 'eune', 25821901, 30, 'SILVER', 'Ryze\'s Lancers', 'IV', 100, 18, 14, 93),
('X_ShinKe_X', 'Shinkex', 'eune', 28879582, 30, 'SILVER', 'Caitlyn\'s Zealots', 'IV', 35, 16, 34, 94),
('Merinksban', 'merinks', 'eune', 24006388, 30, 'SILVER', 'Maokai\'s Captains', 'I', 33, 51, 52, 95),
('Delek', 'Delek04', 'eune', 35763884, 30, 'GOLD', 'Gragas\'s Giants', 'I', 53, 82, 59, 96),
('Feronek', 'Bulwa Gwozdek', 'eune', 31230639, 30, 'SILVER', 'Corki\'s Snipers', 'V', 94, 13, 15, 97),
('Razjel', 'Irfirin', 'eune', 27555204, 30, 'GOLD', 'Teemo\'s Scions', 'IV', 31, 218, 223, 98),
('Byczek', 'Bakuzz', 'eune', 23949583, 30, 'SILVER', 'Lux\'s Runemasters', 'II', 0, 72, 67, 99),
('Givo', 'Givo1', 'eune', 30483554, 30, 'SILVER', 'Rammus\'s Weaponmasters', 'V', 75, 134, 158, 100),
('MaNu', '420 Unlucky Manu', 'eune', 25196373, 30, 'SILVER', 'Blitzcrank\'s Host', 'II', 1, 75, 73, 101),
('Remios', 'DabekPL', 'eune', 20658207, 30, 'SILVER', 'Wukong\'s Dragons', 'V', 0, 5, 6, 102),
('Dominik905', 'Autumnlove ', 'eune', 34395886, 30, 'SILVER', 'Warwick\'s Brutes', 'V', 0, 54, 68, 103),
('Zulfisek', 'Geoffrey', 'eune', 36384231, 30, 'BRONZE', 'Volibear\'s Commandos', 'II', 37, 97, 110, 104),
('Szulerski Majsiek', 'Cmentarny Szczaw', 'eune', 20983931, 30, 'BRONZE', 'Sejuani\'s Snipers', 'III', 26, 11, 21, 105),
('zakius', 'Mornaq', 'eune', 36059070, 30, 'BRONZE', 'Galio\'s Phantoms', 'III', 24, 24, 25, 106),
('jankiel7', 'Wczorajsza Zupa', 'eune', 30453106, 30, 'SILVER', 'Vayne\'s Warlords', 'IV', 0, 130, 111, 107);
--
-- Indeksy dla zrzutów tabel
--
--
-- Indexes for table `players`
--
ALTER TABLE `players`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT dla tabeli `players`
--
ALTER TABLE `players`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=108;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Legendarny ranking torga</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css">
<style type="text/css">
.center-text{
text-align: center;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
</head>
<body>
<div class="row">
<div class="col-md-4 col-md-offset-4"><h1 class="center-text">Legendarny ranking Torga</h1></div>
</div>
<!-- <div class="row">
<div class="col-md-4 col-md-offset-4"><h3 class="center-text">Ostatni refresh: <?php echo date("j-m-y, H:i:s")?></h3></div>
</div> -->
<div class="row">
<div class="col-md-8 col-md-offset-2">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th>Nick na torgu</th>
<th>Nick na lidze</th>
<th>Serwer</th>
<th>Dywizja</th>
<th>LP</th>
<th>Win ratio</th>
<th>Profil</th>
</tr>
</thead>
<tbody>
<?php
require_once('config.php');
$DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name};charset=utf8",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $DB_con->prepare("SELECT * FROM players ORDER BY FIELD(tier,'CHALLENGER', 'MASTER', 'DIAMOND', 'PLATINUM', 'GOLD', 'SILVER', 'BRONZE'), division, leaguePoints DESC");
$result->execute();
$x = 1;
while ($row = $result->fetch(PDO::FETCH_ASSOC))
{
echo '<tr>';
echo '<th scope="row">'.$x.'</th>';
$found = false;
for ($i=0; $i < count ($staff); $i++) {
if (in_array($row['nick_torg'], $staff[$i])) {
echo '<td style="color:'.$staff[$i][0].'">'.$row['nick_torg'].'</td>';
$found = true;
break;
}
}
if(!$found){
echo '<td>'.$row['nick_torg'].'</td>';
}
echo '<td>'.$row['nick_lol'].'</td>';
echo '<td>'.$row['server'].'</td>';
echo '<td>'.ucfirst(strtolower($row['tier'])).' '.$row['division'].'</td>';
echo '<td>'.$row['leaguePoints'].'</td>';
echo '<td>'.number_format(($row['wins']/($row['wins']+$row['losses'])*100),2).'%</td>';
echo '<td><a href="https://'.$row['server'].'.op.gg/summoner/userName='.$row['nick_lol'].'">op.gg</a> <a href="http://www.lolking.net/summoner/'.$row['server'].'/'.$row['player_id'].'/'.$row['nick_lol'].'">lolking</a></td>';
echo '</tr>';
$x++;
}
?>
</tbody>
</table>
</div>
</div>
</body>
</html>
<?php
require_once('config.php');
ini_set('max_execution_time', 0);
//10 request per 10 sec only
$uT = microtime(true);
$count = 1;
try{
$DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name};charset=utf8",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo_result = $DB_con->prepare("SELECT * FROM players ORDER BY id");
$pdo_result->execute();
while ($row = $pdo_result->fetch(PDO::FETCH_ASSOC))
{
$nick_lol = $row['nick_lol'];
$server = $row['server'];
$player_id = $row['player_id'];
$id = $row['id'];
// prepare sql and bind parameters
$stmt = $DB_con ->prepare("UPDATE players SET nick_lol = :nick_lol, tier = :tier, division_name = :division_name, division = :division, leaguePoints = :leaguePoints, wins = :wins, losses = :losses WHERE id = :id");
$stmt->bindParam(':nick_lol', $nick_lol);
$stmt->bindParam(':tier', $tier);
$stmt->bindParam(':division_name', $division_name);
$stmt->bindParam(':division', $division);
$stmt->bindParam(':leaguePoints', $leaguePoints);
$stmt->bindParam(':wins', $wins);
$stmt->bindParam(':losses', $losses);
$stmt->bindParam(':id', $id);
// get rest of data
$url = "https://".$server.".api.riotgames.com/api/lol/".strtoupper($server)."/v2.5/league/by-summoner/".$player_id."/entry?api_key=".$api_key."";
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Decode to json->arrays
$result = json_decode($result, true);
$tier = $result[$player_id][0]['tier'];
$division_name = $result[$player_id][0]['name'];
$division = $result[$player_id][0]['entries'][0]['division'];
$leaguePoints = $result[$player_id][0]['entries'][0]['leaguePoints'];
$nick_lol = $result[$player_id][0]['entries'][0]['playerOrTeamName'];
$wins = $result[$player_id][0]['entries'][0]['wins'];
$losses = $result[$player_id][0]['entries'][0]['losses'];
// update record
$stmt->execute();
//10 request per 10 sec only
if($count == 10){
if( microtime(true) - $uT < 10)
usleep((11-(microtime(true)-$uT))*1E6);
$uT = microtime(true);
$count = 1;
}
else{
$count++;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment