kyleAI_13

Untitled

Sep 19th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.70 KB | None | 0 0
  1. <?php
  2. //test rabid api
  3. function grabPlayerData($name, $uid) {
  4.     $context = stream_context_create(array(
  5.       'http' => array(
  6.         'method' => 'GET',
  7.         'header' => "Content-Type: type=application/json\r\n"
  8.         )
  9.       )
  10.     );
  11.     $url = "http://173.16.48.132/api/player?name={$name}&uid={$uid}";
  12.     if (empty($name) || empty($uid)) $url='http://173.16.48.132/api/player?name=KrazyKlown77&uid=8e42b4fabdf0b3a5';
  13.     $api = json_decode(file_get_contents($url, false, $context));
  14.     return $api;
  15. }
  16.  
  17. // Start User session
  18. @session_start();
  19. // if using overlay and the uid is alpha-numeric check if playerID matches on HaloVault, if so, set playerID session and auto authorize
  20. if (!isset($_SESSION['dewPlayerID']) && isset($_COOKIE['dewUID']) && isset($_COOKIE['dewName']) && ctype_alnum($_COOKIE['dewUID'])) {
  21.     $DEW = getPlayerData($_COOKIE['dewName'], $_COOKIE['dewUID']);
  22.     $chkuser = $_SQL->query("SELECT * FROM users WHERE `playerid` = '{$DEW->playerID}' LIMIT 1");
  23.     if ($chkuser->num_rows == 1) {
  24.         $_DEW = $chkuser->fetch_object();
  25.         if (!isset($_SESSION['dewPlayerID'])) $_SESSION['dewPlayerID'] = $_AUTH->playerid;
  26.     }
  27. }
  28. else {
  29.     unset($_AUTH); $_SESSION['dewPlayerID']=null;
  30. }
  31.  
  32. if (isset($_COOKIE['hvAuth']) && !empty($_COOKIE['hvAuth'])) {
  33.     $_AUTH = @json_decode(base64_decode(base64_decode($_COOKIE['hvAuth']))); $aid=(int)$_AUTH->id;
  34.     $checkKey=$_SQL->query("SELECT sodium FROM users WHERE id = '{$aid}'") or die($_SQL->error);
  35.     $assoc=$checkKey->fetch_object();
  36.     if ($checkKey->num_rows==1 && $_AUTH->apiKey==sha1($assoc->sodium)) {
  37.         if (!isset($_SESSION['key'])) $_SESSION['key'] = $_AUTH->apiKey;
  38.     } else unset($_AUTH);
  39. }
  40. else {
  41.     unset($_AUTH); $_SESSION['key']=null;
  42. }
  43.  
  44. function getContents($url) {
  45.     $ch = curl_init();
  46.     $timeout = 5;
  47.     curl_setopt($ch, CURLOPT_URL, $url);
  48.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  49.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  50.     $data = curl_exec($ch);
  51.     curl_close($ch);
  52.     if ($data == FALSE or empty($data)) {
  53.         return false;
  54.     } else return $data;
  55. }
  56.  
  57. function resize($file, $w, $h, $crop=FALSE) {
  58.     list($width, $height) = getimagesize($file);
  59.     $r = $width / $height;
  60.     if ($crop) {
  61.         if ($width > $height) {
  62.             $width = ceil($width-($width*abs($r-$w/$h)));
  63.         } else {
  64.             $height = ceil($height-($height*abs($r-$w/$h)));
  65.         }
  66.         $newwidth = $w;
  67.         $newheight = $h;
  68.     } else {
  69.         if ($w/$h > $r) {
  70.             $newwidth = $h*$r;
  71.             $newheight = $h;
  72.         } else {
  73.             $newheight = $w/$r;
  74.             $newwidth = $w;
  75.         }
  76.     }
  77.     $src = imagecreatefromjpeg($file);
  78.     $dst = imagecreatetruecolor($newwidth, $newheight);
  79.     imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  80.  
  81.     return $dst;
  82. }
  83.  
  84. class int_helper {
  85.     public static function int8($i) {
  86.         return is_int($i) ? pack("c", $i) : unpack("c", $i)[1];
  87.     }
  88.     public static function uInt8($i) {
  89.         return is_int($i) ? pack("C", $i) : unpack("C", $i)[1];
  90.     }
  91.     public static function int16($i) {
  92.         return is_int($i) ? pack("s", $i) : unpack("s", $i)[1];
  93.     }
  94.     public static function uInt16($i, $endianness=false) {
  95.         $f = is_int($i) ? "pack" : "unpack";
  96.         if ($endianness === true) {  // big-endian
  97.             $i = $f("n", $i);
  98.         }
  99.         elseif ($endianness === false) {  // little-endian
  100.             $i = $f("v", $i);
  101.         }
  102.         elseif ($endianness === null) {  // machine byte order
  103.             $i = $f("S", $i);
  104.         }
  105.         return is_array($i) ? $i[1] : $i;
  106.     }
  107.     public static function int32($i) {
  108.         return is_int($i) ? pack("l", $i) : unpack("l", $i)[1];
  109.     }
  110.     public static function uInt32($i, $endianness=false) {
  111.         $f = is_int($i) ? "pack" : "unpack";
  112.         if ($endianness === true) {  // big-endian
  113.             $i = $f("N", $i);
  114.         }
  115.         elseif ($endianness === false) {  // little-endian
  116.             $i = $f("V", $i);
  117.         }
  118.         elseif ($endianness === null) {  // machine byte order
  119.             $i = $f("L", $i);
  120.         }
  121.         return is_array($i) ? $i[1] : $i;
  122.     }
  123.     public static function int64($i) {
  124.         return is_int($i) ? pack("q", $i) : unpack("q", $i)[1];
  125.     }
  126.     public static function uInt64($i, $endianness=false) {
  127.         $f = is_int($i) ? "pack" : "unpack";
  128.         if ($endianness === true) {  // big-endian
  129.             $i = $f("J", $i);
  130.         }
  131.         elseif ($endianness === false) {  // little-endian
  132.             $i = $f("P", $i);
  133.         }
  134.         elseif ($endianness === null) {  // machine byte order
  135.             $i = $f("Q", $i);
  136.         }
  137.         return is_array($i) ? $i[1] : $i;
  138.     }
  139. }
  140.  
  141. function printImg($filepath) {
  142.     $type = exif_imagetype($filepath); // [] if you don't have exif you could use getImageSize()
  143.     $allowedTypes = array(
  144.         1,  // [] gif
  145.         2,  // [] jpg
  146.         3,  // [] png
  147.         6   // [] bmp
  148.     );
  149.     if (!in_array($type, $allowedTypes)) return false;
  150.     switch ($type) {
  151.         case 1 : $im = imageCreateFromGif($filepath);
  152.          break;
  153.         case 2 : $im = imageCreateFromJpeg($filepath);
  154.          break;
  155.         case 3 : $im = imageCreateFromPng($filepath);
  156.          break;
  157.         case 6 : $im = imageCreateFromBmp($filepath);
  158.          break;
  159.     }    
  160.     return $im;  
  161. }
  162.  
  163. function byteSize($bytes) {
  164.     if ($bytes >= 1073741824)  $bytes = number_format($bytes / 1073741824, 2) . ' GB';
  165.     elseif ($bytes >= 1048576) $bytes = number_format($bytes / 1048576, 2) . ' MB';
  166.     elseif ($bytes >= 1024)    $bytes = number_format($bytes / 1024, 2) . ' KB';
  167.     elseif ($bytes > 1)        $bytes = $bytes . ' bytes';
  168.     elseif ($bytes == 1)       $bytes = $bytes . ' byte';
  169.     else                       $bytes = '0 bytes';
  170.     return $bytes;
  171. }
  172.  
  173. function getMapName($mid) {
  174.     if ($mid==30)       return "Last Resort";    
  175.     elseif ($mid==310)  return "High Ground";  
  176.     elseif ($mid==320)  return "Guardian";     
  177.     elseif ($mid==340)  return "Valhalla";     
  178.     elseif ($mid==380)  return "Narrows";      
  179.     elseif ($mid==390)  return "The Pit";      
  180.     elseif ($mid==400)  return "Sandtrap";     
  181.     elseif ($mid==410)  return "Standoff";     
  182.     elseif ($mid==700)  return "Reactor";      
  183.     elseif ($mid==705)  return "Diamondback";  
  184.     elseif ($mid==31)   return "Icebox";       
  185.     elseif ($mid==703)  return "Edge";         
  186.     elseif ($mid==413)  return "Flatgrass";    
  187.     elseif ($mid==415)  return "Station";      
  188.     elseif ($mid==414)  return "Lockout";      
  189.     elseif ($mid==416)  return "Hang 'Em High";
  190.     else return "Custom";
  191. }
  192. //GAME VARIANTS
  193. function getGameType($gid) {
  194.     if ($gid=='03')     return "Oddball";      
  195.     elseif ($gid=='02') return "Slayer";         
  196.     elseif ($gid=='0a') return "Infection";      
  197.     elseif ($gid=='09') return "Assault";      
  198.     elseif ($gid=='04') return "King of the Hill";
  199.     elseif ($gid=='07') return "Juggernaut";     
  200.     elseif ($gid=='08') return "Territories";    
  201.     elseif ($gid=='06') return "VIP";            
  202.     elseif ($gid=='01') return "Capture the Flag";
  203.     elseif ($gid=='05') return "Forge";            
  204.     else return "None";
  205. }
  206. function getVarExt($gid) {
  207.     if ($gid == '03')   return "variant.oddball";      
  208.     elseif ($gid=='02') return "variant.slayer";         
  209.     elseif ($gid=='0a') return "variant.zombiez";      
  210.     elseif ($gid=='09') return "variant.assault";      
  211.     elseif ($gid=='04') return "variant.koth";
  212.     elseif ($gid=='07') return "variant.jugg";   
  213.     elseif ($gid=='08') return "variant.terries";    
  214.     elseif ($gid=='06') return "variant.vip";            
  215.     elseif ($gid=='01') return "variant.ctf";
  216.     else                return "variant.forge";
  217. }
  218. function getDmgResist($dmg) {
  219.     if ($dmg=='00')     return "100%"; 
  220.     elseif ($dmg=='01') return "10%";      
  221.     elseif ($dmg=='02') return "50%";      
  222.     elseif ($dmg=='03') return "90%";      
  223.     elseif ($dmg=='04') return "100%";     
  224.     elseif ($dmg=='05') return "110%";     
  225.     elseif ($dmg=='06') return "150%";     
  226.     elseif ($dmg=='07') return "200%";     
  227.     elseif ($dmg=='08') return "300%";     
  228.     elseif ($dmg=='09') return "500%";     
  229.     elseif ($dmg=='0a') return "1000%";    
  230.     elseif ($dmg=='0b') return "2000%";    
  231.     elseif ($dmg=='0c') return "Invulnerable";
  232.     else return "Unknown";
  233. }
  234. function getDmgDeal($dmg) {
  235.     if ($dmg=='00')     return "100%";         
  236.     elseif ($dmg=='01') return "0%";           
  237.     elseif ($dmg=='02') return "25%";          
  238.     elseif ($dmg=='03') return "50%";          
  239.     elseif ($dmg=='04') return "75%";          
  240.     elseif ($dmg=='05') return "90%";          
  241.     elseif ($dmg=='06') return "100%";         
  242.     elseif ($dmg=='07') return "110%";         
  243.     elseif ($dmg=='08') return "125%";         
  244.     elseif ($dmg=='09') return "150%";         
  245.     elseif ($dmg=='0a') return "200%";         
  246.     elseif ($dmg=='0b') return "300%";         
  247.     elseif ($dmg=='0c') return "Instant Kill"; 
  248.     else return "Unknown";
  249. }
  250. function getWeap($wea) {
  251.     if ($wea=='01' || $wea=='ff' | $wea=='fe') return "Assault Rifle";
  252.     elseif ($wea=='00') return "Battle Rifle"; 
  253.     elseif ($wea=='0d') return "Brute Shot";   
  254.     elseif ($wea=='12') return "Gravity Hammer";
  255.     elseif ($wea=='07') return "Magnum";       
  256.     elseif ($wea=='08') return "Needler";      
  257.     elseif ($wea=='02') return "Plasma Pistol";
  258.     elseif ($wea=='0a') return "Rocket Launcher";
  259.     elseif ($wea=='0b') return "Shotgun";      
  260.     elseif ($wea=='04') return "S.M.G.";       
  261.     elseif ($wea=='0c') return "Sniper Rifle"; 
  262.     elseif ($wea=='10') return "Spartan Laser";
  263.     elseif ($wea=='06') return "Energy Sword"; 
  264.     elseif ($wea=='03') return "Spiker";       
  265.     elseif ($wea=='05') return "Carbine";      
  266.     elseif ($wea=='0f') return "Beam Rifle";   
  267.     elseif ($wea=='13') return "Mauler";       
  268.     elseif ($wea=='17') return "Fuel-Rod";     
  269.     elseif ($wea=='16') return "Sentinel Beam";
  270.     elseif ($wea=='18') return "D.M.R.";       
  271.     elseif ($wea=='1d') return "Assault Rifle ACC";
  272.     elseif ($wea=='1a') return "Assault Rifle DMG";
  273.     elseif ($wea=='1b') return "Assault Rifle ROF";
  274.     elseif ($wea=='1e') return "Assault Rifle PWR";
  275.     elseif ($wea=='20') return "Battle Rifle ACC";
  276.     elseif ($wea=='22') return "Battle Rifle DMG";
  277.     elseif ($wea=='21') return "Battle Rifle MAG";
  278.     elseif ($wea=='23') return "Battle Rifle RNG";
  279.     elseif ($wea=='1f') return "Battle Rifle ROF";
  280.     elseif ($wea=='24') return "Battle Rifle PWR";
  281.     elseif ($wea=='3b') return "Carbine ACC";  
  282.     elseif ($wea=='3a') return "Carbine DMG";  
  283.     elseif ($wea=='38') return "Carbine MAG";  
  284.     elseif ($wea=='39') return "Carbine RNG";  
  285.     elseif ($wea=='37') return "Carbine ROF";  
  286.     elseif ($wea=='3c') return "Carbine PWR";  
  287.     elseif ($wea=='26') return "D.M.R. ACC";   
  288.     elseif ($wea=='28') return "D.M.R. DMG";   
  289.     elseif ($wea=='29') return "D.M.R. MAG";   
  290.     elseif ($wea=='25') return "D.M.R. RNG";   
  291.     elseif ($wea=='27') return "D.M.R. ROF";   
  292.     elseif ($wea=='2a') return "D.M.R. PWR";   
  293.     elseif ($wea=='2c') return "S.M.G. ACC";   
  294.     elseif ($wea=='2e') return "S.M.G. DMG";   
  295.     elseif ($wea=='2b') return "S.M.G. ROF";   
  296.     elseif ($wea=='30') return "S.M.G. PWR";       
  297.     elseif ($wea=='41') return "Magnum DMG";           
  298.     elseif ($wea=='42') return "Magnum PWR";           
  299.     elseif ($wea=='36') return "Plasma Rifle PWR";         
  300.     elseif ($wea=='3f') return "Mauler PWR";           
  301.     elseif ($wea=='fd') return "Random";   
  302.     elseif ($wea=='43') return "None";         
  303.     else return "Unknown";
  304. }
  305. function getPlayerSpeed($spd) {
  306.     if ($spd=='00')     return "100%";
  307.     elseif ($spd=='01') return "25%";
  308.     elseif ($spd=='02') return "50%";
  309.     elseif ($spd=='03') return "75%";
  310.     elseif ($spd=='04') return "90%";
  311.     elseif ($spd=='05') return "100%";
  312.     elseif ($spd=='06') return "110%";
  313.     elseif ($spd=='07') return "125%";
  314.     elseif ($spd=='08') return "150%";
  315.     elseif ($spd=='09') return "200%";
  316.     elseif ($spd=='0a') return "300%";
  317.     else return "Unknown";
  318. }
  319. function getShieldMulti($shm) {
  320.     if ($shm=='00')     return "Normal";   
  321.     elseif ($shm=='01') return "None";     
  322.     elseif ($shm=='02') return "Normal";   
  323.     elseif ($shm=='03') return "Overshield x2";
  324.     elseif ($shm=='04') return "Overshield x3";
  325.     elseif ($shm=='05') return "Overshield x4";
  326.     else return "Unknown";
  327. }
  328.  function getWeapPick($wea) {
  329.     if ($wea=='02') return false;
  330.     else return true;
  331. }
  332. function getMapImg($mid) {
  333.     $MAPname = getMapName($mid);
  334.     return "/site/src/images/maps/".strtolower(str_ireplace(' ','',$MAPname)).".png";
  335. }
  336. function getIncludeContents($filename) {
  337.     if (is_file($filename)) {
  338.         ob_start();
  339.         include $filename;
  340.         $contents = ob_get_contents();
  341.         ob_end_clean();
  342.         return $contents;
  343.     }
  344.     return false;
  345. }
  346. function getMapQuote($map) {
  347.     $map = strtolower($map);
  348.     if ($map == 'diamondback')      $forgeQuote = "Hot winds blow over what should be a dead moon. A reminder of the power Forerunners once wielded.";
  349.     elseif ($map == 'edge')         $forgeQuote = "The remote frontier world of Partition has provided this ancient databank with the safety of seclusion.";
  350.     elseif ($map == 'guardian')     $forgeQuote = "Millennia of tending has produced trees as ancient as the Forerunner structures they have grown around.";
  351.     elseif ($map == 'icebox')       $forgeQuote = "Downtown Tyumen's Precinct 13 offers an ideal context for urban combat training.";
  352.     elseif ($map == 'narrows')      $forgeQuote = "Without cooling systems such as these, excess heat from the Ark's forges would render the construct uninhabitable.";
  353.     elseif ($map == 'reactor')      $forgeQuote = "Being constructed just prior to the Invasion, its builders had to evacuate before it was completed.";
  354.     elseif ($map == 'standoff')     $forgeQuote = "Once, nearby telescopes listened for a message from the stars. Now, these silos contain our prepared response.";
  355.     elseif ($map == 'the pit')      $forgeQuote = "Software simulations are held in contempt by the veteran instructors who run these training facilities.";
  356.     elseif ($map == 'valhalla')     $forgeQuote = "The crew of V-398 barely survived their unplanned landing in this gorge, but they know they are not alone.";
  357.     elseif ($map == 'last resort')  $forgeQuote = "Remote industrial sites like this one are routinely requisitioned & used as part of Spartan training exercises.";
  358.     elseif ($map == 'high ground')  $forgeQuote = "A relic of older conflicts, this base was reactivated after the New Mombasa Slipspace Event.";
  359.     elseif ($map == 'sandtrap')     $forgeQuote = "Although the Brute occupiers have been driven from this ancient structure, they left plenty to remember them by.";
  360.     elseif ($map == 'flatgrass')    $forgeQuote = "Modders offering a plain flat map with an extended pallet of items ideal for Forge.";
  361.     elseif ($map == 'lockout')      $forgeQuote = "Some believe this remote facility was once used to study the Flood. But few clues remain amidst the snow and ice.";
  362.     else                            $forgeQuote = "A custom map imported by a modder of the Halo Online community";
  363.     return $forgeQuote;
  364. }
  365.  
  366. // check for spamming against the database
  367. function isSpamming($authid, $numToCheck, $min) {
  368.     $_CHECK = new mysqli("localhost", "root", "all0utofcoolpasses", "vault") or die($_SQL->error);
  369.     if (empty($interval) || !isset($interval)) $interval = '8 MINUTE';
  370.     if (empty($numToCheck) || !isset($numToCheck)) $numToCheck = 2;
  371.     $checkMapSpam = $_CHECK->query("SELECT id FROM maps WHERE (dewid='{$authid}' OR uid='{$authid}') AND (`date` > date_sub(CURRENT_TIMESTAMP, INTERVAL {$interval}))");
  372.     $checkFileSpam = $_CHECK->query("SELECT id FROM files WHERE (dewid='{$authid}' OR uid='{$authid}') AND (`date` > date_sub(CURRENT_TIMESTAMP, INTERVAL {$interval}))");
  373.     $checkMedSpam = $_CHECK->query("SELECT id FROM media WHERE (dewid='{$authid}' OR uid='{$authid}') AND (`date` > date_sub(CURRENT_TIMESTAMP, INTERVAL {$interval}))");
  374.     $checkComSpam = $_CHECK->query("SELECT id FROM community WHERE (dewid='{$authid}' OR uid='{$authid}') AND (`date` > date_sub(CURRENT_TIMESTAMP, INTERVAL {$interval}))");
  375.     $checkSpam = $checkMapSpam->num_rows + $checkFileSpam->num_rows + $checkComSpam->num_rows + $checkMedSpam->num_rows;
  376.      if ($checkSpam > $numToCheck) return true;
  377.      else return false;
  378. } ?>
Add Comment
Please, Sign In to add comment