#!/usr/bin/php-cgi
<?php
//joey
//##89f23112eeab23

session_start();

$user  = $_REQUEST['user'];
$RETRY = 30;
$in_out_octet   = 0;

while ($ctr < $RETRY)
{
                exec("chilli_query list", $tokens);
                //print_r($tokens);
                //echo "\n\n";
                for ($i = 0; $i < count($tokens); $i++)
                {
                        $inf = explode(" ", $tokens[$i]);
                        //print_r($inf);
                        if ($inf[4] == 1)
                        {
                                if (strcmp($inf[5], $user) == 0)
                                {
                                    //echo "Found:" . $inf[5] . "<br>";
                                        $in_out_octet = $inf[8] . ":" . $inf[9]; 
										$ctr = $RETRY;
                                        $_SESSION['inoutoctets'] = $int_out_octet;
                                }
                        }
                }

                $ctr++;
}

echo $in_out_octet;

?>
