#============================================================================# # vHost - one-step solution for all virtual hosting needs # # V35webalizer - webalizer virtualization module # # # # Copyright(c) Chaogic Systems, LLC. http://chaogic.com # # Author: Jake Fan # # # # This is Free Software; permission to use, copy, modify, and distribute # # this software and its documentation for any purpose - with or without fee # # - is hereby granted, provided that the above copyright information and # # this permission notice appear in all copies and documentations. This # # software is provided "as is" without express or implied warranty. For # # more details, see GNU General Public License as published by the Free # # Software Foundation. # # # #============================================================================# $X eq "configuration" && do { ################################################ ### EDITABLE CONFIGURATIONS ################################################## ### webstats directory name on virtual hosts. virtual host webstats will be # accessed at "http://virtual.host.name/$wsDir". # $wsDir = "webstats"; $wsDir = "webstats"; ### command "webalizer". # $webalizer = "/usr/bin/webalizer"; $webalizer = "/usr/bin/webalizer"; ### webalizer default configuration file. # $webalizerCf = "/etc/webalizer.conf"; $webalizerCf = "/etc/webalizer.conf"; ### DO NOT TOUCH ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING!! ### SanityChecking ########################################################### $ERR = 1, Error "$MOD: \$wsDir = '$wsDir'" if $wsDir eq $guiDir || !CheckN $wsDir; $ERR = 1, Error "$MOD: \$webalizer = '$webalizer'" if $webalizer !~ /^\// || !-x (split /[\s|&;]+/, $webalizer)[0]; $ERR = 1, Error "$MOD: \$webalizerCf = '$webalizerCf'" if !-f $webalizerCf; $wsRoot = "$VHOME/$H/var/$webDir/$urlDir/$wsDir"; $EVAL{'$wsRoot;'} = 4; $EVAL{'$webalizer;'} = 4; }; $X eq "initialization" && do { ############################################### if ($ARGV[0] eq "rotatelog") { my $d; $d = "$HOME{$PROF{$_}}/$_/var/$webDir/$urlDir/$wsDir", -d $d || next, `(cd $d && $webalizer -c webalizer.conf && mv index.html webalizer.html) $NERR` for $H || grep CheckQ ($QHOST{$_}), keys %PROF; } }; $X eq "addhost" && do { ###################################################### `mkdir $wsRoot $NERR`; `cp -p $webalizerCf $wsRoot/webalizer.conf $NERR`; `ln -f $wsRoot/webalizer.conf $VHOME/$H/etc/webalizer.conf $NERR`; Flock "$wsRoot/webalizer.conf", "+<", 0; s/^\s*(LogFile\s+).*/$1$VHOME\/$H\/var\/log\/access_log\n/s, s/^\s*(OutputDir\s+).*/$1$wsRoot\n/s, s/^\s*(HistoryName\s+).*/$1webalizer.hist\n/s, s/^[#\s]*(Incremental\s+).*/$1yes\n/s, s/^[#\s]*(IncrementalName\s+).*/$1webalizer.current\n/s, s/^[#\s]*(HostName\s+).*/$1$H\n/s for @FILE; print FILE @FILE; Flock 0; Flock "$wsRoot/index.php", ">", 0; print FILE "\n"; Flock 0; }; $X eq "finalization" && do { ################################################# if ($ARGV[0] eq "addhost" || $ARGV[0] eq "adduser" && $U eq $webDir || $ARGV[0] eq "rotatelog") { for ($H || grep CheckQ ($QHOST{$_}), keys %PROF) { # my $wuid = getpwnam $webUser; my $wsroot = "$HOME{$PROF{$_}}/$_/var/$webDir/$urlDir/$wsDir"; `chown -Rh $O[2]:$GHID $wsroot $NERR`; -l && `chown -h 0:$GHID $_ $NERR` for <$wsroot/*>; -f && `chmod 0664 $_ $NERR` for <$wsroot/*>; `chmod 0644 $wsroot/index.* $NERR`; `chmod 0644 $wsroot/*.conf $NERR`; `chmod 0775 $wsroot $NERR`; }} }; 1;