Advertisement
Guest User

Untitled

a guest
Sep 29th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. <?php
  2. # Copyright (c) 2015 Jordan Turley, CSGO Win Big. All Rights Reserved.
  3.  
  4. include 'default.php';
  5. $db = getDB();
  6.  
  7. $maxPotCount = 60;
  8.  
  9. # Get password, owner steam ID, and all deposit items
  10. $password = isset($_POST['password']) ? $_POST['password'] : null;
  11. $tradeOwnerSteamId32 = isset($_POST['owner']) ? $_POST['owner'] : null;
  12. $allItemsJson = isset($_POST['items']) ? $_POST['items'] : null;
  13.  
  14. if (is_null($password) || is_null($tradeOwnerSteamId32) || is_null($allItemsJson) || strlen($password) === 0 || strlen($tradeOwnerSteamId32) === 0 || strlen($allItemsJson) === 0) {
  15. echo jsonErr('One of the required fields was not sent correctly or was left blank.');
  16. return;
  17. }
  18.  
  19. # Convert Steam ID to Steam64 ID
  20. $idParts = explode(':', $tradeOwnerSteamId32);
  21. $authServer = intval($idParts[1]);
  22. $accountNumber = intval($idParts[2]);
  23. $tradeOwnerSteamId64 = $accountNumber * 2 + 76561197960265728 + $authServer;
  24.  
  25. # Get the password from config file and make sure it matches
  26. $realPassword = "Pironi";
  27.  
  28. if ($password !== $realPassword) {
  29. echo jsonErr('The password was incorrect.');
  30. return;
  31. }
  32.  
  33. # Create all items array from json
  34. $allItems = json_decode($allItemsJson, true);
  35.  
  36. $totalPrice = 0;
  37. $itemsArr = array();
  38.  
  39. # Get the bot's inventory
  40. $botInventory = json_decode(file_get_contents("https://steamcommunity.com/profiles/(hiding this from pastebin)/inventory/json/730/2"), true);
  41.  
  42. if ($botInventory['success'] !== true) {
  43. echo jsonErr('An error occured fetching the bot\'s inventory.');
  44. return;
  45. }
  46.  
  47. $rgInventory = $botInventory['rgInventory'];
  48. $rgDescriptions = $botInventory['rgDescriptions'];
  49.  
  50. function clean3($string) {
  51. $string = str_replace(' ', '-', $string);
  52. $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);
  53.  
  54. return preg_replace('/-+/', '-', $string);
  55. }
  56. # Loop through each item and get their name and price, and add them to the database
  57. foreach ($allItems as $item) {
  58. $classId = $item['classId'];
  59. $instanceId = $item['instanceId'];
  60. $marketName = $item['marketName'];
  61. $rarityName = $item['rarityName'];
  62. $rarityColor = $item['rarityColor'];
  63. $price = $item['price'];
  64. $iconUrl = $item['iconUrl'];
  65.  
  66.  
  67. $creditinsert = clean3($price);
  68. $sql =
  69. 'INSERT INTO deposited
  70. (classId, instanceId, ownerSteamId64, ownerSteamId32, itemName, itemPrice, itemRarityName, itemRarityColor, itemIcon)
  71. VALUES
  72. (:class, :instance, :owner64, :owner32, :itemname, :itemprice, :itemrarityname, :itemraritycolor, :itemicon)';
  73.  
  74. $stmt = $db->prepare($sql);
  75. $stmt->bindValue(':class', $classId);
  76. $stmt->bindValue(':instance', $instanceId);
  77. $stmt->bindValue(':owner64', $tradeOwnerSteamId64);
  78. $stmt->bindValue(':owner32', $tradeOwnerSteamId32);
  79. $stmt->bindValue(':itemname', $marketName);
  80. $stmt->bindValue(':itemprice', $price);
  81. $stmt->bindValue(':itemrarityname', $rarityName);
  82. $stmt->bindValue(':itemraritycolor', $rarityColor);
  83. $stmt->bindValue(':itemicon', $iconUrl);
  84. $stmt->execute();
  85.  
  86. $sql2 =
  87. "
  88. UPDATE users SET credits=credits + '".$creditinsert."' WHERE steamid = '".$tradeOwnerSteamId64."'
  89. ";
  90. mysql_connect("localhost", "root", "");
  91. @mysql_select_db("test");
  92. mysql_query($sql2);
  93. }
  94.  
  95. # If the pot was not over the top, potOver = 0
  96. $data = array('minDeposit' => 1, 'potOver' => 0);
  97. echo jsonSuccess($data);
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement