[Serusers] Accounting Script

jh at lohi.eng.song.fi jh at lohi.eng.song.fi
Wed Mar 26 20:30:35 CET 2003


here is how i get the information of calls made by a user as identified
by the user's nai (username + realm) from radius accounting records that
i store in mysql database.

-- juha

/* Get call records of a user */
function vsp_getCalls($nai) {
  $calls = array();
  $call = array();
  vsp_connect();
  $result = mysql_query("SELECT t1.fromUri, t1.toUri, t1.date, (sec_to_time(unix_timestamp(t2.date)-unix_timestamp(t1.date))) AS duration FROM radacct AS t1, radacct AS t2 WHERE t1.nai = '$nai' AND t1.method = 'INVITE' AND t2.method = 'BYE' and t1.callId = t2.callId ORDER BY t1.date DESC") or die ("<h1 align=center>Cannot access accounting information!</h1>");
  while ( $call = mysql_fetch_array( $result ) ) {
    $calls[] = $call;
  }
  //  print_r(array_values($calls));
  vsp_close();
  return $calls;
}




More information about the sr-users mailing list