"Page deleter", "version" => "0.8", "author" => "Starbeamrainbowlabs", "description" => "Adds an action to allow administrators to delete pages.", "id" => "page-delete", "code" => function() { add_action("delete", function() { global $pageindex, $settings, $env, $paths, $modules; if(!$settings->editing) { exit(page_renderer::render_main("Deleting $env->page - error", "
You tried to delete $env->page, but editing is disabled on this wiki.
If you wish to delete this page, please re-enable editing on this wiki first.
Nothing has been changed.
")); } if(!$env->is_admin) { exit(page_renderer::render_main("Deleting $env->page - error", "You tried to delete $env->page, but you are not an admin so you don't have permission to do that.
You should try logging in as an admin.
")); } if(!isset($_GET["delete"]) or $_GET["delete"] !== "yes") { exit(page_renderer::render_main("Deleting $env->page", "You are about to delete $env->page. You can't undo this!
Click here to delete $env->page.
Click here to go back.")); } $page = $env->page; // Delete the associated file if it exists if(!empty($pageindex->$page->uploadedfile)) { unlink($env->storage_prefix . $pageindex->$page->uploadedfilepath); } // Delete the page from the page index unset($pageindex->$page); // Save the new page index file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT)); // Remove the page's name from the id index ids::deletepagename($env->page); // Delete the page from the search index, if that module is installed if(isset($modules["feature-search"])) { $pageid = ids::getid($env->page); $invindex = search::load_invindex($paths->searchindex); search::delete_entry($invindex, $pageid); search::save_invindex($paths->searchindex, $invindex); } // Delete the page from the disk unlink("$env->storage_prefix$env->page.md"); exit(page_renderer::render_main("Deleting $env->page - $settings->sitename", "
$env->page has been deleted. Go back to the main page.
")); }); } ]); ?>