function deleteBCW($type = -1, $id) { $type = intval($type); switch ($type) { case 1: // Blotter posts $query = "DELETE FROM " . THblotter_table . " WHERE id=" . intval($id); break; case 2: // Capcodes $query = "DELETE FROM " . THcapcodes_table . " WHERE id=" . intval($id); rebuild_capcodes(); break; case 3: // Wordfilters $query = "DELETE FROM " . THfilters_table . " WHERE id=" . intval($id); rebuild_filters(); break; default: die("BCW error: Invalid type provided!"); break; } $this->myquery($query); }
} else { header("Location: " . THurl . "admin.php?a=x"); // failure } } else { header("Location: " . THurl . "admin.php?a=x"); // even worse failure } } elseif ($_GET['t'] == "ac") { if ($_POST['capcodefrom'] == null || $_POST['capcodeto'] == null) { THdie('Invalid field provided.'); // don't know if this is right } // insertBCW takes care of the rest. $db->insertBCW(THbcw_capcode, $_POST['capcodefrom'], $_POST['capcodeto'], $_POST['notes']); rebuild_capcodes(); $actionstring = "CP add\tfrom:" . $_POST['capcodefrom'] . "\tto:" . $_POST['capcodeto']; writelog($actionstring, "admin"); header("Location: " . THurl . "admin.php?a=c"); } elseif ($_GET['t'] == "rc") { $capcodes = $db->fetchBCW(THbcw_capcode); foreach ($capcodes as $cap) { if ($_POST['del' . $cap['id']]) { $db->deleteBCW(THbcw_capcode, $cap['id']); $actionstring = "CP delete\tid:" . $cap['id']; writelog($actionstring, "admin"); } else { $capcode = array('id' => (int) $_POST['id' . $cap['id']], 'from' => $_POST['from' . $cap['id']], 'to' => $_POST['to' . $cap['id']], 'notes' => $_POST['notes' . $cap['id']]); $db->updateBCW(THbcw_capcode, $capcode['id'], $capcode['from'], $capcode['to'], $capcode['notes']); } }