]> bicyclesonthemoon.info Git - botm/oldlogs/commitdiff
finished generating index & 2words bugfix
authorb <rowerynaksiezycu@gmail.com>
Fri, 29 Dec 2023 03:08:20 +0000 (03:08 +0000)
committerb <rowerynaksiezycu@gmail.com>
Fri, 29 Dec 2023 03:08:20 +0000 (03:08 +0000)
2words.1.pl
botm-common
bsta_lib.1.pm
frame.1.pl
viewer.1.pl

index 9649b764ff036566150c288e4a75df220dbae588..186e31a70fbfb0ba79961ea848430a520afc764c 100644 (file)
@@ -30,28 +30,19 @@ use botm_common (
        'read_data_file', 'write_data_file',
        'join_path',
        'merge_url',
-       'html_entitiy_encode_dec',
-       'print_html_start', 'print_html_end',
-       'print_html_head_start', 'print_html_head_end',
-       'print_html_body_start', 'print_html_body_end'
+       'read_header_env',
+       'html_entity_encode_dec',
+       'url_query_decode'
 );
 use bsta_lib (
        'STATE', 'INTF_STATE',
        'fail_method', 'fail_content_type',
-       'read_header_env',
-       'url_query_decode',
-       
-       
-       
-       # to replace
-       'failpage',
-       'gethttpheader',
-       'getcgi',
-       'entityencode',
-       'readdatafile',
-       'writedatafile',
-       'urlencode',
-       'bb2ht'
+       'print_html_start', 'print_html_end',
+       'print_html_head_start', 'print_html_head_end',
+       'print_html_body_start', 'print_html_body_end',
+       'write_index',
+       'get_remote_addr',
+       'merge_settings'
 );
 use  File::Copy;
 
@@ -111,6 +102,7 @@ my $turn;
 my $message;
 my $first_letter;
 my $second_letter;
+my $last_letter;
 my $intf_state;
 my $intf_pass;
 my $intf_pause;
@@ -163,8 +155,8 @@ if ($cgi{'words'} ne '') {
 %settings = read_data_file(DATA_SETTINGS_PATH());
 %state    = read_data_file(DATA_STATE_PATH());
 $ong_state = int($state{'state'});
-$cmd_clear     = settings{'password'}.' clear';
-$cmd_clear_all = settings{'password'}.' clearall';
+$cmd_clear     = $settings{'password'}.' clear';
+$cmd_clear_all = $settings{'password'}.' clearall';
 
 $story_lock=0;
 if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
@@ -172,7 +164,7 @@ if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
        if (flock($story_file,2)) {
                $story_lock=2;
        }
-       %story = $read_data_file($story_file);
+       %story = read_data_file($story_file);
        
        if ($story{'lastip'} =~ /^.+$/) {
                $last_IP=$&;
@@ -212,8 +204,14 @@ if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
                $story{'pass'   } = 0;
                $story{'state'  } = INTF_STATE->{'X'};
                $turn = 0;
-               if($ong_state == STATE->{'inactive'}) {
-                       writeindex(WWW_INDEX_PATH,0,0,0);  # TO REPLACE
+               if ($ong_state == STATE->{'inactive'}) {
+                       write_index(
+                               \%state,
+                               \%settings,
+                               $story{'pass'},
+                               $story{'state'},
+                               0 # pause
+                       );
                }
                write_data_file($story_file, '', '', \%story);
        }
@@ -265,7 +263,13 @@ if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
                                                $intf_pause= 0;
                                                if($ong_state == STATE->{'inactive'}) {
                                                        # ONG not activated yet; reset index
-                                                       writeindex(WWW_INDEX_PATH,0,0,0); # TO REPLACE
+                                                       write_index(
+                                                               \%state,
+                                                               \%settings,
+                                                               $intf_pass,
+                                                               $intf_mode,
+                                                               $intf_pause
+                                                       );
                                                }
                                                # save new game
                                                write_data_file($story_file, '', '', \%new_story);
@@ -282,7 +286,13 @@ if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
                                                $intf_pass = 2;
                                                $story{'pass'} = 2;
                                                if($ong_state == STATE->{'inactive'}) {
-                                                       writeindex(WWW_INDEX_PATH,2,0,0); # TO REPLACE
+                                                       write_index(
+                                                               \%state,
+                                                               \%settings,
+                                                               $intf_pass,
+                                                               $intf_mode,
+                                                               $intf_pause
+                                                       );
                                                }
                                        }
                                        elsif(lc($2).' '.lc($4) eq $settings{'unlock'}) {
@@ -305,7 +315,7 @@ if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
                                                        
                                                        # prepare to ONG frame 0!
                                                        
-                                                       $frame_data_path = joint_path(PATH_SEPARATOR(), DATA_PATH(), 0);
+                                                       $frame_data_path = join_path(PATH_SEPARATOR(), DATA_PATH(), 0);
                                                        %frame_data = read_data_file($frame_data_path);
                                                        %default    = read_data_file(DATA_DEFAULT_PATH());
                                                        %frame_data = merge_settings(\%default, \%frame_data);
@@ -317,7 +327,7 @@ if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
                                                        # set ONG time of frame 0
                                                        # NOTE: might get overwritten later if ONG not launched
                                                        $frame_data{'ongtime'} = $time;
-                                                       write_data_file($frame_data_path, '', '' \%frame_data);
+                                                       write_data_file($frame_data_path, '', '', \%frame_data);
                                                        
                                                        # update the GOTO list with frame 0
                                                        $goto_list{'title-0'  } = $frame_data{'title'};
@@ -332,16 +342,22 @@ if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
                                                                $intf_pause = 0;
                                                                $story{'pass'} = 1;
                                                                $story{'state'} = INTF_STATE->{'X'};
-                                                               writeindex(WWW_INDEX_PATH,1,0,0); # to replace
+                                                               write_index(
+                                                                       \%state,
+                                                                       \%settings,
+                                                                       $intf_pass,
+                                                                       $intf_mode,
+                                                                       $intf_pause
+                                                               );
                                                        }
                                                }
                                        }
                                        write_data_file($story_file, '', '', \%story);
                                }
                        }
-                       else {
-                               $message = 'Please, two words, not more, not less (some punctuation is allowed).';
-                       }
+               }
+               else {
+                       $message = 'Please, two words, not more, not less (some punctuation is allowed).';
                }
        }
        elsif (
@@ -353,8 +369,14 @@ if (open ($story_file,"+<:encoding(UTF-8)",DATA_STORY_PATH())){
                $intf_mode  = $intf_state & INTF_STATE->{'mode'};
                $intf_pause = $intf_state & INTF_STATE->{'||'};
                $story{'state'} = $intf_state;
-               writeindex(WWW_INDEX_PATH,1,$intf_mode,$intf_pause); # TO REPLACE
-               write_data_file($story_file, '', '' \%story);
+               write_index(
+                       \%state,
+                       \%settings,
+                       $intf_pass,
+                       $intf_mode,
+                       $intf_pause
+               );
+               write_data_file($story_file, '', '', \%story);
        }
        @story_lines = split(/\r?\n/, $story{'content'});
        if(@story_lines & 1) {
@@ -373,12 +395,23 @@ my $max_page = int(($story_id - FIRSTPAGE_LENGTH - 1) / PAGE_LENGTH) + 1;
 my $newer_available = ($page > 0);
 my $older_available = ($page < $max_page);
 my $show_intf = ($intf_pass == 1) && ($ong_state == STATE=>{'inactive'});
+my $id_start = 
+       $story_id-1 -(
+               ($page == 0)    ? 0 : (
+                       (($page-1) * PAGE_LENGTH ) + FIRSTPAGE_LENGTH
+               )
+       );
+my $id_stop = $story_id-1 - (($page*PAGE_LENGTH) + FIRSTPAGE_LENGTH);
+if ($id_stop < 0) {
+       $id_stop = -1;
+}
 
+my $bsta_url = CGI_PATH;
 my $twowords_url = CGI_2WORDS_PATH;
 my $newer_url;
 my $older_url;
 my $oldest_url;
-my $newerst_url = merge_url(
+my $newest_url = merge_url(
        {'path' => $twowords_url},
        {'path' => 0}
 );
@@ -398,16 +431,83 @@ if ($older_available) {
                {'path' => $max_page}
        );
 }
-my $buton_5_url = merge_url(
-       {'path' => CGI_PATH},
-       {'path' => 
-       
+my $button_4_url = merge_url(
+       {'path' => $twowords_url},
+       {'query' => {'s' => (INTF_STATE->{'>'} | $intf_pause)}}
+);
+my $button_3_url = merge_url(
+       {'path' => $twowords_url},
+       {'query' => {'s' => (INTF_STATE->{'<<'} | $intf_pause)}}
+);
+my $button_2_url = merge_url(
+       {'path' => $twowords_url},
+       {'query' => {'s' => (INTF_STATE->{'>>'} | $intf_pause)}}
+);
+my $button_1_url = merge_url(
+       {'path' => $twowords_url},
+       {'query' => {'s' => INTF_STATE->{'X'}}}
+);
+my $button_0_url = merge_url(
+       {'path' => $twowords_url},
+       {'query' => {'s' => ($intf_pause ? $intf_mode : ($intf_mode | INTF_STATE->{'||'}))}}
+);
+my $button_5_img = merge_url(
+       {'path' => CGI_PATH()},
+       {'path' => 'intf-20.gif'}
+);
+my $button_4_img = merge_url(
+       {'path' => CGI_PATH()},
+       {'path' => 'intf-10'.(($intf_mode == INTF_STATE->{'>'}) ? '_' : '').'.gif'}
+);
+my $button_3_img = merge_url(
+       {'path' => CGI_PATH()},
+       {'path' => 'intf-08'.(($intf_mode == INTF_STATE->{'<<'}) ? '_' : '').'.gif'}
+);
+my $button_2_img = merge_url(
+       {'path' => CGI_PATH()},
+       {'path' => 'intf-04'.(($intf_mode == INTF_STATE->{'>>'}) ? '_' : '').'.gif'}
+);
+my $button_1_img = merge_url(
+       {'path' => CGI_PATH()},
+       {'path' => 'intf-02.gif'}
+);
+my $button_0_img = merge_url(
+       {'path' => CGI_PATH()},
+       {'path' => 'intf-01'.($intf_pause ? '_' : '').'.gif'}
+);
+my $intf_img_id = '';
+if ($intf_state == INTF_STATE->{'>'}) {
+       $intf_img_id = '_10'
+}
+elsif ($intf_mode == INTF_STATE->{'<<'}) {
+       $intf_img_id = '_08'
+}
+elsif ($intf_mode == INTF_STATE->{'>>'}) {
+       $intf_img_id = '_04'
+}
+my $intf_img = merge_url(
+       {'path' => CGI_PATH()},
+       {'path' => 'intf-00'.$intf_img_id.'.gif'}
+);
 
+my $_bsta_url     = html_entity_encode_dec($bsta_url     , 1);
 my $_twowords_url = html_entity_encode_dec($twowords_url , 1);
 my $_newest_url   = html_entity_encode_dec($newest_url   , 1);
 my $_newer_url    = html_entity_encode_dec($newer_url    , 1);
 my $_older_url    = html_entity_encode_dec($older_url    , 1);
 my $_oldest_url   = html_entity_encode_dec($oldest_url   , 1);
+my $_button_4_url = html_entity_encode_dec($button_4_url , 1);
+my $_button_3_url = html_entity_encode_dec($button_3_url , 1);
+my $_button_2_url = html_entity_encode_dec($button_2_url , 1);
+my $_button_1_url = html_entity_encode_dec($button_1_url , 1);
+my $_button_0_url = html_entity_encode_dec($button_0_url , 1);
+my $_button_5_img = html_entity_encode_dec($button_5_img , 1);
+my $_button_4_img = html_entity_encode_dec($button_4_img , 1);
+my $_button_3_img = html_entity_encode_dec($button_3_img , 1);
+my $_button_2_img = html_entity_encode_dec($button_2_img , 1);
+my $_button_1_img = html_entity_encode_dec($button_1_img , 1);
+my $_button_0_img = html_entity_encode_dec($button_0_img , 1);
+my $_intf_img     = html_entity_encode_dec($intf_img     , 1);
 my $_message      = html_entity_encode_dec($message      , 1);
 my $_website_name = html_entity_encode_dec(WEBSITE_NAME(), 1);
 
@@ -424,8 +524,8 @@ if ($newer_available) {
        print '  <link rel="next" href="'.$_newer_url.'">'."\n";
 }
 
-print_html_head_end($fh);
-print_html_body_start($fh);
+print_html_head_end(\*STDOUT);
+print_html_body_start(\*STDOUT);
 
 print '   <div id="inst" class="ins">'."\n";
 
@@ -481,7 +581,7 @@ if ($show_intf) {
        print '   <div id="framespace">'."\n";
        print '    <table id="intftable" cellspacing="0" cellpadding="0">'."\n";
        print '     <tr class="intf">'."\n";
-       print '      <td colspan="6" class="intf"><img src="'.$_intf_img.'.gif" alt="" class="intf"></td>'."\n";
+       print '      <td colspan="6" class="intf"><img src="'.$_intf_img.'" alt="" class="intf"></td>'."\n";
        print '     </tr>'."\n";
        
        print '     <tr class="intf">'."\n";
@@ -533,184 +633,184 @@ print '   </div>'."\n";
 print_html_body_end(\*STDOUT);
 print_html_end(\*STDOUT);
 
-sub writeindex {
-       (my $indexpath, my $pass, my $mode, my $pause) = @_;
-       my $indexfile;
-       my $indexof;
+sub writeindex {
+       (my $indexpath, my $pass, my $mode, my $pause) = @_;
+       my $indexfile;
+       my $indexof;
                
-       if(ref($indexpath)) {
-               $indexfile=$indexpath;
-               unless (seek($indexfile, 0, 0)) {
-                       return 0;
-               }
-       }
-       else {
-               unless (open ($indexfile, ">", $indexpath)) {
-                       return 0;
-               }
-       }
+       if(ref($indexpath)) {
+               $indexfile=$indexpath;
+               unless (seek($indexfile, 0, 0)) {
+                       return 0;
+               }
+       }
+       else {
+               unless (open ($indexfile, ">", $indexpath)) {
+                       return 0;
+               }
+       }
        
-       $indexof = CGI_PATH;
-       $indexof =~ s/\/$//g;
+       $indexof = CGI_PATH;
+       $indexof =~ s/\/$//g;
        
-       my %coin = readdatafile(DATA_COIN_PATH);
+       my %coin = readdatafile(DATA_COIN_PATH);
        
-       if ($pass != 1) {
-               print $indexfile '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'."\n";
-               print $indexfile '<html>'."\n";
-               print $indexfile ' <head>'."\n";
-               print $indexfile '  <title>Index of '.$indexof.'</title>'."\n";
-               print $indexfile ' </head>'."\n";
-               print $indexfile ' <body>'."\n";
-               print $indexfile '<h1>Index of '.$indexof.'</h1>'."\n";
-               print $indexfile '<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr>'."\n";
-               print $indexfile '<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td><td><a href="/">Parent Directory</a></td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>'."\n";
-               print $indexfile '<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="2words/">2words/</a></td><td align="right">'.INTF_DATE.'  </td><td align="right">  - </td><td>&nbsp;</td></tr>'."\n";
-               print $indexfile '<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="coin/">coin/</a></td><td align="right">'.COIN_DATE.'  </td><td align="right">  - </td><td> Coincidence </td></tr>'."\n";
-               print $indexfile '<tr><th colspan="5"><hr></th></tr>'."\n";
-               print $indexfile '</table>'."\n";
-               print $indexfile '<address>Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80</address>'."\n";
-               print $indexfile '</body></html>'."\n";
-       }
-       else {
-               my %framedata;
-               my %nextframedata;
-               my %default;
+       if ($pass != 1) {
+               print $indexfile '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'."\n";
+               print $indexfile '<html>'."\n";
+               print $indexfile ' <head>'."\n";
+               print $indexfile '  <title>Index of '.$indexof.'</title>'."\n";
+               print $indexfile ' </head>'."\n";
+               print $indexfile ' <body>'."\n";
+               print $indexfile '<h1>Index of '.$indexof.'</h1>'."\n";
+               print $indexfile '<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr>'."\n";
+               print $indexfile '<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td><td><a href="/">Parent Directory</a></td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>'."\n";
+               print $indexfile '<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="2words/">2words/</a></td><td align="right">'.INTF_DATE.'  </td><td align="right">  - </td><td>&nbsp;</td></tr>'."\n";
+               print $indexfile '<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="coin/">coin/</a></td><td align="right">'.COIN_DATE.'  </td><td align="right">  - </td><td> Coincidence </td></tr>'."\n";
+               print $indexfile '<tr><th colspan="5"><hr></th></tr>'."\n";
+               print $indexfile '</table>'."\n";
+               print $indexfile '<address>Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80</address>'."\n";
+               print $indexfile '</body></html>'."\n";
+       }
+       else {
+               my %framedata;
+               my %nextframedata;
+               my %default;
                
-               %framedata = readdatafile(DATA_PATH.0);
-               %nextframedata = readdatafile(DATA_PATH.1);
-               %default=readdatafile(DATA_DEFAULT_PATH);
+               %framedata = readdatafile(DATA_PATH.0);
+               %nextframedata = readdatafile(DATA_PATH.1);
+               %default=readdatafile(DATA_DEFAULT_PATH);
                
-               # if($mode == 16 && $pause) {
-                       # $framedata{'ongtime'} = $time;
-                       # writedatafile(DATA_PATH.0,%framedata);
-               # }
+               # if($mode == 16 && $pause) {
+                       # $framedata{'ongtime'} = $time;
+                       # writedatafile(DATA_PATH.0,%framedata);
+               # }
                
-               foreach my $ind (keys %default) {
-                       unless(defined($framedata{$ind})){
-                               $framedata{$ind}=$default{$ind};
-                       }
-                       unless(defined($nextframedata{$ind})){
-                               $nextframedata{$ind}=$default{$ind};
-                       }
-               }
+               foreach my $ind (keys %default) {
+                       unless(defined($framedata{$ind})){
+                               $framedata{$ind}=$default{$ind};
+                       }
+                       unless(defined($nextframedata{$ind})){
+                               $nextframedata{$ind}=$default{$ind};
+                       }
+               }
                
                
-               print $indexfile '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">'."\n";
-               print $indexfile '<html lang="en"><head>'."\n";
-               print $indexfile '<title>';
-               if($mode == 8 || $mode == 4) {
-                       print $indexfile 'Index of';
-               }
-               elsif($mode == 16) {
-                       print $indexfile entityencode($settings{'story'});
-                       if($pause) {
-                               print $indexfile ' &bull; '.WEBSITE_NAME;
-                       }
-               }
-               else {
-                       print $indexfile 'Index of '.$indexof;
-               }
-               print $indexfile '</title>'."\n";
-               print $indexfile '<meta http-equiv="Content-type" content="text/html; charset=UTF-8">'."\n";
-               print $indexfile '<link rel="icon" type="image/png" href="'.FAVICON_PATH.'">'."\n";
-               print $indexfile '<link rel="stylesheet" href="'.CGI_CSS_PATH.'">'."\n";
-               print $indexfile '</head><body>'."\n";
-               print $indexfile '<a href="/"><img id="botmlogo" src="'.CGI_LOGO_PATH.'" alt="'.WEBSITE.'"></a>'."\n";
-               print $indexfile '<div id="all">'."\n";
+               print $indexfile '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">'."\n";
+               print $indexfile '<html lang="en"><head>'."\n";
+               print $indexfile '<title>';
+               if($mode == 8 || $mode == 4) {
+                       print $indexfile 'Index of';
+               }
+               elsif($mode == 16) {
+                       print $indexfile entityencode($settings{'story'});
+                       if($pause) {
+                               print $indexfile ' &bull; '.WEBSITE_NAME;
+                       }
+               }
+               else {
+                       print $indexfile 'Index of '.$indexof;
+               }
+               print $indexfile '</title>'."\n";
+               print $indexfile '<meta http-equiv="Content-type" content="text/html; charset=UTF-8">'."\n";
+               print $indexfile '<link rel="icon" type="image/png" href="'.FAVICON_PATH.'">'."\n";
+               print $indexfile '<link rel="stylesheet" href="'.CGI_CSS_PATH.'">'."\n";
+               print $indexfile '</head><body>'."\n";
+               print $indexfile '<a href="/"><img id="botmlogo" src="'.CGI_LOGO_PATH.'" alt="'.WEBSITE.'"></a>'."\n";
+               print $indexfile '<div id="all">'."\n";
                
-               print $indexfile '<div id="inst" class="ins">'."\n";
+               print $indexfile '<div id="inst" class="ins">'."\n";
                
-               print $indexfile '<div id="title">'."\n";
-               print $indexfile '<H1 id="titletext">';
-               if($mode == 8 || $mode == 4) {
-                       print $indexfile 'Index of';
-               }
-               elsif($mode == 16) {
-                       print $indexfile entityencode($settings{'story'});
-               }
-               else {
-                       print $indexfile 'Index of '.$indexof;
-               }
-               print $indexfile '</H1>'."\n";
-               print $indexfile '</div>'."\n";
+               print $indexfile '<div id="title">'."\n";
+               print $indexfile '<H1 id="titletext">';
+               if($mode == 8 || $mode == 4) {
+                       print $indexfile 'Index of';
+               }
+               elsif($mode == 16) {
+                       print $indexfile entityencode($settings{'story'});
+               }
+               else {
+                       print $indexfile 'Index of '.$indexof;
+               }
+               print $indexfile '</H1>'."\n";
+               print $indexfile '</div>'."\n";
                
-               print $indexfile '</div><div id="framespace">'."\n";
-               print $indexfile '<img src="'.CGI_PATH;
-               if($mode == 8) {
-                       print $indexfile 'intf-ll.gif'
-               }
-               elsif($mode == 4) {
-                       print $indexfile 'intf-pp.gif'
-               }
-               elsif($mode == 16) {
-                       if($pause) {
-                               print $indexfile sprintf($settings{'frame'},0,$framedata{'ext'}).'" title="'.entityencode($framedata{'title'});
-                       }
-                       else {
-                               print $indexfile 'intf-tr.gif'
-                       }
-               }
-               else {
-                       print $indexfile 'intf-kw.gif'
-               }
-               print $indexfile '" alt="0" id="frame">'."\n";
+               print $indexfile '</div><div id="framespace">'."\n";
+               print $indexfile '<img src="'.CGI_PATH;
+               if($mode == 8) {
+                       print $indexfile 'intf-ll.gif'
+               }
+               elsif($mode == 4) {
+                       print $indexfile 'intf-pp.gif'
+               }
+               elsif($mode == 16) {
+                       if($pause) {
+                               print $indexfile sprintf($settings{'frame'},0,$framedata{'ext'}).'" title="'.entityencode($framedata{'title'});
+                       }
+                       else {
+                               print $indexfile 'intf-tr.gif'
+                       }
+               }
+               else {
+                       print $indexfile 'intf-kw.gif'
+               }
+               print $indexfile '" alt="0" id="frame">'."\n";
                
-               print $indexfile '</div><div id="insb" class="ins">'."\n";
-               print $indexfile '<div id="undertext">'."\n";
-               if($mode == 8 || $mode == 4) {
-                       print $indexfile '<img src="/icons/back.gif" alt="[DIR]"> <a href="/">Parent Directory</a><br><img src="/icons/folder.gif" alt="[DIR]"> <a href="#">yyyyb/</a>'."\n";
-               }
-               elsif ($mode == 16) {
-                       if($pause) {
-                               print $indexfile bb2ht($framedata{'content'})."\n";
-                       }
-                       else {
-                               print $indexfile "...\n";
-                       }
-               }
-               else {
-                       print $indexfile '<img src="/icons/back.gif" alt="[DIR]"> <a href="/">Parent Directory</a><br>'."\n";
-                       print $indexfile '<img src="/icons/folder.gif" alt="[DIR]"> <a href="2words/">2words/</a> '.INTF_DATE.' - <br>'."\n";
-                       print $indexfile '<img src="/icons/folder.gif" alt="[DIR]"> <a href="coin/">coin/</a> '.COIN_DATE.' - '.entityencode($coin{'server'})."\n";
-               }
-               print $indexfile '</div>'."\n";
+               print $indexfile '</div><div id="insb" class="ins">'."\n";
+               print $indexfile '<div id="undertext">'."\n";
+               if($mode == 8 || $mode == 4) {
+                       print $indexfile '<img src="/icons/back.gif" alt="[DIR]"> <a href="/">Parent Directory</a><br><img src="/icons/folder.gif" alt="[DIR]"> <a href="#">yyyyb/</a>'."\n";
+               }
+               elsif ($mode == 16) {
+                       if($pause) {
+                               print $indexfile bb2ht($framedata{'content'})."\n";
+                       }
+                       else {
+                               print $indexfile "...\n";
+                       }
+               }
+               else {
+                       print $indexfile '<img src="/icons/back.gif" alt="[DIR]"> <a href="/">Parent Directory</a><br>'."\n";
+                       print $indexfile '<img src="/icons/folder.gif" alt="[DIR]"> <a href="2words/">2words/</a> '.INTF_DATE.' - <br>'."\n";
+                       print $indexfile '<img src="/icons/folder.gif" alt="[DIR]"> <a href="coin/">coin/</a> '.COIN_DATE.' - '.entityencode($coin{'server'})."\n";
+               }
+               print $indexfile '</div>'."\n";
                
-               print $indexfile '<div id="command">'."\n";
-               if ($mode == 8) {
-                       print $indexfile '[<span class="br">EE</span>:<span class="br">EE</span>:<span class="br">EE</span>]'."\n";
-               }
-               elsif ($mode == 4) {
-                       print $indexfile '[<span class="ni">EE</span>:<span class="ni">EE</span>:<span class="ni">EE</span>]'."\n";
-               }
-               elsif ($mode == 16) {
-                       if($pause) {
-                               print $indexfile '[<span class="br">00</span>:<span class="br">00</span>:<span class="br">00</span>]<br>'."\n";
-                               print $indexfile '&gt;<a href="'.CGI_VIEWER_PATH.'/1">'.entityencode($nextframedata{'title'}).'</a>'."\n";
-                       }
-                       else {
-                               print $indexfile '[<span class="ni">--</span>:<span class="ni">--</span>:<span class="ni">--</span>]<br>'."\n";
-                               print $indexfile '&gt;...<span class="inp">_</span>'."\n";
-                       }
-               }
-               else {
-               }
-               print $indexfile '</div>'."\n";
+               print $indexfile '<div id="command">'."\n";
+               if ($mode == 8) {
+                       print $indexfile '[<span class="br">EE</span>:<span class="br">EE</span>:<span class="br">EE</span>]'."\n";
+               }
+               elsif ($mode == 4) {
+                       print $indexfile '[<span class="ni">EE</span>:<span class="ni">EE</span>:<span class="ni">EE</span>]'."\n";
+               }
+               elsif ($mode == 16) {
+                       if($pause) {
+                               print $indexfile '[<span class="br">00</span>:<span class="br">00</span>:<span class="br">00</span>]<br>'."\n";
+                               print $indexfile '&gt;<a href="'.CGI_VIEWER_PATH.'/1">'.entityencode($nextframedata{'title'}).'</a>'."\n";
+                       }
+                       else {
+                               print $indexfile '[<span class="ni">--</span>:<span class="ni">--</span>:<span class="ni">--</span>]<br>'."\n";
+                               print $indexfile '&gt;...<span class="inp">_</span>'."\n";
+                       }
+               }
+               else {
+               }
+               print $indexfile '</div>'."\n";
                
-               print $indexfile '</div>'."\n";
+               print $indexfile '</div>'."\n";
                
-               print $indexfile '</div>'."\n";
-               print $indexfile '<a href="/" class="cz">'.WEBSITE.'</a>'."\n";
+               print $indexfile '</div>'."\n";
+               print $indexfile '<a href="/" class="cz">'.WEBSITE.'</a>'."\n";
                
-               print $indexfile '</body></html>'."\n";
-       }
+               print $indexfile '</body></html>'."\n";
+       }
        
-       unless (ref($indexpath)) {
-               close ($indexfile);
-       }
-       else {
-               truncate ($indexfile , tell($indexfile));
-       }
+       unless (ref($indexpath)) {
+               close ($indexfile);
+       }
+       else {
+               truncate ($indexfile , tell($indexfile));
+       }
        
-       return 1;
-}
+       return 1;
+}
index dca0f2b9cc42433ef0f9bf5b0d7d8b0a8f6fce43..9a09107fdff2fa2ca6747de5185df3e442e21666 160000 (submodule)
@@ -1 +1 @@
-Subproject commit dca0f2b9cc42433ef0f9bf5b0d7d8b0a8f6fce43
+Subproject commit 9a09107fdff2fa2ca6747de5185df3e442e21666
index 7ae11838834d7383c7213ac0bcf7f89e566f5223..1c19400603f5c0b256464b63645b78414f74e6ec 100644 (file)
@@ -40,6 +40,9 @@ our @EXPORT_OK   = (
        'failpage', 'fail_method', 'fail_content_type',
        'get_remote_addr', 'get_frame', 'get_password',
        'merge_settings',
+       'print_html_start', 'print_html_end',
+       'print_html_head_start', 'print_html_head_end',
+       'print_html_body_start', 'print_html_body_end',
        'print_viewer_page',
        'write_index',
        
@@ -67,7 +70,9 @@ use botm_common (
 ###PERL_PATH_SEPARATOR:     PATH_SEPARATOR     = /
 
 ###PERL_CGI_PATH:           CGI_PATH           = /bsta/
+###PERL_CGI_2WORDS_PATH:    CGI_2WORDS_PATH    = /bsta/2words
 ###PERL_CGI_BBCODE_PATH:    CGI_BBCODE_PATH    = /bsta/b
+###PERL_CGI_COIN_PATH:      CGI_COIN_PATH      = /bsta/coin
 ###PERL_CGI_CSS_PATH:       CGI_CSS_PATH       = /bsta/bsta.css
 ###PERL_CGI_FRAME_PATH:     CGI_FRAME_PATH     = /bsta/f
 ###PERL_CGI_GOTO_PATH:      CGI_GOTO_PATH      = /bsta/g
@@ -77,6 +82,7 @@ use botm_common (
 ###PERL_CGI_VIEWER_PATH:    CGI_VIEWER_PATH    = /bsta/v
 
 ###PERL_DATA_PATH:          DATA_PATH          = /botm/data/bsta/
+###PERL_DATA_COIN_PATH:     DATA_COIN_PATH     = /botm/data/bsta/coincidence
 ###PERL_DATA_DEFAULT_PATH:  DATA_DEFAULT_PATH  = /botm/data/bsta/default
 
 ###PERL_WWW_INDEX_PATH:     WWW_INDEX_PATH     = /botm/www/1190/bsta/index.htm
@@ -86,6 +92,8 @@ use botm_common (
 ###PERL_WEBSITE_NAME:       WEBSITE_NAME       = Bicycles on the Moon
 ###PERL_FAVICON_PATH:       FAVICON_PATH       = /img/favicon.png
 
+###PERL_COIN_DATE:          COIN_DATE          = 13-Nov-2016 22:15
+###PERL_INTF_DATE:          INTF_DATE          = 28-Sep-2016 20:34
 
 use constant STATE => {
        'inactive' => 0,
@@ -870,7 +878,10 @@ sub print_viewer_page {
        my $timer_h;
        my $timer_m;
        my $timer_s;
-       if ($timer > 0) {
+       if (
+               ($timer > 0) ||
+               (($timer >= 0) && ($frame == 0))
+       ) {
                $timer_s = sprintf('%02d', $timer % 60);
                $timer_h = int($timer / 60);
                $timer_m = sprintf('%02d', $timer_h % 60);
@@ -897,9 +908,15 @@ sub print_viewer_page {
                )
        );
        my $show_timer = (
-               ($frame == $last_frame) && (
-                       ($ong_state == STATE->{'waiting'}) ||
-                       ($ong_state == STATE->{'ready'})
+               (
+                       $access &&
+                       ($ong_state == STATE->{'inactive'}) &&
+                       ($frame == 0)
+               ) || (
+                       ($frame == $last_frame) && (
+                               ($ong_state == STATE->{'waiting'}) ||
+                               ($ong_state == STATE->{'ready'})
+                       )
                )
        );
        my $show_command = (
@@ -1206,17 +1223,18 @@ sub write_index {
                my $settings,
                my $pass,
                my $mode,
-               my $index
+               my $pause
        ) = @_;
        my $fh;
-       my $r;
+       my $r = 1;
+       my $ong_state = int($state->{'state'});
        
        unless (open ($fh, ">:encoding(UTF-8)", encode('locale_fs', WWW_INDEX_PATH()))) {
                return 0;
        }
        
        # normal running story
-       if ($state > STATE->{'inactive'}) {
+       if ($ong_state > STATE->{'inactive'}) {
                my %frame_data     = read_data_file(join_path(PATH_SEPARATOR(), DATA_PATH(), 0));
                my %next_frame_data= read_data_file(join_path(PATH_SEPARATOR(), DATA_PATH(), 1));
                my %default        = read_data_file(DATA_DEFAULT_PATH());
@@ -1246,8 +1264,10 @@ sub write_index {
                my $index_of = CGI_PATH;
                $index_of =~ s/\/$//g;
                
-               my $_index_of = html_entity_encode_dec($index_of, 1);
-               
+               my $_index_of     = html_entity_encode_dec($index_of  , 1);
+               my $_2words_date  = html_entity_encode_dec(INTF_DATE(), 1);
+               my $_coin_date    = html_entity_encode_dec(COIN_DATE(), 1);
+               my $_website      = html_entity_encode_dec(WEBSITE()  , 1);
                
                print_html_start ($fh);
                print $fh ' <head>'."\n";
@@ -1274,23 +1294,162 @@ sub write_index {
                print $fh '   </tr><tr>'."\n";
                print $fh '    <td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td>'."\n";
                print $fh '    <td><a href="2words/">2words/</a></td>'."\n";
-               print $fh '    <td align="right">'.INTF_DATE.'  </td>'."\n";
+               print $fh '    <td align="right">'.$_2words_date.'  </td>'."\n";
                print $fh '    <td align="right">  - </td><td>&nbsp;</td>'."\n";
                print $fh '   </tr><tr>'."\n";
                print $fh '    <td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td>'."\n";
                print $fh '    <td><a href="coin/">coin/</a></td>'."\n";
-               print $fh '    <td align="right">'.COIN_DATE.'  </td>'."\n";
+               print $fh '    <td align="right">'.$_coin_date.'  </td>'."\n";
                print $fh '    <td align="right">  - </td><td> Coincidence </td>'."\n";
                print $fh '   </tr><tr>'."\n";
                print $fh '    <th colspan="5"><hr></th>'."\n";
                print $fh '   </tr>'."\n";
                print $fh '  </table>'."\n";
-               print $fh '  <address>Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80</address>'."\n";
+               print $fh '  <address>Apache/2.2.22 (Debian) Server at '.$_website.' Port 80</address>'."\n";
                print $fh '  /body>'."\n";
                print_html_end ($fh);
        }
+       # the launch index
        else {
+               my %frame_data     = read_data_file(join_path(PATH_SEPARATOR(), DATA_PATH(), 0));
+               my %next_frame_data= read_data_file(join_path(PATH_SEPARATOR(), DATA_PATH(), 1));
+               my %default        = read_data_file(DATA_DEFAULT_PATH());
+               my %coin_data      = read_data_file(DATA_COIN_PATH());
+               
+               %frame_data     = merge_settings(\%default,      \%frame_data);
+               %next_frame_data= merge_settings(\%default, \%next_frame_data);
+               
+               if (($mode == INTF_STATE->{'>'}) && $pause) {
+                       $r = print_viewer_page(
+                               $fh,
+                               {
+                                       'frame' => 0,
+                                       'access' => 1,
+                                       'password_ok' => 0,
+                                       'timer_unlocked' => 3,
+                                       'timer' => 0,
+                                       'static' => 1,
+                                       'show_command' => 1
+                               },
+                               $state,
+                               $settings,
+                               \%frame_data,
+                               \%next_frame_data
+                       );
+                       return $r;
+               }
+               
+               my $index_of = CGI_PATH;
+               $index_of =~ s/\/$//g;
+               my $title;
+               my $frame_file;
+               my $undertext = '';
+               my $show_parent_dir = 0;
+               my $show_yb = 0;
+               my $show_folders = 0;
+               my $timer = '';
+               my $timer_color = 'ni';
+               if ($mode == INTF_STATE->{'>'}) {
+                       $title = $settings->{'story'}; # $frame_data{'title'} ?
+                       $frame_file = 'intf-tr.gif';
+                       $undertext = '...';
+                       $timer = '--';
+                       $timer_color = 'br';
+               }
+               elsif ($mode == INTF_STATE->{'<<'}) {
+                       $title = 'Index of';
+                       $frame_file = 'intf-ll.gif';
+                       $show_parent_dir = 1;
+                       $show_yb = 1;
+                       $timer = 'EE';
+               }
+               elsif ($mode == INTF_STATE->{'>>'}) {
+                       $title = 'Index of';
+                       $frame_file = 'intf-ll.gif';
+                       $show_parent_dir = 1;
+                       $show_yb = 1;
+                       $timer = 'EE';
+               }
+               else
+               {
+                       $title = 'Index of '.$index_of;
+                       $frame_file = 'intf-kw.gif';
+                       $show_parent_dir = 1;
+                       $show_folders = 1;
+               }
+               my $frame_url = merge_url(
+                       {'path' => CGI_PATH()},
+                       {'path' => $frame_file}
+               );
+               my $coin_server = $coin_data{'server'};
+               
+               my $_title        = html_entity_encode_dec($title           , 1);
+               my $_website_name = html_entity_encode_dec(WEBSITE_NAME()   , 1);
+               my $_frame_url    = html_entity_encode_dec($frame_url       , 1);
+               my $_undertext    = html_entity_encode_dec($undertext       , 1);
+               my $_2words_date  = html_entity_encode_dec(INTF_DATE()      , 1);
+               my $_coin_date    = html_entity_encode_dec(COIN_DATE()      , 1);
+               my $_coin_server  = html_entity_encode_dec($coin_server     , 1);
+               my $_2words_url   = html_entity_encode_dec(CGI_2WORDS_PATH(), 1);
+               my $_coin_url     = html_entity_encode_dec(CGI_COIN_PATH()  , 1);
+               
+               print_html_start($fh);
+               print_html_head_start($fh);
+               
+               print $fh '  <title>'.$_title.' $bull; '.$_website_name.'</title>'."\n";
+               
+               print_html_head_end($fh);
+               print_html_body_start($fh);
+               
+               print $fh '   <div id="inst" class="ins">'."\n";
+               
+               print $fh '    <div id="title">'."\n";
+               print $fh '     <h1 id="titletext">'.$_title.'</h1>'."\n";
+               print $fh '    </div>'."\n";
+               
+               print $fh '   </div>'."\n";
+               print $fh '   <div id="framespace">'."\n";
+               
+               print $fh '    <img src="'.$_frame_url.'" id="frame" alt="0">'."\n"; # title="'.$_title.'"
+               
+               print $fh '   </div>'."\n";
+               print $fh '   <div id="insb" class="ins">'."\n";
+               
+               print $fh '    <div id="undertext">'."\n";
+               
+               if ($show_parent_dir) {
+                       print $fh '     <img src="/icons/back.gif" alt="[DIR]"> <a href="..">Parent Directory</a><br>'."\n";
+               }
+               if ($show_folders) {
+                       print $fh '     <img src="/icons/folder.gif" alt="[DIR]"> <a href="'.$_2words_url.'">2words/</a> '.$_2words_date.' - <br>'."\n";
+                       print $fh '     <img src="/icons/folder.gif" alt="[DIR]"> <a href="'.$_coin_url.'">coin/</a> '.$_coin_date.' - '.$_coin_server."\n";
+               }
+               elsif ($show_yb) {
+                       print $fh '     <img src="/icons/folder.gif" alt="[DIR]"> <a href="#">yyyyb/</a>'."\n";
+               }
+               if ($undertext ne '') {
+                       print $fh '     '.$_undertext."\n";
+               }
+               
+               print $fh '    </div>'."\n";
+               
+               if ($timer ne '') {
+                       print $fh '    <div id="command">'."\n";
+                       
+                       print $fh '     [<span id="ongh" class="'.$timer_color.'">'.$timer.'</span>';
+                       print $fh      ':<span id="ongm" class="'.$timer_color.'">'.$timer.'</span>';
+                       print $fh      ':<span id="ongs" class="'.$timer_color.'">'.$timer.'</span>]<br>'."\n";
+                       
+                       if ($undertext ne '') {
+                               print $fh '&gt;'.$_undertext.'<span class="inp">_</span>'."\n";
+                       }
+                       print $fh "    </div>\n";
+               }
+               
+               print $fh "   </div>\n";
                
+               print_html_body_end($fh);
+               print_html_end($fh);
        }
        close ($fh);
        return $r
index 7645c47039c92b495ef093accb70aa9172f34e0d..2541bd789da46b678203c671c13074553b5bf20d 100644 (file)
@@ -31,6 +31,7 @@ use bsta_lib qw(failpage gethttpheader getcgi readdatafile);
 ###PERL_DATA_NOACCESS_PATH: DATA_NOACCESS_PATH = /botm/data/bsta/noaccess
 ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/settings
 ###PERL_DATA_STATE_PATH:    DATA_STATE_PATH    = /botm/data/bsta/state
+###PERL_DATA_STORY_PATH:    DATA_STORY_PATH    = /botm/data/bsta/story
 
 my %http;
 my %cgi;
@@ -120,10 +121,13 @@ if ($passwordOK || (int($state{'state'}) >= 1 && $frame <= int($state{'last'}) &
 }
 else {
        $access=0;
-       %framedata = readdatafile(DATA_NOACCESS_PATH);
-       foreach my $ind (keys %default) {
-               unless(defined($framedata{$ind})){
-                       $framedata{$ind}=$default{$ind};
+       if(int($state{'state'}) == 0) {
+               my %story=readdatafile(DATA_STORY_PATH);
+               if (
+                       (int($story{'pass'}) == 1) &&
+                       (int($story{'state'}) == 17)
+               ) {
+                       $access = 1;
                }
        }
 }
@@ -132,6 +136,12 @@ if($access){
        $framepath=DATA_PATH.sprintf($settings{'frame'},$frame,$framedata{'ext'});
 }
 else {
+       %framedata = readdatafile(DATA_NOACCESS_PATH);
+       foreach my $ind (keys %default) {
+               unless(defined($framedata{$ind})){
+                       $framedata{$ind}=$default{$ind};
+               }
+       }
        $framepath=DATA_PATH.$framedata{'frame'};
 }
 
index 68db13cb3e6fc4f3974d866b8f11c1c962f0e8b8..9205be6ddab2a9227aaea22991ad98153b6db3da 100644 (file)
@@ -33,7 +33,7 @@ use botm_common (
        'join_path'
 );
 use bsta_lib (
-       'STATE', 'TEXT_MODE', 'INFT_STATE',
+       'STATE', 'TEXT_MODE', 'INTF_STATE',
        'fail_method', 'fail_content_type',
        'get_remote_addr', 'get_frame', 'get_password',
        'merge_settings',