Esempio n. 1
0
function get_knowledge_base()
{
    $kb = array(t('Concepts') => array('cryptocurrencies' => array('title' => t("What are cryptocurrencies?"), 'inline' => 'inline_cryptocurrencies'), 'versions' => array('title' => t(":site_name Version History"), 'inline' => 'inline_versions', 'new' => true)), t('Interface') => array('bitcoin_csv' => t("How do I upload a Bitcoin-Qt CSV file?"), 'litecoin_csv' => t("How do I upload a Litecoin-Qt CSV file?"), 'notifications' => array('title' => t("How do automated notifications work?"), 'inline' => 'inline_notifications'), 'managed_graphs' => array('title' => t("How are graphs automatically managed?"), 'inline' => 'inline_managed_graphs'), 'graph_refresh' => array('title' => t("Do graphs live update?"), 'inline' => 'inline_graph_refresh'), 'finance' => array('title' => t("What is :site_name Finance?"), 'inline' => 'inline_finance', 'new' => true)), t('Accounts') => array('add_currency' => array('title' => t("Can you add support for another cryptocurrency?"), 'inline' => 'inline_add_currency'), 'add_fiat' => array('title' => t("Can you add support for another fiat currency?"), 'inline' => 'inline_add_fiat'), 'add_service' => array('title' => t("Can you add support for another exchange/mining pool?"), 'inline' => 'inline_add_service')), t('Notifications') => array('notifications_ticker' => array('title' => t("How do I get notified of exchange rate changes?"), 'inline' => 'inline_notifications_ticker'), 'notifications_reports' => array('title' => t("How do I get notified of changes in my reports?"), 'inline' => 'inline_notifications_reports'), 'notifications_hashrates' => array('title' => t("How do I get notified of changes in my hashrates?"), 'inline' => 'inline_notifications_hashrates')), t('Finance') => array('transaction_creation' => array('title' => t("How are transactions automatically created?"), 'inline' => 'inline_transaction_creation', 'new' => true)));
    // automatically construct KB for adding accounts through the wizards
    $wizards = array("Mining pools" => 'mining pool account', "Exchanges" => 'exchange account', "Securities" => 'securities exchange account', "Individual Securities" => 'securities', "Other" => '');
    foreach (account_data_grouped() as $label => $group) {
        if (isset($wizards[$label])) {
            foreach ($group as $key => $data) {
                if ($data['disabled']) {
                    continue;
                }
                if ($label == 'Individual Securities') {
                    $title = 'How do I add individual ' . get_exchange_name($data['exchange']) . (isset($data['suffix']) ? $data['suffix'] : '') . ($wizards[$label] ? ' ' . $wizards[$label] : '') . '?';
                } else {
                    $title = 'How do I add a ' . get_exchange_name($key) . (isset($data['suffix']) ? $data['suffix'] : '') . ($wizards[$label] ? ' ' . $wizards[$label] : '') . '?';
                }
                $kb[t('Accounts')][$key] = array('title' => $title, 'inline' => 'inline_accounts_' . $key, 'new' => in_array($key, get_new_supported_wallets()) || in_array($key, get_new_exchanges()) || in_array($key, get_new_security_exchanges()) || isset($data['exchange']) && in_array($data['exchange'], get_new_security_exchanges()));
            }
        }
    }
    // sort each section by title
    foreach ($kb as $label => $group) {
        uasort($kb[$label], '_sort_get_knowledge_base');
    }
    return $kb;
}
Esempio n. 2
0
 function testGenerate()
 {
     $templates = array('currencies_list' => array(), 'currencies_inline' => array(), 'fiat_currencies_list' => array(), 'fiat_currencies_inline' => array(), 'crypto_currencies_list' => array(), 'crypto_currencies_inline' => array(), 'commodity_currencies_list' => array(), 'commodity_currencies_inline' => array(), 'exchange_wallets_list' => array(), 'mining_pools_list' => array(), 'securities_list' => array(), 'exchange_list' => array());
     foreach (get_all_currencies() as $cur) {
         $templates['currencies_list'][] = "  * " . get_currency_name($cur);
         $templates['currencies_inline'][] = get_currency_abbr($cur);
     }
     foreach (get_all_fiat_currencies() as $cur) {
         $templates['fiat_currencies_list'][] = "  * " . get_currency_name($cur);
         $templates['fiat_currencies_inline'][] = get_currency_abbr($cur);
     }
     foreach (get_all_cryptocurrencies() as $cur) {
         $templates['crypto_currencies_list'][] = "  * " . get_currency_name($cur);
         $templates['crypto_currencies_inline'][] = get_currency_abbr($cur);
     }
     foreach (get_all_commodity_currencies() as $cur) {
         $templates['commodity_currencies_list'][] = "  * " . get_currency_name($cur);
         $templates['commodity_currencies_inline'][] = get_currency_abbr($cur);
     }
     $grouped = account_data_grouped();
     foreach ($grouped['Exchanges'] as $key => $data) {
         if (!$data['disabled']) {
             $templates['exchange_wallets_list'][] = "  * " . get_exchange_name($key);
         }
     }
     foreach ($grouped['Mining pools'] as $key => $data) {
         if (!$data['disabled']) {
             $templates['mining_pools_list'][] = "  * " . get_exchange_name($key);
         }
     }
     foreach ($grouped['Securities'] as $key => $data) {
         if (!$data['disabled']) {
             $templates['securities_list'][] = "  * " . get_exchange_name($key);
         }
     }
     foreach (get_exchange_pairs() as $key => $pairs) {
         $templates['exchange_list'][] = "  * " . get_exchange_name($key);
     }
     $templates['currencies_list'] = implode("\n", array_unique($templates['currencies_list']));
     $templates['fiat_currencies_list'] = implode("\n", array_unique($templates['fiat_currencies_list']));
     $templates['crypto_currencies_list'] = implode("\n", array_unique($templates['crypto_currencies_list']));
     $templates['commodity_currencies_list'] = implode("\n", array_unique($templates['commodity_currencies_list']));
     $templates['exchange_wallets_list'] = implode("\n", array_unique($templates['exchange_wallets_list']));
     $templates['mining_pools_list'] = implode("\n", array_unique($templates['mining_pools_list']));
     $templates['securities_list'] = implode("\n", array_unique($templates['securities_list']));
     $templates['exchange_list'] = implode("\n", array_unique($templates['exchange_list']));
     $templates['currencies_inline'] = implode(", ", array_unique($templates['currencies_inline']));
     $templates['fiat_currencies_inline'] = implode(", ", array_unique($templates['fiat_currencies_inline']));
     $templates['crypto_currencies_inline'] = implode(", ", array_unique($templates['crypto_currencies_inline']));
     $templates['commodity_currencies_inline'] = implode(", ", array_unique($templates['commodity_currencies_inline']));
     // load the template
     $input = file_get_contents(__DIR__ . "/../README.template.md");
     foreach ($templates as $key => $value) {
         $input = str_replace('{$' . $key . '}', $value, $input);
     }
     // write it out
     file_put_contents(__DIR__ . "/../README.md", $input);
 }
Esempio n. 3
0
function get_exchange_or_currency_name($exchange)
{
    $account_data_grouped = account_data_grouped();
    if (isset($account_data_grouped['Addresses'][$exchange])) {
        return $account_data_grouped['Addresses'][$exchange]['title'];
    } else {
        return get_exchange_name($exchange);
    }
}
 /**
  * Test a BTC/DOGE exchange increase notification, particularly the precision.
  * Issue #257
  */
 function testDogecoin()
 {
     // create a notification
     $id = $this->createNotificationTicker($this->user, array('exchange' => get_default_currency_exchange('dog'), 'currency1' => 'btc', 'currency2' => 'dog'));
     $arg_id = $this->createNotification($this->user, array('last_value' => 2.0E-7, 'notification_type' => 'ticker', 'type_id' => $id, 'trigger_condition' => 'increases', 'trigger_value' => 1, 'is_percent' => 0));
     // execute the job
     $this->executeJob($this->user, $arg_id);
     $mails = $this->getMails();
     $this->assertEquals(1, count($mails));
     $exchange_name = get_exchange_name(get_default_currency_exchange('dog'));
     $this->assertHasLine("The exchange rate on {$exchange_name} for BTC/DOGE has increased, from 0.00000020 BTC/DOGE to 0.00000030 BTC/DOGE (50%), in the last hour.", $mails[0]);
 }
Esempio n. 5
0
 public function getData($days)
 {
     $key_column = array('type' => 'string', 'title' => get_exchange_name($this->exchange));
     $columns = array();
     $columns[] = array('type' => 'string', 'title' => ct("Price"), 'heading' => true);
     $columns[] = array('type' => 'string', 'title' => ct("Value"));
     $data = array();
     $q = db()->prepare("SELECT * FROM ticker_recent WHERE exchange=:exchange AND currency1=:currency1 AND currency2=:currency2");
     $q->execute(array('exchange' => $this->exchange, 'currency1' => $this->currency1, 'currency2' => $this->currency2));
     if ($ticker = $q->fetch()) {
         $last_updated = $ticker['created_at'];
         $data[] = array('Bid', currency_format($this->currency1, $ticker['bid'], 4));
         $data[] = array('Ask', currency_format($this->currency1, $ticker['ask'], 4));
     } else {
         throw new GraphException(t("No recent rates found for :exchange :pair", $this->getTitleArgs()));
     }
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated, 'no_header' => true);
 }
Esempio n. 6
0
 public function getData($days)
 {
     $key_column = array('type' => 'string', 'title' => ct("Currency"));
     $columns = array();
     // get data
     // TODO could probably cache this
     $q = db()->prepare("SELECT SUM(balance) AS balance, exchange, MAX(created_at) AS created_at FROM balances WHERE user_id=? AND is_recent=1 AND currency=? GROUP BY exchange");
     $q->execute(array($this->getUser(), $this->currency));
     $balances = $q->fetchAll();
     // need to also get address balances
     $summary_balances = get_all_summary_instances($this->getUser());
     // get additional balances
     $data = array();
     if (isset($summary_balances['blockchain' . $this->currency]) && $summary_balances['blockchain' . $this->currency]['balance'] != 0) {
         $balances[] = array("balance" => $summary_balances['blockchain' . $this->currency]['balance'], "exchange" => "blockchain", "created_at" => $summary_balances['blockchain' . $this->currency]['created_at']);
     }
     if (isset($summary_balances['offsets' . $this->currency]) && $summary_balances['offsets' . $this->currency]['balance'] != 0) {
         $balances[] = array("balance" => $summary_balances['offsets' . $this->currency]['balance'], "exchange" => "offsets", "created_at" => $summary_balances['offsets' . $this->currency]['created_at']);
     }
     // sort by balance
     usort($balances, array($this, 'sort_by_balance_desc'));
     $last_updated = find_latest_created_at($balances);
     // apply demo_scale and calculate total summary
     $data = array();
     $total = 0;
     foreach ($balances as $b) {
         if ($b['balance'] != 0) {
             $columns[] = array('type' => 'number', 'title' => get_exchange_name($b['exchange']));
             $data[] = demo_scale($b['balance']);
             $total += demo_scale($b['balance']);
         }
     }
     // return a more helpful message if there is no data
     if (!$data) {
         throw new NoDataGraphException_AddAccountsAddresses();
     }
     // sort data by balance
     $data = array(get_currency_abbr($this->currency) => $data);
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated);
 }
Esempio n. 7
0
 public function getData($days)
 {
     $columns = array();
     $key_column = array('type' => 'string', 'title' => ct("Key"));
     $columns[] = array('type' => 'string', 'title' => ct("Exchange"), 'heading' => true);
     $columns[] = array('type' => 'string', 'title' => ct("Price"));
     $columns[] = array('type' => 'string', 'title' => ct("Volume"));
     $q = db()->prepare("SELECT * FROM ticker_recent WHERE currency1=? AND currency2=? ORDER BY volume DESC");
     $q->execute(array($this->currency1, $this->currency2));
     $tickers = $q->fetchAll();
     $q = db()->prepare("SELECT * FROM average_market_count WHERE currency1=? AND currency2=?");
     $q->execute(array($this->currency1, $this->currency2));
     $market_count = $q->fetch();
     $average = false;
     foreach ($tickers as $ticker) {
         if ($ticker['exchange'] == 'average') {
             $average = $ticker;
         }
     }
     if (!$average) {
         throw new RenderGraphException(t("Could not find any average data"));
     }
     $volume_currency = $average['currency2'];
     // generate the table of data
     $data = array();
     foreach ($tickers as $ticker) {
         if ($ticker['exchange'] == "average") {
             continue;
         }
         if ($ticker['volume'] == 0) {
             continue;
         }
         $id = $ticker['exchange'] . "_" . $ticker['currency1'] . $ticker['currency2'] . "_daily";
         $data[$ticker['exchange']] = array("<a href=\"" . htmlspecialchars(url_for('historical', array('id' => $id, 'days' => 180))) . "\">" . get_exchange_name($ticker['exchange']) . "</a>", $this->average_currency_format_html($ticker['last_trade'], $ticker['last_trade']), currency_format($volume_currency, $ticker['volume'], 0) . " (" . ($average['volume'] == 0 ? "-" : number_format($ticker['volume'] * 100 / $average['volume']) . "%") . ")");
     }
     $last_updated = $average['created_at'];
     return array('key' => $key_column, 'columns' => $columns, 'data' => $data, 'last_updated' => $last_updated, 'h1' => get_currency_abbr($average['currency1']) . "/" . get_currency_abbr($average['currency2']) . ": " . currency_format($average['currency1'], $average['last_trade']), 'h2' => "(" . number_format($average['volume']) . " " . get_currency_abbr($volume_currency) . " total volume)");
 }
<?php

$account_data = array('exchange_name' => get_exchange_name('cryptopools_dgc'));
?>

<div class="instructions_add">
<h2>Adding a <?php 
echo $account_data['exchange_name'];
?>
 account</h2>

<ol class="steps">
	<li>Log into your <?php 
echo $account_data['exchange_name'];
?>
 account
		and visit your <a href="http://dgc.cryptopools.com/index.php?page=account&amp;action=edit">Edit Account page</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/cryptopools_dgc1.png'));
?>
"></li>

	<li>Copy and paste your <i>API Key</i> into the <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_pools'));
?>
">"Add new Mining Pool" form</a>, and click "Add account".<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/cryptopools_dgc2.png'));
?>
"></li>
</ol>
<?php

$account_data = array('exchange_name' => get_exchange_name('havelock'));
?>

<div class="instructions_add">
<h2>Adding a Havelock Investments account</h2>

<ol class="steps">
	<li>Log into your <a href="https://www.havelockinvestments.com/api.php">Havelock Investments account</a> and visit your <i>API Setup</i>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/havelock1.png'));
?>
"></li>

	<li>Create a new API key by entering in a <i>Key Name</i> and clicking "Create Key".<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/havelock2.png'));
?>
"></li>

	<li>For this new key, select the <i>Portfolio</i> and <i>Balance</i> permissions, and click "Save Key Permissions".<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/havelock3.png'));
?>
"></li>

	<li>Copy and paste this long <i>API Key</i> into the <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_securities'));
?>
">"Add new Securities Exchange" form</a>, and click "Add account".<br>
require __DIR__ . "/../layout/templates.php";
$user = get_user(user_id());
require_user($user);
$exchange = require_get('exchange');
$id = require_get('id');
// make sure that we actually have a valid account
$account_data = false;
$accounts = array();
foreach (account_data_grouped() as $label => $data) {
    foreach ($data as $key => $value) {
        if ($key == $exchange) {
            // we've found a valid account type
            $account_data = get_accounts_wizard_config($key);
            $account_type = get_wizard_account_type($value['wizard']);
            $add_types[] = $key;
            $add_type_names[$key] = get_exchange_name($key) . (isset($value['suffix']) ? $value['suffix'] : "");
            $q = db()->prepare("SELECT * FROM " . $account_data['table'] . "\n        WHERE user_id=? AND id=? ORDER BY title ASC");
            $q->execute(array(user_id(), $id));
            while ($r = $q->fetch()) {
                $r['exchange'] = $key;
                $r['khash'] = $account_data['khash'];
                $accounts[] = $r;
            }
        }
    }
}
if (!$account_data) {
    throw new Exception("No account data found for exchange '" . htmlspecialchars($exchange) . "'");
}
// no header or footer; we just output straight HTML
// uses $accounts to generate rows;
Esempio n. 11
0
<dt>7 November</dt>
<dd>
  Added currency support for <a href="https://www.reddcoin.com/" class="currency_name_rdd">Reddcoin</a>
  and <a href="http://viacoin.org/" class="currency_name_via">Viacoin</a>;

  added <a href="https://www.nicehash.com/">NiceHash</a>,
  <a href="https://westhash.com/">WestHash</a>,
  <a href="https://hash-to-coins.com/">Hash-to-coins</a> and
  <a href="https://www.eobot.com/">Eobot</a> mining pools;

  added <a href="https://btclevels.com/">BTClevels</a> accounts;

  disabled <a href="https://www.scryptguild.com/">ScryptGuild</a>,
  <a href="http://ltcmine.ru/">LTCMine.ru</a>,
  <a href="http://beeeeer.org/"><?php 
echo htmlspecialchars(get_exchange_name('beeeeer'));
?>
</a> and
  <a href="https://doge.rapidhash.net/">RapidHash</a> mining pools;

  fixed <span class="currency_name_xpm">XPM</span> addresses and
  <a href="https://nvc.khore.org">nvc.khore.org</a> accounts not updating;

  updated example graph images.
</dd>

<dt>10 September</dt>
<dd>
  Added currency support for <a href="https://www.darkcoin.io/" class="currency_name_drk">Darkcoin</a>,
  <a href="http://www.vericoin.info/" class="currency_name_vrc">Vericoin</a>,
  <a href="http://nxt.org/" class="currency_name_nxt">Nxt</a>,
<?php

$account_data = array('exchange_name' => get_exchange_name('ozcoin_btc'));
?>

<div class="instructions_add">
<h2>Adding a <?php 
echo $account_data['exchange_name'];
?>
 account</h2>

<ol class="steps">
  <li>Log into your <?php 
echo $account_data['exchange_name'];
?>
 account
    and visit your <a href="http://ozco.in/content/api-key">API Key page</a>.<br>
    <img src="<?php 
echo htmlspecialchars(url_for('img/accounts/ozcoin_btc1.png'));
?>
"></li>

  <li>Copy and paste your <i>API Key</i> into the <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_pools'));
?>
">"Add new Mining Pool" form</a>, and click "Add account".<br>
    <img src="<?php 
echo htmlspecialchars(url_for('img/accounts/ozcoin_btc2.png'));
?>
"></li>
</ol>
<?php

$account_data = array('exchange_name' => get_exchange_name('d2_wdc'));
?>

<div class="instructions_add">
<h2>Adding a <?php 
echo $account_data['exchange_name'];
?>
 account</h2>

<ol class="steps">
  <li>Log into your <a href="https://wdc.d2.cc/accountdetails.php"><?php 
echo $account_data['exchange_name'];
?>
 account details</a>.<br>
    <img src="<?php 
echo htmlspecialchars(url_for('img/accounts/d2_wdc1.png'));
?>
"></li>

  <li>Find your <i>API Key</i>, as illustrated below: <br>
    <img src="<?php 
echo htmlspecialchars(url_for('img/accounts/d2_wdc2.png'));
?>
"></li>

  <li>Copy and paste this <i>API Key</i> into the <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_pools'));
?>
">"Add new Mining Pool" form</a>, and click "Add account".</li>
<?php

$exchange = get_exchange_name("crypto-trade");
$example = "ESB";
?>

<div class="instructions_add">
<h2>Adding individual <?php 
echo htmlspecialchars($exchange);
?>
 securities</h2>

<ol class="steps">
	<li>As of Openclerk 0.10, you can manually add quantities of privately-owned securities
		to your portfolio, and estimate their value against those traded on <?php 
echo htmlspecialchars($exchange);
?>
,
		by visiting your <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_individual_securities'));
?>
">"Individual Securities" wizard page</a>
		through your <a href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_securities'));
?>
">"Securities" wizard page</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/individual_securities.png'));
?>
"></li>
	</li>
<?php

$exchange = get_exchange_name("cryptostocks");
$example = "ABT";
?>

<div class="instructions_add">
<h2>Adding individual <?php 
echo htmlspecialchars($exchange);
?>
 securities</h2>

<ol class="steps">
	<li>As of Openclerk 0.10, you can manually add quantities of privately-owned securities
		to your portfolio, and estimate their value against those traded on <?php 
echo htmlspecialchars($exchange);
?>
,
		by visiting your <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_individual_securities'));
?>
">"Individual Securities" wizard page</a>
		through your <a href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_securities'));
?>
">"Securities" wizard page</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/individual_securities.png'));
?>
"></li>
	</li>
<?php

$exchange = get_exchange_name("litecoinglobal");
$example = "ASICMINER1K-PT";
$url = url_for('historical', array('id' => 'securities_litecoininvest_ltc', 'days' => 180, 'name' => $example));
?>

<div class="instructions_add">
<h2>Adding individual <?php 
echo htmlspecialchars($exchange);
?>
 securities</h2>

<ol class="steps">
	<li>As of Openclerk 0.10, you can manually add quantities of privately-owned securities
		to your portfolio, and estimate their value against those traded on <?php 
echo htmlspecialchars($exchange);
?>
,
		by visiting your <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_individual_securities'));
?>
">"Individual Securities" wizard page</a>
		through your <a href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_securities'));
?>
">"Securities" wizard page</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/individual_securities.png'));
?>
"></li>
Esempio n. 17
0
     case "decreases_by":
         $change_text = "decreased by at least " . number_format_human($notification['trigger_value']) . ($notification['is_percent'] ? '%' : " " . $value_label);
         break;
     case "below":
         $change_text = "decreased below " . number_format_human($notification['trigger_value']) . " " . $value_label;
         break;
     default:
         throw new JobException("Unknown trigger condition for change text: '" . $notification['trigger_condition'] . "'");
 }
 // send the email
 if ($user['email']) {
     $args = array("name" => $user['name'] ? $user['name'] : $user['email'], "url" => absolute_url(url_for('wizard_notifications')), "profile" => absolute_url(url_for('profile')), "last_value" => number_format_human($notification['last_value']), "current_value" => number_format_human($current_value), "value_label" => $value_label, "value_delta" => number_format_human($value_delta), "percent" => $percent === null ? "infinite%" : number_format_human($percent * 100, -1), "change_text" => $change_text, "period" => $notification['period']);
     switch ($notification['notification_type']) {
         case "ticker":
             $email_template = 'notification_ticker';
             $args += array("exchange" => get_exchange_name($account['exchange']), "currency1" => get_currency_abbr($account['currency1']), "currency2" => get_currency_abbr($account['currency2']));
             break;
         case "summary_instance":
             $email_template = 'notification_summary_instance';
             if (substr($account['summary_type'], 0, strlen('totalmh_')) == 'totalmh_') {
                 $currency = substr($account['summary_type'], strlen('totalmh_'));
                 $args += array("label" => "total " . get_currency_abbr($currency) . " hashrate");
             } else {
                 if (substr($account['summary_type'], 0, strlen('total')) == 'total') {
                     $currency = substr($account['summary_type'], strlen('total'));
                     $args += array("label" => "total " . get_currency_abbr($currency));
                 } else {
                     if (substr($account['summary_type'], 0, strlen('all2')) == 'all2') {
                         $summary_type = substr($account['summary_type'], strlen('all2'));
                         $summary_types = get_total_conversion_summary_types();
                         $args += array("label" => "converted " . $summary_types[$summary_type]['short_title']);
<?php

$account_data = array('exchange_name' => get_exchange_name('liteguardian'));
?>

<div class="instructions_add">
<h2>Adding a LiteGuardian account</h2>

<ol class="steps">
	<li>Log into your <a href="https://www.liteguardian.com/secure/user/manageAccount">LiteGuardian account details</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/liteguardian1.png'));
?>
"></li>

	<li>Find your <i>Api Key</i>, as illustrated below: <br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/liteguardian2.png'));
?>
"></li>

	<li>Copy and paste this <i>Api Key</i> into the <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_pools'));
?>
">"Add new Mining Pool" form</a>, and click "Add account".</li>
</ol>
</div>

<div class="instructions_safe">
<h2>Is it safe to provide <?php 
echo htmlspecialchars(get_site_config('site_name'));
Esempio n. 19
0
/**
 * Return some text describing the default exchanges used for the given currencies.
 * For example:
 *  array('ltc', 'ftc', 'usd', 'ghs') => 'BTC-e for LTC/FTC, Mt.Gox for USD, CEX.io for GHS'
 * @see get_default_currency_exchange()
 */
function get_default_exchange_text($currencies)
{
    $result = array();
    foreach ($currencies as $c) {
        $default = get_default_currency_exchange($c);
        if (!isset($result[$default])) {
            $result[$default] = array();
        }
        $result[$default][] = get_currency_abbr($c);
    }
    $result2 = array();
    foreach ($result as $exchange => $currencies) {
        $result2[] = get_exchange_name($exchange) . " for " . implode("/", $currencies);
    }
    return implode(", ", $result2);
}
<?php

$account_data = array('exchange_name' => get_exchange_name('bitmarket_pl'));
?>

<div class="instructions_add">
<h2>Adding a <?php 
echo $account_data['exchange_name'];
?>
 account</h2>

<ol class="steps">
	<li>Log into your <a href="https://www.bitmarket.pl/account.php"><?php 
echo $account_data['exchange_name'];
?>
 account ("Konto")</a> and visit the
		<a href="https://www.bitmarket.pl/apikeys.php"><i>API Keys</i> section</a> (<i>Dostęp API</i>).<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/bitmarket_pl1.png'));
?>
"></li>

	<li>Click on the "Generate new API key" button (<i>"Wygeneruj nowy klucz API"</i>).<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/bitmarket_pl2.png'));
?>
"></li>

	<li>Make sure that <i>only</i> the "account balances" (<i>"Pobranie informacji o koncie"</i>) permission is selected,
		and click "generate new key" (<i>"wygeneruj nowy klucz"</i>).<br>
		<img src="<?php 
<?php

$account_data = array('exchange_name' => get_exchange_name('westhash'));
?>

<div class="instructions_add">
<h2>Adding a <?php 
echo $account_data['exchange_name'];
?>
 account</h2>

<ol class="steps">
	<li>Log into your <?php 
echo $account_data['exchange_name'];
?>
 account
		and visit your <a href="https://www.westhash.com/index.jsp?p=account">Account page</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/westhash1.png'));
?>
"></li>

	<li>Copy and paste your <i>API ID</i> and <i>ReadOnly API Key</i> into the <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_pools'));
?>
">"Add new Mining Pool" form</a>, and click "Add account".<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/westhash2.png'));
?>
"></li>
</ol>
<?php

$account_data = array('exchange_name' => get_exchange_name('vircurex'));
?>

<div class="instructions_add">
<h2>Adding a Vircurex account</h2>

<ol class="steps">
	<li>Log into your <a href="https://vircurex.com/accounts">Vircurex account</a> and visit <i>Settings</i> in the top right navigation.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/vircurex1.png'));
?>
"></li>

	<li>Under the <i>API tab</i>, check <i>Get balance</i>, insert in any random secret string - for example,
		you can use <a href="https://www.grc.com/passwords.htm">GRC&apos;s random password generator</a> to generate
		a 63-character random alphanumeric string - and click <i>Save</i>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/vircurex2.png'));
?>
"></li>

	<li>Copy and paste your both your username and your chosen random secret string into the <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_exchanges'));
?>
">"Add new Exchange" form</a>, and click "Add account".</li>
</ol>
</div>

<div class="instructions_safe">
<?php

$exchange = get_exchange_name("havelock");
$example = "ASICMINER";
?>

<div class="instructions_add">
<h2>Adding individual <?php 
echo htmlspecialchars($exchange);
?>
 securities</h2>

<ol class="steps">
	<li>As of Openclerk 0.10, you can manually add quantities of privately-owned securities
		to your portfolio, and estimate their value against those traded on <?php 
echo htmlspecialchars($exchange);
?>
,
		by visiting your <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_individual_securities'));
?>
">"Individual Securities" wizard page</a>
		through your <a href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_securities'));
?>
">"Securities" wizard page</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/individual_securities.png'));
?>
"></li>
	</li>
<?php

$account_data = array('exchange_name' => get_exchange_name('kraken'));
?>

<div class="instructions_add">
<h2>Adding a <?php 
echo $account_data['exchange_name'];
?>
 account</h2>

<ol class="steps">
	<li>Log into <a href="https://www.kraken.com/u/settings/account">your <?php 
echo $account_data['exchange_name'];
?>
 account</a> and visit your <i>Settings</i> page.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/kraken1.png'));
?>
"></li>

	<li>Visit your <a href="https://www.kraken.com/u/settings/api">API settings</a> page.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/kraken2.png'));
?>
"></li>

	<li>Click on the <i>Generate New Key</i> button to create a new API key.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/kraken3.png'));
?>
<?php

$exchange = get_exchange_name("796");
$example = "ASICMINER-796";
?>

<div class="instructions_add">
<h2>Adding individual <?php 
echo htmlspecialchars($exchange);
?>
 securities</h2>

<ol class="steps">
	<li>As of Openclerk 0.10, you can manually add quantities of privately-owned securities
		to your portfolio, and estimate their value against those traded on <?php 
echo htmlspecialchars($exchange);
?>
,
		by visiting your <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_individual_securities'));
?>
">"Individual Securities" wizard page</a>
		through your <a href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_securities'));
?>
">"Securities" wizard page</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/individual_securities.png'));
?>
"></li>
	</li>
Esempio n. 26
0
<?php

$account_data = array('exchange_name' => get_exchange_name('btce'));
?>

<div class="instructions_add">
<h2>Adding a <?php 
echo $account_data['exchange_name'];
?>
 account</h2>

<ol class="steps">
	<li>Log into your <a href="https://btc-e.com/profile"><?php 
echo $account_data['exchange_name'];
?>
 profile</a>.<br>
	<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/btce1.png'));
?>
"></li>

	<li>From the profile, select <i>API keys</i>.<br>
	<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/btce2.png'));
?>
"></li>

	<li>Create a name for a new key (such as "<?php 
echo htmlspecialchars(get_site_config('site_name'));
?>
") and click <i>Create</i>.<br>
Esempio n. 27
0
 /**
  * Implements failing tables; if an account type fails multiple times,
  * then send the user an email and disable the account.
  * @see OpenclerkJobQueuer#getStandardJobs()
  */
 function failed(\Exception $runtime_exception, Connection $db, Logger $logger)
 {
     // is this a standard job?
     $standard = $this->findStandardJob();
     if ($standard) {
         $logger->info("Using standard job " . print_r($standard, true));
         if (!$standard['failure']) {
             $logger->info("Not a failure standard job");
             return;
         }
     } else {
         return;
     }
     $failing_table = $standard['table'];
     $job = $this->job;
     // find the relevant account_data for this standard job
     $account_data = false;
     foreach (account_data_grouped() as $label => $group) {
         foreach ($group as $exchange => $data) {
             if (isset($data['job_type']) && $job['job_type'] == $data['job_type']) {
                 $account_data = $data;
                 $account_data['exchange'] = $exchange;
                 break;
             }
         }
     }
     if (!$account_data) {
         $logger->warn("Could not find any account data for job type '" . $job['job_type'] . "'");
     }
     $logger->info("Using account data " . print_r($account_data, true));
     // don't count CloudFlare as a failure
     if ($runtime_exception instanceof CloudFlareException || $runtime_exception instanceof \Openclerk\Apis\CloudFlareException) {
         $logger->info("Not increasing failure count: was a CloudFlareException");
     } else {
         if ($runtime_exception instanceof IncapsulaException || $runtime_exception instanceof \Openclerk\Apis\IncapsulaException) {
             $logger->info("Not increasing failure count: was a IncapsulaException");
         } else {
             if ($runtime_exception instanceof BlockchainException || $runtime_exception instanceof \Core\BlockchainException) {
                 $logger->info("Not increasing failure count: was a BlockchainException");
             } else {
                 $q = $db->prepare("UPDATE {$failing_table} SET failures=failures+1,first_failure=IF(ISNULL(first_failure), NOW(), first_failure) WHERE id=?");
                 $q->execute(array($job['arg_id']));
                 $logger->info("Increasing account failure count");
             }
         }
     }
     $user = get_user($job['user_id']);
     if (!$user) {
         $logger->info("Warning: No user " . $job['user_id'] . " found");
     } else {
         // failed too many times?
         $q = $db->prepare("SELECT * FROM {$failing_table} WHERE id=? LIMIT 1");
         $q->execute(array($job['arg_id']));
         $account = $q->fetch();
         $logger->info("Current account failure count: " . number_format($account['failures']));
         if ($account['failures'] >= get_premium_value($user, 'max_failures')) {
             // disable it and send an email
             $q = $db->prepare("UPDATE {$failing_table} SET is_disabled=1 WHERE id=?");
             $q->execute(array($job['arg_id']));
             crypto_log(print_r($account_data, true));
             if ($user['email'] && !$account['is_disabled']) {
                 $email_type = $job['job_type'] == "notification" ? "failure_notification" : "failure";
                 send_user_email($user, $email_type, array("name" => $user['name'] ? $user['name'] : $user['email'], "exchange" => get_exchange_name($account_data['exchange']), "label" => $account_data['label'], "labels" => $account_data['labels'], "failures" => number_format($account['failures']), "message" => $runtime_exception->getMessage(), "length" => recent_format(strtotime($account['first_failure']), "", ""), "title" => isset($account['title']) && $account['title'] ? "\"" . $account['title'] . "\"" : "untitled", "url" => absolute_url(url_for("wizard_accounts"))));
                 $logger->info("Sent failure e-mail to " . htmlspecialchars($user['email']) . ".");
             }
         }
     }
 }
Esempio n. 28
0
    // (this will hide them from the Your Securities page as well)
    $q = db()->prepare("UPDATE securities SET is_recent=0 WHERE user_id=? AND exchange=? AND account_id=?");
    $q->execute(array(user_id(), $account_data['exchange'], require_post("id")));
    $messages[] = t("Removed :title.", array(':title' => htmlspecialchars($account_data['title'])));
    // redirect to GET
    set_temporary_errors($errors);
    set_temporary_messages($messages);
    redirect(url_for(require_post("callback")));
}
// process 'test'
if (require_post('test', false) && require_post('id', false)) {
    // do we already have a job queued up?
    $q = db()->prepare("SELECT * FROM jobs WHERE is_executed=0 AND user_id=? AND is_test_job=1 LIMIT 1");
    $q->execute(array(user_id()));
    if ($job = $q->fetch()) {
        $errors[] = t("Cannot create a :title test, because you already have a :type test pending.", array(':title' => htmlspecialchars($account_data['title']), ':type' => get_exchange_name($job['job_type'])));
    } else {
        if ($account_data['disabled']) {
            $errors[] = t("Cannot test that job; that account type is disabled.");
        } else {
            $q = db()->prepare("INSERT INTO jobs SET\n      job_type=:job_type,\n      job_prefix=:job_prefix,\n      user_id=:user_id,\n      arg_id=:arg_id,\n      priority=:priority,\n      is_test_job=1");
            $q->execute(array('job_type' => $account_data['job_type'], 'job_prefix' => \Openclerk\Jobs\JobQueuer::getJobPrefix($account_data['exchange']), 'user_id' => user_id(), 'arg_id' => require_post('id'), 'priority' => get_site_config('job_test_priority')));
            $messages[] = t("Queued up a new :title test; results should be available shortly.", array(':title' => htmlspecialchars($account_data['title'])));
            set_temporary_messages($messages);
            redirect(url_for(require_post("callback")));
        }
    }
}
// process 'enable'
if (require_post('enable', false) && require_post('id', false)) {
    if (!can_user_add($user, $account_data['exchange'])) {
<?php

$account_data = array('exchange_name' => get_exchange_name('litecoinpool'));
?>

<div class="instructions_add">
<h2>Adding a <?php 
echo $account_data['exchange_name'];
?>
 account</h2>

<ol class="steps">
	<li>Log into your <?php 
echo $account_data['exchange_name'];
?>
 account
		and visit your <a href="https://www.litecoinpool.org/account">My Account page</a>.<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/litecoinpool1.png'));
?>
"></li>

	<li>Copy and paste your <i>API Key</i> into the <a class="wizard_link" href="<?php 
echo htmlspecialchars(url_for('wizard_accounts_pools'));
?>
">"Add new Mining Pool" form</a>, and click "Add account".<br>
		<img src="<?php 
echo htmlspecialchars(url_for('img/accounts/litecoinpool2.png'));
?>
"></li>
</ol>
Esempio n. 30
0
 public function getTitleArgs()
 {
     return array(':exchange' => get_exchange_name($this->exchange), ':pair' => get_currency_abbr($this->currency1) . "/" . get_currency_abbr($this->currency2));
 }