From 07917f7df529dab51e8f6f6d346f5c7610972639 Mon Sep 17 00:00:00 2001 From: Chris Buechler Date: Thu, 17 Dec 2015 18:59:08 -0600 Subject: Flush zone's tables if its db must be reset to avoid leaving behind any table entries. Ticket #5622 --- etc/inc/captiveportal.inc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'etc') diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 5e834ca..0236ac9 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -1326,7 +1326,7 @@ function radius($username,$password,$clientip,$clientmac,$type, $radiusctx = nul } function captiveportal_opendb() { - global $g, $cpzone; + global $g, $config, $cpzone, $cpzoneid; $db_path = "{$g['vardb_path']}/captiveportal{$cpzone}.db"; $createquery = "CREATE TABLE IF NOT EXISTS captiveportal (" . @@ -1375,6 +1375,19 @@ function captiveportal_opendb() { $DB->busyTimeout(60000); if ($DB->exec($createquery)) { captiveportal_syslog("Successfully reinitialized tables for {$cpzone} -- database has been reset."); + if (!is_numericint($cpzoneid)) { + if (is_array($config['captiveportal'])) { + foreach ($config['captiveportal'] as $cpkey => $cp) { + if ($cpzone == $cp['zone']) { + $cpzoneid = $cp['zoneid']; + } + } + } + } + if (is_numericint($cpzoneid)) { + mwexec("/sbin/ipfw -x $cpzoneid table all flush"); + captiveportal_syslog("Flushed tables for {$cpzone} after database reset."); + } } else { captiveportal_syslog("Still unable to create tables for {$cpzone}. Error message: {$DB->lastErrorMsg()}. Remove the database file manually and try again."); } -- cgit v1.1