Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = '';
- $dbselect = 'torg';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass);
- if(! $conn )
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db($dbselect) or die(mysql_error());
- ///////////////////
- //Caly jebany kod//
- ///////////////////
- $result = mysql_query("SELECT * FROM torgrating ORDER BY id DESC LIMIT 1")
- or die(mysql_error());
- $row = mysql_fetch_array( $result );
- $ostatnieid = $row['id'];
- ///////////////////////////////
- //Sciagniecie danych ze stron//
- ///////////////////////////////
- function getTime()
- {
- $a = explode (' ',microtime());
- return(double) $a[0] + $a[1];
- }
- $id=1;
- $totaltime = 0;
- function vBulletinLogin($username,$password,$url,$posturl)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HEADER,false);
- curl_setopt($ch, CURLOPT_COOKIEFILE, 'veri.txt');
- curl_setopt($ch, CURLOPT_COOKIEJAR, 'veri.txt');
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch, CURLOPT_COOKIESESSION,true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
- curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
- curl_setopt($ch, CURLOPT_REFERER, $url.'index.php');
- curl_setopt($ch, CURLOPT_URL, $url.'login.php?do=login');
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "vb_login_username=$username&vb_login_password&s=&securitytoken=guest&do=login&vb_login_md5password=".md5($password)."&vb_login_md5password_utf=".md5($password));
- $exec = curl_exec($ch);
- curl_setopt($ch, CURLOPT_POST, 0);
- curl_setopt($ch, CURLOPT_REFERER, $url.'login.php?do=login');
- curl_setopt($ch, CURLOPT_URL, $url.'clientscript/vbulletin_global.js?v=373');
- $exec = curl_exec($ch);
- curl_setopt($ch, CURLOPT_REFERER, $url.'login.php?do=login');
- curl_setopt($ch, CURLOPT_URL, $url.'index.php');
- $exec = curl_exec($ch);
- curl_setopt($ch, CURLOPT_REFERER, $url.'index.php');
- curl_setopt($ch, CURLOPT_URL, $posturl);
- $exec = curl_exec($ch);
- return $exec;
- }
- while ($ostatnieid+1>$id)
- {
- $Start = getTime();
- $query = mysql_fetch_array( mysql_query( "SELECT `linktorg`,`serwer`,`summonerId` FROM `torgrating` WHERE `id` = '$id' "));
- $linktorg = $query['linktorg'];
- $serwer = $query['serwer'];
- $summonerId = $query['summonerId'];
- $try = 0;
- while ($try < 4)
- {
- if($serwer == "euw")
- {
- $strona = @file_get_contents('https://euw.api.pvp.net/api/lol/'."$serwer".'/v2.5/league/by-summoner/'."$summonerId".'/entry?api_key=2bd7ccc9-66d4-4aba-9b54-3caa6d917ce6');
- }
- else
- {
- $strona = @file_get_contents('https://eune.api.pvp.net/api/lol/'."$serwer".'/v2.5/league/by-summoner/'."$summonerId".'/entry?api_key=2bd7ccc9-66d4-4aba-9b54-3caa6d917ce6');
- }
- if (!$strona)
- {
- $status = '<font color="red">error</font>';
- $try++;
- sleep(1);
- }
- else
- {
- $status = '<font color="green">Ok</font>';
- $try = 4;
- sleep(1);
- }
- }
- //nick
- preg_match('#"'."$summonerId".'","playerOrTeamName":"(.*?)"#s', $strona, $wynik);
- $lolnick = "$wynik[1]";
- //dywizja
- preg_match('#"tier":"(.*?)","queue":"RANKED_SOLO_5x5",#s', $strona, $wynik);
- $tier = "$wynik[1]";
- preg_match('#playerOrTeamName":"'."$lolnick".'","division":"(.*?)",#s', $strona, $wynik);
- $rank = "$wynik[1]";
- //score
- preg_match('#playerOrTeamName":"'."$lolnick".'","division":"'."$rank".'","leaguePoints":(.*?),#s', $strona, $wynik);
- $score = "$wynik[1]";
- //torgowe gowno
- //////////////////////
- //Logowanie na torga//
- //////////////////////
- $cusername = 'kupsztal';
- $cpassword = 'gowno123';
- $cloginUrl = 'http://torg.pl/';
- $cookie = "cookie.txt";
- $strona = vBulletinLogin($cusername,$cpassword,$cloginUrl,$linktorg);
- preg_match('#<span class="member_username">(.*?)</span>#s', $strona, $wynik);
- $nickztorga = trim(strip_tags($wynik[0]));
- if ($tier == "CHALLENGER")
- {
- $tier = "Challenger";
- }
- else if ($tier == "MASTER")
- {
- $tier = "Master";
- }
- else if ($tier == "DIAMOND")
- {
- $tier = "Diamond";
- }
- else if ($tier == "PLATINUM")
- {
- $tier = "Platinum";
- }
- else if ($tier == "GOLD")
- {
- $tier = "Gold";
- }
- else if ($tier == "SILVER")
- {
- $tier = "Silver";
- }
- else if ($tier == "BRONZE")
- {
- $tier = "Bronze";
- }
- $dywizja = $tier." ".$rank;
- $nicktorg = mysql_real_escape_string($nickztorga);
- $End = getTime();
- $czas1 = number_format(($End - $Start),2);
- mysql_query("UPDATE `torgrating` SET `score` = '$score' , `lolnick` = '$lolnick' , `dywizja` = '$dywizja' , `nicktorg` = '$nicktorg' WHERE `id` = '$id' ");
- $id++;
- if ($czas1 < 2)
- {
- sleep(2.1 - $czas1);
- }
- }
- ?>
- <meta HTTP-EQUIV="Refresh" CONTENT="0; URL=rankingtorga.php">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement