diff --git a/ext/bulk_remove/main.php b/ext/bulk_remove/main.php
new file mode 100644
index 00000000..e7cbad9e
--- /dev/null
+++ b/ext/bulk_remove/main.php
@@ -0,0 +1,132 @@
+
+ * Link: http://www.drudexsoftware.com/
+ * License: GPLv2
+ * Description: Allows admin to delete many images at once through Board Admin.
+ * Documentation:
+ *
+ */
+//todo: removal by tag returns 1 less image in test for some reason, actually a combined search doesn't seem to work for shit either
+
+class BulkRemove extends Extension {
+ public function onPageRequest(PageRequestEvent $event) {
+ global $page, $user;
+ if($event->page_matches("bulk_remove") && $user->is_admin() && $user->check_auth_token()) {
+ if ($event->get_arg(0) == "confirm") $this->do_bulk_remove();
+ else $this->show_confirm();
+ }
+ }
+
+ public function onAdminBuilding(AdminBuildingEvent $event) {
+ global $page, $user;
+ $html = "Be extremely careful when using this!
+ Once an image is removed there is no way to recover it so it is recommended that
+ you first take when removing a large amount of images.
+ Note: Entering both an ID range and tags will only remove images between the given ID's that have the given tags.
+
+
".make_form(make_link("bulk_remove"))."
+
+
+ ";
+ $page->add_block(new Block("Bulk Remove", $html));
+ }
+
+ // returns a list of images to be removed
+ private function determine_images()
+ {
+ // set vars
+ $images_for_removal = array();
+ $error = "";
+
+ $min_id = $_POST['remove_id_min'];
+ $max_id = $_POST['remove_id_max'];
+ $tags = $_POST['remove_tags'];
+
+
+ // if using id range to remove (comined removal with tags)
+ if ($min_id != "" && $max_id != "")
+ {
+ // error if values are not correctly entered
+ if (!is_numeric($min_id) || !is_numeric($max_id) ||
+ intval($max_id) < intval($min_id))
+ $error = "Values not correctly entered for removal between id.";
+
+ else { // if min & max id are valid
+
+ // Grab the list of images & place it in the removing array
+ foreach (Image::find_images(intval($min_id), intval($max_id)) as $image)
+ array_push($images_for_removal, $image);
+ }
+ }
+
+ // refine previous results or create results from tags
+ if ($tags != "")
+ {
+ $tags_arr = explode(" ", $_POST['remove_tags']);
+
+ // Search all images with the specified tags & add to list
+ foreach (Image::find_images(1, 2147483647, $tags_arr) as $image)
+ array_push($images_for_removal, $image);
+ }
+
+
+ // if no images were found with the given info
+ if (count($images_for_removal) == 0 && $html == "")
+ $error = "No images selected for removal";
+
+ var_dump($tags_arr);
+ return array(
+ "error" => $error,
+ "images_for_removal" => $images_for_removal);
+ }
+
+ // displays confirmation to admin before removal
+ private function show_confirm()
+ {
+ global $page;
+
+ // set vars
+ $determined_imgs = $this->determine_images();
+ $error = $determined_imgs["error"];
+ $images_for_removal = $determined_imgs["images_for_removal"];
+
+ // if there was an error in determine_images()
+ if ($error != "") {
+ $page->add_block(new Block("Cannot remove images", $error));
+ return;
+ }
+ // generates the image array & places it in $_POST["bulk_remove_images"]
+ $_POST["bulk_remove_images"] = $images_for_removal;
+
+ // Display confirmation message
+ $html = make_form(make_link("bulk_remove")).
+ "Are you sure you want to PERMANENTLY remove ".
+ count($images_for_removal) ." images?
";
+ $page->add_block(new Block("Confirm Removal", $html));
+ }
+
+ private function do_bulk_remove()
+ {
+ // display error if user didn't go through admin board
+ if (!isset($_POST["bulk_remove_images"])) {
+ $page->add_block(new Block("Bulk Remove Error",
+ "Please use Board Admin to use bulk remove."));
+ }
+
+ //
+ $image_arr = $_POST["bulk_remove_images"];
+ }
+}
+?>