1 ###RUN_PERL: #!/usr/bin/perl
4 ###RUN_PERL: #!/usr/bin/perl
8 # Copyright (C) 2017, 2023 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 ###PERL_LIB: use lib /botm/lib/bsta
26 use bsta_lib qw(failpage gethttpheader getcgi readdatafile printdatafile entityencode urlencode);
29 ###PERL_CGI_PATH: CGI_PATH = /bsta/
30 ###PERL_CGI_CSS_PATH: CGI_CSS_PATH = /bsta/bsta.css
31 ###PERL_CGI_LOGO_PATH: CGI_LOGO_PATH = /bsta/botmlogo.png
32 ###PERL_CGI_VIEWER_PATH: CGI_VIEWER_PATH = /bsta/v
34 ###PERL_DATA_PATH: DATA_PATH = /botm/data/bsta/
35 ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/settings
36 ###PERL_DATA_STATE_PATH: DATA_STATE_PATH = /botm/data/bsta/state
37 ###PERL_DATA_LIST_PATH: DATA_LIST_PATH = /botm/data/bsta/list
39 ###PERL_WEBSITE: WEBSITE = 1190.bicyclesonthemoon.info
40 ###PERL_WEBSITE_NAME: WEBSITE_NAME = Bicycles on the Moon
41 ###PERL_FAVICON_PATH: FAVICON_PATH = /img/favicon.png
65 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
66 ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
68 if ($ENV{'REQUEST_METHOD'} =~ /^(HEAD|GET|POST)$/) {
72 exit failpage("Status: 405 Method Not Allowed\nAllow: GET, POST, HEAD\n","405 Method Not Allowed","The interface does not support the $ENV{'REQUEST_METHOD'} method.",$method);
75 %http = gethttpheader (\%ENV);
76 %cgi = getcgi($ENV{'QUERY_STRING'});
78 if ($method eq 'POST') {
79 if ($http{'content-type'} eq 'application/x-www-form-urlencoded') {
80 my %cgipost=getcgi( <STDIN> );
81 foreach my $ind (keys %cgipost) {
82 $cgi{$ind}=$cgipost{$ind};
85 # multipart not supported
87 exit failpage("Status: 415 Unsupported Media Type\n","415 Unsupported Media Type","Unsupported Content-type: $http{'content-type'}.");
91 if ($cgi{'p'} =~ /^(.+)$/) {
98 %settings=readdatafile(DATA_SETTINGS_PATH);
99 %state=readdatafile(DATA_STATE_PATH);
100 %gotolist=readdatafile(DATA_LIST_PATH);
102 if($password eq $settings{'password'}){
109 print "Content-type: text/html\n";
111 if($method eq 'HEAD') {
115 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">'."\n";
116 print '<html lang="en"><head>'."\n";
117 print '<title>GOTO • '.entityencode($settings{'story'}).' • '.WEBSITE_NAME.'</title>'."\n";
118 print '<meta http-equiv="Content-type" content="text/html; charset=UTF-8">'."\n";
119 print '<link rel="icon" type="image/png" href="'.FAVICON_PATH.'">'."\n";
120 print '<link rel="stylesheet" href="'.CGI_CSS_PATH.'">'."\n";
121 print '</head><body>'."\n";
122 print '<a href="/"><img id="botmlogo" src="'.CGI_LOGO_PATH.'" alt="'.WEBSITE.'"></a>'."\n";
123 print '<div id="all">'."\n";
125 print '<div id="inst" class="ins">'."\n";
127 print '<div id="title">'."\n";
128 print '<H1 id="titletext">'.entityencode($settings{'story'}).'</H1>'."\n";
131 print '</div><div id="insb" class="ins">'."\n";
133 print '<div id="chat">'."\n";
135 $last=int($state{'last'});
136 $ongstate=int($state{'state'});
137 for ($frame=0; ; ++$frame) {
138 if((($frame > $last) || $ongstate<1) && !$passwordOK) {
142 $ongtime=$gotolist{'ongtime-'.$frame};
143 $title=$gotolist{'title-'.$frame};
144 if ($ongtime eq '') {
147 @timetab=gmtime($ongtime);
149 print '<span class="'.(($frame==$last && int($state{'state'}<2))?'ni':'br').'">'.sprintf('%03d',$frame).'</span> '.sprintf('%02d.%02d.%02d %02d:%02d',$timetab[3],$timetab[4]+1,$timetab[5]-100,$timetab[2],$timetab[1]).' <a href="'.CGI_VIEWER_PATH.'/'.$frame.($passwordOK?('?p='.urlencode($password)):'').'">'.entityencode($title).'</a><br>'."\n";
154 print '<div id="underlinks">'."\n";
156 print '<a href="'.CGI_PATH.'">BSTA</a>'."\n";
163 print '<a href="/" class="cz">'.WEBSITE.'</a>'."\n";
166 print '</body></html>'."\n";