Jump to content
Sign in to follow this  
aidis steam

SteamAuth - Wpładanie itemów / depozytów. AJAX error from offer

Recommended Posts

Failed to load resource: the server responded with a get_inv.php?undefined  status of 500 (Internal Server Error)

 

AJAX error while loadleft: Internal Server Error

 

function showConfirm() {
    $("#confirmModal").modal("show");
}

function cmd() {
    var t = parseInt($("#cmd").html());
    if (t > 0) {
        $("#cmd").html(t - 1);
        setTimeout(cmd, 1000);
    }
}

function cmdm() {
    var t = parseInt($("#cmdm").html());
    if (t > 0) {
        $("#cmdm").html(t - 1);
        setTimeout(cmdm, 1000);
    }
}


function addPadding(lr, across) {
    var MIN = 2;
    var count = $(lr + " .reals>.emptyitem:not(.hidden)").length;
    var needed = 0;
    if (count <= across * MIN) {
        needed = across * MIN - count;
    } else {
        needed = (across - (count % across)) % across;
    }
    $(lr + " .bricks>.emptyitem").addClass("hidden").slice(0, needed).removeClass("hidden");
}

function addUp() {
    var creds = 0;
    var count = 0;
    $("#right .slot").each(function(i, e) {
        creds += $(this).data("price");
        count++;
    });
    if(window.location.href.indexOf("deposit") < 0) {
        creds = -creds;
    }
    $("#sum").html(formatNum(creds));
    if (count == 0) {
        $("#botFilter .btn").removeClass("disabled");
    }
}

function doFilter() {
    var b = $("#botFilter .btn.active").data("bot") || 0;
    var t = $("#filter").val().toLowerCase();
    var total = $("#left .reals>.emptyitem").length;
    var n = $("#left .reals>.emptyitem").addClass("hidden").filter(function(i, e) {
        var bx = $(this).data("bot") || "";
        var tx = $(this).data("name") || "";
        var px = $(this).data("price") || 0;
        if (b == 0 || b == bx) {
            if (tx.toLowerCase().indexOf(t) >= 0) {
                return true;
            } else if (t.charAt(0) == ">") {
                return px > parseInt(t.substr(1));
            } else if (t.charAt(0) == ">") {
                return px < parseInt(t.substr(1));
            }
        }
    }).removeClass("hidden").length;
    if (t === "" && b == 0) {
        $("#left_number").html(total);
    } else {
        $("#left_number").html(n + "/" + total);
    }
    addPadding("#left", 6);
}
$(document).ready(function() {
    
       loadLeft();
    
    $(document).on("click", "#right .slot", function() {
        $(this).parent().remove();
        $(this).appendTo(".emptyitem[data-pos='" + $(this).data("pos") + "']");
        addPadding("#right", 4);
        addUp();
    });
    $(document).on("click", "#left .slot:not(.reject)", function() {
        var b = $(this).data("bot") || null;
        if (b != null) {
            $("#botFilter .btn").removeClass("active").addClass("disabled");
            $("#botFilter .btn[data-bot='" + b + "']").addClass("active").removeClass("disabled");
            doFilter();
        }
        var c = $("#right .slot").length;
        if (c < 32) {
            $("#right .reals").append("<div class='emptyitem'></div>");
            $(this).appendTo($("#right .reals .emptyitem:empty").first());
            addPadding("#right", 4);
            addUp();
        }
    });
    $("#filter").on("keyup", function() {
        doFilter();
    });
    $("#orderBy").on("change", function() {
        var o = $(this).val();
        if (o == 1) {
            tinysort("#left .reals>.emptyitem", {
                data: "price",
                order: "desc"
            });
        } else if (o == 2) {
            tinysort("#left .reals>.emptyitem", {
                data: "price",
                order: "asc"
            });
        } else if (o == 3) {
            tinysort("#left .reals>.emptyitem", {
                data: "name",
                order: "asc"
            });
        } else {
            tinysort("#left .reals>.emptyitem", {
                data: "price",
                order: "desc"
            });
        }
    });
    $("#botFilter .btn").on("click", function() {
        if ($(this).hasClass("disabled")) {
            return;
        }
        $("#botFilter .btn").removeClass("active");
        $(this).addClass("active");
        doFilter();
    });
    $("#confirmButton").on("click", function() {
        inlineAlert("", "Potwierdzanie wymiany, prosimy czekać...");
        $this = $(this);
        $this.prop("disabled", true);
        var tid = $this.data("tid");
        $.ajax({
            url: "/confirm.php",
            type: "GET",
            data: {
                "tid": tid
            },
            success: function(data) {
                try {
                    data = JSON.parse(data);
                    if (data.success) {
                        if (data.action == "accept") {
                            inlineAlert("success", data.result);
                        } else {
                            inlineAlert("cross", data.result);
                        }
                        $("#offerPanel").slideUp();
                    } else {
                        inlineAlert("error", data.error);
                        if (data.count > 0) {
                            cmdm();
                        }
                    }
                } catch (err) {
                    inlineAlert("error", "Javascript error: " + err);
                }
            },
            error: function(err) {
                inlineAlert("error", "AJAX error while confirming: " + err.statusText);
            },
            complete: function() {
                $this.prop("disabled", false);
            }
        });
        return false;
    });
    $(document).on("contextmenu", ".slot", function(e) {
        if (e.ctrlKey) return;
        e.preventDefault();
        var view = $(this).data("view");
        if (view == "none") {
            return;
        }
        $("#contextMenu [data-act=0]").attr("href", view);
        var $menu = $("#contextMenu");
        $menu.show().css({
            position: "absolute",
            left: getMenuPosition(e.clientX, 'width', 'scrollLeft'),
            top: getMenuPosition(e.clientY, 'height', 'scrollTop')
        }).off("click").on("click", "a", function(e) {});
    });
    $(document).on("click", function() {
        $("#contextMenu").hide();
    });
});

function getMenuPosition(mouse, direction, scrollDir) {
    var win = $(window)[direction](),
        scroll = $(window)[scrollDir](),
        menu = $("#contextMenu")[direction](),
        position = mouse + scroll;
    if (mouse + menu > win && menu < mouse)
        position -= menu;
    return position;

}

function showPending(data) {
    var content = "<b>Wymiana z " + data.bot + " ";
    content += "- Tajny kod: " + data.code + ", otrzymasz " + data.amount + " <i class='fa fa-diamond'></i>.";
    content += " Kliknij <a href='https://steamcommunity.com/tradeoffer/" + data.tid + "' target='_blank' >tutaj</a>, aby zaakceptować ofertę";
    if (data.amount > 0) {
        content += " oraz odebrać swoje diamenty.";
    } else {
        content += ".";
    }
    $("#offerContent").html(content);
    $("#confirmButton").data("tid", data.tid);
    if (data.amount < 0) {
        if (data.state == 2 || data.state == 3 || data.state == 4 || data.state == 9) {
            $("#confirmButton").html("Confirm");
        } else {
            $("#confirmButton").html("Confirmed");
        }
    }
    $("#offerPanel").slideDown();
}

function loadLeft(opts) {

    inlineAlert("", "Ĺadowanie ekwipunku...");
    var DIV = "<div class='emptyitem matched' data-name='{0}' data-pos='{1}' data-price='{2}' data-bot='{3}'>";
    DIV += "<div class='slot {13}' data-view='{15}' data-name='{4}' data-pos='{5}' data-price='{6}' data-bot='{7}' data-id='{8}' style='background-image:url(\"{9}\")'>";
    DIV += "<div class='name'>{10}</div>";
    DIV += "<div class='price {11}'><i class='fa fa-diamond'></i> {12}</div>";
    DIV += "<div class='bot'>{14}</div>";
    DIV += "</div></div>";
    var IMG = "{0}/{1}fx{2}f";
    var url = "";
    if(window.location.href.indexOf("deposit") > -1) {
        url = "/get_inv.php?" + opts;
    } else {
        url = "/get_bank_safe.php?g-recaptcha-response=true";
    }
    $.ajax({
        "url": url,
        success: function(data) {
            try {
				console.log("try withdraw loading");
                data = JSON.parse(data);
                if (data.success) {
                    
                    $("#left .reals").empty();
                    $("#right .reals").empty();
                    $("#right .bricks").removeClass("hidden");
                    $("#avail").html(formatNum(data.balance));
                    var count = data.items.length;
                    var eleA = [];
                    for (var i = 0; i < count; i++) {
                        var item = data.items[i];
                        var url = IMG.format(item.img, 110, 50);
                        var price_class = "pricee";
                        if(window.location.href.indexOf("deposit") > -1) {
                            price_class = "ball-0";
                        }
                        var slot_class = "";
                        var price_content = item.price;
                        if (price_content == 0) {
                            price_content = item.reject;
                            slot_class = "reject";
							price_class = "pricee";
                        } else {
                            price_content = formatNum(price_content);
                        }
                        bot = 0;
                        if (item.botid) {
                            bot = item.botid;
                        }
                        var botLabel = "";
                        if(window.location.href.indexOf("deposit") < 0) {
                  
                            botLabel = "Bot " + bot;
                        }
                        var ele = DIV.format(item.name, i, item.price, bot, item.name, i, item.price, bot, item.assetid, url, item.name, price_class, price_content, slot_class, botLabel, item.view);
                        eleA.push(ele);
                    }
                    $("#left_number").html(count);
                    document.getElementById("left").getElementsByClassName("reals")[0].innerHTML = eleA.join('');
                    addPadding("#left", 6);
                    if (data.fromcache) {
                        inlineAlert("success", "Załadowano " + count + " przedmiotów z pamięci cache - <a href=\"javascript:loadLeft('nocache')\">załaduj ponownie</a>");
                    } else {
                        inlineAlert("success", "Załadowano " + count + " przedmiotów.");
                    }
                } else {
                    inlineAlert("error", data.error);
                    if (data.count > 0) {
                        cmd();
                    }
                }
                if (data.tid) {
                    showPending(data);
                }
            } catch (err) {
                inlineAlert("error", "Javascript error: " + err);
            }
        },
        error: function(err) {
            inlineAlert("error", "AJAX error while loadleft: " + err.statusText);
        },
    });
}

function offer() {
    inlineAlert("", "Wykonywanie oferty wymiany, prosimy czekać...");
    $("#confirmModal").modal("hide");
    var csv = "";
    var sum = 0;
    $("#right .slot").each(function(i, e) {
        csv += $(this).data("id") + ",";
        sum += $(this).data("price");
    });
    var turl = $("#tradeurl").val();
    var remember = $("#remember").is(":checked") ? "on" : "off";
    var url = "/withdraw_js.php";
    if(window.location.href.indexOf("deposit") > -1) {
        url = "/deposit_js.php";
    }
    $.ajax({
        "url": url,
        type: "GET",
        data: {
            "assetids": csv,
            "tradeurl": turl,
            "checksum": sum,
            "remember": remember
        },
        success: function(data) {
            try {
                data = JSON.parse(data);
                if (data.success) {
                    inlineAlert("success", "Nowa oferta wymiany!");
                    showPending(data);
                } else {
                    inlineAlert("error", data.error);
                }
            } catch (err) {
                inlineAlert("error", "Javascript error: " + err);
            }
        },
        error: function(err) {
            inlineAlert("error", "AJAX error from offer: " + err.statusText);
        },
    });
}

 

Edited by aidis steam

Share this post


Link to post

GET http://5.196.126.85/deposit_js.php?assetids=&tradeurl=https%3A%2F%2Fsteamco…r%2Fnew%2F%3Fpartner%3D317864823%26token%3D5QSLD3K-&checksum=0&remember=on 500 (Internal Server Error)

 

AJAX error from offer: Internal Server Error

 

<?php
include ('link.php');
require_once('steamauth/steamauth.php');
@include_once('steamauth/userInfo.php');
if(isset($_SESSION["steamid"])){
	if($_COOKIE['tid']) {
			exit(json_encode(array('success'=>false, 'error'=>'You isset active tradeoffer.')));
		}
		$sql = $db->query('SELECT `id`,`name` FROM `bots` ORDER BY rand() LIMIT 1');
		$row = $sql->fetch();
		$bot = $row['id'];
		$partner = extract_partner($_GET['tradeurl']);
		$token = extract_token($_GET['tradeurl']);
		setcookie('tradeurl', $_GET['tradeurl'], time() + 3600 * 24 * 7, '/');
		$checksum = intval($_GET['checksum']);
		$prices = file_get_contents('prices.txt');
		$prices = json_decode($prices, true);
		$out = curl('http://'.$ip.':'.(3000+$bot).'/c492d8ccb5d9ef0eef014b4a2e91e9bf66fab31511cbf44c3afa413e751bb1f0/?assetids='.$_GET['assetids'].'&partner='.$partner.'&token='.$token.'&checksum='.$_GET['checksum'].'&steamid='.$user['steamid']);
		$out = json_decode($out, true);
		$out['bot'] = $row['name'];
		if($out['success'] == true) {
			$s = 0;
			foreach ($out['items'] as $key => $value) {
				$db->exec('INSERT INTO `items` SET `trade` = '.$db->quote($out['tid']).', `market_hash_name` = '.$db->quote($value['market_hash_name']).', `img` = '.$db->quote($value['icon_url']).', `botid` = '.$db->quote($bot).', `time` = '.$db->quote(time()));
				$price = $prices[$value['market_hash_name']]*1000;
				if ($price <= 5000){
					$price = $price * 0.85;
				} else if ($price <= 10000){
					$price = $price * 0.93;
				}
				$s += floor($price);
			}
			$db->exec('INSERT INTO `trades` SET `id` = '.$db->quote($out['tid']).', `bot_id` = '.$db->quote($bot).', `code` = '.$db->quote($out['code']).', `status` = 0, `user` = '.$db->quote($user['steamid']).', `summa` = '.$db->quote($s).', `time` = '.$db->quote(time()));
			$out['amount'] = $s;
			setcookie('tid', $out['tid'], time() + 3600 * 24 * 7, '/');
		}
		exit(json_encode($out));
} else {
	exit(json_encode(array('success'=>false, 'error'=>'Musisz się zalogować, żeby zdepozytować przedmioty.')));
}
		?>
Edited by aidis steam

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Create a New Account. It’s free and easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×
×
  • Create New...