{'title'}; my $head = \$_[1]->{'head'}; my $body = \$_[1]->{'body'}; my $bodyopts = \$_[1]->{'bodyopts'}; $$title = $ML{'.title'}; # server down? if ($LJ::SERVER_DOWN) { $$body = LJ::server_down_html(); return; } LJ::set_active_crumb("update"); # invalid text input? unless (LJ::text_in(\%POST)) { BML::set_status(403); # 403 Forbidden $$body = ""; return; } # get remote and see if they can post right now my $remote = LJ::get_remote(); # Errors that are unlikely to change between starting # to compose an entry and submitting it. if ($remote) { if ($remote->underage) { return BML::redirect("$LJ::SITEROOT/agecheck/?s=1"); } if ($remote->identity) { BML::set_status(403); # 403 Forbidden $$title = "Sorry"; $$body = "Non-$LJ::SITENAME users can't post, as they don't actually have journals here. You can leave comments in other journals, though."; return; } if (! LJ::get_cap($remote, "can_post")) { BML::set_status(403); # 403 Forbidden $$title = "Can't Post"; $$body = $LJ::MSG_NO_POST || $ML{'.error.cantpost'}; return; } if (LJ::get_cap($remote, "disable_can_post")) { unless (LJ::run_hook("update.bml_disable_can_post", { title => $title, body => $body, })) { #BML::set_status(403); # 403 Forbidden $$title = $ML{'.error.disabled.title'}; $$body = $ML{'.error.disabled'}; } return; } } my %res = (); # see if we need to do any transformations LJ::run_hooks("transform_update_$POST{transform}", \%GET, \%POST) if $POST{transform}; # Set up form default values: my @time = localtime(time); my ($year, $mon, $mday, $hour, $min) = ($time[5] + 1900, sprintf("%02d", $time[4] + 1), sprintf("%02d", $time[3]), $time[2], sprintf("%02d", $time[1])); my $subject = $POST{'subject'} || $GET{'subject'}; my $event = $POST{'event'} || $GET{'event'}; ### define some bools with common logic ### my $did_post = LJ::did_post() && !$POST{transform}; # transforms aren't posts 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 && ! $POST{'response'}; # user w/o password # which authentication option do we display by default? my $altlogin_display = 'none'; my $remotelogin_display = 'none'; if ($auth_as_remote) { $remotelogin_display = 'table-row'; } else { $altlogin_display = 'table-row'; } # Check for errors, store in hash to render later my $errors; my $onload = "shift_contents(); "; my $showform = $POST{'showform'} || $auth_missing; # show entry form my $preview = $POST{'action:preview'}; # are we spellchecking before we post? my $did_spellcheck; my $spellcheck_html; if ($LJ::SPELLER && $POST{'action:spellcheck'}) { $did_spellcheck++; my $s = new LJ::SpellCheck { 'spellcommand' => $LJ::SPELLER, 'color' => '', }; my $event = LJ::ehtml($event); $spellcheck_html = $s->check_html(\$event); $spellcheck_html = "" unless $spellcheck_html ne ""; $onload .= "pageload(0); "; # js fill-in off my $date = LJ::html_datetime_decode({ 'name' => "date_ymd", }, \%POST); ($year, $mon, $mday) = split( /\D/, $date); $hour = $POST{'hour'}; $min = $POST{'min'}; } else { $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]); } # richtext # 'switched_rte_on' is only set when the user first enables rte. We do this in a POST # so any pre-existing text in the event and subject fields aren't lost when going to RTE. # 'rich' is used to keep RTE mode enabled between pages, such as spellchecks. # The $GET{'rich'} is simply for user bookmarking / faq linking convenience. my $enabled_rte = $POST{'switched_rte_on'}; my $richtext = 1 if $GET{rich} || $POST{rich} || ($enabled_rte && ! $spellcheck_html && ! $preview); $$bodyopts .= "onunload=\"save_entry();\" " if $richtext; my $print_entry_form = sub { my $opts = shift; # authentication box my $auth = ''; if ($remote) { # so lynx won't show this $auth .= "