From: kkalev Date: Sun, 29 Sep 2002 11:39:42 +0000 (+0000) Subject: * In lib/ldap/functions.php3 only ask for the cn attribute in ldap_search not the... X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=3d9f16188c78b48baaf843dc936dce73756e2ea8;p=freeradius-dialup-admin.git * In lib/ldap/functions.php3 only ask for the cn attribute in ldap_search not the whole entry. That should make user_finger a lot faster when the user database is in ldap * In lib/functions.php3 pass a second argument to date2timediv with the current time. user_finger calls that function for each online user so we now don't need to do a lot of calls to time() but only one. That should make user_finger somewhat faster. --- diff --git a/Changelog b/Changelog index 21f3c34..701231f 100644 --- a/Changelog +++ b/Changelog @@ -14,6 +14,11 @@ Ver 1.60: * html fixes in accounting.php3 * Fix a problem in user_accounting when NASIPAddress is not set. * Use CISCO-AAA-SESSION-MIB in snmpfinger +* In lib/ldap/functions.php3 only ask for the cn attribute in ldap_search not the whole entry. That should make + user_finger a lot faster when the user database is in ldap +* In lib/functions.php3 pass a second argument to date2timediv with the current time. user_finger calls that + function for each online user so we now don't need to do a lot of calls to time() but only one. That should make + user_finger somewhat faster. Ver 1.59: * Small html fixes in user_edit.php3 and password.php3 * Show number of failed logins in the last 7 days in the user admin page diff --git a/htdocs/user_admin.php3 b/htdocs/user_admin.php3 index 7031202..e6491fc 100644 --- a/htdocs/user_admin.php3 +++ b/htdocs/user_admin.php3 @@ -170,7 +170,7 @@ if ($link){ $lastlog_time = $row['AcctStartTime']; $lastlog_server_ip = $row['NASIPAddress']; $lastlog_server_port = $row['NASPortId']; - $lastlog_session_time = date2timediv($lastlog_time); + $lastlog_session_time = date2timediv($lastlog_time,0); if ($daily_limit != 'none'){ $remaining = $remaining - $lastlog_session_time; if ($remaining < 0) diff --git a/htdocs/user_finger.php3 b/htdocs/user_finger.php3 index 35a1419..9d24205 100644 --- a/htdocs/user_finger.php3 +++ b/htdocs/user_finger.php3 @@ -74,6 +74,7 @@ if ($link){ AcctStopTime = '0' AND NASIPAddress = '$name_data' $extra GROUP BY UserName ORDER BY AcctStartTime;"); if ($search){ + $now = time(); while($row = @da_sql_fetch_array($search,$config)){ $num++; $h += 21; @@ -82,7 +83,7 @@ if ($link){ if ($finger_info[$servers_num][$num]['ip'] == '') $finger_info[$servers_num][$num]['ip'] = '-'; $session_time = $row['AcctStartTime']; - $session_time = date2timediv($session_time); + $session_time = date2timediv($session_time,$now); $finger_info[$servers_num][$num]['session_time'] = time2strclock($session_time); $finger_info[$servers_num][$num]['user'] = $user; $finger_info[$servers_num][$num]['callerid'] = $row['CallingStationId']; diff --git a/lib/functions.php3 b/lib/functions.php3 index 1a60c1f..88cd197 100644 --- a/lib/functions.php3 +++ b/lib/functions.php3 @@ -64,13 +64,14 @@ function time2strclock($time) return $ret; } -function date2timediv($date) +function date2timediv($date,$now) { list($day,$time)=explode(' ',$date); $day = explode('-',$day); $time = explode(':',$time); $timest = mktime($time[0],$time[1],$time[2],$day[1],$day[2],$day[0]); - $now = time(); + if (!$now) + $now = time(); return ($now - $timest); } diff --git a/lib/ldap/functions.php3 b/lib/ldap/functions.php3 index d480bf3..14481f4 100644 --- a/lib/ldap/functions.php3 +++ b/lib/ldap/functions.php3 @@ -38,7 +38,8 @@ function connect2db($config) function get_user_info($ds,$user,$config) { if ($ds){ - $sr=@ldap_search($ds,"$config[ldap_base]", "uid=" . $user); + $attrs = array('cn'); + $sr=@ldap_search($ds,"$config[ldap_base]", "uid=" . $user,$attrs); $info = @ldap_get_entries($ds, $sr); $cn = $info[0]["cn"][0]; if ($cn == '')