#!/bin/sh
#
# FILESTATS: Make a File Stats Page that tells you all the goodies
#            about textfiles.com and lets you see how big the thing is.

I="/textfiles/inbox.html"

echo "<HTML><TITLE>T E X T F I L E S</TITLE>"                                                            >$I
echo "<BODY BGCOLOR="#000000" TEXT="#00FF00" LINK="#00FF00" ALINK="#00FF00" VLINK="#00FF00">"           >>$I
echo "<TABLE WIDTH=100%><TR><TD VALIGN=TOP><IMG SRC=\"images/mailbox.jpg\"><TD>"                                   >>$I
echo "<CENTER><H1>TEXTFILES.COM Inbox Statistics</H1>"                                                  >>$I
echo "<SMALL><I>This Document Was Last Updated at `date`</I></SMALL>"                                   >>$I
echo "<P>"                                                                                              >>$I
echo ""                                                                                                 >>$I
echo "<TABLE WIDTH=100%><TR><TD BGCOLOR=#00FF00><FONT COLOR=#000000>&nbsp<B>Directory</B></FONT>"       >>$I
echo "<TD BGCOLOR=#00DD00><FONT COLOR=#000000>&nbsp<B># of Files</B></FONT>"                            >>$I
echo "<TD BGCOLOR=#00AA00><FONT COLOR=#000000>&nbsp<B>Size of Directory</B></FONT>"                     >>$I

cd /textfiles/holdbin

for directory in *
    do
    if [ ! "$directory" = "OUTBOX" ]
       then
    if [ -d $directory ] 
       then
    nfiles="`ls -R /textfiles/holdbin/$directory | grep -v .html | wc -l`"
    bytes="`du -sb /textfiles/holdbin/$directory | cut -f1`"

    let tfiles=$tfiles+$nfiles
    let tbyte=$tbyte+$bytes

    echo "<TR><TD>&nbsp<B><A HREF=\"/holdbin/$directory\">$directory</A></B>"                           >>$I
    echo "<TD>&nbsp `/textfiles/magic/comma $nfiles`"                                                   >>$I
    echo "<TD>&nbsp `/textfiles/magic/comma $bytes`"                                                    >>$I
    fi
    fi
    done

echo "<TR><TD BGCOLOR=#00FF00><FONT COLOR=#000000>&nbsp<B>Totals</B></FONT>"                              >>$I
echo "<TD BGCOLOR=#00DD00><FONT COLOR=#000000>&nbsp<B>`/textfiles/magic/comma $tfiles` files</B></FONT>"  >>$I
echo "<TD BGCOLOR=#00AA00><FONT COLOR=#000000>&nbsp<B>`/textfiles/magic/comma $tbyte` bytes</B></FONT>"   >>$I

echo "</TABLE></TABLE>"                                                                                   >>$I
echo "</BODY></HTML>"                                                                                     >>$I
