mirror of
https://github.com/PurpleI2P/regi2p.git
synced 2025-02-11 11:44:14 +00:00
save re-registered records to "outdated" table
This commit is contained in:
parent
eb94626b2e
commit
ac9603cc43
@ -1,5 +1,5 @@
|
||||
CREATE TABLE `hosts` (
|
||||
`host` varchar(67) NOT NULL,
|
||||
`host` varchar(67) NOT NULL PRIMARY KEY,
|
||||
`base64` varchar(616) NOT NULL,
|
||||
`base32` varchar(52) NOT NULL,
|
||||
`description` varchar(128) NOT NULL DEFAULT '',
|
||||
@ -12,17 +12,21 @@ CREATE TABLE `hosts` (
|
||||
`blacklisted` tinyint(1) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `outdated` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`host` varchar(67) NOT NULL,
|
||||
`base64` varchar(616) NOT NULL,
|
||||
`base32` varchar(52) NOT NULL,
|
||||
`description` varchar(128) NOT NULL DEFAULT '',
|
||||
`add_date` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||
`last_seen` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`updated` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `subscriptions` (
|
||||
`name` varchar(67) NOT NULL,
|
||||
`name` varchar(67) NOT NULL PRIMARY KEY,
|
||||
`url` varchar(256) NOT NULL,
|
||||
`modified` char(30) NOT NULL DEFAULT '',
|
||||
`etag` varchar(64) NOT NULL DEFAULT '',
|
||||
`active` tinyint(1) NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
ALTER TABLE `hosts`
|
||||
ADD PRIMARY KEY (`host`);
|
||||
|
||||
ALTER TABLE `subscriptions`
|
||||
ADD PRIMARY KEY (`name`);
|
||||
|
@ -201,7 +201,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
|
||||
|
||||
/* print all records, which will be deleted*/
|
||||
$STH = $pdo->prepare('SELECT `host`, `base32`, `base64` FROM `hosts` WHERE `host` = ? OR `host` LIKE ?');
|
||||
$STH->execute([$domain, '%'.$domain]);
|
||||
$STH->execute([$domain, '%.'.$domain]);
|
||||
$hosts = $STH->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($hosts as $host) {
|
||||
$log .= "Host: " . $host['host'] . PHP_EOL . "Base32: " . $host['base32'] . PHP_EOL . "Base64: " . $host['base64'] . PHP_EOL;
|
||||
@ -209,8 +209,14 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
|
||||
|
||||
file_put_contents(__DIR__ . '/../logs/reg.log', $log, FILE_APPEND);
|
||||
|
||||
/* remove domain and subdomains if any found */
|
||||
$pdo->prepare('DELETE FROM `hosts` WHERE `host` = ? OR `host` LIKE ?')->execute([$domain, '%'.$domain]);
|
||||
/* copy records of re-registered domain with subdomains to 'outdated' table and delete them from 'hosts' */
|
||||
$STH = $pdo->prepare(
|
||||
'INSERT INTO `outdated` (`host`, `base64`, `base32`, `description`, `add_date`, `last_seen`) ' .
|
||||
' SELECT `host`, `base64`, `base32`, `description`, `add_date`, `last_seen` FROM `hosts` ' .
|
||||
' WHERE `host` = ? OR `host` LIKE ?; ' .
|
||||
'DELETE FROM `hosts` WHERE `host` = ? OR `host` LIKE ?');
|
||||
$STH->execute([$domain, '%.'.$domain, $domain, '%.'.$domain]);
|
||||
|
||||
$result["reregister"] = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user