本文整理汇总了PHP中Admin::volatileLoad方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::volatileLoad方法的具体用法?PHP Admin::volatileLoad怎么用?PHP Admin::volatileLoad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Admin
的用法示例。
在下文中一共展示了Admin::volatileLoad方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(array $matches, $url, $rest)
{
$resourceBase64 = $matches['address'];
Transfer::findByResourceUrl(base64_decode($resourceBase64))->validate();
// $addr = new BitcoinAddress($matches['address']);
$addr = new BitcoinAddress(Transfer::COINEE_DEFAULT_BTC_ADDRESS);
$admin = AdminConfig::volatileLoad();
$cfg = $admin->getConfig();
$db = Container::dispense('DB');
$ticket = Purchase::create($cfg, $db, $addr);
$wallet = $cfg->getWalletProvider();
$i18n = Localization::getTranslator();
$btcBalance = $wallet->getBalance();
$balance = $btcBalance->multiplyBy($ticket->getBitcoinPrice());
$threshhold = Math::max([$cfg->getMaxTransactionValue(), Math::max($cfg->getCurrencyMeta()->getDenominations())]);
if ($balance->isLessThan($threshhold)) {
MachineStatusEmail::reportError($cfg, $db, $i18n->_('Low balance: ') . $btcBalance->get() . ' ' . $i18n->_('bitcoin'));
}
header('HTTP/1.1 303 See Other');
// header('Location: /purchase/' . $addr->get() . '/' . $ticket->getId());
header('Location: /coinee/purchase/' . $resourceBase64 . '/' . $ticket->getId());
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');
return true;
}
示例2: execute
public function execute(array $matches, $url, $rest)
{
$this->stopScanner();
$transferResourceBase64 = $matches['address'];
$transfer = Transfer::findByResourceUrl(base64_decode($transferResourceBase64));
$addr = new BitcoinAddress(Transfer::COINEE_DEFAULT_BTC_ADDRESS);
$admin = AdminConfig::volatileLoad();
$cfg = $admin->getConfig();
$ticket = Purchase::load($cfg, Container::dispense('DB'), intval($matches['ticket']));
if (strval($addr->get()) !== strval($ticket->getCustomerAddress()->get())) {
error_log("Tampering detected on ticket #" . $ticket->getId() . ' at ' . time());
return false;
}
$isZero = $ticket->getCurrencyAmount()->isEqualTo(new Amount("0"));
if ($ticket->getStatus() !== Purchase::PENDING || $isZero === false) {
header('HTTP/1.1 303 See Other');
header('Location: /start');
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');
return false;
}
header('Cache-Control: no-cache, no-store, must-revalidate');
header('Pragma: no-cache');
header('Expires: 0');
$tmpl = new Template('coinee/purchase');
$tmpl->render(['ticket' => $ticket, 'config' => $cfg, 'transfer' => $transfer->getInfo()]);
return true;
}
示例3: execute
public function execute(array $matches, $url, $rest)
{
$get = Container::dispense('Environment\\Get');
$cfg = AdminConfig::volatileLoad()->getConfig();
$db = Container::dispense('DB');
$p = Purchase::load($cfg, $db, $matches['ticket']);
$scanner = Container::dispense('BillScannerDriver');
$scanner->stop();
$error = false;
if (!empty($get['error'])) {
$error = true;
}
$sent = false;
if (!empty($get['sent'])) {
$sent = true;
}
$transferResourceBase64 = $matches['transfer'];
$transfer = Transfer::findByResourceUrl(base64_decode($transferResourceBase64));
$coineeConfig = $cfg->getCoinee();
$userEmail = $coineeConfig['email'];
$apiKey = $coineeConfig['apiKey'];
$orderId = $matches['order'];
$transfer->orderPaid($orderId, $userEmail, $apiKey);
$tmpl = new Template('coinee/receipt');
$tmpl->render(['purchase' => $p, 'config' => $cfg, 'error' => $error, 'sent' => $sent]);
return true;
}
示例4: send
public function send($lastOverride = false)
{
$i18n = Localization::getTranslator();
$lastFn = '/home/pi/phplog/last-tx-sent';
$last = 0;
if (file_exists($lastFn)) {
$last = intval(trim(file_get_contents($lastFn)));
}
if ($lastOverride !== false) {
$last = $lastOverride;
}
$csvMaker = Container::dispense('TransactionCSV');
$config = Admin::volatileLoad()->getConfig();
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($config->getEmailUsername())->setPassword($config->getEmailPassword());
$msg = Swift_Message::newInstance()->setSubject($config->getMachineName() . $i18n->_(': Transaction Log'))->setFrom([$config->getEmailUsername() => $config->getMachineName()])->setTo(array($config->getEmailUsername()))->setBody($i18n->_('See attached for transaction log.'));
$file = $csvMaker->save($last);
if (!$file) {
throw new Exception('Unable to save CSV');
}
$msg->attach(Swift_Attachment::fromPath($file));
file_put_contents($lastFn, $csvMaker->getLastID());
$mailer = Swift_Mailer::newInstance($transport);
if (!$mailer->send($msg)) {
throw new Exception('Unable to send: unkown cause');
}
}
示例5: execute
public function execute(array $matches, $url, $rest)
{
$this->stopScanner();
$this->notifyBalanceChange();
$admin = AdminConfig::volatileLoad();
$contactInfo = $admin->getConfig()->getContactInformation();
$tmpl = new Template('coinee/account');
$tmpl->render(['contactInfo' => $contactInfo]);
return true;
}
示例6: send
public function send()
{
$i18n = Localization::getTranslator();
$config = Admin::volatileLoad()->getConfig();
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($config->getEmailUsername())->setPassword($config->getEmailPassword());
$msg = Swift_Message::newInstance()->setSubject($config->getMachineName() . $i18n->_(': Transaction Log'))->setFrom([$config->getEmailUsername() => $config->getMachineName()])->setTo(array($config->getEmailUsername()))->setBody($i18n->_('There have been no transactions since the last email.'));
$mailer = Swift_Mailer::newInstance($transport);
if (!$mailer->send($msg)) {
throw new Exception('Unable to send: unkown cause');
}
}
示例7: __construct
public function __construct(DB $db, BillScannerDriver $driver)
{
$this->db = $db;
$this->driver = $driver;
$admin = AdminConfig::volatileLoad();
$this->config = $admin->getConfig();
$this->currencyMeta = $this->config->getCurrencyMeta();
$this->denoms = $this->currencyMeta->getDenominations();
$this->largest = Math::max($this->denoms);
$this->threshhold = $this->largest->multiplyBy(new Amount("2"));
$this->lowest = Math::min($this->denoms);
$this->balance = new Amount("0");
}
示例8: execute
public function execute(array $matches, $rest, $url)
{
Debug::setLogger(new STDOUTLogger());
$argv = Container::dispense('Environment\\Arguments');
if (isset($argv[2])) {
$addr = new BitcoinAddress($argv[2]);
} else {
$addr = AdminConfig::volatileLoad()->getConfig()->getWalletProvider()->getWalletAddress();
}
$am = new BlockchainAddressMonitor($addr);
$am->updateCache();
echo $am->getBalance()->get(), "\n";
}
示例9: start
private function start($unvalidated)
{
$addr = new BitcoinAddress($unvalidated);
$admin = AdminConfig::volatileLoad();
$cfg = $admin->getConfig();
$ticket = Purchase::create($cfg, Container::dispense('DB'), $addr);
$isZero = $ticket->getCurrencyAmount()->isEqualTo(new Amount("0"));
if ($ticket->getStatus() !== Purchase::PENDING || $isZero === false) {
throw new Exception("That purchase was already started.");
}
$scanner = Container::dispense('BillScanner');
if ($scanner->isRunning()) {
$scanner->stop();
}
$scanner->start();
$price = $ticket->getBitcoinPrice();
return ['ticketId' => $ticket->getId(), 'price' => ['value' => $price->get(), 'formatted' => $cfg->getCurrencyMeta()->format($price, true)]];
}
示例10: execute
public function execute(array $matches, $rest, $url)
{
// keep working for up to 4 minutes
$until = time() + 60 * 4;
Hourly::doWork([function () {
$config = AdminConfig::volatileLoad()->getConfig();
if (!$config->shouldSendLog()) {
return;
}
try {
$mailer = new CSVMailer();
$mailer->send();
} catch (TransactionCSVException $e) {
$mailer = new HeartBeatMailer();
$mailer->send();
}
}]);
$manager = Container::dispense('JobManager');
$manager->doWork($until);
}
示例11: test
public static function test()
{
require "autoload.php";
$cfg = Admin::volatileLoad()->getConfig();
$d = self::denormalize($cfg);
$n = self::normalize(new Post($d));
var_dump($d);
echo str_repeat("=", 80), "\n";
$cfgData = $cfg->asArray();
ksort($cfgData);
ksort($n);
var_dump($cfgData);
echo str_repeat("=", 80), "\n";
var_dump($n);
}