if (!is_numeric($remaining)) {
         $remaining = $session_limit;
     }
     if ($remaining > $session_limit) {
         $remaining = $session_limit;
     }
 }
 $search = @da_sql_query($link, $config, "SELECT " . da_sql_limit(1, 0, $config) . " * FROM {$config['sql_accounting_table']}\n\tWHERE username = '******' AND acctstoptime IS NULL " . da_sql_limit(1, 1, $config) . "\n\t ORDER BY acctstarttime DESC " . da_sql_limit(1, 2, $config) . " ;");
 if ($search) {
     if (@da_sql_num_rows($search, $config)) {
         $logged_now = 1;
         $row = @da_sql_fetch_array($search, $config);
         $lastlog_time = $row['acctstarttime'];
         $lastlog_server_ip = $row['nasipaddress'];
         $lastlog_server_port = $row['nasportid'];
         $lastlog_session_time = date2timediv($lastlog_time, 0);
         if ($daily_limit != 'none') {
             $remaining = $remaining - $lastlog_session_time;
             if ($remaining < 0) {
                 $remaining = 0;
             }
             $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_server_name = @gethostbyaddr($lastlog_server_ip);
         $lastlog_client_name = @gethostbyaddr($lastlog_client_ip);
         $lastlog_callerid = $row['callingstationid'];
         if ($lastlog_callerid == '') {
             $lastlog_callerid = 'not available';
         $num = $row[onlineusers];
     }
 }
 $search = @da_sql_query($link, $config, "SELECT DISTINCT username,acctstarttime,framedipaddress,callingstationid\n\t\tFROM {$config['sql_accounting_table']} WHERE\n\t\tacctstoptime IS NULL AND nasipaddress = '{$name_data}' {$extra} {$sql_extra_query}\n\t\tGROUP BY username,acctstarttime,framedipaddress,callingstationid\n\t\tORDER BY acctstarttime;");
 if ($search) {
     $now = time();
     while ($row = @da_sql_fetch_array($search, $config)) {
         $j++;
         $h += 21;
         $user = $row['username'];
         $finger_info[$servers_num][$j]['ip'] = $row['framedipaddress'];
         if ($finger_info[$servers_num][$j]['ip'] == '') {
             $finger_info[$servers_num][$j]['ip'] = '-';
         }
         $session_time = $row['acctstarttime'];
         $session_time = date2timediv($session_time, $now);
         $finger_info[$servers_num][$j]['session_time'] = time2strclock($session_time);
         $finger_info[$servers_num][$j]['user'] = $user;
         $finger_info[$servers_num][$j]['callerid'] = $row['callingstationid'];
         if ($finger_info[$servers_num][$j]['callerid'] == '') {
             $finger_info[$servers_num][$j]['callerid'] = '-';
         }
         if ($user_info["{$user}"] == '') {
             $user_info["{$user}"] = get_user_info($link2, $user, $config, $decode_normal, $k);
             if ($user_info["{$user}"] == '' || $user_info["{$user}"] == ' ') {
                 $user_info["{$user}"] = 'Unknown User';
             }
         }
     }
     $height[$servers_num] = $h;
 }