From a152c4e7e4c15be60d9d5118db2a83199fb6dbaf Mon Sep 17 00:00:00 2001 From: b Date: Thu, 9 Nov 2023 22:50:02 +0000 Subject: [PATCH] generating fake index --- bsta_lib.1.pm | 74 ++++++++++++++++++++++++++++++++++++++++++++++----- viewer.1.pl | 2 +- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/bsta_lib.1.pm b/bsta_lib.1.pm index 50eea1a..7ae1183 100644 --- a/bsta_lib.1.pm +++ b/bsta_lib.1.pm @@ -407,7 +407,8 @@ sub urlencode { # to consider: # a BBcode library? -#analyse bbcode text to build tag tree #TODO make [/*] optional! +#analyse bbcode text to build tag tree +#TODO make [/*] optional! sub bbtree { (my $bb, my $printdebug) = @_; my %bbtree; @@ -1201,12 +1202,21 @@ sub print_viewer_page { sub write_index { ( - my $mode, my $state, - my $settings + my $settings, + my $pass, + my $mode, + my $index ) = @_; + my $fh; + my $r; + + unless (open ($fh, ">:encoding(UTF-8)", encode('locale_fs', WWW_INDEX_PATH()))) { + return 0; + } - if ($mode eq 'viewer') { + # normal running story + if ($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()); @@ -1214,8 +1224,8 @@ sub write_index { %frame_data = merge_settings(\%default, \%frame_data); %next_frame_data= merge_settings(\%default, \%next_frame_data); - print_viewer_page( - WWW_INDEX_PATH(), + $r = print_viewer_page( + $fh, { 'frame' => 0, 'access' => 1, @@ -1231,9 +1241,59 @@ sub write_index { \%next_frame_data ); } + # no conditions met, pretend a normal Apache2 index + elsif ($pass != 1) { + my $index_of = CGI_PATH; + $index_of =~ s/\/$//g; + + my $_index_of = html_entity_encode_dec($index_of, 1); + + + print_html_start ($fh); + print $fh ' '."\n"; + print $fh ' '."\n"; + print $fh ' Index of '.$_index_of.''."\n"; + print $fh ' '."\n"; + print $fh ' '."\n"; + print $fh '

Index of '.$_index_of.'

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

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

'."\n"; + print $fh '
Apache/2.2.22 (Debian) Server at '.WEBSITE.' Port 80
'."\n"; + print $fh ' /body>'."\n"; + print_html_end ($fh); + } else { - # TO DO ! + } + close ($fh); + return $r } diff --git a/viewer.1.pl b/viewer.1.pl index 356e46c..68db13c 100644 --- a/viewer.1.pl +++ b/viewer.1.pl @@ -214,7 +214,7 @@ if (open ($state_file, "+<:encoding(UTF-8)", DATA_STATE_PATH())) { $goto_list{'ongtime-1'} = $frame_data{'ongtime'}; if (copy ($in_path, $out_path)) { - write_index('viewer', \%state, \%settings); + write_index(\%state, \%settings); write_data_file($state_file, '','', \%state); write_data_file(DATA_LIST_PATH(),'','', \%goto_list); } -- 2.30.2