1 ###RUN_PERL: #!/usr/bin/perl
4 # goto is generated from goto.1.pl.
8 # Copyright (C) 2017, 2023, 2024 Balthasar SzczepaĆski
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU Affero General Public License as
12 # published by the Free Software Foundation, either version 3 of the
13 # License, or (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Affero General Public License for more details.
20 # You should have received a copy of the GNU Affero General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 # use Encode::Locale ('decode_argv');
26 use Encode ('encode', 'decode');
28 ###PERL_LIB: use lib /botm/lib/bsta
36 'fail_method', 'fail_content_type',
41 'read_settings', 'read_state', 'read_goto'
44 ###PERL_CGI_PATH: CGI_PATH = /bsta/
45 ###PERL_CGI_LIST_PATH: CGI_LIST_PATH = /bsta/goto.htm
46 ###PERL_CGI_VIEWER_PATH: CGI_VIEWER_PATH = /bsta/v
48 ###PERL_WWW_GOTO_PATH: WWW_GOTO_PATH = /botm/www/1190/bsta/goto.htm
50 ###PERL_WEBSITE_NAME: WEBSITE_NAME = Bicycles on the Moon
52 binmode STDIN, ':encoding(UTF-8)';
53 binmode STDOUT, ':encoding(UTF-8)';
54 binmode STDERR, ':encoding(UTF-8)';
71 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
72 ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
74 if ($ENV{'REQUEST_METHOD'} =~ /^(HEAD|GET|POST)$/) {
78 exit fail_method($ENV{'REQUEST_METHOD'}, ['GET', 'POST', 'HEAD']);
81 %http = read_header_env(\%ENV);
82 %cgi = url_query_decode($ENV{'QUERY_STRING'});
84 if ($method eq 'POST') {
85 if ($http{'content-type'} eq 'application/x-www-form-urlencoded') {
86 my %cgi_post = url_query_decode( <STDIN> );
87 %cgi = merge_settings(\%cgi, \%cgi_post);
89 # multipart not supported
91 exit fail_content_type($method, $http{'content-type'});
95 $no_cgi = (scalar (keys %cgi) == 0);
98 if (_x_encoded('-f', WWW_GOTO_PATH())) {
99 exit redirect($method, CGI_LIST_PATH());
103 $password = get_password(\%cgi);
105 %settings = read_settings();
106 %state = read_state();
107 %goto_list = read_goto();
109 $password_ok = ($password eq $settings{'password'});
111 print "Content-type: text/html; charset=UTF-8\n";
113 if($method eq 'HEAD') {