]> bicyclesonthemoon.info Git - ott/bsta/blob - 2words.1.pl
reworked Coincidence chat
[ott/bsta] / 2words.1.pl
1 ###RUN_PERL: #!/usr/bin/perl
2
3 # /bsta/2words
4 # 2words is generated from 2words.1.pl.
5 #
6 # The wordgame interface
7 #
8 # Copyright (C) 2016 - 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 utf8;
25 # use Encode::Locale ('decode_argv');
26 use Encode ('encode', 'decode');
27
28 ###PERL_LIB: use lib /botm/lib/bsta
29 use botm_common (
30         'read_data_file', 'write_data_file',
31         'join_path',
32         'merge_url',
33         'read_header_env',
34         'html_entity_encode_dec',
35         'url_query_decode'
36 );
37 use bsta_lib (
38         'STATE', 'INTF_STATE',
39         'get_id',
40         'fail_method', 'fail_content_type',
41         'print_html_start', 'print_html_end',
42         'print_html_head_start', 'print_html_head_end',
43         'print_html_body_start', 'print_html_body_end',
44         'write_index',
45         'get_remote_addr',
46         'merge_settings'
47 );
48 use  File::Copy;
49
50 ###PERL_PATH_SEPARATOR:     PATH_SEPARATOR     = /
51
52 ###PERL_CGI_PATH:           CGI_PATH           = /bsta/
53 ###PERL_CGI_2WORDS_PATH:    CGI_2WORDS_PATH    = /bsta/2words
54
55 ###PERL_DATA_PATH:          DATA_PATH          = /botm/data/bsta/
56 ###PERL_DATA_DEFAULT_PATH:  DATA_DEFAULT_PATH  = /botm/data/bsta/default
57 ###PERL_DATA_LIST_PATH:     DATA_LIST_PATH     = /botm/data/bsta/list
58 ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/settings
59 ###PERL_DATA_STATE_PATH:    DATA_STATE_PATH    = /botm/data/bsta/state
60 ###PERL_DATA_STORY_PATH:    DATA_STORY_PATH    = /botm/data/bsta/story
61
62 ###PERL_WWW_PATH:           WWW_PATH           = /botm/www/1190/bsta/
63
64 ###PERL_WEBSITE_NAME:       WEBSITE_NAME       = Bicycles on the Moon
65
66 ###PERL_STORY_LENGTH:       STORY_LENGTH       = 16
67 ###PERL_PAGE_LENGTH:        PAGE_LENGTH        = 16
68 ###PERL_FIRSTPAGE_LENGTH:   FIRSTPAGE_LENGTH   = 4
69
70 binmode STDIN,  ':encoding(UTF-8)';
71 binmode STDOUT, ':encoding(UTF-8)';
72 binmode STDERR, ':encoding(UTF-8)';
73 # decode_argv();
74
75 my %http;
76 my %cgi;
77 my %story;
78 my %new_story;
79 my %settings;
80 my %state;
81 my %goto_list;
82
83 my $time = time();
84 srand ($time-$$);
85
86 my $method;
87 my $IP;
88 my $words;
89 my $color2;
90 my $last_IP;
91 my $story_id;
92 my $turn;
93 my $message;
94 my $first_letter;
95 my $second_letter;
96 my $last_letter;
97 my $intf_state;
98 my $intf_pass;
99 my $intf_pause;
100 my $intf_mode;
101 my $story_i_path;
102 my $story_file;
103 my $story_lock;
104 my @story_lines;
105 my $ong_state;
106 my $page;
107 my $cmd_clear;
108 my $cmd_clear_all;
109
110
111 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
112 ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
113
114 if ($ENV{'REQUEST_METHOD'} =~ /^(HEAD|GET|POST)$/) {
115         $method = $1;
116 }
117 else {
118         exit fail_method($ENV{'REQUEST_METHOD'}, 'GET, POST, HEAD');
119 }
120
121 %http = read_header_env(\%ENV);
122 %cgi = url_query_decode($ENV{'QUERY_STRING'});
123
124 if ($method eq 'POST') {
125         if ($http{'content-type'} eq 'application/x-www-form-urlencoded') {
126                 my %cgi_post = url_query_decode( <STDIN> );
127                 %cgi = merge_settings(\%cgi, \%cgi_post);
128         }
129         # multipart not supported
130         else{
131                 exit fail_content_type($method, $http{'content-type'});
132         }
133 }
134
135 $IP = get_remote_addr();
136 $page = get_id(\%cgi);
137 if ($cgi{'words'} ne '') {
138         $words = $cgi{'words'};
139 }
140
141 %settings = read_data_file(DATA_SETTINGS_PATH());
142 %state    = read_data_file(DATA_STATE_PATH());
143 $ong_state = int($state{'state'});
144 $cmd_clear     = $settings{'password'}.' clear';
145 $cmd_clear_all = $settings{'password'}.' clearall';
146
147 $story_lock=0;
148 if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
149         $story_lock=1;
150         if (flock($story_file,2)) {
151                 $story_lock=2;
152         }
153         %story = read_data_file($story_file);
154         
155         if ($story{'lastip'} =~ /^.+$/) {
156                 $last_IP=$&;
157         }
158         else {
159                 $last_IP='0.0.0.0';
160         }
161         
162         $last_letter = lc($story{'letter'});
163         $story_id   = int($story{'id'});
164         $intf_pass  = int($story{'pass'});
165         $intf_state = int($story{'state'});
166         $intf_mode  = $intf_state & INTF_STATE->{'mode'};
167         $intf_pause = $intf_state & INTF_STATE->{'||'};
168         
169         if ($IP ne $last_IP) {
170                 $turn = 1;
171         }
172         else {
173                 $turn = 0;
174         }
175         
176         if (
177                 ($words eq $cmd_clear) ||
178                 ($words eq $cmd_clear_all) ||
179                 ($intf_state < 0)
180         ) {
181                 if (
182                         ($words eq $cmd_clear_all) ||
183                         ($intf_state < -1)
184                 ) {
185                         $story{'id'} = 0;
186                 }
187                 $story{'content'} = '';
188                 $story{'lastip' } = '0.0.0.0';
189                 $story{'letter' } = '';
190                 $story{'pass'   } = 0;
191                 $story{'state'  } = INTF_STATE->{'X'};
192                 $turn = 0;
193                 if ($ong_state == STATE->{'inactive'}) {
194                         write_index(
195                                 \%state,
196                                 \%settings,
197                                 $story{'pass'},
198                                 $story{'state'},
199                                 0 # pause
200                         );
201                 }
202                 write_data_file($story_file, '', '', \%story);
203         }
204         
205         if ($words ne '') {
206                 if (!$turn) {
207                         $message = "It's not your turn.";
208                 }
209                 # TODO: consider allowing non-ASCII letters in words.
210                 # (not very important in English language)
211                 elsif ($words =~ /^([!"\(\),\.:;\?][ \t]*)?([A-Za-z][A-Za-z'\-]*[A-Za-z']?)([!"\(\),\.:;\? \t][ \t]*)([A-Za-z][A-Za-z'\-]*[A-Za-z']?)([!"\(\),\.:;\?]?[ \t]*)$/) {
212                         # we have 2 words
213                         $first_letter  = lc(substr($2, 0, 1));
214                         $second_letter = lc(substr($4, 0, 1));
215                         if (
216                                 ($first_letter ne $last_letter) &&
217                                 ($last_letter ne '')
218                         ) {
219                                 $message = 'The first word must start with '.uc($last_letter).'.';
220                         }
221                         elsif ($first_letter eq $second_letter) {
222                                 $message = 'The second word can\'t also start with '.uc($first_letter).'.';
223                         }
224                         else {
225                                 # words are valid
226                                 # update state
227                                 $story{'content'} = $story{'content'} . $words."\n";
228                                 $turn = 0;
229                                 $story{'lastip'} = $IP;
230                                 $story{'letter'} = $second_letter;
231                                 
232                                 if ($cgi{'next'} ne '') {
233                                         # start next game
234                                         if (split(/\r?\n/,$story{'content'}) >= (STORY_LENGTH-1)) {
235                                                 # store finished game
236                                                 $story_i_path = DATA_STORY_PATH.$story_id;
237                                                 write_data_file($story_i_path, '', '', \%story);
238                                                 # init new game
239                                                 $new_story{'id'     } = $story_id + 1;
240                                                 $new_story{'letter' } = '';
241                                                 $new_story{'lastip' } = $IP;
242                                                 $new_story{'content'} = '';
243                                                 $new_story{'pass'   } = 0;
244                                                 $new_story{'state'  } = INTF_STATE->{'X'};
245                                                 # reset hidden interface
246                                                 $intf_state = INTF_STATE->{'X'};
247                                                 $intf_pass = 0;
248                                                 $intf_mode = INTF_STATE->{'X'};
249                                                 $intf_pause= 0;
250                                                 if($ong_state == STATE->{'inactive'}) {
251                                                         # ONG not activated yet; reset index
252                                                         write_index(
253                                                                 \%state,
254                                                                 \%settings,
255                                                                 $intf_pass,
256                                                                 $intf_mode,
257                                                                 $intf_pause
258                                                         );
259                                                 }
260                                                 # save new game
261                                                 write_data_file($story_file, '', '', \%new_story);
262                                         }
263                                         else {
264                                                 $message = 'To early to finish this wordgame.';
265                                                 write_data_file($story_file, '', '', \%story);
266                                         }
267                                 }
268                                 else {
269                                         # continue the game
270                                         if ($intf_pass == 1) {
271                                                 # hidden interface was already active; deactivate
272                                                 $intf_pass = 2;
273                                                 $story{'pass'} = 2;
274                                                 if($ong_state == STATE->{'inactive'}) {
275                                                         write_index(
276                                                                 \%state,
277                                                                 \%settings,
278                                                                 $intf_pass,
279                                                                 $intf_mode,
280                                                                 $intf_pause
281                                                         );
282                                                 }
283                                         }
284                                         elsif(lc($2).' '.lc($4) eq $settings{'unlock'}) {
285                                                 # correct password for the hidden interface!
286                                                 if ($intf_pass != 0) {
287                                                         $message = 'The password has already been used in this story.';
288                                                 }
289                                                 elsif ($ong_state != STATE->{'inactive'}) {
290                                                         # ONG already active, nothing to do here
291                                                         $message = "???";
292                                                 }
293                                                 else {
294                                                         # ready to activate?
295                                                         my $frame_data_path;
296                                                         my %frame_data;
297                                                         my %default;
298                                                         my $frame_file;
299                                                         my $in_path;
300                                                         my $out_path;
301                                                         my $ext;
302                                                         
303                                                         # prepare to ONG frame 0!
304                                                         
305                                                         $frame_data_path = join_path(PATH_SEPARATOR(), DATA_PATH(), 0);
306                                                         %frame_data = read_data_file($frame_data_path);
307                                                         %default    = read_data_file(DATA_DEFAULT_PATH());
308                                                         
309                                                         $ext = (defined($frame_data{'ext'})) ?
310                                                                 $frame_data{'ext'} :
311                                                                 $default{'ext'};
312                                                         
313                                                         $frame_file = sprintf($settings{'frame'}, 0, $ext);
314                                                         $in_path  = join_path(PATH_SEPARATOR(), DATA_PATH(), $frame_file);;
315                                                         $out_path = join_path(PATH_SEPARATOR(), WWW_PATH(),  $frame_file);
316                                                         
317                                                         # set ONG time of frame 0
318                                                         # NOTE: might get overwritten later if ONG not launched
319                                                         $frame_data{'ongtime'} = $time;
320                                                         $frame_data{'timer'} = 0;
321                                                         write_data_file($frame_data_path, '', '', \%frame_data);
322                                                         
323                                                         # update the GOTO list with frame 0
324                                                         $goto_list{'title-0'  } = $frame_data{'title'};
325                                                         $goto_list{'ongtime-0'} = $frame_data{'ongtime'};
326                                                         write_data_file(DATA_LIST_PATH(), '', '', \%goto_list);
327                                                         
328                                                         if(copy ($in_path, $out_path)) {
329                                                                 # new state of hidden interface
330                                                                 $intf_pass = 1;
331                                                                 $intf_state = INTF_STATE->{'X'};
332                                                                 $intf_mode  = INTF_STATE->{'X'};
333                                                                 $intf_pause = 0;
334                                                                 $story{'pass'} = 1;
335                                                                 $story{'state'} = INTF_STATE->{'X'};
336                                                                 write_index(
337                                                                         \%state,
338                                                                         \%settings,
339                                                                         $intf_pass,
340                                                                         $intf_mode,
341                                                                         $intf_pause
342                                                                 );
343                                                         }
344                                                 }
345                                         }
346                                         write_data_file($story_file, '', '', \%story);
347                                 }
348                         }
349                 }
350                 else {
351                         $message = 'Please, two words, not more, not less (some punctuation is allowed).';
352                 }
353         }
354         elsif (
355                 ($cgi{'s'} ne '') &&
356                 ($intf_pass == 1) &&
357                 ($ong_state == STATE->{'inactive'})
358         ) {
359                 $intf_state = int($cgi{'s'}) & INTF_STATE->{'mask'};
360                 $intf_mode  = $intf_state & INTF_STATE->{'mode'};
361                 $intf_pause = $intf_state & INTF_STATE->{'||'};
362                 $story{'state'} = $intf_state;
363                 write_index(
364                         \%state,
365                         \%settings,
366                         $intf_pass,
367                         $intf_mode,
368                         $intf_pause
369                 );
370                 write_data_file($story_file, '', '', \%story);
371         }
372         @story_lines = split(/\r?\n/, $story{'content'});
373         if(@story_lines & 1) {
374                 $turn = !$turn;
375         }
376         
377         close($story_file);
378 }
379
380 print "Content-type: text/html\n\n";
381 if($method eq 'HEAD') {
382         exit;
383 }
384
385 my $max_page = int(($story_id - FIRSTPAGE_LENGTH - 1) / PAGE_LENGTH) + 1;
386 my $newer_available = ($page > 0);
387 my $older_available = ($page < $max_page);
388 my $show_intf = ($intf_pass == 1) && ($ong_state == STATE->{'inactive'});
389 my $id_start = 
390         $story_id-1 -(
391                 ($page == 0)    ? 0 : (
392                         (($page-1) * PAGE_LENGTH ) + FIRSTPAGE_LENGTH
393                 )
394         );
395 my $id_stop = $story_id-1 - (($page*PAGE_LENGTH) + FIRSTPAGE_LENGTH);
396 if ($id_stop < 0) {
397         $id_stop = -1;
398 }
399
400 my $bsta_url = CGI_PATH;
401 my $twowords_url = CGI_2WORDS_PATH;
402 my $newer_url;
403 my $older_url;
404 my $oldest_url;
405 my $newest_url = merge_url(
406         {'path' => $twowords_url},
407         {'path' => 0}
408 );
409 if ($newer_available) {
410         $newer_url = merge_url(
411                 {'path' => $twowords_url},
412                 {'path' => $page-1}
413         );
414 }
415 if ($older_available) {
416         $older_url = merge_url(
417                 {'path' => $twowords_url},
418                 {'path' => $page+1}
419         );
420         $oldest_url = merge_url(
421                 {'path' => $twowords_url},
422                 {'path' => $max_page}
423         );
424 }
425 my $button_4_url = merge_url(
426         {'path' => $twowords_url},
427         {'query' => {'s' => (INTF_STATE->{'>'} | $intf_pause)}}
428 );
429 my $button_3_url = merge_url(
430         {'path' => $twowords_url},
431         {'query' => {'s' => (INTF_STATE->{'<<'} | $intf_pause)}}
432 );
433 my $button_2_url = merge_url(
434         {'path' => $twowords_url},
435         {'query' => {'s' => (INTF_STATE->{'>>'} | $intf_pause)}}
436 );
437 my $button_1_url = merge_url(
438         {'path' => $twowords_url},
439         {'query' => {'s' => INTF_STATE->{'X'}}}
440 );
441 my $button_0_url = merge_url(
442         {'path' => $twowords_url},
443         {'query' => {'s' => ($intf_pause ? $intf_mode : ($intf_mode | INTF_STATE->{'||'}))}}
444 );
445 my $button_5_img = merge_url(
446         {'path' => CGI_PATH()},
447         {'path' => 'intf-20.gif'}
448 );
449 my $button_4_img = merge_url(
450         {'path' => CGI_PATH()},
451         {'path' => 'intf-10'.(($intf_mode == INTF_STATE->{'>'}) ? '_' : '').'.gif'}
452 );
453 my $button_3_img = merge_url(
454         {'path' => CGI_PATH()},
455         {'path' => 'intf-08'.(($intf_mode == INTF_STATE->{'<<'}) ? '_' : '').'.gif'}
456 );
457 my $button_2_img = merge_url(
458         {'path' => CGI_PATH()},
459         {'path' => 'intf-04'.(($intf_mode == INTF_STATE->{'>>'}) ? '_' : '').'.gif'}
460 );
461 my $button_1_img = merge_url(
462         {'path' => CGI_PATH()},
463         {'path' => 'intf-02.gif'}
464 );
465 my $button_0_img = merge_url(
466         {'path' => CGI_PATH()},
467         {'path' => 'intf-01'.($intf_pause ? '_' : '').'.gif'}
468 );
469 my $intf_img_id = '';
470 if ($intf_state == INTF_STATE->{'>'}) {
471         $intf_img_id = '_10'
472 }
473 elsif ($intf_mode == INTF_STATE->{'<<'}) {
474         $intf_img_id = '_08'
475 }
476 elsif ($intf_mode == INTF_STATE->{'>>'}) {
477         $intf_img_id = '_04'
478 }
479 my $intf_img = merge_url(
480         {'path' => CGI_PATH()},
481         {'path' => 'intf-00'.$intf_img_id.'.gif'}
482 );
483
484 my $_bsta_url     = html_entity_encode_dec($bsta_url     , 1);
485 my $_twowords_url = html_entity_encode_dec($twowords_url , 1);
486 my $_newest_url   = html_entity_encode_dec($newest_url   , 1);
487 my $_newer_url    = html_entity_encode_dec($newer_url    , 1);
488 my $_older_url    = html_entity_encode_dec($older_url    , 1);
489 my $_oldest_url   = html_entity_encode_dec($oldest_url   , 1);
490 my $_button_4_url = html_entity_encode_dec($button_4_url , 1);
491 my $_button_3_url = html_entity_encode_dec($button_3_url , 1);
492 my $_button_2_url = html_entity_encode_dec($button_2_url , 1);
493 my $_button_1_url = html_entity_encode_dec($button_1_url , 1);
494 my $_button_0_url = html_entity_encode_dec($button_0_url , 1);
495 my $_button_5_img = html_entity_encode_dec($button_5_img , 1);
496 my $_button_4_img = html_entity_encode_dec($button_4_img , 1);
497 my $_button_3_img = html_entity_encode_dec($button_3_img , 1);
498 my $_button_2_img = html_entity_encode_dec($button_2_img , 1);
499 my $_button_1_img = html_entity_encode_dec($button_1_img , 1);
500 my $_button_0_img = html_entity_encode_dec($button_0_img , 1);
501 my $_intf_img     = html_entity_encode_dec($intf_img     , 1);
502 my $_message      = html_entity_encode_dec($message      , 1);
503 my $_website_name = html_entity_encode_dec(WEBSITE_NAME(), 1);
504
505 print_html_start(\*STDOUT);
506 print_html_head_start(\*STDOUT);
507
508
509 print '  <title>Two words &bull; '.$_website_name.'</title>'."\n";
510 print '  <link rel="start" href="'.$_oldest_url.'">'."\n";
511 if ($older_available) {
512         print '  <link rel="prev" href="'.$_older_url.'">'."\n";
513 }
514 if ($newer_available) {
515         print '  <link rel="next" href="'.$_newer_url.'">'."\n";
516 }
517
518 print_html_head_end(\*STDOUT);
519 print_html_body_start(\*STDOUT);
520
521 print '   <div id="inst" class="ins">'."\n";
522
523 print '    <div id="title">'."\n";
524 print '     <h1 id="titletext">Two words</h1>'."\n";
525 print '    </div>'."\n";
526
527 if ($page == 0) {
528         print '    <div id="storypuzzle">'."\n";
529         for (my $i = 0; $i < @story_lines; ++$i) {
530                 print '     <span class="'.($turn ? 'ni':'br').'">'.html_entity_encode_dec($story_lines[$i], 1).'</span>'."\n";
531                 $turn = !$turn;
532         }
533         print '    </div>'."\n";
534
535         print '    <div id="command">'."\n";
536         if ($message ne '') {
537                 print '     <span class="br">'.$_message.'</span>'."\n";
538         }
539         
540         if ($turn) {
541                 print '     <form method="post" action="'.$_twowords_url.'">'."\n";
542                 if ($message eq '') {
543                         if ($story{"content"} eq '') {
544                                 print '      Two words, please:<br>'."\n";
545                         }
546                         else {
547                                 print '      Please continue, two words:<br>'."\n";
548                         }
549                 }
550                 print '      <input class="intx" type="text" name="words">'."\n";
551                 print '      <input class="inbt" type="submit" value="enter">'."\n";
552                 if(@story_lines >= (STORY_LENGTH-1)) {
553                         print '      <input class="inbt" type="submit" name="next" value="enter and then start a new one">'."\n";
554                 }
555                 print '     </form>'."\n";
556         }
557         else {
558                 if ($message eq '') {
559                         print '     Wait for it.'."\n";
560                 }
561         }
562         print '    </div>'."\n";
563 }
564 elsif ($message ne '') {
565         print '    <div id="command">'."\n";
566         print '     <span class="br">'.$_message.'</span>'."\n";
567         print '    </div>'."\n";
568 }
569 print '   </div>'."\n";
570
571 if ($show_intf) {
572         print '   <div id="framespace">'."\n";
573         print '    <table id="intftable" cellspacing="0" cellpadding="0">'."\n";
574         print '     <tr class="intf">'."\n";
575         print '      <td colspan="6" class="intf"><img src="'.$_intf_img.'" alt="" class="intf"></td>'."\n";
576         print '     </tr>'."\n";
577         
578         print '     <tr class="intf">'."\n";
579         print '      <td class="intf"><img src="'.$_button_5_img.'" alt="o" class="intf"></td>'."\n";
580         print '      <td class="intf"><a href="'.$_button_4_url.'"><img src="'.$_button_4_img.'" class="intf" alt="&gt;"></a></td>'."\n";
581         print '      <td class="intf"><a href="'.$_button_3_url.'"><img src="'.$_button_3_img.'" class="intf" alt="&lt;&lt;"></a></td>'."\n";
582         print '      <td class="intf"><a href="'.$_button_2_url.'"><img src="'.$_button_2_img.'" class="intf" alt="&gt;&gt;"></a></td>'."\n";
583         print '      <td class="intf"><a href="'.$_button_1_url.'"><img src="'.$_button_1_img.'" class="intf" alt="^"></a></td>'."\n";
584         print '      <td class="intf"><a href="'.$_button_0_url.'"><img src="'.$_button_0_img.'" class="intf" alt="||"></a></td>'."\n";
585         print '     </tr>'."\n";
586         print '    </table>'."\n";
587         print '   </div>'."\n";
588 }
589
590 print '   <div id="insb" class="ins">'."\n";
591
592 print '    <div id="undertext">'."\n";
593 for (my $i = $id_start; $i > $id_stop; --$i) {
594         $story_i_path = DATA_STORY_PATH.$i;
595         %new_story = read_data_file($story_i_path);
596         print '     <p class="'.(($i&1)?'br':'ni').'" id="s'.$i.'">'.html_entity_encode_dec($new_story{'content'}).'</p>'."\n";
597 }
598 print '    </div>'."\n";
599
600 print '    <div id="underlinks">'."\n";
601 print '     <a href="'.$_bsta_url.'">BSTA</a> |'."\n";
602 print '     <a href="'.$_twowords_url.'">Once again</a>';
603 if ($older_available) {
604         print ' |'."\n";
605         print '     <a href="'.$_older_url.'">Before</a>';
606 }
607 if ($newer_available) {
608         print ' |'."\n";
609         print '     <a href="'.$newer_url.'">Unbefore</a>';
610 }
611 if ($older_available) {
612         print ' |'."\n";
613         print '<a href="'.$_oldest_url.'">Initially</a>';
614 }
615 if($turn) {
616         print ' |'."\n";
617         print '     (Entering words here is irreversible. Your actions might be remembered forever. So please be reasonable.)';
618 }
619 print "\n";
620 print '    </div>'."\n";
621
622 print '   </div>'."\n";
623
624 print_html_body_end(\*STDOUT);
625 print_html_end(\*STDOUT);