From 26ee5aafa2787c9249b50a57a7ab9977e6303fe8 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 18 Dec 2012 09:19:34 +0000 Subject: Convert the CP db to sqlite rather than a text file. Some more optimizations might be needed and probably vouchers db might need conversion as well. --- etc/inc/voucher.inc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'etc/inc/voucher.inc') diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc index 3a8c0bc..094b829 100644 --- a/etc/inc/voucher.inc +++ b/etc/inc/voucher.inc @@ -215,8 +215,6 @@ function voucher_expire($voucher_received) { // split into an array. Useful for multiple vouchers given $a_vouchers_received = preg_split("/[\t\n\r ]+/s", $voucher_received); $active_dirty = false; - - $cpdb = captiveportal_read_db(false, 4); /* Indexed by Voucher */ $unsetindexes[] = array(); // go through all received vouchers, check their valid and extract @@ -250,11 +248,10 @@ function voucher_expire($voucher_received) { captiveportal_syslog("{$voucher} ({$roll}/{$nr}) forced to expire"); /* Check if this voucher has any active sessions */ - if (isset($cpdb[$voucher])) { - $cpentry = $cpdb[$voucher]; + $cpentry = captiveportal_read_db("WHERE username = '{$voucher}'"); + if (!empty($cpentry)) { captiveportal_disconnect($cpentry,null,13); captiveportal_logportalauth($cpentry[4],$cpentry[3],$cpentry[2],"FORCLY TERMINATING VOUCHER {$voucher} SESSION"); - unset($cpdb[$voucher]); $unsetindexes[] = $cpentry[5]; } } else @@ -289,7 +286,7 @@ function voucher_expire($voucher_received) { /* Write database */ if (!empty($unsetindexes)) - captiveportal_write_db($cpdb, false, $unsetindexes); + captiveportal_remove_entries($unsetindexes); return true; } -- cgit v1.1