Fixed potential whois/rdap db issue and some cleanup

This commit is contained in:
Pinga 2023-11-02 12:46:55 +02:00
parent 8966edf046
commit 76ec107f71
3 changed files with 30 additions and 29 deletions

View file

@ -24,10 +24,10 @@ return [
'escrow_report_password' => 'your_password', 'escrow_report_password' => 'your_password',
// Reporting Configuration // Reporting Configuration
'reporting_upload' => false, 'reporting_upload' => false,
'reporting_username' => 'your_username', 'reporting_username' => 'your_username',
'reporting_password' => 'your_password', 'reporting_password' => 'your_password',
// Zone Writer Configuration // Zone Writer Configuration
'dns_server' => 'bind', 'dns_server' => 'bind',
]; ];

View file

@ -51,18 +51,19 @@ $http->set([
'http_compression' => true '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 // Register a callback to handle incoming requests
$http->on('request', function ($request, $response) { $http->on('request', function ($request, $response) use ($c, $pdo) {
// 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;
}
// Extract the request path // Extract the request path
$requestPath = $request->server['request_uri']; $requestPath = $request->server['request_uri'];

View file

@ -25,23 +25,23 @@ $server->set([
'package_eof' => "\r\n" '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 // Register a callback to handle incoming connections
$server->on('connect', function ($server, $fd) { $server->on('connect', function ($server, $fd) {
echo "Client connected: {$fd}\r\n"; echo "Client connected: {$fd}\r\n";
}); });
// Register a callback to handle incoming requests // Register a callback to handle incoming requests
$server->on('receive', function ($server, $fd, $reactorId, $data) { $server->on('receive', function ($server, $fd, $reactorId, $data) use ($c, $pdo) {
// 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);
}
$privacy = $c['privacy']; $privacy = $c['privacy'];
// Validate and sanitize the data // Validate and sanitize the data