Email handling, frontpage design, signup page, minor other style changes

master
Sven Slootweg 11 years ago
parent 8eab3e0e54
commit 94fe505254

@ -0,0 +1,16 @@
<?php
/*
* projectname 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."); }
$sPageContents = NewTemplater::Render("index", $locale->strings, array());

@ -0,0 +1,80 @@
<?php
/*
* projectname 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."); }
$sErrors = array();
if(!empty($_POST['submit']))
{
if(empty($_POST['username']) || !preg_match("/^[a-zA-Z0-9-.]+$/", $_POST['username']))
{
$sErrors[] = "You did not enter a valid username. Your username can only contain a-z, A-Z, 0-9, dots, and dashes.";
}
elseif(User::CheckIfUsernameExists($_POST['username']) || User::CheckIfDisplayNameExists($_POST['username']))
{
$sErrors[] = "The username you entered is already in use. Please pick a different username.";
}
if(empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
{
$sErrors[] = "You did not enter a valid e-mail address.";
}
elseif(User::CheckIfEmailExists($_POST['email']))
{
$sErrors[] = "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)
{
$sErrors[] = "You did not enter a valid password. Your password has to be at least 8 characters.";
}
elseif(empty($_POST['password2']) || $_POST['password'] != $_POST['password2'])
{
$sErrors[] = "The passwords you entered did not match.";
}
if(!empty($_POST['displayname']) && User::CheckIfDisplayNameExists($_POST['displayname']))
{
$sErrors[] = "The (display) name you entered is already in use. Please pick a different name. You can also just use your nickname!";
}
if(empty($sErrors))
{
$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.cryto.net/confirm/{$sUser->sEmailAddress}/{$sUser->sActivationKey}/",
"name" => $sUser->uDisplayName)), /* we don't want a HTML-entities-encoded version here */
NewTemplater::Render("email/layout.html", $locale->strings, array(
"contents" => NewTemplater::Render("email/signup.html", $locale->strings, array(
"confirmation-url" => "http://redonate.cryto.net/confirm/{$sUser->sEmailAddress}/{$sUser->sActivationKey}/",
"name" => $sUser->sDisplayName))
))
);
$sPageContents = NewTemplater::Render("signup/success", $locale->strings, array());
return;
}
}
$sPageContents = NewTemplater::Render("signup/form", $locale->strings, array('errors' => $sErrors));

@ -81,4 +81,17 @@ $sSubscription->uConfirmed = 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.cryto.net/confirm/{$sSubscription->sEmailAddress}/{$sSubscription->sConfirmationKey}/",
"amount" => "$5.00")),
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.cryto.net/confirm/{$sSubscription->sEmailAddress}/{$sSubscription->sConfirmationKey}/",
"amount" => "$5.00"))
))
);
$sPageContents = NewTemplater::Render("subscription/success", $locale->strings, array());

@ -16,14 +16,50 @@ $_CPHP_CONFIG = "../config.json";
require("cphp/base.php");
$_APP = true;
function __autoload($class_name)
require_once('lib/swiftmailer/swift_required.php');
function autoload_redonate($class_name)
{
global $_APP;
$class_name = str_replace("\\", "/", strtolower($class_name));
require_once("classes/{$class_name}.php");
if(file_exists("classes/{$class_name}.php"))
{
require_once("classes/{$class_name}.php");
}
}
spl_autoload_register(autoload_redonate);
function send_mail($to, $subject, $text, $html)
{
global $mail_transport, $cphp_config;
$sMessage = Swift_Message::newInstance();
$sMessage->setSubject($subject);
$sMessage->setTo($to);
$sMessage->setFrom($cphp_config->smtp->from);
$sMessage->setBody($text);
$sMessage->addPart($html, "text/html");
echo("<div style=\"border: 1px solid black; padding: 8px; background-color: white; margin: 8px; margin-bottom: 24px;\">
<div style=\"font-size: 14px;\">
<strong>From:</strong> {$cphp_config->smtp->from}<br>
<strong>To:</strong> {$to}<br>
<strong>Subject:</strong> {$subject}
</div>
<hr>
<pre class=\"debug\">{$text}</pre>
<hr>
<div>
{$html}
</div>
</div>");
//$mail_transport->send($sMessage);
}
$sPageTitle = "";
$sPageContents = "";
$sError = "";
@ -34,8 +70,11 @@ $router->ignore_query = true;
$router->routes = array(
0 => array(
"^/$" => "modules/index.php",
"^/register$" => "modules/register.php",
"^/$" => array(
'target' => "modules/index.php",
'_padded' => false
),
"^/sign-up$" => "modules/signup.php",
"^/login$" => "modules/login.php",
"^/campaign/([a-zA-Z0-9-]+)$" => "modules/landing.php",
"^/campaign/([a-zA-Z0-9-]+)/subscribe$" => "modules/subscribe.php",
@ -44,4 +83,5 @@ $router->routes = array(
$router->RouteRequest();
echo(NewTemplater::Render("layout", $locale->strings, array("contents" => $sPageContents, "title" => $sPageTitle)));
echo(NewTemplater::Render("layout", $locale->strings, array("contents" => $sPageContents, "title" => $sPageTitle,
"padded" => (isset($router->uVariables['padded']) ? $router->uVariables['padded'] : true))));

@ -16,6 +16,15 @@ body
margin: 0px auto;
}
pre.debug
{
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
/**************************************
* CLEARFIX *
**************************************/
@ -65,6 +74,11 @@ body
color: #3B4A28;
}
.main h2.spaced
{
margin-bottom: 24px;
}
/**************************************
* FOOTER *
**************************************/
@ -99,6 +113,106 @@ body
content: "";
}
.intro
{
background-color: #F5F5F5;
padding: 14px -18px;
text-align: center;
}
.col1, .col2
{
width: 46%;
line-height: 140%;
}
.col1
{
font-size: 18px;
float: left;
margin-left: 8px;
text-align: justify;
}
.col2
{
font-size: 17px;
float: right;
margin-right: 16px;
}
/**************************************
* FORMS *
**************************************/
.formfield
{
margin: 6px 0px;
}
.formfield.next-similar
{
margin-bottom: 6px;
}
.formfield.previous-similar
{
margin-top: 6px;
}
.formfield label, .formfield input
{
float: left;
}
.formfield input
{
font-size: 17px;
padding: 4px;
width: 30%;
border: 1px solid #6CA825;
border-radius: 1px;
background-color: #F4FDE4;
}
.formfield label
{
width: 18%;
font-size: 18px;
padding-top: 7px;
margin-right: 12px;
font-weight: bold;
}
.formfield.submit
{
padding-left: 20%;
margin-top: 24px;
}
form .note
{
clear: both;
font-size: 14px;
margin-left: 20%;
padding-top: 3px;
}
form .note:before
{
content: "↳";
margin-right: 5px;
}
.errors
{
color: #2F0003;
margin-bottom: 36px;
padding: 12px;
border: 1px solid #6F0008;
background-color: #FFF7F8;
}
/**************************************
* LANDING *
**************************************/
@ -264,3 +378,14 @@ p.pledge-button
-ms-filter: grayscale(100%);
filter: grayscale(100%);
}
.no-padding
{
padding: 0px;
}
.padding
{
padding: 16px 20px;
}

@ -0,0 +1,23 @@
<p>
<strong>Hello there, great to have you on board!</strong>
</p>
<p>
You've subscribed to pledge {%?amount} a month to {%?project-name} using Redonate. We want to make sure that it was really you, so you'll have to click on the following link (or copy-paste it) to confirm that you want to do this:
</p>
<p>
<a href="{%?confirmation-url}">{%?confirmation-url}</a>
</p>
<p>
If you did not subscribe and someone else used your e-mail address, don't panic! ReDonate is a service for voluntary recurring donations. We do not automatically charge for a donation, and just act as a reminder service. You can safely ignore this e-mail if you did not subscribe (or changed your mind), and we'll remove the subscription in 7 days.
</p>
<p>
If you have any further questions, don't hesitate to reply to this e-mail! We promise we'll read every e-mail, and give you a personal response.
</p>
<p>
<em>- Sven Slootweg, ReDonate</em>
</p>

@ -0,0 +1,11 @@
Hello there, great to have you on board!
You've subscribed to pledge {%?amount} a month to {%?project-name} using Redonate. We want to make sure that it was really you, so you'll have to click on the following link (or copy-paste it) to confirm that you want to do this:
{%?confirmation-url}
If you did not subscribe and someone else used your e-mail address, don't panic! ReDonate is a service for voluntary recurring donations. We do not automatically charge for a donation, and just act as a reminder service. You can safely ignore this e-mail if you did not subscribe (or changed your mind), and we'll remove the subscription in 7 days.
If you have any further questions, don't hesitate to reply to this e-mail! We promise we'll read every e-mail, and give you a personal response.
- Sven Slootweg, ReDonate

@ -0,0 +1,5 @@
<div style="background-color: #E5EFD7; font-family: sans-serif; padding: 12px; color: black;">
<p style="font-size: 46px; font-weight: bold; margin-top: 5px; margin-bottom: 12px;"><span style="color: #7AAA3E;">Re</span><span style="color: #587532;">Donate</span></p>
{%?contents}
</div>

@ -0,0 +1,23 @@
<p>
<strong>Hello there {%?name}, great to have you on board!</strong>
</p>
<p>
You've recently signed up on ReDonate. We want to make sure that it was really you, so you'll have to click (or copy-paste) the following link to let us know that you're okay with this:
</p>
<p>
<a href="{%?confirmation-url}">{%?confirmation-url}</a>
</p>
<p>
If you did not sign up yourself or you changed your mind, don't worry! You can simply ignore this e-mail, and we'll remove your account in 7 days.
</p>
<p>
If you have any further questions, don't hesitate to reply to this e-mail! We promise we'll read every e-mail, and give you a personal response.
</p>
<p>
<em>- Sven Slootweg, ReDonate</em>
</p>

@ -0,0 +1,11 @@
Hello there {%?name}, great to have you on board!
You've recently signed up on ReDonate. We want to make sure that it was really you, so you'll have to click (or copy-paste) the following link to let us know that you're okay with this:
{%?confirmation-url}
If you did not sign up yourself or you changed your mind, don't worry! You can simply ignore this e-mail, and we'll remove your account in 7 days.
If you have any further questions, don't hesitate to reply to this e-mail! We promise we'll read every e-mail, and give you a personal response.
- Sven Slootweg, ReDonate

@ -0,0 +1,60 @@
<div class="padding">
<h2>ReDonate is recurring contributions, done right.</h2>
</div>
<div class="intro">
<img src="/static/images/intro.png">
</div>
<div class="padding">
<div class="col1">
<h3>Why use ReDonate?</h3>
<p>
You just made an awesome website. Or maybe you made an album, or even a movie! You really want
to make it available to others for free, but you don't get donations very often.
</p>
<p>
<strong>What if your fans are simply <em>forgetting</em> to donate?</strong>
</p>
<p>
Maybe you've considered recurring donations. But on the other hand, would you really want to automatically take
away money from your users and fans? If they have to jump through hoops to get rid of it... is it really a donation?
</p>
<p>
<strong>We're here to help.</strong> We'll allow your users and fans to subscribe to monthly donations, while
still keeping them <em>100% voluntary</em>. A donor can unsubscribe or choose not to donate at any time. And
we'll give you a neat statistics page to keep track of what's going on :)
</p>
</div>
<div class="col2">
<h3>Here's what you get:</h3>
<ul>
<li><strong>100% free! No fees, no paid memberships.</strong></li>
<li>For developers, creators, artists, fundraisers, charity workers, and quite literally everyone else.</li>
<li>Have a more predictable income, from donations.</li>
<li>Keep your donations <em>really</em> voluntary.</li>
<li>Allow your donors to unsubscribe at any time, no commitments or hoops to jump through.</li>
</ul>
<ul>
<li>No restrictions on payment methods or currencies.</li>
<li>Yes, we do Bitcoin as well.</li>
<li>No restrictions on what your campaign is about.</li>
<li>Completely safe. We do not process any transactions ourselves, and do not hold any funds.</li>
<li>ReDonate is a non-profit project. We have no interest or benefit in selling your data.</li>
</ul>
<div style="text-align: center; margin-top: 36px;">
<form method="post" action="/sign-up">
<button type="submit" class="green-button" id="button_subscribe">
Sign up now!<br><span style="font-size: 12px;">(it's free, so why not?)</span>
</button>
</form>
</div>
<div style="font-size: 14px; margin-bottom: 24px; text-align: center;">
(or <a href="/login">log in</a> to your existing account)
</div>
</div>
<div class="clear"></div>
</div>

@ -13,7 +13,7 @@
Re<span class="highlight">Donate</span>
</h1>
</div>
<div class="main">
<div class="main {%if padded == false}no-padding{%/if}">
{%?contents}
</div>
<div class="footer">

@ -0,0 +1,49 @@
<h2 class="spaced">Great! It'll only take a moment...</h2>
{%if isempty|errors == false}
<div class="errors">
One or more problems occurred:
<ul>
{%foreach error in errors}
<li>{%?error}</li>
{%/foreach}
</ul>
Please correct these issues and submit the form again.
</div>
{%/if}
<form method="post" action="/sign-up">
<div class="formfield next-similar">
<label>Username</label>
{%input type="text" name="username"}
<div class="clear"></div>
</div>
<div class="formfield next-similar previous-similar">
<label>Name (optional)</label>
{%input type="text" name="displayname"}
<div class="clear"></div>
</div>
<div class="formfield previous-similar">
<label>E-mail address</label>
{%input type="email" name="email"}
<div class="note">we'll send you a verification e-mail</div>
</div>
<div class="formfield next-similar">
<label>Password</label>
{%input type="password" name="password"}
<div class="clear"></div>
</div>
<div class="formfield previous-similar">
<label>Password (again)</label>
{%input type="password" name="password2"}
<div class="note">at least 8 characters</div>
</div>
<div class="formfield submit">
<button type="submit" class="green-button" name="submit" value="submit">Sign me up!</button>
</div>
</form>

@ -0,0 +1,10 @@
<h2>Only one more step...</h2>
<p>
We want to make sure that you're really the owner of that e-mail address - we hate spam as much as you do!
To verify, we've sent you an e-mail with a confirmation link.
</p>
<p>
Once you click that link, you'll be automatically logged in, and you can start creating a campaign right away!
</p>
Loading…
Cancel
Save