diff -urN httpd-2.4.3-orig/modules/generators/mod_autoindex.c httpd-2.4.3/modules/generators/mod_autoindex.c
--- httpd-2.4.3-orig/modules/generators/mod_autoindex.c 2011-12-19 03:02:21 +0900
+++ httpd-2.4.3/modules/generators/mod_autoindex.c 2013-01-07 06:05:07 +0900
@@ -74,6 +74,8 @@
#define ADDALTCLASS (1 << 19)
#define OPTION_UNSET (1 << 20)
+#define SEMIFANCY_INDEXING (1 << 30)
+
#define K_NOADJUST 0
#define K_ADJUST 1
#define K_UNSET 2
@@ -351,6 +353,9 @@
if (!strcasecmp(w, "FancyIndexing")) {
option = FANCY_INDEXING;
}
+ else if (!strcasecmp(w, "SemiFancyIndexing")) {
+ option = SEMIFANCY_INDEXING;
+ }
else if (!strcasecmp(w, "FoldersFirst")) {
option = FOLDERS_FIRST;
}
@@ -753,7 +758,7 @@
struct ent *next;
int ascending, ignore_case, version_sort;
char key;
- int isdir;
+ unsigned char isdir, isdir_ff;
};
static char *find_item(const char *content_type, const char *content_encoding,
@@ -1362,16 +1367,20 @@
p->desc = NULL;
p->lm = -1;
p->isdir = 0;
+ p->isdir_ff = 0;
p->key = apr_toupper(keyid);
p->ascending = (apr_toupper(direction) == D_ASCENDING);
p->version_sort = !!(autoindex_opts & VERSION_SORT);
p->ignore_case = !!(autoindex_opts & IGNORE_CASE);
- if (autoindex_opts & (FANCY_INDEXING | TABLE_INDEXING)) {
+ if (autoindex_opts & (FANCY_INDEXING | SEMIFANCY_INDEXING | TABLE_INDEXING)) {
p->lm = rr->finfo.mtime;
if (dirent->filetype == APR_DIR) {
- if (autoindex_opts & FOLDERS_FIRST) {
+ if (autoindex_opts & (SEMIFANCY_INDEXING | FOLDERS_FIRST)) {
p->isdir = 1;
+ if (autoindex_opts & FOLDERS_FIRST) {
+ p->isdir_ff = 1;
+ }
}
rr->filename = ap_make_dirstr_parent (rr->pool, rr->filename);
@@ -1661,6 +1670,9 @@
ap_rputc('\n', r);
}
}
+ else if (autoindex_opts & SEMIFANCY_INDEXING) {
+ ap_rputs("
", r);
+ }
else {
ap_rputs("
", r);
}
@@ -1866,6 +1878,79 @@
}
ap_rputc('\n', r);
}
+ else if (autoindex_opts & SEMIFANCY_INDEXING) {
+ if (!x && t[0] == '/') {
+ continue;
+ }
+ if (strcmp(t, ".htaccess") == 0) {
+ continue; /* Don't show .htaccess files to the world */
+ }
+ int len = strlen(t);
+ const char *type;
+#define ENDS_WITH(str) (len > sizeof(str)-1 && strcasecmp(t+len-(sizeof(str)-1),str) == 0)
+ if (ar[x]->isdir) {
+ type = "DIR";
+ len--; /* Drop trailing slash */
+ } else if (ENDS_WITH(".html")
+ || ENDS_WITH(".htm")
+ || ENDS_WITH(".shtml")
+ || ENDS_WITH(".css")
+ || ENDS_WITH(".txt")
+ || ENDS_WITH(".diff")
+ || ENDS_WITH(".patch")
+ || ENDS_WITH(".i")
+ || ENDS_WITH(".s")
+ || ENDS_WITH(".asm")
+ || ENDS_WITH("makefile")
+ || ENDS_WITH(".c")
+ || ENDS_WITH(".cc")
+ || ENDS_WITH(".cpp")
+ || ENDS_WITH(".cxx")
+ || ENDS_WITH(".h")
+ || ENDS_WITH(".pl")
+ || ENDS_WITH(".py")) {
+ type = "TXT";
+ } else {
+ type = "BIN";
+ }
+#undef ENDS_WITH
+ ap_rvputs(r, "[", type, "] ", NULL);
+ nwidth = len;
+ if (nwidth > name_width) {
+ memcpy(name_scratch, t2, name_width - 3);
+ name_scratch[name_width - 3] = '.';
+ name_scratch[name_width - 2] = '.';
+ name_scratch[name_width - 1] = '.';
+ name_scratch[name_width] = 0;
+ t2 = name_scratch;
+ nwidth = name_width;
+ }
+ else {
+ snprintf(name_scratch, name_width, "%-*.*s",
+ name_width, len, t2);
+ t2 = name_scratch;
+ }
+ ap_rvputs(r, "",
+ ap_escape_html(scratch, t2),
+ " ", NULL);
+ if (!ar[x]->isdir) {
+ char sizebuf[22];
+ snprintf(sizebuf, sizeof(sizebuf), "%10llu ", ar[x]->size);
+ ap_rputs(sizebuf, r);
+ if (ar[x]->lm != -1) {
+ char datebuf[11];
+ apr_time_exp_t ts;
+ apr_time_exp_lt(&ts, ar[x]->lm);
+ snprintf(datebuf, sizeof(datebuf), "%04d/%02d/%02d",
+ ts.tm_year+1900, ts.tm_mon+1, ts.tm_mday);
+ ap_rputs(datebuf, r);
+ }
+ else {
+ ap_rputs(" ", r);
+ }
+ }
+ ap_rputc('\n', r);
+ }
else {
ap_rvputs(r, "- ",
ap_escape_html(scratch, t2),
@@ -1887,6 +1972,9 @@
ap_rputs("\n", r);
}
}
+ else if (autoindex_opts & SEMIFANCY_INDEXING) {
+ ap_rputs("", r);
+ }
else {
ap_rputs("
\n", r);
}
@@ -1917,7 +2005,7 @@
* Now see if one's a directory and one isn't, if we're set
* isdir for FOLDERS_FIRST.
*/
- if ((*e1)->isdir != (*e2)->isdir) {
+ if ((*e1)->isdir_ff != (*e2)->isdir_ff) {
return (*e1)->isdir ? -1 : 1;
}
/*