public function GenerateEmail() { global $locale; $sText = NewTemplater::Render("email/change.txt", $locale->strings, array("campaign-name" => $this->sCampaign->sName, "confirmation-url" => "http://redonate.net/change/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}", "unsubscribe-url" => "http://redonate.net/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}", "old" => Currency::Format($this->sOldCurrency, $this->sOldAmount), "new" => Currency::Format($this->sNewCurrency, $this->sNewAmount))); $sHtml = NewTemplater::Render("email/layout.html", $locale->strings, array("contents" => NewTemplater::Render("email/change.html", $locale->strings, array("campaign-name" => $this->sCampaign->sName, "confirmation-url" => "http://redonate.net/change/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}", "unsubscribe-url" => "http://redonate.net/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}", "old" => Currency::Format($this->sOldCurrency, $this->sOldAmount), "new" => Currency::Format($this->sNewCurrency, $this->sNewAmount))))); return array("text" => $sText, "html" => $sHtml); }
public function GenerateEmail() { global $locale; $sMethods = array(); foreach ($this->sCampaign->GetPaymentMethods() as $sPaymentMethod) { $sMethods[] = array("name" => $sPaymentMethod->GetName(), "url" => $sPaymentMethod->GenerateUrl($this)); } $sText = NewTemplater::Render("email/reminder.txt", $locale->strings, array("campaign-name" => $this->sCampaign->sName, "amount" => Currency::Format($this->sCurrency, $this->sAmount), "skip-url" => "http://redonate.net/pay/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}/skip", "unsubscribe-url" => "http://redonate.net/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}", "methods" => $sMethods)); $sHtml = NewTemplater::Render("email/layout.html", $locale->strings, array("contents" => NewTemplater::Render("email/reminder.html", $locale->strings, array("campaign-name" => $this->sCampaign->sName, "amount" => Currency::Format($this->sCurrency, $this->sAmount), "skip-url" => "http://redonate.net/pay/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}/skip", "unsubscribe-url" => "http://redonate.net/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}", "methods" => $sMethods)))); return array("text" => $sText, "html" => $sHtml); }
$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}¤cy_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));
<?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"));
<?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 = PaymentMethod::CreateFromQuery("SELECT * FROM payment_methods WHERE `CampaignId` = :CampaignId AND `Id` = :Id", array(":CampaignId" => $sPaymentRequest->sCampaign->sId, ":Id" => $router->uParameters[4]), 0, true); } catch (NotFoundException $e) { throw new RouterException("No such payment method found."); } $sPageContents = NewTemplater::Render("payment/other", $locale->strings, array("name" => $sPaymentMethod->sCustomName, "address" => $sPaymentMethod->sAddress, "amount" => Currency::Format($sPaymentRequest->sCurrency, $sPaymentRequest->sAmount), "done-url" => "/pay/{$sPaymentRequest->sSubscription->sEmailAddress}/{$sPaymentRequest->sId}/{$sPaymentRequest->sKey}/{$sPaymentMethod->sId}/done"));
* Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } $sOtherSubscriptions = array(); foreach (Subscription::FindByEmail($sSubscription->sEmailAddress) as $sOtherSubscription) { /* We don't want to add the currently visible subscription to the * list of other subscriptions. */ if ($sOtherSubscription->sId != $sSubscription->sId) { if ($sOtherSubscription->sIsConfirmed == false) { $sStatus = "Awaiting confirmation"; } elseif ($sOtherSubscription->sIsActive == true) { $sStatus = "Active"; } else { $sStatus = "Cancelled"; } $sOtherSubscriptions[] = array("name" => $sOtherSubscription->sCampaign->sName, "amount" => Currency::Format($sOtherSubscription->sCurrency, $sOtherSubscription->sAmount), "key" => $sOtherSubscription->sSettingsKey, "status" => $sStatus); } } if ($sSubscription->sIsConfirmed == false) { $sStatus = "Awaiting confirmation"; } elseif ($sSubscription->sIsActive == true) { $sStatus = "Active"; } else { $sStatus = "Cancelled"; } $sPageTitle = "Manage your subscriptions"; $sPageContents = NewTemplater::Render("subscription/manage", $locale->strings, array("name" => $sSubscription->sCampaign->sName, "amount" => Currency::Format($sSubscription->sCurrency, $sSubscription->sAmount), "email" => $sSubscription->sEmailAddress, "key" => $sSubscription->sSettingsKey, "status" => $sStatus, "other" => $sOtherSubscriptions));
$sChangeRequest->uSubscriptionId = $sExistingSubscription->sId; $sChangeRequest->uCampaignId = $sExistingSubscription->sCampaign->sId; $sChangeRequest->uIsConfirmed = false; $sChangeRequest->uDate = time(); $sChangeRequest->InsertIntoDatabase(); $sEmail = $sChangeRequest->GenerateEmail(); send_mail($sExistingSubscription->sEmailAddress, "Changes to your pledge to {$sExistingSubscription->sCampaign->sName}", $sEmail['text'], $sEmail['html']); return; } $sLogEntry = new LogEntry(0); $sLogEntry->uType = LogEntry::SUBSCRIPTION; $sLogEntry->uIp = $_SERVER['REMOTE_ADDR']; $sLogEntry->uData = json_encode(array("email" => $_POST['email'])); $sLogEntry->uCampaignId = $sCampaign->sId; $sLogEntry->uDate = time(); $sLogEntry->uSessionId = session_id(); $sLogEntry->InsertIntoDatabase(); $sSubscription = new Subscription(0); $sSubscription->uEmailAddress = $_POST['email']; $sSubscription->uConfirmationKey = random_string(25); $sSubscription->uSettingsKey = random_string(25); $sSubscription->uCurrency = $_POST['currency']; $sSubscription->uAmount = str_replace(",", ".", $_POST['amount']); $sSubscription->uSubscriptionDate = time(); $sSubscription->uIsConfirmed = false; $sSubscription->uIsActive = false; $sSubscription->uCampaignId = $sCampaign->sId; $sSubscription->InsertIntoDatabase(); send_mail($_POST['email'], "Please confirm your ReDonate pledge.", NewTemplater::Render("email/confirm.txt", $locale->strings, array("project-name" => $sCampaign->sName, "confirmation-url" => "http://redonate.net/confirm/{$sSubscription->sEmailAddress}/{$sSubscription->sConfirmationKey}/", "amount" => Currency::Format($sSubscription->sCurrency, $sSubscription->sAmount))), NewTemplater::Render("email/layout.html", $locale->strings, array("contents" => NewTemplater::Render("email/confirm.html", $locale->strings, array("project-name" => $sCampaign->sName, "confirmation-url" => "http://redonate.net/confirm/{$sSubscription->sEmailAddress}/{$sSubscription->sConfirmationKey}/", "amount" => Currency::Format($sSubscription->sCurrency, $sSubscription->sAmount)))))); $sPageContents = NewTemplater::Render("subscription/success", $locale->strings, array()); $sPageTitle = "Thanks for your pledge!";
$sProjections = array(); $sSubscribers = array(); try { foreach (Campaign::CreateFromQuery("SELECT * FROM campaigns WHERE `OwnerId` = :UserId", array(":UserId" => $sCurrentUser->sId)) as $sCampaign) { $sCampaign->UpdateStatistics(); $sPaymentMethods = array(); try { foreach (PaymentMethod::CreateFromQuery("SELECT * FROM payment_methods WHERE `CampaignId` = :CampaignId", array(":CampaignId" => $sCampaign->sId)) as $sPaymentMethod) { $sPaymentMethods[] = $sPaymentMethod->GetLogo(); } } catch (NotFoundException $e) { /* No payment methods...? */ } if ($sCampaign->sHaveData) { $sPercentages[] = $sCampaign->sDonationRate; $sTotals[] = $sCampaign->sMonthlyTotal; $sProjections[] = $sCampaign->sMonthlyProjection; } $sSubscribers[] = $sCampaign->sSubscriberCount; $sCampaigns[] = array("name" => $sCampaign->sName, "urlname" => $sCampaign->sUrlName, "subscribers" => number_format($sCampaign->sSubscriberCount, 0), "rate" => number_format($sCampaign->sDonationRate, 2), "total" => Currency::Format("usd", $sCampaign->sMonthlyTotal), "projection" => Currency::Format("usd", $sCampaign->sMonthlyProjection), "one-off" => $sCampaign->sAllowOneTime, "payment-methods" => $sPaymentMethods, "have-data" => $sCampaign->sHaveData); } } catch (NotFoundException $e) { /* pass */ } $sPercentages = empty($sPercentages) ? array(0) : $sPercentages; $sTotals = empty($sTotals) ? array(0) : $sTotals; $sProjections = empty($sProjections) ? array(0) : $sProjections; $sSubscribers = empty($sSubscribers) ? array(0) : $sSubscribers; $sPageTitle = "Dashboard"; $sPageContents = NewTemplater::Render("dashboard", $locale->strings, array("campaigns" => $sCampaigns, "total-rate" => number_format(array_sum($sPercentages) / count($sPercentages), 2), "total-subscribers" => number_format(array_sum($sSubscribers), 0), "total-total" => Currency::Format("usd", array_sum($sTotals)), "total-projection" => Currency::Format("usd", array_sum($sProjections))));