mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-18 23:33:48 +02:00
Added PgSQL support in all automation scripts
This commit is contained in:
parent
2ebeed2500
commit
ba05bd618c
7 changed files with 93 additions and 47 deletions
|
@ -1,10 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Connect to the MySQL database using PDO
|
$c = require_once 'config.php';
|
||||||
$c = require 'config.php';
|
require_once 'helpers.php';
|
||||||
$dsn = "mysql:host={$c['mysql_host']};dbname={$c['mysql_database']};port={$c['mysql_port']}";
|
|
||||||
$dbh = new PDO($dsn, $c['mysql_username'], $c['mysql_password']);
|
// Connect to the database
|
||||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']};port={$c['db_port']}";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dbh = new PDO($dsn, $c['db_username'], $c['db_password']);
|
||||||
|
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Connection failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$query_domain = "SELECT id, name, registrant, crdate, exdate, `update`, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE CURRENT_TIMESTAMP > acdate AND trstatus = 'pending'";
|
$query_domain = "SELECT id, name, registrant, crdate, exdate, `update`, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, transfer_exdate FROM domain WHERE CURRENT_TIMESTAMP > acdate AND trstatus = 'pending'";
|
||||||
$stmt_domain = $dbh->prepare($query_domain);
|
$stmt_domain = $dbh->prepare($query_domain);
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
try {
|
$c = require_once 'config.php';
|
||||||
// Create a new PDO connection
|
require_once 'helpers.php';
|
||||||
$c = require 'config.php';
|
|
||||||
$dsn = "mysql:host={$c['mysql_host']};dbname={$c['mysql_database']};port={$c['mysql_port']}";
|
|
||||||
$dbh = new PDO($dsn, $c['mysql_username'], $c['mysql_password']);
|
|
||||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
|
|
||||||
|
// Connect to the database
|
||||||
|
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']};port={$c['db_port']}";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dbh = new PDO($dsn, $c['db_username'], $c['db_password']);
|
||||||
|
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Connection failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Prepare and execute the SQL statement to select unused hosts
|
// Prepare and execute the SQL statement to select unused hosts
|
||||||
$stmt = $dbh->prepare("SELECT `h`.`id`,`h`.`name` FROM `host` AS `h`
|
$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`
|
LEFT JOIN `domain_host_map` AS `m` ON `h`.`id` = `m`.`host_id`
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Connect to the MySQL database using PDO
|
$c = require_once 'config.php';
|
||||||
$c = require 'config.php';
|
require_once 'helpers.php';
|
||||||
$dsn = "mysql:host={$c['mysql_host']};dbname={$c['mysql_database']};port={$c['mysql_port']}";
|
|
||||||
$dbh = new PDO($dsn, $c['mysql_username'], $c['mysql_password']);
|
// Connect to the database
|
||||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']};port={$c['db_port']}";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dbh = new PDO($dsn, $c['db_username'], $c['db_password']);
|
||||||
|
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Connection failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-Renew Grace Period
|
// Auto-Renew Grace Period
|
||||||
$auto_renew = 0;
|
$auto_renew = 0;
|
||||||
|
|
|
@ -6,26 +6,31 @@ require __DIR__ . '/vendor/autoload.php';
|
||||||
$c = require_once 'config.php';
|
$c = require_once 'config.php';
|
||||||
require_once 'helpers.php';
|
require_once 'helpers.php';
|
||||||
|
|
||||||
// Database connection
|
// Connect to the database
|
||||||
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']}";
|
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']}";
|
||||||
$options = [
|
$options = [
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
PDO::ATTR_EMULATE_PREPARES => false,
|
PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
];
|
];
|
||||||
$pdo = new PDO($dsn, $c['db_username'], $c['db_password'], $options);
|
|
||||||
|
|
||||||
$domainCount = fetchCount($pdo, 'domain');
|
try {
|
||||||
$hostCount = fetchCount($pdo, 'host');
|
$dbh = new PDO($dsn, $c['db_username'], $c['db_password'], $options);
|
||||||
$contactCount = fetchCount($pdo, 'contact');
|
} catch (PDOException $e) {
|
||||||
$registrarCount = fetchCount($pdo, 'registrar');
|
die("Connection failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$domainCount = fetchCount($dbh, 'domain');
|
||||||
|
$hostCount = fetchCount($dbh, 'host');
|
||||||
|
$contactCount = fetchCount($dbh, 'contact');
|
||||||
|
$registrarCount = fetchCount($dbh, 'registrar');
|
||||||
|
|
||||||
// Fetching TLDs
|
// Fetching TLDs
|
||||||
$stmt = $pdo->query("SELECT id,tld FROM domain_tld;");
|
$stmt = $dbh->query("SELECT id,tld FROM domain_tld;");
|
||||||
$tlds = $stmt->fetchAll();
|
$tlds = $stmt->fetchAll();
|
||||||
|
|
||||||
// Fetching details from rde_escrow_deposits table
|
// Fetching details from rde_escrow_deposits table
|
||||||
$stmt = $pdo->prepare("SELECT deposit_id, revision FROM rde_escrow_deposits;");
|
$stmt = $dbh->prepare("SELECT deposit_id, revision FROM rde_escrow_deposits;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$deposit_id = $stmt->fetch();
|
$deposit_id = $stmt->fetch();
|
||||||
|
|
||||||
|
@ -56,7 +61,7 @@ foreach ($tlds as $tld) {
|
||||||
$xml->writeAttributeNS('xmlns', 'rdeRegistrar', null, 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
$xml->writeAttributeNS('xmlns', 'rdeRegistrar', null, 'urn:ietf:params:xml:ns:rdeRegistrar-1.0');
|
||||||
|
|
||||||
// Fetch domain details for this TLD
|
// Fetch domain details for this TLD
|
||||||
$stmt = $pdo->prepare("SELECT * FROM domain WHERE tldid = :tldid;");
|
$stmt = $dbh->prepare("SELECT * FROM domain WHERE tldid = :tldid;");
|
||||||
$stmt->bindParam(':tldid', $tld['id']);
|
$stmt->bindParam(':tldid', $tld['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domains = $stmt->fetchAll();
|
$domains = $stmt->fetchAll();
|
||||||
|
@ -69,7 +74,7 @@ foreach ($tlds as $tld) {
|
||||||
$xml->writeElement('rdeDom:idnTableId', 'Latn');
|
$xml->writeElement('rdeDom:idnTableId', 'Latn');
|
||||||
|
|
||||||
// Fetch domain status
|
// Fetch domain status
|
||||||
$stmt = $pdo->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
|
$stmt = $dbh->prepare("SELECT * FROM domain_status WHERE domain_id = :domain_id;");
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$status = $stmt->fetch();
|
$status = $stmt->fetch();
|
||||||
|
@ -78,7 +83,7 @@ foreach ($tlds as $tld) {
|
||||||
$xml->writeElement('rdeDom:registrant', $domain['registrant']);
|
$xml->writeElement('rdeDom:registrant', $domain['registrant']);
|
||||||
|
|
||||||
// Fetch domain contacts
|
// Fetch domain contacts
|
||||||
$stmt = $pdo->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
|
$stmt = $dbh->prepare("SELECT * FROM domain_contact_map WHERE domain_id = :domain_id;");
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domain_contacts = $stmt->fetchAll();
|
$domain_contacts = $stmt->fetchAll();
|
||||||
|
@ -90,7 +95,7 @@ foreach ($tlds as $tld) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch domain hosts and incorporate into XML
|
// Fetch domain hosts and incorporate into XML
|
||||||
$stmt = $pdo->prepare("SELECT host.name FROM domain_host_map JOIN host ON domain_host_map.host_id = host.id WHERE domain_host_map.domain_id = :domain_id;");
|
$stmt = $dbh->prepare("SELECT host.name FROM domain_host_map JOIN host ON domain_host_map.host_id = host.id WHERE domain_host_map.domain_id = :domain_id;");
|
||||||
$stmt->bindParam(':domain_id', $domain['id']);
|
$stmt->bindParam(':domain_id', $domain['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$domain_hosts = $stmt->fetchAll();
|
$domain_hosts = $stmt->fetchAll();
|
||||||
|
@ -109,7 +114,7 @@ foreach ($tlds as $tld) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch and incorporate registrar details
|
// Fetch and incorporate registrar details
|
||||||
$stmt = $pdo->prepare("SELECT * FROM registrar;");
|
$stmt = $dbh->prepare("SELECT * FROM registrar;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$registrars = $stmt->fetchAll();
|
$registrars = $stmt->fetchAll();
|
||||||
|
|
||||||
|
@ -121,7 +126,7 @@ foreach ($tlds as $tld) {
|
||||||
$xml->writeElement('rdeRegistrar:status', 'ok');
|
$xml->writeElement('rdeRegistrar:status', 'ok');
|
||||||
|
|
||||||
// Fetch and incorporate registrar contact details
|
// Fetch and incorporate registrar contact details
|
||||||
$stmt = $pdo->prepare("SELECT * FROM registrar_contact WHERE registrar_id = :registrar_id;");
|
$stmt = $dbh->prepare("SELECT * FROM registrar_contact WHERE registrar_id = :registrar_id;");
|
||||||
$stmt->bindParam(':registrar_id', $registrar['id']);
|
$stmt->bindParam(':registrar_id', $registrar['id']);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$registrar_contacts = $stmt->fetchAll();
|
$registrar_contacts = $stmt->fetchAll();
|
||||||
|
@ -153,7 +158,7 @@ foreach ($tlds as $tld) {
|
||||||
$xml->endElement(); // Closing rdeRegistrar:registrar
|
$xml->endElement(); // Closing rdeRegistrar:registrar
|
||||||
|
|
||||||
// Fetch and incorporate host details
|
// Fetch and incorporate host details
|
||||||
$stmt = $pdo->prepare("SELECT * FROM host;");
|
$stmt = $dbh->prepare("SELECT * FROM host;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$hosts = $stmt->fetchAll();
|
$hosts = $stmt->fetchAll();
|
||||||
|
|
||||||
|
@ -174,7 +179,7 @@ foreach ($tlds as $tld) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch and incorporate contact details
|
// Fetch and incorporate contact details
|
||||||
$stmt = $pdo->prepare("SELECT * FROM contact;");
|
$stmt = $dbh->prepare("SELECT * FROM contact;");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$contacts = $stmt->fetchAll();
|
$contacts = $stmt->fetchAll();
|
||||||
|
|
||||||
|
@ -188,7 +193,7 @@ foreach ($tlds as $tld) {
|
||||||
$xml->endElement(); // Closing rdeContact:status
|
$xml->endElement(); // Closing rdeContact:status
|
||||||
|
|
||||||
// Fetch postalInfo for the current contact
|
// Fetch postalInfo for the current contact
|
||||||
$stmtPostal = $pdo->prepare("SELECT * FROM contact_postalInfo WHERE contact_id = :contact_id;");
|
$stmtPostal = $dbh->prepare("SELECT * FROM contact_postalInfo WHERE contact_id = :contact_id;");
|
||||||
$stmtPostal->bindParam(':contact_id', $contact['id']);
|
$stmtPostal->bindParam(':contact_id', $contact['id']);
|
||||||
$stmtPostal->execute();
|
$stmtPostal->execute();
|
||||||
$postalInfo = $stmtPostal->fetch();
|
$postalInfo = $stmtPostal->fetch();
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
try {
|
$c = require_once 'config.php';
|
||||||
// Connect to the MySQL database using PDO
|
require_once 'helpers.php';
|
||||||
$c = require 'config.php';
|
|
||||||
$dsn = "mysql:host={$c['mysql_host']};dbname={$c['mysql_database']};port={$c['mysql_port']}";
|
|
||||||
$dbh = new PDO($dsn, $c['mysql_username'], $c['mysql_password']);
|
|
||||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
|
|
||||||
|
// Connect to the database
|
||||||
|
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']};port={$c['db_port']}";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dbh = new PDO($dsn, $c['db_username'], $c['db_password']);
|
||||||
|
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Connection failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Check if there's an entry for the current date
|
// 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();
|
$curdate_id = $dbh->query($query)->fetchColumn();
|
||||||
|
|
|
@ -1,5 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$c = require_once 'config.php';
|
||||||
|
require_once 'helpers.php';
|
||||||
|
|
||||||
|
// Connect to the database
|
||||||
|
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']};port={$c['db_port']}";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dbh = new PDO($dsn, $c['db_username'], $c['db_password']);
|
||||||
|
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die("Connection failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$hostname = '{your_imap_server:993/imap/ssl}INBOX';
|
$hostname = '{your_imap_server:993/imap/ssl}INBOX';
|
||||||
$username = 'your_email@example.com';
|
$username = 'your_email@example.com';
|
||||||
$password = 'your_password';
|
$password = 'your_password';
|
||||||
|
@ -14,9 +27,6 @@ $emailsFromProviderB = imap_search($inbox, 'FROM "providerB@example.com" UNSEEN'
|
||||||
// Combine the arrays of email IDs
|
// Combine the arrays of email IDs
|
||||||
$allEmails = array_merge($emailsFromProviderA, $emailsFromProviderB);
|
$allEmails = array_merge($emailsFromProviderA, $emailsFromProviderB);
|
||||||
|
|
||||||
// Connect to the database using PDO
|
|
||||||
$pdo = new PDO("mysql:host=your_host;dbname=your_db", "db_username", "db_password");
|
|
||||||
|
|
||||||
foreach ($allEmails as $emailId) {
|
foreach ($allEmails as $emailId) {
|
||||||
$header = imap_headerinfo($inbox, $emailId);
|
$header = imap_headerinfo($inbox, $emailId);
|
||||||
$from = $header->from[0]->mailbox . "@" . $header->from[0]->host;
|
$from = $header->from[0]->mailbox . "@" . $header->from[0]->host;
|
||||||
|
@ -31,7 +41,7 @@ foreach ($allEmails as $emailId) {
|
||||||
$domainName = extractDomainNameFromEmail($body); // You'd have to define this function
|
$domainName = extractDomainNameFromEmail($body); // You'd have to define this function
|
||||||
|
|
||||||
// Insert into the database
|
// Insert into the database
|
||||||
$stmt = $pdo->prepare("INSERT INTO urs_actions (domain_name, urs_provider, action_date, status) VALUES (?, ?, ?, ?)");
|
$stmt = $dbh->prepare("INSERT INTO urs_actions (domain_name, urs_provider, action_date, status) VALUES (?, ?, ?, ?)");
|
||||||
$stmt->execute([$domainName, $ursProvider, $date, 'Suspended']);
|
$stmt->execute([$domainName, $ursProvider, $date, 'Suspended']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Database connection
|
$c = require_once 'config.php';
|
||||||
$c = include 'config.php';
|
require_once 'helpers.php';
|
||||||
$dsn = "mysql:host={$c['mysql_host']};port={$c['mysql_port']};dbname={$c['mysql_database']}";
|
|
||||||
|
// Connect to the database
|
||||||
|
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']};port={$c['db_port']}";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dbh = new PDO($dsn, $c['mysql_username'], $c['mysql_password']);
|
$dbh = new PDO($dsn, $c['db_username'], $c['db_password']);
|
||||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
die("Connection failed: " . $e->getMessage());
|
die("Connection failed: " . $e->getMessage());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue