]> bicyclesonthemoon.info Git - ott/bsta/blob - goto.1.pl
Adapted for new config tool.
[ott/bsta] / goto.1.pl
1 ###RUN_PERL: #!/usr/bin/perl
2 #
3 # /bsta/g
4 ###RUN_PERL: #!/usr/bin/perl
5
6 # The frame list
7 #
8 # Copyright (C) 2017, 2023  Balthasar SzczepaƄski
9 #
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.
14 #
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.
19 #
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/>.
22
23 use strict;
24 #use warnings;
25 ###PERL_LIB: use lib /botm/lib/bsta
26 use bsta_lib qw(failpage gethttpheader getcgi readdatafile printdatafile entityencode urlencode);
27 use File::Copy;
28
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
33
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
38
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
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 ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
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(DATA_SETTINGS_PATH);
99 %state=readdatafile(DATA_STATE_PATH);
100 %gotolist=readdatafile(DATA_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="'.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";
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="'.CGI_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