Пример #1
0
 function run(Connection $db, Logger $logger)
 {
     $job = $this->job;
     switch ($job['job_type']) {
         // average jobs
         case "average":
             require __DIR__ . "/../jobs/average.php";
             break;
             // account jobs
         // account jobs
         case "generic":
             require __DIR__ . "/../jobs/generic.php";
             break;
         case "cryptostocks":
             require __DIR__ . "/../jobs/cryptostocks.php";
             break;
         case "securities_cryptostocks":
             require __DIR__ . "/../jobs/securities_cryptostocks.php";
             break;
         case "havelock":
             require __DIR__ . "/../jobs/havelock.php";
             break;
         case "securities_havelock":
             require __DIR__ . "/../jobs/securities_havelock.php";
             break;
         case "securities_crypto-trade":
             require __DIR__ . "/../jobs/securities_cryptotrade.php";
             break;
         case "796":
             require __DIR__ . "/../jobs/796.php";
             break;
         case "securities_796":
             require __DIR__ . "/../jobs/securities_796.php";
             break;
         case "litecoininvest":
             require __DIR__ . "/../jobs/litecoininvest.php";
             break;
             // individual securities jobs
         // individual securities jobs
         case "individual_cryptostocks":
             require __DIR__ . "/../jobs/individual_cryptostocks.php";
             break;
         case "individual_havelock":
             require __DIR__ . "/../jobs/individual_havelock.php";
             break;
         case "individual_crypto-trade":
             require __DIR__ . "/../jobs/individual_crypto-trade.php";
             break;
         case "individual_796":
             require __DIR__ . "/../jobs/individual_796.php";
             break;
         case "individual_litecoininvest":
             require __DIR__ . "/../jobs/individual_litecoininvest.php";
             break;
             // summary jobs
         // summary jobs
         case "sum":
             require __DIR__ . "/../jobs/sum.php";
             break;
         case "securities_count":
             require __DIR__ . "/../jobs/securities_count.php";
             break;
             // notification jobs
         // notification jobs
         case "notification":
             require __DIR__ . "/../jobs/notification.php";
             break;
             // system jobs
         // system jobs
         case "securities_update":
             require __DIR__ . "/../jobs/securities_update.php";
             break;
         case "version_check":
             require __DIR__ . "/../jobs/version_check.php";
             break;
         case "vote_coins":
             require __DIR__ . "/../jobs/vote_coins.php";
             break;
         case "missing_average_find":
             require __DIR__ . "/../jobs/missing_average_find.php";
             break;
         case "missing_average":
             require __DIR__ . "/../jobs/missing_average.php";
             break;
             // transaction jobs
         // transaction jobs
         case "transaction_creator":
             require __DIR__ . "/../jobs/transaction_creator.php";
             break;
         case "transactions":
             require __DIR__ . "/../jobs/transactions.php";
             break;
             // cleanup jobs, admin jobs etc
         // cleanup jobs, admin jobs etc
         case "outstanding":
             require __DIR__ . "/../jobs/outstanding.php";
             break;
         case "expiring":
             require __DIR__ . "/../jobs/expiring.php";
             break;
         case "expire":
             require __DIR__ . "/../jobs/expire.php";
             break;
         case "cleanup":
             require __DIR__ . "/../jobs/cleanup.php";
             break;
         case "disable_warning":
             require __DIR__ . "/../jobs/disable_warning.php";
             break;
         case "disable":
             require __DIR__ . "/../jobs/disable.php";
             break;
         case "delete_user":
             require __DIR__ . "/../jobs/delete_user.php";
             break;
         default:
             if (substr($job['job_type'], 0, strlen("address_")) === "address_") {
                 // address job
                 $currency = substr($job['job_type'], strlen("address_"));
                 if (!in_array($currency, get_address_currencies())) {
                     throw new JobException("Currency {$currency} is not a valid address currency");
                 }
                 if (in_array($currency, \DiscoveredComponents\Currencies::getBalanceCurrencies())) {
                     require __DIR__ . "/../jobs/addresses/discovered.php";
                 } else {
                     // TODO eventually remove this block once we have no currencies that are also in getBalanceCurrencies()
                     if (!file_exists(__DIR__ . "/../jobs/addresses/" . safe_include_arg($currency) . ".php")) {
                         throw new JobException("Could not find any addresses/{$currency}.php include");
                     }
                     require __DIR__ . "/../jobs/addresses/" . safe_include_arg($currency) . ".php";
                 }
                 break;
             }
             if (substr($job['job_type'], 0, strlen("blockcount_")) === "blockcount_") {
                 // address job
                 $currency = substr($job['job_type'], strlen("blockcount_"));
                 if (!in_array($currency, \DiscoveredComponents\Currencies::getBlockCurrencies())) {
                     throw new JobException("Currency {$currency} is not a valid block currency");
                 }
                 require __DIR__ . "/../jobs/blockcount/discovered.php";
                 break;
             }
             if (substr($job['job_type'], 0, strlen("difficulty_")) === "difficulty_") {
                 // address job
                 $currency = substr($job['job_type'], strlen("difficulty_"));
                 if (!in_array($currency, \DiscoveredComponents\Currencies::getDifficultyCurrencies())) {
                     throw new JobException("Currency {$currency} is not a valid difficulty currency");
                 }
                 require __DIR__ . "/../jobs/difficulty/discovered.php";
                 break;
             }
             if (substr($job['job_type'], 0, strlen("markets_")) === "markets_") {
                 // address job
                 $exchange = substr($job['job_type'], strlen("markets_"));
                 if (!in_array($exchange, \DiscoveredComponents\Exchanges::getKeys())) {
                     throw new JobException("Exchange {$exchange} is not a valid exchange");
                 }
                 require __DIR__ . "/../jobs/markets/discovered.php";
                 break;
             }
             if (substr($job['job_type'], 0, strlen("ticker_")) === "ticker_") {
                 // address job
                 $exchange = substr($job['job_type'], strlen("ticker_"));
                 if (!in_array($exchange, \DiscoveredComponents\Exchanges::getKeys())) {
                     throw new JobException("Exchange {$exchange} is not a valid exchange");
                 }
                 require __DIR__ . "/../jobs/ticker/discovered.php";
                 break;
             }
             if (substr($job['job_type'], 0, strlen("currencies_")) === "currencies_") {
                 // address job
                 $exchange = substr($job['job_type'], strlen("currencies_"));
                 if (!in_array($exchange, \DiscoveredComponents\Accounts::getKeys())) {
                     throw new JobException("Account {$exchange} is not a valid account");
                 }
                 require __DIR__ . "/../jobs/currencies/discovered.php";
                 break;
             }
             if (substr($job['job_type'], 0, strlen("hashrates_")) === "hashrates_") {
                 // address job
                 $exchange = substr($job['job_type'], strlen("hashrates_"));
                 if (!in_array($exchange, \DiscoveredComponents\Accounts::getMiners())) {
                     throw new JobException("Account {$exchange} is not a valid miner");
                 }
                 require __DIR__ . "/../jobs/hashrates/discovered.php";
                 break;
             }
             if (substr($job['job_type'], 0, strlen("account_")) === "account_") {
                 // address job
                 $exchange = substr($job['job_type'], strlen("account_"));
                 if (!in_array($exchange, \DiscoveredComponents\Accounts::getKeys())) {
                     throw new JobException("Account {$exchange} is not a valid account");
                 }
                 require __DIR__ . "/../jobs/account/discovered.php";
                 break;
             }
             throw new JobException("Unknown job type '" . htmlspecialchars($job['job_type']) . "'");
     }
 }
Пример #2
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;
}