当前位置: 首页>>代码示例>>PHP>>正文


PHP crypto_log函数代码示例

本文整理汇总了PHP中crypto_log函数的典型用法代码示例。如果您正苦于以下问题:PHP crypto_log函数的具体用法?PHP crypto_log怎么用?PHP crypto_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了crypto_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xchange796_query

function xchange796_query($appid, $apikey, $secretkey, $url)
{
    // from https://796.com/wiki.html
    $timestamp = time();
    $params = array('appid' => $appid, 'apikey' => $apikey, 'secretkey' => $secretkey, 'timestamp' => $timestamp);
    ksort($params);
    // "be careful that the sequence is quite important"
    $param_uri = http_build_query($params, '', '&');
    $sig = base64_encode(hash_hmac('sha1', $param_uri, $secretkey));
    $token_url = url_add("https://796.com/oauth/token", array('appid' => $appid, 'timestamp' => $timestamp, 'apikey' => $apikey, 'secretkey' => $secretkey, 'sig' => $sig));
    // our curl handle (initialize if required)
    $ch = crypto_curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; 796 PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')');
    curl_setopt($ch, CURLOPT_URL, crypto_wrap_url($token_url));
    // curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    // run the query
    $res = curl_exec($ch);
    if ($res === false) {
        throw new ExternalAPIException('Could not get reply: ' . curl_error($ch));
    }
    $dec = crypto_json_decode($res, "in authentication");
    if (isset($dec['errno']) && $dec['errno']) {
        throw new ExternalAPIException("Could not get OAuth Token: " . htmlspecialchars($dec['msg']));
    }
    if (!isset($dec['data']['access_token'])) {
        throw new ExternalAPIException("No access token provided");
    }
    $token = $dec['data']['access_token'];
    crypto_log("Obtained OAuth token");
    // now, call the given URL
    // 796 has a bug where the token can't be urlencoded again, so we can't use url_add() (though we should)
    $destination_url = $url . "?access_token=" . $token;
    // our curl handle (initialize if required)
    $ch = crypto_curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; 796 PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')');
    curl_setopt($ch, CURLOPT_URL, crypto_wrap_url($destination_url));
    // curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    // run the query
    $res = curl_exec($ch);
    if ($res === false) {
        throw new ExternalAPIException('Could not get reply: ' . curl_error($ch));
    }
    $dec = crypto_json_decode($res, "in request");
    if (isset($dec['errno']) && $dec['errno']) {
        throw new ExternalAPIException("Error in reply: " . htmlspecialchars($dec['msg']));
    }
    if (!isset($dec['data'])) {
        throw new ExternalAPIException("No data in reply");
    }
    return $dec['data'];
}
开发者ID:phpsource,项目名称:openclerk,代码行数:57,代码来源:796.php

示例2: callback

 function callback($data)
 {
     $table = $this->table;
     $query = array();
     $args = array();
     foreach ($data as $key => $value) {
         $query[] = $key . " = :" . $key;
         $args[$key] = $value;
     }
     $args["id"] = $this->account['id'];
     crypto_log("Self-updating table '{$table}'");
     $q = db()->prepare("UPDATE {$table} SET " . implode(", ", $query) . " WHERE id=:id");
     $q->execute($args);
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:14,代码来源:discovered.php

示例3: delete_user

function delete_user($id)
{
    $user = get_user($id);
    if (!$user) {
        throw new Exception("No such user {$id}");
    }
    crypto_log("Deleting user " . ($user ? htmlspecialchars(print_r($user, true)) : "<i>(phantom)</i>"));
    // go through all accounts
    $already_done = array();
    foreach (account_data_grouped() as $label => $accounts) {
        foreach ($accounts as $key => $account) {
            if ($account['table'] != 'graphs' && !isset($already_done[$account['table']])) {
                delete_from($account['table']);
                $already_done[$account['table']] = 1;
            }
        }
    }
    delete_from('balances');
    delete_from('address_balances');
    delete_from('hashrates');
    delete_from('securities');
    delete_from('offsets');
    delete_from('summary_instances');
    delete_from('summaries');
    delete_from('graph_data_summary');
    delete_from('graph_data_balances');
    delete_from('pending_subscriptions');
    // delete graphs
    crypto_log("Deleting graphs...");
    $q = db()->prepare("SELECT * FROM graph_pages WHERE user_id=?");
    $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']));
        crypto_log("(" . number_format($q->rowCount()) . " rows deleted)");
    }
    delete_from('graph_pages');
    delete_from('managed_graphs');
    crypto_log("Deleting user_properties...");
    $q = db()->prepare("DELETE FROM user_properties WHERE id=?");
    $q->execute(array($user['id']));
    crypto_log("(" . number_format($q->rowCount()) . " rows deleted)");
    // finally delete the user object
    crypto_log("Deleting user...");
    $user = Users\User::findUser(db(), $user['id']);
    $user->delete(db());
}
开发者ID:phpsource,项目名称:openclerk,代码行数:48,代码来源:delete_user.php

示例4: get_user

<?php

/**
 * An existing free user has not logged in within X days and we
 * now need to disable their account.
 */
// get the relevant user info
$user = get_user($job['arg_id']);
if (!$user) {
    throw new JobException("Cannot find user ID " . $job['arg_id']);
}
// check that they're not a premium user etc - this should never happen
if ($user['is_premium']) {
    throw new JobException("Premium user was requested to be disabled - this should not happen");
}
// update user (before sending email)
$q = db()->prepare("UPDATE user_properties SET is_disabled=1,disabled_at=NOW() WHERE id=? LIMIT 1");
$q->execute(array($user['id']));
// construct email
if ($user['email']) {
    $disables_at = strtotime(($user['last_login'] ? $user['last_login'] : $user['created_at']) . " +" . get_site_config('user_expiry_days') . " day");
    send_user_email($user, "disable", array("name" => $user['name'] ? $user['name'] : $user['email'], "days" => number_format(get_site_config('user_expiry_days')), "disables" => iso_date($disables_at), "disables_text" => recent_format($disables_at, false, ""), "url" => absolute_url(url_for("user#user_premium")), "login" => absolute_url(url_for("login")), "profile" => absolute_url(url_for("profile"))));
    crypto_log("Sent disabled account e-mail to " . htmlspecialchars($user['email']) . ".");
} else {
    crypto_log("User had no valid e-mail address.");
}
开发者ID:phpsource,项目名称:openclerk,代码行数:26,代码来源:disable.php

示例5: db

<?php

/**
 * Generic API job.
 */
$exchange = "generic";
// get the relevant address
$q = db()->prepare("SELECT * FROM accounts_generic WHERE user_id=? AND id=?");
$q->execute(array($job['user_id'], $job['arg_id']));
$account = $q->fetch();
if (!$account) {
    throw new JobException("Cannot find a {$exchange} account " . $job['arg_id'] . " for user " . $job['user_id']);
}
$balance = crypto_get_contents(crypto_wrap_url($account['api_url']));
if (!is_numeric($balance)) {
    crypto_log("{$exchange} balance for " . htmlspecialchars($account['api_url']) . " is non-numeric: " . htmlspecialchars($balance));
    throw new ExternalAPIException("Generic API returned non-numeric balance: " . htmlspecialchars(substr($balance, 0, 100)));
} else {
    // issue #11: add editable multiplier
    crypto_log("{$exchange} balance: {$balance} * " . $account['multiplier']);
    $balance = $balance * $account['multiplier'];
    crypto_log("{$exchange} balance for " . htmlspecialchars($account['api_url']) . ": " . $balance);
}
insert_new_balance($job, $account, $exchange, $account['currency'], $balance);
开发者ID:phpsource,项目名称:openclerk,代码行数:24,代码来源:generic.php

示例6: havelock_query

}
require __DIR__ . "/_havelock.php";
$content = havelock_query("https://www.havelockinvestments.com/r/balance", array('key' => $account['api_key']));
// balance, balanceavailable, balanceescrow
$wallet = $content['balance']['balance'];
$balance = 0;
crypto_log("{$exchange} wallet balance for " . $job['user_id'] . ": " . $wallet);
// set is_recent=0 for all old security instances for this user
$q = db()->prepare("UPDATE securities SET is_recent=0 WHERE user_id=? AND exchange=? AND account_id=?");
$q->execute(array($job['user_id'], $exchange, $account['id']));
// assume we don't need to delay
$content = havelock_query("https://www.havelockinvestments.com/r/portfolio", array('key' => $account['api_key']));
if ($content['portfolio'] && is_array($content['portfolio'])) {
    foreach ($content['portfolio'] as $entry) {
        // the API returns the marketvalue, so we can just use that rather than calculate it from previous jobs (like btct)
        crypto_log("{$exchange} security balance for " . htmlspecialchars($entry['symbol']) . ": " . $entry['quantity'] . '*' . $entry['lastprice'] . "=" . $entry['marketvalue']);
        $balance += $entry['marketvalue'];
        // find the security ID, if there is one
        $q = db()->prepare("SELECT * FROM securities_havelock WHERE name=?");
        $q->execute(array($entry['symbol']));
        $security_def = $q->fetch();
        if ($security_def) {
            // insert security instance
            $q = db()->prepare("INSERT INTO securities SET user_id=:user_id, exchange=:exchange, security_id=:security_id, quantity=:quantity, account_id=:account_id, is_recent=1");
            $q->execute(array('user_id' => $job['user_id'], 'exchange' => $exchange, 'security_id' => $security_def['id'], 'quantity' => $entry['quantity'], 'account_id' => $account['id']));
        }
    }
}
// we've now calculated both the wallet balance + the value of all securities
insert_new_balance($job, $account, $exchange . "_wallet", $currency, $wallet);
insert_new_balance($job, $account, $exchange . "_securities", $currency, $balance);
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:havelock.php

示例7: crypto_json_decode

 * so we will have historical data even if no user has the security yet.
 */
$exchange = "securities_litecoininvest";
$currency = 'ltc';
// get the API data
$json = crypto_json_decode(crypto_get_contents(crypto_wrap_url('https://www.litecoininvest.com/api/ticker')));
foreach ($json as $security => $data) {
    crypto_log("Parsing security '" . htmlspecialchars($security) . "'");
    // we now have a new value
    $balance = $data['bid'];
    // also available: ask, latest, outstanding, 24h_vol, etc
    // if this security has a balance of 0, then it's worthless and it's not really
    // worth saving into the database
    if ($balance == 0) {
        crypto_log("Security '" . htmlspecialchars($security) . "' had a bid of 0: ignoring");
        continue;
    }
    $q = db()->prepare("SELECT * FROM securities_litecoininvest WHERE name=?");
    $q->execute(array($security));
    $security_def = $q->fetch();
    if (!$security_def) {
        // need to insert a new security definition, so we can later get its value
        // we can't calculate the value of this security yet
        crypto_log("No securities_litecoininvest definition existed for '" . htmlspecialchars($security) . "': adding in new definition");
        $q = db()->prepare("INSERT INTO securities_litecoininvest SET name=?");
        $q->execute(array($security));
        $security_def = array('name' => $security, 'id' => db()->lastInsertId());
    }
    // since we already have bid data here, we might as well save it for free
    insert_new_balance($job, $security_def, $exchange, $currency, $balance);
}
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:litecoininvest.php

示例8: get_wizard_account_type

        $wizard = get_wizard_account_type($account['wizard']);
        if (!$wizard['transaction_creation']) {
            continue;
        }
        $q = db()->prepare("SELECT * FROM " . $account['table'] . " WHERE user_id=?" . (isset($account['query']) ? $account['query'] : false));
        $q->execute(array($job['user_id']));
        while ($a = $q->fetch()) {
            $a['exchange'] = $exchange;
            $current_accounts[$exchange . " " . $a['id']] = $a;
        }
    }
}
crypto_log("User " . $job['user_id'] . " has " . count($current_accounts) . " accounts to parse.");
// are there any creators that need to be deleted for this user?
$q = db()->prepare("SELECT * FROM transaction_creators WHERE user_id=?");
$q->execute(array($job['user_id']));
$to_delete = array();
while ($a = $q->fetch()) {
    if (!isset($current_accounts[$a['exchange'] . " " . $a['account_id']])) {
        $to_delete[] = $a['id'];
    } else {
        unset($current_accounts[$a['exchange'] . " " . $a['account_id']]);
    }
}
if ($to_delete) {
    crypto_log("Need to delete " . count($to_delete) . " old transaction creators");
    $q = db()->prepare("DELETE FROM transaction_creators WHERE user_id=? AND id IN (" . implode(",", $to_delete) . ")");
    $q->execute(array($job['user_id']));
}
crypto_log("Complete.");
开发者ID:phpsource,项目名称:openclerk,代码行数:30,代码来源:transaction_creator.php

示例9: array

                        $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']);
                        } else {
                            throw new JobException("Unknown summary_instance summary_type '" . htmlspecialchars($account['summary_type']) . "'");
                        }
                    }
                }
                $args['label_uc'] = capitalize($args['label']);
                break;
            default:
                throw new JobException("Unknown notification type for email '" . $notification['notification_type'] . "'");
        }
        send_user_email($user, $email_template, $args);
        crypto_log("Sent notification e-mail to " . htmlspecialchars($user['email']) . ".");
        // update user stats
        $q = db()->prepare("UPDATE user_properties SET notifications_sent=notifications_sent+1 WHERE id=?");
        $q->execute(array($user['id']));
    }
    // update the notification
    $q = db()->prepare("UPDATE notifications SET is_notified=1,last_notification=NOW(),last_value=?,notifications_sent=notifications_sent+1 WHERE id=?");
    $q->execute(array($current_value, $notification['id']));
} else {
    crypto_log("Trigger not successful.");
    // update the notification
    $q = db()->prepare("UPDATE notifications SET is_notified=0,last_value=? WHERE id=?");
    $q->execute(array($current_value, $notification['id']));
}
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:notification.php

示例10: getBalanceAtBlock


//.........这里部分代码省略.........
         // don't return raw HTML if we can find a valid error message
         if (strpos($e->getContent(), "Not a valid address")) {
             throw new BalanceException("Not a valid address", $e);
         }
         if (strpos($e->getContent(), "Address not seen on the network")) {
             throw new BalanceException("Address not seen on the network", $e);
         }
         // otherwise, throw HTML as normal
         throw new BalanceException($e->getContent(), $e);
     }
     $html = $this->stripHTML($html);
     // assumes that the page format will not change
     if (!$is_received && preg_match('#(<p>|<tr><th>|<tr><td>)Balance:?( |</th><td>|</td><td>)([0-9,\\.]+) ' . $this->currency->getAbbr() . '#im', $html, $matches)) {
         $balance = str_replace(",", "", $matches[3]);
         $logger->info("Address balance before removing unconfirmed: " . $balance);
         // transaction, block, date, amount, [balance,] currency
         if (preg_match_all('#<tr><td>.+</td><td><a href=[^>]+>([0-9]+)</a></td><td>.+?</td><td>(- |\\+ |)([0-9,\\.\\(\\)]+)</td>(|<td>([0-9\\.]+)</td>)<td>' . $this->currency->getAbbr() . '</td></tr>#im', $html, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $match) {
                 if ($match[1] >= $block) {
                     // too recent
                     $amount = str_replace(",", "", $match[3]);
                     if (substr($amount, 0, 1) == "(" && substr($amount, -1) == ")") {
                         // convert (1.23) into -1.23
                         $amount = -substr($amount, 1, strlen($amount) - 2);
                     }
                     if ($match[2] == "+ ") {
                         $amount = +$amount;
                     } else {
                         if ($match[2] == "- ") {
                             $amount = -$amount;
                         }
                     }
                     $logger->info("Removing " . $amount . " from balance: unconfirmed (block " . $match[1] . " >= " . $block . ")");
                     $balance -= $amount;
                 }
             }
             $logger->info("Confirmed balance after " . $this->confirmations . " confirmations: " . $balance);
         } else {
             $this->foundNoTransactions($logger);
         }
     } else {
         if ($is_received && preg_match('#(|<tr><th>|<tr><td>)Received:?( |</th><td>|</td><td>)([0-9,\\.]+) ' . $this->currency->getAbbr() . '#i', $html, $matches)) {
             $balance = str_replace(",", "", $matches[3]);
             $logger->info("Address received before removing unconfirmed: " . $balance);
             // transaction, block, date, amount, [balance,] currency
             if (preg_match_all('#<tr><td>.+</td><td><a href=[^>]+>([0-9]+)</a></td><td>.+?</td><td>(- |\\+ |)([0-9,\\.\\(\\)]+)</td>(|<td>([0-9\\.]+)</td>)<td>' . $this->currency->getAbbr() . '</td></tr>#im', $html, $matches, PREG_SET_ORDER)) {
                 foreach ($matches as $match) {
                     if ($match[1] >= $block) {
                         // too recent
                         $amount = str_replace(",", "", $match[3]);
                         if (substr($amount, 0, 1) == "(" && substr($amount, -1) == ")") {
                             // convert (1.23) into -1.23
                             $amount = -substr($amount, 1, strlen($amount) - 2);
                         }
                         if ($match[2] == "+ ") {
                             $amount = +$amount;
                         } else {
                             if ($match[2] == "- ") {
                                 $amount = -$amount;
                             }
                         }
                         // only consider received
                         if ($amount > 0) {
                             $logger->info("Removing " . $amount . " from received: unconfirmed (block " . $match[1] . " >= " . $block . ")");
                             $balance -= $amount;
                         }
                     }
                 }
                 $logger->info("Confirmed received after " . $this->confirmations . " confirmations: " . $balance);
             } else {
                 $this->foundNoTransactions($logger);
             }
         } else {
             if (strpos($html, "Address not seen on the network.") !== false) {
                 // the address is valid, it just doesn't have a balance
                 $balance = 0;
                 $logger->info("Address is valid, but not yet seen on network");
             } else {
                 if (strpos($html, "Not a valid address.") !== false || strpos($html, "Please enter search terms") !== false) {
                     // the address is NOT valid
                     throw new BalanceException("Not a valid address");
                 } else {
                     if (strpos($html, "this address has too many records to display") !== false) {
                         // this address is valid, and it has a balance, but it has too many records for this Abe instance
                         crypto_log("Address is valid, but has too many records to display");
                         throw new BalanceException("Address has too many transactions");
                     } else {
                         if (strpos(strtolower($html), "500 internal server error") !== false) {
                             crypto_log("Server returned 500 Internal Server Error");
                             throw new BalanceException("Server returned 500 Internal Server Error");
                         } else {
                             throw new BalanceException("Could not find balance on page");
                         }
                     }
                 }
             }
         }
     }
     return $balance;
 }
开发者ID:openclerk,项目名称:cryptocurrencies,代码行数:101,代码来源:AbstractAbeService.php

示例11: min

    // update as necessary
    $stored[$date][$user_id][$exchange][$account_id][$currency]['min'] = min($balance['balance'], $stored[$date][$user_id][$exchange][$account_id][$currency]['min']);
    $stored[$date][$user_id][$exchange][$account_id][$currency]['max'] = max($balance['balance'], $stored[$date][$user_id][$exchange][$account_id][$currency]['max']);
    $stored[$date][$user_id][$exchange][$account_id][$currency]['close'] = $balance['balance'];
    $stored[$date][$user_id][$exchange][$account_id][$currency]['samples']++;
    $stored[$date][$user_id][$exchange][$account_id][$currency]['values'][] = $balance['balance'];
}
crypto_log("Processed " . number_format($count) . " balances entries");
// we now have lots of data; insert it
// danger! danger! five nested loops!
$insert_count = 0;
foreach ($stored as $date => $a) {
    foreach ($a as $user_id => $b) {
        foreach ($b as $exchange => $c) {
            foreach ($c as $account_id => $d) {
                foreach ($d as $currency => $summary) {
                    $q = db_master()->prepare("INSERT INTO graph_data_balances SET\n              user_id=:user_id, exchange=:exchange, account_id=:account_id, currency=:currency, data_date=:data_date, samples=:samples,\n              balance_min=:min, balance_opening=:open, balance_closing=:close, balance_max=:max, balance_stdev=:stdev");
                    $q->execute(array('user_id' => $user_id, 'exchange' => $exchange, 'account_id' => $account_id, 'currency' => $currency, 'data_date' => $date, 'samples' => $summary['samples'], 'min' => $summary['min'], 'open' => $summary['open'], 'close' => $summary['close'], 'max' => $summary['max'], 'stdev' => stdev($summary['values'])));
                    $insert_count++;
                }
            }
        }
    }
}
crypto_log("Inserted " . number_format($insert_count) . " balances entries into graph_data_balances");
// finally, delete all the old data
// we've exhausted over everything so this should be safe
$q = db_master()->prepare("DELETE FROM balances WHERE created_at <= :date ORDER BY created_at ASC");
$q->execute(array("date" => $cutoff_date));
crypto_log("Deleted " . number_format($count) . " summary entries");
batch_footer();
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:batch_cleanup_balances.php

示例12: add_summary_instance

            add_summary_instance($job, 'crypto2' . $currency, $total);
        }
    }
    crypto_log("</ul>");
}
// update last_sum_job
$q = db()->prepare("UPDATE user_properties SET last_sum_job=NOW() WHERE id=?");
$q->execute(array($job['user_id']));
// and now that we have added summary instances, check for first_report
// (this is so that first_report jobs don't block up the job queue)
/**
 * Send an e-mail to new users once their first non-zero summary reports have been compiled.
 */
// reload user in case multiple summary jobs for the same user are all blocked at once
$user = get_user($job['user_id']);
if (!$user['is_first_report_sent']) {
    // is there a non-zero summary instance?
    $q = db()->prepare("SELECT * FROM summary_instances WHERE user_id=? AND is_recent=1 AND balance > 0 LIMIT 1");
    $q->execute(array($user['id']));
    if ($instance = $q->fetch()) {
        crypto_log("User has a non-zero summary instance.");
        // update that we've reported now
        $q = db()->prepare("UPDATE user_properties SET is_first_report_sent=1,first_report_sent=NOW() WHERE id=?");
        $q->execute(array($user['id']));
        // send email
        if ($user['email']) {
            send_user_email($user, "first_report", array("name" => $user['name'] ? $user['name'] : $user['email'], "url" => absolute_url(url_for("profile")), "login" => absolute_url(url_for("login")), "wizard_currencies" => absolute_url(url_for("wizard_currencies")), "wizard_addresses" => absolute_url(url_for("wizard_accounts_addresses")), "wizard_accounts" => absolute_url(url_for("wizard_accounts")), "wizard_notifications" => absolute_url(url_for("wizard_notifications")), "reports" => absolute_url(url_for("profile")), "premium" => absolute_url(url_for("premium"))));
            crypto_log("Sent first report e-mail to " . htmlspecialchars($user['email']) . ".");
        }
    }
}
开发者ID:phpsource,项目名称:openclerk,代码行数:31,代码来源:sum.php

示例13: define

<?php

/**
 * A batch script to clean up old jobs.
 * This always executes (no job framework) so it should be used sparingly or as necessary.
 *
 * Arguments (in command line, use "-" for no argument):
 *   $key/1 required the automated key
 */
define('USE_MASTER_DB', true);
// always use the master database for selects!
require __DIR__ . "/../inc/global.php";
require __DIR__ . "/_batch.php";
require_batch_key();
batch_header("Batch cleanup jobs", "batch_cleanup_jobs");
crypto_log("Current time: " . date('r'));
// simply delete all jobs that haven't executed and are over three months old
$q = db_master()->prepare("DELETE FROM jobs WHERE is_executed=1 AND executed_at < DATE_SUB(NOW(), INTERVAL 1 MONTH)");
$q->execute(array());
crypto_log("Deleted old jobs.");
batch_footer();
开发者ID:phpsource,项目名称:openclerk,代码行数:21,代码来源:batch_cleanup_jobs.php

示例14: crypto_log

<?php

/**
 * Openclerk version check job.
 */
$exchange = "version_check";
crypto_log("Local version: " . get_site_config('openclerk_version'));
// call cryptfolio.com to find the latest openclerk.org version
$version = crypto_get_contents(crypto_wrap_url(url_add('https://cryptfolio.com/version', array('absolute_url' => get_site_config('absolute_url'), 'openclerk_version' => get_site_config('openclerk_version')))));
crypto_log("Remote version: " . $version);
if (!$version) {
    throw new ExternalAPIException("Could not retrieve remote Openclerk version");
}
// compare
if (version_compare($version, get_site_config('openclerk_version')) > 0) {
    // delete any unread messages
    $q = db()->prepare("DELETE FROM admin_messages WHERE message_type=? AND is_read=0");
    $q->execute(array('version_check'));
    // and insert a new one
    $q = db()->prepare("INSERT INTO admin_messages SET message_type=?, message=?");
    $q->execute(array('version_check', '<a href="http://openclerk.org">A new version</a> of Openclerk is available: ' . $version));
    crypto_log("Inserted new admin_message.");
}
开发者ID:phpsource,项目名称:openclerk,代码行数:23,代码来源:version_check.php

示例15: crypto_log

<?php

/**
 * Restore market average data for a particular day (#457).
 */
crypto_log("Restoring market average data for day " . $job['arg_id']);
$q = db()->prepare("SELECT * FROM ticker WHERE created_at_day=? AND is_daily_data=1 AND exchange <> 'average'");
$q->execute(array($job['arg_id']));
$recents = $q->fetchAll();
crypto_log("Found " . number_format(count($recents)) . " ticker instances to recreate average data");
$exchange = array('name' => 'average');
require __DIR__ . "/_average.php";
// we can now create ticker values as necessary
foreach ($pairs as $pair) {
    if ($pair['total_volume'] > 0) {
        // delete any old average data
        $q = db()->prepare("DELETE FROM ticker WHERE exchange=:exchange AND currency1=:currency1 AND currency2=:currency2 AND created_at_day=TO_DAYS(:date)");
        $q->execute(array("date" => $recents[0]['created_at'], "exchange" => $exchange['name'], "currency1" => $pair['currency1'], "currency2" => $pair['currency2']));
        crypto_log("Deleted any old average data");
        // insert in new ticker value
        $q = db()->prepare("INSERT INTO ticker SET exchange=:exchange, currency1=:currency1, currency2=:currency2, last_trade=:last_trade, bid=:bid, ask=:ask, volume=:volume, job_id=:job_id, is_daily_data=1, created_at=:date, created_at_day=TO_DAYS(:date)");
        $q->execute(array("date" => $recents[0]['created_at'], "exchange" => $exchange['name'], "currency1" => $pair['currency1'], "currency2" => $pair['currency2'], "last_trade" => $pair['total_last_trade'] / $pair['total_volume'], "bid" => $pair['total_volume_bid'] > 0 ? $pair['total_bid'] / $pair['total_volume_bid'] : 0, "ask" => $pair['total_volume_ask'] > 0 ? $pair['total_ask'] / $pair['total_volume_ask'] : 0, "volume" => $pair['total_volume'], "job_id" => $job['id']));
        crypto_log("Inserted in new ticker ID " . db()->lastInsertId());
    }
    // no need to track average market count: this isn't used in historical data
}
开发者ID:phpsource,项目名称:openclerk,代码行数:26,代码来源:missing_average.php


注:本文中的crypto_log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。