Changeset 1331

Show
Ignore:
Timestamp:
03/06/08 22:29:33 (7 months ago)
Author:
benoitg
Message:
  • Fix #438. Not Node::getNumOnlineUsers() will count every users connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user.
    • Network::getNumOnlineUsers() use the same counting method
    • Network.php: Reformat variables names according to coding standards.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/CHANGELOG

    r1330 r1331  
    11# $Id$ 
     22008-03-06 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
     3    * Fix #438.  Not Node::getNumOnlineUsers() will count every users connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user. 
     4        * Network::getNumOnlineUsers() use the same counting method 
     5        * Network.php:  Reformat variables names according to coding standards. 
     6         
    272008-03-02 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
    38        * Fix #431: Don't even display the Signup button if none of the networks allow signing up.  Allow Authenticators to define the signup URL themselves. 
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r1316 r1331  
    507507 
    508508        // Init values 
    509         $_retVal = true; 
     509        $retVal = true; 
    510510 
    511511        if ($value != $this->getCreationDate()) { 
    512512            $value = $db->escapeString($value); 
    513             $_retVal = $db->execSqlUpdate("UPDATE networks SET creation_date = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     513            $retVal = $db->execSqlUpdate("UPDATE networks SET creation_date = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
    514514            $this->refresh(); 
    515515        } 
    516516 
    517         return $_retVal; 
     517        return $retVal; 
    518518    } 
    519519 
     
    655655    { 
    656656        // Init values 
    657         $_authenticators = array (); 
    658         $_useCache = false; 
    659         $_cachedData = null; 
     657        $authenticators = array (); 
     658        $useCache = false; 
     659        $cachedData = null; 
    660660 
    661661        // Create new cache object with a lifetime of one week 
    662         $_cache = new Cache("AuthenticatorClasses", "ClassFileCaches", 604800); 
     662        $cache = new Cache("AuthenticatorClasses", "ClassFileCaches", 604800); 
    663663 
    664664        // Check if caching has been enabled. 
    665         if ($_cache->isCachingEnabled) { 
    666             $_cachedData = $_cache->getCachedData("mixed"); 
    667  
    668             if ($_cachedData) { 
     665        if ($cache->isCachingEnabled) { 
     666            $cachedData = $cache->getCachedData("mixed"); 
     667 
     668            if ($cachedData) { 
    669669                // Return cached data. 
    670                 $_useCache = true; 
    671                 $_authenticators = $_cachedData; 
    672             } 
    673         } 
    674  
    675         if (!$_useCache) { 
    676             $_dir = WIFIDOG_ABS_FILE_PATH."classes/Authenticators"; 
    677             $_dirHandle = @ opendir($_dir); 
    678  
    679             if ($_dirHandle) { 
     670                $useCache = true; 
     671                $authenticators = $cachedData; 
     672            } 
     673        } 
     674 
     675        if (!$useCache) { 
     676            $dir = WIFIDOG_ABS_FILE_PATH."classes/Authenticators"; 
     677            $dirHandle = @ opendir($dir); 
     678 
     679            if ($dirHandle) { 
    680680                // Loop over the directory 
    681                 while (false !== ($_filename = readdir($_dirHandle))) { 
     681                while (false !== ($filename = readdir($dirHandle))) { 
    682682                    // Loop through sub-directories of Content 
    683                     if ($_filename != '.' && $_filename != '..') { 
    684                         $_matches = null; 
    685  
    686                         if (preg_match("/^(.*)\.php$/", $_filename, $_matches) > 0) { 
     683                    if ($filename != '.' && $filename != '..') { 
     684                        $matches = null; 
     685 
     686                        if (preg_match("/^(.*)\.php$/", $filename, $matches) > 0) { 
    687687                            // Only add files containing a corresponding Authenticator class 
    688                             if (is_file("{$_dir}/{$_matches[0]}")) { 
    689                                 $_authenticators[] = $_matches[1]; 
     688                            if (is_file("{$dir}/{$matches[0]}")) { 
     689                                $authenticators[] = $matches[1]; 
    690690                            } 
    691691                        } 
     
    693693                } 
    694694 
    695                 closedir($_dirHandle); 
     695                closedir($dirHandle); 
    696696            } 
    697697            else { 
    698                 throw new Exception(_('Unable to open directory ').$_dir); 
     698                throw new Exception(_('Unable to open directory ').$dir); 
    699699            } 
    700700 
    701701            // Sort the result array 
    702             sort($_authenticators); 
     702            sort($authenticators); 
    703703 
    704704            // Check if caching has been enabled. 
    705             if ($_cache->isCachingEnabled) { 
     705            if ($cache->isCachingEnabled) { 
    706706                // Save results into cache, because it wasn't saved into cache before. 
    707                 $_cache->saveCachedData($_authenticators, "mixed"); 
    708             } 
    709         } 
    710  
    711         return $_authenticators; 
     707                $cache->saveCachedData($authenticators, "mixed"); 
     708            } 
     709        } 
     710 
     711        return $authenticators; 
    712712    } 
    713713 
     
    730730 
    731731        // Init values 
    732         $_authenticators = array (); 
    733  
    734         foreach (self :: getAvailableAuthenticators() as $_authenticator) { 
    735             $_authenticators[] = array ($_authenticator, $_authenticator); 
    736         } 
    737  
    738         $_name = $user_prefix; 
     732        $authenticators = array (); 
     733 
     734        foreach (self :: getAvailableAuthenticators() as $authenticator) { 
     735            $authenticators[] = array ($authenticator, $authenticator); 
     736        } 
     737 
     738        $name = $user_prefix; 
    739739 
    740740        if ($pre_selected_authenticator) { 
    741             $_selectedID = $pre_selected_authenticator; 
     741            $selectedID = $pre_selected_authenticator; 
    742742        } 
    743743        else { 
    744             $_selectedID = null; 
    745         } 
    746  
    747         $_html = FormSelectGenerator :: generateFromArray($_authenticators, $_selectedID, $_name, null, false); 
    748  
    749         return $_html; 
     744            $selectedID = null; 
     745        } 
     746 
     747        $html = FormSelectGenerator :: generateFromArray($authenticators, $selectedID, $name, null, false); 
     748 
     749        return $html; 
    750750    } 
    751751 
     
    10261026 
    10271027        // Init values 
    1028         $_map_types = array (array ("G_NORMAL_MAP", _("Map")), array ("G_SATELLITE_MAP", _("Satellite")), array ("G_HYBRID_MAP", _("Hybrid"))); 
    1029  
    1030         $_name = $user_prefix; 
     1028        $map_types = array (array ("G_NORMAL_MAP", _("Map")), array ("G_SATELLITE_MAP", _("Satellite")), array ("G_HYBRID_MAP", _("Hybrid"))); 
     1029 
     1030        $name = $user_prefix; 
    10311031 
    10321032        if ($pre_selected_map_type) { 
    1033             $_selectedID = $pre_selected_map_type; 
     1033            $selectedID = $pre_selected_map_type; 
    10341034        } 
    10351035        else { 
    1036             $_selectedID = null; 
    1037         } 
    1038  
    1039         $_html = FormSelectGenerator :: generateFromArray($_map_types, $_selectedID, $_name, null, false); 
    1040  
    1041         return $_html; 
     1036            $selectedID = null; 
     1037        } 
     1038 
     1039        $html = FormSelectGenerator :: generateFromArray($map_types, $selectedID, $name, null, false); 
     1040 
     1041        return $html; 
    10421042    } 
    10431043 
     
    10781078 
    10791079        // Init values 
    1080         $_retval = 0; 
    1081         $_row = null; 
    1082         $_useCache = false; 
    1083         $_cachedData = null; 
     1080        $retval = 0; 
     1081        $row = null; 
     1082        $useCache = false; 
     1083        $cachedData = null; 
    10841084 
    10851085        // Create new cache objects (valid for 1 minute) 
    1086         $_cache = new Cache('network_'.$this->_id.'_num_users', $this->_id, 60); 
     1086        $cache = new Cache('network_'.$this->_id.'_num_users', $this->_id, 60); 
    10871087 
    10881088        // Check if caching has been enabled. 
    1089         if ($_cache->isCachingEnabled) { 
    1090             $_cachedData = $_cache->getCachedData(); 
    1091  
    1092             if ($_cachedData) { 
     1089        if ($cache->isCachingEnabled) { 
     1090            $cachedData = $cache->getCachedData(); 
     1091 
     1092            if ($cachedData) { 
    10931093                // Return cached data. 
    1094                 $_useCache = true; 
    1095                 $_retval = $_cachedData; 
    1096             } 
    1097         } 
    1098  
    1099         if (!$_useCache) { 
     1094                $useCache = true; 
     1095                $retval = $cachedData; 
     1096            } 
     1097        } 
     1098 
     1099        if (!$useCache) { 
    11001100            // Get number of users 
    1101             $_network_id = $db->escapeString($this->_id); 
    1102             $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_origin='$_network_id'", $_row, false); 
     1101            $network_id = $db->escapeString($this->_id); 
     1102            $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_origin='$network_id'", $row, false); 
    11031103 
    11041104            // String has been found 
    1105             $_retval = $_row['count']; 
     1105            $retval = $row['count']; 
    11061106 
    11071107            // Check if caching has been enabled. 
    1108             if ($_cache->isCachingEnabled) { 
     1108            if ($cache->isCachingEnabled) { 
    11091109                // Save data into cache, because it wasn't saved into cache before. 
    1110                 $_cache->saveCachedData($_retval); 
    1111             } 
    1112         } 
    1113  
    1114         return $_retval; 
     1110                $cache->saveCachedData($retval); 
     1111            } 
     1112        } 
     1113 
     1114        return $retval; 
    11151115    } 
    11161116 
     
    11261126 
    11271127        // Init values 
    1128         $_retval = 0; 
    1129         $_row = null; 
    1130         $_useCache = false; 
    1131         $_cachedData = null; 
     1128        $retval = 0; 
     1129        $row = null; 
     1130        $useCache = false; 
     1131        $cachedData = null; 
    11321132 
    11331133        // Create new cache objects (valid for 1 minute) 
    1134         $_cache = new Cache('network_'.$this->_id.'_num_valid_users', $this->_id, 60); 
     1134        $cache = new Cache('network_'.$this->_id.'_num_valid_users', $this->_id, 60); 
    11351135 
    11361136        // Check if caching has been enabled. 
    1137         if ($_cache->isCachingEnabled) { 
    1138             $_cachedData = $_cache->getCachedData(); 
    1139  
    1140             if ($_cachedData) { 
     1137        if ($cache->isCachingEnabled) { 
     1138            $cachedData = $cache->getCachedData(); 
     1139 
     1140            if ($cachedData) { 
    11411141                // Return cached data. 
    1142                 $_useCache = true; 
    1143                 $_retval = $_cachedData; 
    1144             } 
    1145         } 
    1146  
    1147         if (!$_useCache) { 
     1142                $useCache = true; 
     1143                $retval = $cachedData; 
     1144            } 
     1145        } 
     1146 
     1147        if (!$useCache) { 
    11481148            // Get number of valid users 
    1149             $_network_id = $db->escapeString($this->_id); 
    1150             $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_status = ".ACCOUNT_STATUS_ALLOWED." AND account_origin='$_network_id'", $_row, false); 
     1149            $network_id = $db->escapeString($this->_id); 
     1150            $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_status = ".ACCOUNT_STATUS_ALLOWED." AND account_origin='$network_id'", $row, false); 
    11511151            // String has been found 
    1152             $_retval = $_row['count']; 
     1152            $retval = $row['count']; 
    11531153 
    11541154            // Check if caching has been enabled. 
    1155             if ($_cache->isCachingEnabled) { 
     1155            if ($cache->isCachingEnabled) { 
    11561156                // Save data into cache, because it wasn't saved into cache before. 
    1157                 $_cache->saveCachedData($_retval); 
    1158             } 
    1159         } 
    1160  
    1161         return $_retval; 
    1162     } 
    1163  
    1164     /** 
    1165      * Find out how many users are online on the entire network or at a 
    1166      * specific Hotspot on the network 
    1167      * 
     1157                $cache->saveCachedData($retval); 
     1158            } 
     1159        } 
     1160 
     1161        return $retval; 
     1162    } 
     1163 
     1164    /** 
     1165     * Find out how many users are connected on the entire network 
     1166     * Counts every user account connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user 
    11681167     * @return int Number of online users 
    11691168     */ 
     
    11741173 
    11751174        // Init values 
    1176         $_retval = 0; 
    1177         $_row = null; 
    1178         $_useCache = false; 
    1179         $_cachedData = null; 
     1175        $retval = 0; 
     1176        $row = null; 
     1177        $useCache = false; 
     1178        $cachedData = null; 
    11801179 
    11811180        // Create new cache objects (valid for 1 minute) 
    1182         $_cache = new Cache('network_'.$this->_id.'_num_online_users', $this->_id, 60); 
     1181        $cache = new Cache('network_'.$this->_id.'_num_online_users', $this->_id, 60); 
    11831182 
    11841183        // Check if caching has been enabled. 
    1185         if ($_cache->isCachingEnabled) { 
    1186             $_cachedData = $_cache->getCachedData(); 
    1187  
    1188             if ($_cachedData) { 
     1184        if ($cache->isCachingEnabled) { 
     1185            $cachedData = $cache->getCachedData(); 
     1186 
     1187            if ($cachedData) { 
    11891188                // Return cached data. 
    1190                 $_useCache = true; 
    1191                 $_retval = $_cachedData; 
    1192             } 
    1193         } 
    1194  
    1195         if (!$_useCache) { 
     1189                $useCache = true; 
     1190                $retval = $cachedData; 
     1191            } 
     1192        } 
     1193 
     1194        if (!$useCache) { 
    11961195            // Get number of online users 
    1197             $_network_id = $db->escapeString($this->_id); 
    1198             $db->execSqlUniqueRes("SELECT COUNT(conn_id) FROM connections NATURAL JOIN nodes JOIN networks ON (nodes.network_id=networks.network_id AND networks.network_id='$_network_id') "."WHERE connections.token_status='".TOKEN_INUSE."' ", $_row, false); 
     1196            $network_id = $db->escapeString($this->_id); 
     1197            $splashOnlyUserId = $this->getSplashOnlyUser()->getId(); 
     1198            $sql = "SELECT ((SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections NATURAL JOIN nodes JOIN networks ON (nodes.network_id=networks.network_id AND networks.network_id='$network_id') WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND users.user_id!='{$splashOnlyUserId}') + (SELECT COUNT(DISTINCT connections.user_mac) as count FROM users,connections NATURAL JOIN nodes JOIN networks ON (nodes.network_id=networks.network_id AND networks.network_id='$network_id') WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND users.user_id='{$splashOnlyUserId}')) AS count"; 
     1199            $db->execSqlUniqueRes($sql, $row, false); 
     1200 
     1201            $retval = $row['count']; 
     1202 
     1203            // Check if caching has been enabled. 
     1204            if ($cache->isCachingEnabled) { 
     1205                // Save data into cache, because it wasn't saved into cache before. 
     1206                $cache->saveCachedData($retval); 
     1207            } 
     1208        } 
     1209 
     1210        return $retval; 
     1211    } 
     1212 
     1213    /** 
     1214     * Find out how many nodes are registered in this networks's database 
     1215     * 
     1216     * @return int Number of nodes 
     1217     */ 
     1218    public function getNumNodes() 
     1219    { 
     1220 
     1221        $db = AbstractDb::getObject(); 
     1222 
     1223        // Init values 
     1224        $retval = 0; 
     1225        $row = null; 
     1226        $useCache = false; 
     1227        $cachedData = null; 
     1228 
     1229        // Create new cache objects (valid for 5 minutes) 
     1230        $cache = new Cache('network_'.$this->_id.'_num_nodes', $this->_id, 300); 
     1231 
     1232        // Check if caching has been enabled. 
     1233        if ($cache->isCachingEnabled) { 
     1234            $cachedData = $cache->getCachedData(); 
     1235 
     1236            if ($cachedData) { 
     1237                // Return cached data. 
     1238                $useCache = true; 
     1239                $retval = $cachedData; 
     1240            } 
     1241        } 
     1242 
     1243        if (!$useCache) { 
     1244            // Get number of nodes 
     1245            $network_id = $db->escapeString($this->_id); 
     1246            $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$network_id'", $row, false); 
    11991247 
    12001248            // String has been found 
    1201             $_retval = $_row['count']; 
     1249            $retval = $row['count']; 
    12021250 
    12031251            // Check if caching has been enabled. 
    1204             if ($_cache->isCachingEnabled) { 
     1252            if ($cache->isCachingEnabled) { 
    12051253                // Save data into cache, because it wasn't saved into cache before. 
    1206                 $_cache->saveCachedData($_retval); 
    1207             } 
    1208         } 
    1209  
    1210         return $_retval; 
    1211     } 
    1212  
    1213     /** 
    1214      * Find out how many nodes are registered in this networks's database 
    1215      * 
    1216      * @return int Number of nodes 
    1217      */ 
    1218     public function getNumNodes() 
    1219     { 
    1220  
    1221         $db = AbstractDb::getObject(); 
    1222  
    1223         // Init values 
    1224         $_retval = 0; 
    1225         $_row = null; 
    1226         $_useCache = false; 
    1227         $_cachedData = null; 
     1254                $cache->saveCachedData($retval); 
     1255            } 
     1256        } 
     1257 
     1258        return $retval; 
     1259    } 
     1260 
     1261    /** 
     1262     * Find out how many nodes are deployed in this networks's database 
     1263     * 
     1264     * @return int Number of deployed nodes 
     1265     */ 
     1266    public function getNumDeployedNodes() 
     1267    { 
     1268 
     1269        $db = AbstractDb::getObject(); 
     1270 
     1271        // Init values 
     1272        $retval = 0; 
     1273        $row = null; 
     1274        $useCache = false; 
     1275        $cachedData = null; 
    12281276 
    12291277        // Create new cache objects (valid for 5 minutes) 
    1230         $_cache = new Cache('network_'.$this->_id.'_num_nodes', $this->_id, 300); 
     1278        $cache = new Cache('network_'.$this->_id.'_num_deployed_nodes', $this->_id, 300); 
    12311279 
    12321280        // Check if caching has been enabled. 
    1233         if ($_cache->isCachingEnabled) { 
    1234             $_cachedData = $_cache->getCachedData(); 
    1235  
    1236             if ($_cachedData) { 
     1281        if ($cache->isCachingEnabled) { 
     1282            $cachedData = $cache->getCachedData(); 
     1283 
     1284            if ($cachedData) { 
    12371285                // Return cached data. 
    1238                 $_useCache = true; 
    1239                 $_retval = $_cachedData; 
    1240             } 
    1241         } 
    1242  
    1243         if (!$_useCache) { 
    1244             // Get number of nodes 
    1245             $_network_id = $db->escapeString($this->_id); 
    1246             $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id'", $_row, false); 
     1286                $useCache = true; 
     1287                $retval = $cachedData; 
     1288            } 
     1289        } 
     1290 
     1291        if (!$useCache) { 
     1292            // Get number of deployed nodes 
     1293            $network_id = $db->escapeString($this->_id); 
     1294            $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE')", $row, false); 
    12471295 
    12481296            // String has been found 
    1249             $_retval = $_row['count']; 
     1297            $retval = $row['count']; 
    12501298 
    12511299            // Check if caching has been enabled. 
    1252             if ($_cache->isCachingEnabled) { 
     1300            if ($cache->isCachingEnabled) { 
    12531301                // Save data into cache, because it wasn't saved into cache before. 
    1254                 $_cache->saveCachedData($_retval); 
    1255             } 
    1256         } 
    1257  
    1258         return $_retval; 
    1259     } 
    1260  
    1261     /** 
    1262      * Find out how many nodes are deployed in this networks's database 
    1263      * 
    1264      * @return int Number of deployed nodes 
    1265      */ 
    1266     public function getNumDeployedNodes() 
    1267     { 
    1268  
    1269         $db = AbstractDb::getObject(); 
    1270  
    1271         // Init values 
    1272         $_retval = 0; 
    1273         $_row = null; 
    1274         $_useCache = false; 
    1275         $_cachedData = null; 
    1276  
    1277         // Create new cache objects (valid for 5 minutes) 
    1278         $_cache = new Cache('network_'.$this->_id.'_num_deployed_nodes', $this->_id, 300); 
    1279  
    1280         // Check if caching has been enabled. 
    1281         if ($_cache->isCachingEnabled) { 
    1282             $_cachedData = $_cache->getCachedData(); 
    1283  
    1284             if ($_cachedData) { 
    1285                 // Return cached data. 
    1286                 $_useCache = true; 
    1287                 $_retval = $_cachedData; 
    1288             } 
    1289         } 
    1290  
    1291         if (!$_useCache) { 
    1292             // Get number of deployed nodes 
    1293             $_network_id = $db->escapeString($this->_id); 
    1294             $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE')", $_row, false); 
    1295  
    1296             // String has been found 
    1297             $_retval = $_row['count']; 
    1298  
    1299             // Check if caching has been enabled. 
    1300             if ($_cache->isCachingEnabled) { 
    1301                 // Save data into cache, because it wasn't saved into cache before. 
    1302                 $_cache->saveCachedData($_retval); 
    1303             } 
    1304         } 
    1305  
    1306         return $_retval; 
     1302                $cache->saveCachedData($retval); 
     1303            } 
     1304        } 
     1305 
     1306        return $retval; 
    13071307    } 
    13081308 
     
    13201320 
    13211321        // Init values 
    1322         $_retval = 0; 
    1323         $_row = null; 
    1324         $_useCache = false; 
    1325         $_cachedData = null; 
     1322        $retval = 0; 
     1323        $row = null; 
     1324        $useCache = false; 
     1325        $cachedData = null; 
    13261326 
    13271327        // Create new cache objects (valid for 5 minutes) 
    13281328        if ($nonMonitoredOnly) { 
    1329             $_cache = new Cache('network_'.$this->_id.'_num_online_nodes_non_monitored', $this->_id, 300); 
     1329            $cache = new Cache('network_'.$this->_id.'_num_online_nodes_non_monitored', $this->_id, 300); 
    13301330        } else { 
    1331             $_cache = new Cache('network_'.$this->_id.'_num_online_nodes', $this->_id, 300); 
     1331            $cache = new Cache('network_'.$this->_id.'_num_online_nodes', $this->_id, 300); 
    13321332        } 
    13331333 
    13341334        // Check if caching has been enabled. 
    1335         if ($_cache->isCachingEnabled) { 
    1336             $_cachedData = $_cache->getCachedData(); 
    1337  
    1338             if ($_cachedData) { 
     1335        if ($cache->isCachingEnabled) { 
     1336            $cachedData = $cache->getCachedData(); 
     1337 
     1338            if ($cachedData) { 
    13391339                // Return cached data. 
    1340                 $_useCache = true; 
    1341                 $_retval = $_cachedData; 
    1342             } 
    1343         } 
    1344  
    1345         if (!$_useCache) { 
     1340                $useCache = true; 
     1341                $retval = $cachedData; 
     1342            } 
     1343        } 
     1344 
     1345        if (!$useCache) { 
    13461346            // Get number of online nodes 
    1347             $_network_id = $db->escapeString($this->_id); 
     1347            $network_id = $db->escapeString($this->_id); 
    13481348 
    13491349            if ($nonMonitoredOnly) { 
    1350                 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND node_deployment_status = 'NON_WIFIDOG_NODE' AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) >= interval '5 minutes')", $_row, false); 
     1350                $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$network_id' AND node_deployment_status = 'NON_WIFIDOG_NODE' AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) >= interval '5 minutes')", $row, false); 
    13511351            } else { 
    1352                 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes')", $_row, false); 
     1352                $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes')", $row, false); 
    13531353            } 
    13541354 
    13551355            // String has been found 
    1356             $_retval = $_row['count']; 
     1356            $retval = $row['count']; 
    13571357 
    13581358            // Check if caching has been enabled. 
    1359             if ($_cache->isCachingEnabled) { 
     1359            if ($cache->isCachingEnabled) { 
    13601360                // Save data into cache, because it wasn't saved into cache before. 
    1361                 $_cache->saveCachedData($_retval); 
    1362             } 
    1363         } 
    1364  
    1365         return $_retval; 
     1361                $cache->saveCachedData($retval); 
     1362            } 
     1363        } 
     1364 
     1365        return $retval; 
    13661366    } 
    13671367 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r1324 r1331  
    11051105        } 
    11061106        else { 
    1107            $_title = _("Name"); 
     1107            $_title = _("Name"); 
    11081108            $_data = $this->getName(); 
    11091109            $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_name", $_title, $_data); 
     
    13091309 
    13101310        // Creation date 
    1311        $permArray = null; 
     1311        $permArray = null; 
    13121312        $permArray[]=array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network); 
    13131313        $permArray[]=array(Permission::P('NODE_PERM_EDIT_DEPLOYMENT_DATE'), $this); 
     
    15731573    /** 
    15741574     * Find out how many users are online this specific Node 
    1575      * 
     1575     * Counts every user account connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user 
    15761576     * @return int Number of online users 
    15771577     * 
     
    15801580    public function getNumOnlineUsers() 
    15811581    { 
    1582           
    15831582        $db = AbstractDb::getObject(); 
    1584  
    15851583        // Init values 
    15861584        $retval = array (); 
    15871585        $row = null; 
    1588  
    1589         if (!$this->isConfiguredSplashOnly()) { 
    1590             $db->execSqlUniqueRes("SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $row, false); 
    1591         } else { 
    1592             $db->execSqlUniqueRes("SELECT COUNT(DISTINCT connections.user_mac) as count FROM connections WHERE connections.token_status='".TOKEN_INUSE."' AND connections.node_id='{$this->id}'", $row, false); 
    1593         } 
     1586        $splashOnlyUserId = $this->getNetwork()->getSplashOnlyUser()->getId(); 
     1587        $sql = "SELECT ((SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}' AND users.user_id!='{$splashOnlyUserId}') + (SELECT COUNT(DISTINCT connections.user_mac) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}' AND users.user_id='{$splashOnlyUserId}')) AS count"; 
     1588        $db->execSqlUniqueRes($sql, $row, false); 
    15941589 
    15951590        return $row['count'];