tosapol@hotmail.com

[ Home ] [ Education ] [ Working ] [ Hobbies ] [ Software ] [ Hardware ] [ How-To ] [ Link ] [ mail ]


Light and tiny /cgi-bin/footer for Apache, allowing to

Apache configuration

httpd/conf/srm.conf:
# Or to do this for all HTML files, for example, use:
Action text/html /cgi-bin/footer

The code of /cgi-bin/footer


#!/bin/sh

FICHIER=$DOCUMENT_ROOT/$REDIRECT_URL
DIR=`dirname $FICHIER`
FOOTER=$DIR/footer

DATA="$DOCUMENT_ROOT/data/`echo $FICHIER | tr '/' '_'"

echo "Content-type: text/html"
echo

cat $FICHIER

if [ ! -f $FOOTER ]; then
	exit 0
fi

# Positionne les variables d'environnements
# ACCES_USER nombre d'utilisateurs authentifies par les cookies
# ACCES_ACCES nombre d'acces
# ACCES_HOST nombre de machines
# MODIF	date et heure de derniere modification



FILEDATE="`dirname $SCRIPT_FILENAME`/FileDate"

MODIF="`$FILEDATE $FICHIER`"


COOKIE=$DATA.cookie
if [ ! -f $COOKIE ]; then
	touch $COOKIE
fi

if [ "${HTTP_COOKIE:=x}" != "x" ]; then
	echo $HTTP_COOKIE >> $COOKIE
fi

ACCES_USER="`sort -u $COOKIE | wc -l`"



if [ "${REMOTE_HOST:=x}" != "x" ]; then
	REMOTE=$REMOTE_HOST
else
	REMOTE=$REMOTE_ADDR
fi

HOST=$DATA.host
if [ ! -f $HOST ]; then
	touch $HOST
fi
echo $REMOTE >> $HOST
ACCES_HOST="`sort -u $HOST | wc -l`"



ACCES_ACCES="`cat $HOST | wc -l`"


Send(){

	IFS=" "
	a="cat << EOF
	`cat $1`
	EOF"
	eval $a
}

Send $FOOTER



The code of FileDate

#include < stdio.h >
#include < sys/types.h >
#include < sys/stat.h >
#include < time.h >

main(int argc, char **argv){

char buf[256];
struct stat Stat;



stat(argv[1],&Stat);


cftime( &(buf[0]), "%d/%m/%y à %kh%M", &(Stat.st_mtime) );

printf("%s", buf );

}


Internet Link Exchange
Member of the Internet Link Exchange Free Home Pages at GeoCities