diff --git a/UPDATE_SQL__SHADOW_DELETE.sql b/UPDATE_SQL__SHADOW_DELETE.sql new file mode 100644 index 00000000..4fdcf942 --- /dev/null +++ b/UPDATE_SQL__SHADOW_DELETE.sql @@ -0,0 +1,76 @@ + + + + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `shadow_antispam` +-- + +CREATE TABLE IF NOT EXISTS `shadow_antispam` ( + `board` varchar(58) NOT NULL, + `thread` int(11) DEFAULT NULL, + `hash` char(40) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, + `created` int(11) NOT NULL, + `expires` int(11) DEFAULT NULL, + `passed` smallint(6) NOT NULL, + PRIMARY KEY (`hash`), + KEY `board` (`board`,`thread`), + KEY `expires` (`expires`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `shadow_cites` +-- + +CREATE TABLE IF NOT EXISTS `shadow_cites` ( + `board` varchar(58) NOT NULL, + `post` int(11) NOT NULL, + `target_board` varchar(58) NOT NULL, + `target` int(11) NOT NULL, + KEY `target` (`target_board`,`target`), + KEY `post` (`board`,`post`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `shadow_deleted` +-- + +CREATE TABLE IF NOT EXISTS `shadow_deleted` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `board` varchar(58) NOT NULL, + `post_id` int(10) NOT NULL, + `del_time` int(11) NOT NULL, + `files` text CHARACTER SET ascii NOT NULL, + `cite_ids` text CHARACTER SET armscii8 NOT NULL, + PRIMARY KEY (`id`), + KEY `board` (`board`), + KEY `post_id` (`post_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `shadow_filehashes` +-- + +CREATE TABLE IF NOT EXISTS `shadow_filehashes` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `board` varchar(58) NOT NULL, + `thread` int(11) NOT NULL, + `post` int(11) NOT NULL, + `filehash` text CHARACTER SET ascii NOT NULL, + PRIMARY KEY (`id`), + KEY `thread_id` (`thread`), + KEY `post_id` (`post`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 472b1e56..97f30fd0 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -503,6 +503,13 @@ function mod_new_board() { $query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query); query($query) or error(db_error()); + + // Create shadow copy table + $query = Element('posts.sql', array('board' => $board['uri'])); + $query = str_replace("``posts_", "``shadow_posts_", $query); + if (mysql_version() < 50503) + $query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query); + query($query) or error(db_error()); // Create Archive Table in DB $query = Element('archive.sql', array('board' => $board['uri'])); diff --git a/inc/shadow-delete.php b/inc/shadow-delete.php index 5e8487ee..a5e744ee 100644 --- a/inc/shadow-delete.php +++ b/inc/shadow-delete.php @@ -403,7 +403,7 @@ class ShadowDelete { // Delete Temp Cites $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) . "))"); - $delete_query->bindValue(':board', $board['uri']); + $delete_query->bindValue(':board', $shadow_post['board']); $delete_query->execute() or error(db_error($delete_query)); }