#!/bin/sh
LOGIN=$1
IP=$2
CASH=$3
ID=$4

fwcmd="/sbin/ipfw -q"


cur_date=`date \+\%Y.\%m.\%d`
cur_time=`date \+\%H:\%M:\%S`


# DELETE OLD PIPES
${fwcmd} pipe `expr $ID + 101` delete
${fwcmd} pipe `expr $ID + 18101` delete

# DELETE FROM SHAPER
${fwcmd} table 3 delete $IP
${fwcmd} table 4 delete $IP

${fwcmd} table 47 add $IP


# DAY/NIGHT switcher
/bin/rm /etc/stargazer/dn/$LOGIN


echo "$cur_date $cur_time DISCONNECT: ID-$ID;LOGIN-$LOGIN;IP-$IP;CASH-$CASH" >> /var/stargazer/allconnect.log
