/** * Remove a board * * @param string $dir Directory to remove * @return boolean Result */ function removeBoard($dir) { global $tc_db; if (!isset($GLOBALS['remerror'])) { $GLOBALS['remerror'] = false; } if ($handle = opendir(KU_BOARDSDIR . $dir)) { /* If the folder exploration is sucsessful, continue */ while (false !== ($file = readdir($handle))) { /* As long as storing the next file to $file is successful, continue */ $path = $dir . '/' . $file; if (is_file(KU_BOARDSDIR . $path)) { if (!unlink(KU_BOARDSDIR . $path)) { echo '<u><font color="red">' . sprintf(_gettext('"%s" could not be deleted. This may be due to a permissions problem.</u><br />Directory cannot be deleted until all files are deleted.'), $path) . '</font><br />'; $GLOBALS['remerror'] = true; return false; } } else { if (is_dir(KU_BOARDSDIR . $path) && substr($file, 0, 1) != '.') { removeBoard($path); @rmdir(KU_BOARDSDIR . $path); } } } closedir($handle); /* Close the folder exploration */ } if (!$GLOBALS['remerror']) { /* If no errors occured, delete the now empty directory */ if (!rmdir(KU_BOARDSDIR . $dir)) { echo '<strong><font color="red">' . sprintf(_gettext('Could not remove directory "%s". This may be due to a permissions problem.'), $dir) . '</font></strong><br />' . $GLOBALS['remerror']; return false; } else { return true; } } return false; }
function delboard($dir, $confirm = '') { global $tc_db; $this->AdministratorsOnly(); $output = ''; $output .= '<h2>' . _gettext('Delete Results') . '</h2><br />'; if (!empty($dir)) { $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "boards` WHERE `name` = " . $tc_db->qstr($dir) . ""); foreach ($results as $line) { $board_id = $line['id']; $board_dir = $line['name']; } if (count($results) > 0) { if (!empty($confirm)) { if (removeBoard($board_dir)) { $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = '" . $board_id . "'"); $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "boards` WHERE `id` = '" . $board_id . "'"); $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "board_filetypes` WHERE `boardid` = '" . $board_id . "'"); require_once KU_ROOTDIR . 'inc/classes/menu.class.php'; $menu_class = new Menu(); $menu_class->Generate(); $output .= _gettext('Board successfully deleted.'); management_addlogentry(_gettext('Deleted board') . ': /' . $dir . '/', 3); } else { // Error $output .= _gettext('Unable to delete board.'); } } else { $output .= sprintf(_gettext('Are you absolutely sure you want to delete %s?'), '/' . $board_dir . '/') . '<br /> <form action="manage_page.php?action=adddelboard" method="post"> <input type="hidden" name="del" id="del" value="del" /> <input type="hidden" name="directory" id="directory" value="' . $dir . '" /> <input type="hidden" name="confirmation" id="confirmation" value="yes" /> <input type="submit" value="' . _gettext('Continue') . '" /> </form><br />'; } } else { $output .= _gettext('A board with that name does not exist.'); } } $output .= '<br />'; return $output; }