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

44 lines
955 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?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'
2016-01-10 11:01:49 +01:00
);
function __dbConnect($admin = false) {
global $aConfig;
$h = $aConfig['host'];
$d = $aConfig['database'];
2016-01-10 11:01:49 +01:00
$u = $aConfig[$admin ? 'adminUser' : 'user'];
$p = $aConfig[$admin ? 'adminPassword' : 'password'];
$cString = "dbname='$d' host='$h' sslmode='prefer' user='$u' password='$p'";
2016-01-10 11:01:49 +01:00
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;
}
?>