# 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;
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());
%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,
\%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> </td>'."\n";
+ print $fh ' <td align="right"> - </td>'."\n";
+ print $fh ' <td> </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> </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
}