我有一个从Steam Market获取价格的网站。它按物品的名称取价。然后我的javascript bot获取有关item的信息并将其处理到MySQL(当PHP文件将其处理到另一个表时)。
所以问题就是从它开始。有些项目在名称上有字符串。它会导致我的javascript机器人被窃听并崩溃。到目前为止,我有以下代码。
有没有办法保存数据库并将信息发送到带有字符串的javascript bot?抱歉。也许我缺乏逻辑。
<?php
$item = $_GET['item'];
$item = str_replace("\"", "", $item);
$item = str_replace("\'", "", $item);
$item = str_replace(" ", "%20", $item);
$item = str_replace("\\", "", $item);
@include_once ("set.php");
$rs = mysql_query("SELECT * FROM items WHERE name='$item'");
if(mysql_num_rows($rs) > 0) {
$row = mysql_fetch_array($rs);
if(time()-$row["lastupdate"] < 604800) die($row["cost"]);
}
$link = "http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=".$item;
$string = file_get_contents($link);
$obj = json_decode($string);
if($obj->{'success'} == "0") die("notfound");
$lowest_price = $obj->{'lowest_price'};
for($i = 5; $i < strlen($lowest_price); $i++) {
$lowest_price[$i-5] = $lowest_price[$i];
}
$lowest_price[strlen($lowest_price)] = 0;
$lowest_price = (float)($lowest_price);
mysql_query("DELETE FROM items WHERE name='$item'");
mysql_query("INSERT INTO items (`name`,`cost`,`lastupdate`) VALUES ('$item','$lowest_price','".time()."')");
echo $lowest_price;
?>
答案 0 :(得分:1)
client(utc+8) dbserver(utc)
upload time 1443145546920 without tzoffset
write 1443145546920
download
send 1443145546920
got 1443145546920 and add client tzoffset 480m
答案 1 :(得分:-1)
那会是这样的吗?
<?php
$item = $_GET['item'];
$item = str_replace("\"", "", $item);
$item = str_replace("\'", "", $item);
$item = str_replace(" ", "%20", $item);
$item = str_replace("\\", "", $item);
$item = (string)$item