This commit is contained in:
2019-02-06 00:49:12 +03:00
commit 8dbb1bb605
4796 changed files with 506072 additions and 0 deletions

View File

@@ -0,0 +1,180 @@
<?_code
{
use strict;
use vars qw(%POST $title $body);
# central time t from which validity calculations are made
my $time_start = 1101427200; # nov. 26, 2004 (GMT)
my $time_end = 1104537599; # last second of 2004 (GMT)
# statushistory type
my $shtype = '2004_dec_promo';
my $dollar_value = 15; # value of generated coupon
my $dollar_req = 50; # need 50 per coupon
$title = "2004 Holidays Promotion";
$body = "";
# date with no hhmmss
my $date = sub { substr(LJ::mysql_time($_[0]), 0, 10) };
# die immediately if applicable time frame has expired
my $now = time();
if ($now > $time_end) {
$title = "Offer Expired";
$body = "Sorry, the 2004 Holidays Promotion offer expired at the end of December, GMT.";
return;
}
my $err = sub {
$title = "Error";
$body = LJ::bad_input(@_);
return;
};
# no authas for this page
my $u = LJ::get_remote();
return $err->($ML{'error.noremote'})
unless $u;
my $dbh = LJ::get_db_writer();
my $sys_id = LJ::get_userid("system") or die "No system id";
# form output
$body = "";
# no suspended accounts
if ($u->{statusvis} eq "S") {
$body .= "<?h1 Suspended Account h1?>";
$body .= "<?p This journal has been either temporarily or permanently suspended by $LJ::SITENAME for policy violation. " .
"You are unable to claim paid time until this journal is unsuspended. p?>";
return;
}
# statusvis must be v, and journaltype C || P
unless ($u->{statusvis} eq 'V' && $u->{journaltype} eq 'P') {
$body .= "<?h1 Invalid Account h1?>";
$body .= "<?p This journal's current status does not allow it to use this tool. p?>";
return;
}
# Find the following payitems:
# -- belong to this user
# -- between $time_start and $time_end
# -- checked out (used='Y')
# -- not clothes (intangible ... coupons are allowed)
# -- positive amount
my $has_already = sub {
return $dbh->selectrow_array
("SELECT COUNT(*) FROM statushistory WHERE userid=? AND adminid=? AND shtype=?",
undef, $u->{userid}, $sys_id, $shtype)+0;
};
my $amt = $dbh->selectrow_array
("SELECT SUM(pi.amt) FROM payments p, payitems pi WHERE p.userid=? AND pi.payid=p.payid " .
"AND p.daterecv>=FROM_UNIXTIME(?) AND p.daterecv<=FROM_UNIXTIME(?) " .
"AND p.used='Y' AND pi.amt>0 AND pi.item IN ('rename','paidacct','perm','userpic')",
undef, $u->{userid}, $time_start, $time_end);
my $total = POSIX::floor($amt/$dollar_req);
my $have = $has_already->() + 0;
my $need = $total - $have;
# posting a form submission
if (LJ::did_post() && $POST{submit} && $need > 0) {
# get a lock on this userid
my $lockkey = "$shtype:$u->{userid}";
LJ::get_lock($dbh, "global", $lockkey)
or return $err->("Couldn't get lock: $lockkey");
# revalidate count inside of lock
$have = $has_already->();
$need = $total - $have;
my @tokens = ();
foreach my $ct ($have+1..$total) {
my ($tokenid, $token) = LJ::Pay::new_coupon('dollarofftan', $dollar_value, $u->{userid}, 0);
unless ($tokenid && $token) {
return $err->("There has been an error generating your coupon. Please try again later.");
}
push @tokens, $token;
# log this action in statushistory. note that this is also what signifies the action
# has already been performed
LJ::statushistory_add
($u->{userid}, $sys_id, $shtype, "($ct) generated coupon: $token");
}
# we're done working, release lock
LJ::release_lock($dbh, "global", $lockkey);
$body = "<?h1 Success! h1?>";
$body .= "<?p You've generated $need coupons: p?><ul>";
foreach ( @tokens ) {
$body .= "<li>$_</li>";
}
$body .= "</ul>";
my $coup_amt = $dollar_value * $need;
$body .= "<?p You can redeem your coupons for \$$coup_amt USD in <a href='/store/'>$LJ::SITENAMESHORT merchandise</a>. p?>";
$body .= "<?p <strong>Note:</strong> A coupon is only valid for one use, so be sure that your order's ";
$body .= " value is greater than or equal to \$$coup_amt USD. p?>";
return;
}
# claim form
$body .= "<form method='post' action='2004_december_promo.bml'>";
$body .= "<?h1 Something Extra this Year&hellip; h1?>";
$body .= "<?p As a way to say thank you to all of our supporters, we're offering \$$dollar_value USD ";
$body .= "<a href='/store/'>clothing</a> coupons ";
$body .= "for every \$$dollar_req USD spent on service items in <a href='/pay/'>our store</a>. ";
$body .= "Store purchases are cumulative, so you don't have to spend \$$dollar_req at once -- separate ";
$body .= "purchases can be saved up until there's enough to generate a coupon. p?>";
$body .= "<?p The promotion begins November 26th of 2004 (GMT) ";
$body .= "and will end at the beginning of 2005 (GMT), at which time the generated coupons also expire.";
$body .= " p?>";
$body .= "<?h1 Coupon Status h1?>";
if ($need > 0) {
my $s = $total == 1 ? "" : "s";
$body .= "<?p You purchased \$$amt of service items between November 26th and the end of December (GMT)";
$body .= ", making you eligible for $total \$$dollar_value.00 USD clothing coupon${s}. You have currently claimed $have of ";
$body .= "these, so you can claim $need more if you wish. p?>";
my $s = $need == 1 ? "" : "s";
$body .= "<div style='margin-left: 30px; margin-top: 10px'>";
$body .= LJ::html_submit('submit' => "Claim $need Coupon$s");
$body .= "</div>";
} else {
my $goal = sprintf("%0.02f", $dollar_req - ($amt % $dollar_req));
if ($have == 0) {
$body .= "<?p To qualify for this promotion, please purchase at least \$$dollar_req USD worth of <a href='/pay/'>services from our store</a>. p?>";
} else {
my $s = $have == 1 ? "" : "s";
$body .= "<?p You have purchased \$$amt USD of service items between November 26th and the end of December (GMT) ";
$body .= " and have already claimed $have coupon${s}. You will need to purchase another \$$goal USD";
$body .= " worth of services from our store before you will be eligible for a new coupon. p?>";
}
}
if ($have > 0) {
$body .= "<?h1 Existing Coupons h1?>";
$body .= "<?p To view or retrieve any of the $have coupons that you have already generated via this promotion, ";
$body .= "please see the <a href='$LJ::SITEROOT/pay/coupons.bml'>coupon retrieval</a> page. p?>";
}
$body .= "</form>";
return;
}
_code?><?page
title=><?_code return $title; _code?>
body=><?_code return $body; _code?>
page?>

View File

@@ -0,0 +1,97 @@
<?page
title=>Apply Payment
body<=
<?_code
{
use strict;
use vars qw(%GET %POST);
my $remote = LJ::get_remote();
return "<?p You are not currently logged in. If you have an account already, go <a href='/login.bml?ret=1'>login</a> " .
"first. Otherwise, go <a href='/create.bml'>create an account</a> using your payment code, and the payment will be " .
"automatically applied to the newly created account. p?>"
unless $remote;
my $authas = $GET{'authas'} || $remote->{'user'};
my $u = LJ::get_authas_user($authas);
return LJ::bad_input($ML{'error.invalidauth'})
unless $u;
my $ret = '';
# authas switcher form
$ret .= "<form method='get' action='apply.bml'>\n";
$ret .= LJ::make_authas_select($remote, { 'authas' => $GET{'authas'} }) . "\n";
$ret .= "</form>\n\n";
$ret .= "<?h1 About h1?><?p This page lets you apply a payment code towards an existing account. p?>";
# handle form submission
if ($POST{'code'}) {
my $dbh = LJ::get_db_writer();
my $code = $POST{'code'};
return LJ::bad_input("Invalid code") unless length($code) == 12;
my ($acid, $auth) = LJ::acct_code_decode($code);
my ($usedby, $realauth) =
$dbh->selectrow_array("SELECT rcptid, auth FROM acctcode ".
"WHERE acid=?", undef, $acid);
return LJ::bad_input("Invalid code") unless $realauth && $auth eq $realauth;
return LJ::bad_input("You've already applied this payment") if $usedby == $u->{'userid'};
return LJ::bad_input("Somebody else has already applied this payment") if $usedby;
my $months;
if (my $pi = $dbh->selectrow_hashref("SELECT pi.item, pi.qty ".
"FROM payitems pi, acctpayitem api ".
"WHERE pi.piid=api.piid AND api.acid=?",
undef, $acid)) {
$months = 99 if $pi->{'item'} eq "perm";
$months = $pi->{'qty'} if $pi->{'item'} eq "paidacct";
} else {
$months = $dbh->selectrow_array("SELECT p.months ".
"FROM payments p, acctpay ap ".
"WHERE p.payid=ap.payid ".
"AND ap.acid=?", undef, $acid);
}
return "The code provided has no paid time associated with it." unless $months > 0;
if ($u->{'caps'} & 16) {
return "You already have a permanent account, so applying this ".
"second permanent account code would do nothing." if $months == 99;
return "You already have a permament account, so applying $months ".
"extra paid account months would do nothing.";
}
# double click protection
my $rows = $dbh->do("UPDATE acctcode SET rcptid=? WHERE acid=?", undef,
$u->{'userid'}, $acid);
if ($rows) {
LJ::Pay::add_paid_months($dbh, $u->{'userid'}, $months);
}
return "<?h1 Success h1?><?p You now have a permanent account. p?>" if $months == 99;
return "<?h1 Success h1?><?p $months extra paid account months have been applied to your account. p?>";
}
# show form before post
my $getextra = $authas ne $remote->{'user'} ? "?authas=$authas" : '';
$ret .= "<form method='post' action='apply.bml$getextra'>";
$ret .= "<?h1 Payment Code h1?><?p Enter a payment code to apply towards the <?ljuser $u->{'user'} ljuser?> account. p?>";
$ret .= "<?standout Code: ";
$ret .= LJ::html_text({ 'name' => 'code', 'size' => 13, 'maxlength' => 12, 'value' => $GET{'code'} }) . " ";
$ret .= LJ::html_submit("Apply") . " standout?>";
$ret .= "</form>";
return $ret;
}
_code?>
<=body
page?>

View File

@@ -0,0 +1 @@
<?_code return BML::redirect("$LJ::SITEROOT/pay/"); _code?>

View File

@@ -0,0 +1,125 @@
<?page
title=>Buy for friends!
body<=
<?_code
{
use strict;
my $dbr = LJ::get_db_reader();
my $remote = LJ::get_remote();
unless ($remote) {
return "This page requires you to first <a href='/login.bml?ret=1'>login</a>.";
}
my $ret;
$ret .= "<?h1 Give the gift of LiveJournal.... h1?>";
$ret .= "<?p Looking for an easy gift? Buy a <a href='/paidaccounts/'>paid account</a> for one of the people on your friends list! p?>";
# get status of all friends
# TAG:FR:bml_paidaccts_friends:get_friend_statuses
my $sth = $dbr->prepare("SELECT u.userid, u.user, u.name, u.caps, u.journaltype ".
"FROM friends f, user u, userusage uu ".
"WHERE f.userid=? AND u.userid=f.friendid AND uu.userid=f.friendid ".
"AND u.statusvis='V' LIMIT 500");
$sth->execute($remote->{'userid'});
my %f;
while (my $f = $sth->fetchrow_hashref) {
next unless $f->{'journaltype'} eq "P" || $f->{'journaltype'} eq "C";
$f{$f->{'userid'}} = $f;
}
# when are people's paid accounts expiring?
# TAG:FR:bml_paidaccts_friends:get_friend_expiring
$sth = $dbr->prepare("SELECT p.userid, UNIX_TIMESTAMP(p.paiduntil) AS 'paiduntil' ".
"FROM friends f, paiduser p ".
"WHERE f.userid=? AND f.friendid=p.userid");
$sth->execute($remote->{'userid'});
while (my $f = $sth->fetchrow_hashref) {
next unless $f{$f->{'userid'}};
$f{$f->{'userid'}}->{'paiduntil'} = $f->{'paiduntil'};
}
# who has pending gifts?
# TAG:FR:bml_paidaccts_friends:get_pending_gifts
$sth = $dbr->prepare("SELECT p.userid, p.months ".
"FROM friends f, payments p ".
"WHERE f.userid=? AND f.friendid=p.userid AND ".
" p.used='N' AND p.giveafter > 0");
$sth->execute($remote->{'userid'});
while (my $f = $sth->fetchrow_hashref) {
next unless $f{$f->{'userid'}};
$f{$f->{'userid'}}->{'pending'} += $f->{'months'};
}
unless (%f) {
$ret .= "<?p However, you have nobody on your friends list, so we can't make any recommendations. p?>";
return $ret;
}
my $now = time;
my $one_month = 60*60*24*30;
# separate users into two groups: those needy and those who aren't
my (@needy_paid, @needy_free, @not);
foreach my $f (sort { $a->{'user'} cmp $b->{'user'} } values %f)
{
my $paid_months;
if ($f->{'caps'} & 8) {
$paid_months += ($f->{'paiduntil'} - $now) / $one_month;
$paid_months = 0 if $paid_months < 0;
}
$paid_months += $f->{'pending'};
# permanent account holders or those with 6 months of real or pending gift payments
# aren't needy
if ($f->{'caps'} & 16 || $paid_months > 6) {
push @not, $f;
next;
}
# now, they're needy, but do they already have a paid account?
if ($f->{'caps'} & 8) {
push @needy_paid, $f;
} else {
push @needy_free, $f;
}
}
my $dump_table = sub {
my $list = shift;
$ret .= "<ul><table cellspacing='3'>\n";
foreach my $f (@$list) {
$ret .= "<tr><td>";
$ret .= LJ::ljuser($f->{'user'}, { 'type' => $f->{'journaltype'} });
$ret .= " - " . LJ::ehtml($f->{'name'});
unless ($f->{'caps'} & 16) { # unless a permanent account
$ret .= " [<a href='/pay/?item=paidacct-12&amp;for=$f->{'user'}'>buy gift</a>]";
}
$ret .= "</td></tr>\n";
}
$ret .= "</table></ul>";
};
if (@needy_free) {
$ret .= "<?h1 Free Users h1?><?p The following friends might appreciate a paid account. p?>";
$dump_table->(\@needy_free);
}
if (@needy_paid) {
$ret .= "<?h1 Expiring Soon h1?><?p The following friends have a paid account, but it's expiring soon. p?>";
$dump_table->(\@needy_paid);
}
if (@not) {
$ret .= "<?h1 Other Friends h1?><?p These friends have paid accounts that aren't due to expire for awhile. (This includes time for gifts which are being held for surprise delivery.) p?>";
$dump_table->(\@not);
}
return $ret;
}
_code?>
<=body
page?>

View File

@@ -0,0 +1,50 @@
<?page
title=><?_ml .title _ml?>
head<=
<style type='text/css'>
#featureslist dt { margin-top: 10px; font-weight: bold}
</style>
<=head
body<=
<?_code
{
use strict;
my $ret;
LJ::set_active_crumb('paidaccounts');
$ret .= "<?h1 <?_ml .whypay.header _ml?> h1?>";
$ret .= "<?p <?_ml .whypay.argument _ml?> p?>";
$ret .= "<?p <?_ml .whypay.no_ads _ml?> p?>";
$ret .= "<?h1 <?_ml .costs.header _ml?> h1?> ";
$ret .= "<?p <?_ml .costs.rates _ml?> p?>";
$ret .= "<table cellpadding='5' cellspacing='1' border='1' style='margin: 1em 0 1em 30px' class='edged'><tr bgcolor='<?emcolorlite?>'>";
$ret .= "<td><b><?_ml .costs.rates.time.header _ml?></b></td><td><b><?_ml .costs.rates.amount.header _ml?></b></td><td>&nbsp;</td></tr>";
foreach my $prid (sort { $b <=> $a } keys %LJ::Pay::account) {
$ret .= "<tr valign='middle'><td><a href='/pay/?item=paidacct-$prid'>$LJ::Pay::account{$prid}->{'name'}</a></td><td align='right'>\$$LJ::Pay::account{$prid}->{'amount'}.00 US</td><td><form style='display:inline' action='/pay/'><input type='hidden' name='item' value='paidacct-$prid' /><input type='submit' value='Order' /></form></td></tr>";
}
$ret .= "</table>";
$ret .= "<?p <?_ml .costs.rates.inexpensive _ml?> p?>";
$ret .= "<?h1 What's the status of my paid account? h1?>";
$ret .= "<?p You can review the status of any of your paid accounts by checking the <a href='./status.bml'>Paid Account Status</a> page. p?>";
my $remote = LJ::get_remote(); my $ru;
if ($remote) {
$ru = $remote->{'user'}
} else {
$ru = "<var><?_ml .your_username _ml?></var>";
}
$ret .= "<?h1 <a name='features'>$ML{'.features.header'}</a> h1?>";
$ret .= "<?p Check out our <a href='/site/accounts.bml'>Features by Account Type</a> comparison chart. p?>";
$ret .= "<dl id='featureslist'>";
$ret .= BML::ml('.features', { 'username' => $ru, });
$ret .= "</dl>";
return $ret;
}
_code?>
<=body
page?>

View File

@@ -0,0 +1,55 @@
<?_code
my $remote = LJ::get_remote();
$body = "";
unless ($remote) {
$title = "Join Paidmembers";
$body = "<?h1 Login First h1?><?p To join the paidmembers community, you must first go and <A HREF=\"/login.bml?ret=1\">log in</A>. p?>";
return;
}
my $u = LJ::load_userid($remote->{'userid'});
unless (LJ::get_cap($u, "paid")) {
$title = "Join Paidmembers";
$body = "<?h1 Sorry h1?><?p You have to have a <a href=\"/paidaccounts/\">paid account</a> to join the <?ljuser paidmembers ljuser?> community. p?>";
return;
}
if ($FORM{'mode'} eq "join") {
unless (LJ::did_post()) {
$title = "Error";
$body = "<?requirepost?>";
return;
}
my $puserid = LJ::get_userid("paidmembers");
if (LJ::is_friend($puserid, $remote->{'userid'}) ||
LJ::add_friend($puserid, $remote->{'userid'})) {
$title = "Joined";
$body = "<?h1 Success h1?><?p You are now a member of the <?ljuser paidmembers ljuser?> community p?>";
} else {
$title = "Error";
$body = "paidmembers community doesn't exist?";
}
return;
}
$title .= "Join Paidmembers?";
$body .= "<?h1 Confirm h1?><?p To join the <?ljuser paidmembers ljuser?> community, click the button below. p?>";
$body .= "<form method=\"post\">";
$body .= "<input type=\"hidden\" name=\"mode\" value=\"join\">";
$body .= "<center><input type=\"submit\" value=\"Join paidmembers!\"></center>";
$body .= "</form>";
return;
_code?>
<?page
title=><?_code return $title; _code?>
body<=
<?_code
return $body;
_code?>
<=body
page?>

View File

@@ -0,0 +1,49 @@
<?page
title=>Purchase new account
body<=
<?_code
{
my $months = $FORM{'months'};
return "<b>Error:</b> Invalid months value." unless $LJ::Pay::account{$months};
my $amount = $LJ::Pay::account{$months}->{'amount'};
my $name = "New account, with paid benefits for $months months";
if (LJ::did_post()) {
if ($FORM{'email'}) {
my @errors;
if ($FORM{'email'} =~ /\s/) { push @errors, "Email address shouldn't contain spaces."; }
LJ::check_email($FORM{'email'}, \@errors);
return LJ::bad_input(@errors) if @errors;
}
my $url = "https://www.paypal.com/cgi-bin/webscr?amount=$amount&return=http%3A//www.livejournal.com/paidaccounts/thankyou.bml&item_name=" . LJ::eurl($name) . "&custom=months%3D$months%26newacct%3D1%26email%3D" . LJ::eurl($FORM{'email'}) . "&business=paypal%40livejournal.com&cmd=_xclick&cmd=_xclick&no_shipping=1&no_note=1&notify_url=http%3A//www.livejournal.com/paidaccounts/pp_notify.bml";
return BML::redirect($url);
}
return <<"FORM";
<form method='post'>
<input type='hidden' name='months' value='$months'>
<?h1 Step 1: Your email address. h1?>
<?p
What email address should we email your account creation code to?
<blockquote>
<input type='text' name='email' size='30'> <input type='submit' value='Continue &gt;&gt;'><br />
<b>Example:</b> <tt>bob3984\@yourisp.com</tt>
</blockquote>
If you leave the box blank, the code will be mailed to your PayPal email address (if you have an existing PayPal account), or the email address PayPal will ask you for if you don't have an account.
p?>
<?p
If you no longer have access to your PayPal email address, but continue to use that PayPal account, please provide a good email address we can mail you at.
p?>
</form>
FORM
}
_code?>
<=body
page?>

View File

@@ -0,0 +1,111 @@
<?_code
{
use strict;
use vars qw(%FORM);
# generate a 500 server error (for paypal)
my $err500 = sub {
my $error = shift;
BML::set_status(500);
return "<h1>Payment Processing Error</h1>" . $error;
};
my $dbh = LJ::get_db_writer();
return $err500->("Couldn't connect to database.") unless $dbh;
my $body = "REMOTE_ADDR = " . BML::get_remote_ip() . "\n\n";
$body .= join("\n", map { "$_ = $FORM{$_}" } sort keys %FORM);
my $error;
my $ok = 0;
# FIXME: automatically call LJ::revoke_payitems on these in LJ::Pay::verify_paypal_transaction
if ($FORM{payment_status} eq 'Reversed') {
$body = "Paypal has reversed the following transaction, please revoke the items manually\n\n$body";
LJ::send_mail({ to => $LJ::PAYPAL_ERROR_EMAIL || $LJ::ACCOUNTS_EMAIL,
from => $LJ::BOGUS_EMAIL,
fromname => 'Paypal Reversal',
subject => "Paypal Reversal: $FORM{custom}",
body => $body,
});
return "notified";
}
if ($FORM{payment_status} eq 'Canceled_Reversal') {
$body = "Paypal has canceled reversal of the following transaction, please take appropriate action\n\n$body";
LJ::send_mail({ to => $LJ::PAYPAL_ERROR_EMAIL || $LJ::ACCOUNTS_EMAIL,
from => $LJ::BOGUS_EMAIL,
fromname => 'Paypal Canceled Reversal',
subject => "Paypal Canceled Reversal: $FORM{custom}",
body => $body,
});
return "notified";
}
if ($FORM{payment_status} eq 'Refunded') {
$body = "Paypal has refunded the following transaction, please revoke the items manually\n\n$body";
LJ::send_mail({ to => $LJ::PAYPAL_ERROR_EMAIL || $LJ::ACCOUNTS_EMAIL,
from => $LJ::BOGUS_EMAIL,
fromname => 'Paypal Refund',
subject => "Paypal Refund: $FORM{custom}",
body => $body,
});
return "notified";
}
if (LJ::Pay::verify_paypal_transaction(\%FORM, { 'error' => \$error }))
{
$ok = LJ::Pay::register_paypal_payment($dbh, \%FORM,
{ 'error' => \$error });
}
if ($FORM{custom}) {
if (my $custom = LJ::Pay::paypal_parse_custom($FORM{custom})) {
if (my $cartobj = LJ::Pay::load_cart($custom->{cart})) {
LJ::Pay::send_fraud_email($cartobj);
if (my $u = LJ::load_userid($cartobj->{userid})) {
LJ::Pay::note_payment_from_user($u);
}
}
}
}
my $errorsub;
unless ($ok) {
# paypal sends us duplicate notifications fairly often, so when one is received,
# send an email to $LJ::PAYPAL_ERROR_EMAIL and tell paypal everything's okay
if ($error =~ /already paid/i) {
$body = "Paypal has sent notification of the following transaction, which has already been paid for\n\n$body";
LJ::send_mail({ to => $LJ::PAYPAL_ERROR_EMAIL || $LJ::ACCOUNTS_EMAIL,
from => $LJ::BOGUS_EMAIL,
fromname => 'Paypal Duplicate Notification',
subject => "Paypal Duplicate Notification: $FORM{custom}",
body => $body,
});
return "notified";
}
$errorsub = " (ERROR)";
$body = "ERROR: $error\n\n$body";
}
$FORM{'custom'} =~ /user=(\w+)/;
my $user = $1;
LJ::send_mail({ 'to' => $LJ::PAYPAL_ERROR_EMAIL || $LJ::ACCOUNTS_EMAIL,
'from' => 'lj_dontreply@livejournal.com',
'fromname' => 'LiveJournal',
'subject' => "PayPal Notify - $user$errorsub",
'body' => $body,
});
if ($ok) {
return "notified";
} else {
return $err500->($error);
}
}
_code?>

View File

@@ -0,0 +1,53 @@
<?page
title=>Paid Account Status
body<=
<?_code
{
use strict;
use vars qw(%GET);
LJ::set_active_crumb('paidacctstatus');
my $remote = LJ::get_remote();
return LJ::bad_input($ML{'error.noremote'})
unless $remote;
my $authas = $GET{'authas'} || $remote->{'user'};
my $u = LJ::get_authas_user($authas);
return LJ::bad_input("You could not be authenticated as the specified user.")
unless $u;
return LJ::bad_input("Account has been deleted")
if $u->{'statusvis'} eq 'D' || $u->{'statusvis'} eq 'X';
my $ret;
# authas switcher form
$ret .= "<form method='get' action='status.bml'>\n";
$ret .= LJ::make_authas_select($remote, { 'authas' => $GET{'authas'},
'cap' => 'paid' }) . "\n";
$ret .= "</form>\n\n";
my $getextra = "?authas=$authas" unless $authas eq $remote->{'user'};
$ret .= "<?p Below is a summary of the $LJ::SITENAME services to which you ";
$ret .= "are currently subscribed: p?>";
# render account summary
$ret .= LJ::Pay::account_summary($u);
# disk quota summary
my $qsummary = LJ::Pay::quota_summary($u);
return $ret unless $qsummary;
$ret .= "<?h2 Disk Quota Usage h2?>";
$ret .= "<?p The following is a break-down of your disk space quota usage. p?>";
$ret .= $qsummary;
return $ret;
}
_code?>
<=body
page?>

View File

@@ -0,0 +1,20 @@
<?page
title=>Thanks!
body<=
<?h1 What now? h1?>
<?p
PayPal is now processing your payment and their server will contact our server with the full details of the transaction shortly. This will happen within 12 hours, if not much sooner.
p?>
<?p
If you're paying for an existing account, your paid account will be setup when PayPal sends our server the details.
p?>
<?p
If you're paying to <a href="/create.bml">create a new account</a>, an account creation code will be emailed to the same email address you used for PayPal.
p?>
<?p
We appreciate your payment.
p?>
<=body
page?>

View File

@@ -0,0 +1,99 @@
<?page
title=>Pay using PayPal
body<=
<?_code
my $ret;
my $user = LJ::canonical_username($FORM{'user'});
my $u = LJ::load_user($user);
unless ($u) {
return "<?h1 Error h1?><?p Unknown user p?>";
}
if ($FORM{'loggedin'}) {
my $remote = LJ::get_remote();
unless ($remote && $remote->{'user'} eq $user) {
return "<?h1 Error h1?><?p Invalid login? No longer logged in? p?>";
}
} else {
unless (LJ::auth_okay($u, $FORM{'password'}, $FORM{'hpassword'})) {
return "<?h1 Invalid password h1?><?p The password you entered is not correct. p?>";
}
}
my $giftfor = LJ::canonical_username($FORM{'giftfor'});
if ($FORM{'giftfor'} && ! $giftfor) {
return "<?h1 Error h1?><?p The username you entered for the gift recipient doesn't look like a username. p?>";
}
# can't buy a gift for yourself.
undef $giftfor if ($giftfor eq $user);
if ($giftfor) {
my $gu = LJ::load_user($giftfor);
unless ($gu) {
return "<?h1 Error h1?><?p The gift recipient's username doesn't seem to exist. p?>";
}
if ($gu->{'caps'} & 16) {
return "<?h1 Error h1?><?p User <?ljuser $gu->{'user'} ljuser?> has a permanent account. You can't buy them a gift payment. p?>";
}
}
my $months = $FORM{'months'};
my $amount;
if (defined $LJ::Pay::account{$months}) {
$amount = $LJ::Pay::account{$months}->{'amount'};
}
unless ($amount) {
return "<?h1 Error h1?><?p You did not select the number of months you want to pay for. p?>";
}
my $forkey = $giftfor ? "&for=$giftfor" : "";
my $forwho = $giftfor ? ", for $giftfor" : "";
my $anonkey = $FORM{'anon'} ? "&anon=1" : "";
my $datekey;
if ($FORM{'giveafter'}) {
return "<?h1 $ML{'Error'} h1?><?p $ML{'.delivery.badformat'} p?>"
unless ($FORM{'giveafter'} =~ /^(\d\d\d\d)\-(\d\d)\-(\d\d)(?: (\d\d):(\d\d))?/);
my $dtime = 0;
eval { $dtime = Time::Local::timegm(0, $5, $4, $3, $2-1, $1); };
return "<?h1 $ML{'Error'} h1?><?p $ML{'.delivery.badformat'} p?>" if @$;
my $delay = $dtime - time();
return "<?h1 $ML{'Error'} h1?><?p $ML{'.delivery.past'} p?>" if $delay < 0;
return "<?h1 $ML{'Error'} h1?><?p $ML{'.delivery.toofuture'} p?>"
if $delay > 60*60*24*31;
$datekey = "&giveafter=$dtime";
}
$ret .= "All your LiveJournal data has been validated. To continue the purchase, click the PayPal icon below to go to PayPal's secure server and pay. PayPal then sends us a notification of the payment and your account will be automatically setup.";
$ret .= "<center>";
$ret .= "<form method=\"post\" action=\"https://www.paypal.com/cgi-bin/webscr\">\n";
$ret .= "<input type=hidden name=cmd value=_xclick>\n";
$ret .= "<input type=hidden name=business value=\"paypal\@livejournal.com\">\n";
$ret .= "<input type=hidden name=item_name value=\"$months months paid account ($user$forwho)\">\n";
$ret .= "<input type=hidden name=custom value=\"months=$months&user=$user$forkey$anonkey$datekey\">\n";
$ret .= "<input type=hidden name=amount value=\"$amount\">\n";
$ret .= "<input type=hidden name='no_shipping' value='1'>\n";
$ret .= "<input type=hidden name='no_note' value='1'>\n";
$ret .= "<input type=hidden name=return value=\"http://www.livejournal.com/paidaccounts/thankyou.bml\">\n";
$ret .= "<input type=hidden name=notify_url value=\"http://www.livejournal.com/paidaccounts/pp_notify.bml\">\n";
$ret .= "<input type=hidden name=cmd value=_xclick>\n";
$ret .= "<input type=image src=\"http://images.paypal.com/images/x-click-but3.gif\" value=\"Buy...\">\n";
$ret .= "</form>\n";
$ret .= "</center>";
return $ret;
_code?>
<=body
page?>

View File

@@ -0,0 +1,26 @@
<?page
title=>Philosophy
body<=
<?h1 Why paid accounts can do more... h1?>
<?p
Here's our strategy on paid accounts and site functionality: We don't want to make any feature on the site that not everybody will be able to use --- that's just stupid. It's a waste of our time, and the feature won't improve because there won't be many people giving us feedback. On the other hand, we don't want to let everybody do everything, otherwise there would be no incentive for users to buy <a href="/paidaccounts/">paid accounts</a> and support the project.
p?>
<?p
So, our plan so far as been to let all users use every part of the site, but remove some little part of the feature, or limit how much it can be used.
p?>
<?p
Examples:
<ul>
<li>Users with paid accounts can make private and friends-only <a href="/todo/">to-do items</a>, but regular users can only make public items, and are limited to 25 to-do items at a time.
<li>Users with paid accounts can have 10 mini pictures to represent themselves in various parts of the site, while regular users can only have 3.
</ul>
In the future we'll probably continue this strategy. If you buy a paid account now, you'll be able to use future features as they become available. However, if you don't feel like buying an account, then don't ... we'll still make everything available to you, albeit in a slightly crippled fashion.
p?>
<?p
We hope you understand our decision. $2.00-$2.50/month isn't that much to spend on a paid account, but if everybody helps out, it makes the site run a lot nicer as we can afford to upgrade our servers and afford our colocation fees without dipping into our own pockets.
p?>
<=body
page?>