ljr/local/htdocs/mobile/post.bml

106 lines
2.5 KiB
Plaintext

<?_info
nocache=>1
_info?><?_code
{
use strict;
use vars qw(%POST $u $res);
my $err = sub {
BML::finish();
return $_[0];
};
$u = LJ::get_remote()
or return $err->("You must <a href='login.bml'>log in</a> before posting.");
$res = LJ::Protocol::do_request("login", {
"ver" => $LJ::PROTOCOL_VER,
"username" => $u->{'user'},
"getpickws" => 1,
}, undef, {
"noauth" => 1,
"u" => $u,
});
return "" unless LJ::did_post();
return "<b>$ML{'Error'}</b> $ML{'error.invalidform'}" unless LJ::check_form_auth();
my $event = LJ::Util::blogger_deserialize($POST{'event'});
my $journal = $POST{'usejournal'};
my $sec = $POST{'security'};
my $allowmask = undef;
if ($sec eq "friends") {
$sec = "usemask";
$allowmask = 1;
}
my $req = {
'usejournal' => $journal ne $u->{user} ? $journal : undef,
'ver' => 1,
'username' => $u->{'user'},
'password' => $u->{'password'},
'event' => $event->{'event'},
'subject' => $POST{'subject'},
'props' => $event->{'props'},
'tz' => 'guess',
'security' => $sec,
'allowmask' => $allowmask,
};
my $errcode;
my $res = LJ::Protocol::do_request("postevent", $req, \$errcode);
if ($errcode) {
return $err->("Error posting: " . LJ::Protocol::error_message($errcode));
}
my $url = $res->{url};
BML::finish();
my $ret = "";
$ret .= "<a href='./'>&lt;&lt; Back</a> to LiveJournal Mobile.</a><h1>Success!</h1>";
$ret .= "Posted. Available <a href='$url'>here</a>.";
return $ret;
}
_code?>
<html>
<head>
<meta name="viewport" content="width = 320" />
<style>
</style>
</head>
<body>
<a href="./">&lt;&lt; Back</a> to LiveJournal Mobile.
<h1>Post</h1>
<form method='post' action='/mobile/post.bml'>
<?_code { return LJ::form_auth(); } _code?>
Subject:<br />
<input name='subject' size='50' style='width: 90%' /><br />
Post:<br />
<textarea rows='10' cols='40' name='event' wrap='virtual' style='width: 90%'></textarea><br />
Security: <?_code {
my @secs = ("public", BML::ml('label.security.public'), "private", BML::ml('label.security.private'),
"friends", BML::ml('label.security.friends'));
return LJ::html_select({ 'name' => 'security',
'selected' => "public" }, @secs);
} _code?><br />
<hr />
<center>
<input type='submit' value="Post" /> to <?_code
{
return LJ::html_select({ 'name' => 'usejournal', },
"", $u->{'user'},
map { $_, $_ } @{$res->{'usejournals'} || []});
}_code?>
</center>
</form>
</body>
</html>