11 $MasterKey =
'ndcng/Mwln#TR-3APMkxf68MaFWeaXaD';
13 function StartDMSTag($pStartTag, $pIdx=0, $pMenuVal=
'') {
14 global $LAYOUT_PAGE, $LAYOUT_GROUP, $LAYOUT_LINE, $CURRENT_LAYOUT, $Build_CSS_Menu, $PAGE_COUNT, $GROUP_COUNT;
20 for ($idx = $CURRENT_LAYOUT; $idx >= $pStartTag; $idx--) {
29 print
"</div><!--form-horizontal --></div><!-- well -->";
42 print
"<div id='securepage$pIdx' class='noshow'>";
45 print
"<div class='well well-sm col-xs-12 groupgo_{$GROUP_COUNT}'><div class='form-horizontal'>";
48 print
"<div class='newrow'>";
52 $CURRENT_LAYOUT = $pStartTag;
57 for ($idxMenu = $CURRENT_LAYOUT; $idxMenu >= $pStartTag; $idxMenu--) {
61 if ($Build_CSS_Menu !=
'') {
62 $Build_CSS_Menu .=
"</ul></li>";
69 if ($idxMenu >= 0 && $pMenuVal !=
'') {
72 $Build_CSS_Menu .=
"<li class='' data-rowid=''><a class='' href='#' target=''><div id='pghdr_{$PAGE_COUNT}' title='$pMenuVal'>$pMenuVal</div></a><ul class='nav nav-second-level collapse in'>";
75 $Build_CSS_Menu .=
"<li id='group_{$GROUP_COUNT}'><a href='#groupgo_{$GROUP_COUNT}' id='page{$PAGE_COUNT}'><i class='fa fa-long-arrow-right local-menu-error' aria-hidden='true'></i>$pMenuVal</a></li>";
84 function Load_AnswerList ($p_ansid) {
85 global $DB_TABLE_PREFIX, $App_AnswerDetail, $dbh;
92 FROM {$DB_TABLE_PREFIX}anslookupdetail 93 WHERE ansid = " . intval($p_ansid) .
" 94 ORDER BY ansdisplay ";
96 $ans_rs = db_query($sql, $dbh);
107 while ($ans_row = db_fetch_array($ans_rs, $ansid)) {
110 if ($ansIdx == 1 && trim($ans_row[
'ansvalue']) !=
'') {
113 $App_AnswerDetail[$p_ansid][
''] =
'';
115 $App_AnswerDetail[$p_ansid][$ans_row[
'ansvalue']] = $ans_row[
'ansdisplay'];
121 $App_AnswerDetail[$p_ansid] =
"NO ROWS";
126 function Display_AnswerList($p_ansid, $p_fieldname, $p_displaytype, $p_fieldlabel, $p_returndisplayof =
"", $p_setdefaultval =
"", $p_valueconditionalname=
'', $p_fieldclass=
'') {
127 global $App_AnswerDetail, $GROUP_COUNT;
133 if (!isset($App_AnswerDetail[$p_ansid])) {
135 Load_AnswerList($p_ansid);
141 $radio_id_value =
" id='{$p_fieldname}' ";
142 if ($App_AnswerDetail[$p_ansid] !=
"NO ROWS") {
143 foreach ($App_AnswerDetail[$p_ansid] as $Ans_key => $Ans_value) {
144 if ($p_returndisplayof ==
'') {
146 switch($p_displaytype) {
148 $default_val = ($p_setdefaultval !=
'' && $Ans_key == $p_setdefaultval ?
" SELECTED " :
"");
149 $Answer_Field .=
"<option value='$Ans_key' $default_val>$Ans_value</option>";
153 if ($Ans_key !=
'' && $Ans_value !=
'') {
154 $default_val = ($p_setdefaultval !=
'' && $Ans_key == $p_setdefaultval ?
" CHECKED " :
"");
156 $Answer_Field .= <<< APP_AR
157 <label
class=
"radio-inline">
158 <input type=
'radio' group=
'group_{$GROUP_COUNT}' id=
'{$p_fieldname}' {$default_val} name=
'{$p_fieldname}' {$p_valueconditionalname} value=
'{$Ans_key}'/> {$Ans_value}
161 $radio_id_value =
'';
168 if ($Ans_key == $p_returndisplayof) {
169 $Answer_Field = $Ans_value;
174 if ($p_displaytype ==
"S" && $p_returndisplayof ==
'') {
175 $Answer_Field =
"<select class='$p_fieldclass' data-role='dropdownlist' id='$p_fieldname' name='$p_fieldname' class='t' style='width: 100%' title='$p_fieldlabel' {$p_valueconditionalname}>$Answer_Field</select>";
179 return $Answer_Field;
191 function encrypt($data, $key, $method=
'AES-256-ECB') {
193 $ivSize = openssl_cipher_iv_length($method);
194 $iv = openssl_random_pseudo_bytes($ivSize);
196 $encrypted = openssl_encrypt($data, $method, $key, OPENSSL_RAW_DATA, $iv);
199 $encrypted = base64_encode($iv . $encrypted);
214 function decrypt($data, $key, $method=
'AES-256-ECB') {
215 $data = base64_decode($data);
216 $ivSize = openssl_cipher_iv_length($method);
217 $iv = substr($data, 0, $ivSize);
218 $data = openssl_decrypt(substr($data, $ivSize), $method, $key, OPENSSL_RAW_DATA, $iv);
223 function Check_Credentials() {
224 global $DB_TABLE_PREFIX, $DMSAPP_USERID_CookieString, $MasterKey, $dbh, $DMSAPP_CURRENTCUCODE, $DMSAPP_SECRET_KEY;
228 $l_cookieval_ary = array();
235 if (isset($_COOKIE[$DMSAPP_USERID_CookieString])) {
238 parse_str($_COOKIE[$DMSAPP_USERID_CookieString], $l_cookieval_ary);
239 $l_user = trim(decrypt($l_cookieval_ary[
'C1'], $MasterKey));
241 if (intval($l_user) != $l_user) {
245 $l_user = intval($l_user);
259 if ((sha1($DMSAPP_SECRET_KEY . $l_cookieval_ary[
'C1'] . $l_cookieval_ary[
'C2'] . $l_cookieval_ary[
'C3']) == $l_cookieval_ary[
'C4'])) {
264 FROM {$DB_TABLE_PREFIX}user 265 WHERE userid = " . intval($l_user);
266 $user_rs = db_query($sql, $dbh);
268 if ($user_row = db_fetch_array($user_rs)) {
272 $l_email = trim($user_row[
'email']);
273 $l_banking_user_id = trim($user_row[
'banking_user_id']);
274 $l_pwd = trim($user_row[
'pwd']);
275 $l_confword = trim($user_row[
'confidenceword']);
277 $l_device_cookie_name = ReturnDeviceCookieName($DMSAPP_CURRENTCUCODE, $l_cookieval_ary[
'C3'], $l_email, $ret_user);
279 if (isset($_COOKIE[$l_device_cookie_name])) {
282 $l_CookieVal = sha1($DMSAPP_SECRET_KEY . $l_pwd . $l_email . $l_confword . $l_banking_user_id);
284 if ($l_CookieVal == $_COOKIE[$l_device_cookie_name]) {
288 $ret_email = $l_email;
291 if (time() < $l_cookieval_ary[
'C2']) {
303 return Array($ret_status, $ret_user, $ret_email, $l_cookieval_ary[
'C3']);
306 function ReturnDeviceCookieName($p_cucode, $p_logintype, $p_email, $p_userid) {
307 global $DB_TABLE_PREFIX;
308 return sha1(
"{$DB_TABLE_PREFIX}{$p_cucode}Tu0geethSaith7ch{$p_logintype}{$p_email}{$p_userid}");
311 function SetLnappDeviceCookie($p_hb_env, $p_cookiename, $p_cookieval, $pSessionCookie =
false) {
312 global $DMSAPP_Device_Cookie_ExpireTime, $DMSAPP_Cookie_Domain;
314 $cooked_exp = $pSessionCookie ? 0 : time() + $DMSAPP_Device_Cookie_ExpireTime;
319 HCU_setcookie_env($p_hb_env[
'SYSENV'], $p_cookiename, $p_cookieval, $cooked_exp);
326 function DMSAppSetCookie($p_hb_env, $userid, $p_logintype, $p_ForceExpired =
false) {
328 global $MasterKey, $DMSAPP_Cookie_ExpireTime, $DMSAPP_USERID_CookieString, $DMSAPP_Cookie_Domain, $DMSAPP_SECRET_KEY;
332 $l_uid = encrypt($userid, $MasterKey);
334 if (!$p_ForceExpired) {
335 $l_exptime = time() + (60 * $DMSAPP_Cookie_ExpireTime);
337 $l_exptime = time() - 60;
346 $cooked_val =
"C1=" . urlencode($l_uid) .
"&C2=$l_exptime&C3=$p_logintype&C4=" . sha1($DMSAPP_SECRET_KEY . $l_uid . $l_exptime . $p_logintype);
357 HCU_setcookie_env($p_hb_env[
'SYSENV'], $DMSAPP_USERID_CookieString, $cooked_val);
361 function DMSAppCookieResetTimer($p_hb_env) {
362 global $DMSAPP_Cookie_Domain, $DMSAPP_USERID_CookieString, $DMSAPP_Cookie_ExpireTime, $MasterKey, $DMSAPP_SECRET_KEY;
367 if (isset($_COOKIE[$DMSAPP_USERID_CookieString])) {
370 $l_cookieval_ary = array();
371 parse_str($_COOKIE[$DMSAPP_USERID_CookieString], $l_cookieval_ary);
372 $l_user = trim(decrypt($l_cookieval_ary[
'C1'], $MasterKey));
374 if (intval($l_user) == $l_user) {
375 $l_user = intval($l_user);
380 if ((sha1($DMSAPP_SECRET_KEY . $l_cookieval_ary[
'C1'] . $l_cookieval_ary[
'C2'] . $l_cookieval_ary[
'C3']) == $l_cookieval_ary[
'C4'])) {
382 if (time() < $l_cookieval_ary[
'C2']) {
383 $l_exptime = time() + (60 * $DMSAPP_Cookie_ExpireTime);
384 $newC4 = sha1($DMSAPP_SECRET_KEY . $l_user . $l_exptime . $p_logintype);
386 $reBakedVal =
"C1={$l_cookieval_ary['C1']}&C2=$l_exptime&C3={$l_cookieval_ary['C3']}&C4=" . $newC4;
388 setcookie($DMSAPP_USERID_CookieString, $reBakedVal, 0,
"/", $DMSAPP_Cookie_Domain, 1);
396 function Disclosure_Exists($p_LoanID = -1, $p_RespID = -1) {
397 global $dbh, $DMSAPP_CUHOME_PATH;
410 if ($p_LoanID >= 0 || $p_RespID >= 0) {
413 if ($p_LoanID >= 0) {
414 $sql =
"SELECT loandisclosure_fragment 415 FROM lnappschemamaster 416 WHERE loanid = " . intval($p_LoanID) .
" ";
417 } elseif ($p_RespID >= 0) {
418 $sql =
"SELECT loandisclosure_fragment 419 FROM lnappschemamaster 420 JOIN lnappuserresponse on lnappuserresponse.loanid = lnappschemamaster.loanid 421 WHERE respid = " . intval($p_RespID) .
" ";
423 $disc_rs = db_query($sql, $dbh);
424 list($disc_filename) = db_fetch_array($disc_rs);
426 if (trim($disc_filename) !=
'') {
428 if (file_exists($DMSAPP_CUHOME_PATH . $disc_filename)) {
441 function SetAppMode($p_dbh, $p_cu, $p_dmsapp_online, $p_allowReadonly) {
443 $retMode = Array(
"offline" =>
false,
"offlineReadonly" =>
false,
"offlineDesc" =>
"The loan application is currently offline. Please check back later.");
445 $sql =
"SELECT offlinestat, offlineblurb 447 WHERE cu = '{$p_cu}'; ";
449 if ($off_rs = db_query($sql, $p_dbh)) {
450 $off_row = db_fetch_assoc($off_rs, 0);
451 $curOfflineStat = $off_row[
'offlinestat'];
452 $retMode[
'offlineDesc'] = $off_row[
'offlineblurb'];
455 $setArray = array(
'Cu'=>$p_cu,
'offline'=>$curOfflineStat,
'live'=>$GLOBALS[
'DMSAPP_CULIVE'],
'allowReadonly'=>$p_allowReadonly);
456 $retMode[
'offline'] = hcu_checkOffline($p_dbh, $setArray);
461 $retMode[
'offlineReadonly'] = ($curOfflineStat ==
"R");
472 function RefreshCookie($p_hb_env) {
473 global $DMSAPP_CURRENTUSERID, $DMSAPP_CURRENTEMAIL, $DMSAPP_LOGINTYPE;
476 $Refresh_Return =
"False";
479 list($check_status, $check_user, $check_email, $check_logintype) = Check_Credentials();
480 if (intval($check_user) == $check_user) {
481 $DMSAPP_CURRENTUSERID = $check_user;
482 $DMSAPP_CURRENTEMAIL = strtolower($check_email);
483 $DMSAPP_LOGINTYPE = $check_logintype;
487 DMSAppSetCookie($p_hb_env, $DMSAPP_CURRENTUSERID, $DMSAPP_LOGINTYPE);
488 $Refresh_Return =
"True";
492 return $Refresh_Return;
519 function GetAllUserLoans($pHbEnv, $pUserId) {
532 global $DMSAPP_CULIVE, $DMSAPP_MODE_ARY;
535 $retVal = Array(
"code" =>
"000",
"data" => Array());
537 $dbh = HCU_array_key_value(
'dbh', $pHbEnv);
539 if (db_connection_status($dbh) !== PGSQL_CONNECTION_OK) {
540 throw new Exception (
"Database Error");
543 $sql =
"SELECT userresponse.*, schemamaster.loantitle, 544 to_char(userresponse.respstarton,'MM/DD/YYYY HH12:MI') as user_startedon, 545 to_char(userresponse.respsubmiton,'MM/DD/YYYY HH12:MI') as user_submiton, 546 trim(userresponse.resplname) || ', ' || trim(userresponse.respfname) || ' ' || userresponse.respmname as name, 547 case when resplastinquire + interval '5' minute < now() then 'T' else 'F' end as inquire 548 FROM {$pHbEnv['DB_TABLE_PREFIX']}userresponse as userresponse 549 JOIN {$pHbEnv['DB_TABLE_PREFIX']}schemamaster as schemamaster 550 ON schemamaster.loanid = userresponse.loanid 551 WHERE userid = " . intval($pUserId) .
" 552 ORDER BY respstarton desc ";
555 $resp_rs = db_query($sql, $dbh);
563 while ($resp_row = db_fetch_array($resp_rs, $resp_cnt)) {
586 $dataRow[
'LoanRespId'] = intval($resp_row[
'respid']);
587 $dataRow[
'LoanId'] = intval($resp_row[
'loanid']);
588 $dataRow[
'LoanType'] = disp_text($resp_row[
'loantitle']);
589 $dataRow[
'LoanName'] = disp_text($resp_row[
'name']);
590 $tempName = disp_text($resp_row[
'resplname']) .
', ' . disp_text($resp_row[
'respfname']) .
' ' . disp_text($resp_row[
'respmname']);
591 $dataRow[
'LoanName'] = (strlen(trim($tempName)) > 1 ? $tempName :
'');
592 $dataRow[
'LoanStartOn'] = disp_text($resp_row[
'user_startedon']);
593 $dataRow[
'LoanSubmitOn'] = disp_text($resp_row[
'user_submiton']);
595 $dataRow[
'CuLoanStatus'] = disp_text($resp_row[
'respstatus']);
596 $dataRow[
'CuLoanResp'] = disp_text($resp_row[
'respstatusdesc']);
598 $dataRow[
'CuLoanId'] = (disp_text($resp_row[
'respcoreloanappid']) == -1 ?
"" : disp_text($resp_row[
'respcoreloanappid']));
599 $dataRow[
'LoanAction'] = Array(
"edit" =>
false,
605 if (!isset($row_SubmitOn) || $row_SubmitOn ==
"") {
607 if (($DMSAPP_CULIVE) || (!$DMSAPP_CULIVE && !($DMSAPP_MODE_ARY[
'offline'] && $DMSAPP_MODE_ARY[
'offlineReadonly'])) ) {
609 $dataRow[
'action'][
'edit'] =
true;
610 $dataRow[
'action'][
'delete'] =
true;
617 $dataRow[
'action'][
'view'] =
true;
621 $dataRow[
'action'][
'view'] =
true;
629 if ($resp_row[
'inquire'] ==
'T' && $DMSAPP_ONLINE && $DMSAPP_MODE_ARY[
'offline']) {
631 if ((strpos(
":" . $dataRow[
'CuLoanStatus'] .
":",
":026:") !==
false) && ($dataRow[
'LoanId'] > 0)) {
632 list($inq_status, $inq_desc) = InquireApplication($dataRow[
'LoanRespId'], $dataRow[
'LoanId']);
642 $sql =
"UPDATE {$DB_TABLE_PREFIX}userresponse 643 SET resplastinquire = now() 644 WHERE respid = " . $dataRow[
'LoanRespId'] .
" 645 AND userid = " . intval($pHbEnv[
'Uid']) .
" ";
647 $upd_rs = db_query($sql, $dbh);
649 if (trim($inq_status) != trim($resp_row[
'respstatus'])) {
651 $dataRow[
'CuLoanStatus'] = $inq_status;
652 $dataRow[
'CuLoanResp'] = disp_text($inq_desc);
657 if ($dataRow[
'CuLoanResp'] !=
'') {
661 switch ($dataRow[
'CuLoanStatus']) {
663 $row_DisplayStatus =
"Received";
671 $row_DisplayStatus =
"Submit Error";
680 $row_DisplayStatus =
"Approved";
683 $row_DisplayStatus =
"Rejected";
686 $row_DisplayStatus =
"Pending";
692 $row_DisplayStatus =
"Submitted";
694 $dataRow[
'CuLoanResp'] = $row_DisplayStatus;
697 $retVal[
'data'][] = $dataRow;
699 }
catch (Exception $e) {
700 $retVal[
'code'] =
'999';
722 function GetClassPropertyVal($objVal, $property) {
725 if (is_object($objVal)) {
726 if (property_exists($objVal, $property)) {
727 $bolRet = $objVal->{$property};
749 function VerifyUserAccountAccessForLoan($pHBEnv, $pUserId, $pSelAcct) {
751 $pHBEnv[
'Uid'] = $pUserId;
753 $pUsePlat = ($pHBEnv[
'platform'] ==
"MBL" ?
"M" :
"D");
754 $acctList = Get_FeatureAccounts( $pHBEnv,
"LOAN", $pUsePlat );
756 return (in_array($pSelAcct, $acctList) !==
false);