]> bicyclesonthemoon.info Git - ott/bsta/blob - goto.1.pl
Initial state as of 31.08.2023
[ott/bsta] / goto.1.pl
1 ###PERL;
2 #
3 # /bsta/g
4 # goto.pl is generated from goto.1.pl.
5 # 02.07.2017
6 #
7 # The frame list
8 #
9 #    Copyright (C) 2017  Balthasar SzczepaƄski
10 #
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.
15 #
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.
20 #
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/>.
23
24 use strict;
25 #use warnings;
26 ###LIB;
27 use bsta_lib qw(failpage gethttpheader getcgi readdatafile printdatafile entityencode urlencode);
28 use File::Copy;
29
30 ###DATA_PATH;
31 ###SETTINGS_PATH;
32 ###STATE_PATH;
33 ###LIST_PATH;
34 ###WEBSITE_NAME;
35 ###FAVICON_PATH;
36 ###CSS_PATH;
37 ###LOGO_PATH;
38 ###WEBSITE;
39 ###CGI_PATH;
40 ###VIEWER_PATH;
41
42
43 my %http;
44 my %cgi;
45 my %settings;
46 my %state;
47 my %gotolist;
48
49 my @timetab;
50
51 my $time = time();
52 srand ($time-$$);
53
54 my $method;
55 my $password;
56 my $passwordOK;
57
58 my $frame;
59 my $last;
60 my $title;
61 my $ongtime;
62 my $ongstate;
63 my $line;
64
65 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
66 ###PATH;
67
68 if ($ENV{'REQUEST_METHOD'} =~ /^(HEAD|GET|POST)$/) {
69         $method=$1;
70 }
71 else{
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);
73 }
74
75 %http = gethttpheader (\%ENV);
76 %cgi = getcgi($ENV{'QUERY_STRING'});
77
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};
83                 }
84         }
85         # multipart not supported
86         else{
87                 exit failpage("Status: 415 Unsupported Media Type\n","415 Unsupported Media Type","Unsupported Content-type: $http{'content-type'}.");
88         }
89 }
90
91 if ($cgi{'p'} =~ /^(.+)$/) {
92         $password=$1;
93 }
94 else {
95         $password='';
96 }
97
98 %settings=readdatafile(SETTINGS_PATH);
99 %state=readdatafile(STATE_PATH);
100 %gotolist=readdatafile(LIST_PATH);
101
102 if($password eq $settings{'password'}){
103         $passwordOK = 1;
104 }
105 else{
106         $passwordOK = 0;
107 }
108
109 print "Content-type: text/html\n";
110 print "\n";
111 if($method eq 'HEAD') {
112         exit;
113 }
114
115 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">'."\n";
116 print '<html lang="en"><head>'."\n";
117 print '<title>GOTO &bull; '.entityencode($settings{'story'}).' &bull; '.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";
124
125 print '<div id="inst" class="ins">'."\n";
126
127 print '<div id="title">'."\n";
128 print '<H1 id="titletext">'.entityencode($settings{'story'}).'</H1>'."\n";
129 print '</div>'."\n";
130
131 print '</div><div id="insb" class="ins">'."\n";
132
133 print '<div id="chat">'."\n";
134
135 $last=int($state{'last'});
136 $ongstate=int($state{'state'});
137 for ($frame=0; ; ++$frame) {
138         if((($frame > $last) || $ongstate<1) && !$passwordOK) {
139                 last;
140         }
141         
142         $ongtime=$gotolist{'ongtime-'.$frame};
143         $title=$gotolist{'title-'.$frame};
144         if ($ongtime eq '') {
145                 last;
146         }
147         @timetab=gmtime($ongtime);
148         
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";
150 }
151
152 print '</div>'."\n";
153
154 print '<div id="underlinks">'."\n";
155
156 print '<a href="'.CGI_PATH.'">BSTA</a>'."\n";
157
158 print '</div>'."\n";
159
160 print '</div>'."\n";
161
162 print '</div>'."\n";
163 print '<a href="/" class="cz">'.WEBSITE.'</a>'."\n";
164
165
166 print '</body></html>'."\n";
167
168
169
170
171
172