This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/admin/config.inc

39 lines
847 B
PHP

<?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'
);
function __dbConnect($admin = false) {
global $aConfig;
$u = $aConfig[$admin ? 'adminUser' : 'user'];
$p = $aConfig[$admin ? 'adminPassword' : 'password'];
$cString = "dbname='legacyworlds' host='127.0.0.1' 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;
}
?>