4 # goto.pl is generated from goto.1.pl.
9 # Copyright (C) 2017 Balthasar SzczepaĆski
11 # This program is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU Affero General Public License as
13 # published by the Free Software Foundation, either version 3 of the
14 # License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU Affero General Public License for more details.
21 # You should have received a copy of the GNU Affero General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 use bsta_lib qw(failpage gethttpheader getcgi readdatafile printdatafile entityencode urlencode);
65 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
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(SETTINGS_PATH);
99 %state=readdatafile(STATE_PATH);
100 %gotolist=readdatafile(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="'.CSS_PATH.'">'."\n";
121 print '</head><body>'."\n";
122 print '<a href="/"><img id="botmlogo" src="'.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="'.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";