mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-21 10:06:05 +02:00
Fixed issue in DAS too
This commit is contained in:
parent
76ec107f71
commit
b906febeeb
1 changed files with 12 additions and 11 deletions
|
@ -25,22 +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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate and sanitize the domain name
|
// Validate and sanitize the domain name
|
||||||
$domain = trim($data);
|
$domain = trim($data);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue