diff --git a/.gitattributes b/.gitattributes index ad537a53..15f6bf24 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13,6 +13,25 @@ aide/index.sgml -text aide/sommaire.sgml -text aide/stats.sgml -text aide/test.sgml -text +awstats/Makefile -text +awstats/alternc-awstats -text +awstats/awstats.cache.php -text +awstats/awstats.sql -text +awstats/awstats.template.conf -text +awstats/awstats_alternc.png -text +awstats/bureau/admin/aws_add.php -text +awstats/bureau/admin/aws_del.php -text +awstats/bureau/admin/aws_doadd.php -text +awstats/bureau/admin/aws_doedit.php -text +awstats/bureau/admin/aws_edit.php -text +awstats/bureau/admin/aws_list.php -text +awstats/bureau/admin/aws_pass.php -text +awstats/bureau/admin/aws_useradd.php -text +awstats/bureau/admin/aws_userdel.php -text +awstats/bureau/admin/aws_users.php -text +awstats/bureau/admin/menu_aws.php -text +awstats/bureau/class/m_aws.php -text +awstats/logresolvemerge.pl -text bureau/admin/about.php -text bureau/admin/adm_add.php -text bureau/admin/adm_authip_whitelist.php -text @@ -372,6 +391,11 @@ bureau/locales/pt_BR/LC_MESSAGES/messages.po -text debian/.svnignore -text debian/NEWS -text debian/README.Debian -text +debian/alternc-awstats.dirs -text +debian/alternc-awstats.lintian-override -text +debian/alternc-awstats.postinst -text +debian/alternc-awstats.postrm -text +debian/alternc-awstats.preinst -text debian/alternc-slave.config -text debian/alternc-slave.dirs -text debian/alternc-slave.install -text diff --git a/awstats/Makefile b/awstats/Makefile new file mode 100755 index 00000000..8d69bcb8 --- /dev/null +++ b/awstats/Makefile @@ -0,0 +1,28 @@ +# ---------------------------------------------------------------------- +# LICENSE +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License (GPL) +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# To read the license please visit http://www.gnu.org/copyleft/gpl.html +# ---------------------------------------------------------------------- +# Purpose of file: Install the files of alternc-awstats packages +# ---------------------------------------------------------------------- + +install: + install -m 0644 -g root -o root alterncawstats.conf $(DESTDIR)/etc/alternc/ + install -m 0755 -g root -o root logresolvemerge.pl $(DESTDIR)/usr/lib/alternc/ + install -m 0644 -g www-data -o www-data awstats_alternc.png $(DESTDIR)/usr/share/awstats/icon/other/ + install -m 0755 -g www-data -o www-data alternc-awstats $(DESTDIR)/usr/lib/alternc/ + install -m 0755 -g www-data -o www-data awstats.cache.php $(DESTDIR)/usr/lib/alternc/ + install -m 0644 awstats.sql $(DESTDIR)/usr/share/alternc/ + install -m 0644 -g www-data -o www-data awstats.template.conf $(DESTDIR)/etc/alternc/templates/awstats/ + install -m 0644 -g www-data -o www-data awstats.alternc.generic.conf $(DESTDIR)/etc/alternc/ + #install -m 0444 lintian-override $(DESTDIR)/usr/share/lintian/overrides/alternc-awstats diff --git a/awstats/alternc-awstats b/awstats/alternc-awstats new file mode 100755 index 00000000..2b1a54d2 --- /dev/null +++ b/awstats/alternc-awstats @@ -0,0 +1,62 @@ +#!/bin/bash + +# Appelé seul, lance les stats AWStats du jour. +# Appelé avec "all" lance les stats avec tous les fichiers .gz situés dans /var/log/apache +# Appelé avec un nom de domaine en paramètre, rescanne tous les fichiers .gz pour ce domaine uniquement. + +# Include some usefull functions +. /usr/lib/alternc/functions.sh + +# Regenerate the awstat etc cache files : +if [ -x ./awstats.cache.php ] +then + ./awstats.cache.php +fi + +# FIXME : set this var in local.sh +LOG_DIR="/var/alternc/logs" + +CACHEDIR="/var/cache/awstats" # Dans la sarge par defaut les données awstats sont stockées dans /var/lib/awstats ... +mkdir -p $CACHEDIR + +function searchdomain { + U_ID=$(mysql_query "SELECT uid FROM aws WHERE hostname='$1'" | grep -v "^uid") + U_LOGIN=$(mysql_query "SELECT login FROM membres WHERE uid='$U_ID'" |grep -v "^login") + DOM_DIR="$LOG_DIR/$U_ID-$U_LOGIN" + echo $(find -P "$DOM_DIR" -mindepth 1 -maxdepth 2 -type f -iname "*.log" -print0 | xargs -0) +} + +function dostatgz { + read DOM + while [ "$DOM" ] + do + LOGAPACHE=$(searchdomain $DOM) + echo "processing $DOM (for access files in $LOGAPACHE )" + /usr/lib/cgi-bin/awstats.pl -config=$DOM -update -LogFile="/usr/lib/alternc/logresolvemerge.pl $LOGAPACHE* |" + read DOM + done +} + +function dostat { + read DOM + while [ "$DOM" ] + do + echo "processing $DOM" + LOGAPACHE=$(searchdomain $DOM) + /usr/lib/cgi-bin/awstats.pl -config=$DOM -LogFile="/usr/lib/alternc/logresolvemerge.pl $LOGAPACHE | " + read DOM + done +} + +if [ -z "$1" ] + then + mysql_query "SELECT hostname FROM aws" |grep -v "^hostname" | dostat +else + if [ "$1" = "all" ] + then + mysql_query "SELECT hostname FROM aws" |grep -v "^hostname" | dostatgz + else + echo "$1" | dostatgz + fi +fi + diff --git a/awstats/awstats.cache.php b/awstats/awstats.cache.php new file mode 100755 index 00000000..33c29ef7 --- /dev/null +++ b/awstats/awstats.cache.php @@ -0,0 +1,14 @@ +#!/usr/bin/php -q +query("SELECT id,hostname FROM aws;"); +while ($db->next_record()) { + $d[]=$db->Record; +} +foreach ($d as $r) { + $aws->_createconf($r[0],1); +} + +?> \ No newline at end of file diff --git a/awstats/awstats.sql b/awstats/awstats.sql new file mode 100644 index 00000000..d0960021 --- /dev/null +++ b/awstats/awstats.sql @@ -0,0 +1,28 @@ +# -------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `aws` ( + `id` int(10) unsigned NOT NULL auto_increment, + `uid` int(10) unsigned NOT NULL default '0', + `hostname` varchar(255) NOT NULL default '', + PRIMARY KEY (`id`) +) TYPE=MyISAM COMMENT='Statistiques web par Awstats'; + + +# -------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `aws_users` ( + `uid` int(10) unsigned NOT NULL, + `login` varchar(128) NOT NULL, + `pass` varchar(38) NOT NULL, + PRIMARY KEY (`login`), + INDEX (`uid`) +) COMMENT = 'Comptes pouvant accéder aux stats awstats.'; + +# -------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `aws_access` ( +`id` int(10) unsigned NOT NULL, +`uid` int(10) unsigned NOT NULL, +`login` varchar(128) NOT NULL, +INDEX (`id`) +) COMMENT = 'Qui peut accéder aux stats awstats '; + + ALTER TABLE `aws` ADD `public` INT(1) unsigned NOT NULL DEFAULT '1'; + ALTER TABLE `aws` ADD `hostaliases` TEXT ; diff --git a/awstats/awstats.template.conf b/awstats/awstats.template.conf new file mode 100644 index 00000000..5d424302 --- /dev/null +++ b/awstats/awstats.template.conf @@ -0,0 +1,9 @@ +Include "/etc/alternc/awstats.alternc.generic.conf" +Include "/etc/awstats/awstats.conf.local" +Include "/etc/alternc/awstats.log.alternc.conf" +SiteDomain="%%HOSTNAME%%" +HostAliases="%%HOSTALIASES%%" +DirData="/var/cache/awstats/%%HOSTNAME%%" +AllowAccessFromWebToFollowingAuthenticatedUsers="admin %%USERS%%" +AllowAccessFromWebToAuthenticatedUsersOnly=%%PUBLIC%% +AllowFullYearView=3 diff --git a/awstats/awstats_alternc.png b/awstats/awstats_alternc.png new file mode 100644 index 00000000..7e4bb233 Binary files /dev/null and b/awstats/awstats_alternc.png differ diff --git a/awstats/bureau/admin/aws_add.php b/awstats/bureau/admin/aws_add.php new file mode 100644 index 00000000..c33cc6d9 --- /dev/null +++ b/awstats/bureau/admin/aws_add.php @@ -0,0 +1,107 @@ + array ("request", "integer", 0), +); +getFields($fields); + +if (!$id && !$quota->cancreate("aws")) { + $error=_("You cannot add any new statistics, your quota is over."); +} + +include_once("head.php"); +?> +
+