From: b Date: Fri, 29 Dec 2023 03:08:20 +0000 (+0000) Subject: finished generating index & 2words bugfix X-Git-Tag: v1.1.0~23 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=c950433e323a20209086fd5f067a716fd8ff678c;p=ott%2Fbsta finished generating index & 2words bugfix --- diff --git a/2words.1.pl b/2words.1.pl index 9649b76..186e31a 100644 --- a/2words.1.pl +++ b/2words.1.pl @@ -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 ' '."\n"; } -print_html_head_end($fh); -print_html_body_start($fh); +print_html_head_end(\*STDOUT); +print_html_body_start(\*STDOUT); print '
'."\n"; @@ -481,7 +581,7 @@ if ($show_intf) { print '
'."\n"; print ' '."\n"; print ' '."\n"; - print ' '."\n"; + print ' '."\n"; print ' '."\n"; print ' '."\n"; @@ -533,184 +633,184 @@ print ' '."\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 ''."\n"; - print $indexfile ''."\n"; - print $indexfile ' '."\n"; - print $indexfile ' Index of '.$indexof.''."\n"; - print $indexfile ' '."\n"; - print $indexfile ' '."\n"; - print $indexfile '

Index of '.$indexof.'

'."\n"; - print $indexfile '
'."\n"; - print $indexfile ''."\n"; - print $indexfile ''."\n"; - print $indexfile ''."\n"; - print $indexfile ''."\n"; - print $indexfile '
[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[DIR]2words/'.INTF_DATE.' -  
[DIR]coin/'.COIN_DATE.' - Coincidence

'."\n"; - print $indexfile '
Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80
'."\n"; - print $indexfile ''."\n"; - } - else { - my %framedata; - my %nextframedata; - my %default; + # if ($pass != 1) { + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ' '."\n"; + # print $indexfile ' Index of '.$indexof.''."\n"; + # print $indexfile ' '."\n"; + # print $indexfile ' '."\n"; + # print $indexfile '

Index of '.$indexof.'

'."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile '
[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[DIR]2words/'.INTF_DATE.' -  
[DIR]coin/'.COIN_DATE.' - Coincidence

'."\n"; + # print $indexfile '
Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80
'."\n"; + # print $indexfile ''."\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 ''."\n"; - print $indexfile ''."\n"; - print $indexfile ''; - if($mode == 8 || $mode == 4) { - print $indexfile 'Index of'; - } - elsif($mode == 16) { - print $indexfile entityencode($settings{'story'}); - if($pause) { - print $indexfile ' • '.WEBSITE_NAME; - } - } - else { - print $indexfile 'Index of '.$indexof; - } - print $indexfile ''."\n"; - print $indexfile ''."\n"; - print $indexfile ''."\n"; - print $indexfile ''."\n"; - print $indexfile ''."\n"; - print $indexfile ''."\n"; - print $indexfile '
'."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''; + # if($mode == 8 || $mode == 4) { + # print $indexfile 'Index of'; + # } + # elsif($mode == 16) { + # print $indexfile entityencode($settings{'story'}); + # if($pause) { + # print $indexfile ' • '.WEBSITE_NAME; + # } + # } + # else { + # print $indexfile 'Index of '.$indexof; + # } + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile ''."\n"; + # print $indexfile '
'."\n"; - print $indexfile '
'."\n"; + # print $indexfile '
'."\n"; - print $indexfile '
'."\n"; - print $indexfile '

'; - 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 '

'."\n"; - print $indexfile '
'."\n"; + # print $indexfile '
'."\n"; + # print $indexfile '

'; + # 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 '

'."\n"; + # print $indexfile '
'."\n"; - print $indexfile '
'."\n"; - print $indexfile '0'."\n"; + # print $indexfile '
'."\n"; + # print $indexfile '0'."\n"; - print $indexfile '
'."\n"; - print $indexfile '
'."\n"; - if($mode == 8 || $mode == 4) { - print $indexfile '[DIR] Parent Directory
[DIR] yyyyb/'."\n"; - } - elsif ($mode == 16) { - if($pause) { - print $indexfile bb2ht($framedata{'content'})."\n"; - } - else { - print $indexfile "...\n"; - } - } - else { - print $indexfile '[DIR] Parent Directory
'."\n"; - print $indexfile '[DIR] 2words/ '.INTF_DATE.' -
'."\n"; - print $indexfile '[DIR] coin/ '.COIN_DATE.' - '.entityencode($coin{'server'})."\n"; - } - print $indexfile '
'."\n"; + # print $indexfile '
'."\n"; + # print $indexfile '
'."\n"; + # if($mode == 8 || $mode == 4) { + # print $indexfile '[DIR] Parent Directory
[DIR] yyyyb/'."\n"; + # } + # elsif ($mode == 16) { + # if($pause) { + # print $indexfile bb2ht($framedata{'content'})."\n"; + # } + # else { + # print $indexfile "...\n"; + # } + # } + # else { + # print $indexfile '[DIR] Parent Directory
'."\n"; + # print $indexfile '[DIR] 2words/ '.INTF_DATE.' -
'."\n"; + # print $indexfile '[DIR] coin/ '.COIN_DATE.' - '.entityencode($coin{'server'})."\n"; + # } + # print $indexfile '
'."\n"; - print $indexfile '
'."\n"; - if ($mode == 8) { - print $indexfile '[EE:EE:EE]'."\n"; - } - elsif ($mode == 4) { - print $indexfile '[EE:EE:EE]'."\n"; - } - elsif ($mode == 16) { - if($pause) { - print $indexfile '[00:00:00]
'."\n"; - print $indexfile '>'.entityencode($nextframedata{'title'}).''."\n"; - } - else { - print $indexfile '[--:--:--]
'."\n"; - print $indexfile '>..._'."\n"; - } - } - else { - } - print $indexfile '
'."\n"; + # print $indexfile '
'."\n"; + # if ($mode == 8) { + # print $indexfile '[EE:EE:EE]'."\n"; + # } + # elsif ($mode == 4) { + # print $indexfile '[EE:EE:EE]'."\n"; + # } + # elsif ($mode == 16) { + # if($pause) { + # print $indexfile '[00:00:00]
'."\n"; + # print $indexfile '>'.entityencode($nextframedata{'title'}).''."\n"; + # } + # else { + # print $indexfile '[--:--:--]
'."\n"; + # print $indexfile '>..._'."\n"; + # } + # } + # else { + # } + # print $indexfile '
'."\n"; - print $indexfile '
'."\n"; + # print $indexfile '
'."\n"; - print $indexfile '
'."\n"; - print $indexfile ''.WEBSITE.''."\n"; + # print $indexfile '
'."\n"; + # print $indexfile ''.WEBSITE.''."\n"; - print $indexfile ''."\n"; - } + # print $indexfile ''."\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; +# } diff --git a/botm-common b/botm-common index dca0f2b..9a09107 160000 --- a/botm-common +++ b/botm-common @@ -1 +1 @@ -Subproject commit dca0f2b9cc42433ef0f9bf5b0d7d8b0a8f6fce43 +Subproject commit 9a09107fdff2fa2ca6747de5185df3e442e21666 diff --git a/bsta_lib.1.pm b/bsta_lib.1.pm index 7ae1183..1c19400 100644 --- a/bsta_lib.1.pm +++ b/bsta_lib.1.pm @@ -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 ' '."\n"; @@ -1274,23 +1294,162 @@ sub write_index { print $fh ' '."\n"; print $fh ' [DIR]'."\n"; print $fh ' 2words/'."\n"; - print $fh ' '.INTF_DATE.' '."\n"; + print $fh ' '.$_2words_date.' '."\n"; print $fh ' -  '."\n"; print $fh ' '."\n"; print $fh ' [DIR]'."\n"; print $fh ' coin/'."\n"; - print $fh ' '.COIN_DATE.' '."\n"; + print $fh ' '.$_coin_date.' '."\n"; print $fh ' - Coincidence '."\n"; print $fh ' '."\n"; print $fh '
'."\n"; print $fh ' '."\n"; print $fh ' '."\n"; - print $fh '
Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80
'."\n"; + print $fh '
Apache/2.2.22 (Debian) Server at '.$_website.' Port 80
'."\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.' $bull; '.$_website_name.''."\n"; + + print_html_head_end($fh); + print_html_body_start($fh); + + print $fh '
'."\n"; + + print $fh '
'."\n"; + print $fh '

'.$_title.'

'."\n"; + print $fh '
'."\n"; + + print $fh '
'."\n"; + print $fh '
'."\n"; + + print $fh ' 0'."\n"; # title="'.$_title.'" + + print $fh '
'."\n"; + print $fh '
'."\n"; + + print $fh '
'."\n"; + + if ($show_parent_dir) { + print $fh ' [DIR] Parent Directory
'."\n"; + } + if ($show_folders) { + print $fh ' [DIR] 2words/ '.$_2words_date.' -
'."\n"; + print $fh ' [DIR] coin/ '.$_coin_date.' - '.$_coin_server."\n"; + } + elsif ($show_yb) { + print $fh ' [DIR] yyyyb/'."\n"; + } + if ($undertext ne '') { + print $fh ' '.$_undertext."\n"; + } + + print $fh '
'."\n"; + + if ($timer ne '') { + print $fh '
'."\n"; + + print $fh ' ['.$timer.''; + print $fh ':'.$timer.''; + print $fh ':'.$timer.']
'."\n"; + + if ($undertext ne '') { + print $fh '>'.$_undertext.'_'."\n"; + } + print $fh "
\n"; + } + + print $fh "
\n"; + print_html_body_end($fh); + print_html_end($fh); } close ($fh); return $r diff --git a/frame.1.pl b/frame.1.pl index 7645c47..2541bd7 100644 --- a/frame.1.pl +++ b/frame.1.pl @@ -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'}; } diff --git a/viewer.1.pl b/viewer.1.pl index 68db13c..9205be6 100644 --- a/viewer.1.pl +++ b/viewer.1.pl @@ -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',