lwb5-in-2025/game/admin/config.inc

43 lines
955 B
PHP

<?php
$aConfig = array(
'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='$d' host='$h' sslmode='prefer' user='$u' password='$p'";
return pg_connect($cString);
}
function __sendControl($command) {
global $aConfig;
$fName = $aConfig['ctrlFifo'];
if (!file_exists($fName)) {
return false;
}
$fifo = @fopen($fName, "w");
if ($fifo === false) {
return false;
}
fwrite($fifo, "$command\n");
fclose($fifo);
return true;
}
?>