mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-05 17:18:04 +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
|
||||
|
||||
// Connect to the MySQL database using PDO
|
||||
$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);
|
||||
$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());
|
||||
}
|
||||
|
||||
$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);
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
<?php
|
||||
|
||||
try {
|
||||
// Create a new PDO connection
|
||||
$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);
|
||||
$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());
|
||||
}
|
||||
|
||||
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`
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
<?php
|
||||
|
||||
// Connect to the MySQL database using PDO
|
||||
$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);
|
||||
$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());
|
||||
}
|
||||
|
||||
// Auto-Renew Grace Period
|
||||
$auto_renew = 0;
|
||||
|
|
|
@ -6,26 +6,31 @@ require __DIR__ . '/vendor/autoload.php';
|
|||
$c = require_once 'config.php';
|
||||
require_once 'helpers.php';
|
||||
|
||||
// Database connection
|
||||
// Connect to the database
|
||||
$dsn = "{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']}";
|
||||
$options = [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
];
|
||||
$pdo = new PDO($dsn, $c['db_username'], $c['db_password'], $options);
|
||||
|
||||
$domainCount = fetchCount($pdo, 'domain');
|
||||
$hostCount = fetchCount($pdo, 'host');
|
||||
$contactCount = fetchCount($pdo, 'contact');
|
||||
$registrarCount = fetchCount($pdo, 'registrar');
|
||||
try {
|
||||
$dbh = new PDO($dsn, $c['db_username'], $c['db_password'], $options);
|
||||
} catch (PDOException $e) {
|
||||
die("Connection failed: " . $e->getMessage());
|
||||
}
|
||||
|
||||
$domainCount = fetchCount($dbh, 'domain');
|
||||
$hostCount = fetchCount($dbh, 'host');
|
||||
$contactCount = fetchCount($dbh, 'contact');
|
||||
$registrarCount = fetchCount($dbh, 'registrar');
|
||||
|
||||
// Fetching TLDs
|
||||
$stmt = $pdo->query("SELECT id,tld FROM domain_tld;");
|
||||
$stmt = $dbh->query("SELECT id,tld FROM domain_tld;");
|
||||
$tlds = $stmt->fetchAll();
|
||||
|
||||
// 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();
|
||||
$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');
|
||||
|
||||
// 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->execute();
|
||||
$domains = $stmt->fetchAll();
|
||||
|
@ -69,7 +74,7 @@ foreach ($tlds as $tld) {
|
|||
$xml->writeElement('rdeDom:idnTableId', 'Latn');
|
||||
|
||||
// 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->execute();
|
||||
$status = $stmt->fetch();
|
||||
|
@ -78,7 +83,7 @@ foreach ($tlds as $tld) {
|
|||
$xml->writeElement('rdeDom:registrant', $domain['registrant']);
|
||||
|
||||
// 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->execute();
|
||||
$domain_contacts = $stmt->fetchAll();
|
||||
|
@ -90,7 +95,7 @@ foreach ($tlds as $tld) {
|
|||
}
|
||||
|
||||
// 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->execute();
|
||||
$domain_hosts = $stmt->fetchAll();
|
||||
|
@ -109,7 +114,7 @@ foreach ($tlds as $tld) {
|
|||
}
|
||||
|
||||
// Fetch and incorporate registrar details
|
||||
$stmt = $pdo->prepare("SELECT * FROM registrar;");
|
||||
$stmt = $dbh->prepare("SELECT * FROM registrar;");
|
||||
$stmt->execute();
|
||||
$registrars = $stmt->fetchAll();
|
||||
|
||||
|
@ -121,7 +126,7 @@ foreach ($tlds as $tld) {
|
|||
$xml->writeElement('rdeRegistrar:status', 'ok');
|
||||
|
||||
// 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->execute();
|
||||
$registrar_contacts = $stmt->fetchAll();
|
||||
|
@ -153,7 +158,7 @@ foreach ($tlds as $tld) {
|
|||
$xml->endElement(); // Closing rdeRegistrar:registrar
|
||||
|
||||
// Fetch and incorporate host details
|
||||
$stmt = $pdo->prepare("SELECT * FROM host;");
|
||||
$stmt = $dbh->prepare("SELECT * FROM host;");
|
||||
$stmt->execute();
|
||||
$hosts = $stmt->fetchAll();
|
||||
|
||||
|
@ -174,7 +179,7 @@ foreach ($tlds as $tld) {
|
|||
}
|
||||
|
||||
// Fetch and incorporate contact details
|
||||
$stmt = $pdo->prepare("SELECT * FROM contact;");
|
||||
$stmt = $dbh->prepare("SELECT * FROM contact;");
|
||||
$stmt->execute();
|
||||
$contacts = $stmt->fetchAll();
|
||||
|
||||
|
@ -188,7 +193,7 @@ foreach ($tlds as $tld) {
|
|||
$xml->endElement(); // Closing rdeContact:status
|
||||
|
||||
// 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->execute();
|
||||
$postalInfo = $stmtPostal->fetch();
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
<?php
|
||||
|
||||
try {
|
||||
// Connect to the MySQL database using PDO
|
||||
$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);
|
||||
$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());
|
||||
}
|
||||
|
||||
try {
|
||||
// Check if there's an entry for the current date
|
||||
$query = "SELECT `id` FROM `statistics` WHERE `date` = CURDATE()";
|
||||
$curdate_id = $dbh->query($query)->fetchColumn();
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
<?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';
|
||||
$username = 'your_email@example.com';
|
||||
$password = 'your_password';
|
||||
|
@ -14,9 +27,6 @@ $emailsFromProviderB = imap_search($inbox, 'FROM "providerB@example.com" UNSEEN'
|
|||
// Combine the arrays of email IDs
|
||||
$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) {
|
||||
$header = imap_headerinfo($inbox, $emailId);
|
||||
$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
|
||||
|
||||
// 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']);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
|
||||
// Database connection
|
||||
$c = include 'config.php';
|
||||
$dsn = "mysql:host={$c['mysql_host']};port={$c['mysql_port']};dbname={$c['mysql_database']}";
|
||||
$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['mysql_username'], $c['mysql_password']);
|
||||
$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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue