body<=
"
if $remote && $remote->{journaltype} ne 'P';
return $LJ::MSG_READONLY_USER if LJ::get_cap($remote, "readonly");
my ($ret, $saved);
my %errors;
my $error_msg = sub {
my $key = shift;
my $msg = $errors{$key};
return unless $msg;
return "
| |
";
};
my %formats = (
'ogg', 'Ogg Vorbis',
'wav', 'Wav (GSM encoded)'
);
$formats{'mp3'} = 'Mp3' if $LJ::PHONEPOST_MP3;
POST:
while ($remote && LJ::did_post()) {
my $phone = $POST{phone};
my $trans = $POST{trans};
my $format = $POST{format};
my $pin = $POST{pin};
if ($POST{delete}) {
my $dbh = LJ::get_db_writer();
$dbh->do("DELETE FROM phonepostlogin WHERE userid=?", undef, $remote->{userid});
return "";
}
$phone =~ s/\D//g;
$errors{'.phone'} = $ML{'.error.phone.length'}
unless length $phone >= 10;
$errors{'.pin'} = $ML{'.error.pin'} if $pin =~ /\D/ or
length $pin < 1;
my $dbh = LJ::get_db_writer();
my $prevuserid = $dbh->selectrow_array("SELECT userid FROM phonepostlogin ".
"WHERE phone=? AND pin=?", undef,
$phone, $pin);
$errors{'.pin'} = $ML{'.error.inuse'} if $prevuserid && $prevuserid != $remote->{userid};
my $grouplist = LJ::get_friend_group($remote);
$errors{'.transcribers'} = $ML{'.error.transcription'}
unless $trans == -1 || $trans == 0 || defined $grouplist->{$trans};
$errors{'.format'} = "Bad format selected." unless $formats{$format};
last POST if %errors;
$dbh->do("REPLACE INTO phonepostlogin ".
"(phone, pin, userid) VALUES (?, ?, ?)", undef,
$phone, $pin, $remote->{userid});
LJ::set_userprop($remote, 'pp_transallow', $trans);
LJ::set_userprop($remote, 'pp_format', $format);
$saved .= "";
$saved .= "";
$saved .= "";
last;
}
my $grouplist = LJ::get_friend_group($remote);
my $tableline = sub {
my ($mlcaption, $content) = @_;
my $err = $error_msg->($mlcaption);
return "$ML{$mlcaption} | $content | |
\n$err";
};
my $dbr = LJ::get_db_reader();
my ($phone, $pin);
if ($remote) {
($phone, $pin) = $dbr->selectrow_array(
"SELECT phone, pin FROM phonepostlogin ".
"WHERE userid=?", undef,
$remote->{userid});
LJ::load_user_props($remote, qw/ pp_transallow pp_format /);
$ret .= $ML{'.intro.loggedin'};
} else {
$ret .= "";
}
$phone = $POST{'phone'} ? $POST{'phone'} : $phone;
$pin = $POST{'pin'} ? $POST{'pin'} : $pin;
$ret .= "";
$ret .= $saved if $saved;
return $ret;
}
_code?>
<=body
page?>