diff --git a/automation/config.php.dist b/automation/config.php.dist index 7b45474..6af0b2d 100644 --- a/automation/config.php.dist +++ b/automation/config.php.dist @@ -8,7 +8,7 @@ return [ 'db_database' => 'your_database_name', 'db_username' => 'your_username', 'db_password' => 'your_password', - + // Escrow Configuration 'escrow_deposit_path' => '/opt/escrow', 'escrow_deleteXML' => false, @@ -22,12 +22,12 @@ return [ 'escrow_report_url' => 'https://ry-api.icann.org/report/', 'escrow_report_username' => 'your_username', 'escrow_report_password' => 'your_password', - + // Reporting Configuration - 'reporting_upload' => false, - 'reporting_username' => 'your_username', - 'reporting_password' => 'your_password', - + 'reporting_upload' => false, + 'reporting_username' => 'your_username', + 'reporting_password' => 'your_password', + // Zone Writer Configuration - 'dns_server' => 'bind', + 'dns_server' => 'bind', ]; \ No newline at end of file diff --git a/rdap/start_rdap.php b/rdap/start_rdap.php index 875de35..edfe101 100644 --- a/rdap/start_rdap.php +++ b/rdap/start_rdap.php @@ -51,18 +51,19 @@ $http->set([ 'http_compression' => true ]); +// Connect to the database +try { + $c = require_once 'config.php'; + $pdo = new PDO("{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']}", $c['db_username'], $c['db_password']); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + $response->header('Content-Type', 'application/json'); + $response->end(json_encode(['error' => 'Error connecting to database'])); + return; +} + // Register a callback to handle incoming requests -$http->on('request', function ($request, $response) { - // Connect to the database - try { - $c = require_once 'config.php'; - $pdo = new PDO("{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']}", $c['db_username'], $c['db_password']); - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } catch (PDOException $e) { - $response->header('Content-Type', 'application/json'); - $response->end(json_encode(['error' => 'Error connecting to database'])); - return; - } +$http->on('request', function ($request, $response) use ($c, $pdo) { // Extract the request path $requestPath = $request->server['request_uri']; diff --git a/whois/port43/start_whois.php b/whois/port43/start_whois.php index 6cafa7d..5ad0b16 100644 --- a/whois/port43/start_whois.php +++ b/whois/port43/start_whois.php @@ -25,23 +25,23 @@ $server->set([ 'package_eof' => "\r\n" ]); +// Connect to the database +try { + $c = require_once 'config.php'; + $pdo = new PDO("{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']}", $c['db_username'], $c['db_password']); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + $server->send($fd, "Error connecting to database"); + $server->close($fd); +} + // Register a callback to handle incoming connections $server->on('connect', function ($server, $fd) { echo "Client connected: {$fd}\r\n"; }); // Register a callback to handle incoming requests -$server->on('receive', function ($server, $fd, $reactorId, $data) { - // Connect to the database - try { - $c = require_once 'config.php'; - $pdo = new PDO("{$c['db_type']}:host={$c['db_host']};dbname={$c['db_database']}", $c['db_username'], $c['db_password']); - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } catch (PDOException $e) { - $server->send($fd, "Error connecting to database"); - $server->close($fd); - } - +$server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pdo) { $privacy = $c['privacy']; // Validate and sanitize the data