use open qw{:utf8 :std};
use Encode;
-sub printheader ($) { #{{{
+sub printheader ($) {
my $session=shift;
if ($config{sslcookie}) {
print $session->header(-charset => 'utf-8',
-cookie => $session->cookie(-httponly => 1));
}
-} #}}}
+}
-sub showform ($$$$;@) { #{{{
+sub showform ($$$$;@) {
my $form=shift;
my $buttons=shift;
my $session=shift;
printheader($session);
print misctemplate($form->title, $form->render(submit => $buttons), @_);
-} #}}}
+}
-sub redirect ($$) { #{{{
+sub redirect ($$) {
my $q=shift;
my $url=shift;
if (! $config{w3mmode}) {
print "Content-type: text/plain\n";
print "W3m-control: GOTO $url\n\n";
}
-} #}}}
+}
-sub decode_cgi_utf8 ($) { #{{{
+sub decode_cgi_utf8 ($) {
# decode_form_utf8 method is needed for 5.10
if ($] < 5.01) {
my $cgi = shift;
$cgi->param($f, map { decode_utf8 $_ } $cgi->param($f));
}
}
-} #}}}
+}
-sub decode_form_utf8 ($) { #{{{
+sub decode_form_utf8 ($) {
if ($] >= 5.01) {
my $form = shift;
foreach my $f ($form->field) {
);
}
}
-} #}}}
+}
# Check if the user is signed in. If not, redirect to the signin form and
# save their place to return to later.
-sub needsignin ($$) { #{{{
+sub needsignin ($$) {
my $q=shift;
my $session=shift;
cgi_savesession($session);
exit;
}
-} #}}}
+}
-sub cgi_signin ($$) { #{{{
+sub cgi_signin ($$) {
my $q=shift;
my $session=shift;
}
showform($form, $buttons, $session, $q);
-} #}}}
+}
-sub cgi_postsignin ($$) { #{{{
+sub cgi_postsignin ($$) {
my $q=shift;
my $session=shift;
else {
error(gettext("login failed, perhaps you need to turn on cookies?"));
}
-} #}}}
+}
-sub cgi_prefs ($$) { #{{{
+sub cgi_prefs ($$) {
my $q=shift;
my $session=shift;
}
showform($form, $buttons, $session, $q);
-} #}}}
+}
-sub check_banned ($$) { #{{{
+sub check_banned ($$) {
my $q=shift;
my $session=shift;
exit;
}
}
-} #}}}
+}
-sub cgi_getsession ($) { #{{{
+sub cgi_getsession ($) {
my $q=shift;
eval q{use CGI::Session; use HTML::Entities};
umask($oldmask);
return $session;
-} #}}}
+}
# To guard against CSRF, the user's session id (sid)
# can be stored on a form. This function will check
# (for logged in users) that the sid on the form matches
# the session id in the cookie.
-sub checksessionexpiry ($$) { # {{{
+sub checksessionexpiry ($$) {
my $q=shift;
my $session = shift;
error(gettext("Your login session has expired."));
}
}
-} # }}}
+}
-sub cgi_savesession ($) { #{{{
+sub cgi_savesession ($) {
my $session=shift;
# Force session flush with safe umask.
my $oldmask=umask(077);
$session->flush;
umask($oldmask);
-} #}}}
+}
-sub cgi (;$$) { #{{{
+sub cgi (;$$) {
my $q=shift;
my $session=shift;
else {
error("unknown do parameter");
}
-} #}}}
+}
# Does not need to be called directly; all errors will go through here.
-sub cgierror ($) { #{{{
+sub cgierror ($) {
my $message=shift;
print "Content-type: text/html\n\n";
print misctemplate(gettext("Error"),
"<p class=\"error\">".gettext("Error").": $message</p>");
die $@;
-} #}}}
+}
1