Changeset 717 for trunk/wifidog-auth/wifidog/classes/Authenticator.php
- Timestamp:
- 09/07/05 22:16:10 (8 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/wifidog/classes/Authenticator.php
r715 r717 49 49 } 50 50 51 /** Start accounting traffic for the user */ 52 function acctStart($info) 53 { 51 /** Start accounting traffic for the user 52 * $conn_id: The connection id for the connection to work on */ 53 function acctStart($conn_id) 54 {//$info['conn_id'] 54 55 global $db; 56 $conn_id = $db->escapeString($conn_id); 57 $db->ExecSqlUniqueRes("SELECT NOW(), *, CASE WHEN ((NOW() - reg_date) > networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired FROM connections JOIN users ON (users.user_id=connections.user_id) JOIN networks ON (users.account_origin = networks.network_id) WHERE connections.conn_id='$conn_id'", $info, false); 58 $network= Network::getObject($info['network_id']); 59 $splash_user_id = $network->getSplashOnlyUser()->getId(); 55 60 $auth_response = $info['account_status']; 56 61 /* Login the user */ 57 62 $mac = $db->EscapeString($_REQUEST['mac']); 58 63 $ip = $db->EscapeString($_REQUEST['ip']); 59 $sql = "UPDATE connections SET "."token_status='".TOKEN_INUSE."',"."user_mac='$mac',"."user_ip='$ip',"."last_updated=NOW()"."WHERE conn_id='{$ info['conn_id']}';\n";64 $sql = "UPDATE connections SET "."token_status='".TOKEN_INUSE."',"."user_mac='$mac',"."user_ip='$ip',"."last_updated=NOW()"."WHERE conn_id='{$conn_id}';\n"; 60 65 $db->ExecSqlUpdate($sql, false); 61 62 /* Logging in with a new token implies that all other active tokens should expire */ 63 $token = $db->EscapeString($_REQUEST['token']); 64 $sql = "UPDATE connections SET "."timestamp_out=NOW(), token_status='".TOKEN_USED."' "."WHERE user_id = '{$info['user_id']}' AND token_status='".TOKEN_INUSE."' AND token!='$token';\n"; 65 $db->ExecSqlUpdate($sql, false); 66 if($splash_user_id != $info['user_id'] && $network->getMultipleLoginAllowed()==false) 67 { 68 /* The user isn't the splash_only user and the network config does not allow multiple logins. 69 * Logging in with a new token implies that all other active tokens should expire */ 70 $token = $db->EscapeString($_REQUEST['token']); 71 $sql = "UPDATE connections SET "."timestamp_out=NOW(), token_status='".TOKEN_USED."' "."WHERE user_id = '{$info['user_id']}' AND token_status='".TOKEN_INUSE."' AND token!='$token';\n"; 72 $db->ExecSqlUpdate($sql, false); 73 } 74 66 75 /* Delete all unused tokens for this user, so we don't fill the database with them */ 67 76 $sql = "DELETE FROM connections "."WHERE token_status='".TOKEN_UNUSED."' AND user_id = '{$info['user_id']}';\n"; … … 69 78 } 70 79 71 /** Update traffic counters */ 72 function acctUpdate($info, $incoming, $outgoing) 80 /** Update traffic counters 81 * $conn_id: The connection id for the connection to work on */ 82 function acctUpdate($conn_id, $incoming, $outgoing) 73 83 { 74 84 // Write traffic counters to database 75 85 global $db; 76 $db->ExecSqlUpdate("UPDATE connections SET "."incoming='$incoming',"."outgoing='$outgoing',"."last_updated=NOW() "."WHERE conn_id='{$info['conn_id']}'"); 86 $conn_id = $db->escapeString($conn_id); 87 $db->ExecSqlUpdate("UPDATE connections SET "."incoming='$incoming',"."outgoing='$outgoing',"."last_updated=NOW() "."WHERE conn_id='{$conn_id}'"); 77 88 } 78 89 79 /** Final update and stop accounting */ 80 function acctStop($info) 90 /** Final update and stop accounting 91 * $conn_id: The connection id (the token id) for the connection to work on 92 * */ 93 function acctStop($conn_id) 81 94 { 82 95 // Stop traffic counters update 83 96 global $db; 84 $db->ExecSqlUpdate("UPDATE connections SET "."timestamp_out=NOW(),"."token_status='".TOKEN_USED."' "."WHERE conn_id='{$info['conn_id']}';\n", false); 97 $conn_id = $db->escapeString($conn_id); 98 $db->ExecSqlUpdate("UPDATE connections SET "."timestamp_out=NOW(),"."token_status='".TOKEN_USED."' "."WHERE conn_id='{$conn_id}';\n", false); 85 99 } 86 100
