Revision 5e71234e
Added by Chris Buechler over 9 years ago
src/etc/inc/captiveportal.inc | ||
---|---|---|
1392 | 1392 |
} |
1393 | 1393 |
|
1394 | 1394 |
function captiveportal_opendb() { |
1395 |
global $g, $cpzone;
|
|
1395 |
global $g, $config, $cpzone, $cpzoneid;
|
|
1396 | 1396 |
|
1397 | 1397 |
$db_path = "{$g['vardb_path']}/captiveportal{$cpzone}.db"; |
1398 | 1398 |
$createquery = "CREATE TABLE IF NOT EXISTS captiveportal (" . |
... | ... | |
1441 | 1441 |
$DB->busyTimeout(60000); |
1442 | 1442 |
if ($DB->exec($createquery)) { |
1443 | 1443 |
captiveportal_syslog("Successfully reinitialized tables for {$cpzone} -- database has been reset."); |
1444 |
if (!is_numericint($cpzoneid)) { |
|
1445 |
if (is_array($config['captiveportal'])) { |
|
1446 |
foreach ($config['captiveportal'] as $cpkey => $cp) { |
|
1447 |
if ($cpzone == $cp['zone']) { |
|
1448 |
$cpzoneid = $cp['zoneid']; |
|
1449 |
} |
|
1450 |
} |
|
1451 |
} |
|
1452 |
} |
|
1453 |
if (is_numericint($cpzoneid)) { |
|
1454 |
mwexec("/sbin/ipfw -x $cpzoneid table all flush"); |
|
1455 |
captiveportal_syslog("Flushed tables for {$cpzone} after database reset."); |
|
1456 |
} |
|
1444 | 1457 |
} else { |
1445 | 1458 |
captiveportal_syslog("Still unable to create tables for {$cpzone}. Error message: {$DB->lastErrorMsg()}. Remove the database file manually and try again."); |
1446 | 1459 |
} |
Also available in: Unified diff
Flush zone's tables if its db must be reset to avoid leaving behind any table entries. Ticket #5622