133 lines
3.9 KiB
Text
133 lines
3.9 KiB
Text
|
|
<?_c
|
||
|
|
# This code was forked from the LiveJournal project owned and operated
|
||
|
|
# by Live Journal, Inc. The code has been modified and expanded by
|
||
|
|
# Dreamwidth Studios, LLC. These files were originally licensed under
|
||
|
|
# the terms of the license supplied by Live Journal, Inc, which can
|
||
|
|
# currently be found at:
|
||
|
|
#
|
||
|
|
# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
|
||
|
|
#
|
||
|
|
# In accordance with the original license, this code and all its
|
||
|
|
# modifications are provided under the GNU General Public License.
|
||
|
|
# A copy of that license can be found in the LICENSE file included as
|
||
|
|
# part of this distribution.
|
||
|
|
_c?>
|
||
|
|
<?_info
|
||
|
|
nocache=>1
|
||
|
|
_info?><?_code
|
||
|
|
{
|
||
|
|
use strict;
|
||
|
|
use vars qw(%POST $u $res);
|
||
|
|
|
||
|
|
my $err = sub { BML::finish(); return $_[0] };
|
||
|
|
|
||
|
|
my $parse_content = sub {
|
||
|
|
my $content = $_[0];
|
||
|
|
my $event = { 'props' => {} };
|
||
|
|
if ($content =~ s/(^|\n)lj-mood:\s*(.*)\n//i) {
|
||
|
|
$event->{'props'}->{'current_mood'} = $2;
|
||
|
|
}
|
||
|
|
if ($content =~ s/(^|\n)lj-music:\s*(.*)\n//i) {
|
||
|
|
$event->{'props'}->{'current_music'} = $2;
|
||
|
|
}
|
||
|
|
$content =~ s/^\s+//; $content =~ s/\s+$//;
|
||
|
|
$event->{'event'} = $content;
|
||
|
|
return $event;
|
||
|
|
};
|
||
|
|
|
||
|
|
$u = LJ::get_remote()
|
||
|
|
or return $err->( BML::ml( ".post.login", { aopts => "href='login'" } ) );
|
||
|
|
|
||
|
|
$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{'.post.error'}</b> $ML{'error.invalidform'}" unless LJ::check_form_auth();
|
||
|
|
|
||
|
|
my $event = $parse_content->($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,
|
||
|
|
'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, {
|
||
|
|
"noauth" => 1,
|
||
|
|
"u" => $u,
|
||
|
|
});
|
||
|
|
if ($errcode) {
|
||
|
|
return $err->( "<?_ml .post.error_posting _ml?>: " . LJ::Protocol::error_message($errcode) );
|
||
|
|
}
|
||
|
|
|
||
|
|
my $url = $res->{url};
|
||
|
|
|
||
|
|
BML::finish();
|
||
|
|
my $ret = "";
|
||
|
|
$ret .= BML::ml( ".post.back", { aopts => "href='./'", sitename => $LJ::SITENAMESHORT } ) . "<h1>" . BML::ml( ".post.success.header" ) . "</h1>";
|
||
|
|
$ret .= BML::ml( ".post.success.text", { aopts => "href='$url'" } );
|
||
|
|
return $ret;
|
||
|
|
}
|
||
|
|
_code?>
|
||
|
|
<html>
|
||
|
|
<head>
|
||
|
|
<meta name="viewport" content="width = 320" />
|
||
|
|
<style>
|
||
|
|
</style>
|
||
|
|
<title><?_ml .page.title _ml?></title>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<?_code BML::ml( ".post.back", { aopts => "href='./'", sitename => $LJ::SITENAMESHORT } ) _code?>
|
||
|
|
<h1><?_ml .form.header _ml?></h1>
|
||
|
|
|
||
|
|
<form method='post' action='/mobile/post'>
|
||
|
|
<?_code { return LJ::form_auth(); } _code?>
|
||
|
|
<?_ml .form.subject2 _ml?>:<br />
|
||
|
|
<input name='subject' size='50' style='width: 90%' /><br />
|
||
|
|
<?_ml .form.post _ml?>:<br />
|
||
|
|
<textarea rows='10' cols='40' name='event' wrap='virtual' style='width: 90%'></textarea><br />
|
||
|
|
|
||
|
|
<?_ml .form.security _ml?>: <?_code {
|
||
|
|
my @secs = ("public", BML::ml('label.security.public'), "private", BML::ml('label.security.private'),
|
||
|
|
"friends", BML::ml('label.security.accesslist'));
|
||
|
|
return LJ::html_select({ 'name' => 'security',
|
||
|
|
'selected' => "public" }, @secs);
|
||
|
|
} _code?><br />
|
||
|
|
|
||
|
|
<hr />
|
||
|
|
<center>
|
||
|
|
<input type='submit' value="<?_ml .form.button _ml?>" /> <?_ml .form.post_to _ml?> <?_code
|
||
|
|
{
|
||
|
|
return LJ::html_select({ 'name' => 'usejournal', },
|
||
|
|
"", $u->{'user'},
|
||
|
|
map { $_, $_ } @{$res->{'usejournals'} || []});
|
||
|
|
|
||
|
|
}_code?>
|
||
|
|
</center>
|
||
|
|
|
||
|
|
</form>
|
||
|
|
|
||
|
|
</body>
|
||
|
|
</html>
|