diff --git a/web/yaamp/commands/CoindbCommand.php b/web/yaamp/commands/CoindbCommand.php index e30daf5..a32d6ea 100644 --- a/web/yaamp/commands/CoindbCommand.php +++ b/web/yaamp/commands/CoindbCommand.php @@ -49,7 +49,6 @@ class CoindbCommand extends CConsoleCommand $nbUpdated = $this->grabBterIcons(); $nbUpdated += $this->grabCcexIcons(); - $nbUpdated += $this->grabAllcoinIcons(); $nbUpdated += $this->grabCryptopiaIcons(); $nbUpdated += $this->grabAlcurexIcons(); $nbUpdated += $this->grabBanxIcons(); @@ -289,42 +288,6 @@ class CoindbCommand extends CConsoleCommand return $nbUpdated; } - /** - * Icon grabber - Allcoin - */ - public function grabAllcoinIcons() - { - $url = 'http://www.allcoin.com/img/icon/'; - $nbUpdated = 0; - $sql = "SELECT DISTINCT coins.id FROM coins INNER JOIN markets M ON M.coinid = coins.id ". - "WHERE M.name='allcoin' AND IFNULL(coins.image,'') = ''"; - $coins = dbolist($sql); - if (empty($coins)) - return 0; - echo "allcoin: try to download new icons...\n"; - foreach ($coins as $coin) { - $coin = getdbo('db_coins', $coin["id"]); - $symbol = $coin->symbol; - if (!empty($coin->symbol2)) $symbol = $coin->symbol2; - $local = $this->basePath."/images/coin-{$symbol}.png"; - try { - $data = @ file_get_contents($url.strtolower($symbol).'.png'); - } catch (Exception $e) { - continue; - } - if (strlen($data) < 2048) continue; - echo $symbol." icon found\n"; - file_put_contents($local, $data); - if (filesize($local) > 0) { - $coin->image = "/images/coin-{$symbol}.png"; - $nbUpdated += $coin->save(); - } - } - if ($nbUpdated) - echo "$nbUpdated icons downloaded from allcoin\n"; - return $nbUpdated; - } - /** * Icon grabber - Cryptsy (jpg only) */ diff --git a/web/yaamp/core/backend/markets.php b/web/yaamp/core/backend/markets.php index 866d082..a99a416 100644 --- a/web/yaamp/core/backend/markets.php +++ b/web/yaamp/core/backend/markets.php @@ -8,13 +8,13 @@ function BackendPricesUpdate() updatePoloniexMarkets(); updateBleutradeMarkets(); updateCCexMarkets(); - updateCryptsyMarkets(); updateCryptopiaMarkets(); updateYobitMarkets(); - updateAllcoinMarkets(); + updateSafecexMarkets(); updateAlcurexMarkets(); updateBterMarkets(); updateEmpoexMarkets(); + updateCryptsyMarkets(); updateJubiMarkets(); updateBanxioMarkets(); @@ -683,34 +683,33 @@ function updateBanxioMarkets() } } -function updateAllcoinMarkets() +function updateSafecexMarkets() { - $data = allcoin_api_query('pairs'); - if(!is_object($data)) return; + $data = safecex_api_query('getmarkets'); + if(empty($data)) return; - $list = getdbolist('db_markets', "name='allcoin'"); + $list = getdbolist('db_markets', "name='safecex'"); foreach($list as $market) { $coin = getdbo('db_coins', $market->coinid); if(!$coin || !$coin->installed) continue; - $pair = strtoupper($coin->symbol).'_BTC'; + $pair = strtoupper($coin->symbol).'/BTC'; - if (isset($data->data[$pair])) { - $ticker = $data->data[$pair]; - $market->price = AverageIncrement($market->price, $ticker->top_bid); - $market->price2 = AverageIncrement($market->price2, $ticker->top_ask); - $market->deleted = (floatval($ticker->volume_24h_BTC) < 0.01); - $market->save(); - if (empty($coin->price2)) { - $coin->price = $market->price; - $coin->price2 = $market->price2; - $coin->save(); - } - if ($coin->name == 'unknown' && !empty($ticker->name)) { - $coin->name = $ticker->name; - $coin->save(); - debuglog("allcoin: update $symbol name {$coin->name}"); + foreach ($data as $ticker) { + if ($ticker->market === $pair) { + + $price2 = ($ticker->bid + $ticker->ask)/2; + $market->price2 = AverageIncrement($market->price2, $price2); + $market->price = AverageIncrement($market->price, $ticker->bid*0.98); + $market->save(); + if (empty($coin->price)) { + $coin->price = $market->price; + $coin->price2 = $market->price2; + $coin->save(); + } + debuglog("safecex: $pair $market->price ".bitcoinvaluetoa($market->price2)); + break; } } } diff --git a/web/yaamp/core/backend/rawcoins.php b/web/yaamp/core/backend/rawcoins.php index ff2183c..f9fe845 100644 --- a/web/yaamp/core/backend/rawcoins.php +++ b/web/yaamp/core/backend/rawcoins.php @@ -85,16 +85,16 @@ function updateRawcoins() } } - $list = allcoin_api_query('pairs'); - if(isset($list->data)) + $list = safecex_api_query('getmarkets'); + if(!empty($list)) { - dborun("UPDATE markets SET deleted=true WHERE name='allcoin'"); - foreach($list->data as $pair => $item) { - if (strtoupper($item->exchange) !== 'BTC') + dborun("UPDATE markets SET deleted=true WHERE name='safecex'"); + foreach($list as $pair => $item) { + $e = explode('/', $item->market); + if (strtoupper($e[1]) !== 'BTC') continue; - if (intval($item->status) == -2) - continue; - updateRawCoin('allcoin', $item->type, $item->name); + $symbol = strtoupper($e[0]); + updateRawCoin('safecex', $symbol); } } diff --git a/web/yaamp/core/exchange/allcoin.php b/web/yaamp/core/exchange/allcoin.php deleted file mode 100644 index d63566e..0000000 --- a/web/yaamp/core/exchange/allcoin.php +++ /dev/null @@ -1,17 +0,0 @@ -