bloor

games_players.php

May 26th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. <?php
  2.     function extractData($t) {
  3.         // Uncompress Data
  4.         $t = gzuncompress($t);
  5.    
  6.         // Get Position of Cols/Rows
  7.         $s1 = strpos($t, '*') + 1;
  8.         $s2 = strpos($t, '*', $s1);
  9.    
  10.         // Extract Cols/Rows
  11.         $rows = substr($t, 0, $s1-1);
  12.         $cols = substr($t, $s1, $s2-$s1);
  13.    
  14.         // Extract Data
  15.         $c = $s2 + 1;
  16.         for($i = 0; $i < $rows; $i++) {
  17.             for($x = 0; $x < $cols; $x++) {
  18.                 $n = strpos($t, ':', $c);
  19.                 $len = substr($t, $c, $n - $c);
  20.    
  21.                 $data[$i][$x] = substr($t, $n + 1, $len);
  22.                 $c = $n + $len + 1;
  23.             }
  24.         }
  25.         // Return Data
  26.         return $data;
  27.     }
  28.  
  29.     $t = file_get_contents('http://www.rankedgaming.com/api/fetchnames.php?0='.$_GET['acc_ID']);
  30.     $data = extractData($t);
  31.  
  32.     $row[0] = $_GET['game_ID'];
  33.     $row[1] = $_GET['player_ID'];
  34.     $row[2] = $_GET['acc_ID'];
  35.     $row[3] = $data[0][1];
  36.     $row[4] = $_GET['time'];
  37.     $row[5] = $_GET['status'];
  38.     $row[6] = $_GET['IP'];
  39.     $row[7] = $_GET['Hero'];
  40.     $row[8] = $_GET['K'];
  41.     $row[9] = $_GET['D'];
  42.     $row[10] = $_GET['A'];
  43.     $row[11] = $_GET['CK'];
  44.     $row[12] = $_GET['CD'];
  45.     $row[13] = $_GET['NK'];
  46.     $row[14] = $_GET['item1'];
  47.     $row[15] = $_GET['item2'];
  48.     $row[16] = $_GET['item3'];
  49.     $row[17] = $_GET['item4'];
  50.     $row[18] = $_GET['item5'];
  51.     $row[19] = $_GET['item6'];
  52.     $row[20] = $_GET['LeftReason'];
  53.  
  54.     require 'connection.php' ;
  55.     $query = mysql_query("INSERT INTO DB_game_players VALUES($row[0], $row[1], $row[2], '$row[3]', $row[4], '$row[5]', '$row[20]', '$row[6]', '$row[7]', $row[8], $row[9],$row[10], $row[11], $row[12], $row[13], '$row[14]', '$row[15]', '$row[16]', '$row[17]', '$row[18]', '$row[19]')");
  56.  
  57.         if (!$query){
  58.             $fh = fopen('error_log.txt', 'a') or die("can't open file");
  59.             fwrite($fh,"[".date('H:m:s d/m/y',time())."][Game #$row[0]][Player: #$row[1]]\n");
  60.             fclose($fh);
  61.         }
  62.  
  63.        
  64. ?>
Advertisement
Add Comment
Please, Sign In to add comment