34 $suppressPrint =
false;
40 require(
'remote-hcu-services.conf');
41 require(
'cutrusted.i');
45 $dbhost = ($homecuServer ==
'monitor' ?
'localhost' :
"db-" . $homecuServer);
49 $options = Array(
"s:" =>
"required:",
52 $opts = getopt(implode(
'', array_keys($options)), $options);
56 if (array_key_exists(
'a', $opts)) {
57 if (strtolower($opts[
'a']) ==
'on' || strtolower($opts[
'a']) ==
'off') {
58 $serviceAction = strtolower($opts[
'a']);
68 if (array_key_exists(
's', $opts)) {
69 $serviceCodes = $opts[
's'];
74 if (array_key_exists(
'q', $opts)) {
75 $suppressPrint =
true;
80 usage: hcu-services -a action -s service [-q] 92 $trustSettings = Array(
'Cu' => prep_save($homecuTrustCU, 12),
'trustedid' => prep_save($homecuTrustID, 20));
93 $retResp = cutd_read($dbh, $trustSettings);
94 if ($retResp[
'status'][
'Response']) {
96 if ($retResp[
'data'][
"{$homecuTrustCU}|{$homecuTrustID}"]) {
97 if (is_array($retResp[
'data'][
"{$homecuTrustCU}|{$homecuTrustID}"])) {
98 $homecuServices = $retResp[
'data'][
"{$homecuTrustCU}|{$homecuTrustID}"];
117 foreach ($homecuServices as $itemService => $itemValue) {
119 $foundService =
false;
120 if (is_array($serviceCodes)) {
122 if (in_array($itemService, $serviceCodes)) {
124 $foundService =
true;
126 } elseif ((strtoupper($serviceCodes) ==
'ALL') || ($serviceCodes == trim($itemService))) {
130 $foundService =
true;
134 if ($serviceAction ==
'on') {
136 if ($itemValue ==
'U') {
137 $homecuServices[$itemService] =
'N';
139 } elseif ($serviceAction ==
'off') {
141 if ($itemValue ==
'N') {
142 $homecuServices[$itemService] =
'U';
151 $trustSettings = Array(
'Cu' => prep_save($homecuTrustCU, 12),
'trustedid' => prep_save($homecuTrustID, 20),
'fields' => $homecuServices);
152 $retResp = cutd_write($dbh, $trustSettings);
153 if ($retResp[
'status'][
'Response']) {
156 if (!$suppressPrint) {print
"\nError when updating the services.";}
159 if (!$suppressPrint) {print
"\nHomeCU Services Found. Data Not Valid";}
162 if (!$suppressPrint) {print
"\nHomeCU Services Found. No Services Data Found";}
165 if (!$suppressPrint) {print
"\nNo HomeCU Services Record Found.";}