47 if (strpos($_SERVER[
'REMOTE_ADDR'],
"192.168.168") ===
false && strpos($_SERVER[
'REMOTE_ADDR'],
"192.168.169") ===
false && strpos($_SERVER[
'REMOTE_ADDR'],
"199.184.207.194") ===
false && strpos($_SERVER[
'REMOTE_ADDR'],
"199.184.207.3") ===
false && strpos($_SERVER[
'REMOTE_ADDR'],
"199.184.207.5") ===
false && strpos($_SERVER[
'REMOTE_ADDR'],
"199.184.207.66") ===
false && strpos($_SERVER[
'REMOTE_ADDR'],
"184.73.202.7") ===
false && strpos($_SERVER[
'REMOTE_ADDR'],
"107.20.248.233") ===
false) {
48 print
"RU: 900 - HomeCU Remote IP Error";
52 $monLibrary= dirname(__FILE__) .
"/../library";
53 $monIncludes= dirname(__FILE__) .
"/../includes";
54 require_once(
"$monLibrary/cu_top.i");
55 require_once(
"$monIncludes/cu_remote_top.prg");
58 $str_pos = strpos($_SERVER[
'SERVER_NAME'],
".");
59 $home_host = substr($_SERVER[
'SERVER_NAME'], 0, $str_pos);
60 $dbhost = ($home_host ==
'monitor' ?
62 "db-" . $_SERVER[
'SERVER_NAME']);
64 $dbhost = (($home_host ==
'monitor') ?
66 ($home_host ==
'ivr' ?
67 'db-ivr.cpzo4mvee2q5.us-east-1.rds.amazonaws.com sslmode=verify-full sslrootcert=/etc/ssl/certs/rds-combined-ca-bundle.pem' :
68 "db-" . $_SERVER[
'SERVER_NAME']));
71 print
"RU: 901 - HomeCU Database Connection Failed";
79 if ($_POST[
'ac'] ==
"S") {
80 $tbl_update = $_POST[
'tbl'];
87 if (!isset($Allowed_Tables[$_POST[
'tbl']])) {
88 print
"RU: 904 - Table Update Not Allowed";
91 $tbl_update = $Allowed_Tables[$_POST[
'tbl']][
'tablename'];
92 $tbl_key = $_POST[
'tbl'];
95 if ($tbl_update ==
"") {
96 print
"RU: 904 - Table Update Not Allowed";
102 if (isset($_POST[
'col']) && is_array($_POST[
'col'])) {
103 $tbl_cols = $_POST[
'col'];
105 foreach ($tbl_cols as $key => $value) {
106 if ($Allowed_Tables[$tbl_key][$value[
'name']][
'key'] ==
"1") {
107 $tbl_pk .= ($tbl_pk !=
"" ?
" AND " :
"") . $Allowed_Tables[$tbl_key][$value[
'name']][
'name'] .
" = '" . $value[
'value'] .
"' ";
112 print
"RU: 902 - Field Values Not Set";
117 if (strlen($tbl_pk) == 0) {
118 print
"RU: 903 - Key Not Set";
125 $cnt_sql =
"SELECT count(*) as record_count 129 $cnt_rs = db_query($cnt_sql, $link);
130 list($cnt_row) = db_fetch_array($cnt_rs);
131 db_free_result($cnt_rs);
134 switch ($_POST[
'ac']) {
139 $act_sql =
"INSERT INTO $tbl_update (";
143 foreach ($tbl_cols as $key => $value) {
145 $act_sql .= ($fld_cnt > 1 ?
", " :
"");
147 $act_sql .= $Allowed_Tables[$tbl_key][$value[
'name']][
'name'];
151 $act_sql .=
") VALUES (";
155 foreach ($tbl_cols as $key => $value) {
157 $act_sql .= ($fld_cnt > 1 ?
", " :
"");
160 switch ($Allowed_Tables[$tbl_key][$value[
'name']][
'dt']) {
163 $act_sql .=
"'" . intval($value[
'value']) .
"'";
167 $act_sql .=
"'" . prep_save($value[
'value'], $Allowed_Tables[$tbl_key][$value[
'name']][
'len']) .
"'";
173 if (isdate($value[
'value']) && strlen($value[
'value']) > 0) {
174 $save_date =
"'" . prep_save($value[
'value'], $Allowed_Tables[$tbl_key][$value[
'name']][
'len']) .
"'";
178 $act_sql .= $save_date;
183 } elseif ($cnt_row == 1) {
185 $act_sql =
"UPDATE $tbl_update SET ";
188 foreach ($tbl_cols as $key => $value) {
190 $act_sql .= ($fld_cnt > 1 ?
", " :
"");
192 $act_sql .= $Allowed_Tables[$tbl_key][$value[
'name']][
'name'] .
" = ";
194 switch ($Allowed_Tables[$tbl_key][$value[
'name']][
'dt']) {
197 $act_sql .=
"'" . intval($value[
'value']) .
"'";
201 $act_sql .=
"'" . prep_save($value[
'value'], $Allowed_Tables[$tbl_key][$value[
'name']][
'len']) .
"'";
205 if (isdate($value[
'value']) && strlen($value[
'value']) > 0) {
206 $save_date =
"'" . prep_save($value[
'value'], 10) .
"'";
210 $act_sql .= $save_date;
215 $act_sql .=
" WHERE $tbl_pk ";
218 print
"RU: 800 - No Action Taken";
221 if (strlen($act_sql) > 0) {
222 if (!$act_rs = db_query($act_sql, $link)) {
223 print
"RU: 905 - Update has failed";
225 print
"RU: 801 - Update was successful";
233 $act_sql =
"DELETE FROM $tbl_update 235 if ($act_rs = db_query($act_sql, $link)) {
236 print
"RU: 801 - Delete was successful";
238 print
"RU: 905 - Delete has failed";
241 print
"RU: 800 - No Action Taken";
247 switch ($tbl_update) {
249 $tbl_cols = $_POST[
'col'];
250 $act_sql =
"INSERT INTO cuadminexclude (cu, user_name, program) 251 (SELECT cu, trim(user_name), '" . prep_save($tbl_cols[0][
'value'], $Allowed_Tables[$tbl_update][$tbl_cols[0][
'name']][len]) .
"' 258 print
"RU: 800 - No Action Taken";