function delip($ip, $delsub = false) { if ($delsub) { // calculate the subnet $sub = ipsub($ip); $submax = $sub + 255; // Get the imgidxes for the affected posts $reply_imgidx = $this->myarray("select distinct imgidx from " . THreplies_table . " where ip between " . $sub . " and " . $submax . " and imgidx!=0"); $thread_imgidx = $this->myarray("select distinct imgidx from " . THthreads_table . " where ip between " . $sub . " and " . $submax . " and imgidx!=0"); // Get the affected replies/threads $affreplies = $this->mymultiarray("select id, globalid, board from " . THreplies_table . " where ip between " . $sub . " and " . $submax); $affthreads = $this->mymultiarray("select id, globalid, board from " . THthreads_table . " where ip between " . $sub . " and " . $submax); // Delete from the tables $this->myquery("delete from " . THreplies_table . " where ip between " . $sub . " and " . $submax); $this->myquery("delete from " . THthreads_table . " where ip between " . $sub . " and " . $submax); } else { // Get the imgidxes for the affected posts $reply_imgidx = $this->myarray("select distinct imgidx from " . THreplies_table . " where ip=" . $ip . " and imgidx!=0"); $thread_imgidx = $this->myarray("select distinct imgidx from " . THthreads_table . " where ip=" . $ip . " and imgidx!=0"); // Get the affected replies/threads $affreplies = $this->mymultiarray("select id, globalid, board from " . THreplies_table . " where ip=" . $ip); $affthreads = $this->mymultiarray("select id, globalid, board from " . THthreads_table . " where ip=" . $ip); // Delete from the tables $this->myquery("delete from " . THreplies_table . " where ip=" . $ip); $this->myquery("delete from " . THthreads_table . " where ip=" . $ip); } if ($reply_imgidx == null) { $reply_imgidx = array(); } if ($thread_imgidx == null) { $thread_imgidx = array(); } // $affimgs will hold imgidxes to delete later by other functions $affimgs = array(); $affimgs = array_merge($affimgs, $reply_imgidx, $thread_imgidx); // $affthreadids is an array of thread IDs so that we can later // turn into a string to use in a SQL query $affthreadids = array(); // Clear the caches for each thread, add the thread ID to the $affthreadids array, // and mark valid all the reports for it foreach ($affthreads as $thread) { $affthreadids[] = $thread['id']; smclearcache($thread['board'], -1, $thread['globalid']); // clear the associated cache for this thread smclearcache($thread['board'], -1, -1); // AND this board $this->touchreports($thread['globalid'], $thread['board'], 1); // Mark as valid all reports for this thread } // All we have to do is mark the reports as valid foreach ($affreplies as $reply) { $this->touchreports($reply['globalid'], $reply['board'], 1); // Mark as valid all reports for this reply } // We need to handle replies in threads (started by this IP or IP range) if (count($affthreads) > 0) { // Get an array of thread IDs and turn it into a string so that we can // pop it into an SQL query easily $affstr = implode(",", $affthreadids); // Get replies to deleted threads $threadreplies = $this->mymultiarray("select globalid, board, imgidx from " . THreplies_table . " where thread in (" . $affstr . ")"); // All we have to do is mark the reports as other (status 3) and // add nonzero imgidxes to $affimgs foreach ($threadreplies as $reply) { $this->touchreports($reply['globalid'], $reply['board'], 3); // Add valid imgidxes to $affimgs if ($reply['imgidx'] != 0) { $affimgs[] = $reply['imgidx']; } } // Now delete the replies $this->myquery("delete from " . THreplies_table . " where thread in (" . $affstr . ")"); } // Delete DB info for all of these images (in $affimgs) if (count($affimgs) > 0) { $extra_info_entries = $this->myarray("select extra_info from " . THimages_table . " where id in (" . implode(",", $affimgs) . ")"); // Remove extra_info sections if (count($extra_info_entries) > 0) { $this->myquery("delete from " . THextrainfo_table . " where id in (" . implode(",", $extra_info_entries) . ")"); } $this->myquery("delete from " . THimages_table . " where id in (" . implode(",", $affimgs) . ")"); } // Return the affected images info return $affimgs; }
if ($_POST['moddo'] == "killpost") { smclearcache($board, -1, $thread); // clear the associated cache for this thread smclearcache($board, -1, -1); // AND the board delimgs($moddb->delpost($targetid, $targetisthread)); } elseif ($_POST['moddo'] == "killip") { delimgs($moddb->delipfrompost($targetid, $targetisthread, false)); // Indicate that an entire IP is getting its posts deleted $actionstring = $actionstring . "\tip:" . $ipstring; } elseif ($_POST['moddo'] == "killsub") { delimgs($moddb->delipfrompost($targetid, $targetisthread, true)); // Indicate that an entire subnet is getting its posts deleted // We do this by writing "sub" instead of "ip" and calling ipsub so that // the last octet will be a 0 $actionstring = $actionstring . "\tsub:" . long2ip(ipsub($postarray['ip'])); } // Write to the log writelog($actionstring, "moderator"); //Display our link back. THdie($diereturn); } elseif ($_POST['moddo'] != "nil") { THdie("You lack sufficient ability to delete this post!"); } } } // Attempt to move a thread (we can if we're an admin) if (isset($_POST['movethread']) && $_POST['movethread'] != "nil") { if ($adminpowers > 0 && $postarray['thread'] == 0) { $destboard = intval($_POST['movethread']); $destboard_name = $db->getboardname($destboard);