Exemplo n.º 1
0
/**
 * @param $keytype e.g. 'blockchain', 'mtgox', 'notification', ...
 */
function can_user_add($user, $keytype, $amount = 1)
{
    $summary = user_limits_summary($user['id']);
    $data = get_account_data($keytype);
    $current_total = $summary['total_' . $data['group']];
    $limit = get_premium_value($user, $data['group']);
    return $current_total + $amount <= $limit;
    throw new Exception("Could not find user limit type '{$keytype}'");
}
Exemplo n.º 2
0
/**
 * Calculate all of the graphs that would be created for a given user,
 * with a given graph calculation strategy.
 * @param $strategy 'auto', 'managed' or '' (use user-defined)
 * @param $managed an array of categories or use, or empty to use user-defined
 */
function calculate_user_graphs($user, $strategy = false, $categories = array())
{
    if ($strategy === false) {
        if (!$user['graph_managed_type']) {
            throw new ManagedGraphException("User has no managed graph type, so cannot select user-defined strategy");
        }
        return calculate_user_graphs($user, $user['graph_managed_type'], $categories);
    }
    $managed = calculate_all_managed_graphs($user);
    // merge them all together based on user preferences
    if ($strategy == "managed") {
        if (!$categories) {
            $q = db()->prepare("SELECT * FROM managed_graphs WHERE user_id=?");
            $q->execute(array($user['id']));
            while ($m = $q->fetch()) {
                $categories[] = $m['preference'];
            }
        }
    } else {
        // default categories for auto
        $categories = get_auto_managed_graph_categories();
    }
    // merge all graphs based on categories
    $result = array();
    foreach ($categories as $key) {
        if (isset($managed[$key])) {
            foreach ($managed[$key] as $graph_key => $graph) {
                // remove any graphs that are not free priorities for non-premium users
                if ($user['is_premium'] || isset($graph['free']) && $graph['free']) {
                    $result[$graph_key] = $graph;
                }
            }
        }
    }
    // limit to the maximum number of graphs that we can support, if necessary
    // sort by priority
    uasort($result, '_sort_by_priority_key');
    if (count($result) > get_premium_value($user, 'graphs_per_page')) {
        $result = array_slice($result, 0, get_premium_value($user, 'graphs_per_page'));
    }
    // sort by order
    uasort($result, '_sort_by_order_key');
    return $result;
}
Exemplo n.º 3
0
/**
 * Render the HTML on the page necessary for rendering a graph to the user.
 *
 * @param $graph = array(
 *    'graph_type' => $id,
 *    'width' => 8,
 *    'height' => 4,
 *    'page_order' => 0,
 *    'days' => $days,
 *    'id' => 0,
 *    'arg0_resolved' => $name,
 *    'delta' => $delta,
 *    'public' => true,
 *    'no_technicals' => true,
 *  );
 * @param $include_user_hash if true, include user_id and user_hash in the graph data, necessary for
 *        graphs that require user authentication; default is false
 */
function render_graph_new($graph, $include_user_hash = false)
{
    global $_rendered_graph_contents;
    if (!$_rendered_graph_contents) {
        // calculate the relevant text for outofdate indicators
        $title = "";
        if (user_logged_in()) {
            $user = get_user(user_id());
            $plural_hours = plural("hour", user_is_new($user) ? get_site_config('refresh_queue_hours_premium') : get_premium_value($user, "refresh_queue_hours"));
            if ($user['is_first_report_sent']) {
                $title = t("This graph will take up to :hours to be updated with recently added or removed accounts.", array(':hours' => $plural_hours));
            } else {
                if ($user['has_added_account']) {
                    $title = t("As a new user, it will take up to :hours for this graph to be populated with initial data.", array(':hours' => $plural_hours));
                } else {
                    $title = t("You need to add some account data for this graph to display.");
                }
            }
        }
        ?>
    <div id="graph_contents_template" style="display:none;">
      <div class="graph_headings">
        <h1 class="h1"></h1>
        <h2 class="h2"></h2>
        <h2 class="graph_title">
          <a href=""></a>
        </h2>
        <span class="outofdate" style="display:none;" title="<?php 
        echo htmlspecialchars($title);
        ?>
"></span>
        <span class="subheading"></span>
        <span class="last-updated"></span>
        <ul class="graph_controls">
          <li class="move_up"><a><?php 
        echo ht("Move up");
        ?>
</a></li>
          <li class="move_down"><a><?php 
        echo ht("Move down");
        ?>
</a></li>
          <li class="remove"><a><?php 
        echo ht("Remove");
        ?>
</a></li>
          <li class="edit"><a><?php 
        echo ht("Edit");
        ?>
</a></li>
        </ul>
        <div class="edit_target" style="display:none;">
          <ul class="graph_edit_controls">
            <li class="close"><a><?php 
        echo ht("Close");
        ?>
</a></li>
          </ul>
        </div>
      </div>
      <div class="graph-target"><span class="status_loading"><?php 
        echo ht("Loading...");
        ?>
</span></div>
      <div class="graph_extra extra" style="display:none;"><a href="#"></a></span></div>
      <div class="admin-stats-wrapper hide-admin"><span class="admin-stats render_time"></span></div>
    </div>
    <div id="graph_table_template" class="overflow_wrapper extra-text-container" style="display:none;">
      <table class="standard graph_table">
      </table>
    </div>
    <?php 
    }
    if (user_logged_in()) {
        $user = get_user(user_id());
        $graph['can_be_edited'] = !($user['graph_managed_type'] == 'auto' && isset($graph['is_managed']) && $graph['is_managed']);
    }
    if (isset($graph['page_id']) && isset($graph['id'])) {
        $graph['move_up_link'] = url_for('profile', array('page' => $graph['page_id'], 'move_up' => $graph['id']));
        $graph['move_down_link'] = url_for('profile', array('page' => $graph['page_id'], 'move_down' => $graph['id']));
        $graph['remove_link'] = url_for('profile', array('page' => $graph['page_id'], 'remove' => $graph['id']));
    }
    if (isset($graph['id']) && $graph['id']) {
        $graph_id = "graph_" . $graph['id'];
    } else {
        $graph_id = "graph_" . rand(0, 0xffff);
    }
    $graph['target'] = $graph_id;
    $graph['graphWidth'] = get_site_config('default_graph_width') * $graph['width'];
    $graph['computedWidth'] = $graph['graphWidth'];
    $graph['graphHeight'] = get_site_config('default_graph_height') * $graph['height'];
    $graph['computedHeight'] = $graph['graphHeight'] + 30;
    // if we are logged in, also provide the user ID and computed user hash, to verify that we can
    // correctly access this graph (also means that we don't have to initialise sessions on the API)
    if ($include_user_hash && user_logged_in()) {
        $graph['user_id'] = user_id();
        $graph['user_hash'] = compute_user_graph_hash(get_user(user_id()));
    }
    // enable demo if necessary
    if (require_get("demo", false)) {
        $graph['demo'] = true;
    }
    // we set the widths and heights initially here so that the page layout doesn't move around
    // a lot as the graphs are loaded via AJAX
    $inline_styles = "overflow: hidden; width: " . $graph['computedWidth'] . "px; height: " . $graph['computedHeight'] . "px;";
    switch ($graph['graph_type']) {
        case "linebreak":
        case "heading":
            // don't render anything! this rendering is handled by profile.php
            return;
        case "calculator":
            // a special case for the Calculator widget; it doesn't seem a good idea to
            // have this as an API call that returns a mixture of HTML and Javascript
            ?>
      <div id="<?php 
            echo htmlspecialchars($graph_id);
            ?>
" class="graph graph_calculator" style="<?php 
            echo $inline_styles;
            ?>
">
        <div class="graph_headings">
          <h2 class="graph_title"><?php 
            echo ht("Currency converter");
            ?>
</h2>
        </div>
        <div class="graph-target">
          <?php 
            require __DIR__ . "/../pages/_calculator.php";
            ?>
        </div>
      </div>
      <script type="text/javascript">
      $(document).ready(function() {
        Graphs.render(<?php 
            echo json_encode($graph);
            ?>
, true /* static graph */);
        initialise_calculator($("#<?php 
            echo htmlspecialchars($graph_id);
            ?>
"))
      });
      </script>
      <?php 
            return;
    }
    // 'overflow: hidden;' is to fix a Chrome rendering bug
    ?>
    <div id="<?php 
    echo htmlspecialchars($graph_id);
    ?>
" class="graph" style="<?php 
    echo $inline_styles;
    ?>
"></div>
    <script type="text/javascript">
      Graphs.render(<?php 
    echo json_encode($graph);
    ?>
);
    </script>
  <?php 
}
        }
        $exchanges = $result;
    }
}
// go through all crypto currencies and add just summary_CUR
foreach ($currencies as $c) {
    $exchanges[] = "summary_" . $c;
}
// don't do this with commodity currencies, since summary_CUR is actually a valid currency
// strip out any invalid exchanges
$exchanges = array_intersect($exchanges, array_keys(get_summary_types()));
// and make it unique
$exchanges = array_unique($exchanges);
// make sure this user can have this many summaries
if (count($exchanges) > get_premium_value($user, 'summaries')) {
    $errors[] = t("Could not update currencies: too many currencies (:count selected out of a maximum of :maximum).", array(':count' => number_format(count($exchanges)), ':maximum' => number_format(get_premium_value($user, 'summaries')))) . ($user['is_premium'] ? "" : " " . t("To add more currencies, upgrade to a :premium_account.", array(':premium_account' => link_to(url_for('premium'), t('premium account')))));
    set_temporary_messages($messages);
    set_temporary_errors($errors);
    redirect(url_for('wizard_currencies'));
    // go back
}
// get all the currencies we're currently interested in
// (so we know if we need to reset managed graphs)
$q = db()->prepare("SELECT * FROM summaries WHERE user_id=?");
$q->execute(array(user_id()));
$existing = array();
while ($summary = $q->fetch()) {
    $existing[] = $summary['summary_type'];
}
// delete any old currencies that no longer exist
$q = db()->prepare("SELECT id, summary_type FROM summaries WHERE user_id=?");
Exemplo n.º 5
0
echo t("Your Reports");
?>
</a></li>
  </ul>
</div>

<div class="wizard-content">
<h1><?php 
echo t("Notification Preferences");
?>
</h1>

<p>
  <?php 
echo t(':site_name can also optionally :notify_you when
  your accounts change. (You can always change these options
  later, by selecting the "Configure Accounts" link above.)', array(':notify_you' => link_to(url_for('help/notifications'), t('notify you'))));
?>
</p>

<!--<p class="tip tip_float your_account_limits">-->
<p>
<?php 
echo ht("As a :user, you may have up to :notifications defined.", array(':user' => $user['is_premium'] ? ht("premium user") : ht("free user"), ':notifications' => plural("configured notification", get_premium_value($user, 'notifications'))));
echo "\n";
if (!$user['is_premium']) {
    echo t("To increase this limit, please purchase a :premium_account.", array(':premium_account' => link_to(url_for('premium'), ht("premium account"))));
}
?>
</p>
Exemplo n.º 6
0
?>
</h1>

<p>
  <?php 
echo t('Once information from your accounts have been downloaded and compiled into reports,
  you may view :reports by defining graphs and pages.
  :site_name can automatically manage these reports for you, or you may opt to define these manually.
  (You can always change these accounts later, by selecting the "Configure Accounts" link above.)', array(':reports' => link_to(url_for('profile'), t('these reports'))));
?>
</p>

<!--<p class="tip tip_float your_account_limits">-->
<p>
<?php 
echo ht("As a :user, you may have up to :graphs per page defined.", array(':user' => $user['is_premium'] ? ht("premium user") : ht("free user"), ':graphs' => plural("graph", get_premium_value($user, 'graphs_per_page'))));
echo "\n";
if (!$user['is_premium']) {
    echo t("To increase this limit, please purchase a :premium_account.", array(':premium_account' => link_to(url_for('premium'), ht("premium account"))));
}
?>
</p>

<p><a href="<?php 
echo htmlspecialchars(url_for('help/managed_graphs'));
?>
"><?php 
echo htmlspecialchars(get_knowledge_base_title('managed_graphs'));
?>
</a></p>
Exemplo n.º 7
0
</a>:</th>
  <td><?php 
echo t(":number (out of :total)", array(':number' => number_format($accounts['total_finance_accounts']), ':total' => number_format(get_premium_value($user, 'finance_accounts'))));
?>
</td>
</tr>
<tr>
  <th><a href="<?php 
echo htmlspecialchars(url_for('finance_categories'));
?>
"><?php 
echo ht("Finance Categories");
?>
</a>:</th>
  <td><?php 
echo t(":number (out of :total)", array(':number' => number_format($accounts['total_finance_categories']), ':total' => number_format(get_premium_value($user, 'finance_categories'))));
?>
</td>
</tr>
</table>

<p>
<?php 
if (!$user['is_premium']) {
    echo t("Support :site_name and get access to more features with a :premium_account!", array(':premium_account' => link_to(url_for('premium'), t("premium account"))));
} else {
    echo t("Thank you for supporting :site_name. Extend your existing :premium_account here:", array(':premium_account' => link_to(url_for('premium'), t("premium account"))));
}
?>
</p>
?>
"><?php 
echo t("Reports");
?>
</a></li>
		<li class=""><a href="<?php 
echo htmlspecialchars(url_for('profile'));
?>
"><?php 
echo t("Your Reports");
?>
</a></li>
	</ul>
</div>

<div class="wizard-content">
<h1><?php 
echo t("Add Addresses");
?>
</h1>

<p>
<?php 
echo t("As a :user, you may have up to :addresses of :your_currencies defined.", array(':user' => $user['is_premium'] ? ht("premium user") : ht("free user"), ':addresses' => plural("address", "addresses", get_premium_value($user, 'addresses')), ':your_currencies' => link_to(url_for('wizard_currencies'), ht("your currencies"))));
echo "\n";
if (!$user['is_premium']) {
    echo t("To increase this limit, please purchase a :premium_account.", array(':premium_account' => link_to(url_for('premium'), ht("premium account"))));
}
?>
</p>
Exemplo n.º 9
0
function page_header_old($page_title, $page_id = false, $options = array())
{
    define('PAGE_RENDER_START', microtime(true));
    header('Content-type: text/html; charset=utf-8');
    $html_classes = array();
    if (has_required_admin()) {
        $html_classes[] = "body_admin";
    }
    $html_classes[] = get_site_config('site_id');
    if (is_admin()) {
        $html_classes[] = "is_admin";
    }
    ?>
<!DOCTYPE HTML>
<html<?php 
    echo " class=\"" . implode(" ", $html_classes) . "\"";
    ?>
>
<head>
    <title><?php 
    echo htmlspecialchars($page_title);
    if (has_required_admin()) {
        echo " [admin]";
    }
    ?>
</title>
    <link rel="stylesheet" type="text/css" href="<?php 
    echo htmlspecialchars(url_for('styles/generated.css' . '?' . get_site_config('openclerk_version')));
    ?>
" />
    <link rel="stylesheet" type="text/css" href="<?php 
    echo htmlspecialchars(url_for(get_site_config('default_css') . '?' . get_site_config('openclerk_version')));
    ?>
" />
    <?php 
    if (get_site_config('custom_css')) {
        ?>
    <link rel="stylesheet" type="text/css" href="<?php 
        echo htmlspecialchars(url_for(get_site_config('custom_css') . '?' . get_site_config('openclerk_version')));
        ?>
" />
    <?php 
    }
    ?>
    <?php 
    if (has_required_admin()) {
        ?>
    <link rel="stylesheet" type="text/css" href="<?php 
        echo htmlspecialchars(url_for('admin.css' . '?' . get_site_config('openclerk_version')));
        ?>
" />
    <?php 
    }
    ?>
    <?php 
    if (isset($options["refresh"])) {
        ?>
    <meta http-equiv="refresh" content="<?php 
        echo htmlspecialchars($options['refresh']);
        ?>
">
    <?php 
    }
    ?>
    <script type="text/javascript" src="<?php 
    echo htmlspecialchars(url_for('js/jquery-1.9.1.min.js'));
    ?>
"></script>
    <script type="text/javascript" src="<?php 
    echo htmlspecialchars(url_for('js/common.js' . '?' . get_site_config('openclerk_version')));
    ?>
"></script>
    <script type="text/javascript" src="<?php 
    echo htmlspecialchars(url_for('js/locale/' . I18n::getCurrentLocale() . '.js?' . get_site_config('openclerk_version')));
    ?>
"></script>
    <?php 
    if (isset($options['jsapi']) && $options['jsapi']) {
        ?>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
    <?php 
        $user = user_logged_in() ? get_user(user_id()) : false;
        if ($user) {
            if ($user['disable_graph_refresh'] || isset($graph_type['no_refresh']) && $graph_type['no_refresh']) {
                $timeout = 0;
                // disable refresh
            } else {
                $timeout = get_premium_value(get_user(user_id()), 'graph_refresh');
            }
        } else {
            $timeout = get_site_config('graph_refresh_public');
        }
        // TODO move this into a more helpful location rather than in the template head
        ?>
window.UserGraphRefresh = <?php 
        echo $timeout * 1000 * 60;
        ?>
;  // ms
    </script>
    <?php 
    }
    ?>
    <?php 
    if (isset($options["js"]) && $options["js"]) {
        if (!is_array($options['js'])) {
            $options['js'] = array($options['js']);
        }
        foreach ($options['js'] as $js) {
            $js_hash = "";
            if (strpos($js, "?") !== false) {
                $js_hash = "&" . substr($js, strpos($js, "?") + 1);
                $js = substr($js, 0, strpos($js, "?"));
            }
            ?>
    <script type="text/javascript" src="<?php 
            echo htmlspecialchars(url_for('js/' . $js . '.js' . '?' . get_site_config('openclerk_version') . $js_hash));
            ?>
"></script>
    <?php 
        }
    }
    ?>
  <?php 
    require_template("templates_head");
    ?>
  <?php 
    $head_compiled = __DIR__ . "/../site/head-compiled.html";
    if (file_exists($head_compiled)) {
        require $head_compiled;
    } else {
        // fix relative paths
        $input = file_get_contents(__DIR__ . "/head.html");
        $input = str_replace("src=\"", "src=\"" . htmlspecialchars(calculate_relative_path()), $input);
        echo $input;
    }
    ?>
</head>
<body<?php 
    if ($page_id) {
        echo ' id="' . $page_id . '"';
    }
    if (isset($options['class'])) {
        echo " class=\"" . htmlspecialchars($options['class']) . "\"";
    }
    ?>
>
<div class="body_wrapper">

<?php 
    require_template("templates_header");
    ?>

<div id="navigation">
<ul>
  <li class="home"><a href="<?php 
    echo url_for('index');
    ?>
" title="<?php 
    echo htmlspecialchars(get_site_config('site_name'));
    ?>
"><span class="text"><?php 
    echo htmlspecialchars(get_site_config('site_name'));
    ?>
</span></a></li>
  <?php 
    if (user_logged_in()) {
        ?>
    <li class="profile"><a href="<?php 
        echo url_for('profile');
        ?>
" title="<?php 
        echo ht("Your Reports");
        ?>
"><span class="text"><?php 
        echo ht("Your Reports");
        ?>
</span><span class="responsive-text"><?php 
        echo ht("Reports");
        ?>
</span></a></li>
    <li class="finance"><a href="<?php 
        echo url_for('your_transactions');
        ?>
" title="<?php 
        echo ht("Finance");
        ?>
"><span class="text"><?php 
        echo ht("Finance");
        ?>
</span></a></li>
    <li class="accounts"><a href="<?php 
        echo url_for('wizard_currencies');
        ?>
" title="<?php 
        echo ht("Configure Accounts");
        ?>
"><span class="text"><?php 
        echo ht("Configure Accounts");
        ?>
</span><span class="responsive-text"><?php 
        echo ht("Configure");
        ?>
</span></a></li>
    <li class="user"><a href="<?php 
        echo url_for('user');
        ?>
" title="<?php 
        echo ht("User Profile");
        ?>
"><span class="text"><?php 
        echo ht("User Profile");
        ?>
</span></a></li>
    <li class="logout"><a href="<?php 
        echo url_for('login', array('logout' => 1));
        ?>
" title="<?php 
        echo ht("Logout");
        ?>
"><span class="text"><?php 
        echo ht("Logout");
        ?>
</span></a></li>
    <?php 
        if (is_admin()) {
            ?>
      <li class="admin"><a href="<?php 
            echo url_for('admin');
            ?>
" title="<?php 
            echo ht("Admin");
            ?>
"><span class="text"><?php 
            echo ht("Admin");
            ?>
</span></a></li>
    <?php 
        }
        ?>
  <?php 
    } else {
        ?>
    <li class="signup"><a href="<?php 
        echo url_for('signup');
        ?>
" title="<?php 
        echo ht("Signup");
        ?>
"><span class="text"><?php 
        echo ht("Signup");
        ?>
</span></a></li>
    <li class="login"><a href="<?php 
        echo url_for('login');
        ?>
" title="<?php 
        echo ht("Login");
        ?>
"><span class="text"><?php 
        echo ht("Login");
        ?>
</span></a></li>
  <?php 
    }
    ?>
  <li class="premium"><a href="<?php 
    echo url_for('premium');
    ?>
" title="<?php 
    echo ht("Premium");
    ?>
"><span class="text"><?php 
    echo ht("Premium");
    ?>
</span></a></li>
  <li class="help"><a href="<?php 
    echo url_for('help');
    ?>
" title="<?php 
    echo ht("Help");
    ?>
"><span class="text"><?php 
    echo ht("Help");
    ?>
</span></a></li>
</ul>
</div>

<?php 
    if (did_autologin()) {
        ?>
<div id="autologin">
  <?php 
        echo t("Automatically logged in. Hi, :user!", array(':user' => "<a href=\"" . url_for('user') . "\" class=\"disabled\">" . ($_SESSION["user_name"] ? htmlspecialchars($_SESSION["user_name"]) : "<i>" . t("anonymous") . "</i>") . "</a>"));
        ?>
  (<a href="<?php 
        echo url_for('login', array('logout' => 1));
        ?>
"><?php 
        echo ht("This isn't me.");
        ?>
</a>)
</div>
<?php 
    }
    ?>

  <div id="page_content">
<?php 
    // always display messages on every page as necessary
    display_messages();
}
Exemplo n.º 10
0
    global $add_type_names;
    return strcmp(strtolower($add_type_names[$a]), strtolower($add_type_names[$b]));
}
usort($add_types, '_sort_by_exchange_name');
$account_data = null;
?>

<div class="page_accounts">

<?php 
if ($account_type['wizard'] != 'offsets') {
    ?>
  <p>
  <?php 
    $extra_hours = (int) (get_site_config('new_user_premium_update_hours') - (time() - strtotime($user['created_at'])) / (60 * 60));
    echo t("As a :user, your :titles should be updated at least once every :hours:extra.", array(':user' => $user['is_premium'] ? ht("premium user") : (user_is_new($user) ? ht("new user") : link_to(url_for('premium'), t("free user"))), ':titles' => $account_type['accounts'], ':hours' => plural("hour", user_is_new($user) ? get_site_config('refresh_queue_hours_premium') : get_premium_value($user, "refresh_queue_hours")), ':extra' => user_is_new($user) && !$user['is_premium'] ? " " . t("(for the next :hours)", array(':hours' => plural("hour", $extra_hours))) : ""));
    ?>
  </p>
<?php 
}
?>

<h2><?php 
echo t("Your :titles", array(':titles' => $account_type['titles']));
?>
</h2>

<?php 
require __DIR__ . "/_sort_buttons.php";
?>
Exemplo n.º 11
0
?>
</a></li>
	</ul>
</div>

<div class="wizard-content">
<h1><?php 
echo t("Currency Preferences");
?>
</h1>

<p>
	<?php 
echo t('Welcome to :site_name!
	To begin tracking your investments and addresses, please first select the
	currencies that you are interested in. (You can always change these options
	later, by selecting the "Configure Accounts" link above.)');
?>
</p>

<!--<p class="tip tip_float your_account_limits">-->
<p>
<?php 
echo ht("As a :user, you may have up to :accounts defined.", array(':user' => $user['is_premium'] ? ht("premium user") : ht("free user"), ':accounts' => plural("currency and exchange selection", get_premium_value($user, 'summaries'))));
echo "\n";
if (!$user['is_premium']) {
    echo t("To increase this limit, please purchase a :premium_account.", array(':premium_account' => link_to(url_for('premium'), ht("premium account"))));
}
?>
</p>
Exemplo n.º 12
0
</a></li>
	</ul>
</div>

<div class="wizard-content">
<h1><?php 
echo t("Add Accounts and Addresses");
?>
</h1>

<p>
	<?php 
echo t(':site_name keeps track of your
	cryptocurrencies, investments and equities by regularly downloading account details
	from accounts that you define. You can add five different types of accounts as
	illustrated below. (You can always change these accounts
	later, by selecting the "Configure Accounts" link above.)');
?>
</p>

<!--<p class="tip tip_float your_account_limits">-->
<p>
<?php 
echo ht("As a :user, you may have up to :addresses and :accounts defined.", array(':user' => $user['is_premium'] ? ht("premium user") : ht("free user"), ':addresses' => plural("address", "addresses", get_premium_value($user, 'addresses')), ':accounts' => plural("account", get_premium_value($user, 'accounts'))));
echo "\n";
if (!$user['is_premium']) {
    echo t("To increase these limits, please purchase a :premium_account.", array(':premium_account' => link_to(url_for('premium'), ht("premium account"))));
}
?>
</p>
Exemplo n.º 13
0
echo t("Reports");
?>
</a></li>
		<li class=""><a href="<?php 
echo htmlspecialchars(url_for('profile'));
?>
"><?php 
echo t("Your Reports");
?>
</a></li>
	</ul>
</div>

<div class="wizard-content">
<h1><?php 
echo t("Add :titles", array(':titles' => $account_type['titles']));
?>
</h1>

<p>
<?php 
echo t("Summary calculations will also include any currency values defined below as :offsets.", array(':offsets' => "<i>" . t("offsets") . "</i>"));
echo "\n";
echo ht("As a :user, you may have up to :offsets defined.", array(':user' => $user['is_premium'] ? ht("premium user") : ht("free user"), ':offsets' => plural("offset", get_premium_value($user, 'offsets'))));
echo "\n";
if (!$user['is_premium']) {
    echo t("To increase this limit, please purchase a :premium_account.", array(':premium_account' => link_to(url_for('premium'), ht("premium account"))));
}
?>
</p>
Exemplo n.º 14
0
 }
 // update graphs or reset graphs if necessary
 if ($preference != "none") {
     // if we're submitting this form, and we are using some form of management, we should update the graphs anyway
     $update_needed = true;
     if ($update_needed || $total_reset_needed) {
         // we let the next page load handle updating graphs, so we can also
         // update graphs without forcing users to use the wizard
         $q = db()->prepare("UPDATE user_properties SET needs_managed_update=1 WHERE id=?");
         $q->execute(array(user_id()));
     }
     if ($total_reset_needed) {
         // delete all managed pages, the next page load will display them
         // if the user can't have more than one page, then automatically
         // delete and reset the only available page
         $query_extra = get_premium_value($user, 'graph_pages') > 1 ? " AND is_managed=1" : "";
         $q = db()->prepare("SELECT * FROM graph_pages WHERE user_id=? {$query_extra}");
         $q->execute(array(user_id()));
         $pages = $q->fetchAll();
         foreach ($pages as $page) {
             $q = db()->prepare("DELETE FROM graphs WHERE page_id=?");
             $q->execute(array($page['id']));
         }
         $q = db()->prepare("DELETE FROM graph_pages WHERE user_id=? {$query_extra}");
         $q->execute(array(user_id()));
         $messages[] = t("Reset graphs.");
     } else {
         if ($update_needed) {
             // $messages[] = "Updated graphs.";
         }
     }
Exemplo n.º 15
0
  <td colspan="2" class="buttons">
    <input type="hidden" name="page" value="<?php 
echo htmlspecialchars($page_id);
?>
">
    <input type="submit" value="<?php 
echo ht("Add page");
?>
"> (<a href="<?php 
echo htmlspecialchars(url_for('premium'));
?>
"><?php 
echo t("maximum");
?>
 <?php 
echo number_format(get_premium_value($user, 'graph_pages'));
?>
</a>)
  </td>
</tr>
</table>
</form>
</div>
</li>

<?php 
if ($pages && !$graph_page['is_managed']) {
    ?>
<li id="tab_profile_deletepage_tab" style="display:none;">
<div class="delete_page">
<h2><?php 
Exemplo n.º 16
0
<?php

global $user;
?>

<h1><?php 
echo ht("Finance Accounts");
?>
</h1>

<p>
	<?php 
echo t(":site_name Finance can\n\tkeep track of :your_transactions\n\tand assign them to separate accounts,\n\tfor tax or accounting purposes.", array(':your_transactions' => link_to(url_for('your_transactions'), ht("your cryptocurrency transactions"))));
?>

	<?php 
echo t("Once you have added a finance account, you can :add_remove associated with this account.", array(':add_remove' => link_to(url_for('your_transactions'), ht("add and remove transactions"))));
?>
</p>

<!--<p class="tip tip_float your_account_limits">-->
<p>
<?php 
echo ht("As a :user, you may have up to :accounts defined.", array(':user' => $user['is_premium'] ? ht("premium user") : ht("free user"), ':accounts' => plural("finance account", get_premium_value($user, 'finance_accounts'))));
echo "\n";
if (!$user['is_premium']) {
    echo t("To increase this limit, please purchase a :premium_account.", array(':premium_account' => link_to(url_for('premium'), ht("premium account"))));
}
?>
</p>
?>
"><?php 
echo t("Reports");
?>
</a></li>
		<li class=""><a href="<?php 
echo htmlspecialchars(url_for('profile'));
?>
"><?php 
echo t("Your Reports");
?>
</a></li>
	</ul>
</div>

<div class="wizard-content">
<h1><?php 
echo t("Add :titles", array(':titles' => $account_type['titles']));
?>
</h1>

<p>
<?php 
echo ht("As a :user, you may have up to :accounts defined.", array(':user' => $user['is_premium'] ? ht("premium user") : ht("free user"), ':accounts' => plural("individual security", "individual securities", get_premium_value($user, 'securities'))));
echo "\n";
if (!$user['is_premium']) {
    echo t("To increase this limit, please purchase a :premium_account.", array(':premium_account' => link_to(url_for('premium'), ht("premium account"))));
}
?>
</p>
Exemplo n.º 18
0
$q = db()->prepare("SELECT * FROM graph_pages WHERE user_id=? AND id=?");
$q->execute(array(user_id(), $page_id));
if (!$q->fetch()) {
    throw new Exception("Cannot find page " . htmlspecialchars($page_id));
}
$errors = array();
$messages = array();
$user = get_user(user_id());
require_user($user);
// check premium account limits (unless we're editing a graph)
if (!$graph_id) {
    $q = db()->prepare("SELECT COUNT(*) AS c FROM graphs WHERE page_id=? AND is_removed=0 AND graph_type <> 'linebreak'");
    $q->execute(array($page_id));
    $count = $q->fetch();
    $count = $count['c'];
    if ($count >= get_premium_value($user, 'graphs_per_page')) {
        $errors[] = t("Cannot add graph: too many existing graphs on this page.") . ($user['is_premium'] ? "" : " " . t("To add more graphs on this page, upgrade to a :premium_account.", array(':premium_account' => link_to(url_for('premium'), t('premium account')))));
        set_temporary_errors($errors);
        redirect(url_for('profile', array('page' => $page_id)));
    }
}
// only permit valid values
$graph_types = graph_types();
$permitted_days = array();
foreach (get_permitted_days() as $key => $data) {
    $permitted_days[] = $data['days'];
}
$permitted_deltas = get_permitted_deltas();
if (!isset($graph_types[$graph_type])) {
    throw new Exception("Invalid graph type '" . htmlspecialchars($graph_type) . "'");
} else {
Exemplo n.º 19
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']) . ".");
             }
         }
     }
 }
Exemplo n.º 20
0
            $graph['technical_period'] = $technical['technical_period'];
        }
        render_graph_new($graph, true);
        if ($graph['graph_type'] == "linebreak" || $graph['graph_type'] == "heading") {
            ?>
</div>
</div>
<?php 
        }
    }
    if (!$graphs) {
        ?>
  <div class="graph_collection_empty">
    <?php 
        if (require_get("securities", false)) {
            if (get_premium_value($user, 'your_securities')) {
                echo t("No securities to display! You might want to add details about :your_securities, if you have any.", array(':your_securities' => link_to(url_for('wizard_accounts_securities'), t("your securities"))));
            } else {
                echo t('To display historical value graphs of your securities, please :upgrade, or add them as
            normal "security value" graphs on one of your other :reports.', array(':upgrade' => link_to(url_for('premium'), t("purchase a premium account")), ':reports' => link_to(url_for('profile'), t("report pages"))));
            }
        } else {
            echo t("No graphs to display! You might want to add one below.");
        }
        ?>
  </div>

  <?php 
        if (require_get("securities", false)) {
            ?>
  <div class="graph_collection_screenshot"><a href="<?php