diff --git a/contrib/admin/main.php b/contrib/admin/main.php index 3085256f..a99d22b1 100644 --- a/contrib/admin/main.php +++ b/contrib/admin/main.php @@ -9,17 +9,8 @@ *

Lowercase all tags: *
Set all tags to lowercase for consistency *

Recount tag use: - *
If the counts of images per tag get messed up somehow, this will reset them - *

Purge unused tags: - *
Get rid of all the tags that don't have any images associated with - * them (normally they were created as typos or spam); this is mostly for - * neatness, the performance gain is tiny... - *

Convert to InnoDB: - *
Convert your database tables to InnoDB, thus allowing shimmie to - * take advantage of useful InnoDB-only features (this should be done - * automatically, this button only exists as a backup). This only applies - * to MySQL -- all other databases come with useful features enabled - * as standard. + *
If the counts of images per tag get messed up somehow, this will + * reset them, and remove any unused tags *

Database dump: *
Download the contents of the database in plain text format, useful * for backups. @@ -130,16 +121,11 @@ class AdminPage extends Extension { 0 ) "); - return true; - } - - private function purge_unused_tags() { - global $database; - $this->recount_tag_use(); $database->Execute("DELETE FROM tags WHERE count=0"); return true; } + private function database_dump() { global $page; @@ -172,77 +158,6 @@ class AdminPage extends Extension { return false; } - private function check_for_orphanned_images() { - $orphans = array(); - foreach(glob("images/*") as $dir) { - foreach(glob("$dir/*") as $file) { - $hash = str_replace("$dir/", "", $file); - if(!$this->db_has_hash($hash)) { - $orphans[] = $hash; - } - } - } - return true; - } - - /* - private function convert_to_innodb() { - global $database; - - if($database->engine->name != "mysql") return; - - $tables = $database->db->MetaTables(); - foreach($tables as $table) { - log_info("upgrade", "converting $table to innodb"); - $database->execute("ALTER TABLE $table TYPE=INNODB"); - } - return true; - } - */ - - private function reset_image_ids() { - global $database; - - if($database->engine->name != "mysql") return; - - //This might be a bit laggy on boards with lots of images (?) - //Seems to work fine with 1.2k~ images though. - $i = 0; - $image = $database->get_all("SELECT * FROM images ORDER BY images.id ASC"); - /*$score_log = $database->get_all("SELECT message FROM score_log");*/ - foreach($image as $img){ - $xid = $img[0]; - $i = $i + 1; - $table = array( //Might be missing some tables? - "image_tags", "tag_histories", "image_reports", "comments", "user_favorites", "tag_histories", - "numeric_score_votes", "pool_images", "slext_progress_cache", "notes"); - - $sql = - "SET FOREIGN_KEY_CHECKS=0; - UPDATE images - SET id=".$i. - " WHERE id=".$xid.";"; //id for images - - foreach($table as $tbl){ - $sql .= " - UPDATE ".$tbl." - SET image_id=".$i." - WHERE image_id=".$xid.";"; - } - - /*foreach($score_log as $sl){ - //This seems like a bad idea. - //TODO: Might be better for log_info to have an $id option (which would then affix the id to the table?) - preg_replace(".Image \\#[0-9]+.", "Image #".$i, $sl); - }*/ - $sql .= " SET FOREIGN_KEY_CHECKS=1;"; - $database->execute($sql); - } - $count = (count($image)) + 1; - $database->execute("ALTER TABLE images AUTO_INCREMENT=".$count); - return true; - } - private function download_all_images() { global $database, $page; diff --git a/contrib/admin/theme.php b/contrib/admin/theme.php index e5d5ac03..ab29b630 100644 --- a/contrib/admin/theme.php +++ b/contrib/admin/theme.php @@ -38,12 +38,9 @@ class AdminPageTheme extends Themelet { $html = ""; $html .= $this->button("All tags to lowercase", "lowercase_all_tags", true); $html .= $this->button("Recount tag use", "recount_tag_user", false); - $html .= $this->button("Purge unused tags", "purge_unused_tags", true); $html .= $this->button("Download all images", "image_dump", false); - if($database->engine->name == "mysql") { - $html .= $this->button("Download database contents", "database_dump", false); - $html .= $this->button("Reset image IDs", "reset_image_ids", true); - } + $html .= $this->button("Download database contents", "database_dump", false); + $page->add_block(new Block("Misc Admin Tools", $html)); }