| 2 | | /********************************************************************\ |
| 3 | | * This program is free software; you can redistribute it and/or * |
| 4 | | * modify it under the terms of the GNU General Public License as * |
| 5 | | * published by the Free Software Foundation; either version 2 of * |
| 6 | | * the License, or (at your option) any later version. * |
| 7 | | * * |
| 8 | | * This program is distributed in the hope that it will be useful, * |
| 9 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 10 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 11 | | * GNU General Public License for more details. * |
| 12 | | * * |
| 13 | | * You should have received a copy of the GNU General Public License* |
| 14 | | * along with this program; if not, contact: * |
| 15 | | * * |
| 16 | | * Free Software Foundation Voice: +1-617-542-5942 * |
| 17 | | * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * |
| 18 | | * Boston, MA 02111-1307, USA gnu@gnu.org * |
| 19 | | * * |
| 20 | | \********************************************************************/ |
| 21 | | /**@file Authenticator.php |
| 22 | | * @author Copyright (C) 2005 Benoit Gr�goire <bock@step.polymtl.ca>, Technologies Coeus inc. |
| 23 | | */ |
| | 2 | |
| | 3 | |
| | 4 | /********************************************************************\ |
| | 5 | * This program is free software; you can redistribute it and/or * |
| | 6 | * modify it under the terms of the GNU General Public License as * |
| | 7 | * published by the Free Software Foundation; either version 2 of * |
| | 8 | * the License, or (at your option) any later version. * |
| | 9 | * * |
| | 10 | * This program is distributed in the hope that it will be useful, * |
| | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| | 13 | * GNU General Public License for more details. * |
| | 14 | * * |
| | 15 | * You should have received a copy of the GNU General Public License* |
| | 16 | * along with this program; if not, contact: * |
| | 17 | * * |
| | 18 | * Free Software Foundation Voice: +1-617-542-5942 * |
| | 19 | * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * |
| | 20 | * Boston, MA 02111-1307, USA gnu@gnu.org * |
| | 21 | * * |
| | 22 | \********************************************************************/ |
| | 23 | /**@file Authenticator.php |
| | 24 | * @author Copyright (C) 2005 Benoit Gr�goire <bock@step.polymtl.ca>, |
| | 25 | * Technologies Coeus inc. |
| | 26 | */ |
| 49 | | /** Update traffic counters */ |
| 50 | | function acctUpdate() |
| 51 | | { |
| 52 | | } |
| | 48 | /** Start accounting traffic for the user */ |
| | 49 | function acctStart($info) |
| | 50 | { |
| | 51 | global $db; |
| | 52 | $auth_response = $info['account_status']; |
| | 53 | /* Login the user */ |
| | 54 | $mac = $db->EscapeString($_REQUEST['mac']); |
| | 55 | $ip = $db->EscapeString($_REQUEST['ip']); |
| | 56 | $sql = "UPDATE connections SET "."token_status='".TOKEN_INUSE."',"."user_mac='$mac',"."user_ip='$ip',"."last_updated=NOW()"."WHERE conn_id='{$info['conn_id']}';\n"; |
| | 57 | $db->ExecSqlUpdate($sql, false); |
| 54 | | /** Final update and stop accounting */ |
| 55 | | function acctStop() |
| 56 | | { |
| 57 | | } |
| | 59 | /* Logging in with a new token implies that all other active tokens should expire */ |
| | 60 | $token = $db->EscapeString($_REQUEST['token']); |
| | 61 | $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"; |
| | 62 | $db->ExecSqlUpdate($sql, false); |
| | 63 | /* Delete all unused tokens for this user, so we don't fill the database with them */ |
| | 64 | $sql = "DELETE FROM connections "."WHERE token_status='".TOKEN_UNUSED."' AND user_id = '{$info['user_id']}';\n"; |
| | 65 | $db->ExecSqlUpdate($sql, false); |
| | 66 | } |
| 59 | | }// End class |
| | 68 | /** Update traffic counters */ |
| | 69 | function acctUpdate($info, $incoming, $outgoing) |
| | 70 | { |
| | 71 | // Write traffic counters to database |
| | 72 | global $db; |
| | 73 | $db->ExecSqlUpdate("UPDATE connections SET "."incoming='$incoming',"."outgoing='$outgoing',"."last_updated=NOW() "."WHERE conn_id='{$info['conn_id']}'"); |
| | 74 | } |
| | 75 | |
| | 76 | /** Final update and stop accounting */ |
| | 77 | function acctStop($info) |
| | 78 | { |
| | 79 | // Stop traffic counters update |
| | 80 | global $db; |
| | 81 | $db->ExecSqlUpdate("UPDATE connections SET "."timestamp_out=NOW(),"."token_status='".TOKEN_USED."' "."WHERE conn_id='{$info['conn_id']}';\n"); |
| | 82 | } |
| | 83 | |
| | 84 | } // End class |