reset image id function for admin
this basically grabs all the image_id's > sets them all from 1-whatever (so it would be like you never deleted an image)
This commit is contained in:
parent
0e25c82fc5
commit
d3d395c347
@ -78,6 +78,10 @@ class AdminPage extends SimpleExtension {
|
|||||||
case 'database dump':
|
case 'database dump':
|
||||||
$this->dbdump($page);
|
$this->dbdump($page);
|
||||||
break;
|
break;
|
||||||
|
case 'reset image ids':
|
||||||
|
$this->reset_imageids();
|
||||||
|
$redirect = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($redirect) {
|
if($redirect) {
|
||||||
@ -175,5 +179,44 @@ class AdminPage extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
private function reset_imageids() {
|
||||||
|
global $database;
|
||||||
|
//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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -26,6 +26,7 @@ class AdminPageTheme extends Themelet {
|
|||||||
<option value='recount tag use'>Recount tag use</option>
|
<option value='recount tag use'>Recount tag use</option>
|
||||||
<option value='purge unused tags'>Purge unused tags</option>
|
<option value='purge unused tags'>Purge unused tags</option>
|
||||||
<option value='database dump'>Download database contents</option>
|
<option value='database dump'>Download database contents</option>
|
||||||
|
<option value='reset image ids'>Reset image ids</option>
|
||||||
<!--<option value='convert to innodb'>Convert database to InnoDB (MySQL only)</option>-->
|
<!--<option value='convert to innodb'>Convert database to InnoDB (MySQL only)</option>-->
|
||||||
</select>
|
</select>
|
||||||
<input type='submit' value='Go'>
|
<input type='submit' value='Go'>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user