From: jdegraeve Date: Fri, 21 Apr 2006 10:56:20 +0000 (+0000) Subject: Reduce looping for session lookups. (speeds things up) X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=208259a0f071db096f7c679e0567ebb3da4f40ff;p=m0n0chwall.git Reduce looping for session lookups. (speeds things up) git-svn-id: https://svn.m0n0.ch/wall/trunk@134 e36fee2c-cc09-0410-a7cc-ebac5c6737de --- diff --git a/captiveportal/index.php b/captiveportal/index.php index e331d96..829f9f5 100755 --- a/captiveportal/index.php +++ b/captiveportal/index.php @@ -257,28 +257,24 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut $radiusservers = captiveportal_get_radius_servers(); - /* Find an existing session on a different ip with the same username */ - - if ((isset($config['captiveportal']['noconcurrentlogins'])) && ($username != 'unauthenticated')) { - /* find duplicate entry */ - for ($i = 0; $i < count($cpdb); $i++) { - if (($cpdb[$i][2] != $clientip) && ($cpdb[$i][4] == $username)) { - /* This user was already logged in so we disconnect the old one */ - captiveportal_disconnect($cpdb[$i],$radiusservers, 13); - captiveportal_logportalauth($cpdb[$i][4],$cpdb[$i][3],$cpdb[$i][2],"CONCURRENT LOGIN - TERMINATING OLD SESSION"); - unset($cpdb[$i]); - break; - } - } - } - - /* Find an existing session on the same ip and reuse it */ + /* Find an existing session */ for ($i = 0; $i < count($cpdb); $i++) { + /* on the same ip */ if($cpdb[$i][2] == $clientip) { captiveportal_logportalauth($cpdb[$i][4],$cpdb[$i][3],$cpdb[$i][2],"CONCURRENT LOGIN - REUSING OLD SESSION"); $sessionid = $cpdb[$i][5]; break; } + elseif ((isset($config['captiveportal']['noconcurrentlogins'])) && ($username != 'unauthenticated')) { + /* on the same username */ + if ($cpdb[$i][4] == $username) { + /* This user was already logged in so we disconnect the old one */ + captiveportal_disconnect($cpdb[$i],$radiusservers,13); + captiveportal_logportalauth($cpdb[$i][4],$cpdb[$i][3],$cpdb[$i][2],"CONCURRENT LOGIN - TERMINATING OLD SESSION"); + unset($cpdb[$i]); + break; + } + } } if (!isset($sessionid)) {