if (!$ID) { $post = $xml->channel->item[count($xml->channel->item) - 1]; } else { //find the post using the ID (we need to know the numerical index for later) for ($i = 0; $i < count($xml->channel->item); $i++) { if (strstr($xml->channel->item[$i]->link, '#') == "#{$ID}") { break; } } $post = $xml->channel->item[$i]; } /* has the un/pw been submitted to authenticate the delete? -------------------------------------------------------------------------------------------------------------- */ if (AUTH && CAN_REPLY && (IS_MOD || strtolower(NAME) == strtolower($post->author) && (FORUM_LOCK != 'posts' || IS_MEMBER))) { if ($ID) { if (IS_MOD && $i <= (count($xml->channel->item) - 2) % FORUM_POSTS && (isset($_POST['remove']) || $post->xpath('category[.="deleted"]')) || @simplexml_load_string('<body>' . DOMTemplate::html_entity_decode($post->description) . '</body>') === false) { //remove the post from the thread entirely unset($xml->channel->item[$i]); //we’ll redirect to the last page (which may have changed number when the post was deleted) $url = FORUM_URL . url(PATH_URL, $FILE) . '#nnf_replies'; } else { //remove the post text and replace with the deleted messgae $post->description = NAME == (string) $post->author ? THEME_DEL_USER : THEME_DEL_MOD; //add a "deleted" category so we know to no longer allow it to be edited or deleted again if (!$post->xpath('category[.="deleted"]')) { $post->category[] = 'deleted'; } //need to know what page this post is on to redirect back to it $url = FORUM_URL . url(PATH_URL, $FILE, $PAGE) . "#{$ID}"; } //commit the data