เครดิตท่าน koko2330 แห่งเวบ www.linuxthai.org
vi /usr/local/etc/radiusd.conf
บรรทัดที่ ~2003
#
# Accounting. Log the accounting data.
#
accounting {
#
# Create a 'detail'ed log of the packets.
# Note that accounting requests which are proxied
# are also logged in the detail file.
detail
# daily
# Update the wtmp file
#
# If you don't use "radlast", you can delete this line.
# unix
#
# For Simultaneous-Use tracking.
#
# Due to packet losses in the network, the data here
# may be incorrect. There is little we can do about it.
# radutmp
# sradutmp
# Return an address to the IP Pool when we see a stop record.
# main_pool
# sqlippool
#
# Log traffic to an SQL database.
#
# See "Accounting queries" in sql.conf
sql
#
# Instead of sending the query to the SQL server,
# write it into a log file.
#
# sql_log
# Cisco VoIP specific bulk accounting
# pgsql-voip
}
แค่นี้ ข้อมูล User ก็จะไม่เก็บไว้ใน Text File แต่จะเก็บไว้ใน Mysql ที่ เวลา = 0000-00-00 00:00:00 หมายถึงเวลของคนที่ออนไลน์
แล้วสร้างไฟล์ xxx.php ให้มีเนื้อหาตามนี้
โค๊ด:
ob_start();
include("include/class.mysqldb.php");
include("include/config.inc.php");
$uday = date("Y-m-d");
$sql2 = "SELECT * from radacct where AcctStopTime = '0000-00-00 00:00:00'";
$result2 = mysql_query($sql2);
while($data = mysql_fetch_object($result2)) {
$user = $data->UserName;
passthru("/bin/echo 'User-Name = $user' | /usr/local/bin/radclient -x localhost:3799 disconnect testing123");
$sql = "UPDATE radacct SET AcctStopTime='$uday 00:00:00' where ((AcctStopTime = '0000-00-00 00:00:00') and (UserName='$usus'))";
$result = mysql_query($sql);
}
$sql3 = "DELETE from radacct where AcctStopTime = '0000-00-00 00:00:00'";
$result3 = mysql_query($sql3);
exit();
?>
ไม่มีความคิดเห็น:
แสดงความคิดเห็น