Project

General

Profile

« Previous | Next » 

Revision 07917f7d

Added by Chris Buechler over 9 years ago

Flush zone's tables if its db must be reset to avoid leaving behind any table entries. Ticket #5622

View differences:

etc/inc/captiveportal.inc
1326 1326
}
1327 1327

  
1328 1328
function captiveportal_opendb() {
1329
	global $g, $cpzone;
1329
	global $g, $config, $cpzone, $cpzoneid;
1330 1330

  
1331 1331
	$db_path = "{$g['vardb_path']}/captiveportal{$cpzone}.db";
1332 1332
	$createquery = "CREATE TABLE IF NOT EXISTS captiveportal (" .
......
1375 1375
		$DB->busyTimeout(60000);
1376 1376
		if ($DB->exec($createquery)) {
1377 1377
			captiveportal_syslog("Successfully reinitialized tables for {$cpzone} -- database has been reset.");
1378
			if (!is_numericint($cpzoneid)) {
1379
				if (is_array($config['captiveportal'])) {
1380
					foreach ($config['captiveportal'] as $cpkey => $cp) {
1381
						if ($cpzone == $cp['zone']) {
1382
							$cpzoneid = $cp['zoneid'];
1383
						}
1384
					}
1385
				}
1386
			}
1387
			if (is_numericint($cpzoneid)) {
1388
				mwexec("/sbin/ipfw -x $cpzoneid table all flush");
1389
				captiveportal_syslog("Flushed tables for {$cpzone} after database reset.");
1390
			}
1378 1391
		} else {
1379 1392
			captiveportal_syslog("Still unable to create tables for {$cpzone}. Error message: {$DB->lastErrorMsg()}. Remove the database file manually and try again.");
1380 1393
		}

Also available in: Unified diff