Пример #1
0
    echo $job['is_test_job'] ? "yes" : "-";
    ?>
</td>
    <td class="<?php 
    echo $job['is_executing'] ? "yes" : "no";
    ?>
"><?php 
    echo $job['is_executing'] ? "yes" : "-";
    ?>
</td>
    <td><?php 
    echo number_format($job['execution_count']);
    ?>
</td>
    <td><?php 
    echo recent_format_html($job['created_at']);
    ?>
</td>
    <td><?php 
    echo $job['email'] ? htmlspecialchars($job['email']) : htmlspecialchars($job['user_id']);
    ?>
</td>
    <td><a href="<?php 
    echo htmlspecialchars(url_for('admin_run_job', array('job_id' => $job['id'])));
    ?>
">Run now</a></td>
  </tr>
  <?php 
}
?>
</tbody>
Пример #2
0
<h1><?php 
echo t("Support :site_name with Premium Accounts");
?>
</h1>

<?php 
if (user_logged_in() && ($user = get_user(user_id()))) {
    if ($user['is_premium']) {
        ?>
	<div class="success success_float">
		<?php 
        echo t("Thank you for supporting :site_name with :premium!", array(':premium' => link_to(url_for('user#user_premium'), ht("your premium account"))));
        ?>
		<br>
		<?php 
        echo t("Your premium account expires in :time.", array(":time" => recent_format_html($user['premium_expires'], " ago", "")));
        ?>
	</div>
<?php 
    }
}
?>

<p>
	<?php 
$result = array();
foreach (get_site_config('premium_currencies') as $currency) {
    $result[] = get_currency_name($currency);
}
echo t("You can support :site_name by purchasing a\n\tpremium account with :currencies currencies. You will also get access to exclusive, premium-only functionality such as\n\tvastly increased limits on the number of addresses and accounts you may track at once,\n\tand advanced reporting and notification functionality. Your jobs and reports will also have higher priority over free users.", array(":currencies" => implode_english($result)));
?>
Пример #3
0
    <td class="address"><?php 
    echo crypto_address($account_data['currency'], $a['address']);
    ?>
</td>
    <td class="added"><?php 
    echo recent_format_html($a['created_at']);
    ?>
</td>
    <td class="job_status <?php 
    if ($job) {
        echo $job['is_error'] ? "job_error" : "job_success";
    }
    ?>
">
      <?php 
    echo recent_format_html($last_updated);
    ?>
      <?php 
    if ($job && $job['message']) {
        ?>
      : <?php 
        echo htmlspecialchars($job['message']);
        ?>
      <?php 
    }
    ?>
    </td>
    <td class="balances"><ul><?php 
    echo "<li>";
    echo $a['balance'] === null ? "-" : currency_format($account_data['currency'], $a['balance']);
    echo "</li>";
Пример #4
0
function api_v1_graphs($graph)
{
    $start_time = microtime(true);
    $result = array();
    /**
     * Graph rendering goes like this:
     * 0. check graph rendering permissions
     * 1. get raw graph data (from a {@link GraphRenderer} through {@link construct_graph_renderer()})
     * 2. apply deltas as necessary
     * 3. add technicals as necessary
     * 4. strip dates outside of the requested ?days parameter (e.g. from extra_days)
     * 5. construct heading and links
     * 6. construct subheading and revise last_updated
     * 7. return data
     * that is, deltas and technicals are done on the server-side; not the client-side.
     */
    $renderer = construct_graph_renderer($graph['graph_type'], $graph['arg0'], $graph['arg0_resolved']);
    // 0. check graph rendering permissions
    if ($renderer->requiresUser()) {
        if (!isset($graph['user_id']) || !$graph['user_id']) {
            throw new GraphException("No user specified for authenticated graph");
        }
        if (!isset($graph['user_hash']) || !$graph['user_hash']) {
            throw new GraphException("No user hash specified for authenticated graph");
        }
        $user = get_user($graph['user_id']);
        if (!$user) {
            throw new GraphException("No such user found");
        }
        if (!has_expected_user_graph_hash($graph['user_hash'], $user)) {
            throw new GraphException("Mismatched user hash for user " . $graph['user_id'] . " with graph type " . $graph['graph_type']);
        }
        if ($renderer->requiresAdmin()) {
            if (!$user['is_admin']) {
                throw new GraphException("Graph requires administrator privileges");
            }
        }
        $renderer->setUser($user['id']);
    }
    if ($renderer->usesDays()) {
        // 0.5 limit 'days' parameter as necessary
        $get_permitted_days = get_permitted_days();
        $has_valid_days = false;
        foreach ($get_permitted_days as $key => $days) {
            if ($days['days'] == $graph['days']) {
                $has_valid_days = true;
            }
        }
        if (!$has_valid_days) {
            throw new GraphException("Invalid days '" . $graph['days'] . "' for graph that requires days");
        }
    }
    // 1. get raw graph data
    try {
        $data = $renderer->getData($graph['days']);
        $original_count = count($data['data']);
        $result['type'] = $renderer->getChartType();
        // 2. apply deltas as necessary
        $data['data'] = calculate_graph_deltas($graph, $data['data'], false);
        // if there is no data, bail out early
        if (count($data['data']) == 0) {
            $result['type'] = 'nodata';
        } else {
            if ($renderer->canHaveTechnicals()) {
                // 3. add technicals as necessary
                // (only if there is at least one point of data, otherwise calculate_technicals() will throw an error)
                $technicals = calculate_technicals($graph, $data['data'], $data['columns'], false);
                $data['columns'] = $technicals['headings'];
                $data['data'] = $technicals['data'];
            }
        }
        // 4. discard early data
        if ($renderer->usesDays()) {
            $data['data'] = discard_early_data($data['data'], $graph['days']);
            $after_discard_count = count($data['data']);
        }
        $result['columns'] = $data['columns'];
        $result['key'] = $data['key'];
        $result['data'] = $data['data'];
        // clean up columns
        foreach ($result['columns'] as $key => $value) {
            $result['columns'][$key]['technical'] = isset($result['columns'][$key]['technical']) && $result['columns'][$key]['technical'] ? true : false;
            if ($result['columns'][$key]['technical']) {
                if (!isset($result['columns'][$key]['type'])) {
                    $result['columns'][$key]['type'] = 'number';
                }
            }
        }
    } catch (NoDataGraphException_AddAccountsAddresses $e) {
        $result['type'] = 'nodata';
        $result['text'] = ct("Either you have not specified any accounts or addresses, or these addresses and accounts have not yet been updated by :site_name.");
        $result['args'] = array(':site_name' => get_site_config('site_name'));
        $result['data'] = array();
        $data['last_updated'] = false;
        $data['add_accounts_addresses'] = true;
    } catch (NoDataGraphException_AddCurrencies $e) {
        $result['type'] = 'nodata';
        $result['text'] = ct("Either you have not enabled this currency, or your summaries for this currency have not yet been updated by :site_name.");
        $result['args'] = array(':site_name' => get_site_config('site_name'));
        $result['data'] = array();
        $data['last_updated'] = false;
        $data['add_more_currencies'] = true;
    }
    // 5. construct heading and links
    $result['heading'] = array('label' => $renderer->getTitle(), 'args' => $renderer->getTitleArgs(), 'url' => $renderer->getURL(), 'title' => $renderer->getLabel());
    if (isset($data['h1'])) {
        $result['h1'] = $data['h1'];
    }
    if (isset($data['h2'])) {
        $result['h2'] = $data['h2'];
    }
    if (isset($data['no_header'])) {
        $result['noHeader'] = $data['no_header'];
    }
    // 6. construct subheading and revise last_updated\
    if ($result['type'] != 'nodata' && $renderer->hasSubheading()) {
        $suffix = "";
        if ($graph['delta'] == 'percent') {
            $suffix .= '%';
        }
        if ($renderer->getCustomSubheading() !== false) {
            $result['subheading'] = number_format_html($renderer->getCustomSubheading(), 4, $suffix);
        } else {
            if ($result['type'] == 'piechart') {
                // sum up the first row and use that as a total
                if (count($data['data']) != 1) {
                    throw new GraphException("Expected one row of data for a piechart, got " . count($data['data']));
                }
                $sum = 0;
                foreach ($data['data'] as $ignored => $row) {
                    foreach ($row as $value) {
                        $sum += $value;
                    }
                }
                $result['subheading'] = number_format_html($sum, 4, $suffix);
            } else {
                $result['subheading'] = format_subheading_values_objects($graph, $data['data'], $data['columns']);
            }
        }
    }
    $result['lastUpdated'] = recent_format_html($data['last_updated']);
    $result['timestamp'] = iso_date();
    $result['classes'] = $renderer->getClasses();
    $result['graph_type'] = $graph['graph_type'];
    if (is_localhost()) {
        $result['_debug'] = $graph;
        if (isset($after_discard_count)) {
            $result['_debug']['data_discarded'] = $original_count - $after_discard_count;
        } else {
            $result['_debug']['data_not_discarded'] = true;
        }
    }
    // make sure that all 'number'-typed data is numeric
    foreach ($result['data'] as $i => $row) {
        foreach ($row as $key => $value) {
            $column = $result['columns'][$key];
            if ($column['type'] == 'number' || $column['type'] == 'percent') {
                $result['data'][$i][$key] = (double) $value;
                if (is_localhost()) {
                    $result['_debug']['number_formatted'] = true;
                }
            }
        }
    }
    // make sure that all data rows are numeric arrays and not objects
    // i.e. reindex everything to be numeric arrays, so they aren't output as JSON objects
    foreach ($result['data'] as $i => $row) {
        $new_row = array_values($row);
        foreach ($row as $key => $value) {
            $new_row[$key] = $value;
        }
        $result['data'][$i] = $new_row;
    }
    // format any extra text from the result
    if (isset($data['add_more_currencies'])) {
        $result['extra'] = array('classes' => 'add_accounts', 'href' => url_for('wizard_currencies'), 'label' => ct("Add more currencies"), 'args' => array());
    }
    if (isset($data['add_accounts_addresses'])) {
        $result['extra'] = array('classes' => 'add_accounts', 'href' => url_for('wizard_accounts'), 'label' => ct("Add accounts and addresses"), 'args' => array());
    }
    // 7. calculate if the graph data may be out of date
    if ($renderer->requiresUser() && $renderer->getUser()) {
        $user = get_user($renderer->getUser());
        if ($user && $renderer->usesSummaries() && (!$user['has_added_account'] || !$user['is_first_report_sent'] || strtotime($user['last_account_change']) > strtotime($user['last_sum_job']))) {
            $result['outofdate'] = true;
        }
    }
    $end_time = microtime(true);
    $time_diff = ($end_time - $start_time) * 1000;
    $result['time'] = (double) number_format_autoprecision($time_diff, 1, '.', '');
    $result['hash'] = $graph['hash'];
    // 7. return data
    return $result;
}
Пример #5
0
            $link = url_for('wizard_accounts_addresses#wizard_xrp');
        }
        if (substr($exchange, 0, strlen('individual_')) === 'individual_') {
            $link = url_for('wizard_accounts_individual_securities');
        }
        if ($link) {
            echo "<a href=\"" . htmlspecialchars($link) . "\">";
        }
        echo htmlspecialchars(get_exchange_name($exchange));
        if ($link) {
            echo "</a>";
        }
        ?>
</td>
    <td><?php 
        echo recent_format_html($last_updated[$exchange]);
        ?>
</td>
    <td class="number"><?php 
        echo currency_format($currency, $balance, 4);
        ?>
</td>
  </tr>
<?php 
    }
    ?>
</tbody>
<tfoot>
  <tr>
    <th colspan="2"><?php 
    echo t("Total :currency", array(':currency' => get_currency_name($currency)));
Пример #6
0
 $q = db()->prepare("SELECT COUNT(*) AS identity_count, identity FROM user_openid_identities WHERE user_id=?");
 $q->execute(array($user['id']));
 $openid = $q->fetch();
 echo "<tr>\n";
 echo "<td class=\"number\">" . number_format($user['id']) . "</td>\n";
 if ($openid && $openid['identity_count']) {
     echo "<td><a href=\"" . htmlspecialchars($openid['identity']) . "\">" . ($user['email'] ? htmlspecialchars($user['email']) : "<i>(no email)</i>") . "</a> " . $openid['identity_count'] . "</td>\n";
 } else {
     echo "<td>" . htmlspecialchars($user['email']) . "</a> (password)</td>\n";
 }
 echo "<td>" . htmlspecialchars($user['name']) . "</td>\n";
 echo "<td class=\"" . ($user['has_added_account'] ? 'yes' : 'no') . "\">-</td>\n";
 echo "<td class=\"" . ($user['is_premium'] ? 'yes' : 'no') . "\">-</td>\n";
 echo "<td>" . recent_format_html($user['premium_expires'], "", "") . "</td>\n";
 echo "<td>" . recent_format_html($user['created_at']) . "</td>\n";
 echo "<td>" . recent_format_html($user['last_login']) . "</td>\n";
 echo "<td class=\"number\">" . number_format($user['currencies']) . "</td>\n";
 echo "<td>";
 echo "<form action=\"" . htmlspecialchars(url_for('admin_login')) . "\" method=\"get\">";
 echo "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($user['id']) . "\">";
 echo "<input type=\"submit\" value=\"Login as\">";
 echo "</form>";
 echo "<form action=\"" . htmlspecialchars(url_for('admin_user_export')) . "\" method=\"post\">";
 echo "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($user['id']) . "\">";
 echo "<input type=\"submit\" value=\"Export\">";
 echo "</form>";
 echo "<form action=\"" . htmlspecialchars(url_for('admin_user_delete')) . "\" method=\"post\">";
 echo "<input type=\"hidden\" name=\"id\" value=\"" . htmlspecialchars($user['id']) . "\">";
 echo "<input type=\"hidden\" name=\"confirm\" value=\"1\">";
 echo "<input type=\"submit\" value=\"Delete\" onclick=\"return confirm('Are you sure you want to delete this user?');\">";
 echo "</form>";
Пример #7
0
">
    <td><span class="email_notification"><?php 
    echo $account_text . " " . $trigger_text;
    ?>
</span></td>
    <td><?php 
    $notification_periods = get_permitted_notification_periods();
    echo $notification_periods[$notification['period']]['title'];
    ?>
</td>
    <td><?php 
    echo recent_format_html($notification['last_queue']);
    ?>
</td>
    <td><?php 
    echo recent_format_html($notification['last_notification']);
    ?>
</td>
    <td class="buttons">
      <form action="<?php 
    echo htmlspecialchars(url_for('wizard_notifications'));
    ?>
" method="get">
        <input type="hidden" name="edit" value="<?php 
    echo htmlspecialchars($notification['id']);
    ?>
">
        <input type="submit" value="<?php 
    echo ht("Edit");
    ?>
" class="edit" title="<?php 
Пример #8
0
        }
        echo "</li>\n";
    }
    if ($group_name == "Other") {
        $q = db()->prepare("SELECT * FROM site_statistics WHERE is_recent=1 LIMIT 1");
        $q->execute();
        $stats = $q->fetch();
        if ($stats) {
            echo "<li><span class=\"title\">" . t("Free user job delay") . "</span> ";
            echo "<span class=\"status_percent " . get_error_class($stats['free_delay_minutes'] / 60 / (get_site_config('refresh_queue_hours') * 3) * 100) . "\">";
            echo expected_delay_html($stats['free_delay_minutes']);
            echo "</span></li>\n";
            echo "<li><span class=\"title\">" . t(":premium_user job delay", array(':premium_user' => link_to(url_for('premium'), t("Premium user")))) . "</span> ";
            echo "<span class=\"status_percent " . get_error_class($stats['premium_delay_minutes'] / 60 / (get_site_config('refresh_queue_hours_premium') * 3) * 100) . "\">";
            echo expected_delay_html($stats['premium_delay_minutes']);
            echo "</span></li>\n";
        }
    }
    echo "</ul></li>\n";
}
?>
</ul>

<p>
<?php 
echo t("This data is refreshed automatically once per hour (last updated :ago).", array(':ago' => recent_format_html($last_updated)));
?>
</p>

<?php 
page_footer();
Пример #9
0
    $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())) {
        echo "<td><i>disabled</i></td>";
    } else {
        echo "<td></td>";
    }
    echo "<td></td>";
    echo "<td></td>";
    echo "<td>" . recent_format_html($job['executed_at']) . "</td>\n";
    ?>
    <td class="number">
      <?php 
    if ($job) {
        ?>
      <a href="<?php 
        echo htmlspecialchars(url_for('admin_run_job', array('job_id' => $job['id'], 'force' => true)));
        ?>
"><?php 
        echo number_format($job['id']);
        ?>
</a>
      <?php 
    }
    ?>
Пример #10
0
<?php

global $last_calculated;
?>

<h1><?php 
echo t("Coin Voting");
?>
</h1>

<p>
  <?php 
echo t("Here you can vote for the next currencies which should be added to :site_name in a future release, if the currency satisfies the :requirements.\n    Each vote is counted proportionally to the total number of votes from each user;\n    votes from :premium_users are multipled by :number.\n    Total currency popularity is recalculated daily (last calculated :calculated).\n    :site_name will also notify you when a currency you have voted on has been added.", array(':requirements' => link_to(url_for('help/add_currency'), t('explorer and exchange requirements')), ':premium_users' => link_to(url_for('premium'), t('premium users')), ':number' => number_format(get_site_config('premium_user_votes')), ':calculated' => recent_format_html($last_calculated)));
?>
</p>

<?php 
if (!user_logged_in()) {
    ?>
<p>
  <?php 
    echo t("You need to be :logged_in in order to vote.", array(':logged_in' => link_to(url_for('login'), t('logged in'))));
    ?>
</p>
<?php 
}
?>

<p>
  <?php 
echo t("If you would like to sponsor the implementation of a currency immediately, or to suggest a new currency, please :contact_us.", array(':contact_us' => link_to(url_for('contact'), t('contact us'))));
Пример #11
0
                }
            }
        }
        ?>
      <tr>
        <th><?php 
        echo htmlspecialchars($key);
        ?>
</th>
        <td class="number"><span class="<?php 
        echo $status ? "status_percent " . $status : "";
        ?>
">
          <?php 
        if ($key == "created_at") {
            echo recent_format_html($value);
        } else {
            if (is_numeric($value)) {
                echo number_format($value, $dp);
            } else {
                echo htmlspecialchars($value);
            }
        }
        echo $suffix;
        ?>
</span></td>
      </tr>
      <?php 
    }
    ?>
    <tr>