วันศุกร์ที่ 18 กันยายน พ.ศ. 2552

แก้ยูเซอร์ค้างในระบบอย่างถาวร..จากเวบ linuxthai.org

เครดิตท่าน 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();

?>

ปรับแก้ม.บูรพาเพื่อคุม upload/download

Bandwidth ทะลุของม.บูรพาปรับให้สามารถคุมอัพโหลดดาว์นโหลดได้ จากเวบ linuxthai.org
ใน file manage_group.php มันมีบางที่ *1024*8 จริง ๆ แค่ *1024 ก็พอ (รึเปล่า ฮืม)
if($newdown != 0) {
$down = $newdown * 1024 * 8;
$sql = "insert into radgroupreply values ('', 'group".$_REQUEST['newgname']."', 'WISPr-Bandwidth-Max-Down', ':=', '$down')";

มันมี *8 มาด้วย
ทำให้เวลาบันทึกลง Database ค่ามันเลยสูงครับ
เช่น กำหนด Download 512 = 512*1024*8 = 4,194,304
512 = 512*1024 = 524,288 (ค่าที่ถูกต้อง)

ลองแล้ว Bandwidth Download ไม่ทะลุแล้วครับ
แต่ upload ทะลุอยู่ครั