function testBytes2Str() { $arr = array('0.9B', '1B', '1.1B', '921.6B', '1KB', '1.1KB', '921.6KB', '1MB', '1.1MB', '921.6MB', '1GB', '1.1GB', '921.6GB', '1TB', '1.1TB', '921.6TB', '1PB', '1.1PB', '921.6PB', '1EB', '1.1EB', '921.6EB', '1ZB', '1.1ZB', '921.6ZB', '1YB', '1.1YB'); for ($i = 0; $i < 9; $i++) { $this->equals(bytes2str(pow(1024, $i) * 0.9, 2), array_shift($arr)); $this->equals(bytes2str(pow(1024, $i), 2), array_shift($arr)); $this->equals(bytes2str(pow(1024, $i) * 1.1, 2), array_shift($arr)); } }
$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_server_name = $lastlog_server_ip != '' ? @gethostbyaddr($lastlog_server_ip) : '-'; $lastlog_client_name = $lastlog_client_ip != '' ? @gethostbyaddr($lastlog_client_ip) : '-'; $lastlog_callerid = $row['callingstationid']; if ($lastlog_callerid == '') { $lastlog_callerid = 'not available'; } $lastlog_input = $row['acctinputoctets']; $lastlog_input = bytes2str($lastlog_input); $lastlog_output = $row['acctoutputoctets']; $lastlog_output = bytes2str($lastlog_output); } else { $not_known = 1; } } else { echo "<b>Database query failed: " . da_sql_error($link, $config) . "</b><br>\n"; } } } else { echo "<b>Could not connect to SQL database</b><br>\n"; } $monthly_limit = is_numeric($monthly_limit) ? time2str($monthly_limit) : $monthly_limit; $weekly_limit = is_numeric($weekly_limit) ? time2str($weekly_limit) : $weekly_limit; $daily_limit = is_numeric($daily_limit) ? time2str($daily_limit) : $daily_limit; $session_limit = is_numeric($session_limit) ? time2str($session_limit) : $session_limit; $remaining = is_numeric($remaining) ? time2str($remaining) : $remaining;
echo "<td>{$acct_download}</td>\n"; } if ($acct_attrs[ua][7] != '') { echo "<td>{$acct_server}</td>\n"; } if ($acct_attrs[ua][8] != '') { echo "<td>{$acct_terminate_cause}</td>\n"; } if ($acct_attrs[ua][9] != '') { echo "<td>{$acct_callerid}</td>\n"; } echo "</tr>\n"; } $acct_sessiontime_sum = time2str($acct_sessiontime_sum); $acct_upload_sum = bytes2str($acct_upload_sum); $acct_download_sum = bytes2str($acct_download_sum); } else { echo "<b>Database query failed: " . da_sql_error($link, $config) . "</b><br>\n"; } } else { echo "<b>Could not connect to SQL database</b><br>\n"; } $colspan = 3; if ($acct_attrs[ua][1] == '') { $colspan--; } if ($acct_attrs[ua][2] == '') { $colspan--; } echo <<<EOM \t\t\t<tr bgcolor="lightyellow">
$num++; $acct_login = $row[username]; if ($acct_login == '') { $acct_login = '******'; } else { $Acct_login = urlencode($acct_login); $acct_login = "******"user_admin.php?login={$Acct_login}\" title=\"Edit user {$acct_login}\">{$acct_login}</a>"; } $acct_time = $row[conntotduration]; $acct_time = time2str($acct_time); $acct_conn_num = $row[connnum]; $acct_date = $row[acctdate]; $acct_upload = $row[inputoctets]; $acct_download = $row[outputoctets]; $acct_upload = bytes2str($acct_upload); $acct_download = bytes2str($acct_download); $acct_server = $da_name_cache[$row[nasipaddress]]; if (!isset($acct_server)) { $acct_server = @gethostbyaddr($row[nasipaddress]); if (!isset($da_name_cache) && $config[general_use_session] == 'yes') { $da_name_cache[$row[nasipaddress]] = $acct_server; session_register('da_name_cache'); } else { $da_name_cache[$row[nasipaddress]] = $acct_server; } } if ($acct_server == '') { $acct_server = '-'; } echo <<<EOM t<tr align=center bgcolor="white">