11 require_once
'logging.i';
12 require_once
'hcuEnv.i';
20 $env = LoadSystemEnv(
'version');
21 if ($env[
'devmode']) {
22 $env[
'logger']->warning(
"Showing /getcustatus info - DEVMODE.");
25 $HB_ENV = LoadSystemEnv(
"banking");
28 $connect_to = sprintf(
'host=%s port=%d dbname=%s', $db[
'host'],
29 $db[
'port'], $db[
'dbname']);
30 if (!is_null($db[
'user'])) {
31 $connect_to .=
' user=' . $db[
'user'];
33 if (!is_null($db[
'connect_timeout'])) {
34 $connect_to .=
' connect_timeout=' . $db[
'connect_timeout'];
36 if (!is_null($db[
'password'])) {
37 $connect_to .=
' password=' . $db[
'password'];
39 $r = pg_connect($connect_to);
42 throw new Exception(
'DB connect error');
44 if (pg_connection_status($r) !== PGSQL_CONNECTION_OK) {
45 throw new Exception(
'DB status error');
48 throw new Exception(
'DB ping error');
53 $result = pg_query($r,
"select user_name, livebatch, offlinestat from cuadmin order by user_name");
55 $fields = [
"name",
"livebatch",
"offlinestat" ];
57 while ($row = pg_fetch_row($result)) {
58 $row[0] = trim($row[0]);
64 for( $i=1; $i<count($fields); $i++) {
65 $entry[$fields[$i]] = trim($row[$i]);
70 echo json_encode($res);