1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
#include <module.h> 
inherit "module"; 
inherit "roxenlib"; 
 
/************** Generic module stuff ***************/ 
 
array register_module() 
{ 
  return ({ MODULE_DIRECTORIES,  
            "Index files only", 
            "You can use this directory module if you do _not_ want " 
            "directory listings.\n", 
            ({ }),  
            1 
         }); 
} 
 
void create() 
{ 
  defvar("indexfiles", ({ "index.html", "Main.html", "welcome.html", }), 
         "Index files", TYPE_STRING_LIST, 
         "If one of these files is present in a directory, it will " 
         "be returned instead of 'no such file'."); 
} 
 
mapping parse_directory(object id) 
{ 
  string file; 
 
  if(id->not_query[-1] == '.' && id->not_query[-2]=='/') 
    return http_redirect(id->not_query[..strlen(id->not_query)-2], id); 
 
  if(id->not_query[-1] != '/') 
    return http_redirect(id->not_query+"/", id); 
   
  string oq = id->not_query; 
  mapping result; 
  foreach(query("indexfiles"), file) 
  { 
    id->not_query = oq+file; 
    if(result=roxen->get_file(id)) 
    { 
      id->not_query = oq; 
      return result; 
    } 
  } 
  id->not_query = oq; 
  return 0; 
}