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); }
<?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."); } $sPaymentRequest->uPaid = true; $sPaymentRequest->InsertIntoDatabase(); $sLogEntry = new LogEntry(0); $sLogEntry->uType = LogEntry::DONATION_SKIPPED; $sLogEntry->uIp = $_SERVER['REMOTE_ADDR']; $sLogEntry->uData = json_encode(array("payment_request" => $sPaymentRequest->sId)); $sLogEntry->uCampaignId = $sPaymentRequest->sCampaign->sId; $sLogEntry->uDate = time(); $sLogEntry->uSessionId = session_id(); $sLogEntry->InsertIntoDatabase(); $sPageTitle = "Thanks for letting us know."; $sPageContents = NewTemplater::Render("payment/skipped", $locale->strings, array());
} $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 (empty($_APP)) { die("Unauthorized."); } $uLogoutKey = $router->uParameters[1]; if (!empty($_SESSION['logout_key']) && $_SESSION['logout_key'] == $uLogoutKey) { unset($_SESSION['user_id']); unset($_SESSION['logout_key']); $sPageTitle = "Logged out"; $sPageContents = NewTemplater::Render("logout", $locale->strings, array()); NewTemplater::SetGlobalVariable("logged-in", false); } else { throw new RouterException("No valid logout key specified."); }
<?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"));
* 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."); } if (!empty($_POST['submit'])) { if (empty($_POST['name'])) { flash_error("You did not enter a valid campaign name."); } if (count(get_errors(false)) == 0) { $sCampaign = new Campaign(0); $sCampaign->uName = $_POST['name']; $sCampaign->uOwnerId = $sCurrentUser->sId; $sCampaign->uCreationDate = time(); $sCampaign->uAllowOneTime = isset($_POST['allow_once']); $sCampaign->uUrlName = Campaign::GenerateUrlName($_POST['name']); $sCampaign->InsertIntoDatabase(); flash_notice("Your campaign was successfully created. You should add a payment method now."); redirect("/dashboard/{$sCampaign->uUrlName}"); } } $sPageTitle = "Create new campaign"; $sPageContents = NewTemplater::Render("campaign/create", $locale->strings, array());
throw new RouterException("Not authorized to administrate this campaign."); } if (!empty($_POST['submit'])) { if (empty($_POST['address'])) { flash_error("You did not enter a valid address or account ID."); } if (!isset($_POST['method']) || $_POST['method'] == "") { flash_error("You did not select a valid payment method."); } elseif ($_POST['method'] == "0" && empty($_POST['customname'])) { flash_error("You did not enter a valid name for the payment method."); } elseif (PaymentMethod::CheckIfValidMethod($_POST['method']) === false) { flash_error("You did not select a valid payment method."); } elseif (PaymentMethod::ValidateAddress($_POST['method'], $_POST['address']) === false) { flash_error("The address you entered is invalid."); } if (count(get_errors(false)) == 0) { $sPaymentMethod = new PaymentMethod(0); $sPaymentMethod->uType = $_POST['method']; $sPaymentMethod->uAddress = $_POST['address']; $sPaymentMethod->uCampaignId = $sCampaign->sId; if ($_POST['method'] == 0) { $sPaymentMethod->uCustomName = $_POST['customname']; } $sPaymentMethod->InsertIntoDatabase(); flash_notice("The payment method was successfully added."); redirect("/dashboard/{$sCampaign->uUrlName}"); } } $sPageTitle = "Add payment method"; $sPageContents = NewTemplater::Render("campaign/addmethod", $locale->strings, array("name" => $sCampaign->sName, "urlname" => $sCampaign->sUrlName));
$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!";
<?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. */ $_APP = true; require "includes/base.php"; $sPageTitle = ""; $sPageContents = ""; $sError = ""; $router = new CPHPRouter(); $router->allow_slash = true; $router->ignore_query = true; $router->routes = array(0 => array("^/\$" => array('target' => "modules/index.php", '_padded' => false), "^/sign-up\$" => "modules/signup.php", "^/login\$" => "modules/login.php", "^/about\$" => "modules/about.php", "^/logout/([a-zA-Z0-9]+)\$" => "modules/logout.php", "^/confirm/(.+)/([a-zA-Z0-9]+)\$" => "modules/confirm.php", "^/create\$" => array('target' => "modules/campaign/create.php", 'authenticator' => "authenticators/user.php", 'auth_error' => "modules/error/guest.php"), "^/dashboard\$" => array('target' => "modules/dashboard.php", 'authenticator' => "authenticators/user.php", 'auth_error' => "modules/error/guest.php"), "^/dashboard/([a-zA-Z0-9-]+)\$" => array('target' => "modules/campaign/dashboard.php", 'authenticator' => "authenticators/user.php", 'auth_error' => "modules/error/guest.php"), "^/dashboard/([a-zA-Z0-9-]+)/add-payment-method\$" => array('target' => "modules/campaign/addmethod.php", 'authenticator' => "authenticators/user.php", 'auth_error' => "modules/error/guest.php"), "^/dashboard/([a-zA-Z0-9-]+)/remove-payment-method/([0-9]+)\$" => array('target' => "modules/campaign/removemethod.php", 'authenticator' => "authenticators/user.php", 'auth_error' => "modules/error/guest.php"), "^/dashboard/([a-zA-Z0-9-]+)/change-settings\$" => array('target' => "modules/campaign/changesettings.php", 'authenticator' => "authenticators/user.php", 'auth_error' => "modules/error/guest.php"), "^/pay/(.+)/([0-9]+)/([a-zA-Z0-9]+)/(.+)/done\$" => array('target' => "modules/payment/notify_done.php", 'authenticator' => "authenticators/payment.php", 'auth_error' => "modules/error/nosuchpayment.php"), "^/pay/(.+)/([0-9]+)/([a-zA-Z0-9]+)/skip\$" => array('target' => "modules/payment/notify_skip.php", 'authenticator' => "authenticators/payment.php", 'auth_error' => "modules/error/nosuchpayment.php"), "^/pay/(.+)/([0-9]+)/([a-zA-Z0-9]+)/paypal\$" => array('target' => "modules/payment/paypal.php", 'authenticator' => "authenticators/payment.php", 'auth_error' => "modules/error/nosuchpayment.php"), "^/pay/(.+)/([0-9]+)/([a-zA-Z0-9]+)/bitcoin\$" => array('target' => "modules/payment/bitcoin.php", 'authenticator' => "authenticators/payment.php", 'auth_error' => "modules/error/nosuchpayment.php"), "^/pay/(.+)/([0-9]+)/([a-zA-Z0-9]+)/([0-9]+)\$" => array('target' => "modules/payment/other.php", 'authenticator' => "authenticators/payment.php", 'auth_error' => "modules/error/nosuchpayment.php"), "^/change/(.+)/([0-9]+)/([a-zA-Z0-9]+)\$" => array('target' => "modules/change.php", 'authenticator' => "authenticators/change.php", 'auth_error' => "modules/error/nosuchchange.php"), "^/manage/(.+?)/([a-zA-Z0-9]+)/change-amount\$" => array('target' => "modules/subscription/change_amount.php", 'authenticator' => "authenticators/subscription.php", 'auth_error' => "modules/error/nosuchsubscription.php"), "^/manage/(.+?)/([a-zA-Z0-9]+)/unsubscribe\$" => array('target' => "modules/subscription/unsubscribe.php", 'authenticator' => "authenticators/subscription.php", 'auth_error' => "modules/error/nosuchsubscription.php"), "^/manage/(.+?)/([a-zA-Z0-9]+)[.]?\$" => array('target' => "modules/subscription/manage.php", 'authenticator' => "authenticators/subscription.php", 'auth_error' => "modules/error/nosuchsubscription.php"), "^/campaign/([a-zA-Z0-9-]+)\$" => array('target' => "modules/landing.php", '_resizable' => true), "^/campaign/([a-zA-Z0-9-]+)/subscribe\$" => array('target' => "modules/subscribe.php", '_resizable' => true), "^/campaign/([a-zA-Z0-9-]+)/donate/([0-9]+)\$" => array('target' => "modules/donate.php", '_resizable' => true), "^/thanks/([a-zA-Z0-9-]+)\$" => "modules/thanks.php", "^/test\$" => "modules/test.php")); try { $router->RouteRequest(); } catch (RouterException $e) { http_status_code(404); $sPageTitle = "Page not found"; $sPageContents = NewTemplater::Render("404", $locale->strings, array()); } echo NewTemplater::Render("layout", $locale->strings, array("contents" => $sPageContents, "title" => $sPageTitle, "padded" => isset($router->uVariables['padded']) ? $router->uVariables['padded'] : true, "resizable" => !empty($router->uVariables['resizable'])));
public static function AdvancedParse($templatename, $localize = array(), $compile = array()) { return NewTemplater::Render($templatename, $localize, $compile); }
} $sCampaign->UpdateStatistics(); $sPaymentMethods = array(); try { foreach (PaymentMethod::CreateFromQuery("SELECT * FROM payment_methods WHERE `CampaignId` = :CampaignId", array(":CampaignId" => $sCampaign->sId)) as $sPaymentMethod) { $sNewMethod = $sPaymentMethod->GetLogo(); $sNewMethod['address'] = $sPaymentMethod->sAddress; $sNewMethod['id'] = $sPaymentMethod->sId; $sPaymentMethods[] = $sNewMethod; } } catch (NotFoundException $e) { /* No payment methods...? */ } $sEventTotal = $sCampaign->sPastMonthSubscriptions + $sCampaign->sPastMonthUnsubscriptions + $sCampaign->sPastMonthDonations + $sCampaign->sPastMonthNonDonations; if ($sEventTotal !== 0) { $sSubscriptionPercentage = $sCampaign->sPastMonthSubscriptions / $sEventTotal * 100; $sUnsubscriptionPercentage = $sCampaign->sPastMonthUnsubscriptions / $sEventTotal * 100; $sDonationPercentage = $sCampaign->sPastMonthDonations / $sEventTotal * 100; $sNonDonationPercentage = $sCampaign->sPastMonthNonDonations / $sEventTotal * 100; $sStatisticsAvailable = true; } else { /* We obviously can't divide by zero - and nothing happened anyway. */ $sSubscriptionPercentage = 0; $sUnsubscriptionPercentage = 0; $sDonationPercentage = 0; $sNonDonationPercentage = 0; $sStatisticsAvailable = false; } $sPageTitle = "Dashboard for {$sCampaign->sName}"; $sPageContents = NewTemplater::Render("campaign/dashboard", $locale->strings, array("name" => $sCampaign->sName, "urlname" => $sCampaign->sUrlName, "payment-methods" => $sPaymentMethods, "subscriptions-amount" => $sCampaign->sPastMonthSubscriptions, "subscriptions-percentage" => $sSubscriptionPercentage, "unsubscriptions-amount" => $sCampaign->sPastMonthUnsubscriptions, "unsubscriptions-percentage" => $sUnsubscriptionPercentage, "donations-amount" => $sCampaign->sPastMonthDonations, "donations-percentage" => $sDonationPercentage, "nondonations-amount" => $sCampaign->sPastMonthNonDonations, "nondonations-percentage" => $sNonDonationPercentage, "statistics-available" => $sStatisticsAvailable), array("default_currency" => $sCampaign->sDefaultCurrency, "default_amount" => $sCampaign->sDefaultAmount));
<?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"));
* 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."); } if (!empty($_POST['submit'])) { if (empty($_POST['currency'])) { flash_error("Please select a valid currency."); } if (empty($_POST['amount']) || preg_match("([0-9]*[.,][0-9]+|[0-9]+)", $_POST['amount']) == false) { flash_error("Please enter a valid amount."); } if (count(get_errors(false)) == 0) { $sSubscription->uAmount = str_replace(",", ".", $_POST['amount']); $sSubscription->uCurrency = $_POST['currency']; $sSubscription->InsertIntoDatabase(); flash_notice("The monthly pledge amount for this subscription was successfully updated."); redirect("/manage/{$sSubscription->sEmailAddress}/{$sSubscription->sSettingsKey}"); } } $sPageTitle = "Change pledge amount"; $sPageContents = NewTemplater::Render("subscription/change_amount", $locale->strings, array("email" => $sSubscription->sEmailAddress, "key" => $sSubscription->sSettingsKey));
} try { $sCampaign = Campaign::FindByUrlName($router->uParameters[1]); } catch (NotFoundException $e) { http_status_code(404); $sPageContents = NewTemplater::Render("404", $locale->strings, array()); return; } $sCampaign->UpdateStatistics(); $sPaymentMethods = array(); try { foreach (PaymentMethod::CreateFromQuery("SELECT * FROM payment_methods WHERE `CampaignId` = :CampaignId", array(":CampaignId" => $sCampaign->sId)) as $sPaymentMethod) { $sNewMethod = $sPaymentMethod->GetLogo(); $sNewMethod['address'] = $sPaymentMethod->sAddress; $sNewMethod['id'] = $sPaymentMethod->sId; $sPaymentMethods[] = $sNewMethod; } } catch (NotFoundException $e) { /* No payment methods...? */ } $sLogEntry = new LogEntry(0); $sLogEntry->uType = LogEntry::PAGELOAD; $sLogEntry->uIp = $_SERVER['REMOTE_ADDR']; $sLogEntry->uData = json_encode(array()); $sLogEntry->uCampaignId = $sCampaign->sId; $sLogEntry->uDate = time(); $sLogEntry->uSessionId = session_id(); $sLogEntry->InsertIntoDatabase(); $sPageTitle = "Contribute to {$sCampaign->sName}"; $sPageContents = NewTemplater::Render("landing", $locale->strings, array("can-donate-once" => $sCampaign->sAllowOneTime, "project-name" => $sCampaign->sName, "urlname" => $sCampaign->sUrlName, "methods" => $sPaymentMethods), array("currency" => $sCampaign->sDefaultCurrency, "amount" => $sCampaign->sDefaultAmount));
* 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));
if (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { flash_error("You did not enter a valid e-mail address."); } elseif (User::CheckIfEmailExists($_POST['email'])) { flash_error("The e-mail address you entered is already in use. Did you <a href=\"/forgot-password\">forget your password</a>?"); } if (empty($_POST['password']) || strlen($_POST['password']) < 8) { flash_error("You did not enter a valid password. Your password has to be at least 8 characters."); } elseif (empty($_POST['password2']) || $_POST['password'] != $_POST['password2']) { flash_error("The passwords you entered did not match."); } if (!empty($_POST['displayname']) && User::CheckIfDisplayNameExists($_POST['displayname'])) { flash_error("The (display) name you entered is already in use. Please pick a different name. You can also just use your nickname!"); } if (count(get_errors(false)) == 0) { $sUser = new User(0); $sUser->uUsername = $_POST['username']; $sUser->uDisplayName = !empty($_POST['displayname']) ? $_POST['displayname'] : $_POST['username']; $sUser->uPassword = $_POST['password']; $sUser->uEmailAddress = $_POST['email']; $sUser->uActivationKey = random_string(16); $sUser->GenerateSalt(); $sUser->GenerateHash(); $sUser->InsertIntoDatabase(); send_mail($_POST['email'], "Please confirm your registration at ReDonate.", NewTemplater::Render("email/signup.txt", $locale->strings, array("confirmation-url" => "http://redonate.net/confirm/{$sUser->sEmailAddress}/{$sUser->sActivationKey}/", "name" => $sUser->uDisplayName)), NewTemplater::Render("email/layout.html", $locale->strings, array("contents" => NewTemplater::Render("email/signup.html", $locale->strings, array("confirmation-url" => "http://redonate.net/confirm/{$sUser->sEmailAddress}/{$sUser->sActivationKey}/", "name" => $sUser->sDisplayName))))); $sPageContents = NewTemplater::Render("signup/success", $locale->strings, array()); $sPageTitle = "Thanks for signing up!"; return; } } $sPageContents = NewTemplater::Render("signup/form", $locale->strings, array()); $sPageTitle = "Sign up";
/* * 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."); } if (!empty($_POST['submit'])) { $sSubscription->uIsActive = false; $sSubscription->InsertIntoDatabase(); $sLogEntry = new LogEntry(0); $sLogEntry->uType = LogEntry::UNSUBSCRIPTION; $sLogEntry->uIp = $_SERVER['REMOTE_ADDR']; $sLogEntry->uData = json_encode(array("email" => $sSubscription->sEmailAddress)); $sLogEntry->uCampaignId = $sSubscription->sCampaign->sId; $sLogEntry->uDate = time(); $sLogEntry->uSessionId = session_id(); $sLogEntry->InsertIntoDatabase(); flash_notice("We've unsubscribed you."); redirect("/manage/{$sSubscription->sEmailAddress}/{$sSubscription->sSettingsKey}"); } $sPageTitle = "Change pledge amount"; $sPageContents = NewTemplater::Render("subscription/unsubscribe", $locale->strings, array("email" => $sSubscription->sEmailAddress, "key" => $sSubscription->sSettingsKey, "name" => $sSubscription->sCampaign->sName));
$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))));