]> bicyclesonthemoon.info Git - ott/bsta/commitdiff
generating fake index
authorb <rowerynaksiezycu@gmail.com>
Thu, 9 Nov 2023 22:50:02 +0000 (22:50 +0000)
committerb <rowerynaksiezycu@gmail.com>
Thu, 9 Nov 2023 22:50:02 +0000 (22:50 +0000)
bsta_lib.1.pm
viewer.1.pl

index 50eea1a49e6369201628d4a3897d53028b4cc0f4..7ae11838834d7383c7213ac0bcf7f89e566f5223 100644 (file)
@@ -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 ' <head>'."\n";
+               print $fh '  <meta http-equiv="Content-type" content="text/html; charset=UTF-8">'."\n";
+               print $fh '  <title>Index of '.$_index_of.'</title>'."\n";
+               print $fh ' </head>'."\n";
+               print $fh ' <body>'."\n";
+               print $fh '  <h1>Index of '.$_index_of.'</h1>'."\n";
+               print $fh '  <table>'."\n";
+               print $fh '   <tr>'."\n";
+               print $fh '    <th><img src="/icons/blank.gif" alt="[ICO]"></th>'."\n";
+               print $fh '    <th><a href="?C=N;O=D">Name</a></th>'."\n";
+               print $fh '    <th><a href="?C=M;O=A">Last modified</a></th>'."\n";
+               print $fh '    <th><a href="?C=S;O=A">Size</a></th>'."\n";
+               print $fh '    <th><a href="?C=D;O=A">Description</a></th>'."\n";
+               print $fh '   </tr><tr>'."\n";
+               print $fh '    <th colspan="5"><hr></th>'."\n";
+               print $fh '   </tr><tr>'."\n";
+               print $fh '    <td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td>'."\n";
+               print $fh '    <td><a href="/">Parent Directory</a></td>'."\n";
+               print $fh '    <td>&nbsp;</td>'."\n";
+               print $fh '    <td align="right">  - </td>'."\n";
+               print $fh '    <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="2words/">2words/</a></td>'."\n";
+               print $fh '    <td align="right">'.INTF_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">  - </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 '  /body>'."\n";
+               print_html_end ($fh);
+       }
        else {
-               # TO DO !
+               
        }
+       close ($fh);
+       return $r
 }
 
 
index 356e46c1a0fa87b7f06a37eab79e53fd0fec6418..68db13cb3e6fc4f3974d866b8f11c1c962f0e8b8 100644 (file)
@@ -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);
                                }