mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-22 02:25:59 +02:00
Further PostgreSQL compatibility
This commit is contained in:
parent
5dc5160f8e
commit
bc8f904c3a
4 changed files with 63 additions and 63 deletions
|
@ -44,7 +44,7 @@ while ($row = $stmt_domain->fetch(PDO::FETCH_ASSOC)) {
|
|||
}
|
||||
}
|
||||
|
||||
[$price] = $dbh->query("SELECT m$date_add FROM domain_price WHERE tldid = '$tld_id' AND command` = 'transfer' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
[$price] = $dbh->query("SELECT m$date_add FROM domain_price WHERE tldid = '$tld_id' AND command = 'transfer' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
|
||||
if (($registrar_balance + $creditLimit) < $price) {
|
||||
$echo = 'The registrar who took over this domain has no money to pay the renewal period that resulted from the transfer request';
|
||||
|
|
|
@ -15,9 +15,9 @@ try {
|
|||
|
||||
try {
|
||||
// Prepare and execute the SQL statement to select unused hosts
|
||||
$stmt = $dbh->prepare("SELECT `h`.`id`,`h`.`name` FROM `host` AS `h`
|
||||
LEFT JOIN `domain_host_map` AS `m` ON `h`.`id` = `m`.`host_id`
|
||||
WHERE `m`.`host_id` IS NULL AND `h`.`domain_id` IS NULL AND `h`.`crdate` < (NOW() - INTERVAL 1 MONTH)");
|
||||
$stmt = $dbh->prepare("SELECT h.id, h.name FROM host AS h
|
||||
LEFT JOIN domain_host_map AS m ON h.id = m.host_id
|
||||
WHERE m.host_id IS NULL AND h.domain_id IS NULL AND h.crdate < (NOW() - INTERVAL 1 MONTH)");
|
||||
$stmt->execute();
|
||||
|
||||
$ids = [];
|
||||
|
@ -28,16 +28,16 @@ try {
|
|||
// Delete associated records from various tables for hosts
|
||||
if (!empty($ids)) {
|
||||
$placeholders = implode(',', array_fill(0, count($ids), '?'));
|
||||
$dbh->prepare("DELETE FROM `host_status` WHERE `host_id` IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM `host_addr` WHERE `host_id` IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM `host` WHERE `id` IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM host_status WHERE host_id IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM host_addr WHERE host_id IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM host WHERE id IN ($placeholders)")->execute($ids);
|
||||
}
|
||||
|
||||
// Prepare and execute the SQL statement to select unused contacts
|
||||
$stmt = $dbh->prepare("SELECT `c`.`id`,`c`.`identifier` FROM `contact` AS `c`
|
||||
LEFT JOIN `domain_contact_map` AS `m` ON `c`.`id` = `m`.`contact_id`
|
||||
LEFT JOIN `domain` AS `d` ON `c`.`id` = `d`.`registrant`
|
||||
WHERE `m`.`contact_id` IS NULL AND `d`.`registrant` IS NULL AND `c`.`crdate` < (NOW() - INTERVAL 1 MONTH)");
|
||||
$stmt = $dbh->prepare("SELECT c.id, c.identifier FROM contact AS c
|
||||
LEFT JOIN domain_contact_map AS m ON c.id = m.contact_id
|
||||
LEFT JOIN domain AS d ON c.id = d.registrant
|
||||
WHERE m.contact_id IS NULL AND d.registrant IS NULL AND c.crdate < (NOW() - INTERVAL 1 MONTH)");
|
||||
$stmt->execute();
|
||||
|
||||
$contact_ids = [];
|
||||
|
@ -48,10 +48,10 @@ try {
|
|||
// Delete associated records from various tables for contacts
|
||||
if (!empty($contact_ids)) {
|
||||
$placeholders = implode(',', array_fill(0, count($contact_ids), '?'));
|
||||
$dbh->prepare("DELETE FROM `contact_status` WHERE `contact_id` IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM `contact_postalInfo` WHERE `contact_id` IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM `contact_authInfo` WHERE `contact_id` IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM `contact` WHERE `id` IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM contact_status WHERE contact_id IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM contact_postalInfo WHERE contact_id IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM contact_authInfo WHERE contact_id IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM contact WHERE id IN ($placeholders)")->execute($contact_ids);
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
|
|
|
@ -17,7 +17,7 @@ try {
|
|||
$auto_renew = 0;
|
||||
|
||||
if ($auto_renew) {
|
||||
$sth_autorenewperiod = $dbh->prepare("SELECT `id`, `name`, `tldid`, `exdate`, `clid` FROM `domain` WHERE CURRENT_TIMESTAMP > `exdate` AND `rgpstatus` IS NULL");
|
||||
$sth_autorenewperiod = $dbh->prepare("SELECT id, name, tldid, exdate, clid FROM domain WHERE CURRENT_TIMESTAMP > exdate AND rgpstatus IS NULL");
|
||||
$sth_autorenewperiod->execute();
|
||||
while ($row = $sth_autorenewperiod->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
|
@ -26,7 +26,7 @@ if ($auto_renew) {
|
|||
$exdate = $row['exdate'];
|
||||
$clid = $row['clid'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT `status` FROM `domain_status` WHERE `domain_id` = ?");
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$set_autorenewPeriod = 1;
|
||||
|
@ -39,24 +39,24 @@ if ($auto_renew) {
|
|||
}
|
||||
|
||||
if ($set_autorenewPeriod) {
|
||||
list($registrar_balance, $creditLimit) = $dbh->query("SELECT `accountBalance`, `creditLimit` FROM `registrar` WHERE `id` = '$clid' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$price = $dbh->query("SELECT `m12` FROM `domain_price` WHERE `tldid` = '$tldid' AND `command` = 'renew' LIMIT 1")->fetchColumn();
|
||||
list($registrar_balance, $creditLimit) = $dbh->query("SELECT accountBalance, creditLimit FROM registrar WHERE id = '$clid' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$price = $dbh->query("SELECT m12 FROM domain_price WHERE tldid = '$tldid' AND command = 'renew' LIMIT 1")->fetchColumn();
|
||||
|
||||
if (($registrar_balance + $creditLimit) > $price) {
|
||||
$dbh->exec("UPDATE `domain` SET `rgpstatus` = 'autoRenewPeriod', `exdate` = DATE_ADD(`exdate`, INTERVAL 12 MONTH), `autoRenewPeriod` = '12', `renewedDate` = `exdate` WHERE `id` = '$domain_id'");
|
||||
$dbh->exec("UPDATE `registrar` SET `accountBalance` = (`accountBalance` - $price) WHERE `id` = '$clid'");
|
||||
$dbh->exec("INSERT INTO `payment_history` (`registrar_id`, `date`, `description`, `amount`) VALUES('$clid', CURRENT_TIMESTAMP, 'autoRenew domain $name for period 12 MONTH', '-$price')");
|
||||
list($to) = $dbh->query("SELECT `exdate` FROM `domain` WHERE `id` = '$domain_id' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$sth = $dbh->prepare("INSERT INTO `statement` (`registrar_id`, `date`, `command`, `domain_name`, `length_in_months`, `from`, `to`, `amount`) VALUES(?, CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?)");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'autoRenewPeriod', exdate = DATE_ADD(exdate, INTERVAL 12 MONTH), autoRenewPeriod = '12', renewedDate = exdate WHERE id = '$domain_id'");
|
||||
$dbh->exec("UPDATE registrar SET accountBalance = (accountBalance - $price) WHERE id = '$clid'");
|
||||
$dbh->exec("INSERT INTO payment_history (registrar_id, date, description, amount) VALUES('$clid', CURRENT_TIMESTAMP, 'autoRenew domain $name for period 12 MONTH', '-$price')");
|
||||
list($to) = $dbh->query("SELECT exdate FROM domain WHERE id = '$domain_id' LIMIT 1")->fetch(PDO::FETCH_NUM);
|
||||
$sth = $dbh->prepare("INSERT INTO statement (registrar_id, date, command, domain_name, length_in_months, from, to, amount) VALUES(?, CURRENT_TIMESTAMP, ?, ?, ?, ?, ?, ?)");
|
||||
$sth->execute([$clid, 'autoRenew', $name, '12', $exdate, $to, $price]);
|
||||
if (!$dbh->query("SELECT `id` FROM `statistics` WHERE `date` = CURDATE()")->fetchColumn()) {
|
||||
$dbh->exec("INSERT IGNORE INTO `statistics` (`date`) VALUES(CURDATE())");
|
||||
if (!$dbh->query("SELECT id FROM statistics WHERE date = CURDATE()")->fetchColumn()) {
|
||||
$dbh->exec("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");
|
||||
}
|
||||
$dbh->exec("UPDATE `statistics` SET `renewed_domains` = `renewed_domains` + 1 WHERE `date` = CURDATE()");
|
||||
$dbh->exec("UPDATE statistics SET renewed_domains = renewed_domains + 1 WHERE date = CURDATE()");
|
||||
} else {
|
||||
$dbh->exec("DELETE FROM `domain_status` WHERE `domain_id` = '$domain_id'");
|
||||
$dbh->exec("UPDATE `domain` SET `rgpstatus` = 'redemptionPeriod', `delTime` = `exdate` WHERE `id` = '$domain_id'");
|
||||
$dbh->exec("INSERT INTO `domain_status` (`domain_id`, `status`) VALUES('$domain_id', 'pendingDelete')");
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod', delTime = exdate WHERE id = '$domain_id'");
|
||||
$dbh->exec("INSERT INTO domain_status (domain_id, status) VALUES('$domain_id', 'pendingDelete')");
|
||||
}
|
||||
}
|
||||
$currentDateTime = new DateTime();
|
||||
|
@ -64,14 +64,14 @@ if ($auto_renew) {
|
|||
}
|
||||
} else {
|
||||
$grace_period = 30;
|
||||
$sth_graceperiod = $dbh->prepare("SELECT `id`, `name`, `exdate` FROM `domain` WHERE CURRENT_TIMESTAMP > DATE_ADD(`exdate`, INTERVAL $grace_period DAY) AND `rgpstatus` IS NULL");
|
||||
$sth_graceperiod = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(exdate, INTERVAL $grace_period DAY) AND rgpstatus IS NULL");
|
||||
$sth_graceperiod->execute();
|
||||
while ($row = $sth_graceperiod->fetch(PDO::FETCH_ASSOC)) {
|
||||
$domain_id = $row['id'];
|
||||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT `status` FROM `domain_status` WHERE `domain_id` = ?");
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$set_graceperiod = 1;
|
||||
|
@ -84,9 +84,9 @@ if ($auto_renew) {
|
|||
}
|
||||
|
||||
if ($set_graceperiod) {
|
||||
$dbh->exec("DELETE FROM `domain_status` WHERE `domain_id` = '$domain_id'");
|
||||
$dbh->exec("UPDATE `domain` SET `rgpstatus` = 'redemptionPeriod', `delTime` = DATE_ADD(`exdate`, INTERVAL $grace_period DAY) WHERE `id` = '$domain_id'");
|
||||
$dbh->exec("INSERT INTO `domain_status` (`domain_id`, `status`) VALUES('$domain_id', 'pendingDelete')");
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod', delTime = DATE_ADD(exdate, INTERVAL $grace_period DAY) WHERE id = '$domain_id'");
|
||||
$dbh->exec("INSERT INTO domain_status (domain_id, status) VALUES('$domain_id', 'pendingDelete')");
|
||||
}
|
||||
$currentDateTime = new DateTime();
|
||||
echo $currentDateTime->format("Y-m-d H:i:s.v") . " - $domain_id\t|\t$name\t|\trgpStatus:redemptionPeriod exdate:$exdate\n";
|
||||
|
@ -95,19 +95,19 @@ if ($auto_renew) {
|
|||
|
||||
try {
|
||||
// clean autoRenewPeriod after 45 days
|
||||
$sql1 = "UPDATE `domain` SET `rgpstatus` = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(`exdate`, INTERVAL 45 DAY) AND `rgpstatus` = 'autoRenewPeriod'";
|
||||
$sql1 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(exdate, INTERVAL 45 DAY) AND rgpstatus = 'autoRenewPeriod'";
|
||||
$dbh->exec($sql1);
|
||||
|
||||
// clean addPeriod after 5 days
|
||||
$sql2 = "UPDATE `domain` SET `rgpstatus` = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(`crdate`, INTERVAL 5 DAY) AND `rgpstatus` = 'addPeriod'";
|
||||
$sql2 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(crdate, INTERVAL 5 DAY) AND rgpstatus = 'addPeriod'";
|
||||
$dbh->exec($sql2);
|
||||
|
||||
// clean renewPeriod after 5 days
|
||||
$sql3 = "UPDATE `domain` SET `rgpstatus` = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(`renewedDate`, INTERVAL 5 DAY) AND `rgpstatus` = 'renewPeriod'";
|
||||
$sql3 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(renewedDate, INTERVAL 5 DAY) AND rgpstatus = 'renewPeriod'";
|
||||
$dbh->exec($sql3);
|
||||
|
||||
// clean transferPeriod after 5 days
|
||||
$sql4 = "UPDATE `domain` SET `rgpstatus` = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(`trdate`, INTERVAL 5 DAY) AND `rgpstatus` = 'transferPeriod'";
|
||||
$sql4 = "UPDATE domain SET rgpstatus = NULL WHERE CURRENT_TIMESTAMP > DATE_ADD(trdate, INTERVAL 5 DAY) AND rgpstatus = 'transferPeriod'";
|
||||
$dbh->exec($sql4);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
|
@ -116,7 +116,7 @@ try {
|
|||
|
||||
// Pending Delete
|
||||
// The current value of the redemptionPeriod is 30 calendar days.
|
||||
$sth_pendingdelete = $dbh->prepare("SELECT `id`, `name`, `exdate` FROM `domain` WHERE CURRENT_TIMESTAMP > DATE_ADD(`delTime`, INTERVAL 30 DAY) AND `rgpstatus` = 'redemptionPeriod'");
|
||||
$sth_pendingdelete = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(delTime, INTERVAL 30 DAY) AND rgpstatus = 'redemptionPeriod'");
|
||||
$sth_pendingdelete->execute();
|
||||
|
||||
while ($row = $sth_pendingdelete->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
@ -124,7 +124,7 @@ while ($row = $sth_pendingdelete->fetch(PDO::FETCH_ASSOC)) {
|
|||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT `status` FROM `domain_status` WHERE `domain_id` = ?");
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$set_pendingDelete = 1;
|
||||
|
@ -137,14 +137,14 @@ while ($row = $sth_pendingdelete->fetch(PDO::FETCH_ASSOC)) {
|
|||
}
|
||||
|
||||
if ($set_pendingDelete) {
|
||||
$dbh->exec("UPDATE `domain` SET `rgpstatus` = 'pendingDelete' WHERE `id` = '$domain_id'");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'pendingDelete' WHERE id = '$domain_id'");
|
||||
}
|
||||
$currentDateTime = new DateTime();
|
||||
echo $currentDateTime->format("Y-m-d H:i:s.v") . " - $domain_id\t|\t$name\t|\trgpStatus:pendingDelete exdate:$exdate\n";
|
||||
}
|
||||
|
||||
// Pending Restore
|
||||
$sth_pendingRestore = $dbh->prepare("SELECT `id`, `name`, `exdate` FROM `domain` WHERE `rgpstatus` = 'pendingRestore' AND (CURRENT_TIMESTAMP > DATE_ADD(`resTime`, INTERVAL 7 DAY))");
|
||||
$sth_pendingRestore = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE rgpstatus = 'pendingRestore' AND (CURRENT_TIMESTAMP > DATE_ADD(resTime, INTERVAL 7 DAY))");
|
||||
$sth_pendingRestore->execute();
|
||||
|
||||
while ($row = $sth_pendingRestore->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
@ -152,14 +152,14 @@ while ($row = $sth_pendingRestore->fetch(PDO::FETCH_ASSOC)) {
|
|||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$dbh->exec("UPDATE `domain` SET `rgpstatus` = 'redemptionPeriod' WHERE `id` = '$domain_id'");
|
||||
$dbh->exec("UPDATE domain SET rgpstatus = 'redemptionPeriod' WHERE id = '$domain_id'");
|
||||
|
||||
$currentDateTime = new DateTime();
|
||||
echo $currentDateTime->format("Y-m-d H:i:s.v") . " - $domain_id\t|\t$name\t|\tback to redemptionPeriod from pendingRestore exdate:$exdate\n";
|
||||
}
|
||||
|
||||
// Domain Deletion
|
||||
$sth_delete = $dbh->prepare("SELECT `id`, `name`, `exdate` FROM `domain` WHERE CURRENT_TIMESTAMP > DATE_ADD(`delTime`, INTERVAL 35 DAY) AND `rgpstatus` = 'pendingDelete'");
|
||||
$sth_delete = $dbh->prepare("SELECT id, name, exdate FROM domain WHERE CURRENT_TIMESTAMP > DATE_ADD(delTime, INTERVAL 35 DAY) AND rgpstatus = 'pendingDelete'");
|
||||
$sth_delete->execute();
|
||||
|
||||
while ($row = $sth_delete->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
@ -167,7 +167,7 @@ while ($row = $sth_delete->fetch(PDO::FETCH_ASSOC)) {
|
|||
$name = $row['name'];
|
||||
$exdate = $row['exdate'];
|
||||
|
||||
$sth_status = $dbh->prepare("SELECT `status` FROM `domain_status` WHERE `domain_id` = ?");
|
||||
$sth_status = $dbh->prepare("SELECT status FROM domain_status WHERE domain_id = ?");
|
||||
$sth_status->execute([$domain_id]);
|
||||
|
||||
$delete_domain = 0;
|
||||
|
@ -184,31 +184,31 @@ while ($row = $sth_delete->fetch(PDO::FETCH_ASSOC)) {
|
|||
|
||||
if ($delete_domain) {
|
||||
// Actual deletion process
|
||||
$sth = $dbh->prepare("SELECT `id` FROM `host` WHERE `domain_id` = ?");
|
||||
$sth = $dbh->prepare("SELECT id FROM host WHERE domain_id = ?");
|
||||
$sth->execute([$domain_id]);
|
||||
while ($host_row = $sth->fetch(PDO::FETCH_ASSOC)) {
|
||||
$host_id = $host_row['id'];
|
||||
$dbh->exec("DELETE FROM `host_addr` WHERE `host_id` = '$host_id'");
|
||||
$dbh->exec("DELETE FROM `host_status` WHERE `host_id` = '$host_id'");
|
||||
$dbh->exec("DELETE FROM `domain_host_map` WHERE `host_id` = '$host_id'");
|
||||
$dbh->exec("DELETE FROM host_addr WHERE host_id = '$host_id'");
|
||||
$dbh->exec("DELETE FROM host_status WHERE host_id = '$host_id'");
|
||||
$dbh->exec("DELETE FROM domain_host_map WHERE host_id = '$host_id'");
|
||||
}
|
||||
|
||||
$dbh->exec("DELETE FROM `domain_contact_map` WHERE `domain_id` = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM `domain_host_map` WHERE `domain_id` = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM `domain_authInfo` WHERE `domain_id` = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM `domain_status` WHERE `domain_id` = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM `host` WHERE `domain_id` = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_contact_map WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_host_map WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_authInfo WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM domain_status WHERE domain_id = '$domain_id'");
|
||||
$dbh->exec("DELETE FROM host WHERE domain_id = '$domain_id'");
|
||||
|
||||
$sth = $dbh->prepare("DELETE FROM `domain` WHERE `id` = ?");
|
||||
$sth = $dbh->prepare("DELETE FROM domain WHERE id = ?");
|
||||
$sth->execute([$domain_id]);
|
||||
if ($sth->errorCode() !== '00000') {
|
||||
$errorInfo = $sth->errorInfo();
|
||||
echo 'Numele de domeniu nu a fost sters cred ca este vre-o legatura cu alte obiecte: ' . $errorInfo[2];
|
||||
} else {
|
||||
if (!$dbh->query("SELECT `id` FROM `statistics` WHERE `date` = CURDATE()")->fetchColumn()) {
|
||||
$dbh->exec("INSERT IGNORE INTO `statistics` (`date`) VALUES(CURDATE())");
|
||||
if (!$dbh->query("SELECT id FROM statistics WHERE date = CURDATE()")->fetchColumn()) {
|
||||
$dbh->exec("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");
|
||||
}
|
||||
$dbh->exec("UPDATE `statistics` SET `deleted_domains` = `deleted_domains` + 1 WHERE `date` = CURDATE()");
|
||||
$dbh->exec("UPDATE statistics SET deleted_domains = deleted_domains + 1 WHERE date = CURDATE()");
|
||||
}
|
||||
}
|
||||
$currentDateTime = new DateTime();
|
||||
|
|
|
@ -15,18 +15,18 @@ try {
|
|||
|
||||
try {
|
||||
// Check if there's an entry for the current date
|
||||
$query = "SELECT `id` FROM `statistics` WHERE `date` = CURDATE()";
|
||||
$query = "SELECT id FROM statistics WHERE date = CURDATE()";
|
||||
$curdate_id = $dbh->query($query)->fetchColumn();
|
||||
|
||||
if (!$curdate_id) {
|
||||
$dbh->exec("INSERT IGNORE INTO `statistics` (`date`) VALUES(CURDATE())");
|
||||
$dbh->exec("INSERT IGNORE INTO statistics (date) VALUES(CURDATE())");
|
||||
}
|
||||
|
||||
// Get the total number of domains
|
||||
$total_domains = $dbh->query("SELECT COUNT(`id`) AS `total_domains` FROM `domain`")->fetchColumn();
|
||||
$total_domains = $dbh->query("SELECT COUNT(id) AS total_domains FROM domain")->fetchColumn();
|
||||
|
||||
// Update the statistics table with the total number of domains for the current date
|
||||
$dbh->exec("UPDATE `statistics` SET `total_domains` = '$total_domains' WHERE `date` = CURDATE()");
|
||||
$dbh->exec("UPDATE statistics SET total_domains = '$total_domains' WHERE date = CURDATE()");
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// Handle database errors
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue