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']) . "'"); } }
/** * Tests {@link safe_include_arg()}. */ function testSafeIncludeArg() { $this->assertEquals("foo", safe_include_arg("foo")); $this->assertEquals("foophp", safe_include_arg("foo.php")); $this->assertEquals("foo", safe_include_arg("/foo")); $this->assertEquals("foo", safe_include_arg("../foo")); }