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 {nodes
, id
, hostname
} =>
29 val fds
= map (fn node
=> Domain
.domainFile
{node
= node
,
30 name
= id ^
".wbl"}) nodes
33 write
:= (fn s
=> app (fn fd
=> TextIO.output (fd
, s
)) fds
);
35 !write Config
.Apache
.logDir
;
38 !write
"/access.log\nOutputDir\t";
39 !write Config
.Webalizer
.outputDir
;
42 !write
"\nHostname\t";
44 !write
"\nHideSite\t";
46 !write
"\nHideReferrer\t";
51 val () = Apache
.registerPost
52 (fn () => app
TextIO.closeOut (!files
))
54 val () = Apache
.registerAliaser
58 !write
"\nHideReferrer\t";
62 val () = Slave
.registerFileHandler (fn fs
=>
64 val spl
= OS
.Path
.splitDirFile (#file fs
)
66 case OS
.Path
.splitBaseExt (#file spl
) of
67 {base
, ext
= SOME
"wbl"} =>
70 (ignore (OS
.Process
.system (Config
.rm
72 ^ Config
.Webalizer
.configDir
76 ignore (OS
.Process
.system (Config
.rm
78 ^ Config
.Webalizer
.outputDir
82 (ignore (OS
.Process
.system (Config
.cp
86 ^ Config
.Webalizer
.configDir
91 val dir
= Config
.Webalizer
.outputDir ^
"/" ^ base
93 if Posix
.FileSys
.access (dir
, []) then
96 Posix
.FileSys
.mkdir (dir
, Posix
.FileSys
.S
.flags
97 [Posix
.FileSys
.S
.iroth
,
98 Posix
.FileSys
.S
.ixoth
,
99 Posix
.FileSys
.S
.irwxu
,
100 Posix
.FileSys
.S
.irgrp
,
101 Posix
.FileSys
.S
.iwgrp
])