From: b Date: Tue, 9 Jan 2024 22:27:18 +0000 (+0000) Subject: info interface supports comments X-Git-Tag: v1.0.0~11 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=a25fb5c4e3540d23ccb93c827dbb4f4440baa220;p=botm%2Foldlogs info interface supports comments --- diff --git a/info.1.pl b/info.1.pl index 09f185a..94cba16 100644 --- a/info.1.pl +++ b/info.1.pl @@ -47,6 +47,7 @@ use bsta_lib ( ###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_WORDS_PATH: DATA_WORDS_PATH = /botm/data/bsta/words/ binmode STDIN, ':encoding(UTF-8)'; binmode STDOUT, ':encoding(UTF-8)'; @@ -58,7 +59,7 @@ srand ($time-$$); my %http; my %cgi; -my %frame_data; +my %info_data; my %next_frame_data; my %default; my %settings; @@ -67,13 +68,14 @@ my %state; my $method; my $frame = ''; my $attachment = ''; +my $words = ''; my $password; my $password_ok; my $access; my $show_command; my $ongtime; my $timer; -my $frame_data_path; +my $info_data_path; my $next_frame_data_path; my $ong_state; my $last_frame; @@ -105,13 +107,22 @@ if ($method eq 'POST') { if ($cgi{'f'} =~ /^.+$/) { $frame = int($&); } +elsif ($cgi{'a'} =~ /^.+$/) { + $attachment = int($&); +} elsif ($cgi{'i'} =~ /^.+$/) { $attachment = int($&); } +elsif ($cgi{'w'} =~ /^.+$/) { + $words = $&; +} elsif ($ENV{'PATH_INFO'} =~ /^\/a(.+)$/) { $attachment = int($1); } -elsif ($ENV{'PATH_INFO'} =~ /^\/(.+)$/) { +elsif ($ENV{'PATH_INFO'} =~ /^\/w(.+)$/) { + $words = $1; +} +elsif ($ENV{'PATH_INFO'} =~ /^\/f?(.+)$/) { $frame = int($1); } @@ -126,21 +137,39 @@ $last_frame = int($state{'last'}); $password_ok = ($password eq $settings{'password'}); +# comment info, not frame +if ($words ne '') { + $info_data_path = join_path(PATH_SEPARATOR(), DATA_WORDS_PATH(), $words); + %info_data = read_data_file($info_data_path); + if ($words =~ /^[0-9]+$/) { + $frame = int($&); + if ($info_data{'posts'} eq '') { + $info_data{'posts'} = 0; + } + } + else { + $frame = ($info_data{'frame'} ne '') ? int($info_data{'frame'}) : -1; + unless ($password_ok) { + delete($info_data{'password'}); + delete($info_data{'key'}); + } + } +} # attachment info, not frame -if ($attachment ne '') { - %frame_data = read_data_file(DATA_ATTACH_PATH().$attachment); - $frame = ($frame_data{'frame'} ne '') ? int($frame_data{'frame'}) : -1; +elsif ($attachment ne '') { + %info_data = read_data_file(DATA_ATTACH_PATH().$attachment); + $frame = ($info_data{'frame'} ne '') ? int($info_data{'frame'}) : -1; } # frame info elsif ($frame ne '') { if ($frame < 0) { $frame = $last_frame + $frame +1; } - $frame_data_path = join_path(PATH_SEPARATOR(), DATA_PATH(), $frame); + $info_data_path = join_path(PATH_SEPARATOR(), DATA_PATH(), $frame); $next_frame_data_path = join_path(PATH_SEPARATOR(), DATA_PATH(), $frame+1); - %frame_data = read_data_file($frame_data_path); + %info_data = read_data_file($info_data_path); %next_frame_data = read_data_file($next_frame_data_path); - %frame_data = merge_settings(\%default, \%frame_data); + %info_data = merge_settings(\%default, \%info_data); %next_frame_data = merge_settings(\%default, \%next_frame_data); $timer = int($state{'nextong'}) - $time; @@ -187,8 +216,9 @@ if ( $access = 1; if ( + ($words eq '') && ($attachment eq '') && - ($frame_data{'command'} eq '') && ( + ($info_data{'command'} eq '') && ( $password_ok || ($frame < $last_frame) || ( ($ong_state >= STATE->{'ready'}) && @@ -196,24 +226,25 @@ if ( ) ) ) { - $frame_data{'command'} = $next_frame_data{'title'}; + $info_data{'command'} = $next_frame_data{'title'}; } } else { $access = 0; - if ($attachment ne '') { - %frame_data = (); + if (($attachment ne '') || ($words ne '')) { + %info_data = (); } else { - %frame_data = read_data_file(DATA_NOACCESS_PATH()); - %frame_data = merge_settings(\%default, \%frame_data); + %info_data = read_data_file(DATA_NOACCESS_PATH()); + %info_data = merge_settings(\%default, \%info_data); } } if ( - ($frame_data{'frame'} eq '') && - ($attachment eq '') + ($info_data{'frame'} eq '') && + ($attachment eq '') && + ($words eq '') ) { - $frame_data{'frame'} = sprintf($settings{'frame'}, $frame, $frame_data{'ext'}); + $info_data{'frame'} = sprintf($settings{'frame'}, $frame, $info_data{'ext'}); } print "Content-type: text/plain\n"; @@ -225,7 +256,7 @@ if($method eq 'HEAD') { exit; } write_data_file( - \*STDOUT, \%frame_data, '', + \*STDOUT, \%info_data, '', 0, 0, 0, '>>', 1 );