Logo  

Home - Old Man Programmer

Displaying projects/sac/scripts//sac.cgi

#!/bin/sh 
#
# bob@norcom.net.au created 1998, modified frequently.
# a cgi interface for sac.cgi
# I use in the following way
# Set up a secure realm on your web server, ie a directory 
# that requires a user to authenticate with a password
# see your web server for details
#
# this authentication is compared to what is input on the form
# so either an accounts user can access all details
# or a user can only access their own details.
#
# I currently run on radius server, and manipulate the radwtmp logs
# As I roll over the radwtmp logs monthly, I them put 3Months plus 
# current months data together for a user to see.
#
# I add extra accounting data into the output page for my clients
#
# Use all care as it may be insecure!
#
# plan on adding additional form fields for dates etc...
#
# Please feel free to modify and send me a copy!
# please write comments here
#
# Please change the html if you use this script
#

Date=`/bin/date`
read postinput

Name=`echo $postinput |cut -f2 -d=|cut -f1 -d \&`


DATA="/var/adm/OLD/radwtmp_temp"
FILE1="/var/adm/radwtmp"
FILE2="/var/adm/OLD/radwtmp.0"
FILE3="/var/adm/OLD/radwtmp.1"
FILE4="/var/adm/OLD/radwtmp.2"
radwtmp_temp="/var/adm/OLD/radwtmp_temp"

cat $FILE4 > $radwtmp_temp
cat $FILE3 >> $radwtmp_temp
cat $FILE2 >> $radwtmp_temp
CAT $FILE1 >> $radwtmp_temp

Trusted="accounts"

echo Content-type: text/html
echo

exec 2>&1
if [ "$Name" != "$REMOTE_USER" ]; then
if [ "$Trusted" != "$REMOTE_USER" ]; then

  cat << ERROR
<HTML>
<Head>
<Title> Error: Access Violation </Title>

</Head>
<Body bgcolor=red>
<H1> ERROR: You Tried to access Priviledged Information. </H1><br>
You did not enter your username or Your attempt to access account information for someone other than yourself has failed.<p>
This attempt has been logged and the webmaster has been alerted.
<hr>
Return to <a href="http://www.norcom.net.au">Pilbara Systems</a> main
website or the <a href="http://www2.norcom.net.au/accounting/index.html">Previous Page</a>
<p><h4><i>Page &copy; Pilbara Systems
Internet</i></h4><p>
</Body>
</HTML>
ERROR
exit 1
  
else

cat << HEADER
<HTML>
<Head>
<Title> Your daily usage </Title>

</Head>
<Body background="http://www2.norcom.net.au/yback.jpg">
<center><h1> Usage Summary</h1></center>
<p><font size="2">
<listing>
HEADER

echo ""
echo "Usage summary for " $Name 
echo ""
echo "$FILE1"
echo ""
/usr/local/bin/sac  -w $DATA -ad -u "$Name"
echo ""
/usr/local/bin/sac  -w $DATA -a -u "$Name"


cat << FOOTER
</listing></font>
<hr>
Return to <a href="http://www.norcom.net.au">Pilbara Systems</a> main
website or the <a href="http://www2.norcom.net.au/accounting/index.html">Previous Page</a>
<p><h4><i>Page &copy; Pilbara Systems
Internet</i></h4><p>

</Body>
</HTML>
FOOTER
exit 0
fi 

  cat << ERROR
<HTML>
<Head>
<Title> Error: Access Violation </Title>

</Head>
<Body bgcolor=red>
<H1> ERROR: You Tried to access Priviledged Information. </H1><br>
You did not enter your username or Your attempt to access account information for someone other than yourself has failed.<p>
This attempt has been logged and the webmaster has been alerted.
<hr>
Return to <a href="http://www.norcom.net.au">Pilbara Systems</a> main
website or the <a href="http://www2.norcom.net.au/accounting/index.html">Previous Page</a>
<p><h4><i>Page &copy; Pilbara Systems
Internet</i></h4><p>
</Body>
</HTML>
ERROR
  exit 1
else

cat << HEADER
<HTML>
<Head>
<Title> Your daily usage </Title>

</Head>
<Body background="http://www2.norcom.net.au/yback.jpg">
<center><h2> Pilbara Systems Account Summary Page</h2></center><p>

Your daily usage is:<p>
<listing><font size="2">
HEADER
echo ""
echo $Name "At " $Date " "
echo ""
echo ""

/usr/local/bin/sac  -w $DATA -ad -u "$Name";
echo ""
/usr/local/bin/sac -w $DATA -a -u "$Name";
echo ""
echo " Your account details are as follows:"
echo ""
grep -w $Name /.staff/accounts/account_file 
echo ""

cat << FOOTER
</listing><font>
Following are some details regarding your account expiry date and type.<p>
The expiry date is in the format YYMMDD (Year, Month, Day) and the symbol ( + ^ ! B ) indicates your account type
with the following meaning:<br>
+ is basic<br>
^ is extended basic<br>
! is flat<p>

B is business<br>
P is Remote Premium<br>
C is City Premium<br>
Q is the 100/100<br>
E is 12hrs/mth <br>
M is EMail only<p>


For more information on account types please see our <a href="http://www.norcom.net.au/prices.html">Prices Page</a><p>

<hr>
Return to <a href="http://www.norcom.net.au">dotnet dotau</a> main
website or the <a href="http://www2.norcom.net.au/accounting/index.html">Previous Page</a>
<p><h4><i>Page &copy; dotnet dotau Pty Ltd</i></h4><p>

</Body>
</HTML>
FOOTER
exit 0
fi