예제 #1
0
 function getJSON($arguments)
 {
     $result = array();
     foreach (\DiscoveredComponents\Exchanges::getAllInstances() as $key => $instance) {
         $q = db()->prepare("SELECT * FROM ticker_recent WHERE exchange=?");
         $q->execute(array($key));
         $rates = array();
         while ($rate = $q->fetch()) {
             $rates[] = array('currency1' => $rate['currency1'], 'currency2' => $rate['currency2'], 'last_trade' => $rate['last_trade'], 'updated' => $rate['created_at']);
         }
         $result[] = array("code" => $instance->getCode(), "name" => $instance->getName(), "disabled" => $instance instanceof \Openclerk\Currencies\DisabledExchange, "rates" => $rates);
     }
     return $result;
 }
예제 #2
0
            echo "<input type=\"hidden\" name=\"enable\" value=\"" . htmlspecialchars($exchange) . "\">";
            echo "<input type=\"submit\" value=\"Enable all\" onclick=\"return confirm('Are you sure you want to re-enable all failed accounts?');\">";
            echo "</form>";
            echo "<form action=\"" . htmlspecialchars(url_for('admin_accounts_message')) . "\" method=\"post\">";
            echo "<input type=\"hidden\" name=\"exchange\" value=\"" . htmlspecialchars($exchange) . "\">";
            echo "<input type=\"submit\" value=\"Message failed\">";
            echo "</form>";
        }
        echo "</td>\n";
        echo "</tr>";
    }
}
?>
  <tr><th colspan="8">Tickers</th></tr>
<?php 
$exchanges = \DiscoveredComponents\Exchanges::getAllInstances();
foreach ($exchanges as $exchange) {
    echo "<tr><td>" . htmlspecialchars($exchange->getName()) . "</td>\n";
    // no accounts use this
    // executing this in two queries is faster than going ORDER BY is_error DESC
    $q = db()->prepare("SELECT * FROM jobs WHERE job_type=? AND is_test_job=0 AND is_error=1 LIMIT 1");
    $q->execute(array('ticker_' . $exchange->getCode()));
    $job = $q->fetch();
    if (!$job) {
        // if there are no failing jobs, just select any one
        $q = db()->prepare("SELECT * FROM jobs WHERE job_type=? AND is_test_job=0 LIMIT 1");
        $q->execute(array('ticker_' . $exchange->getCode()));
        $job = $q->fetch();
    }
    echo "<td>" . get_class($exchange) . "</td>";
    if (in_array($exchange->getCode(), \DiscoveredComponents\Exchanges::getDisabled())) {
예제 #3
0
function get_external_apis()
{
    $external_apis_addresses = array();
    foreach (Currencies::getBalanceCurrencies() as $key) {
        $currency = Currencies::getInstance($key);
        if ($currency->getExplorerURL()) {
            $link = link_to($currency->getExplorerURL(), $currency->getExplorerName());
        } else {
            $link = htmlspecialchars($currency->getExplorerName());
        }
        $external_apis_addresses["address_" . $key] = array('link' => $link, 'package' => Currencies::getDefiningPackage($key));
    }
    $external_apis_blockcounts = array();
    foreach (Currencies::getBlockCurrencies() as $key) {
        $currency = Currencies::getInstance($key);
        if ($currency->getExplorerURL()) {
            $link = link_to($currency->getExplorerURL(), $currency->getExplorerName());
        } else {
            $link = htmlspecialchars($currency->getExplorerName());
        }
        $external_apis_blockcounts["blockcount_" . $key] = array('link' => $link, 'package' => Currencies::getDefiningPackage($key));
    }
    $exchange_tickers = array();
    foreach (Exchanges::getAllInstances() as $key => $exchange) {
        if (in_array($key, Exchanges::getDisabled())) {
            // do not list disabled exchanges
            continue;
        }
        $link = link_to($exchange->getURL(), $exchange->getName());
        $exchange_tickers["ticker_" . $key] = array('link' => $link, 'package' => Exchanges::getDefiningPackage($key));
    }
    $mining_pools = array();
    $exchange_wallets = array();
    foreach (Accounts::getKeys() as $key) {
        if (in_array($key, Accounts::getDisabled())) {
            // do not list disabled accounts
            continue;
        }
        $instance = Accounts::getInstance($key);
        if (in_array($key, Accounts::getMiners())) {
            // a miner
            $mining_pools["account_" . $key] = array('link' => link_to($instance->getURL(), $instance->getName()), 'package' => Accounts::getDefiningPackage($key));
        } else {
            // otherwise, assume exchange wallet
            $exchange_wallets["account_" . $key] = array('link' => link_to($instance->getURL(), $instance->getName()), 'package' => Accounts::getDefiningPackage($key));
        }
    }
    $external_apis = array("Address balances" => $external_apis_addresses, "Block counts" => $external_apis_blockcounts, "Mining pool wallets" => $mining_pools, "Exchange wallets" => $exchange_wallets, "Exchange tickers" => $exchange_tickers, "Security exchanges" => array('securities_796' => '<a href="https://796.com">796 Xchange</a>', 'ticker_crypto-trade' => '<a href="https://crypto-trade.com">Crypto-Trade</a>', 'securities_cryptostocks' => '<a href="http://cryptostocks.com">Cryptostocks</a>', 'securities_havelock' => '<a href="https://www.havelockinvestments.com">Havelock Investments</a>', 'securities_update_cryptostocks' => '<a href="http://cryptostocks.com">Cryptostocks</a> Securities list', 'securities_update_havelock' => '<a href="https://www.havelockinvestments.com">Havelock Investments</a> Securities list', 'securities_update_litecoininvest' => '<a href="https://litecoininvest.com">Litecoininvest</a> Securities list', 'cryptostocks' => '<a href="http://cryptostocks.com">Cryptostocks</a>', 'havelock' => '<a href="https://www.havelockinvestments.com">Havelock Investments</a>', 'litecoininvest' => '<a href="https://litecoininvest.com">Litecoininvest</a>'), "Individual securities" => array('individual_crypto-trade' => '<a href="https://crypto-trade.com">Crypto-Trade</a>', 'individual_cryptostocks' => '<a href="http://cryptostocks.com">Cryptostocks</a>', 'individual_havelock' => '<a href="https://www.havelockinvestments.com">Havelock Investments</a>', 'individual_litecoininvest' => '<a href="https://litecoininvest.com">Litecoininvest</a>'), "Other" => array('outstanding' => '<a href="' . htmlspecialchars(url_for('premium')) . '">Premium account</a> processing'));
    // convert to new format
    foreach ($external_apis as $group => $data) {
        foreach ($data as $key => $value) {
            if (!is_array($value)) {
                $external_apis[$group][$key] = array('link' => $value);
            }
        }
    }
    return $external_apis;
}