$insert_query=prepare(sprintf("INSERT INTO ``shadow_posts_%s`` SELECT * FROM ``posts_%s`` WHERE `id` = ".implode(' OR `id` = ',$ids),$board['uri'],$board['uri']));
$query=prepare(sprintf("DELETE FROM ``posts_%s`` WHERE `id` = :id OR `thread` = :id",$board['uri']));
$query->bindValue(':id',$id,PDO::PARAM_INT);
$query->execute()orerror(db_error($query));
// Insert filehash table into temp filehash table
$insert_query=prepare("INSERT INTO ``shadow_filehashes`` SELECT * FROM ``filehashes`` WHERE `board` = :board AND (`post` = ".implode(' OR `post` = ',$ids).")");
// Delete filehash entries for thread from filehash table
$query=prepare(sprintf("DELETE FROM ``filehashes`` WHERE ( `thread` = :id OR `post` = :id ) AND `board` = '%s'",$board['uri']));
$query->bindValue(':id',$id,PDO::PARAM_INT);
$query->execute()orerror(db_error($query));
// Update bump order
if(isset($thread_id))
{
$query=prepare(sprintf('SELECT MAX(`time`) AS `correct_bump` FROM `posts_%s` WHERE (`thread` = :thread AND NOT email <=> "sage") OR `id` = :thread',$board['uri']));
$query=prepare("SELECT `board`, `post` FROM ``cites`` WHERE `target_board` = :board AND (`target` = ".implode(' OR `target` = ',$ids).") ORDER BY `board`");
$query->bindValue(':board',$board['uri']);
$query->execute()orerror(db_error($query));
while($cite=$query->fetch(PDO::FETCH_ASSOC)){
if($board['uri']!=$cite['board']){
if(!isset($tmp_board))
$tmp_board=$board['uri'];
openBoard($cite['board']);
}
rebuildPost($cite['post']);
}
if(isset($tmp_board))
openBoard($tmp_board);
// Insert Cited to temp table
$query=prepare("INSERT INTO ``shadow_cites`` SELECT * FROM ``cites`` WHERE (`target_board` = :board AND (`target` = ".implode(' OR `target` = ',$ids).")) OR (`board` = :board AND (`post` = ".implode(' OR `post` = ',$ids)."))");
$query->bindValue(':board',$board['uri']);
$query->execute()orerror(db_error($query));
// Delete Cites
$query=prepare("DELETE FROM ``cites`` WHERE (`target_board` = :board AND (`target` = ".implode(' OR `target` = ',$ids).")) OR (`board` = :board AND (`post` = ".implode(' OR `post` = ',$ids)."))");
$query->bindValue(':board',$board['uri']);
$query->execute()orerror(db_error($query));
if(isset($rebuild)&&$rebuild_after){
buildThread($rebuild);
buildIndex();
}
// If Thread ID is set return it (deleted post within thread) this will pe a positive number and thus viewed as true for legacy purposes
$insert_query=prepare(sprintf("INSERT INTO ``posts_%s`` SELECT * FROM ``shadow_posts_%s`` WHERE `id` = ".implode(' OR `id` = ',$ids),$board['uri'],$board['uri']));
$query=prepare(sprintf("DELETE FROM ``shadow_posts_%s`` WHERE `id` = :id OR `thread` = :id",$board['uri']));
$query->bindValue(':id',$id,PDO::PARAM_INT);
$query->execute()orerror(db_error($query));
// Insert filehash table into temp filehash table
$insert_query=prepare("INSERT INTO ``filehashes`` SELECT * FROM ``shadow_filehashes`` WHERE `board` = :board AND (`post` = ".implode(' OR `post` = ',$ids).")");
// Delete filehash entries for thread from filehash table
$query=prepare(sprintf("DELETE FROM ``shadow_filehashes`` WHERE ( `thread` = :id OR `post` = :id ) AND `board` = '%s'",$board['uri']));
$query->bindValue(':id',$id,PDO::PARAM_INT);
$query->execute()orerror(db_error($query));
// Update bump order
if(isset($thread_id))
{
$query=prepare(sprintf('SELECT MAX(`time`) AS `correct_bump` FROM `posts_%s` WHERE (`thread` = :thread AND NOT email <=> "sage") OR `id` = :thread',$board['uri']));
$query=prepare("SELECT `board`, `post` FROM ``shadow_cites`` WHERE `target_board` = :board AND (`target` = ".implode(' OR `target` = ',$ids).") ORDER BY `board`");
$query->bindValue(':board',$board['uri']);
$query->execute()orerror(db_error($query));
while($cite=$query->fetch(PDO::FETCH_ASSOC)){
if($board['uri']!=$cite['board']){
if(!isset($tmp_board))
$tmp_board=$board['uri'];
openBoard($cite['board']);
}
rebuildPost($cite['post']);
}
if(isset($tmp_board))
openBoard($tmp_board);
// Insert Temp Cited to Cited Table
$query=prepare("INSERT INTO ``cites`` SELECT * FROM ``shadow_cites`` WHERE (`target_board` = :board AND (`target` = ".implode(' OR `target` = ',$ids).")) OR (`board` = :board AND (`post` = ".implode(' OR `post` = ',$ids)."))");
$query->bindValue(':board',$board['uri']);
$query->execute()orerror(db_error($query));
// Delete Temp Cites
$query=prepare("DELETE FROM ``shadow_cites`` WHERE (`target_board` = :board AND (`target` = ".implode(' OR `target` = ',$ids).")) OR (`board` = :board AND (`post` = ".implode(' OR `post` = ',$ids)."))");
$query->bindValue(':board',$board['uri']);
$query->execute()orerror(db_error($query));
if(isset($rebuild)&&$rebuild_after){
buildThread($rebuild);
buildIndex();
}
// If Thread ID is set return it (deleted post within thread) this will pe a positive number and thus viewed as true for legacy purposes
$query=prepare(sprintf("DELETE FROM ``shadow_posts_%s`` WHERE `id` = :id OR `thread` = :id",$board['uri']));
$query->bindValue(':id',$id,PDO::PARAM_INT);
$query->execute()orerror(db_error($query));
// Delete filehash entries for thread from filehash table
$query=prepare(sprintf("DELETE FROM ``shadow_filehashes`` WHERE ( `thread` = :id OR `post` = :id ) AND `board` = '%s'",$board['uri']));
$query->bindValue(':id',$id,PDO::PARAM_INT);
$query->execute()orerror(db_error($query));
// Delete Temp Cites
$query=prepare("DELETE FROM ``shadow_cites`` WHERE (`target_board` = :board AND (`target` = ".implode(' OR `target` = ',$ids).")) OR (`board` = :board AND (`post` = ".implode(' OR `post` = ',$ids)."))");
$query->bindValue(':board',$board['uri']);
$query->execute()orerror(db_error($query));
// If Thread ID is set return it (deleted post within thread) this will pe a positive number and thus viewed as true for legacy purposes
if(isset($thread_id))
return$thread_id;
returntrue;
}
staticpublicfunctionpurge(){
global$config;
// Delete data from temp table
$query=prepare("SELECT * FROM ``shadow_deleted`` WHERE `del_time` < :del_time");
$delete_query=prepare("DELETE FROM ``cites`` WHERE (`target_board` = :board AND (`target` = ".implode(' OR `target` = ',$ids).")) OR (`board` = :board AND (`post` = ".implode(' OR `post` = ',$ids)."))");