--- apache_1.3.33/src/modules/standard/mod_autoindex.c.org 2005-08-11 10:15:59.000000000 +0900 +++ apache_1.3.33/src/modules/standard/mod_autoindex.c 2005-08-16 11:51:20.000000000 +0900 @@ -39,6 +39,14 @@ * Handling configuration directives... */ +#ifndef DOCTYPE_XHTML_1_0S + /** XHTML 1.0 Strict Doctype */ + #define DOCTYPE_XHTML_1_0S "\n" +#endif + #define HRULE 1 #define NO_HRULE 0 #define FRONT_MATTER 1 @@ -113,6 +121,8 @@ int icon_width; int icon_height; char *default_order; + char *encoding; + char *css; array_header *icon_list; array_header *alt_list; @@ -153,11 +163,22 @@ * We include the DOCTYPE because we may be using features therefrom (i.e., * HEIGHT and WIDTH attributes on the icons if we're FancyIndexing). */ -static void emit_preamble(request_rec *r, char *title) +static void emit_preamble(request_rec *r, char *title, autoindex_config_rec *d ) { - ap_rvputs(r, DOCTYPE_HTML_3_2, - "\n \n Index of ", title, - "\n \n \n", NULL); + ap_rvputs(r, DOCTYPE_XHTML_1_0S, + "\n\t\n\tIndex of ", title, + "\n", NULL); + + if( d->encoding != NULL ) + ap_rvputs( r, "\t\n", NULL ); + + if( d->css != NULL ) + ap_rvputs( r, "\tcss, + "\" type=\"text/css\" media=\"all\" />\n", NULL ); + + ap_rputs("\n\n\n\n", r); } static void push_item(array_header *arr, char *type, char *to, char *path, @@ -297,6 +318,20 @@ return NULL; } +/* myhack */ +static const char *set_encoding(cmd_parms *cmd, void *d, char *name) +{ + ((autoindex_config_rec *) d)->encoding = ap_pstrdup( cmd->pool, name ); + return NULL; +} + +static const char *set_css(cmd_parms *cmd, void *d, char *name) +{ + ((autoindex_config_rec *) d)->css = ap_pstrdup( cmd->pool, name ); + return NULL; +} +/* myhack end */ + /* A legacy directive, FancyIndexing is superseded by the IndexOptions * keyword. But for compatibility.. */ @@ -557,6 +592,8 @@ {"DefaultIcon", ap_set_string_slot, (void *) XtOffsetOf(autoindex_config_rec, default_icon), DIR_CMD_PERMS, TAKE1, "an icon URL"}, + {"Encoding", set_encoding, NULL, DIR_CMD_PERMS, TAKE1, "filename encoding"}, + {"CSSFile", set_css, NULL, DIR_CMD_PERMS, TAKE1, "css file"}, {NULL} }; @@ -582,6 +619,9 @@ new->decremented_opts = 0; new->default_order = NULL; + new->encoding = NULL; + new->css = NULL; + return (void *) new; } @@ -669,6 +709,18 @@ new->desc_width = add->desc_width; new->desc_adjust = add->desc_adjust; } + + /* myhack */ + if( add->css != NULL ) + new->css = add->css; + else + new->css = base->css; + + if( add->encoding != NULL ) + new->encoding = add->encoding; + else + new->encoding = base->encoding; + /* myhack end */ new->default_order = (add->default_order != NULL) ? add->default_order : base->default_order; @@ -902,7 +954,7 @@ char buf[IOBUFSIZE + 1]; int i, n, c, ch; - ap_rputs("
\n", r);
+    ap_rputs("
\n", r);
     while (!feof(f)) {
 	do {
 	    n = fread(buf, sizeof(char), IOBUFSIZE, f);
@@ -934,7 +986,7 @@
 	    c = i + 1;
 	}
     }
-    ap_rputs("
\n", r); + ap_rputs("
\n", r); } /* See mod_include */ @@ -950,8 +1002,8 @@ * instead of a text document, meaning nothing will be displayed, but * oh well. */ -static void emit_head(request_rec *r, char *header_fname, int suppress_amble, - char *title) +static void emit_head(request_rec *r, autoindex_config_rec *autoindex_conf, + int suppress_amble, char *title) { FILE *f; request_rec *rr = NULL; @@ -961,6 +1013,7 @@ const char *r_accept_enc; table *hdrs = r->headers_in; + char *header_fname = find_header(autoindex_conf, r); /* * If there's a header file, send a subrequest to look for it. If it's * found and html do the subrequest, otherwise handle it @@ -993,7 +1046,7 @@ emit_H1 = 0; if (! suppress_amble) { - emit_preamble(r, title); + emit_preamble(r, title, autoindex_conf); } /* See mod_include */ @@ -1020,7 +1073,7 @@ * where it belongs. */ if ((f = ap_pfopen(r->pool, rr->filename, "r")) != 0) { - emit_preamble(r, title); + emit_preamble(r, title, autoindex_conf); emit_amble = 0; do_emit_plain(r, f); ap_pfclose(r->pool, f); @@ -1042,10 +1095,12 @@ } if (emit_amble) { - emit_preamble(r, title); + emit_preamble(r, title, autoindex_conf); } if (emit_H1) { - ap_rvputs(r, "

Index of ", title, "

\n", NULL); + ap_rvputs(r, "
\n" \ + "\tLocation :\n" \ + "\t", title, "\n
\n", NULL); } if (rr != NULL) { ap_destroy_sub_req(rr); @@ -1116,7 +1171,9 @@ * If we can open the file, suppress the signature. */ if ((f = ap_pfopen(r->pool, rr->filename, "r")) != 0) { + ap_rputs("
\n", r); do_emit_plain(r, f); + ap_rputs("
\n", r); ap_pfclose(r->pool, f); suppress_sig = 1; } @@ -1135,11 +1192,18 @@ ap_table_setn(hdrs, "Accept-Encoding", r_accept_enc); } + /* disable ugly signature */ + /* if (!suppress_sig) { ap_rputs(ap_psignature("", r), r); } + */ + + ap_rputs( "
Copyright " \ + "unfix.net " \ + "all right reserved
\n\n", r ); if (!suppress_post) { - ap_rputs("\n", r); + ap_rputs("\n\n\n", r); } if (rr != NULL) { ap_destroy_sub_req(rr); @@ -1149,7 +1213,7 @@ static char *find_title(request_rec *r) { - char titlebuf[MAX_STRING_LEN], *find = ""; + char titlebuf[MAX_STRING_LEN], *find = "<title>"; FILE *thefile = NULL; int x, y, n, p; @@ -1347,7 +1411,7 @@ qvalue[4] = '\0'; reverse = ((curkey == fname) && (curdirection == D_ASCENDING)); qvalue[3] = reverse ? D_DESCENDING : D_ASCENDING; - ap_rvputs(r, "<A HREF=\"", qvalue, "\">", anchor, "</A>", NULL); + ap_rvputs(r, "<a href=\"", qvalue, "\">", anchor, "</a>", NULL); } else { ap_rputs(anchor, r); @@ -1398,44 +1462,36 @@ pad_scratch[name_width] = '\0'; if (autoindex_opts & FANCY_INDEXING) { - ap_rputs("<PRE>", r); - if ((tp = find_default_icon(d, "^^BLANKICON^^"))) { - ap_rvputs(r, "<IMG SRC=\"", ap_escape_html(scratch, tp), - "\" ALT=\" \"", NULL); - if (d->icon_width && d->icon_height) { - ap_rprintf - ( - r, - " HEIGHT=\"%d\" WIDTH=\"%d\"", - d->icon_height, - d->icon_width - ); - } - ap_rputs("> ", r); - } + + ap_rputs( "<table>\n<tr>\n\t<th class='name'>", r ); emit_link(r, "Name", K_NAME, keyid, direction, static_columns); - ap_rputs(pad_scratch + 4, r); + ap_rputs( "</th>\n", r ); + /* * Emit the guaranteed-at-least-one-space-between-columns byte. */ ap_rputs(" ", r); if (!(autoindex_opts & SUPPRESS_LAST_MOD)) { + ap_rputs( "\t<th class='mtime'>", r ); emit_link(r, "Last modified", K_LAST_MOD, keyid, direction, static_columns); - ap_rputs(" ", r); + ap_rputs( "</th>\n", r ); } if (!(autoindex_opts & SUPPRESS_SIZE)) { + ap_rputs( "\t<th class='size'>", r ); emit_link(r, "Size", K_SIZE, keyid, direction, static_columns); - ap_rputs(" ", r); + ap_rputs( "</th>\n", r ); } if (!(autoindex_opts & SUPPRESS_DESC)) { + ap_rputs( "\t<th class='desc'>", r ); emit_link(r, "Description", K_DESC, keyid, direction, static_columns); + ap_rputs( "</th>\n", r ); } - ap_rputs("\n<HR>\n", r); + ap_rputs("</tr>\n\n", r); } else { - ap_rputs("<UL>", r); + ap_rputs("<ul>", r); } for (x = 0; x < n; x++) { @@ -1460,24 +1516,25 @@ } if (autoindex_opts & FANCY_INDEXING) { + ap_rputs("<tr>\n\t<td class='name'>", r); if (autoindex_opts & ICONS_ARE_LINKS) { - ap_rvputs(r, "<A HREF=\"", anchor, "\">", NULL); + ap_rvputs(r, "<a href=\"", anchor, "\">", NULL); } if ((ar[x]->icon) || d->default_icon) { - ap_rvputs(r, "<IMG SRC=\"", + ap_rvputs(r, "<img src=\"", ap_escape_html(scratch, ar[x]->icon ? ar[x]->icon : d->default_icon), - "\" ALT=\"[", (ar[x]->alt ? ar[x]->alt : " "), + "\" alt=\"[", (ar[x]->alt ? ar[x]->alt : " "), "]\"", NULL); if (d->icon_width && d->icon_height) { - ap_rprintf(r, " HEIGHT=\"%d\" WIDTH=\"%d\"", + ap_rprintf(r, " height=\"%d\" width=\"%d\"", d->icon_height, d->icon_width); } - ap_rputs(">", r); + ap_rputs(" />", r); } if (autoindex_opts & ICONS_ARE_LINKS) { - ap_rputs("</A>", r); + ap_rputs("</a>", r); } nwidth = strlen(t2); @@ -1490,48 +1547,49 @@ t2 = name_scratch; nwidth = name_width; } - ap_rvputs(r, " <A HREF=\"", anchor, "\">", - ap_escape_html(scratch, t2), "</A>", - pad_scratch + nwidth, NULL); + ap_rvputs(r, " <a href=\"", anchor, "\">", + ap_escape_html(scratch, t2), "</a></td>\n", NULL); /* * The blank before the storm.. er, before the next field. */ ap_rputs(" ", r); if (!(autoindex_opts & SUPPRESS_LAST_MOD)) { + ap_rputs( "\t<td class='mtime'>", r ); if (ar[x]->lm != -1) { char time_str[MAX_STRING_LEN]; struct tm *ts = localtime(&ar[x]->lm); strftime(time_str, MAX_STRING_LEN, "%d-%b-%Y %H:%M ", ts); ap_rputs(time_str, r); } - else { - /*Length="22-Feb-1998 23:42 " (see 4 lines above) */ - ap_rputs(" ", r); - } + ap_rputs( "</td>\n", r ); } if (!(autoindex_opts & SUPPRESS_SIZE)) { + ap_rputs( "\t<td class='size'>", r ); ap_send_size(ar[x]->size, r); - ap_rputs(" ", r); + ap_rputs( "</td>\n", r ); } if (!(autoindex_opts & SUPPRESS_DESC)) { + ap_rputs( "\t<td class='desc'>", r ); if (ar[x]->desc) { ap_rputs(terminate_description(d, ar[x]->desc, autoindex_opts, desc_width), r); } + ap_rputs( "</td>\n", r ); } + ap_rputs( "</tr>\n", r ); } else { - ap_rvputs(r, "<LI><A HREF=\"", anchor, "\"> ", t2, - "</A>", NULL); + ap_rvputs(r, "<li><a href=\"", anchor, "\"> ", t2, + "</a>", NULL); } ap_rputc('\n', r); } if (autoindex_opts & FANCY_INDEXING) { - ap_rputs("</PRE>", r); + ap_rputs("</table>\n\n", r); } else { - ap_rputs("</UL>", r); + ap_rputs("</ul>\n\n", r); } } @@ -1674,7 +1732,7 @@ *title_endp-- = '\0'; } - emit_head(r, find_header(autoindex_conf, r), + emit_head(r, autoindex_conf, autoindex_opts & SUPPRESS_PREAMBLE, title_name); /* @@ -1740,9 +1798,6 @@ direction); ap_pclosedir(r->pool, d); - if (autoindex_opts & FANCY_INDEXING) { - ap_rputs("<HR>\n", r); - } emit_tail(r, find_readme(autoindex_conf, r), autoindex_opts & SUPPRESS_PREAMBLE);