daily pastebin goal
60%
SHARE
TWEET

getinv

a guest Feb 17th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. case 'get_inv':
  2.     if(!$user) exit(json_encode(array('success'=>false, 'error'=>'You must login to access the deposit.')));
  3.         if((file_exists('cache/'.$user['steamid'].'.txt')) && (!isset($_GET['nocache']))) {
  4.             $array = file_get_contents('cache/'.$user['steamid'].'.txt');
  5.             $array = unserialize($array);
  6.             $array['fromcache'] = true;
  7.             if(isset($_COOKIE['tid'])) {
  8.                 $sql = $db->query('SELECT * FROM `trades` WHERE `id` = '.$db->quote($_COOKIE['tid']).' AND `status` = 0');
  9.                 if($sql->rowCount() != 0) {
  10.                     $row = $sql->fetch();
  11.                     $array['code'] = $row['code'];
  12.                     $array['amount'] = $row['summa'];
  13.                     $array['tid'] = $row['id'];
  14.                     $array['bot'] = "Bot #".$row['bot_id'];
  15.                 } else {
  16.                     setcookie("tid", "", time() - 3600, '/');
  17.                 }
  18.             }
  19.             exit(json_encode($array));
  20.         }
  21.         $prices = file_get_contents('../prices.txt');
  22.         $prices = json_decode($prices, true);
  23.  
  24.         $inv = file_get_contents('https://steamcommunity.com/profiles/'.$user['steamid'].'/inventory/json/730/2/');
  25.         $inv = json_decode($inv, true);
  26.         if($inv['success'] != 1) {
  27.             exit(json_encode(array('error'=>'Your profile is private. Please <a href="http://steamcommunity.com/my/edit/settings" target="_blank">set your inventory to public</a> and <a href="javascript:loadLeft(\'nocache\')">try again</a>.')));
  28.         }
  29.         $items = array();
  30.         foreach ($inv['rgInventory'] as $key => $value) {
  31.             $id = $value['classid'].'_'.$value['instanceid'];
  32.             $trade = $inv['rgDescriptions'][$id]['tradable'];
  33.             if(!$trade) continue;
  34.             $name = $inv['rgDescriptions'][$id]['market_hash_name'];
  35.             $price = $prices['response']['items'][$name]['value'];
  36.             $img = 'http://steamcommunity-a.akamaihd.net/economy/image/'.$inv['rgDescriptions'][$id]['icon_url'];
  37.             if((preg_match('/(Souvenir)/', $name)) || ($price < $min)) {
  38.                 $price = 0;
  39.                 $reject = 'Junk';
  40.             } else {
  41.                 $reject = 'unknown item';
  42.             }
  43.             $items[] = array(
  44.                 'assetid' => $value['id'],
  45.                 'bt_price' => "0.00",
  46.                 'img' => $img,
  47.                 'name' => $name,
  48.                 'price' => $price,
  49.                 'reject' => $reject,
  50.                 'sa_price' => $price,
  51.                 'steamid' => $user['steamid']);
  52.         }
  53.  
  54.         $array = array(
  55.             'error' => 'none',
  56.             'fromcache' => false,
  57.             'items' => $items,
  58.             'success' => true);
  59.         if(isset($_COOKIE['tid'])) {
  60.             $sql = $db->query('SELECT * FROM `trades` WHERE `id` = '.$db->quote($_COOKIE['tid']).' AND `status` = 0');
  61.             if($sql->rowCount() != 0) {
  62.                 $row = $sql->fetch();
  63.                 $array['code'] = $row['code'];
  64.                 $array['amount'] = $row['summa'];
  65.                 $array['tid'] = $row['id'];
  66.                 $array['bot'] = "Bot #".$row['bot_id'];
  67.             } else {
  68.                 setcookie("tid", "", time() - 3600, '/');
  69.             }
  70.         }
  71.         file_put_contents('cache/'.$user['steamid'].'.txt', serialize($array), LOCK_EX);
  72.         exit(json_encode($array));
  73.         break;
RAW Paste Data
Top