Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case 'get_inv':
- if(!$user) exit(json_encode(array('success'=>false, 'error'=>'You must login to access the deposit.')));
- if((file_exists('cache/'.$user['steamid'].'.txt')) && (!isset($_GET['nocache']))) {
- $array = file_get_contents('cache/'.$user['steamid'].'.txt');
- $array = unserialize($array);
- $array['fromcache'] = true;
- if(isset($_COOKIE['tid'])) {
- $sql = $db->query('SELECT * FROM `trades` WHERE `id` = '.$db->quote($_COOKIE['tid']).' AND `status` = 0');
- if($sql->rowCount() != 0) {
- $row = $sql->fetch();
- $array['code'] = $row['code'];
- $array['amount'] = $row['summa'];
- $array['tid'] = $row['id'];
- $array['bot'] = "Bot #".$row['bot_id'];
- } else {
- setcookie("tid", "", time() - 3600, '/');
- }
- }
- exit(json_encode($array));
- }
- $prices = file_get_contents('../prices.txt');
- $prices = json_decode($prices, true);
- $inv = file_get_contents('https://steamcommunity.com/profiles/'.$user['steamid'].'/inventory/json/730/2/');
- $inv = json_decode($inv, true);
- if($inv['success'] != 1) {
- 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>.')));
- }
- $items = array();
- foreach ($inv['rgInventory'] as $key => $value) {
- $id = $value['classid'].'_'.$value['instanceid'];
- $trade = $inv['rgDescriptions'][$id]['tradable'];
- if(!$trade) continue;
- $name = $inv['rgDescriptions'][$id]['market_hash_name'];
- $price = $prices['response']['items'][$name]['value'];
- $img = 'http://steamcommunity-a.akamaihd.net/economy/image/'.$inv['rgDescriptions'][$id]['icon_url'];
- if((preg_match('/(Souvenir)/', $name)) || ($price < $min)) {
- $price = 0;
- $reject = 'Junk';
- } else {
- $reject = 'unknown item';
- }
- $items[] = array(
- 'assetid' => $value['id'],
- 'bt_price' => "0.00",
- 'img' => $img,
- 'name' => $name,
- 'price' => $price,
- 'reject' => $reject,
- 'sa_price' => $price,
- 'steamid' => $user['steamid']);
- }
- $array = array(
- 'error' => 'none',
- 'fromcache' => false,
- 'items' => $items,
- 'success' => true);
- if(isset($_COOKIE['tid'])) {
- $sql = $db->query('SELECT * FROM `trades` WHERE `id` = '.$db->quote($_COOKIE['tid']).' AND `status` = 0');
- if($sql->rowCount() != 0) {
- $row = $sql->fetch();
- $array['code'] = $row['code'];
- $array['amount'] = $row['summa'];
- $array['tid'] = $row['id'];
- $array['bot'] = "Bot #".$row['bot_id'];
- } else {
- setcookie("tid", "", time() - 3600, '/');
- }
- }
- file_put_contents('cache/'.$user['steamid'].'.txt', serialize($array), LOCK_EX);
- exit(json_encode($array));
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement