]> git.gsnw.org Git - m0n0chwall.git/commitdiff
Reduce looping for session lookups. (speeds things up)
authorjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Fri, 21 Apr 2006 10:56:20 +0000 (10:56 +0000)
committerjdegraeve <jdegraeve@e36fee2c-cc09-0410-a7cc-ebac5c6737de>
Fri, 21 Apr 2006 10:56:20 +0000 (10:56 +0000)
git-svn-id: https://svn.m0n0.ch/wall/trunk@134 e36fee2c-cc09-0410-a7cc-ebac5c6737de

captiveportal/index.php

index e331d9655a50bee1cdbadb6e6c9a9a53907b33b9..829f9f57ff65e99f3007ea31b1165532f4556ad0 100755 (executable)
@@ -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)) {