{'title'}; my $head = \$_[1]->{'head'}; my $body = \$_[1]->{'body'}; my $bodyopts = \$_[1]->{'bodyopts'}; # set page title $$title = $ML{'.title'}; # server down? if ($LJ::SERVER_DOWN) { $$body = LJ::server_down_html(); return; } # invalid text input? unless (LJ::text_in(\%POST)) { $$body = ""; return; } # get remote and see if they can post right now my $remote = LJ::get_remote(); if ($remote) { if (LJ::get_cap($remote, "readonly") || ! LJ::get_cluster_master($remote)) { $$title = $ML{'.title.readonly'}; $$body = $LJ::MSG_READONLY_USER; return; } if (! LJ::get_cap($remote, "can_post")) { $$title = "Can't Post"; $$body = $LJ::MSG_NO_POST || "Sorry, you cannot post at this time."; return; } } # are we spellchecking before we post? my $spellcheck_html; my $did_spellcheck; if ($LJ::SPELLER && $POST{'do_spellcheck'}) { my $s = new LJ::SpellCheck { 'spellcommand' => $LJ::SPELLER, 'color' => '', }; my $event = LJ::ehtml($POST{'event'}); $spellcheck_html = $s->check_html(\$event); $did_spellcheck++; } ### define some bools with common logic ### my $did_post = LJ::did_post(); my $user_is_remote = $remote && $remote->{'user'} eq $POST{'user'}; # user is remote my $auth_as_remote = $remote && (! $GET{'altlogin'} || $user_is_remote); # auth as remote my $auth_missing = $POST{'user'} && ! $POST{'password'} && ! $user_is_remote; # user w/o password my $showform = $POST{'showform'} || $auth_missing; # show entry form if ($did_post && ! $spellcheck_html && ! $showform) { # what's our authentication scheme for subsequent protocol actions? my $flags = {}; my $user; if ($POST{'user'} && # user argument given ! $user_is_remote) { # user != remote $user = $POST{'user'}; } elsif ($remote) { # assume remote if we have it $flags = { 'noauth' => 1, 'u' => $remote }; $user = $remote->{'user'}; } # do a login action my $login_message; { # build a clientversion string my $clientversion = $POST{'webversion'} eq 'full' ? "Web/1.1" : "Web/1.0"; $clientversion .= 's' if $did_spellcheck; # build a request object my %req = ( 'mode' => 'login', 'ver' => $LJ::PROTOCOL_VER, 'clientversion' => $clientversion, 'user' => $user, 'password' => $POST{'password'}, 'hpassword' => $POST{'hpassword'}, ); my %res; LJ::do_request(\%req, \%res, $flags); # error logging in ? unless ($res{'success'} eq 'OK') { $$body .= "\n"; $$body .= "
  • " . LJ::ehtml($res{'errmsg'}) . "
  • p?>"; return; } # server login message for user? $login_message = LJ::auto_linkify(LJ::ehtml($res{'message'})) if $res{'message'}; } # do update postevent { ## see if an "other" mood they typed in has an equivalent moodid my $moodid = $POST{'prop_current_moodid'}; my $moodname = lc($POST{'prop_current_mood'}); if (my $id = LJ::mood_id($moodname)) { $moodid = $id; undef $moodname; } # find security my $sec = "public"; my $amask = 0; if ($POST{'security'} eq "private") { $sec = "private"; } elsif ($POST{'security'} eq "friends") { $sec = "usemask"; $amask = 1; } elsif ($POST{'security'} eq "custom") { $sec = "usemask"; foreach my $bit (1..30) { next unless $POST{"custom_bit_$bit"}; $amask |= (1 << $bit); } } # next, postevent my %req = ( 'mode' => 'postevent', 'ver' => $LJ::PROTOCOL_VER, 'user' => $user, 'password' => $POST{'password'}, 'hpassword' => $POST{'hpassword'}, 'usejournal' => $POST{'usejournal'}, 'security' => $sec, 'allowmask' => $amask, ); # copy some things from %POST foreach (qw(event subject year mon day hour min prop_picture_keyword prop_current_moodid prop_current_mood prop_current_music)) { $req{$_} = $POST{$_}; } # copy some opts, but make sure they are 1 : 0 explicitly foreach (qw(preformatted nocomments backdated noemail)) { $req{"prop_opt_$_"} = $POST{"prop_opt_$_"} ? 1 : 0; } my %res; LJ::do_request(\%req, \%res, $flags); # examine response my $update_message; if ($res{'success'} eq "OK" && $res{'message'}) { $update_message = LJ::auto_linkify(LJ::ehtml($res{'message'})); } # report results $$body .= "\n"; # update failed? unless ($res{'success'} eq 'OK') { $$body .= "
  • " . LJ::ehtml($res{'errmsg'}) . "
  • p?>"; return; } # update success my $ju; if ($POST{'usejournal'}) { $ju = LJ::load_user($POST{'usejournal'}); # posting as community } elsif ($user) { $ju = LJ::load_user($user); # posting not as user from form } else { $ju = $remote; # posting as remote }; $$body .= " LJ::journal_base($ju) . "/" }) ." p?>"; # any messages from the server? if ($login_message) { $$body .= "\n"; $$body .= "
    $login_message
    "; } if ($update_message) { $$body .= "\n"; $$body .= "
    $update_message
    "; } } return; } ### ### show update form ### $$body .= ""; { # if they submit the form and are spellchecking, remember # their settings from the GET requests my $getextra; $getextra .= "altlogin=1&" if $GET{'altlogin'}; $getextra .= "mode=full&" if $GET{'mode'} eq 'full'; chop $getextra; $getextra = "?$getextra" if $getextra; $$body .= "
    "; } $$body .= "\n\n"; $$body .= "
    \n"; { # which authentication option do we display by default? my $altlogin_display = 'none'; my $remotelogin_display = 'none'; if ($auth_as_remote) { $remotelogin_display = 'inline'; } else { $altlogin_display = 'block'; } my $altget = $GET{'mode'} eq 'full' ? "?mode=full&altlogin=1" : "?altlogin=1"; $$body .= "

    "; if ($remote) { # so lynx won't show this $$body .= "You are currently logged in as $remote->{'user'}."; $$body .= "
    To post as another user, click here."; } $$body .= "

    \n"; # table with username/password fields $$body .= "\n"; $$body .= ""; $$body .= "\n"; $$body .= ""; $$body .= "\n"; $$body .= "
    Username:"; $$body .= LJ::html_text({ 'name' => 'user', 'size' => '15', 'maxlength' => '15', 'value' => $POST{'user'} || $GET{'user'} }); $$body .= "
    Password:"; $$body .= LJ::html_text({ 'type' => 'password', 'name' => 'password', 'size' => '15', 'maxlength' => '30' }); # posted with a user, but no password if ($did_post && $auth_missing) { $$body .= "
    "; } $$body .= "
    \n"; } $$body .= "
    \n"; $$body .= "\n"; my ($min,$hour,$mday,$mon,$year); # preserve times from form if spellchecking if ($did_spellcheck) { $$bodyopts = "onLoad=\"pageload(0);\""; # js fill-in off $year = $POST{'year'}; $mon = $POST{'mon'}; $mday = $POST{'day'}; $hour = $POST{'hour'}; $min = $POST{'min'}; # insert current time } else { $$bodyopts = "onLoad=\"pageload(1);\""; # js fill-in on my @time = localtime(time); $year = $time[5] + 1900; $mon = sprintf("%02d", $time[4] + 1); $mday = sprintf("%02d", $time[3]); $hour = $time[2]; $min = sprintf("%02d", $time[1]); } # date entry boxes / formatting note $$body .= "\n"; $$body .= "\n"; # time entry boxes / formatting note $$body .= "\n"; $$body .= "\n"; $$body .= "
    $ML{'.date'} "; $$body .= LJ::html_text({ 'name' => 'year', 'value' => $year, 'size' => '5', 'maxlength' => '4' }) . '-'; $$body .= LJ::html_text({ 'name' => 'mon', 'value' => $mon, 'size' => '3', 'maxlength' => '2' }) . '-'; $$body .= LJ::html_text({ 'name' => 'day', 'value' => $mday, 'size' => '3', 'maxlength' => '2' }); $$body .= "
    (yyyy-mm-dd)
    $ML{'.localtime'} "; $$body .= LJ::html_text({ 'name' => 'hour', 'value' => $hour, 'size' => '3', 'maxlength' => '2' }) . ':'; $$body .= LJ::html_text({ 'name' => 'min', 'value' => $min, 'size' => '3', 'maxlength' => '2' }); $$body .= "
    ($ML{'.timeformat'})
    \n
    \n"; # if no script, above is server time $$body .= "\n"; # subject $$body .= "\n"; $$body .= "
    $ML{'.subject'}
    "; $$body .= LJ::html_text({ 'name' => 'subject', 'value' => $POST{'subject'}, 'size' => '50', 'maxlength' => '100' }) . "\n"; # display spell check results $$body .= "

    $ML{'.spellchecked'}
    $spellcheck_html

    " if $spellcheck_html; # event $$body .= "

    $ML{'.event'}
    "; $$body .= LJ::html_textarea({ 'name' => 'event', 'value' => $POST{'event'} || $GET{'event'}, 'rows' => '10', 'cols' => '50', 'style' => 'width: 99%', 'wrap' => 'soft' }); $$body .= "
    "; # spell check checkbox if ($LJ::SPELLER) { $$body .= "
    " . LJ::html_check({ 'name' => 'do_spellcheck', 'id' => 'do_spellcheck' }); $$body .= ""; } $$body .= "

    "; { # simple mode block my $simple_display = $GET{'mode'} eq 'full' ? 'none' : 'block'; $$body .= "
    "; my $fullget = $GET{'altlogin'} ? "?altlogin=1&mode=full" : "?mode=full"; $$body .= BML::ml(".simple", {'url' => "update.bml$fullget" }) ."

    "; $$body .= "
    "; # put alternate link in head if not already viewing full mode $$head .= "\n" unless $GET{'mode'} eq 'full'; } { # full mode block my $full_display = $GET{'mode'} eq 'full' ? 'block' : 'none'; $$body .= "
    "; } $$body .= "\n\n"; # end full opts block $$body .= "
    \n"; $$body .= "\n"; $$body .= LJ::html_hidden('webversion', 'full') . "\n"; # do a login action to get pics and usejournals, but only if using remote my $res; if ($auth_as_remote) { $res = LJ::Protocol::do_request("login", { "ver" => $LJ::PROTOCOL_VER, "username" => $remote->{'user'}, "getpickws" => 1, }, undef, { "noauth" => 1, "u" => $remote, }); } # communities the user can post in if ($res && ref $res->{'usejournals'} eq 'ARRAY') { $$body .= "

    $ML{'.altpost'} "; $$body .= LJ::html_select({ 'name' => 'usejournal', 'selected' => $POST{'usejournal'} }, "", BML::ml(".defaultjournal", { 'user' => $remote->{'user'} }), map { $_, $_ } @{$res->{'usejournals'}}) . "

    \n"; } # possible security groups $$body .= "

    $ML{'label.security.head'} "; my @secs = ("public", $ML{'label.security.public'}, "private", $ML{'label.security.private'}, "friends", $ML{'label.security.friends'}); my @opts; if ($res && ref $res->{'friendgroups'} eq 'ARRAY') { push @secs, ("custom", $ML{'label.security.custom'}); push @opts, ("onchange" => "customboxes()"); } $$body .= LJ::html_select({ 'name' => 'security', 'selected' => $POST{'security'}, @opts }, @secs); $$body .= LJ::help_icon("security", " "); # if custom security groups available, show them in a hidable div if ($res && ref $res->{'friendgroups'} eq 'ARRAY') { my $display = $POST{'security'} eq "custom" ? "block" : "none"; $$body .= "

    "; foreach my $fg (@{$res->{'friendgroups'}}) { $$body .= LJ::html_check({ 'name' => "custom_bit_$fg->{'id'}", 'id' => "custom_bit_$fg->{'id'}", 'selected' => $POST{"custom_bit_$fg->{'id'}"} }); $$body .= "
    "; } $$body .= "
    "; } $$body .= "\n"; ### opt_ checkboxes my $prop_check = sub { my $prop = shift; my $prop_ml = shift || $prop; return " " . LJ::html_check({ 'type' => 'check', 'name' => "prop_opt_$prop", 'id' => "prop_opt_$prop", 'selected' => $POST{"prop_opt_$prop"} }); }; # backdating $$body .= "

    " . $prop_check->('backdated', 'backdate') . " "; # don't auto-format $$body .= $prop_check->('preformatted', 'noformat') . LJ::help_icon("noautoformat", " ") . "

    \n"; # don't allow comments $$body .= "

    " . $prop_check->('nocomments') . " "; # don't email the poster $$body .= $prop_check->('noemail') . "\n"; # picture to use if ($res && ref $res->{'pickws'} eq 'ARRAY') { $$body .= "

    "; $$body .= "".BML::ml(".picture", {'url' => "$LJ::SITEROOT/allpics.bml?user=$remote->{'user'}"})." "; $$body .= LJ::html_select({'name' => 'prop_picture_keyword', 'selected' => $POST{'prop_picture_keyword'} }, "", $ML{'.opt.defpic'}, map { ($_, $_) } sort { lc($a) cmp lc($b) } @{$res->{'pickws'}}); $$body .= LJ::help_icon("userpics", " ") . "

    \n"; } # mood { my @moodlist = ('', $ML{'.noneother'}); my $sel; my $moods = LJ::get_moods(); foreach (sort { $moods->{$a}->{'name'} cmp $moods->{$b}->{'name'} } keys %$moods) { push @moodlist, ($_, $moods->{$_}->{'name'}); if ($POST{'prop_current_mood'} eq $moods->{$_}->{'name'} || $POST{'prop_current_moodid'} == $_) { $sel = $_; } } $$body .= "

    $ML{'.currmood'}"; $$body .= LJ::html_select({ 'name' => 'prop_current_moodid', 'selected' => $sel }, @moodlist); $$body .= " $ML{'.other'} " . LJ::html_text({ 'name' => 'prop_current_mood', 'value' => $sel ? '' : $POST{'prop_current_mood'}, 'size' => '15', 'maxlength' => '30' }) . "\n"; } # current music $$body .= "

    $ML{'.currmusic'} "; $$body .= LJ::html_text({ 'name' => 'prop_current_music', 'value' => $POST{'prop_current_music'}, 'size' => '40', 'maxlength' => '60' }) . "

    \n"; $$body .= "
    "; $$body .= "
    \n"; # submit button $$body .= "

    " . LJ::html_submit(undef, $ML{'.btn.update'}) . "

    \n"; $$body .= "
    "; return; } _code?>{'title'}; _code?> body=>{'body'}; _code?> bodyopts=>{'bodyopts'}; _code?> head<= {'head'}; _code?> <=head page?> lib: LJ::SpellCheck link: htdocs/users, htdocs/download/index.bml, htdocs/moodlist.bml link: htdocs/update.bml, htdocs/lostinfo.bml, htdocs/support/faqbrowse.bml link: htdocs/allpics.bml post: htdocs/update.bml _c?>