1 (* HCoop
Domtool (http
://hcoop
.sourceforge
.net
/)
2 * Copyright (c
) 2006, Adam Chlipala
4 * This program is free software
; you can redistribute it
and/or
5 * modify it under the terms
of the GNU General Public License
6 * as published by the Free Software Foundation
; either version
2
7 * of the License
, or (at your option
) any later version
.
9 * This program is distributed
in the hope that it will be useful
,
10 * but WITHOUT ANY WARRANTY
; without even the implied warranty
of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
. See the
12 * GNU General Public License for more details
.
14 * You should have received a copy
of the GNU General Public License
15 * along
with this program
; if not
, write to the Free Software
16 * Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
19 (* Webalizer statistics tool handling
*)
21 structure Webalizer
:> WEBALIZER
= struct
23 val files
= ref ([] : TextIO.outstream list
)
24 val write
= ref (fn _
: string => ())
26 val () = Apache
.registerPre
27 (fn {user
, nodes
, id
, hostname
} =>
29 val fds
= map (fn node
=>
31 val fd
= Domain
.domainFile
{node
= node
,
34 TextIO.output (fd
, "LogFile\t");
35 TextIO.output (fd
, Config
.homeBase
);
36 TextIO.output (fd
, "/apache/log/");
37 TextIO.output (fd
, node
);
38 TextIO.output (fd
, hostname
);
39 TextIO.output (fd
, "/access.log\nOutputDir\t");
40 TextIO.output (fd
, Config
.Webalizer
.outputDir
);
41 TextIO.output (fd
, "/");
42 TextIO.output (fd
, node
);
43 TextIO.output (fd
, "/");
44 TextIO.output (fd
, id
);
45 TextIO.output (fd
, "\n");
50 write
:= (fn s
=> app (fn fd
=> TextIO.output (fd
, s
)) fds
);
53 !write
"\nHideSite\t";
55 !write
"\nHideReferrer\t";
60 val () = Apache
.registerPost
61 (fn () => app
TextIO.closeOut (!files
))
63 val () = Apache
.registerAliaser
67 !write
"\nHideReferrer\t";
71 val () = Slave
.registerFileHandler (fn fs
=>
73 val spl
= OS
.Path
.splitDirFile (#file fs
)
75 case OS
.Path
.splitBaseExt (#file spl
) of
76 {base
, ext
= SOME
"wbl"} =>
79 (ignore (OS
.Process
.system (Config
.rm
81 ^ Config
.Webalizer
.configDir
85 ignore (OS
.Process
.system (Config
.rm
87 ^ Config
.Webalizer
.outputDir
91 (ignore (OS
.Process
.system (Config
.cp
95 ^ Config
.Webalizer
.configDir
100 val dir
= Config
.Webalizer
.outputDir ^
"/" ^ base
102 if Posix
.FileSys
.access (dir
, []) then