feat: add hostname/db name config for the admin interface

This commit is contained in:
Emmanuel BENOîT 2024-12-31 11:02:11 +01:00
parent 9e12cf9036
commit c91440af72
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg

View file

@ -1,20 +1,24 @@
<?php
$aConfig = array(
"user" => 'legacyworlds',
"password" => 'password for the standard database user',
"adminUser" => 'legacyworlds_admin',
"adminPassword" => 'password for the administrative database user',
"ctrlFifo" =>'/tmp/.lwFifo',
"ctrlPath" =>'/tmp/.lwControl'
'host' => '127.0.0.1',
'database' => 'legacyworlds',
'user' => 'legacyworlds',
'password' => 'password for the standard database user',
'adminUser' => 'legacyworlds_admin',
'adminPassword' => 'password for the administrative database user',
'ctrlFifo' =>'/tmp/.lwFifo',
'ctrlPath' =>'/tmp/.lwControl'
);
function __dbConnect($admin = false) {
global $aConfig;
$h = $aConfig['host'];
$d = $aConfig['database'];
$u = $aConfig[$admin ? 'adminUser' : 'user'];
$p = $aConfig[$admin ? 'adminPassword' : 'password'];
$cString = "dbname='legacyworlds' host='127.0.0.1' sslmode='prefer' user='$u' password='$p'";
$cString = "dbname='$d' host='$h' sslmode='prefer' user='$u' password='$p'";
return pg_connect($cString);
}