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


PHP Currency::Convert方法代码示例

本文整理汇总了PHP中Currency::Convert方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::Convert方法的具体用法?PHP Currency::Convert怎么用?PHP Currency::Convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Currency的用法示例。


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

示例1: UpdateStatistics

 public function UpdateStatistics()
 {
     global $database, $cphp_config;
     if (!empty($cphp_config->debugmode) || $this->sLastStatisticsUpdate < time() - 60 * 5) {
         /* Update subscriber count */
         if ($result = $database->CachedQuery("SELECT COUNT(*) FROM subscriptions WHERE `CampaignId` = :CampaignId AND `Confirmed` = 1 AND `Active` = 1", array(":CampaignId" => $this->sId))) {
             $this->uSubscriberCount = $result->data[0]["COUNT(*)"];
         }
         /* Update total monthly donations */
         try {
             $sSubscriptions = Subscription::CreateFromQuery("SELECT * FROM subscriptions WHERE `CampaignId` = :CampaignId AND `Confirmed` = 1 AND `Active` = 1", array(":CampaignId" => $this->sId));
             $sTotalDonations = 0;
             foreach ($sSubscriptions as $sSubscription) {
                 $sTotalDonations += Currency::Convert("usd", $sSubscription->sCurrency, $sSubscription->sAmount);
             }
             $this->uMonthlyTotal = $sTotalDonations;
         } catch (NotFoundException $e) {
             $this->uMonthlyTotal = 0;
         }
         /* Update donation rate */
         try {
             $sDonationsAsked = LogEntry::CreateFromQuery("SELECT * FROM log_entries WHERE `CampaignId` = :CampaignId AND `Type` = :Type AND `Date` > DATE_SUB(NOW(), INTERVAL 1 MONTH)", array(":CampaignId" => $this->sId, ":Type" => LogEntry::DONATION_ASKED));
             $have_data = true;
         } catch (NotFoundException $e) {
             /* We don't have any data to work from yet. */
             $sDonationsAsked = array();
             $have_data = false;
         }
         if ($have_data) {
             try {
                 $sDonationsMade = LogEntry::CreateFromQuery("SELECT * FROM log_entries WHERE `CampaignId` = :CampaignId AND `Type` = :Type AND `Date` > DATE_SUB(NOW(), INTERVAL 1 MONTH)", array(":CampaignId" => $this->sId, ":Type" => LogEntry::DONATION_MADE));
                 $this->uDonationRate = count($sDonationsMade) / count($sDonationsAsked) * 100;
                 $this->uHaveData = true;
             } catch (NotFoundException $e) {
                 $sDonationsMade = array();
                 $this->uDonationRate = 0;
                 $this->uHaveData = false;
             }
         } else {
             $sDonationsMade = array();
             $this->uDonationRate = 100;
             $this->uHaveData = false;
         }
         /* Update projected monthly donations */
         $this->uMonthlyProjection = $this->uMonthlyTotal * ($this->uDonationRate / 100);
         /* Update past-month subscription count */
         if ($result = $database->CachedQuery("SELECT COUNT(*) FROM log_entries WHERE `CampaignId` = :CampaignId AND `Type` = :Type AND `Date` > DATE_SUB(NOW(), INTERVAL 1 MONTH)", array(":CampaignId" => $this->sId, ":Type" => LogEntry::SUBSCRIPTION_CONFIRMED), 0)) {
             $this->uPastMonthSubscriptions = $result->data[0]["COUNT(*)"];
         }
         /* Update past-month unsubscription count */
         if ($result = $database->CachedQuery("SELECT COUNT(*) FROM log_entries WHERE `CampaignId` = :CampaignId AND `Type` = :Type AND `Date` > DATE_SUB(NOW(), INTERVAL 1 MONTH)", array(":CampaignId" => $this->sId, ":Type" => LogEntry::UNSUBSCRIPTION), 0)) {
             $this->uPastMonthUnsubscriptions = $result->data[0]["COUNT(*)"];
         }
         /* Update past month donation count */
         $this->uPastMonthDonations = count($sDonationsMade);
         /* Update past month non-donation count */
         $this->uPastMonthNonDonations = count($sDonationsAsked) - count($sDonationsMade);
         $this->uLastStatisticsUpdate = time();
         $this->InsertIntoDatabase();
     }
 }
开发者ID:GodOfConquest,项目名称:redonate,代码行数:61,代码来源:campaign.php

示例2: die

<?php

/*
 * ReDonate is more free software. It is licensed under the WTFPL, which
 * allows you to do pretty much anything with it, without having to
 * ask permission. Commercial use is allowed, and no attribution is
 * required. We do politely request that you share your modifications
 * to benefit other developers, but you are under no enforced
 * obligation to do so :)
 * 
 * Please read the accompanying LICENSE document for the full WTFPL
 * licensing text.
 */
if (!isset($_APP)) {
    die("Unauthorized.");
}
try {
    $sPaymentMethod = $sPaymentRequest->sCampaign->GetPaymentMethod(PaymentMethod::BITCOIN);
} catch (NotFoundException $e) {
    throw new RouterException("No such payment method found.");
}
if ($sPaymentRequest->sCurrency != "btc") {
    $sAmount = Currency::Convert("btc", $sPaymentRequest->sCurrency, $sPaymentRequest->sAmount);
} else {
    $sAmount = $sPaymentRequest->sAmount;
}
$sPageContents = NewTemplater::Render("payment/bitcoin", $locale->strings, array("address" => $sPaymentMethod->sAddress, "amount" => Currency::Format("btc", $sAmount), "done-url" => "/pay/{$sPaymentRequest->sSubscription->sEmailAddress}/{$sPaymentRequest->sId}/{$sPaymentRequest->sKey}/bitcoin/done"));
开发者ID:GodOfConquest,项目名称:redonate,代码行数:27,代码来源:bitcoin.php

示例3: urlencode

                    $sAmount = urlencode($_POST['amount']);
                }
                $sQuotedRecipient = urlencode($sPaymentMethod->sAddress);
                $sQuotedName = urlencode("{$sCampaign->sName} (via ReDonate.net)");
                $sQuotedNumber = urlencode("0");
                $sQuotedReturnUrl = urlencode("http://redonate.net/thanks/{$sCampaign->sUrlName}");
                if (filter_var($sPaymentMethod->sAddress, FILTER_VALIDATE_EMAIL)) {
                    $target = "https://www.paypal.com/cgi-bin/webscr?business={$sQuotedRecipient}&cmd=_donations&item_name={$sQuotedName}&item_number={$sQuotedNumber}&currency_code={$sCurrency}&amount={$sAmount}&return={$sQuotedReturnUrl}";
                } else {
                    /* This is most likely a hosted button ID. We can only provide limited information in this case - we can really only set the item description. 
                     * Not sure if setting the return URL will work, but we might as well try. */
                    $target = "https://www.paypal.com/cgi-bin/webscr?hosted_button_id={$sQuotedRecipient}&cmd=_s-xclick&item_name={$sQuotedName}&return={$sQuotedReturnUrl}";
                }
                redirect($target);
                return;
            case PaymentMethod::BITCOIN:
                if ($sPaymentRequest->sCurrency != "btc") {
                    $sAmount = Currency::Convert("btc", $_POST['currency'], $_POST['amount']);
                } else {
                    $sAmount = htmlspecialchars($_POST['amount']);
                }
                $sPageContents = NewTemplater::Render("payment/bitcoin", $locale->strings, array("address" => $sPaymentMethod->sAddress, "amount" => Currency::Format("btc", $sAmount), "done-url" => "/thanks/{$sCampaign->sUrlName}"));
                return;
            default:
                $sPageContents = NewTemplater::Render("payment/other", $locale->strings, array("name" => $sPaymentMethod->sCustomName, "address" => $sPaymentMethod->sAddress, "amount" => Currency::Format($_POST['currency'], $_POST['amount']), "done-url" => "/thanks/{$sCampaign->sUrlName}"));
                return;
        }
    }
}
$sPageTitle = "Donate to {$sCampaign->sName} once";
$sPageContents = NewTemplater::Render("donate", $locale->strings, array("campaign-name" => $sCampaign->sName, "method-id" => $sPaymentMethod->sId, "urlname" => $sCampaign->sUrlName, "method-name" => $sMethodName));
开发者ID:GodOfConquest,项目名称:redonate,代码行数:31,代码来源:donate.php

示例4: die

 * obligation to do so :)
 * 
 * Please read the accompanying LICENSE document for the full WTFPL
 * licensing text.
 */
if (!isset($_APP)) {
    die("Unauthorized.");
}
try {
    $sPaymentMethod = $sPaymentRequest->sCampaign->GetPaymentMethod(PaymentMethod::PAYPAL);
} catch (NotFoundException $e) {
    throw new RouterException("No such payment method found.");
}
if (strtolower($sPaymentRequest->sCurrency) == "btc") {
    $sCurrency = urlencode("USD");
    $sAmount = round(Currency::Convert("usd", "btc", $sPaymentRequest->sAmount), 2);
} else {
    $sCurrency = urlencode(strtoupper($sPaymentRequest->sCurrency));
    $sAmount = urlencode($sPaymentRequest->sAmount);
}
$sQuotedRecipient = urlencode($sPaymentMethod->sAddress);
$sQuotedName = urlencode("{$sPaymentRequest->sCampaign->sName} (via ReDonate.net)");
$sQuotedNumber = urlencode("{$sPaymentRequest->sId}");
$sQuotedReturnUrl = urlencode("http://redonate.net/pay/{$sPaymentRequest->sSubscription->sEmailAddress}/{$sPaymentRequest->sId}/{$sPaymentRequest->sKey}/paypal/done");
if (filter_var($sPaymentMethod->sAddress, FILTER_VALIDATE_EMAIL)) {
    $target = "https://www.paypal.com/cgi-bin/webscr?business={$sQuotedRecipient}&cmd=_donations&item_name={$sQuotedName}&item_number={$sQuotedNumber}&currency_code={$sCurrency}&amount={$sAmount}&return={$sQuotedReturnUrl}";
} else {
    /* This is most likely a hosted button ID. We can only provide limited information in this case - we can really only set the item description. 
     * Not sure if setting the return URL will work, but we might as well try. */
    $target = "https://www.paypal.com/cgi-bin/webscr?hosted_button_id={$sQuotedRecipient}&cmd=_s-xclick&item_name={$sQuotedName}&return={$sQuotedReturnUrl}";
}
开发者ID:GodOfConquest,项目名称:redonate,代码行数:31,代码来源:paypal.php


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