Apply Payment body<= login " . "first. Otherwise, go create an account 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 .= "
\n\n"; $ret .= ""; # 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 "" if $months == 99; return ""; } # show form before post my $getextra = $authas ne $remote->{'user'} ? "?authas=$authas" : ''; $ret .= ""; return $ret; } _code?> <=body page?>