51,16 → 51,51 |
exit(); |
} |
|
$monthly_limit = ($item_vals['Max-Monthly-Session'][0] != '') ? $item_vals['Max-Monthly-Session'][0] : $default_vals['Max-Monthly-Session'][0]; |
$monthly_limit = ($monthly_limit) ? $monthly_limit : $config[counter_default_monthly]; |
$weekly_limit = ($item_vals['Max-Weekly-Session'][0] != '') ? $item_vals['Max-Weekly-Session'][0] : $default_vals['Max-Weekly-Session'][0]; |
$weekly_limit = ($weekly_limit) ? $weekly_limit : $config[counter_default_weekly]; |
$daily_limit = ($item_vals['Max-Daily-Session'][0] != '') ? $item_vals['Max-Daily-Session'][0] : $default_vals['Max-Daily-Session'][0]; |
$daily_limit = ($daily_limit) ? $daily_limit : $config[counter_default_daily]; |
$session_limit = ($item_vals['Session-Timeout'][0] != '') ? $item_vals['Session-Timeout'][0] : $default_vals['Session-Timeout'][0]; |
if(isset($item_vals['Max-Monthly-Session'][0]) && $item_vals['Max-Monthly-Session'][0] != ''){ |
$monthly_limit = $item_vals['Max-Monthly-Session'][0]; |
} else if (isset($default_vals['Max-Monthly-Session'][0])){ |
$monthly_limit = $default_vals['Max-Monthly-Session'][0]; |
} else { |
$monthly_limit = ''; |
} |
$monthly_limit = ($monthly_limit) ? $monthly_limit : $config['counter_default_monthly']; |
|
if(isset($item_vals['Max-Weekly-Session'][0]) && $item_vals['Max-Weekly-Session'][0] != ''){ |
$weekly_limit = $item_vals['Max-Weekly-Session'][0]; |
} else if (isset($default_vals['Max-Weekly-Session'][0])){ |
$weekly_limit = $default_vals['Max-Weekly-Session'][0]; |
} else { |
$weekly_limit = ''; |
} |
$weekly_limit = ($weekly_limit) ? $weekly_limit : $config['counter_default_weekly']; |
|
if(isset($item_vals['Max-Daily-Session'][0]) && $item_vals['Max-Daily-Session'][0] != ''){ |
$daily_limit = $item_vals['Max-Daily-Session'][0]; |
} else if (isset($default_vals['Max-Daily-Session'][0])){ |
$daily_limit = $default_vals['Max-Daily-Session'][0]; |
} else { |
$daily_limit = ''; |
} |
$daily_limit = ($daily_limit) ? $daily_limit : $config['counter_default_daily']; |
|
if(isset($item_vals['Session-Timeout'][0]) && $item_vals['Session-Timeout'][0] != ''){ |
$session_limit = $item_vals['Session-Timeout'][0]; |
} else if (isset($default_vals['Session-Timeout'][0])){ |
$session_limit = $default_vals['Session-Timeout'][0]; |
} else { |
$session_limit = ''; |
} |
$session_limit = ($session_limit) ? $session_limit : 'none'; |
$total_limit = ($item_vals['Max-All-Session'][0] != '') ? $item_vals['Max-All-Session'][0] : $default_vals['Max-All-Session'][0]; |
|
if(isset($item_vals['Max-All-Session'][0]) && $item_vals['Max-All-Session'][0] != ''){ |
$total_limit = $item_vals['Max-All-Session'][0]; |
} else if (isset($default_vals['Max-All-Session'][0])){ |
$total_limit = $default_vals['Max-All-Session'][0]; |
} else { |
$total_limit = ''; |
} |
$total_limit = ($total_limit) ? $total_limit : 'none'; |
|
$remaining = 'unlimited time'; |
$log_color = 'green'; |
|
69,12 → 104,12 |
$now_str = date("$config[sql_date_format]",$now + 86400); |
$week_str = date("$config[sql_date_format]",$week); |
$day = date('w'); |
$week_start = date($config[sql_date_format],$now - ($day)*86400); |
$month_start = date($config[sql_date_format],$now - date('j')*86400); |
$week_start = date($config['sql_date_format'],$now - ($day)*86400); |
$month_start = date($config['sql_date_format'],$now - date('j')*86400); |
$today = $day; |
$now_tmp = $now; |
for ($i = $day; $i >-1; $i--){ |
$days[$i] = date($config[sql_date_format],$now_tmp); |
$days[$i] = date($config['sql_date_format'],$now_tmp); |
$now_tmp -= 86400; |
} |
$day++; |
82,7 → 117,7 |
$now -= 604800; |
$now += 86400; |
for ($i = $day; $i <= 6; $i++){ |
$days[$i] = date($config[sql_date_format],$now); |
$days[$i] = date($config['sql_date_format'],$now); |
// $now -= 86400; |
$now += 86400; |
} |
91,9 → 126,9 |
$extra_msg = ''; |
$used = array('-','-','-','-','-','-','-'); |
|
$link = @da_sql_pconnect($config); |
$link = da_sql_pconnect($config); |
if ($link){ |
$search = @da_sql_query($link,$config, |
$search = da_sql_query($link,$config, |
"SELECT sum(acctsessiontime) AS sum_sess_time, |
sum(acctinputoctets) AS sum_in_octets, |
sum(acctoutputoctets) AS sum_out_octets, |
104,38 → 139,38 |
$config[sql_accounting_table] WHERE username = '$login' |
AND acctstarttime >= '$week_str' AND acctstarttime <= '$now_str';"); |
if ($search){ |
$row = @da_sql_fetch_array($search,$config); |
$tot_time = time2str($row[sum_sess_time]); |
$tot_input = bytes2str($row[sum_in_octets]); |
$tot_output = bytes2str($row[sum_out_octets]); |
$avg_time = time2str($row[avg_sess_time]); |
$avg_input = bytes2str($row[avg_in_octets]); |
$avg_output = bytes2str($row[avg_out_octets]); |
$tot_conns = $row[counter]; |
$row = da_sql_fetch_array($search,$config); |
$tot_time = time2str($row['sum_sess_time']); |
$tot_input = bytes2str($row['sum_in_octets']); |
$tot_output = bytes2str($row['sum_out_octets']); |
$avg_time = time2str($row['avg_sess_time']); |
$avg_input = bytes2str($row['avg_in_octets']); |
$avg_output = bytes2str($row['avg_out_octets']); |
$tot_conns = $row['counter']; |
} |
else |
echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n"; |
$search = @da_sql_query($link,$config, |
$search = da_sql_query($link,$config, |
"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE username = '$login' |
AND acctstarttime >= '$week_start' AND acctstarttime <= '$now_str';"); |
if ($search){ |
$row = @da_sql_fetch_array($search,$config); |
$weekly_used = $row[sum_sess_time]; |
$row = da_sql_fetch_array($search,$config); |
$weekly_used = $row['sum_sess_time']; |
} |
else |
echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n"; |
if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){ |
$search = @da_sql_query($link,$config, |
if ($monthly_limit != 'none' || (isset($config['counter_monthly_calculate_usage']) && $config['counter_monthly_calculate_usage'] == 'true')){ |
$search = da_sql_query($link,$config, |
"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE username = '$login' |
AND acctstarttime >= '$month_start' AND acctstarttime <= '$now_str';"); |
if ($search){ |
$row = @da_sql_fetch_array($search,$config); |
$monthly_used = $row[sum_sess_time]; |
$row = da_sql_fetch_array($search,$config); |
$monthly_used = $row['sum_sess_time']; |
} |
else |
echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n"; |
} |
$search = @da_sql_query($link,$config, |
$search = da_sql_query($link,$config, |
"SELECT COUNT(*) AS counter FROM $config[sql_accounting_table] WHERE username = '$login' |
AND acctstoptime >= '$week_str' AND acctstoptime <= '$now_str' |
AND (acctterminatecause LIKE 'Login-Incorrect%' OR |
142,8 → 177,8 |
acctterminatecause LIKE 'Invalid-User%' OR |
acctterminatecause LIKE 'Multiple-Logins%');"); |
if ($search){ |
$row = @da_sql_fetch_array($search,$config); |
$tot_badlogins = $row[counter]; |
$row = da_sql_fetch_array($search,$config); |
$tot_badlogins = $row['counter']; |
} |
else |
echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n"; |
150,19 → 185,19 |
for($i = 0; $i <=6; $i++){ |
if ($days[$i] == '') |
continue; |
$search = @da_sql_query($link,$config, |
$search = da_sql_query($link,$config, |
"SELECT sum(acctsessiontime) AS sum_sess_time FROM $config[sql_accounting_table] WHERE |
username = '$login' AND acctstoptime >= '$days[$i] 00:00:00' |
AND acctstoptime <= '$days[$i] 23:59:59';"); |
if ($search){ |
$row = @da_sql_fetch_array($search,$config); |
$used[$i] = $row[sum_sess_time]; |
$row = da_sql_fetch_array($search,$config); |
$used[$i] = $row['sum_sess_time']; |
if ($daily_limit != 'none' && $used[$i] > $daily_limit) |
$used[$i] = "<font color=red>" . time2str($used[$i]) . "</font>"; |
else |
$used[$i] = time2str($used[$i]); |
if ($today == $i){ |
$daily_used = $row[sum_sess_time]; |
$daily_used = $row['sum_sess_time']; |
if ($daily_limit != 'none'){ |
$remaining = $daily_limit - $daily_used; |
if ($remaining <=0) |
207,7 → 242,7 |
$remaining = $tmp; |
$log_color = ($remaining) ? 'green' : 'red'; |
} |
if ($monthly_limit != 'none' || $config[counter_monthly_calculate_usage] == 'true'){ |
if ($monthly_limit != 'none' || (isset($config['counter_monthly_calculate_usage']) && $config['counter_monthly_calculate_usage'] == 'true')){ |
$monthly_used = time2str($monthly_used); |
if ($monthly_limit != 'none' && !$tmp) |
$monthly_used = "<font color=red>$monthly_used</font>"; |
219,14 → 254,14 |
$remaining = $session_limit; |
} |
|
$search = @da_sql_query($link,$config, |
$search = da_sql_query($link,$config, |
"SELECT " . da_sql_limit(1,0,$config) . " * FROM $config[sql_accounting_table] |
WHERE username = '$login' AND acctstoptime IS NULL " . da_sql_limit(1,1,$config) . " |
ORDER BY acctstarttime DESC " . da_sql_limit(1,2,$config). " ;"); |
if ($search){ |
if (@da_sql_num_rows($search,$config)){ |
if (da_sql_num_rows($search,$config)){ |
$logged_now = 1; |
$row = @da_sql_fetch_array($search,$config); |
$row = da_sql_fetch_array($search,$config); |
$lastlog_time = $row['acctstarttime']; |
$lastlog_server_ip = $row['nasipaddress']; |
$lastlog_server_port = $row['nasportid']; |
235,11 → 270,11 |
$remaining = $remaining - $lastlog_session_time; |
if ($remaining < 0) |
$remaining = 0; |
$log_color = ($remaining) ? 'green' : 'red'; |
$log_color = ($remaining) ? 'green' : 'red'; |
} |
$lastlog_session_time_jvs = 1000 * $lastlog_session_time; |
$lastlog_session_time = time2strclock($lastlog_session_time); |
$lastlog_client_ip = $row['framedipaddress']; |
$lastlog_client_ip = $row['framedipaddress']; |
$lastlog_server_name = @gethostbyaddr($lastlog_server_ip); |
$lastlog_client_name = @gethostbyaddr($lastlog_client_ip); |
$lastlog_callerid = $row['callingstationid']; |
259,19 → 294,19 |
} |
else |
echo "<b>Database query failed: " . da_sql_error($link,$config) . "</b><br>\n"; |
if (! $logged_now){ |
$search = @da_sql_query($link,$config, |
if (!isset($logged_now) || !$logged_now){ |
$search = da_sql_query($link,$config, |
"SELECT " . da_sql_limit(1,0,$config) . " * FROM $config[sql_accounting_table] |
WHERE username = '$login' AND acctsessiontime != '0' " . da_sql_limit(1,1,$config) . " |
ORDER BY acctstoptime DESC " . da_sql_limit(1,2,$config). " ;"); |
if ($search){ |
if (@da_sql_num_rows($search,$config)){ |
$row = @da_sql_fetch_array($search,$config); |
if (da_sql_num_rows($search,$config)){ |
$row = da_sql_fetch_array($search,$config); |
$lastlog_time = $row['acctstarttime']; |
$lastlog_server_ip = $row['nasipaddress']; |
$lastlog_server_port = $row['nasportid']; |
$lastlog_session_time = time2str($row['acctsessiontime']); |
$lastlog_client_ip = $row['framedipaddress']; |
$lastlog_client_ip = $row['framedipaddress']; |
$lastlog_server_name = ($lastlog_server_ip != '') ? @gethostbyaddr($lastlog_server_ip) : '-'; |
$lastlog_client_name = ($lastlog_client_ip != '') ? @gethostbyaddr($lastlog_client_ip) : '-'; |
$lastlog_callerid = $row['callingstationid']; |
307,7 → 342,7 |
$msg =<<<EON |
$l_user_remain_login<font color="$log_color"> <b>$remaining $extra_msg</b></font> |
EON; |
$lock_msg = $item_vals['Dialup-Lock-Msg'][0]; |
$lock_msg = (isset($item_vals['Dialup-Lock-Msg'][0])) ? $item_vals['Dialup-Lock-Msg'][0] : ''; |
if ($lock_msg != '') |
$descr =<<<EON |
<font color=red><b>$lock_msg </b</font> |
315,7 → 350,7 |
else |
$descr = '-'; |
|
$expiration = $default_vals['Expiration'][0]; |
$expiration = isset($default_vals['Expiration'][0]) ? $default_vals['Expiration'][0] : ''; |
if ($item_vals['Expiration'][0] != '') |
$expiration = $item_vals['Expiration'][0]; |
if ($expiration != ''){ |