Changeset 1413
- Timestamp:
- 08/06/09 09:55:30 (4 years ago)
- Location:
- trunk/wifidog-auth/wifidog
- Files:
-
- 4 modified
-
auth/index.php (modified) (1 diff)
-
classes/User.php (modified) (1 diff)
-
include/common.php (modified) (2 diffs)
-
include/schema_validate.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/wifidog/auth/index.php
r1412 r1413 159 159 else 160 160 { 161 /* TODO: This is a bit hackish, i s'ta shortcut untill the Token architecture uniform connection limit calculations are in place. */161 /* TODO: This is a bit hackish, it's a shortcut untill the Token architecture uniform connection limit calculations are in place. */ 162 162 $abuseControlFault = User::isAbuseControlViolated(User::getObject($info['user_id']), $info['user_mac'], Node::getObject($info['node_id'])); 163 163 if($abuseControlFault) { -
trunk/wifidog-auth/wifidog/classes/User.php
r1409 r1413 564 564 $sql .= " SUM (CASE WHEN node_id = '".$node->getId()."' THEN (incoming+outgoing) END) AS node_total_bytes, \n"; 565 565 $sql .= " SUM (timestamp_out - timestamp_in) AS network_duration, \n"; 566 $sql .= " SUM (CASE WHEN node_id = '".$node->getId()."' THEN ( timestamp_out - timestamp_in) END) AS node_duration \n";//For real566 $sql .= " SUM (CASE WHEN node_id = '".$node->getId()."' THEN (COALESCE(timestamp_out,last_updated) - timestamp_in) END) AS node_duration \n";//For real //The coalesce is to make sure the substraction returns a value for active conections, since active connections do not yet have a timestamp_out. Do NOT coalesce with CURRENT_TIMESTAMP, it could cause real problems for users in case of gateway crash. 567 567 $sql .= " FROM connections \n";//For real 568 568 $sql .= " JOIN nodes USING (node_id) \n"; -
trunk/wifidog-auth/wifidog/include/common.php
r1350 r1413 150 150 define('ONLINE_STATUS_ONLINE', 1); 151 151 define('ONLINE_STATUS_OFFLINE', 2); 152 152 153 /* End Constant shared with the gateway*/ 154 155 /* Other constants */ 156 define('LOGOUT_REASON_GARBAGE_COLLECTED', 3); 157 define('LOGOUT_REASON_UNKNOWN', 0); 158 /* End of Other constants */ 153 159 154 160 /** Convert a password hash form a NoCat passwd file into the same format as get_password_hash(). … … 172 178 // 10 minutes 173 179 $expiration = '10 minutes'; 174 $db->execSqlUpdate("UPDATE tokens SET token_status='" . TOKEN_USED . "' FROM connections WHERE connections.token_id=tokens.token_id AND last_updated < (CURRENT_TIMESTAMP - interval '$expiration') AND token_status = '" . TOKEN_INUSE . "';", false); 180 $sql = null; 181 $sql .= "BEGIN;\n"; 182 $sql .= "UPDATE connections SET logout_reason=" . LOGOUT_REASON_GARBAGE_COLLECTED . ", timestamp_out=(CURRENT_TIMESTAMP - interval '$expiration') FROM tokens WHERE connections.token_id=tokens.token_id AND last_updated < (CURRENT_TIMESTAMP - interval '$expiration') AND token_status = '" . TOKEN_INUSE . "';"; 183 $sql .= "UPDATE tokens SET token_status='" . TOKEN_USED . "' FROM connections WHERE connections.token_id=tokens.token_id AND last_updated < (CURRENT_TIMESTAMP - interval '$expiration') AND token_status = '" . TOKEN_INUSE . "';"; 184 $sql .= "COMMIT;\n"; 185 $db->execSqlUpdate($sql, false); 175 186 } 176 187 -
trunk/wifidog-auth/wifidog/include/schema_validate.php
r1395 r1413 48 48 * Define current database schema version 49 49 */ 50 define('REQUIRED_SCHEMA_VERSION', 6 5);50 define('REQUIRED_SCHEMA_VERSION', 66); 51 51 /** Used to test a new shecma version before modyfying the database */ 52 52 define('SCHEMA_UPDATE_TEST_MODE', false); … … 1442 1442 } 1443 1443 1444 $new_schema_version = 66; 1445 if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 1446 printUpdateVersion($new_schema_version); 1447 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 1448 $sql .= "UPDATE connections SET logout_reason=0, timestamp_out=timestamp_in FROM tokens WHERE connections.token_id=tokens.token_id AND timestamp_out IS NULL AND (token_status = 'USED' OR token_status = 'UNUSED');\n"; 1449 } 1450 1444 1451 /* 1445 1452 $new_schema_version = ;
