2 # NOTE 10/09/12 exposed logic bug -- cu set as 2-factor, app passing in MFA answers, then cu set as legacy: appeared to work except that USERKEY was not returned in OFX output. Some kind of wart related to getting MFA when not expected 3 # Automatic 1-Way OFX as described in OFX 2.1.1 Specification, Section 16 6 # APPID : Identifies partner. Use OFXRQ for HomeCU app 7 # APPVER : required according to spec, not used at HomeCU. 10 # Script supports both SSO access and authenticated access methods. 11 # request will include either USERKEY (indicating SSO) 12 # or USERID/USERPASS (indicating authenticated access) 15 # USERPASS : password for authenticated account 16 # USERKEY : token for SSO access (replaces both USERID and USERPASS) 17 # CRED2 : Request date, UTC date/time in YYYYmmddHHMISS format 18 # CRED3 : hash # APPID USERID CRED2 hashed with assigned key 19 # DTSTART : Start date, default to 30days past 20 # for Odyssey default to yesterday 21 # DTEND : End date, default to today 23 # NOTE 01/25/18 since AppFeed is specific to Apps we are going to remove need for 24 # CRED2 and CRED3. Don't check at login, and the cookie check will validate 25 # after authentication. 26 define(
"MAX_PHONES", 5 );
29 $serviceMinimal =
true;
30 $serviceShowInfo =
false;
31 $serviceLoadMenu =
false;
32 $serviceShowMenu =
false;
36 require_once(dirname(__FILE__) .
'/../library/hcuService.i');
37 require_once(dirname(__FILE__) .
'/../../shared/library/cutrusted.i');
38 require_once(dirname(__FILE__) .
'/../../shared/library/hcuAppCommon.i');
39 require_once(dirname(__FILE__) .
'/../library/cu_credentials.i');
40 require_once(dirname(__FILE__) .
'/../../shared/library/cu_sms.i');
41 require_once(dirname(__FILE__) .
'/../library/permissions.i');
42 require_once(dirname(__FILE__) .
'/../library/hcuTransfer.i');
43 require_once(dirname(__FILE__) .
'/../library/hcuTransferScheduled.i');
44 require_once(
'LogSSO.i');
48 "APPID" => array(
'filter' => FILTER_SANITIZE_STRING),
49 "DTSTART" => array(
'filter' => FILTER_SANITIZE_STRING),
50 "DTEND" => array(
'filter' => FILTER_SANITIZE_STRING),
51 "CRED2" => array(
'filter' => FILTER_SANITIZE_STRING),
52 "CRED3" => array(
'filter' => FILTER_SANITIZE_STRING),
53 "USERID" => array(
'filter' => FILTER_SANITIZE_STRING),
54 "USERPASS" => array(
'filter' => FILTER_SANITIZE_STRING),
55 "USERKEY" => array(
'filter' => FILTER_SANITIZE_STRING),
56 "MFAKEY" => array(
'filter' => FILTER_SANITIZE_STRING),
57 "DEVICE_COOKIE" => array(
'filter' => FILTER_SANITIZE_STRING),
58 "MFABUNDLE" => array(
'filter' => FILTER_SANITIZE_STRING),
59 "ORG" => array(
'filter' => FILTER_SANITIZE_STRING),
60 "RQMODE" => array(
'filter' => FILTER_SANITIZE_STRING),
61 "FACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
62 "TACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
63 "AMOUNT" => array(
'filter' => FILTER_SANITIZE_NUMBER_FLOAT,
'options' => array(
"flags" => FILTER_FLAG_ALLOW_FRACTION ) ),
64 "TRMEMO" => array(
'filter' => FILTER_SANITIZE_STRING),
65 "PASSTO" => array(
'filter' => FILTER_SANITIZE_STRING),
66 "PASSWITH" => array(
'filter' => FILTER_SANITIZE_STRING),
67 "KEYACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
68 "CFGFLAG" => array(
'filter' => FILTER_SANITIZE_STRING),
69 "UPDAWARE" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
70 "USERMENU" => array(
'filter' => FILTER_SANITIZE_STRING),
71 "SENDAS" => array(
'filter' => FILTER_SANITIZE_STRING),
72 "AUTHMODE" => array(
'filter' => FILTER_SANITIZE_STRING),
76 # CFGFLAG is to be used to capture the session flag settings as used in Fmsg_tx on the desktop. Should be used 77 # currently in TXLIST / TXPOST to control whether or not to query the core for txaccount authority. Not implemented 78 # completely yet, but added to the Load_HB_ENV function and calls 80 HCU_ImportVars( $inPost,
"", $varOk );
81 # apptokenkey used only at HCU, not shared. Used to hash / check our token just to be sure it comes back unchanged. 82 $apptokenkey =
'Chahriv8pahvahsa';
92 if ($_SERVER[
'REQUEST_METHOD'] !=
'POST')
93 throw new Exception(
'Unauthorized Method',2010);# post method required
95 function trim_item(&$item, $key) {
99 array_walk_recursive($inPost,
'trim_item');
102 switch ($inPost[
'APPID']) {
105 $client_source_override =
'APP';
106 # no ip whitelist for iPhone app 107 $appkey =
"yuiQu8laLux7bahx";
108 # require a minimum version to continue 115 $client_source_override =
'ADA';
116 # no ip whitelist for Android app 117 $appkey =
"Gai7Vain2pab5zae";
119 # require a minimum version to continue 125 $HB_ENV[
'SYSENV'][
'logger']->info(
'request: ' . HCU_JsonEncode($_REQUEST));
126 $HB_ENV[
'SYSENV'][
'logger']->info(
'inPost: ' . HCU_JsonEncode($inPost));
127 throw new Exception(
"Unauthorized ID",2020); # invalid app
id 130 # start date optional, must be valid if provided, default 30 days past 131 # end date optional, but must be valid if provided, default today 132 # either USERID/USERPASS or USERKEY is required 133 # USERID HomeCU MEMBER for aggregated access 134 # USERPASS password for aggregated access 135 # USERKEY required if USERID/USERPASS not given; SSO security token 136 # CRED2 required, UTC date in YYYYMMDDHHMI format. 137 # must be within 30 minutes of actual UTC time as shown on HomeCU servers 138 # CRED3 hash required, must match calculated hash 140 # As of 01/25/18 no longer requiring CRED2 or CRED3 to act more like the desktop client. 142 if ( empty($inPost[
'ORG']) ) {
143 throw new Exception(
"Invalid Credentials",2030); # Missing values
146 $CU = $inPost[
'ORG'];
147 $SENDAS = (HCU_array_key_value(
'SENDAS',$inPost) && in_array(strtoupper($inPost[
'SENDAS']), array(
'JSON',
'XML')) ? $inPost[
'SENDAS'] :
'XML');
149 if (!empty($inPost[
'USERKEY'])) {
150 # got USERKEY, validate SSO method 152 $HB_ENV[
'AuthMode'] = $AUTHMODE;
154 # AuthMode=SSO w/Userkey 157 $apptokarr = array();
158 parse_str(urldecode($inPost[
'USERKEY']), $apptokarr);
161 if ( isset( $apptokarr[
"E"] ) && isset( $apptokarr[
"H"] ) ) {
162 $keycheck = CheckUserkey($inPost[
'ORG'], $inPost[
'USERKEY'], $apptokenkey);
170 # don't want to need this block - 171 # if needed, return CAUTH, MEMBER, EXPIRES from CheckUserkey 177 $MEMBER = $apptokarr[
'A'];
179 if ($keycheck[
'Status'][
'Message'] !==
'Success') {
180 throw new Exception($keycheck[
'Status'][
'Message'], $keycheck[
'Status'][
'Code']);
183 $keycheck = CheckSessionUserkey( $HB_ENV, $inPost[
'USERKEY'] );
185 if ($keycheck[
'Status'][
'Message'] !==
'Success') {
186 throw new Exception($keycheck[
'Status'][
'Message'], $keycheck[
'Status'][
'Code']);
189 $MEMBER = $keycheck[
"data"][
"Cn"];
192 $gSavedUserkey = $inPost[
'USERKEY'];
196 # No USERKEY, default to aggregate AUTH method 197 # for Odyssey, USERID will represent a user_name (login id) value 198 $AUTHMODE = (empty($inPost[
'AUTHMODE']) ?
"MFA" : $inPost[
'AUTHMODE']);
199 $HB_ENV[
'AuthMode'] = $AUTHMODE;
202 if ( empty(HCU_array_key_value(
'USERID',$inPost)) ) {
203 throw new Exception(
"Invalid Credentials",2040); #MFQ missing ID
205 $MEMBER = $inPost[
'USERID'];
208 if (!empty($MEMBER) && (preg_match(
"/[\\\`,\"\s;]/", $MEMBER))) {
209 throw new Exception(
"Invalid Credentials",2041); #Member Bad Characters
212 # set the basics so we can get the rest... 213 $HB_ENV[
'Cu'] = $inPost[
'ORG'];
214 $cu = $inPost[
'ORG'];
215 $SENDAS = (!empty($inPost[
'SENDAS']) && in_array(strtoupper($inPost[
'SENDAS']), array(
'JSON',
'XML')) ? $inPost[
'SENDAS'] :
'XML');
217 #replaced with call to LoadCuAdmin() in the top of hcuService.i 220 $HB_ENV[
'platform'] = $client_source_override;
221 $CFGFLAG= HCU_array_key_value(
'CFGFLAG', $inPost);
228 Load_HB_ENV($dbh, $inPost[
'ORG'], $MEMBER, $HB_ENV, $CFGFLAG);
230 if (HCU_array_key_exists(
'USERKEY', $inPost)) {
231 Check_Member_Credentials($HB_ENV, $inPost[
'USERKEY']);
234 # set these things so they are available from the Global scope for 235 # throtlpkt functions 236 $MEMBER=$HB_ENV[
'Cn'];
240 $Clw = $HB_ENV[
'livewait'];
241 $Ml = urldecode($HB_ENV[
'Ml']);
243 $HB_ENV[
'allowReadonly'] =
true;
244 if (!hcu_checkOffline($dbh, $HB_ENV)) {
245 throw new Exception($HB_ENV[
'offlineblurb'],15520); # CU is marked offline
248 if (empty($HB_ENV[
'Cn'])) {
252 throw new Exception(
'Authentication Failed',2003); # invalid Cn
254 if (empty($HB_ENV[
'Cu'])) {
255 throw new Exception(
'Authentication Failed',2002); # invalid Cu
259 $appEncryptionKey =
"";
269 if ($AUTHMODE !==
"SSO") {
270 # now that the HB_ENV array is filled, finish authentication if MFA 272 # Why yes, this IS hitting the database a second time to read the same member 273 # info we just got for Load_HB_ENV. But by migrating this way and using same 274 # functions as desktop to validate, in the future 275 # we can use this instead and float closer to the desktop codeset 277 $userrec = GetUserbyName($dbh, $inPost[
'ORG'], $MEMBER);
279 if ( $userrec[
'lockedacct'] ) {
280 throw new Exception(
'Account Locked', 15502); # locked
285 $HB_ENV[
'Ce'] = time() + $HB_ENV[
'SYSENV'][
'ticket'][
'expires'];
286 $HB_ENV[
'Clu'] = (empty($userrec[
'lastupdate']) ? $MC->msg(
"Unknown") : urlencode(trim($userrec[
'lastupdate'])));
287 $HB_ENV[
'Fhdays'] = $userrec[
'fhdays'];
290 $HB_ENV[
"sid"] = strval(time());
293 if ( empty( $gSavedUserkey ) ) {
294 $gSavedUserkey = BuildBaseSessionTicket( $HB_ENV );
297 switch ($HB_ENV[
'AuthMode']) {
302 # CHECK USERID / USERPASS if given, even if MFAKEY is not given 303 # IF EITHER ONE FAILS, SEND HARD FAIL 305 # USERID validated by userrec above 307 if (HCU_array_key_exists(
'USERID', $inPost) && HCU_array_key_exists(
'USERPASS', $inPost)) {
308 if ($userrec[
'rowfound'] == 0 ||
309 !password_verify($inPost[
'USERPASS'], $userrec[
'passwd']) ||
310 strlen(trim($inPost[
'USERPASS'])) < 4) {
314 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_PWD']);
316 # this should log password failure if rowfound == 1 317 throw new Exception(
'Invalid Username or Password', 15501); # userrec not found or passwd fails
323 # If no USERPASS or no MFAKEY or invalid MFAKEY or Member forced to reset, send email prompt 325 $sendEmailResponse =
true;
326 if ( HCU_array_key_exists(
'USERPASS', $inPost) ||
327 $HB_ENV[
'Ffreset'] != GetUserFlagsValue(
'MEM_FORCE_RESET') ) {
331 if ( HCU_array_key_exists(
'DEVICE_COOKIE', $inPost) &&
332 IsValidAppDeviceCookie($HB_ENV[
"cu"], HCU_array_key_value(
'DEVICE_COOKIE', $inPost), $userrec) ) {
334 $sendEmailResponse =
false;
335 }
else if ( HCU_array_key_exists(
'MFAKEY', $inPost) &&
336 IsValidMFAKey(HCU_array_key_value(
'MFAKEY', $inPost), $userrec) ) {
338 $sendEmailResponse =
false;
342 if ( $sendEmailResponse ) {
343 # first step, ignore any previous bundle 344 # build empty bundle with USERID, 345 # add USERPASS and MFAKEY if given 346 $mfaBundle = array(
'mode' =>
'MFA',
'USERID' => $inPost[
'USERID']);
347 if (HCU_array_key_exists(
'USERPASS', $inPost)) {
348 $mfaBundle[
'USERPASS'] = $inPost[
'USERPASS'];
350 if (HCU_array_key_exists(
'MFAKEY', $inPost) && $HB_ENV[
'Ffreset'] != GetUserFlagsValue(
'MEM_FORCE_RESET')) {
351 $mfaBundle[
'MFAKEY'] = $inPost[
'MFAKEY'];
353 $mfaBundle[
'BUILDTIME'] = time();
354 $mfaBundle = createBundle($inPost[
'ORG'], $mfaBundle);
355 if (empty($mfaBundle)) {
356 throw new Exception(
"Authentication Failed Building Credential Package", 15597); # bundle failed
358 $HB_ENV[
'mfaBundle'] = $mfaBundle;
359 $reply_arr = EML_prompt($dbh, $HB_ENV);
362 send_response( $reply_arr, $SENDAS );
366 # expect USERID, MFA_E (EMAIL) 368 $mfaBundle = HCU_array_key_value(
'MFABUNDLE', $inPost);
369 if (empty($mfaBundle)) {
370 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
371 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
373 $mfaBundle = openBundle($inPost[
'ORG'], $mfaBundle);
374 if (!checkBundle(
'EML', $mfaBundle, $inPost)) {
375 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
376 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
378 if (!checkBundle(
'TIME', $mfaBundle, $inPost)) {
379 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL_TIMEOUT']);
380 throw new Exception(
"Authentication Failed Login Process Took Too Long", 15595); # bundle expired
382 # isValidEmail checks for db empty and valid input but... somebody should save this.... 383 if (!HCU_array_key_value(
'MFA_E', $inPost) || !isValidEmail(HCU_array_key_value(
'MFA_E', $inPost), $userrec)) {
384 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_EMAIL']);
385 throw new Exception(
"Authentication Failed Invalid Email", 15506); # email
387 $inBundle = $mfaBundle; # might test password again, so save the incoming bundle before we recalculate it
388 $mfaBundle[
'mode'] =
'EML';
389 $mfaBundle[
'MFA_E'] = $inPost[
'MFA_E'];
390 $mfaBundle[
'BUILDTIME'] = time();
391 $mfaBundle = createBundle($inPost[
'ORG'], $mfaBundle);
392 if (empty($mfaBundle)) {
393 throw new Exception(
"Authentication Failed Building Credential Package", 15597); # bundle failed
395 $HB_ENV[
'mfaBundle'] = $mfaBundle;
396 # if sec reset, prompt for password, else send challenge 397 if ($HB_ENV[
'Ffreset'] == GetUserFlagsValue(
'MEM_FORCE_RESET')) {
398 # if force security reset, skip the MFA steps. 399 # If we have a password and it is valid, fall through as logged in 400 if (!HCU_array_key_value(
'USERPASS', $inBundle) || !password_verify($inBundle[
'USERPASS'], $userrec[
'passwd']) ||
401 strlen(trim($inBundle[
'USERPASS']) < 4)) {
402 $reply_arr = PWD_prompt($dbh, $HB_ENV);
404 send_response( $reply_arr, $SENDAS );
408 if (intval($userrec[
'flagset3'] & GetFlagsetValue(
'CU3_MFA_AUTHCODE'))) {
409 # using secure access code 410 # send destination list 411 if (trim($userrec[
'email']) ==
'') {
412 $HB_ENV[
'MFA_E'] = $inPost[
'MFA_E'];
414 $reply_arr = SAC_destination($dbh, $HB_ENV, $userrec);
416 # using challenge questions 417 $reply_arr = MFQ_send_chall($dbh, $HB_ENV, $MC);
421 send_response( $reply_arr, $SENDAS );
426 # expect USERID, MFA responses as in current challenge questions 427 # if valid MFA response check password (send password request?) 428 $mfaBundle = HCU_array_key_value(
'MFABUNDLE', $inPost);
429 if (empty($mfaBundle)) {
430 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
431 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
433 $mfaBundle = openBundle($inPost[
'ORG'], $mfaBundle);
434 if (!checkBundle(
'MFQ', $mfaBundle, $inPost)) {
435 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
436 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
438 if (!checkBundle(
'TIME', $mfaBundle, $inPost)) {
439 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL_TIMEOUT']);
440 throw new Exception(
"Authentication Failed Login Process Took Too Long", 15595); # bundle expired
442 if (!(MFQ_defined($inPost) > 0)) {
443 throw new Exception(
'Missing MFQ Parameters', 2040);
445 # MFQ_defined($inPost) > 0) 446 # if (2-factor & not security reset) & MFA_* exists, we have MFA response, validate answers 447 list($fail, $failreason) = MFQ_response($dbh, $HB_ENV, $inPost);
449 # challenge succeeded, ask for password 450 $mfaBundle[
'mode'] =
'MFQ';
451 $mfaBundle[
'haveMFQ'] =
'MFQ';
452 $mfaBundle[
'BUILDTIME'] = time();
453 $mfaBundle = createBundle($inPost[
'ORG'], $mfaBundle);
454 if (empty($mfaBundle)) {
455 throw new Exception(
"Authentication Failed Building Credential Package", 15597); # bundle failed
457 $HB_ENV[
'mfaBundle'] = $mfaBundle;
458 $reply_arr = PWD_prompt($dbh, $HB_ENV);
460 send_response( $reply_arr, $SENDAS );
462 LogFail($dbh, $HB_ENV, $inPost, $failreason, $GLOBALS[
'MEM_LOGIN_FAILED_QST']);
463 # should this be a fail instead? W/new method, 464 # only get MFQ response if I asked for it 466 throw new Exception(
"Authentication Failed Invalid Challenge", 15506); # email
471 # expect USERID, MFS_Deliver (destination for SAC) 472 # if valid destination & email send SAC 473 $mfaBundle = HCU_array_key_value(
'MFABUNDLE', $inPost);
474 if (empty($mfaBundle)) {
475 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
476 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
478 $mfaBundle = openBundle($inPost[
'ORG'], $mfaBundle);
479 if (!checkBundle(
'MFS', $mfaBundle, $inPost)) {
480 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
481 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
483 if (!checkBundle(
'TIME', $mfaBundle, $inPost)) {
484 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL_TIMEOUT']);
485 throw new Exception(
"Authentication Failed Login Process Took Too Long", 15595); # bundle expired
487 if (!HCU_array_key_exists(
'MFS_Deliver', $inPost)) {
488 throw new Exception(
'Missing Parameter Delivery Method', 2040);
492 # might need to get Cu & lookup length + ttl 493 # but right now just use defaults 6 and 1200 494 $authResp = generateAuthcode();
495 if (!$authResp[
'authcode'] || !$authResp[
'authexpires']) {
496 throw new Exception(
'Generate Access Code Failed', 3050);
498 if (!setAuthcode($dbh, $HB_ENV, $HB_ENV[
'MC'], $userrec, $authResp[
'authcode'], $authResp[
'authexpires'])) {
499 throw new Exception(
'Save Access Code Failed', 3050);
501 $sendto = str_replace(array(
"-",
"_",
"."), array(
"+",
"/",
"="), $inPost[
'MFS_Deliver']);
502 if (!sendAuthcode($HB_ENV[
'dbh'], $HB_ENV, $userrec, $sendto)) {
503 throw new Exception(
'Send Access Code Failed', 3050);
505 $mfaBundle[
'mode'] =
'MFS';
506 $mfaBundle[
'MFS_Deliver'] = $inPost[
'MFS_Deliver'];
507 $mfaBundle[
'BUILDTIME'] = time();
508 $mfaBundle = createBundle($inPost[
'ORG'], $mfaBundle);
509 if (empty($mfaBundle)) {
510 throw new Exception(
"Authentication Failed Building Credential Package", 15597); # bundle failed
512 $HB_ENV[
'mfaBundle'] = $mfaBundle;
513 $reply_arr = SAC_prompt($dbh, $HB_ENV);
515 send_response( $reply_arr, $SENDAS );
518 $mfaBundle = HCU_array_key_value(
'MFABUNDLE', $inPost);
519 if (empty($mfaBundle)) {
520 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
521 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
523 $mfaBundle = openBundle($inPost[
'ORG'], $mfaBundle);
524 if (!checkBundle(
'MFC', $mfaBundle, $inPost)) {
525 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
526 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
528 if (!checkBundle(
'TIME', $mfaBundle, $inPost)) {
529 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL_TIMEOUT']);
530 throw new Exception(
"Authentication Failed Login Process Took Too Long", 15595); # bundle expired
533 # if valid SAC check password (send password request?) 534 if (!HCU_array_key_exists(
'MFS_Auth', $inPost)) {
535 throw new Exception(
'Missing MFS Parameter', 2040);
537 if (!isValidAuthcode($userrec, $inPost[
'MFS_Auth'])) {
538 throw new Exception(
'Invalid Access Code', 15507);
540 $mfaBundle[
'mode'] =
'MFC';
541 $mfaBundle[
'haveSAC'] =
'SAC';
542 $mfaBundle[
'BUILDTIME'] = time();
543 $mfaBundle = createBundle($inPost[
'ORG'], $mfaBundle);
544 if (empty($mfaBundle)) {
545 throw new Exception(
"Authentication Failed Building Credential Package", 15597); # bundle failed
547 $HB_ENV[
'mfaBundle'] = $mfaBundle;
548 $reply_arr = PWD_prompt($dbh, $HB_ENV);
550 send_response( $reply_arr, $SENDAS );
553 $mfaBundle = HCU_array_key_value(
'MFABUNDLE', $inPost);
554 if (empty($mfaBundle)) {
555 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
556 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
558 $mfaBundle = openBundle($inPost[
'ORG'], $mfaBundle);
559 if (!checkBundle(
'MFP', $mfaBundle, $inPost)) {
560 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL']);
561 throw new Exception(
"Authentication Failed Invalid Credential Package", 15599); # bundle failed
563 if (!checkBundle(
'TIME', $mfaBundle, $inPost)) {
564 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_BNDL_TIMEOUT']);
565 throw new Exception(
"Authentication Failed Login Process Took Too Long", 15595); # bundle expired
567 # expect USERID, USERPASS 568 # if valid send MFAKEY, USERKEY, FULLFEED 569 # check USERPASS as password 570 if (strlen(trim($inPost[
'USERPASS'])) < 4 ||
571 !password_verify($inPost[
'USERPASS'], $HB_ENV[
'password'])) {
573 LogFail($dbh, $HB_ENV, $inPost, $GLOBALS[
'MEM_LOGIN_FAILED_PWD']);
574 throw new Exception(
"Authentication Failed", 15505); # password
579 throw new Exception(
"Unknown authentication mode", 2999);
587 # logged in - now what? 588 LogPass($dbh,$HB_ENV);
635 # password ok, if Force pwd or verify mail, send upd request or fall thru to send data 637 $sendkeys = array(
'MFAKEY' => MakeMFAKey( $HB_ENV ),
638 'TIMEOUT' => $HB_ENV[
'AppTimeout'],
639 'menu' =>
'REPLACE MENU HERE',
645 "REMEMBER_DEVICE" => array(
'filter' => FILTER_SANITIZE_STRING)
648 HCU_ImportVars( $pass,
"", $postVar );
649 if ( strtolower(HCU_array_key_value(
"REMEMBER_DEVICE", $pass)) ==
"yes" ) {
650 $mfaMode = (intval($userrec[
'flagset3'] & GetFlagsetValue(
'CU3_MFA_AUTHCODE')));
651 $mfaDate = HCU_array_key_value(
"mfadate", $userrec);
653 $persistsTime = $HB_ENV[
'SYSENV'][
'ticket'][
'persists'];
655 $cookieParams = array (
"cu" => $HB_ENV[
'cu'],
656 "user_name" => $userrec[
'user_name'],
657 "saved_pass" => $userrec[
'passwd'],
658 "saved_email" => $userrec[
'email'],
659 "saved_confidence" => $userrec[
'confidence'],
660 "mfa_mode" => $mfaMode,
661 "mfa_date" => $mfaDate,
662 "persists_time" => $persistsTime
665 $cookieInfo = CreateDeviceCookie( $cookieParams);
667 $sendkeys[
"DEVICE_COOKIE"] = $cookieInfo[
"name"] .
"|" . $cookieInfo[
"content"] .
"|" . $cookieInfo[
"expire"];
670 # password ok & 2-factor, send upd request if security reset 671 if ( $inPost[
"UPDAWARE"] == 1 ) {
672 if ($HB_ENV[
'forceupdate'] > 0 && $HB_ENV[
'offline'] ==
'N') {
676 $reply_arr = Return_ReqUpdate($inPost[
'ORG'], $HB_ENV[
'Cn'], $HB_ENV[
'Uid'], $HB_ENV, $sendkeys);
678 send_response( $reply_arr, $SENDAS );
680 }
else if ( $inPost[
"UPDAWARE"] == 2 ) {
682 $l_MbrSettings = Check_Member_Settings($dbh, $HB_ENV, $HB_ENV[
'MC']);
684 if ( $l_MbrSettings[
'code'] !=
'000' ) {
685 $sendkeys[
"ENVINFO"] = BuildEnvironmentInfoCookie($HB_ENV, $inPost[
"UPDAWARE"]);
690 $appEncryptionKey = GetPayloadEncryptionKey(32);
695 if ( empty( $gSavedUserkey ) ) {
696 $gSavedUserkey = BuildBaseSessionTicket( $HB_ENV );
699 apache_note(
'user_name',
"{$inPost['ORG']}:{$HB_ENV['Uid']}");
701 $apptoken = MakeSessionUserkey( $HB_ENV );
702 $dflt_date = date(
"Ymd", time() - (1 * 24 * 60 * 60)); # odyssey
default start date is yesterday
703 $recent = date(
"Ymd", time() - (1 * 24 * 60 * 60));
705 $dflt_end = date(
"Ymd", time() + (4 * 24 * 60 * 60)); # + 4 days
706 $DTSTART = (empty($inPost[
'DTSTART']) ?
"$dflt_date" : $inPost[
'DTSTART']);
707 $DTEND = (empty($inPost[
'DTEND']) ?
"$dflt_end" : $inPost[
'DTEND']);
708 $sqlend = sqlmdy($DTEND);
710 $PASSWITH = HCU_array_key_value(
'PASSWITH', $inPost);
716 parse_str($PASSWITH, $pass);
717 if (array_key_exists(
'MYBAD', $pass)) {
718 $mybad = HCU_array_key_value(
'MYBAD', $pass);
719 $message =
"Okey Dokey";
721 throw new Exception( $message , $mybad );
724 switch (HCU_array_key_value(
'RQMODE', $inPost)) {
727 $myTicket = MakeSessionUserkey( $HB_ENV );
730 $reply_arr = array(
'appToken' => urlencode($myTicket));
736 $expires = $now + $HB_ENV[
'SYSENV'][
'ticket'][
'expires'];
738 $mycookie =
"Ctime=$now&Cu={$HB_ENV['Cu']}&Cn={$HB_ENV['Cn']}&Uid={$HB_ENV['Uid']}&Ce=$expires&Ca=&Ffchg={$HB_ENV['Ffchg']}&Ffremain={$HB_ENV['Ffremain']}";
739 $mycookie .=
"&Fset={$HB_ENV['Fset']}&Fset2=${HB_ENV['Fset2']}&Fset3={$HB_ENV['Fset3']}&Fhdays={$HB_ENV['histdays']}&Flite=0&Clw={$HB_ENV['livewait']}&Clu={$HB_ENV['lastupdate']}";
740 $mycookie .=
"&Fplog={$HB_ENV['Fplog']}&Fflog={$HB_ENV['Fflog']}&Fmsg_tx={$HB_ENV['Fmsg_tx']}&Ml=" . urlencode(trim($HB_ENV[
'Ml'])) .
"&Flang=$Flang&Ffreset={$HB_ENV['Ffreset']}";
742 SetTicket($HB_ENV,
"", $apptoken);
745 $logPassthroughTicket =
new CreditUnionGate(CreditUnionGate::LOG_PASSTHROUGH_TICKET_FEATURE, $config);
746 if ($logPassthroughTicket->WillPass($HB_ENV[
'Cu'])) {
747 $HB_ENV[
'SYSENV'][
'logger']->info(
"[AppFeedPassthrough] appToken=$apptoken;Cn={$HB_ENV['Cn']}");
750 switch ($inPost[
'PASSTO']) {
751 # seems extra, but this way we can change stuff at homecu 752 # without having to recompile app. 754 $PSCRIPT = $HB_ENV[
'homebankingpath'];
755 $PSCRIPT .=
"/ImageSOLO.prg";
756 $PSCRIPT .=
"?cu=${HB_ENV['Cu']}";
759 $PSCRIPT = urldecode($PASSWITH);
760 if (stripos($PSCRIPT,
'homecu') !==
false) {
761 $delim = (strpos($PSCRIPT,
'?') ===
false ?
'?' :
'&');
762 $PSCRIPT .=
"{$delim}vanilla=1";
767 $PSCRIPT = $HB_ENV[
'homebankingpath'];
768 $PSCRIPT .=
"/hcuConnect.prg?cu=${HB_ENV['Cu']}&vanilla=1";
770 parse_str($PASSWITH, $pass);
771 foreach ($pass as $key => $value) {
772 if ($key ==
'MBRACCT') {
773 if (!empty($value)) {
774 $encryptedAccount = hcu_encrypturl($value, $HB_ENV[
'historyHash']);
775 $PSCRIPT .=
"&account=$encryptedAccount";
778 $PSCRIPT .=
"&$key=$value";
781 # empty out PASSWITH so it doesn't get added again below 785 $PSCRIPT = $HB_ENV[
'homebankingpath'];
786 $PSCRIPT .=
"/{$inPost['PASSTO']}";
787 $PSCRIPT .=
"?cu=${HB_ENV['Cu']}";
789 if (!empty($PASSWITH))
790 $PSCRIPT .=
"&" . urldecode($PASSWITH);
792 header(
"Location: $PSCRIPT");
797 # PERKEY is the period key for the desired statement 798 # this could just parse PASSWITH into the environment, but I want to only take the parts I expect - 800 parse_str($PASSWITH, $pass);
801 $stId = $pass[
'PERKEY'];
802 $pAcct = $pass[
'MBRACCT'];
803 # if stId is blank or pAcct is blank throw error 804 if (empty($stId) || empty($pAcct)) {
805 throw new Exception(
"Missing eStatement parameters",4050); # ESTMT_PDF
808 # Create_PDF_Statement will be responsible for the output 809 #ODYSSEY pass $pass['MBRACCT'] for this function 810 $pdfinfo = Create_PDF_Statement($stId, $HB_ENV, $MC,$pAcct);
813 if ( $pdfinfo[
"status"][
"code"] ==
"0" ) {
818 for ( $i = 0; $i < count( $pdfInfo[
"errors"] ); $i++ ) {
819 if ( $errorMessage !=
"" ) {
820 $errorMessage .=
";";
823 $errorMessage .= $pdfInfo[
"errors"];
826 throw new Exception(
"PDF Download Error: $errorMessage", 4051); # ESTMT_PDF
832 #$PASSWITH="NOTICE_TYPE=${TYPE}&NOTICE_ID=${ID}&NOTICE_ACTION=${ACTION}&NOTICE_RESP=${ANSWERID}"; 833 # TYPE indicates notice, survey, mktg message, promo etc 834 # ID is the notice id previously sent or 0 if this is a 'get' 835 # ACTION is P for post or V to view/get 836 # ANSWERID (optional) is the chosen response for survey/mktg message 837 # this could just parse PASSWITH into HB_ENV['HCUPOST'], but I want to only take the parts I expect - 839 parse_str($PASSWITH, $pass);
841 switch ($pass[
'NOTICE_ACTION']) {
843 # action P post so set up the HCUPOST array 844 if (!empty($pass[
'NOTICE_ID']))
845 $HB_ENV[
'HCUPOST'][
'notice_id'] = $pass[
'NOTICE_ID'];
846 if (!empty($pass[
'NOTICE_TYPE']))
847 $HB_ENV[
'HCUPOST'][
'notice_type'] = $pass[
'NOTICE_TYPE'];
849 $resp_arr = ANS_list($pass);
850 $HB_ENV[
'HCUPOST'][
'notice_response'] = array();
851 foreach ($resp_arr as $key => $value) {
852 #print "key $key value $value <br>"; 853 $HB_ENV[
'HCUPOST'][
'notice_response'][] = $value;
856 $HB_ENV[
'HCUPOST'][
'notice_device'] =
'P';
857 $HB_ENV[
'HCUPOST'][
'notice_msg_show'] = 1;
859 $response = Update_NoticeInfo($dbh, $HB_ENV, $MC);
861 $reply_arr = array();
863 if (count($response[
'status'][
'errors']) > 0) {
864 throw new Exception(implode(
" ",$response[
'status'][
'errors']),15530); # Update_NoticeInfo
866 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
867 'DTSERVER' => date(
'YmdHis'),
868 'MEMBER' => $HB_ENV[
'Uid'],
869 'USERKEY' => $apptoken );
871 $reply_arr[
'NOTICE'] = array();
872 if (HCU_array_item_count(
'notice_results', $response) > 0) {
874 foreach ($response[
'notice_results'] as $noticekey => $details) {
875 $reply_arr[
'NOTICE'][
'NOTICE_TYPE'] = $details[
'notice_type'];
876 $reply_arr[
'NOTICE'][
'NOTICE_ID'] = $details[
'notice_id'];
877 $reply_arr[
'NOTICE'][
'NOTICE_POPUP'] = $details[
'notice_popup'];
878 if ($pass[
'NOTICE_TYPE'] ==
'N') {
879 $reply_arr[
'NOTICE'][
'NOTICE_DONOTSHOWTEXT'] = htmlentities($details[
'notice_donotshowtext'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
880 $reply_arr[
'NOTICE'][
'NOTICE_LINKTARGET'] = $details[
'notice_linktarget'];
881 $reply_arr[
'NOTICE'][
'NOTICE_LINKDISPLAY'] = htmlentities($details[
'notice_linkdisplay'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
883 $reply_arr[
'NOTICE'][
'NOTICE_INTRO'] = htmlentities($details[
'notice_intro'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
884 $reply_arr[
'NOTICE'][
'NOTICE_TITLE'] = htmlentities($details[
'notice_title'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
885 $reply_arr[
'NOTICE'][
'NOTICE_TEXT'] = htmlentities(CleanWordQuotes($details[
'notice_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
886 $reply_arr[
'NOTICE'][
'NOTICE_ANSWERTYPE'] = $details[
'notice_answertype'];
887 $reply_arr[
'NOTICE'][
'NOTICE_ANSWERS'] = array();
888 if (count($details[
'notice_answers'])) {
889 foreach ($details[
'notice_answers'] as $anskey => $ansdetl) {
890 $reply_arr[
'NOTICE'][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
891 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
892 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE),
893 'ANSWER_VOTES' =>
"{$ansdetl['answer_votes']}",
894 'ANSWER_PCT' =>
"{$ansdetl['answer_pct']}"));
905 case 'G': # gather multiple promos plus one survey/message
906 if ($pass[
'NOTICE_TYPE'] ==
'N') {
907 # looks like the last two params are reversed? 908 $response = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P', $pass[
'NOTICE_ID'], 0);
910 $response = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P', $pass[
'NOTICE_TYPE']);
913 if (count($response[
'status'][
'errors']) > 0) {
914 throw new Exception(implode(
" ",$response[
'status'][
'errors']),15540); # Get_NoticeInfo
916 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
917 'MEMBER' => $HB_ENV[
'Uid'],
918 'USERKEY' => $apptoken );
920 $reply_arr[
'NOTICE'] = array();
921 if (count($response[
'notice'])) {
922 foreach ($response[
'notice'] as $noticekey => $details) {
926 if (!count($details[
'notice_answers']) &&
sizeof($details[
'notice_donotshowtext'])) {
927 $details[
'notice_answers'][] = array(
'answer_id' => $details[
'notice_id'],
'answer_text' => $details[
'notice_donotshowtext']);
928 $details[
'notice_answertype'] =
'M';
930 foreach ($details as $key => $value) {
931 $key = strtoupper($key);
933 case "NOTICE_ANSWERS":
934 $reply_arr[
'NOTICE'][
'NOTICE_ANSWERS'] = array();
935 foreach ($value as $anskey => $ansdetl) {
936 $reply_arr[
'NOTICE'][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
937 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
938 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
943 if ($pass[
'NOTICE_TYPE'] !=
'N') {
944 $reply_arr[
'NOTICE'][$key] = htmlentities(CleanWordQuotes($value), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
950 case "NOTICE_DONOTSHOWTEXT":
951 case "NOTICE_MSG_TX":
952 case "NOTICE_MSG_TX_SHOW":
953 case "NOTICE_MSG_TX_PERM":
954 case "NOTICE_SUPPRESSRESPONSE":
955 case "NOTICE_POSTTARGET":
960 case "NOTICE_ANSWERTYPE":
961 case "NOTICE_LINKTARGET":
962 case "NOTICE_LINKDISPLAY":
967 $reply_arr[
'NOTICE'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
977 # unknown notice_action -- ignore? 978 throw new Exception(
"Unknown Notice Mode",15550);
984 # before we get started, check permissions 985 $accessRights = Perm_AccessRights( $dbh, $HB_ENV, array(
"feature" => FEATURE_TRANSFERS ) );
986 if ( ! HCU_array_key_value(
'create', $accessRights)) {
987 throw new Exception( $HB_ENV[
'MC']->msg(
'Rights not set', HCU_DISPLAY_AS_HTML), 915 );
990 $HB_ENV[
'allowReadonly'] =
false;
991 if (!hcu_checkOffline($dbh, $HB_ENV)) {
992 throw new Exception($HB_ENV[
'offlineblurb'], 15520); # TXLIST cu not online
995 # AppFeed will accept CFGFLAG from app, set it in HB_ENV so it passes to TX_list / TX_post 996 # this was to maintain Fmsg_tx session flags w/o html session 997 # but didn't want to limit to ONLY Fmsg_tx - might need others in future 998 # coding ready for test in OFXRequest but not ready in server functions 999 #if cfgflag came in from app, pass it along on TX_list / TX_post call 1000 # look for updated setting (of cfgflag? or of Fmsg_tx?) on return 1001 # pass updated setting to app so they can return it again? 1003 $txreturn = TX_list($dbh, $HB_ENV);
1005 if (HCU_array_key_exists(
"Fmsg_tx", $txreturn[
'status'])) {
1007 $HB_ENV[
'Fmsg_tx'] = $txreturn[
'status'][
'Fmsg_tx'];
1009 $gSavedUserkey = BuildBaseSessionTicket($HB_ENV);
1010 $apptoken = MakeSessionUserkey($HB_ENV);
1012 if ( HCU_array_item_count(
"errors", $txreturn[
'status']) > 0 ) {
1013 throw new Exception(implode(
' ', $txreturn[
'status'][
'errors']), 15560); # TX_list returns System Unavailable
1016 foreach ($txreturn[
'acctlist'] as $tx) {
1017 if ($tx[
'from'] ==
'Y')
1021 # FIX FOR PROD - Error checking, anyone? 1022 # send appropriate status if we can't get a list 1025 throw new Exception(
"No Accounts Available", 15570); # TX_list no valid accounts
1027 $reply_arr = array();
1028 $reply_arr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO'),
1029 'MEMBER' => $HB_ENV[
'Uid'],
1030 'USERKEY' => $apptoken,
1031 'TRMEMOMAX' => $HB_ENV[
'trmemomaxlen']);
1033 foreach ($txreturn[
'acctlist'] as $acctkey => $details) {
1034 $acct_arr = array();
1035 $acct_arr[
'ACCTID'] = $acctkey;
1036 foreach ($details as $key => $value) {
1037 $key = strtoupper($key);
1038 $val = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1039 $acct_arr[$key] = $val;
1042 $reply_arr[
'TXLIST'][][
'ACCT'] = $acct_arr;
1045 # now get the transfer notice, if any 1046 $txnotice = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'transferNotice', 1);
1048 if (count($txnotice[
'notice'])) {
1049 foreach ($txnotice[
'notice'] as $noticekey => $details) {
1053 if (!count($details[
'notice_answers']) &&
sizeof($details[
'notice_donotshowtext'])) {
1054 $details[
'notice_answers'][] = array(
'answer_id' => $details[
'notice_id'],
'answer_text' => $details[
'notice_donotshowtext']);
1055 $details[
'notice_answertype'] =
'M';
1058 foreach ($details as $key => $value) {
1059 $key = strtoupper($key);
1061 case "NOTICE_ANSWERS":
1062 $reply_arr[
'TXLIST'][
'NOTICE'][
'NOTICE_ANSWERS'] = array();
1063 foreach ($value as $anskey => $ansdetl) {
1064 $reply_arr[
'TXLIST'][
'NOTICE'][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
1065 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
1066 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
1072 case "NOTICE_DONOTSHOWTEXT":
1073 case "NOTICE_MSG_TX":
1074 case "NOTICE_MSG_TX_SHOW":
1075 case "NOTICE_MSG_TX_PERM":
1076 case "NOTICE_SUPPRESSRESPONSE":
1077 case "NOTICE_POSTTARGET":
1082 case "NOTICE_POPUP":
1083 case "NOTICE_ANSWERTYPE":
1084 case "NOTICE_LINKTARGET":
1085 case "NOTICE_LINKDISPLAY":
1086 case "NOTICE_INTRO":
1087 case "NOTICE_TITLE":
1090 $reply_arr[
'TXLIST'][
'NOTICE'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1096 $allowScheduled = (($HB_ENV[
'flagset2'] & $GLOBALS[
'CU2_PROCRECUR']) && PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_SCHEDULED_TRANSFERS,
'',
false));
1098 if ( $allowScheduled ) {
1099 $reply_arr[
"SCHEDULED"][
"SCHEDALLOW"] =
"yes";
1102 $transferFrequencyList = TxIntervalList($HB_ENV[
"MC"]);
1103 $transferContinueList = TxContinueList($HB_ENV[
"MC"]);
1106 if ( count( $transferFrequencyList ) > 0 ) {
1107 $freqList = array();
1108 for ( $i = 0; $i < count( $transferFrequencyList ); $i++ ) {
1109 $freqList[][
"FREQUENCY"] = array(
"NAME" => $transferFrequencyList[$i][
"value"],
1110 "VALUE" => $transferFrequencyList[$i][
"text"] );
1113 $reply_arr[
"SCHEDULED"][
"FREQUENCIES"] = $freqList;
1116 if ( count( $transferContinueList ) > 0 ) {
1117 $contList = array();
1118 for ( $i = 0; $i < count( $transferContinueList ); $i++ ) {
1119 $contList[][
"CONTINUE"] = array(
"NAME" => $transferContinueList[$i][
"value"],
1120 "VALUE" => $transferContinueList[$i][
"text"] );
1122 $reply_arr[
"SCHEDULED"][
"CONTINUES"] = $contList;
1126 $aryScheduledTerms = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'rptTransferTerms');
1128 $reply_arr[
'SCHEDULED'][
'TERMS'] = array();
1129 if (count($aryScheduledTerms[
'notice'])) {
1130 foreach ($aryScheduledTerms[
'notice'] as $noticekey => $details) {
1131 foreach ($details as $key => $value) {
1132 $key = strtoupper($key);
1134 case "NOTICE_ANSWERS":
1136 $reply_arr[
'SCHEDULED'][
'TERMS'][
'NOTICE_ANSWERS'] = array();
1137 foreach ($value as $anskey => $ansdetl) {
1138 $reply_arr[
'SCHEDULED'][
'TERMS'][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
1139 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
1140 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
1146 case "NOTICE_INTRO":
1147 case "NOTICE_TITLE":
1148 case "NOTICE_DONOTSHOWTEXT":
1149 case "NOTICE_MSG_TX":
1150 case "NOTICE_MSG_TX_SHOW":
1151 case "NOTICE_MSG_TX_PERM":
1152 case "NOTICE_SUPPRESSRESPONSE":
1153 case "NOTICE_POSTTARGET":
1158 case "NOTICE_POPUP":
1159 case "NOTICE_ANSWERTYPE":
1160 case "NOTICE_LINKTARGET":
1161 case "NOTICE_LINKDISPLAY":
1164 $reply_arr[
'SCHEDULED'][
'TERMS'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1176 # before we get started, check permissions 1177 # but OdyTxPost function checks near the top.... so skip this one? 1183 $HB_ENV[
'allowReadonly'] =
false;
1184 if (!hcu_checkOffline($dbh, $HB_ENV)) {
1185 throw new Exception($HB_ENV[
'offlineblurb'],15520); # TXPOST cu not online
1188 # unencode the email for the txpost call 1190 # OFXRequest will accept CFGFLAG from app, set it in HB_ENV so it passes to TX_list / TX_post 1191 # this was to maintain Fmsg_tx session flags w/o html session 1192 # but didn't want to limit to ONLY Fmsg_tx - might need others in future 1193 # coding ready for test in OFXRequest but not ready in server functions 1194 #if cfgflag came in from app, pass it along on TX_list / TX_post call 1195 # look for updated setting (of cfgflag? or of Fmsg_tx?) on return 1196 # pass updated setting to app so they can return it again? 1204 "FACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
1205 "TACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
1206 "TXFREQ" => array(
'filter' => FILTER_SANITIZE_STRING),
1207 "TXSTART" => array(
'filter' => FILTER_SANITIZE_STRING),
1208 "TXCONTINUE" => array(
'filter' => FILTER_SANITIZE_STRING),
1209 "TXEND" => array(
'filter' => FILTER_SANITIZE_STRING),
1210 "AMOUNT" => array(
'filter' => FILTER_SANITIZE_STRING),
1211 "TRMEMO" => array(
'filter' => FILTER_SANITIZE_STRING)
1214 HCU_ImportVars( $pass,
"", $postVar );
1217 if ( HCU_array_key_exists(
"TXFREQ", $pass ) ) {
1218 $txReturn = TxPostAdvanced( $HB_ENV, $dbh, $pass, $HB_ENV[
"MC"] );
1220 if ( HCU_array_item_count(
'errors',$txReturn[
'status']) > 0 ) {
1221 throw new Exception(implode(
' ',$txReturn[
'status'][
'errors']),15580); # TX_post returns data validation errors
1225 $reply_arr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO'),
1226 'DTSERVER' => date(
'YmdHis'),
1227 'MEMBER' => $HB_ENV[
'Uid'],
1228 'USERKEY' => $apptoken );
1231 foreach ($txReturn[
'txn'] as $key => $value) {
1232 $key = strtoupper($key);
1233 $val = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1234 $reply_arr[
'TXPOST'][$key] = $val;
1237 if ( HCU_array_key_exists(
"data_confirm", $txReturn[
"txn"] ) ) {
1239 $reply_arr[
'TXPOST'][
"CONFIRMID"] = $txReturn[
"txn"][
"data_confirm"];
1243 $txreturn = OdyTxPost( $dbh, $HB_ENV, $pass, $HB_ENV[
'MC'] );
1245 if ( HCU_array_item_count(
'errors',$txreturn[
'status']) > 0 ) {
1246 throw new Exception(implode(
' ',$txreturn[
'status'][
'errors']),15580); # TX_post returns data validation errors
1250 $reply_arr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO'),
1251 'DTSERVER' => date(
'YmdHis'),
1252 'MEMBER' => $HB_ENV[
'Uid'],
1253 'USERKEY' => $apptoken );
1255 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1256 'DTSERVER' => date(
'YmdHis'),
1257 'MEMBER' => $HB_ENV[
'Uid'],
1258 'USERKEY' => $apptoken );
1260 foreach ($txreturn[
'txn'] as $key => $value) {
1261 $key = strtoupper($key);
1262 $val = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1263 $reply_arr[
'TXPOST'][$key] = $val;
1266 if ( HCU_array_key_exists(
"data_confirm", $txreturn[
"txn"] ) ) {
1268 $reply_arr[
'TXPOST'][
"CONFIRMID"] = $txreturn[
"txn"][
"data_confirm"];
1274 case "MEMBERSETTINGS":
1285 parse_str($PASSWITH, $pass);
1287 if (HCU_array_key_value(
'GETALLOWED',$pass) ==
'1') {
1288 $reply_arr = Return_AllowedUpdate($inPost[
'ORG'], $HB_ENV[
'Cn'], $HB_ENV[
'Uid'], $HB_ENV);
1290 $HB_ENV[
'requpdate'] = ($pass[
'GETSETTINGS'] & $HB_ENV[
'allowupdate']); #limit acceptable values based on cu config
1291 if ($HB_ENV[
'requpdate'] == 0) {
1292 throw new Exception(
'Invalid Settings Request',3125); # unrecognized GETSETTINGS request or not configured
1294 $reply_arr = Return_ReqUpdate($inPost[
'ORG'], $HB_ENV[
'Cn'], $HB_ENV[
'Uid'], $HB_ENV, array());
1300 parse_str($PASSWITH, $pass);
1301 $upd_fields[
'settings_alias'][
'username'] = $pass[
'UALIAS'];
1302 $upd_fields[
'settings_alias'][
'username_confirm'] = $pass[
'UALIAS'];
1303 $upd_fields[
'settings_alias'][
'username_required'] = ($HB_ENV[
'alias'] ==
'REQUIRE' ?
'Y' :
'N');
1304 $aryUpdate = Validate_Settings($dbh, $HB_ENV, $upd_fields, $MC);
1306 if ($aryUpdate[
'status'][
'code'] ==
'000') {
1307 $reply_arr = Return_ResponseOK($inPost[
'ORG'], $HB_ENV[
'Cn'], $HB_ENV[
'Uid'], 0,
"OK Selected Alias is valid and available"); # Selected Alias is valid and available
1309 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']), 3162); # Selected Alias is not valid or usable
1314 #$PASSWITH contains name=value pairs for each credential to be updated 1315 # this could just parse PASSWITH into HB_ENV['HCUPOST'], but I want to only take the parts I expect - 1317 parse_str($PASSWITH, $pass);
1320 if (HCU_array_key_value(
'ASKLATER',$pass) == 1) {
1321 if ($HB_ENV[
'forceupdate'] > 0 && $HB_ENV[
'Ffremain'] == 0) {
1322 throw new Exception(
'Requested Updates cannot be deferred',3150); # got
'ask later' response w/0 grace logins remaining
1324 $sendkeys = array(
'USERKEY' => $apptoken,
1325 'MFAKEY' => MakeMFAKey( $HB_ENV ),
1326 'TIMEOUT' => $HB_ENV[
'AppTimeout'],
1327 'menu' =>
'REPLACE MENU HERE'); # after update settings
1328 $reply_arr = Return_ResponseOK($inPost[
'ORG'], $HB_ENV[
'Cn'], $HB_ENV[
'Uid'], $sendkeys,
"OK Updates Deferred");
1332 # start out thinking we won't need a transaction 1333 $bolSQLTransaction =
false;
1334 $upd_fields=array();
1336 if (($HB_ENV[
'allowupdate'] & 4) == 4) {
1337 # if challenge stuff allowed and provided, set fields to update, 1339 if (!empty($pass[
'CONFWORD'])) {
1340 $upd_fields[
'settings_confidence'][
'confword'] = $pass[
'CONFWORD'];
1345 while (array_key_exists(
"CQID_{$quest_idx}", $pass)) {
1346 $upd_fields[
'settings_questions'][] = Array(
'cqid' => $pass[
"CQID_{$quest_idx}"],
'display' => $pass[
"CQANS_{$quest_idx}"]);
1349 if (HCU_array_key_exists(
'userflags',$HB_ENV) && HCU_array_key_exists(
'settings_questions',$upd_fields) && ($HB_ENV[
'forceupdate'] & 4) == 4 ) {
1352 $tmpVal = (int) HCU_array_key_value(
'userflags', $HB_ENV);
1354 $tmpVal = ~(~$tmpVal | GetUserFlagsValue(
'MEM_FORCE_RESET'));
1356 $upd_fields[
'settings_confidence'][
'userflags'] = $tmpVal;
1363 if (trim(HCU_array_key_value(
'NEWPWD',$pass)) >
'') {
1364 $upd_fields[
'settings_password'][
'newpasswd'] = $pass[
'NEWPWD'];
1365 $upd_fields[
'settings_password'][
'confpasswd'] = $pass[
'NEWPWD'];
1371 if (!empty(HCU_array_key_value(
'EMAIL',$pass))) {
1372 $upd_fields[
'settings_email'][
'email'] = $pass[
'EMAIL'];
1373 $upd_fields[
'settings_email'][
'egenl'] = $pass[
'OPTIN'];
1374 $upd_fields[
'settings_email'][
'verify'] = ($HB_ENV[
'Fverifyml'] == 512 ?
'Y' :
'N');
1375 $upd_fields[
'settings_email'][
'valid'] =
'Y';
1380 if (($HB_ENV[
'allowupdate'] & 8) == 8 && (HCU_array_key_value(
'UALIAS',$pass)) !=
'') {
1381 $upd_fields[
'settings_alias'][
'username'] = $pass[
'UALIAS'];
1382 $upd_fields[
'settings_alias'][
'username_confirm'] = $pass[
'UALIAS'];
1383 $upd_fields[
'settings_alias'][
'username_required'] = ($HB_ENV[
'alias'] ==
'REQUIRE' ?
'Y' :
'N');
1384 $bolSQLTransaction =
true;
1386 if (($HB_ENV[
'allowupdate'] & 16) == 16) {
1387 # if contact phones allowed and provided, set fields to update, 1389 if (!empty($pass[
'CONFWORD'])) {
1390 $upd_fields[
'settings_confidence'][
'confword'] = $pass[
'CONFWORD'];
1395 if (HCU_array_key_exists(
'PHONE',$pass)) {
1396 $phones = explode(
'|',HCU_array_key_value(
'PHONE',$pass));
1397 # empty array will save empty list (delete pre-existing) 1398 $upd_fields[
'settings_phones'][
'mobile']=array();
1400 # insert punctuation 1402 foreach($phones as $phnum) {
1403 if (!empty($phnum) && $phidx <= MAX_PHONES) {
1404 $upd_fields[
'settings_phones'][
'mobile'][] = format_us_number($phnum);
1408 if (HCU_array_key_exists(
'userflags',$HB_ENV) && ($HB_ENV[
'forceupdate'] & 16) == 16 ) {
1410 $tmpVal = (int) HCU_array_key_value(
'userflags', $HB_ENV);
1412 $tmpVal = ~(~$tmpVal | GetUserFlagsValue(
'MEM_FORCE_RESET'));
1413 $upd_fields[
'settings_confidence'][
'userflags'] = $tmpVal;
1419 if (trim(HCU_array_key_value(
'NEWPWD',$pass)) >
'') {
1420 $aryUpdate = Validate_PwdRules($dbh, $HB_ENV, $upd_fields, $MC);
1422 if ($aryUpdate[
'status'][
'code'] !=
'000') {
1424 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']),3160); # Validate_Settings
1427 if (!count($upd_fields)) {
1428 throw new Exception(
'Nothing found to update',3165); # UPDCRED found nothing to update
1431 $aryUpdate = Validate_Settings($dbh, $HB_ENV, $upd_fields, $MC);
1433 if ($aryUpdate[
'status'][
'code'] !=
'000') {
1435 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']),3160); # Validate_Settings
1436 #print_r($HB_ENV); print_r($upd_fields); exit; 1438 if (isset($upd_fields[
'settings_phones'][
'mobile']) && ($HB_ENV[
'flagset3'] & GetFlagsetValue(
'CU3_MFA_AUTHCODE')) ) {
1442 $aryUpdate = Update_User_Security($dbh, $HB_ENV, $HB_ENV[
'MC'], $upd_fields);
1443 if ($aryUpdate[
'status'][
'code'] !=
'000') {
1444 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']),3172); # Update_User_Security
1448 $aryUpdate = Update_User_Settings($dbh, $HB_ENV, $MC, $upd_fields, $bolSQLTransaction);
1450 if ($aryUpdate[
'status'][
'code'] !=
'000') {
1452 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']),3170); # Update_Settings
1456 $MEMBER = (HCU_array_key_value(
'UALIAS',$pass) ? HCU_array_key_value(
'UALIAS',$pass) : $MEMBER);
1457 Load_HB_ENV($dbh, $CU, $MEMBER, $HB_ENV, $CFGFLAG=0);
1458 $userrec = GetUserbyName($dbh, $inPost[
'ORG'], $MEMBER);
1460 $HB_ENV[
'Ce'] = time() + $HB_ENV[
'SYSENV'][
'ticket'][
'expires'];
1461 $HB_ENV[
'Clu'] = (empty($userrec[
'lastupdate']) ? $MC->msg(
"Unknown") : urlencode(trim($userrec[
'lastupdate'])));
1462 $HB_ENV[
'Fhdays'] = $userrec[
'fhdays'];
1465 $gSavedUserkey = BuildBaseSessionTicket( $HB_ENV );
1468 $apptoken = MakeSessionUserkey( $HB_ENV );
1469 $sendkeys = array(
'USERKEY' => $apptoken,
1470 'MFAKEY' => MakeMFAKey( $HB_ENV ),
1471 'TIMEOUT' => $HB_ENV[
'AppTimeout'],
1472 'menu' =>
'REPLACE MENU HERE'); # after update settings
1473 $reply_arr = Return_ResponseOK($inPost[
'ORG'], $HB_ENV[
'Cn'], $HB_ENV[
'Uid'], $sendkeys,
"OK Updates Successful");
1481 # before we get started, check permissions 1482 $accessRights = Perm_AccessRights( $dbh, $HB_ENV, array(
"feature" => FEATURE_MOBILE_BILLPAY ) );
1483 if ( ! HCU_array_key_value(
'access', $accessRights)) {
1484 throw new Exception( $HB_ENV[
'MC']->msg(
'Rights not set', HCU_DISPLAY_AS_HTML), 915 );
1488 $parms[
'Cu'] = $HB_ENV[
'Cu'];
1489 $parms[
'Cn'] = $HB_ENV[
'Cn'];
1490 $parms[
'Uid'] = $HB_ENV[
'Uid'];
1493 parse_str($PASSWITH, $pass);
1494 if (!isset($pass[
'MP_VENDOR']) || !isset($pass[
'MBRACCT'])) {
1495 throw new Exception(
"Missing Mobile Pay parameters",4001);
1497 switch ($pass[
'MP_VENDOR']) {
1502 if (hcu_checkService($dbh,
'IPAY') !==
true) {
1503 $omsg = hcu_checkServiceMsg($dbh,
"IPAY");
1504 throw new Exception(
"$omsg",999); # MOBLPAY AUTH
1506 if ($pass[
'MP_VENDOR'] ==
'IPAYBPS') {
1507 require_once(dirname(__FILE__) .
'/../library/bpCommon.i'); # HCU functions common to all BILL Pay vendors
1508 require_once(dirname(__FILE__) .
'/../library/IPAYBPS.i');
1510 require_once(dirname(__FILE__) .
'/../library/IPAYMBL.i');
1514 if (hcu_checkService($dbh,
'CHKFREE') !==
true) {
1515 $omsg = hcu_checkServiceMsg($dbh,
"CHKFREE");
1516 throw new Exception(
"$omsg",999); # MOBLPAY AUTH
1518 require_once(dirname(__FILE__) .
'/../library/CHKFREE.i');
1521 if (hcu_checkService($dbh,
'PSCU') !==
true) {
1522 $omsg = hcu_checkServiceMsg($dbh,
"PSCU");
1523 throw new Exception(
"$omsg",999); # MOBLPAY AUTH
1525 require_once(dirname(__FILE__) .
'/../library/PSCUPAY_API.i');
1529 require_once(dirname(__FILE__) .
'/../library/MBLPAY_TEST.i');
1532 throw new Exception(
"Invalid Mobile Pay vendor",4001);
1535 $parray[
'Cu'] = $Cu;
1536 $parray[
'trustedid'] = $pass[
'MP_VENDOR'];
1537 $trusted = cutd_read($dbh, $parray);
1538 if ($trusted[
'status'][
'Response'] ==
'false') {
1540 throw new Exception(
"Bill Pay Service not configured",2076); # no trusted vendor rec
1542 $parms = $trusted[
'data'][
"$Cu|{$pass['MP_VENDOR']}"];
1544 # set up logging here 1545 $loggingFlag = trim($parms[
"hcuLogging"]);
1546 if (strlen($loggingFlag) > 0) {
1548 $enable = $loggingFlag == -1;
1551 $loggingFlag = str_replace(
" ",
"", $loggingFlag);
1552 $testArray = explode(
",", $loggingFlag);
1553 $enable = in_array($HB_ENV[
"Cn"], $testArray);
1558 $parms[
"logging"] =
"enabled";
1559 $parms[
"environment"] = array(
"Cu" => $HB_ENV[
"Cu"],
1560 "memberId" => $HB_ENV[
"Cn"],
1561 "SSOVendor" => $pass[
'MP_VENDOR'],
1562 "userIP" => $_SERVER[
'REMOTE_ADDR'],
1567 $billpay = Get_Billpayid($dbh, $HB_ENV, $pass[
'MP_VENDOR'], $pass[
'MBRACCT']);
1568 $parms[
'BillpayId'] = trim($billpay[
'billpayid']);
1569 $parms[
'passwith'] = $pass;
1570 switch ($pass[
'MP_ACTION']) {
1572 $mblpay = bpAuth($parms);
1573 # deal with response 1575 if ($mblpay[
'status'][
'code'] ==
'000' && strlen($mblpay[
"data"][
'Token']) > 0) {
1576 # good token, return the response 1577 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1578 'DTSERVER' => date(
'YmdHis'),
1579 'MEMBER' => $HB_ENV[
'Uid'],
1580 'MBRACCT' => $pass[
'MBRACCT'],
1581 'USERKEY' => $apptoken );
1583 if (is_array($mblpay[
'data'])) {
1584 $reply_arr[
'MP_AUTH'] = array();
1585 foreach ($mblpay[
'data'] as $key => $value) {
1588 $reply_arr[
'MP_AUTH'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1595 $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC,
"M",
"mblNoMobilePay",
true);
1597 if ($noticesAry[
"status"][
"code"] ==
"000" && $noticesAry[
"notice"][0][
"notice_id"]) {
1598 $noticeString = $noticesAry[
"notice"][0][
"notice_text"];
1600 $noticeString = $mblpay[
'status'][
'message'];
1603 throw new Exception($noticeString,$mblpay[
'status'][
'code']); # MOBLPAY AUTH
get token failed
1608 $mblpay = bpGetTerms($parms);
1609 # deal with response 1610 if ($mblpay[
'status'][
'response'] ==
'false') {
1611 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY AUTH
1614 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1615 'DTSERVER' => date(
'YmdHis'),
1616 'MEMBER' => $HB_ENV[
'Uid'],
1617 'USERKEY' => $apptoken,
1618 'TOKEN' => $pass[
'Token'] );
1620 if (is_array($mblpay[
'data'])) {
1621 $reply_arr[
'MP_TERMS'] = array();
1622 foreach ($mblpay[
'data'] as $key => $value) {
1625 $reply_arr[
'MP_TERMS'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1631 $mblpay = bpAcceptTerms($parms);
1632 # deal with response 1633 if ($mblpay[
'status'][
'response'] ==
'false') {
1634 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY AUTH
1638 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1639 'DTSERVER' => date(
'YmdHis'),
1640 'MEMBER' => $HB_ENV[
'Uid'],
1641 'USERKEY' => $apptoken,
1642 'TOKEN' => $pass[
'Token'] );
1644 if (is_array($mblpay[
'data'])) {
1645 $reply_arr[
'MP_ACCEPT'] = array();
1646 foreach ($mblpay[
'data'] as $key => $value) {
1649 $reply_arr[
'MP_ACCEPT'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1655 # set Account type for from 1656 # AcctType = Payment | Transfer 1657 # Detailed = 'True' | 'False' (may be missing, false) 1658 $mblfrom = bpSourceAccts($parms);
1659 # determine payment or transfer, set Account type accordingly 1660 $mblpay = bpDestAccts($parms);
1662 # deal with response 1663 if ($mblfrom[
'status'][
'response'] ==
'false') {
1664 throw new Exception($mblfrom[
'status'][
'message'], $mblfrom[
'status'][
'code']); # MOBLPAY SourceAccts
1666 if ($mblpay[
'status'][
'response'] ==
'false') {
1667 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY DestAccts
1669 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1670 'DTSERVER' => date(
'YmdHis'),
1671 'MEMBER' => $HB_ENV[
'Uid'],
1672 'USERKEY' => $apptoken,
1673 'TOKEN' => $pass[
'Token'] );
1675 if (is_array($mblfrom[
'data']) || is_array($mblpay[
'data'])) {
1676 $reply_arr[
'MP_ACCTLIST'] = array();
1678 if (is_array($mblfrom[
'data'])) {
1679 $reply_arr[
'MP_ACCTLIST'][
'SOURCEACCTS'] = array();
1680 foreach ($mblfrom[
'data'] as $akey => $account) {
1682 foreach ($account as $key => $value) {
1683 if ($key ==
'AdditionalInfo') {
1684 $acctdet[
'AdditionalInfo'] = htmlentities(http_build_query($value));
1685 } elseif ($key ==
'Name') {
1686 $acctdet[
'Name'] = htmlentities($value);
1690 $acctdet[$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1693 $reply_arr[
'MP_ACCTLIST'][
'SOURCEACCTS'][][
'Account'] = $acctdet;
1696 if (is_array($mblpay[
'data'])) {
1697 $reply_arr[
'MP_ACCTLIST'][
'DESTACCTS'] = array();
1698 foreach ($mblpay[
'data'] as $akey => $account) {
1700 foreach ($account as $key => $value) {
1701 if ($key ==
'AdditionalInfo') {
1702 $acctdet[
'AdditionalInfo'] = htmlentities(http_build_query($value));
1703 } elseif ($key ==
'Name') {
1704 $acctdet[
'Name'] = htmlentities($value);
1708 $acctdet[$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1711 $reply_arr[
'MP_ACCTLIST'][
'DESTACCTS'][][
'Account'] = $acctdet;
1717 case "MP_GETPAYMENTDATES":
1718 $mblpay = bpGetPaymentDates($parms);
1720 # deal with response 1721 if ($mblpay[
'status'][
'response'] ==
'false') {
1722 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY DATES
1725 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1726 'DTSERVER' => date(
'YmdHis'),
1727 'MEMBER' => $HB_ENV[
'Uid'],
1728 'USERKEY' => $apptoken,
1729 'TOKEN' => $pass[
'Token'] );
1731 if (is_array($mblpay[
'data'])) {
1732 $reply_arr[
'MP_GETPAYMENTDATES'] = array();
1733 foreach ($mblpay[
'data'] as $pkey => $paydate) {
1736 if (is_array($paydate)) {
1738 foreach ($paydate as $dateitem) {
1739 if (is_array($dateitem)) {
1740 $det_arr[
'Option'] = array();
1741 foreach ($dateitem as $key => $value) {
1743 $det_arr[
'Option'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1747 $reply_arr[
'MP_GETPAYMENTDATES'][][
'RushOptions'] = $det_arr;
1750 case 'PaymentDates':
1751 if (is_array($paydate)) {
1753 foreach ($paydate as $dateitem) {
1754 if (is_array($dateitem)) {
1755 $det_arr[
'Date'] = array();
1756 foreach ($dateitem as $key => $value) {
1758 $det_arr[
'Date'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1761 $reply_arr[
'MP_GETPAYMENTDATES'][][
'PaymentDates'] = $det_arr;
1766 $reply_arr[
'MP_GETPAYMENTDATES'][$pkey] = $paydate;
1774 $mblpay = bpHist($parms);
1776 # deal with response 1777 if ($mblpay[
'status'][
'response'] ==
'false') {
1778 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1780 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1781 'DTSERVER' => date(
'YmdHis'),
1782 'MEMBER' => $HB_ENV[
'Uid'],
1783 'USERKEY' => $apptoken,
1784 'TOKEN' => $pass[
'Token'] );
1786 if (is_array($mblpay[
'data'])) {
1787 $reply_arr[
'MP_HISTORY'] = array();
1788 foreach ($mblpay[
'data'] as $pkey => $payment) {
1790 foreach ($payment as $key => $value) {
1791 if ($key ==
'AdditionalInfo') {
1792 $det_arr[$key] = htmlentities(http_build_query($value));
1794 $det_arr[$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1797 $reply_arr[
'MP_HISTORY'][][
'Payment'] = $det_arr;
1802 case "MP_GETRUSHOPTIONS":
1803 $mblpay = bpGetRushOptions($parms);
1805 # deal with response 1806 if ($mblpay[
'status'][
'response'] ==
'false') {
1807 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1809 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1810 'DTSERVER' => date(
'YmdHis'),
1811 'MEMBER' => $HB_ENV[
'Uid'],
1812 'USERKEY' => $apptoken,
1813 'TOKEN' => $pass[
'Token'] );
1815 if (is_array($mblpay[
'data'])) {
1816 $reply_arr[
'MP_GETRUSHOPTIONS'] = array();
1817 foreach ($mblpay[
'data'] as $key => $value) {
1818 $reply_arr[
'MP_GETRUSHOPTIONS'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1824 case "MP_SCHEDULED":
1825 $mblpay = bpSched($parms);
1827 # deal with response 1828 if ($mblpay[
'status'][
'response'] ==
'false') {
1829 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1831 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1832 'DTSERVER' => date(
'YmdHis'),
1833 'MEMBER' => $HB_ENV[
'Uid'],
1834 'USERKEY' => $apptoken,
1835 'TOKEN' => $pass[
'Token'] );
1837 if (is_array($mblpay[
'data'])) {
1838 $reply_arr[
'MP_SCHEDULED'] = array();
1839 foreach ($mblpay[
'data'] as $pkey => $payment) {
1841 foreach ($payment as $key => $value) {
1842 if ($key ==
'AdditionalInfo') {
1843 $det_arr[$key] = htmlentities(http_build_query($value));
1845 $det_arr[$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1848 $reply_arr[
'MP_SCHEDULED'][][
'Payment'] = $det_arr;
1855 $mblpay = bpPmtAdd($parms);
1857 # deal with response 1858 if ($mblpay[
'status'][
'response'] ==
'false') {
1859 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1861 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1862 'DTSERVER' => date(
'YmdHis'),
1863 'MEMBER' => $HB_ENV[
'Uid'],
1864 'USERKEY' => $apptoken,
1865 'TOKEN' => $pass[
'Token'] );
1867 if (is_array($mblpay[
'data'])) {
1868 $reply_arr[
'MP_PAYMENT'] = array();
1869 foreach ($mblpay[
'data'] as $key => $value) {
1870 $reply_arr[
'MP_PAYMENT'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1877 $mblpay = bpTrnAdd($parms);
1879 # deal with response 1880 if ($mblpay[
'status'][
'response'] ==
'false') {
1881 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1883 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1884 'DTSERVER' => date(
'YmdHis'),
1885 'MEMBER' => $HB_ENV[
'Uid'],
1886 'USERKEY' => $apptoken,
1887 'TOKEN' => $pass[
'Token'] );
1889 if (is_array($mblpay[
'data'])) {
1890 $reply_arr[
'MP_TRANSFER'] = array();
1891 foreach ($mblpay[
'data'] as $key => $value) {
1892 $reply_arr[
'MP_TRANSFER'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1899 $mblpay = bpPmtEdit($parms);
1901 # deal with response 1902 if ($mblpay[
'status'][
'response'] ==
'false') {
1903 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1905 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1906 'DTSERVER' => date(
'YmdHis'),
1907 'MEMBER' => $HB_ENV[
'Uid'],
1908 'USERKEY' => $apptoken,
1909 'TOKEN' => $pass[
'Token'] );
1911 if (is_array($mblpay[
'data'])) {
1912 $reply_arr[
'MP_EDITPMT'] = array();
1913 foreach ($mblpay[
'data'] as $key => $value) {
1914 $reply_arr[
'MP_EDITPMT'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1921 $mblpay = bpPmtStop($parms);
1923 # deal with response 1924 if ($mblpay[
'status'][
'response'] ==
'false') {
1925 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1927 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1928 'DTSERVER' => date(
'YmdHis'),
1929 'MEMBER' => $HB_ENV[
'Uid'],
1930 'USERKEY' => $apptoken,
1931 'TOKEN' => $pass[
'Token'] );
1933 if (is_array($mblpay[
'data'])) {
1934 $reply_arr[
'MP_STOPPMT'] = array();
1935 foreach ($mblpay[
'data'] as $key => $value) {
1936 $reply_arr[
'MP_STOPPMT'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1944 throw new Exception(
"Unknown MOBLPAY Mode",15550);
1949 # before we get started, check permissions 1950 $accessRights = Perm_AccessRights( $dbh, $HB_ENV, array(
"feature" => FEATURE_SECURE_MSG ) );
1951 if ( ! HCU_array_key_value(
'access', $accessRights)) {
1952 throw new Exception( $HB_ENV[
'MC']->msg(
'Rights not set', HCU_DISPLAY_AS_HTML), 915 );
1957 parse_str($PASSWITH, $pass);
1958 if (!isset($pass[
'MSG_SERVICE'])) {
1959 throw new Exception(
"Missing Message parameters",4001);
1961 $HB_ENV[
'HCUPOST'] = $pass;
1962 if (HCU_array_key_exists(
'filter',$pass)) {
1963 $HB_ENV[
'HCUPOST'][
'what'] = HCU_array_key_value(
'filter',$pass);
1965 if (HCU_array_key_exists(
'thread_id',$pass)) {
1966 $HB_ENV[
'HCUPOST'][
'parentid'] = HCU_array_key_value(
'thread_id',$pass);
1969 switch ($pass[
'MSG_SERVICE']) {
1971 # this file has not been converted to Odyssey 1972 # responses recoded to send response from arrays in 1973 # new standard format, BUT NOT TESTED YET 1974 # moving on to login issues instead 1975 require_once(dirname(__FILE__) .
'/../library/msgECO.i');
1978 throw new Exception(
"Invalid Message Service",4001);
1981 switch ($pass[
'MSG_ACTION']) {
1983 $msgResp = msgReadMessages($dbh, $HB_ENV);
1985 # deal with response 1986 if ($msgResp[
'code'] !==
'000') {
1987 throw new Exception($msgResp[
'homecuErrors'], $msgResp[
'code']); # MESSAGE READ_MSGS
1992 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
1993 'DTSERVER' => date(
'YmdHis'),
1994 'MEMBER' => $HB_ENV[
'Uid'],
1995 'USERKEY' => $apptoken );
1996 if (is_array($msgResp[
'homecuData'])) {
1997 $reply_arr[
'READ_MSGS'] = array();
1998 foreach ($msgResp[
'homecuData'] as $key => $value) {
1999 if (is_array($value)) {
2001 foreach ($value as $mkey => $mvalue) {
2004 $mvalue = htmlentities($mvalue, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2007 $msg_arr[$mkey] = $mvalue;
2009 $reply_arr[
'READ_MSGS'][][
'MSG'] = $msg_arr;
2011 $reply_arr[
'READ_MSGS'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2019 $msgResp = msgReadMessageThread($dbh, $HB_ENV);
2021 # deal with response 2022 if ($msgResp[
'code'] !==
'000') {
2023 throw new Exception($msgResp[
'homecuErrors'], $msgResp[
'code']); # MESSAGE READ_THREAD
2025 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
2026 'DTSERVER' => date(
'YmdHis'),
2027 'MEMBER' => $HB_ENV[
'Uid'],
2028 'USERKEY' => $apptoken );
2030 if (is_array($msgResp[
'homecuData'])) {
2031 $reply_arr[
'READ_THREAD'] = array();
2032 foreach ($msgResp[
'homecuData'] as $key => $value) {
2033 if (is_array($value)) {
2035 foreach ($value as $mkey => $mvalue) {
2039 $mvalue = htmlentities($mvalue, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2042 $msg_arr[$mkey] = $mvalue;
2044 $reply_arr[
'READ_THREAD'][][
'MSG'] = $msg_arr;
2046 $reply_arr[
'READ_THREAD'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2054 $msgResp = msgSendMessage($dbh, $HB_ENV, $MC);
2056 # deal with response 2057 if ($msgResp[
'code'] !==
'000') {
2058 throw new Exception($msgResp[
'homecuErrors'], $msgResp[
'code']); # MESSAGE SEND_MSG
2060 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
2061 'DTSERVER' => date(
'YmdHis'),
2062 'MEMBER' => $HB_ENV[
'Uid'],
2063 'USERKEY' => $apptoken );
2064 # 11/14/17 msgSendMessage return calls msgReadMessages, returning a list of messages 2065 # (and effectively hiding any read failure as a send failure.) For now, if we got 2066 # a successful result, assume the send succeeded and ignore the message list 2067 # returning 'success', as Mammoth did, so apps don't have to change arbitrarily 2068 $reply_arr[
'SEND_MSG'] =
'success';
2073 $msgResp = msgDeleteMessageThread($dbh, $HB_ENV);
2075 # deal with response 2076 if ($msgResp[
'code'] !==
'000') {
2077 throw new Exception($msgResp[
'homecuErrors'], $msgResp[
'code']); # MESSAGE DEL_THREAD
2079 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
2080 'DTSERVER' => date(
'YmdHis'),
2081 'MEMBER' => $HB_ENV[
'Uid'],
2082 'USERKEY' => $apptoken );
2083 # 11/14/17 msgDeleteMessageThread return calls msgReadMessages, returning a list of messages 2084 # (and effectively hiding any read failure as a delete failure.) For now, if we got 2085 # a successful result, assume the delete succeeded and ignore the message list 2086 # returning 'success', as Mammoth did, so apps don't have to change arbitrarily 2087 $reply_arr[
'DEL_MSG'] =
'success';
2092 $msgResp = msgCheckForMessages($dbh, $HB_ENV);
2094 # deal with response 2095 if ($msgResp[
'code'] !==
'000') {
2096 throw new Exception($msgResp[
'homecuErrors'], $msgResp[
'code']); # MESSAGE READ_MSGS
2098 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
2099 'DTSERVER' => date(
'YmdHis'),
2100 'MEMBER' => $HB_ENV[
'Uid'],
2101 'USERKEY' => $apptoken );
2103 if (is_array($msgResp[
'homecuData'])) {
2104 $reply_arr[
'CHECK_MSG'] = array();
2105 foreach ($msgResp[
'homecuData'] as $key => $value) {
2106 $reply_arr[
'CHECK_MSG'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2113 # unknown MSG_ACTION 2114 throw new Exception(
"Unknown MESSAGE Mode",15550);
2120 # check permissions in plugin function 2121 require_once(dirname(__FILE__) .
'/../library/rdcCommon.i'); # HCU functions common to all RDC vendors
2129 parse_str(urldecode($PASSWITH), $pass);
2130 if ( !isset($pass[
'MBRACCT'] )) {
2131 throw new Exception(
"Missing RDC parameters",4001);
2136 $result = HandleRDCRequest( $HB_ENV, $pass );
2137 if ( isset( $result[
"STATUS"][
"CODE"] ) && ( $result[
"STATUS"][
"CODE"] != 0 ) ) {
2138 throw new Exception($result[
"STATUS"][
"MESSAGE"], $result[
"STATUS"][
"CODE"]);
2142 $reply_arr = array(
'STATUS' => array(
'CODE' => 0),
2143 'DTSERVER' => date(
'YmdHis'),
2144 'MEMBER' => $HB_ENV[
'Uid'],
2145 'MBRACCT' => $pass[
'MBRACCT'],
2146 'USERKEY' => $apptoken,
2147 "RDC_RESPONSE" => $result[
"RDC_RESPONSE"] );
2149 if ( HCU_array_key_exists(
"DEPOSITID", $result) ) {
2150 $reply_arr[
"DEPOSITID"] = $result[
"DEPOSITID"];
2155 # before we get started, check permissions 2156 $accessRights = Perm_AccessRights( $dbh, $HB_ENV, array(
"feature" => FEATURE_ESTATEMENTS ) );
2157 if ( ! HCU_array_key_value(
'access', $accessRights)) {
2158 throw new Exception( $HB_ENV[
'MC']->msg(
'Rights not set', HCU_DISPLAY_AS_HTML), 915 );
2161 # PASSWITH ES_UPD=1 indicates app supports estmt_flag setting changes 2162 # response set includes terms & notices 2163 # PASSWITH ENROLL=START/STOP updates status, and returned response set 2164 # contains status & enrollment block only 2165 # PASSWITH MBRACCT=select member account 2168 parse_str($PASSWITH, $pass);
2169 # must indicate member account 2170 if ( empty($pass[
'MBRACCT']) ) {
2171 throw new Exception(
"Missing eStatement parameters",4050); # ESTMT
2174 if (isset($pass[
'ENROLL'])) {
2183 $HB_ENV[
'esProcessMode'] = $pass[
'ENROLL'];
2185 if ($pass[
"ENROLL"] ==
"STOP") {
2186 $HB_ENV[
'HCUPOST'][
'stop_reason'] = $pass[
'STOP_REASON'];
2190 # Post_CUEstmt expects un-encoded $Ml in HB_ENV array 2191 # app stores it encoded, so decode it before calling the function 2192 # and then put it back after so nothing else breaks 2194 $response = Post_CUEStmt($dbh, $HB_ENV, $MC, $pass[
'MBRACCT']);
2196 if (count($response[
'status'][
'errors']) > 0) {
2197 throw new Exception(implode(
' ',$response[
'status'][
'errors']),15592); # Post_CUEStmt
2199 if (intval($pass[
'NOTICE_ID']) > 0) {
2201 $HB_ENV[
"HCUPOST"][
"notice_type"] =
"C";
2202 $HB_ENV[
"HCUPOST"][
"notice_id"] = intval($pass[
'NOTICE_ID']);
2203 $HB_ENV[
"HCUPOST"][
"notice_device"] =
"P";
2204 $HB_ENV[
"HCUPOST"][
"notice_response"] = array(
"answer" => 1);
2205 $HB_ENV[
"HCUPOST"][
"notice_cancel"] =
"0";
2206 $HB_ENV[
"HCUPOST"][
"notice_accountnumber"] = $pass[
"MBRACCT"];
2208 $response = Update_NoticeInfo($dbh, $HB_ENV, $MC);
2214 $response = Get_Estmt($dbh, $HB_ENV, $MC, $pass[
'MBRACCT'], 1);
2218 $response = Get_Estmt($dbh, $HB_ENV, $MC, $pass[
'MBRACCT'] );
2220 # deal with response 2221 if (HCU_array_item_count(
'errors',$response[
'status']) > 0) {
2222 throw new Exception(implode(
' ',$response[
'status'][
'errors']),15590); # Get_Estmt
2224 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
2225 'DTSERVER' => date(
'YmdHis'),
2226 'MEMBER' => $HB_ENV[
'Uid'],
2227 'MBRACCT' => $pass[
'MBRACCT'],
2228 'USERKEY' => $apptoken );
2231 foreach ($response[
'estmt'] as $key => $value) {
2232 switch (strtolower($key)) {
2235 $key = strtoupper($key);
2236 $reply_arr[$key] = $value;
2239 $reply_arr[
'PDFLINKS'] = array();
2240 if (is_array($value)) {
2241 foreach ($value as $tag => $tval) {
2243 foreach ($tval as $tkey => $tkval) {
2244 $tkey = strtoupper($tkey);
2245 $det_arr[$tkey] = $tkval;
2247 $reply_arr[
'PDFLINKS'][][
'PDFLINK'] = $det_arr;
2252 $reply_arr[
'TOCLINKS'] = array();
2253 if (is_array($value)) {
2254 foreach ($value as $tag => $tval) {
2256 foreach ($tval as $tkey => $tkval) {
2257 $tkey = strtoupper($tkey);
2258 $det_arr[$tkey] = $tkval;
2260 $reply_arr[
'TOCLINKS'][][
'TOCLINK'] = $det_arr;
2266 # add appropriate messages - 2269 if (isset($pass[
'ES_UPD'])) {
2270 # set new ENROLLMENT block 2271 if ($enrolled ==
"W") {
2273 $termsMsg = $MC->msg(
'Statement Not Found') .
" " . $MC->msg(
'Statement Missing') .
" " . $MC->msg(
"Statements Stop");
2275 $termsName =
"esTermsStop";
2276 $termsTitle = $MC->msg(
"Stop e-Statements");
2277 }
else if ($enrolled ==
"Y") {
2278 $termsMsg = $MC->msg(
"Statements Stop");
2280 $termsName =
"esTermsStop";
2281 $termsTitle = $MC->msg(
"Stop e-Statements");
2283 $termsMsg = $MC->msg(
'Account not set for EStatements') .
". " . $MC->msg(
'Sign up fast');
2285 $termsName =
"esTermsStart";
2286 $termsTitle = $MC->msg(
"Start e-Statements");
2288 $reply_arr[
'ENROLLMENT'] = array(
2289 'ENROLLED' => $enrolled,
2290 'TERMS_TITLE' => $termsTitle,
2291 'TERMS_MSG' => $termsMsg,
2292 'TERMS_BTN' => $MC->msg(
'Click Here'));
2294 $response = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P', $termsName);
2296 if ($response[
'status'][
'code'] !=
"000" ||
2297 !count($response[
'notice']) ||
2298 count($response[
'status'][
'errors']) > 0 ||
2299 strlen($response[
'notice'][0][
'notice_text']) == 0) {
2300 $response[
'status'][
'errors'][] =
"Error retrieving Terms of Use";
2301 throw new Exception(implode(
' ',$response[
'status'][
'errors']),15593); # Get_NoticeInfo estatement terms
2303 if (count($response[
'notice'])) {
2304 foreach ($response[
'notice'] as $noticekey => $details) {
2305 $reply_arr[
'TERMS'] = array();
2309 if (!count($details[
'notice_answers']) &&
sizeof($details[
'notice_donotshowtext'])) {
2310 $details[
'notice_answers'][] = array(
'answer_id' => $details[
'notice_id'],
'answer_text' => $details[
'notice_donotshowtext']);
2311 $details[
'notice_answertype'] =
'M';
2313 foreach ($details as $key => $value) {
2314 $key = strtoupper($key);
2316 case "NOTICE_ANSWERS":
2317 $reply_arr[
'ENROLLMENT'][
'TERMS'][
'NOTICE_ANSWERS'] = array();
2318 foreach ($value as $anskey => $ansdetl) {
2319 $reply_arr[
'ENROLLMENT'][
'TERMS'][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
2320 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
2321 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
2328 case "NOTICE_INTRO":
2329 case "NOTICE_TITLE":
2330 case "NOTICE_DONOTSHOWTEXT":
2331 case "NOTICE_MSG_TX":
2332 case "NOTICE_MSG_TX_SHOW":
2333 case "NOTICE_MSG_TX_PERM":
2334 case "NOTICE_SUPPRESSRESPONSE":
2335 case "NOTICE_POSTTARGET":
2340 case "NOTICE_POPUP":
2341 case "NOTICE_ANSWERTYPE":
2342 case "NOTICE_LINKTARGET":
2343 case "NOTICE_LINKDISPLAY":
2346 $reply_arr[
'ENROLLMENT'][
'TERMS'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2351 $reply_arr[
'ENROLLMENT'][
'TERMS'] = array();
2355 switch ($response[
'estmt'][
'enrolled']) {
2357 $reply_arr[
'MESSAGES'][][
'MESSAGE'] = array(
'MSGHEAD' =>
'Discontinuing eStatement Service',
2358 'MSGBODY' =>
'Please log in through the full Home Banking site to discontinue eStatement service');
2361 $reply_arr[
'MESSAGES'][][
'MESSAGE'] = array(
'MSGHEAD' => $MC->msg(
'Statement Not Found'),
2362 'MSGBODY' => $MC->msg(
'Statement Missing'));
2366 $reply_arr[
'MESSAGES'][][
'MESSAGE'] = array(
'MSGHEAD' =>
'Enrollment Required',
2367 'MSGBODY' =>
'Please log in through the full Home Banking site to sign up for eStatement');
2372 # now get the estatement notice, if any 2373 $txnotice = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'esNotice', 0);
2375 if (count($txnotice[
'notice'])) {
2376 foreach ($txnotice[
'notice'] as $noticekey => $details) {
2380 if (!count($details[
'notice_answers']) &&
sizeof($details[
'notice_donotshowtext'])) {
2381 $details[
'notice_answers'][] = array(
'answer_id' => $details[
'notice_id'],
'answer_text' => $details[
'notice_donotshowtext']);
2382 $details[
'notice_answertype'] =
'M';
2385 foreach ($details as $key => $value) {
2386 $key = strtoupper($key);
2388 case "NOTICE_ANSWERS":
2389 $reply_arr[
'NOTICE'][
'NOTICE_ANSWERS'] = array();
2390 foreach ($value as $anskey => $ansdetl) {
2391 $reply_arr[
'NOTICE'][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
2392 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
2393 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
2401 case "NOTICE_INTRO":
2402 case "NOTICE_TITLE":
2403 case "NOTICE_DONOTSHOWTEXT":
2404 case "NOTICE_MSG_TX":
2405 case "NOTICE_MSG_TX_SHOW":
2406 case "NOTICE_MSG_TX_PERM":
2407 case "NOTICE_SUPPRESSRESPONSE":
2408 case "NOTICE_POSTTARGET":
2413 case "NOTICE_POPUP":
2414 case "NOTICE_ANSWERTYPE":
2415 case "NOTICE_LINKTARGET":
2416 case "NOTICE_LINKDISPLAY":
2419 $reply_arr[
'NOTICE'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2424 $reply_arr[
'NOTICE'] = array();
2432 parse_str($PASSWITH, $pass);
2433 #is cu configured for Alerts? 2434 if (!Check_AlertsEnabled($dbh, $HB_ENV)) {
2435 throw new Exception(
"Alert feature not configured",3180); # no
'Alert from' email
set in admin
2438 #list of alert types 2439 $ary_alerttypes = Get_AlertTypes($MC);
2440 #list of cell phone providers 2441 $ary_cellproviders = Get_AlertProviders($dbh);
2442 #cuusers.email and most-recently-used cell number for use as default values when defining a new alert 2443 $ary_dfltmail = Get_AlertDefaultEmail($dbh, $HB_ENV);
2444 $ary_dfltcell = Get_AlertDefaultCell($dbh, $HB_ENV);
2445 #list of members' accounts eligible for each alert type 2447 # FOR ODYSSEY GET LIST OF ACCOUNT NUMBERS, then Get_AlertAccountList for ea. account 2448 $ary_acctlist = array();
2449 $accts = Get_AlertAccountList( $dbh, $HB_ENV );
2450 for ($i = 0; $i < count($accts[
'data']); $i++) {
2451 $ary_acctlist[
'data'][] = $accts[
'data'][$i];
2454 #list of currently-defined alerts, if any 2455 $ary_alertdetails = Get_AlertsDetailed($dbh, $HB_ENV[
'Cu'],$HB_ENV[
'Uid'], $HB_ENV[
'Fset3']);
2456 #alerts terms of use document, if any, and a link to display terms of use on demand 2457 $ary_alertterms = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'alertTerms');
2459 #a status indicating whether or not the member must accept terms before continuing 2460 #any other alerts messages or notices the member should see 2461 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO'),
2462 'DTSERVER' => date(
'YmdHis'),
2463 'MEMBER' => $HB_ENV[
'Uid'],
2464 'USERKEY' => $apptoken,
2465 'ALERTSMRY' => array());
2467 $reply_arr[
'ALERTSMRY'][
'ALERTTYPES'] = array();
2468 foreach ($ary_alerttypes[
'data'] as $alertarr) {
2470 foreach ($alertarr as $key => $value) {
2471 $key = strtoupper($key);
2472 $det_arr[$key] = htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2474 $reply_arr[
'ALERTSMRY'][
'ALERTTYPES'][][
'ALERTTYPE'] = $det_arr;
2477 $reply_arr[
'ALERTSMRY'][
'CELLPROVIDERS'] = array();
2478 foreach ($ary_cellproviders[
'data'] as $cellprovider) {
2480 foreach ($cellprovider as $key => $value) {
2481 $key = strtoupper($key);
2482 $det_arr[$key] = htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2484 $reply_arr[
'ALERTSMRY'][
'CELLPROVIDERS'][][
'CELLPROVIDER'] = $det_arr;
2486 $reply_arr[
'ALERTSMRY'][
'EMAILDFLT'] = htmlspecialchars($ary_dfltmail[
'data'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2487 foreach ($ary_dfltcell[
'data'] as $key => $value) {
2488 $key = strtoupper($key);
2489 $reply_arr[
'ALERTSMRY'][
'CELLDFLT'][$key] = htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2492 $reply_arr[
'ALERTSMRY'][
'ACCOUNTS'] = array();
2493 for ( $i = 0; $i < HCU_array_item_count(
"data", $ary_acctlist); $i++ ) {
2494 $acctarr = $ary_acctlist[
"data"][$i];
2497 foreach ($acctarr as $key => $value) {
2498 $key = strtoupper($key);
2499 $det_arr[$key] = htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2501 $reply_arr[
'ALERTSMRY'][
'ACCOUNTS'][][
'ACCOUNT'] = $det_arr;
2504 $reply_arr[
'ALERTSMRY'][
'ALERTS'] = array();
2505 foreach ($ary_alertdetails[
'data'] as $detlarr) {
2507 foreach ($detlarr as $key => $value) {
2508 $key = strtoupper($key);
2509 $det_arr[$key] = htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2511 $reply_arr[
'ALERTSMRY'][
'ALERTS'][][
'ALERT'] = $det_arr;
2513 $reply_arr[
'ALERTSMRY'][
'TERMS'] = array();
2514 if (count($ary_alertterms[
'notice'])) {
2515 foreach ($ary_alertterms[
'notice'] as $noticekey => $details) {
2516 foreach ($details as $key => $value) {
2517 $key = strtoupper($key);
2519 case "NOTICE_ANSWERS":
2521 $reply_arr[
'ALERTSMRY'][
'TERMS'][
'NOTICE_ANSWERS'] = array();
2522 foreach ($value as $anskey => $ansdetl) {
2523 $reply_arr[
'ALERTSMRY'][
'TERMS'][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
2524 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
2525 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
2531 case "NOTICE_INTRO":
2532 case "NOTICE_TITLE":
2533 case "NOTICE_DONOTSHOWTEXT":
2534 case "NOTICE_MSG_TX":
2535 case "NOTICE_MSG_TX_SHOW":
2536 case "NOTICE_MSG_TX_PERM":
2537 case "NOTICE_SUPPRESSRESPONSE":
2538 case "NOTICE_POSTTARGET":
2543 case "NOTICE_POPUP":
2544 case "NOTICE_ANSWERTYPE":
2545 case "NOTICE_LINKTARGET":
2546 case "NOTICE_LINKDISPLAY":
2549 $reply_arr[
'ALERTSMRY'][
'TERMS'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2558 $ary_alertnotice = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'alertNotice');
2560 if (count($ary_alertnotice[
'notice'])) {
2561 foreach ($ary_alertnotice[
'notice'] as $noticekey => $details) {
2562 foreach ($details as $key => $value) {
2563 $key = strtoupper($key);
2565 case "NOTICE_ANSWERS":
2566 $reply_arr[
'ALERTSMRY'][
'NOTICE'][
'NOTICE_ANSWERS'] = array();
2567 foreach ($value as $anskey => $ansdetl) {
2568 $reply_arr[
'ALERTSMRY'][
'NOTICE'][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
2569 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
2570 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
2575 case "NOTICE_INTRO":
2576 case "NOTICE_TITLE":
2577 case "NOTICE_DONOTSHOWTEXT":
2578 case "NOTICE_MSG_TX":
2579 case "NOTICE_MSG_TX_SHOW":
2580 case "NOTICE_MSG_TX_PERM":
2581 case "NOTICE_SUPPRESSRESPONSE":
2582 case "NOTICE_POSTTARGET":
2587 case "NOTICE_POPUP":
2588 case "NOTICE_ANSWERTYPE":
2589 case "NOTICE_LINKTARGET":
2590 case "NOTICE_LINKDISPLAY":
2593 $reply_arr[
'ALERTSMRY'][
'NOTICE'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2603 parse_str($PASSWITH, $pass);
2604 $HB_ENV[
'HCUPOST'] = array(); # start w/ empty array
2605 $HB_ENV[
'HCUPOST'][
'type'] = HCU_array_key_value(
'TYPE',$pass);
2606 $HB_ENV[
'HCUPOST'][
'notifymsg'] = HCU_array_key_value(
'NOTIFYMSG',$pass);
2607 $HB_ENV[
'HCUPOST'][
'emailtype'] = HCU_array_key_value(
'EMAILTYPE',$pass);
2608 $HB_ENV[
'HCUPOST'][
'provider_id'] = HCU_array_key_value(
'PROVIDER_ID',$pass);
2609 $HB_ENV[
'HCUPOST'][
'notifyto'] = HCU_array_key_value(
'NOTIFYTO',$pass);
2610 $HB_ENV[
'HCUPOST'][
'id'] = HCU_array_key_value(
'ALERTID',$pass);
2611 $HB_ENV[
'HCUPOST'][
'mbr_account'] = HCU_array_key_value(
'MBRACCT',$pass);
2612 $HB_ENV[
'HCUPOST'][
'selacct'] = HCU_array_key_value(
'SELACCT',$pass);
2613 $HB_ENV[
'HCUPOST'][
'inctransdesc'] = HCU_array_key_value(
'INCTRANSDESC',$pass);
2615 switch (strtolower($pass[
'TYPE'])) {
2617 $HB_ENV[
'HCUPOST'][
'notifyamt'] = HCU_array_key_value(
'NOTIFYAMT',$pass);
2618 $HB_ENV[
'HCUPOST'][
'incbal'] = HCU_array_key_value(
'INCBAL',$pass);
2619 $HB_ENV[
'HCUPOST'][
'useavailbal'] = HCU_array_key_value(
'USEAVAILBAL',$pass);
2621 $HB_ENV[
'HCUPOST'][
'notifydesc'] = HCU_array_key_value(
'NOTIFYDESC',$pass);
2622 $HB_ENV[
'HCUPOST'][
'userange'] = HCU_array_key_value(
'USERANGE',$pass);
2623 $HB_ENV[
'HCUPOST'][
'desc_amtmin'] = HCU_array_key_value(
'DESC_AMTMIN',$pass);
2624 $HB_ENV[
'HCUPOST'][
'desc_amtmax'] = HCU_array_key_value(
'DESC_AMTMAX',$pass);
2625 $HB_ENV[
'HCUPOST'][
'incbal'] = HCU_array_key_value(
'INCBAL',$pass);
2626 $HB_ENV[
'HCUPOST'][
'incamt'] = HCU_array_key_value(
'INCAMT',$pass);
2627 $HB_ENV[
'HCUPOST'][
'transtype'] = HCU_array_key_value(
'TRANSTYPE',$pass);
2629 $HB_ENV[
'HCUPOST'][
'chknum'] = HCU_array_key_value(
'CHKNUM',$pass);
2630 $HB_ENV[
'HCUPOST'][
'incamt'] = HCU_array_key_value(
'INCAMT',$pass);
2632 $HB_ENV[
'HCUPOST'][
'days_prior'] = HCU_array_key_value(
'DAYS_PRIOR',$pass);
2635 throw new Exception(
'Invalid Alert Update Request',3120); # unrecognized Alert type
2638 $validalert = Validate_Alert($dbh, $HB_ENV, $MC);
2639 if ($validalert[
'code'] !=
'000') {
2640 throw new Exception(implode(
' ',$validalert[
'errors']),3212); # failed Validate_Alert
2642 $validalert = Update_Alert($dbh, $HB_ENV, $MC);
2643 if ($validalert[
'code'] !=
'000') {
2644 throw new Exception(implode(
' ',$validalert[
'errors']),3214); # failed Update_Alert
2646 $sendkeys = array(
'USERKEY' => $apptoken);
2647 $reply_arr = Return_ResponseOK($inPost[
'ORG'], $HB_ENV[
'Cn'], $HB_ENV[
'Uid'], $sendkeys,
"Alert Update Successful");
2653 parse_str($PASSWITH, $pass);
2654 $HB_ENV[
'HCUPOST'] = array(); # start w/ empty array
2655 $HB_ENV[
'HCUPOST'][
'type'] = $pass[
'TYPE'];
2656 $HB_ENV[
'HCUPOST'][
'id'] = $pass[
'ALERTID'];
2658 switch (strtolower($pass[
'TYPE'])) {
2665 throw new Exception(
'Invalid Alert Delete Request',3216); # unrecognized Alert type
2668 $validalert = Delete_Alert($dbh, $HB_ENV, $MC);
2669 if ($validalert[
'code'] !=
'000') {
2670 throw new Exception(implode(
' ',$validalert[
'errors']),3218); # failed Delete_Alert
2672 $sendkeys = array(
'USERKEY' => $apptoken);
2673 $reply_arr = Return_ResponseOK($inPost[
'ORG'], $HB_ENV[
'Cn'], $HB_ENV[
'Uid'], $sendkeys,
"Alert Delete Successful");
2681 $activityVar = array(
2682 "INITIAL" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
2683 "PENDING" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
2684 "PRIOR" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
2685 "DETAIL" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
2686 "TXNTYPE" => array(
'filter' => FILTER_SANITIZE_STRING),
2687 "SCHEDULED" => array(
'filter' => FILTER_SANITIZE_STRING),
2688 "DTSTART" => array(
'filter' => FILTER_SANITIZE_STRING),
2689 "DTEND" => array(
'filter' => FILTER_SANITIZE_STRING),
2690 "ACTION" => array(
'filter' => FILTER_SANITIZE_STRING)
2693 HCU_ImportVars( $pass,
"", $activityVar );
2695 $detail = !isset( $pass[
"DETAIL"] ) ? 0 : intval($pass[
"DETAIL"]);
2696 if ( $detail > 0 ) {
2698 $isScheduled = isset( $pass[
"SCHEDULED"] ) && strlen( trim( $pass[
"SCHEDULED"] ) ) > 0;
2701 $action = isset( $pass[
"ACTION"] ) ? trim( $pass[
"ACTION"] ) :
"";
2702 if ( strlen( $action ) > 0 ) {
2703 $reply_arr = UserActivityAction( $HB_ENV, $detail, $isScheduled, $action );
2705 $reply_arr = GatherUserActivityDetail( $HB_ENV, $detail, $isScheduled );
2708 $reply_arr = GatherUserActivity( $HB_ENV, $pass );
2712 $reply_arr[
"USERKEY"] = $apptoken;
2715 require_once(dirname(__FILE__) .
'/../library/hcuExternalAccts.i');
2718 $permissionInputs = array(
"feature" => FEATURE_EXTERNAL_TRANSFERS );
2719 $return = Perm_AccessRights( $dbh, $HB_ENV, $permissionInputs );
2722 $aryErrors[] = $MC->msg(
'Rights not set', HCU_DISPLAY_AS_HTML);
2723 throw new Exception (HCU_JsonEncode($aryErrors));
2727 $passedVars = array();
2728 $paramInputs = array(
2729 "ACTION" => array(
'filter' => FILTER_SANITIZE_STRING)
2732 HCU_ImportArray( $passedVars, $_REQUEST, $paramInputs );
2735 parse_str($PASSWITH, $pass);
2738 $pass[
"action"] = $passedVars[
"ACTION"];
2741 $needsTermsAnswered =
false;
2742 $termsInfo = array();
2743 $noticeInfo = array();
2746 switch( $passedVars[
"ACTION"] ) {
2747 case "get_accounts":
2749 $aryExtAcctTerms = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'extAccountTerms');
2751 if (count($aryExtAcctTerms[
'notice'])) {
2752 foreach ($aryExtAcctTerms[
'notice'] as $noticekey => $details) {
2753 foreach ($details as $key => $value) {
2754 $key = strtoupper($key);
2756 case "NOTICE_ANSWERS":
2758 $termsInfo[
"TERMS"][
'NOTICE_ANSWERS'] = array();
2759 foreach ($value as $anskey => $ansdetl) {
2760 $termsInfo[
"TERMS"][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
2761 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
2762 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
2768 case "NOTICE_INTRO":
2769 case "NOTICE_TITLE":
2770 case "NOTICE_DONOTSHOWTEXT":
2771 case "NOTICE_MSG_TX":
2772 case "NOTICE_MSG_TX_SHOW":
2773 case "NOTICE_MSG_TX_PERM":
2774 case "NOTICE_SUPPRESSRESPONSE":
2775 case "NOTICE_POSTTARGET":
2778 case "NOTICE_POPUP":
2781 case "NOTICE_ANSWERTYPE":
2782 case "NOTICE_LINKTARGET":
2783 case "NOTICE_LINKDISPLAY":
2785 $termsInfo[
"TERMS"][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2792 $needsTermsAnswered = $termsInfo[
"TERMS"][
"NOTICE_POPUP"] == 1;
2798 $aryExtAcctNotice = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'extAccountNotice');
2800 if (count($aryExtAcctNotice[
'notice'])) {
2801 foreach ($aryExtAcctNotice[
'notice'] as $noticekey => $details) {
2802 foreach ($details as $key => $value) {
2803 $key = strtoupper($key);
2805 case "NOTICE_ANSWERS":
2806 $noticeInfo[
"NOTICE"][
'NOTICE_ANSWERS'] = array();
2807 foreach ($value as $anskey => $ansdetl) {
2808 $noticeInfo[
"NOTICE"][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
2809 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
2810 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
2815 case "NOTICE_INTRO":
2816 case "NOTICE_TITLE":
2817 case "NOTICE_DONOTSHOWTEXT":
2818 case "NOTICE_MSG_TX":
2819 case "NOTICE_MSG_TX_SHOW":
2820 case "NOTICE_MSG_TX_PERM":
2821 case "NOTICE_SUPPRESSRESPONSE":
2822 case "NOTICE_POSTTARGET":
2827 case "NOTICE_POPUP":
2828 case "NOTICE_ANSWERTYPE":
2829 case "NOTICE_LINKTARGET":
2830 case "NOTICE_LINKDISPLAY":
2832 $noticeInfo[
'NOTICE'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2838 $inputFilter = array(
2839 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
2844 $inputFilter = array(
2845 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
2846 "display_name" => array(
"filter" => FILTER_SANITIZE_STRING,
'options' => array(
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES)),
2847 "name_on_account" => array(
"filter" => FILTER_SANITIZE_STRING,
'options' => array(
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES)),
2848 "dfi_routing" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
2849 "dfi_account" => array(
'filter' => FILTER_SANITIZE_STRING),
2850 "dfi_account_type" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT)
2853 case "validate_account":
2854 $inputFilter = array(
2855 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
2856 "micro1" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
2857 "micro2" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
2858 "id" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT)
2862 case "update_account":
2864 $inputFilter = array(
2865 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
2866 "display_name" => array(
"filter" => FILTER_SANITIZE_STRING,
'options' => array(
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES)),
2867 "name_on_account" => array(
"filter" => FILTER_SANITIZE_STRING,
'options' => array(
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES)),
2868 "id" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT)
2871 case "delete_account":
2873 $inputFilter = array(
2874 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
2875 "id" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT)
2879 throw new Exception(
"Unknown action received: {$passedVars["ACTION
"]}", 15511 );
2883 $reply_arr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO' ),
2884 'USERKEY' => $apptoken,
2885 'EXTACCT_RESP' => array() );
2888 if ( !$needsTermsAnswered ) {
2889 HCU_ImportArray( $inputVars, $pass, $inputFilter );
2891 $return = ManageExternalAccount( $HB_ENV, $inputVars );
2894 if ( $return[
"status"][
"code"] !==
"000" ) {
2897 if ( is_array( $return[
"status"][
"errors"] ) ) {
2898 for ( $i = 0; $i < count( $return[
"status"][
"errors"] ); $i++ ) {
2899 if ( strlen( $returnError ) > 0 ) {
2900 $returnError .=
" ";
2903 $returnError .= $return[
"status"][
"errors"][$i];
2906 $returnError .= $return[
"status"][
"errors"];
2908 throw new Exception ($returnError, 15512);
2912 switch( $passedVars[
"ACTION"] ) {
2915 $returnMessage =
"";
2916 for ( $i = 0; $i < count( $return[
"info"] ); $i++ ) {
2917 if ( strlen( $returnMessage ) > 0 ) {
2918 $returnMessage .=
" ";
2920 $returnMessage .= $return[
"info"][$i];
2923 $reply_arr[
"EXTACCT_RESP"][
"DATA"][
"MESSAGE"] = $returnMessage;
2926 case "get_accounts":
2927 $statusLookup = Get_ExternalTransferStatusLookup( $MC );
2929 for ( $i = 0; $i < count( $return[
'data'] ); $i++ ) {
2930 $oneAcct = $return[
"data"][$i];
2934 $detail[
"ID"] = $oneAcct[
"id"];
2935 $detail[
"DISPLAY_NAME"] = htmlspecialchars($oneAcct[
"display_name"], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2936 $detail[
"NAME_ON_ACCOUNT"] = htmlspecialchars($oneAcct[
"name_on_account"], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
2937 $detail[
"STATUS"] = $oneAcct[
"status"];
2938 $detail[
"STATUS_NAME"] = $statusLookup[$oneAcct[
"status"]];
2939 $detail[
"REMOTEACCOUNT"] = $oneAcct[
"remoteAccount"];
2942 $acctInfo = HCU_JsonDecode( $oneAcct[
"remote_info"] );
2944 $type = $acctInfo[
"rdfi"][
"type"] == 10 ? $MC->msg(
"ACH Checking" ) : $MC->msg(
"ACH Savings" );
2945 $detail[
"ACCOUNTTYPE"] = $type;
2949 if ( $oneAcct[
"status"] ==
"p" ) {
2950 $detail[
"PENDING_DATE"] = $acctInfo[
"verify"][
"pending_date"];
2951 $detail[
"TRIES"] = $acctInfo[
"verify"][
"tries"];
2953 $detail[
"VERIFIED"] = date(
"m/d/Y", $acctInfo[
"verify"][
"verified"] );
2956 $reply_arr[
'EXTACCT_RESP'][
'EXTACCTS'][][
'ACCT'] = $detail;
2959 case "validate_account":
2961 $data = array(
"ID" => $return[
"data"][
"id"],
2962 "STATUS" => $return[
"data"][
"status"],
2963 "TRIES" => $return[
"data"][
"tries"],
2964 "MESSAGE" => $return[
"data"][
"message"]
2966 $reply_arr[
"EXTACCT_RESP"][
"DATA"] = $data;
2968 case "update_account":
2970 $data = array(
"ID" => $return[
"data"][
"id"],
2971 "NAME_ON_ACCOUNT" => $return[
"data"][
"name_on_account"],
2972 "DISPLAY_NAME" => $return[
"data"][
"display_name"],
2973 "MESSAGE" => $return[
"info"][0]
2975 $reply_arr[
"EXTACCT_RESP"][
"DATA"] = $data;
2977 case "delete_account":
2979 $data = array(
"ID" => $return[
"data"],
2980 "MESSAGE" => $return[
"info"][0]
2982 $reply_arr[
"EXTACCT_RESP"][
"DATA"] = $data;
2988 if ( HCU_array_key_exists(
"TERMS", $termsInfo ) && HCU_array_key_value(
"NOTICE_ID", $termsInfo[
"TERMS"] ) > 0 ) {
2989 $reply_arr[
"EXTACCT_RESP"][
"TERMS"] = $termsInfo[
"TERMS"];
2993 if ( HCU_array_key_exists(
"NOTICE", $noticeInfo ) && HCU_array_key_value(
"NOTICE_ID", $noticeInfo[
"NOTICE"] ) > 0 ) {
2994 $reply_arr[
"EXTACCT_RESP"][
"NOTICE"] = $noticeInfo[
"NOTICE"];
2999 require_once(dirname(__FILE__) .
'/../library/hcuExternalAccts.i');
3002 $permissionInputs = array(
"feature" => FEATURE_M2M_TRANSFERS );
3003 $return = Perm_AccessRights( $dbh, $HB_ENV, $permissionInputs );
3006 $aryErrors[] = $MC->msg(
'Rights not set', HCU_DISPLAY_AS_HTML);
3007 throw new Exception (HCU_JsonEncode($aryErrors));
3011 $passedVars = array();
3012 $paramInputs = array(
3013 "ACTION" => array(
'filter' => FILTER_SANITIZE_STRING)
3016 HCU_ImportArray( $passedVars, $_REQUEST, $paramInputs );
3019 parse_str($PASSWITH, $pass);
3022 $pass[
"action"] = $passedVars[
"ACTION"];
3025 $needsTermsAnswered =
false;
3026 $termsInfo = array();
3027 $noticeInfo = array();
3030 switch( $passedVars[
"ACTION"] ) {
3031 case "get_m2m_accounts":
3033 $aryM2MAcctTerms = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'm2mAccountTerms');
3035 if (count($aryM2MAcctTerms[
'notice'])) {
3036 foreach ($aryM2MAcctTerms[
'notice'] as $noticekey => $details) {
3037 foreach ($details as $key => $value) {
3038 $key = strtoupper($key);
3040 case "NOTICE_ANSWERS":
3042 $termsInfo[
"TERMS"][
'NOTICE_ANSWERS'] = array();
3043 foreach ($value as $anskey => $ansdetl) {
3044 $termsInfo[
"TERMS"][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
3045 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
3046 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
3052 case "NOTICE_INTRO":
3053 case "NOTICE_TITLE":
3054 case "NOTICE_DONOTSHOWTEXT":
3055 case "NOTICE_MSG_TX":
3056 case "NOTICE_MSG_TX_SHOW":
3057 case "NOTICE_MSG_TX_PERM":
3058 case "NOTICE_SUPPRESSRESPONSE":
3059 case "NOTICE_POSTTARGET":
3062 case "NOTICE_POPUP":
3065 case "NOTICE_ANSWERTYPE":
3066 case "NOTICE_LINKTARGET":
3067 case "NOTICE_LINKDISPLAY":
3069 $termsInfo[
"TERMS"][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
3076 $needsTermsAnswered = $termsInfo[
"TERMS"][
"NOTICE_POPUP"] == 1;
3082 $aryM2MAcctNotice = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'm2mAccountNotice');
3084 if (count($aryM2MAcctNotice[
'notice'])) {
3085 foreach ($aryM2MAcctNotice[
'notice'] as $noticekey => $details) {
3086 foreach ($details as $key => $value) {
3087 $key = strtoupper($key);
3089 case "NOTICE_ANSWERS":
3090 $noticeInfo[
"NOTICE"][
'NOTICE_ANSWERS'] = array();
3091 foreach ($value as $anskey => $ansdetl) {
3092 $noticeInfo[
"NOTICE"][
'NOTICE_ANSWERS'][] = array(
'ANSWER' => array(
3093 'ANSWER_ID' =>
"ANS_{$ansdetl['answer_id']}",
3094 'ANSWER_TEXT' => htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE)));
3099 case "NOTICE_INTRO":
3100 case "NOTICE_TITLE":
3101 case "NOTICE_DONOTSHOWTEXT":
3102 case "NOTICE_MSG_TX":
3103 case "NOTICE_MSG_TX_SHOW":
3104 case "NOTICE_MSG_TX_PERM":
3105 case "NOTICE_SUPPRESSRESPONSE":
3106 case "NOTICE_POSTTARGET":
3111 case "NOTICE_POPUP":
3112 case "NOTICE_ANSWERTYPE":
3113 case "NOTICE_LINKTARGET":
3114 case "NOTICE_LINKDISPLAY":
3116 $noticeInfo[
'NOTICE'][$key] = htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
3122 $inputFilter = array(
3123 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
3126 case "add_m2m_account":
3128 $inputFilter = array(
3129 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
3130 "display_name" => array(
"filter" => FILTER_SANITIZE_STRING,
'options' => array(
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES)),
3131 "name_on_account" => array(
"filter" => FILTER_SANITIZE_STRING,
'options' => array(
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES)),
3132 "dfi_account" => array(
'filter' => FILTER_SANITIZE_STRING),
3133 "dfi_account_type" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT)
3136 case "update_account":
3138 $inputFilter = array(
3139 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
3140 "display_name" => array(
"filter" => FILTER_SANITIZE_STRING,
'options' => array(
'flags' => FILTER_FLAG_NO_ENCODE_QUOTES)),
3141 "id" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT)
3144 case "delete_account":
3146 $inputFilter = array(
3147 "action" => array(
'filter' => FILTER_SANITIZE_STRING),
3148 "id" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT)
3152 throw new Exception(
"Unknown action received: {$passedVars["ACTION
"]}", 15511 );
3156 $reply_arr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO' ),
3157 'USERKEY' => $apptoken,
3158 'M2MACCT_RESP' => array() );
3161 if ( !$needsTermsAnswered ) {
3162 HCU_ImportArray( $inputVars, $pass, $inputFilter );
3165 $return = ManageExternalAccount( $HB_ENV, $inputVars );
3168 if ( $return[
"status"][
"code"] !==
"000" ) {
3171 if ( is_array( $return[
"status"][
"errors"] ) ) {
3172 for ( $i = 0; $i < count( $return[
"status"][
"errors"] ); $i++ ) {
3173 if ( strlen( $returnError ) > 0 ) {
3174 $returnError .=
" ";
3177 $returnError .= $return[
"status"][
"errors"][$i];
3180 $returnError .= $return[
"status"][
"errors"];
3182 throw new Exception ($returnError, 15512);
3186 switch( $passedVars[
"ACTION"] ) {
3187 case "add_m2m_account":
3189 $returnMessage =
"";
3190 for ( $i = 0; $i < count( $return[
"info"] ); $i++ ) {
3191 if ( strlen( $returnMessage ) > 0 ) {
3192 $returnMessage .=
" ";
3194 $returnMessage .= $return[
"info"][$i];
3197 $reply_arr[
"M2MACCT_RESP"][
"DATA"][
"MESSAGE"] = $returnMessage;
3200 case "get_m2m_accounts":
3201 $statusLookup = Get_ExternalTransferStatusLookup( $MC );
3203 for ( $i = 0; $i < count( $return[
'data'] ); $i++ ) {
3204 $oneAcct = $return[
"data"][$i];
3208 $detail[
"ID"] = $oneAcct[
"id"];
3209 $detail[
"DISPLAY_NAME"] = htmlspecialchars($oneAcct[
"display_name"], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
3210 $detail[
"STATUS"] = $oneAcct[
"status"];
3211 $detail[
"STATUS_NAME"] = $statusLookup[$oneAcct[
"status"]];
3212 $detail[
"REMOTEACCOUNT"] = $oneAcct[
"remoteAccount"];
3215 $acctInfo = HCU_JsonDecode( $oneAcct[
"remote_info"] );
3217 $type = $acctInfo[
"rdfi"][
"type"] == 10 ? $MC->msg(
"ACH Checking" ) : $MC->msg(
"ACH Savings" );
3218 $detail[
"ACCOUNTTYPE"] = $type;
3220 $detail[
"VERIFIED"] = date(
"m/d/Y", $acctInfo[
"verify"][
"verified"] );
3222 $reply_arr[
'M2MACCT_RESP'][
'M2MACCTS'][][
'ACCT'] = $detail;
3225 case "update_account":
3227 $data = array(
"ID" => $return[
"data"][
"id"],
3228 "DISPLAY_NAME" => $return[
"data"][
"display_name"],
3229 "MESSAGE" => $return[
"info"][0]
3231 $reply_arr[
"M2MACCT_RESP"][
"DATA"] = $data;
3233 case "delete_account":
3235 $data = array(
"ID" => $return[
"data"],
3236 "MESSAGE" => $return[
"info"][0]
3238 $reply_arr[
"M2MACCT_RESP"][
"DATA"] = $data;
3244 if ( HCU_array_key_exists(
"TERMS", $termsInfo ) && HCU_array_key_value(
"NOTICE_ID", $termsInfo[
"TERMS"] ) > 0 ) {
3245 $reply_arr[
"M2MACCT_RESP"][
"TERMS"] = $termsInfo[
"TERMS"];
3249 if ( HCU_array_key_exists(
"NOTICE", $noticeInfo ) && HCU_array_key_value(
"NOTICE_ID", $noticeInfo[
"NOTICE"] ) > 0 ) {
3250 $reply_arr[
"M2MACCT_RESP"][
"NOTICE"] = $noticeInfo[
"NOTICE"];
3255 require_once(dirname(__FILE__) .
'/../../shared/library/hcuFunctions.i');
3257 $passedVars = array();
3258 $paramInputs = array(
3259 "ACTION" => array(
'filter' => FILTER_SANITIZE_STRING)
3262 HCU_ImportArray( $passedVars, $_REQUEST, $paramInputs );
3264 $action = strtoupper( $passedVars[
"ACTION"] );
3269 $paramInputs = array(
3270 "ID" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT)
3272 HCU_ImportArray( $passedVars, $_REQUEST, $paramInputs );
3273 $landingResult = GetLandingMenuTarget( $HB_ENV, $passedVars[
"ID"], $apptoken );
3278 $paramInputs = array(
3279 "URL" => array(
'filter' => FILTER_SANITIZE_STRING)
3281 HCU_ImportArray( $passedVars, $_REQUEST, $paramInputs );
3282 $landingResult = GetLandingURL( $HB_ENV, $passedVars[
"URL"], $apptoken );
3287 $landingResult =
"";
3293 $reply_arr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO' ),
3294 'USERKEY' => $apptoken,
3295 'TARGET_RESP' => urlencode( $landingResult )
3302 $menuCompass = function_exists(
"CompassMenuJson" ) ? CompassMenuJson( $HB_ENV, $dbh ) : GetFakeUserCompassMenu( $HB_ENV );
3303 $reply_arr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO' ),
3304 'USERKEY' => $apptoken,
3305 'COMPASS' => $menuCompass,
3306 'COMPASS_UPDATE_INTERVAL' => 180
3312 $KEYACCTID = HCU_array_key_value(
'KEYACCTID', $inPost);
3313 $BALONLY = (HCU_array_key_exists(
'KEYACCTID', $inPost) ? 0 : 1);
3314 if (empty($sendkeys)) { $sendkeys=array(); }
3316 $reply_arr = fullFeed($dbh, $HB_ENV, $DTSTART, $DTEND, $BALONLY, $SENDAS, $KEYACCTID, $recent, $sendkeys);
3322 $userMenuRequest = strtolower(HCU_array_key_value(
'USERMENU', $inPost));
3323 if ( $userMenuRequest !=
"" ) {
3325 if ( $userMenuRequest ==
"full" ) {
3326 $userMenu = BuildFullUserMenu($dbh, $HB_ENV,
'A');
3328 $userMenu = BuildUserMenu($dbh, $HB_ENV,
'A');
3330 $reply_arr[
"usermenu"] = $userMenu;
3334 $updateString = GetUserProfileUpdates( $HB_ENV );
3335 $reply_arr[
"PROFILE_UPDATES"] = $updateString;
3336 require_once(dirname(__FILE__) .
'/../../shared/library/hcuFunctions.i');
3339 $count = GetPendingUserActivity($HB_ENV);
3341 $reply_arr[
"USER_ACTIVITY_PENDING"] = $count;
3346 $count = ReturnUnreadSecureMsg($HB_ENV[
"dbh"], $HB_ENV);
3348 $reply_arr[
"SECURE_MSG_UNREAD"]= $count;
3353 if ( $appEncryptionKey !=
"" ) {
3354 $reply_arr[
"encrkey"] = $appEncryptionKey;
3358 }
catch (Exception $e) {
3359 $code = $e->getCode();
3360 $message = $e->getMessage();
3362 $reply_arr = array(
'STATUS' => array(
'CODE' => $code,
'SEVERITY' =>
'ERROR'),
3363 'MESSAGE'=> array(
'ERR' => htmlspecialchars($message, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE),
'ERRNO' => 999,
'ERRSTAT' =>
'FAIL'));
3368 send_response( $reply_arr, $SENDAS );
3375 function Format_AppFeed($data) {
3384 $dom =
new DOMDocument();
3386 $dom->preserveWhiteSpace =
false;
3387 $dom->formatOutput =
true;
3389 $dom->loadXML($data);
3390 $out = $dom->saveXML();
3392 $out = str_replace(
'<?xml version="1.0"?>',
'',$out);
3397 function send_response($reply_arr, $sendas=
'XML') {
3401 $xmlResp = HCU_JsonEncode($reply_arr);
3402 header(
"Content-Type: application/json");
3407 $xmlResp = Format_AppFeed(assocArrayToXML($reply_arr,
'APPFEED'));
3409 if (HCU_array_item_count(
'HB_ENV', $GLOBALS) && HCU_array_key_value(
'Cu',$GLOBALS[
'HB_ENV'])) {
3410 $replace = GetAppMenu($GLOBALS[
'HB_ENV'][
'Cu'],
'appconfig.xml');
3411 $xmlResp = preg_replace(
'/<menu>REPLACE MENU HERE<\/menu>/',
"<menu>{$replace}</menu>",$xmlResp);
3414 header(
"Content-Type: application/x-ofx");
3421 header(
"Content-length: " . strlen($xmlResp));
3427 function sqlmdy($date) {
3429 if (strtolower($date) ==
"now" || strtolower($date) ==
"today") {
3430 $date = date(
"Y-m-d");
3432 # only allow 0-9 and dash(-) or slash (/) 3433 # also allow dot (.) for milliseconds 3434 if (preg_match(
"/[^0-9\-\/\.]/", $date)) {
3437 if (preg_match(
"/[-\/]/", $date)) {
3438 list ($yy, $mm, $dd) = preg_split(
"/[-\/\.]/", $date);
3440 $yy = substr($date, 0, 4);
3441 $mm = substr($date, 4, 2);
3442 $dd = substr($date, 6, 2);
3444 $mm = sprintf(
"%02d", intval($mm));
3445 $dd = sprintf(
"%02d", intval($dd));
3446 if (strlen($yy) > 0 && strlen($yy) < 4) {
3447 $yy = ($yy < 70 ? 2000 + $yy : 1900 + $yy);
3449 $yy = sprintf(
"%04d", intval($yy));
3450 if (checkdate($mm, $dd, $yy)) {
3451 return "${yy}${mm}${dd}";
3457 function countprint($string) {
3459 return strlen($string);
3462 function clockwatch($tz, $CU, $MEMBER) {
3463 $localzone =
'US/Mountain';
3464 $tz = (
"$tz" ==
"" ?
"US/Mountain" : $tz);
3465 if (strpos(
"$tz",
"/") ===
false)
3468 $sqlll =
"set time zone '$tz'; 3469 select extract(epoch from CURRENT_TIMESTAMP(0)) - 3470 extract(epoch from substring(lastlogin,1,19)::timestamp)::integer 3472 where cu='$CU' and user_name='$MEMBER';";
3473 $sthcl = db_query($sqlll, $dbh);
3475 list($sincelast) = db_fetch_array($sthcl, 0);
3477 $sthcl = db_query(
"set time zone '$localzone'", $dbh);
3478 return abs($sincelast);
3481 function MFQ_send_chall($dbh, $HB_ENV, $MC) {
3483 # sending all questions regardless of '1 random' setting for cu 3484 # updated 9/12 to recognize '1 random' setting 3485 # use odyssey function 3487 $MemberChallengeQuestions_ary=GetChallengeQuestions(
"CHALLENGE", $dbh, $HB_ENV, $MC, $HB_ENV[
'Cn']);
3489 $reply_arr = array(
'STATUS' => array(
'CODE' =>3000,
'SEVERITY' =>
'ERROR'),
3490 'DTSERVER' => date(
'YmdHis') );
3493 $reply_arr[
'MFA'] = array();
3494 $reply_arr[
'MFA'][
'AUTHREQ'] =
'MFQ';
3495 $reply_arr[
'MFA'][
'MFABUNDLE'] = $HB_ENV[
'mfaBundle'];
3504 # and now add mfa questions, if any were found 3505 if (count($MemberChallengeQuestions_ary)) {
3506 foreach ((array) $MemberChallengeQuestions_ary as $chakey => $mfaitem) {
3507 $itm_arr = array(
'MFACHALLENGE' => array(
3508 'MFAPHRASEID' =>
"MFA_{$mfaitem['cqid']}",
3509 'MFAPHRASELABEL' =>
"{$mfaitem['display']}"));
3511 $reply_arr[
'MFA'][] = $itm_arr;
3528 function MFQ_response($dbh, $HB_ENV, $inPost) {
3530 $aryMfaQuest = HCU_JsonDecode($HB_ENV[
'mfaquest']);
3531 $mbrMfaQuest = HCU_MFADecode($aryMfaQuest); # from the db
3536 $dbcount = $mbrMfaQuest[
'mfacount']; # how many questions are in the db?
3537 $mfapost = MFQ_resplist($inPost); #
get list of MFA variables in the posted request (skips MFA_E)
3538 # update from mammoth - gets id and answers in array using Odyssey format 3539 $mfacount = count($mfapost); # how many MFA_ responses (excluding MFA_E) did we
get?
3541 if ($mfacount < $dbcount && ($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_RANDOM_CHAL']) == 0) {
3542 # expected more challenge questions than we got, so fail 3544 $failreason = $GLOBALS[
'MEM_LOGIN_FAILED_QST'];
3545 throw new Exception(__LINE__ .
'MFA Failed',$failreason);# expected chall ques and got none
3548 # make sure savemail is set in HB_ENV 3549 # separate eMail check from challenge questions 3550 # eMail check now using isValidEmail from cu_credentials 3570 $aryMfaAnswers = $mbrMfaQuest[
'answers']; # stored answers
3571 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_RANDOM_CHAL'])) {
3572 if ( $mbrMfaQuest[
'challenge'] > 0 ) {
3574 $mfaAnswerIdx = Array($mbrMfaQuest[
'challenge']);
3577 $mfaAnswerIdx = array_keys($mfapost);
3581 $mfaAnswerIdx = array_keys($aryMfaAnswers);
3585 # for each id in $mfaAnserIdx 3586 # intersect should be with posted answer set, not db answer set? 3588 foreach (array_intersect_key($aryMfaAnswers, array_flip($mfaAnswerIdx)) as $qid => $qanswer) {
3589 if (strtolower(trim($qanswer)) != strtolower(trim(HCU_array_key_value(
"MFA_$qid",$inPost)))) {
3591 $failreason = $GLOBALS[
'MEM_LOGIN_FAILED_QST'];
3593 throw new Exception(__LINE__ .
" MFA $qid Failed",$failreason);# chall response mismatch
3596 }
catch (Exception $e) {
3597 # logging handled at point of call - nothing to do here but fall through? 3599 return (array($fail, $failreason));
3602 function MFQ_resplist($posted) {
3603 # examines the (sanitized!) array of posted values 3604 # returns list of MFA_ excluding MFA_E (email) 3606 foreach (array_keys($posted) as $rkey) {
3607 $m = strpos($rkey,
'MFA_');
3608 if ($m !== FALSE && $m == 0 && $rkey !==
'MFA_E') {
3610 $cqid = substr($rkey,4);
3611 $mfalist[$cqid] = $posted[$rkey];
3617 function MFQ_defined($posted) {
3618 # returns a count of MFA_* challenge question responses 3619 # in (sanitized) array of posted values 3621 foreach (array_keys($posted) as $rkey) {
3622 $m = strpos($rkey,
'MFA_');
3623 if ($m !== FALSE && $m == 0) {
3630 function ANS_list($arr) {
3632 foreach (array_keys($arr) as $rkey) {
3633 $m = strpos($rkey,
'ANS_');
3634 if ($m !== FALSE && $m == 0) {
3635 $anslist[] = substr($rkey, 4);
3641 function Return_ResponseOK($CU, $MEMBER, $UID, $SENDKEY, $MESSAGE) {
3642 # was sending <LASTUPDATE>" . $HB_ENV['lastupdate'] . "</LASTUPDATE> 3643 # but it was always empty as HB_ENV is neither passed in nor global 3645 # also a couple of the alert-related calls were using an 'OFXPOST' tag at the top 3646 # but I made them all consistent 3648 $reply_arr = array(
'STATUS' => array(
'CODE' =>0,
'SEVERITY' =>
'INFO',
'MESSAGE'=> array(
'INFO' => $MESSAGE)),
3649 'DTSERVER' => date(
'YmdHis'),
3652 if (is_array($SENDKEY)) {
3653 foreach ($SENDKEY as $key => $value) {
3654 $reply_arr[$key] = $value;
3661 function Return_AllowedUpdate($CU, $MEMBER, $UID, $HB_ENV) {
3664 $apptoken = MakeSessionUserkey( $HB_ENV );
3666 $upd_grace = $HB_ENV[
'Ffremain'];
3667 $upd_wait = ($upd_grace == 0 ?
"You must update your credentials now." :
3668 "You must update your credentials within the next $upd_grace login" . ($upd_grace == 1 ?
'.' :
's.') );
3670 $reply_arr = array(
'STATUS' => array(
'CODE' =>3110,
'SEVERITY' =>
'INFO'),
3671 'SREQ' => $HB_ENV[
'forceupdate'],
3672 'UREQ' => $HB_ENV[
'requpdate'],
3673 'DTSERVER' => date(
'YmdHis'),
3675 'USERKEY' => $apptoken );
3677 $reply_arr[
'ALLOWUPD'] = array();
3679 if ($HB_ENV[
'forceupdate'] != 0) {
3680 $reply_arr[
'ALLOWUPD'][
'UPDCANWAIT'] = $upd_grace;
3681 $reply_arr[
'ALLOWUPD'][
'UPDWAITPHRASE']=$upd_wait;
3683 $reply_arr[
'ALLOWUPD'][
'PASSWORD'] = array(
3684 'ALLOW' => (($HB_ENV[
'allowupdate'] & 1) ?
"YES" :
"NO"),
3685 'REQ' => (($HB_ENV[
'forceupdate'] & 1) ?
"YES" :
"NO"));
3686 $reply_arr[
'ALLOWUPD'][
'EMAIL'] = array(
3687 'ALLOW' => (($HB_ENV[
'allowupdate'] & 2) ?
"YES" :
"NO"),
3688 'REQ' => (($HB_ENV[
'forceupdate'] & 2) ?
"YES" :
"NO"));
3689 $reply_arr[
'ALLOWUPD'][
'CHALLENGE'] = array(
3690 'ALLOW' => (($HB_ENV[
'allowupdate'] & 4) ?
"YES" :
"NO"),
3691 'REQ' => (($HB_ENV[
'forceupdate'] & 4) ?
"YES" :
"NO"));
3692 $reply_arr[
'ALLOWUPD'][
'USERALIAS'] = array(
3693 'ALLOW' => (($HB_ENV[
'allowupdate'] & 8) ?
"YES" :
"NO"),
3694 'REQ' => (($HB_ENV[
'forceupdate'] & 8) ?
"YES" :
"NO"));
3695 $reply_arr[
'ALLOWUPD'][
'PHONE'] = array(
3696 'ALLOW' => (($HB_ENV[
'allowupdate'] & 16) ?
"YES" :
"NO"),
3697 'REQ' => (($HB_ENV[
'forceupdate'] & 16) ?
"YES" :
"NO"));
3702 function Return_ReqUpdate($CU, $MEMBER, $UID, $HB_ENV, $SENDKEY) {
3703 $dbh = $HB_ENV[
'dbh'];
3704 $MC = $HB_ENV[
'MC'];
3707 $apptoken = MakeSessionUserkey( $HB_ENV );
3709 # forceupdate 1 = reset password 3710 # forceupdate 4 = reset security w/ challenge questions 3711 # forceupdate 16 = reset security w/ access codes 3712 # send updRemember if reset pwd or reset security is set 3713 $upd_remember = $HB_ENV[
'forceupdate'] & 21;
3714 $upd_grace = $HB_ENV[
'Ffremain'];
3715 $upd_wait = ($upd_grace == 0 ?
"You must update your credentials now." :
3716 "You must update your credentials within the next $upd_grace login" . ($upd_grace == 1 ?
'.' :
's.') );
3718 $reply_arr = array(
'STATUS' => array(
'CODE' =>3100,
'SEVERITY' =>
'INFO'),
3719 'SREQ' => $HB_ENV[
'forceupdate'],
3720 'UREQ' => $HB_ENV[
'requpdate'],
3721 'DTSERVER' => date(
'YmdHis'),
3722 'MEMBER' => $HB_ENV[
'Uid'],
3723 'USERKEY' => $apptoken );
3725 if (is_array($SENDKEY)) {
3726 foreach ($SENDKEY as $key => $value) {
3727 $reply_arr[$key] = $value;
3731 $reply_arr[
'REQUIREUPD'] = array();
3733 if ($HB_ENV[
'forceupdate'] != 0 && $HB_ENV[
'requpdate'] == 0) {
3734 $reply_arr[
'REQUIREUPD'][
'UPDCANWAIT'] = $upd_grace;
3735 $reply_arr[
'REQUIREUPD'][
'UPDWAITPHRASE']=$upd_wait;
3737 if ($upd_remember) {
3738 $reply_arr[
'REQUIREUPD'][
'UPDREMEMBER']=
'Remember This Device';
3742 if ((($HB_ENV[
'forceupdate'] & 4) == 4 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 4) == 4) {
3743 # 2-factor and either force reset or not enough questions selected yet 3744 # Security Reset: send master list of challenge questions 3745 $upd_req = array(
'UPDPHRASEID' =>
'CHALLENGE',
3746 'UPDCONFLABEL' =>
'This confidence word is used to identify and prevent phishing attempts when you access home banking through the web. It is not used in this app, but you are asked to set it now in case you later access your account through the web.',
3747 'UPDCONFIDENCE' => htmlentities($HB_ENV[
'confidence'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE),
3748 'UPDPHRASECOUNT' => $HB_ENV[
'cu_chgqst_count']);
3749 if ($HB_ENV[
'cu_chgqst_count'] > 0) {
3750 $upd_req[
'UPDPHRASELABEL'] =
"Please select {$HB_ENV['cu_chgqst_count']} challenge questions";
3751 $upd_req[
'UPDCHOICELIST'] = array();
3752 $questlist = GetChallengeQuestions(
"DISPLAY", $dbh, $HB_ENV, $MC);
3753 foreach ($questlist as $QstValue) {
3754 $upd_req[
'UPDCHOICELIST'][][
'CHOICEITEM'] = array(
'CQID' => $QstValue[
'cqid'],
3755 'CQTEXT' => htmlentities($QstValue[
'display'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
3757 if (($HB_ENV[
'requpdate'] & 4) == 4) {
3758 # 'on-demand' update - send current selected questions/responses 3759 $upd_req[
'CURRSELECTED'] = array();
3760 foreach ($HB_ENV[
'MFA'][
'answers'] as $quest_id => $quest_resp) {
3761 $upd_req[
'CURRSELECTED'][][
'SELECTEDITEM'] = array(
'CQID' => $quest_id,
3762 'CQRESP' => htmlentities($quest_resp, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
3766 $reply_arr[
'REQUIREUPD'][][
'REQUPD'] = $upd_req;
3769 if ((($HB_ENV[
'forceupdate'] & 1) == 1 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 1) == 1) {
3772 $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $HB_ENV[
'MC'],
"P",
"pwdRules",
false);
3775 if ( $noticesAry[
"status"][
"code"] ==
"000" && $noticesAry[
"notice"][0][
"notice_id"] ) {
3777 $helpdoc = $noticesAry[
"notice"][0][
"notice_linktarget"];
3779 $pwdRequires = Get_PwdRules($dbh, $HB_ENV);
3780 $upd_req = array(
'UPDPHRASEID' =>
'PASSWORD',
3781 'UPDPHRASELABEL' =>
'Please select a new password.',
3782 'PWDRULESLINK' => ($hasRules ? htmlentities($helpdoc, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) :
''),
3783 'PWDRULESLABEL' => ($hasRules ?
'I have read the Recommended Password Guidelines' :
''),
3784 'PWDADVLABEL' => ($hasRules ?
'Recommended Guidelines' :
''));
3785 foreach ($pwdRequires as $pwdkey => $pwdval) {
3786 $pwdkey = strtoupper($pwdkey);
3787 $upd_req[
'PWDREQUIRES'][$pwdkey] = $pwdval;
3790 $pwdSpecChar = Get_PwdSpecialCharacters();
3791 $upd_req[
'PWDREQUIRES'][
'PWDSPECIALCHARS'] = htmlspecialchars($pwdSpecChar, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
3794 $reply_arr[
'REQUIREUPD'][][
'REQUPD'] = $upd_req;
3796 if ((($HB_ENV[
'forceupdate'] & 6) > 0 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 2) == 2) {
3797 # verify email is set or email is empty, 3798 # or we are sending the CHALLENGE set so include email with it (apps treat email as extra challenge question) 3799 $upd_req = array(
'UPDPHRASEID' =>
'EMAIL',
3800 'UPDPHRASELABEL' =>
'Please provide your email address.',
3801 'CURRENTEMAIL' => htmlentities($HB_ENV[
'Ml'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE),
3802 'CURRENTOPTIN' => $HB_ENV[
'egenl_flag'],
3803 'OPTIN_PHRASE' => $MC->msg(
'Yes Email List'));
3805 $reply_arr[
'REQUIREUPD'][][
'REQUPD'] = $upd_req;
3808 if ((($HB_ENV[
'forceupdate'] & 8) == 8 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 8) == 8) {
3810 $maymust = (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_ALIAS_REQ']) == $GLOBALS[
'CU2_ALIAS_REQ'] ?
'must' :
'may');
3811 $aliaslabel = $MC->combo_msg(
'Username Set', 0,
'#MAYMUST#',
"$maymust");
3812 $upd_req = array(
'UPDPHRASEID' =>
'USERALIAS',
3813 'UPDPHRASEREQ' => ($HB_ENV[
'alias'] ==
'NONE' ?
'NO' : $HB_ENV[
'alias']),
3814 'UPDPHRASELABEL' => htmlentities($aliaslabel, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
3815 if (($HB_ENV[
'requpdate'] & 8) == 8) {
3816 # 'on-demand' update - send current user alias 3817 $upd_req[
'CURRENTALIAS'] = htmlentities($HB_ENV[
'useralias'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
3819 $reply_arr[
'REQUIREUPD'][][
'REQUPD'] = $upd_req;
3821 if ((($HB_ENV[
'forceupdate'] & 16) == 16 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 16) == 16) {
3823 $upd_req = array(
'UPDPHRASEID' =>
'PHONES',
3824 'UPDCONFLABEL' =>
'This confidence word is used to identify and prevent phishing attempts when you access home banking through the web. It is not used in this app, but you are asked to set it now in case you later access your account through the web.',
3825 'UPDCONFIDENCE' => htmlentities($HB_ENV[
'confidence'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
3826 # add array entries for phone numbers 3827 $upd_req[
'MOBILE'][
'MAXLIMIT'] = MAX_PHONES;
3828 $upd_req[
'MOBILE'][
'UPDMBLLABEL'] = $MC->msg(
'TXT Enabled');
3829 $phones = GetUserPhones($CU, $UID, $HB_ENV);
3830 if (is_array($phones[
'mobile'])) {
3831 foreach ($phones[
'mobile'] as $ph => $phnum) {
3833 $upd_req[
'MOBILE'][][
'PHONE'] = preg_replace(
'/\D/',
'', $phnum);
3836 $reply_arr[
'REQUIREUPD'][][
'REQUPD'] = $upd_req;
3842 function MakeUserkey($CU, $MEMBER, $CAUTH) {
3843 global $apptokenkey;
3844 $appexpires = time() + 900; # 15 minutes
3845 $apphash = MD5($apptokenkey . MD5(join(
':', array($apptokenkey, $appexpires, $CU, $MEMBER, $CAUTH))));
3846 # $mytoken="H=$hash&E=$expires&A=$cauth_member&C=$current_member"; 3848 $apptoken = urlencode(
"H=$apphash&E=$appexpires&A=$MEMBER&C=$CAUTH");
3852 function CheckUserkey($CU, $USERKEY, $apptokenkey) {
3855 $result = array(
'Status' => array(
'Code' =>0,
'Message' =>
'Success'));
3857 $apptokarr = array();
3858 parse_str(urldecode($USERKEY), $apptokarr);
3860 if ($apptokarr[
'E'] < time()) {
3861 throw new Exception(
"Invalid Credentials (Expired Token) " . __LINE__,15510);
3864 if (is_null($apptokarr[
'E']) || is_null($apptokarr[
'A']) || is_null($apptokarr[
'H'])) {
3865 throw new Exception(
"Invalid Credentials (Partial Token) " . __LINE__,15510);
3867 # if no C= value, assume oldstyle userkey 3868 # and set member as A= value so hash works 3869 # for odyssey A & C are swapped 3870 # A is Uid, C is primary account 3872 if (is_null($apptokarr[
'C'])) {
3873 $CAUTH = $apptokarr[
'A'];
3875 $CAUTH = $apptokarr[
'C'];
3877 $MEMBER = $apptokarr[
'A'];
3878 $EXPIRES = $apptokarr[
'E'];
3879 $hash = MD5($apptokenkey .
3880 MD5(join(
':', array($apptokenkey, $EXPIRES, $CU, $MEMBER, $CAUTH))));
3881 if ($apptokarr[
'H'] != $hash) {
3882 throw new Exception(
"Invalid Credentials (Corrupted Token) " . __LINE__,15510);
3884 }
catch (Exception $e) {
3885 $result = array(
'Status' => array(
'Code' => $e->getCode(),
'Message' =>
'Failed ' . $e->getMessage()));
3893 function MakeSessionUserkey( $pHBEnv ) {
3894 global $gSavedUserkey;
3898 $newCe = $now + $pHBEnv[
'SYSENV'][
'ticket'][
'expires'];
3900 $newSet =
"Ctime={$newCtime}&Ce={$newCe}";
3902 return urlencode( BuildSessionTicketStr($pHBEnv, $gSavedUserkey, $newSet ) );
3909 function CheckSessionUserkey( $pHBEnv, $sessionStr ) {
3911 $result = array(
'Status' => array(
'Code' =>0,
'Message' =>
'Success'));
3915 if ( strpos( $sessionStr,
"Cu%3D" ) !==
false ) {
3916 $sessionStr = urldecode( $sessionStr );
3919 $returnArray = CheckSessionTicket( $pHBEnv, $sessionStr );
3920 if ( !is_array( $returnArray[
'result'] ) ) {
3923 throw new Exception(
"Session Expired", 15510 );
3926 $result[
"data"] = $returnArray[
"result"];
3927 }
catch (Exception $e) {
3928 $result = array(
'Status' => array(
'Code' => $e->getCode(),
'Message' =>
'Failed ' . $e->getMessage()));
3934 function CleanWordQuotes($instring) {
3976 $instring = str_replace($search, $replace, $instring);
3980 function Load_HB_ENV($dbh, $CU, $MEMBER, &$HB_ENV, $CFGFLAG=0) {
3982 $username = trim($MEMBER);
3983 $live = $HB_ENV[
'live'];
3985 # on first (method MFA) login, MEMBER will have username 3986 # after that, (method SSO) MEMBER will have USERID 3989 # AuthMode=MFQ Multi-factor w/questions 3990 $qby =
"cuuser.user_name ilike '" . prep_save($MEMBER) .
"' ";
3998 $sqluser =
"SELECT cuuser.user_id as user_id, trim(cuuser.user_name) as user_name, 3999 trim(cuuser.passwd) as password, forcechange, forceremain, failedremain, 4000 pwchange, trim(email) as email, egenl_flag, trim(confidence) as confidence, 4001 cuuser.user_id as cuuser_id, 4002 cuuser.group_id as cuuser_group_id, priorlogin, failedlogin, msg_tx, 4003 userflags & {$GLOBALS['MEM_FORCE_RESET']}::int4 as mem_force_reset, userflags, 4004 histdays, gracelimit, trmemomaxlen, cuadmin.tz, mfaquest, primary_account 4006 FROM {$CU}user as cuuser 4007 JOIN cuadmin on cuadmin.cu = '" . prep_save($CU) .
"' 4010 $mbr_sth = db_query($sqluser, $dbh);
4011 if (db_num_rows($mbr_sth) == 0) {
4015 $drow = db_fetch_array($mbr_sth, 0);
4019 $drow = db_fetch_array($mbr_sth, 0);
4020 $HB_ENV[
'Cu'] = $CU;
4021 $HB_ENV[
'cu'] = $CU;
4022 $HB_ENV[
'chome'] = strtolower($CU);
4023 $HB_ENV[
'Uid'] = $drow[
'user_id'];
4024 $HB_ENV[
'Cn'] = $drow[
'user_name'];
4025 $HB_ENV[
'username'] = $drow[
'user_name'];
4026 $HB_ENV[
'user_name'] = $drow[
'user_name'];
4027 $HB_ENV[
'confidence'] = $drow[
'confidence'];
4029 $HB_ENV[
'Ml'] = $drow[
'email'];
4030 $HB_ENV[
'savemail'] = $drow[
'email'];
4031 $HB_ENV[
'egenl_flag'] = urlencode($drow[
'egenl_flag']);
4032 $HB_ENV[
'password'] = $drow[
'password'];
4033 $HB_ENV[
'userflags'] = $drow[
'userflags'];
4034 $HB_ENV[
'failedremain'] = $drow[
'failedremain'];
4035 $HB_ENV[
'Ffchg'] = $drow[
'forcechange'];
4036 $HB_ENV[
'Ffremain'] = $drow[
'forceremain'];
4037 $HB_ENV[
'dbforceremain'] = $drow[
'forceremain'];
4038 $HB_ENV[
'Ffreset'] = (is_null($drow[
'mem_force_reset']) ? 0 : $drow[
'mem_force_reset']);
4040 $HB_ENV[
'Fmsg_tx'] = (is_null($drow[
'msg_tx']) ? 0 : $drow[
'msg_tx']);
4041 $HB_ENV[
'cfgflag'] = $CFGFLAG; #
set cfgflag
if CFGFLAG
if passed
4042 $HB_ENV[
'Fverifyml'] = ($drow[
'msg_tx'] & 512);
4043 # mammoth data calls use Clw; odyssey switched to livewait so define both 4044 $HB_ENV[
'Clw'] = ((is_null($HB_ENV[
'livewait']) || $HB_ENV[
'livewait'] == 0) ? 300 : $HB_ENV[
'livewait']);
4045 $HB_ENV[
'lastupdate'] = (empty($drow[
'lastupdate']) ?
"Unknown" : urlencode(trim($drow[
'lastupdate'])));
4046 $HB_ENV[
'pwchange'] = (is_null($drow[
'pwchange']) ? date(
'Ymd') : $drow[
'pwchange']);
4048 $HB_ENV[
'HCUPOST'] = array(); #
set empty parameter array
4049 if ($HB_ENV[
'flagset2'] & $GLOBALS[
'CU2_ALIAS_REQ']) {
4059 $HB_ENV[
'alias'] = $alias; #
this shouldn
't be needed - oh but it is 4060 # alias is always allowed 4061 # required means must start with non-digit 4062 $HB_ENV['Fset
'] = $HB_ENV['flagset
']; 4063 $HB_ENV['Fset2
'] = $HB_ENV['flagset2
']; 4064 $HB_ENV['Fset3
'] = $HB_ENV['flagset3
']; 4066 // * Create the MFA Quest Array (or set empty if Legacy, which shouldn't happen in Odyssey...)
4067 $HB_ENV[
'MFA'] = ($HB_ENV[
'cver'] ==
'L' ? array() : HCU_MFADecode(HCU_JsonDecode($drow[
'mfaquest'])));
4068 $HB_ENV[
'mfaquest'] = $drow[
'mfaquest'];
4069 $HB_ENV[
'savecqid'] = $HB_ENV[
'MFA'][
'challenge'];
4070 $HB_ENV[
'chcount'] = $HB_ENV[
'MFA'][
'mfacount'];
4073 if ($HB_ENV[
'Ffchg'] ==
'Y') {
4074 $FORCEUPDATE += 1; #password
4076 if ($HB_ENV[
'Fverifyml'] == 512 || $HB_ENV[
'Ml'] ==
'') {
4077 $FORCEUPDATE += 2; # email
4080 if ( intval($HB_ENV[
'flagset3'] & $GLOBALS[
'CU3_MFA_AUTHCODE']) == 0 &&
4081 ( $HB_ENV[
'Ffreset'] == 2 || $HB_ENV[
'chcount'] < $HB_ENV[
'cu_chgqst_count'] ) ) {
4082 $FORCEUPDATE += 4; #challenge questions
4085 if (($HB_ENV[
'flagset2'] & $GLOBALS[
'CU2_ALIAS_REQ']) && !Check_Member_UseAlias($HB_ENV[
'user_name'])) {
4089 if ( intval($HB_ENV[
'flagset3'] & $GLOBALS[
'CU3_MFA_AUTHCODE']) > 0 && $HB_ENV[
'Ffreset'] == 2 ) {
4090 $FORCEUPDATE += 16; #phone numbers
4093 $HB_ENV[
'forceupdate'] = $FORCEUPDATE;
4094 $HB_ENV[
'allowupdate'] = 11; # password, email, and user_name update always allowed
4095 $HB_ENV[
'allowupdate'] += (intval($HB_ENV[
'flagset3'] & $GLOBALS[
'CU3_MFA_AUTHCODE']) == 0 ? 4 : 0); # can
't update Challenge Questions if SAC in use 4096 $HB_ENV['allowupdate
'] += (intval($HB_ENV['flagset3
'] & $GLOBALS['CU3_MFA_AUTHCODE
']) == 0 ? 0 : 16); # can only update contact phone if SAC in use 4098 $HB_ENV['requpdate
'] = 0; # assume at first this is not a 'getsettings
' request 4100 if ( $HB_ENV['failedremain
'] <= 0 || 4101 ( ($HB_ENV['forceupdate
'] & 29) > 0 && $HB_ENV['Ffremain
'] <= 0 ) 4104 $HB_ENV['lockedacct
'] = 1; 4106 $HB_ENV['lockedacct
'] = 0; 4109 # eventually this will come from a new column in cuadmin 4111 $HB_ENV['AppTimeout
'] = intval($HB_ENV['SYSENV
']['ticket
']['expires
'] * .8); 4112 $priorLogin = (trim(HCU_array_key_value('priorlogin
',$drow))=='' ? 'None
' : $drow['priorlogin
']); 4114 $HB_ENV['Fplog
'] = ($priorLogin == 'None
' ? '' : (strftime("%D %R", mktime( 4115 substr($priorLogin, 11, 2), substr($priorLogin, 14, 2), substr($priorLogin, 17, 2), substr($priorLogin, 5, 2), substr($priorLogin, 8, 2), substr($priorLogin, 0, 4))))); 4116 $failedlogin = (trim(HCU_array_key_value('failedlogin
',$drow))=='' ? 'None
' : $drow['failedlogin
']); 4117 $HB_ENV['Fflog
'] = ($failedlogin == 'None
' ? '' : (strftime("%D %R", mktime( 4118 substr($failedlogin, 11, 2), substr($failedlogin, 14, 2), substr($failedlogin, 17, 2), substr($failedlogin, 5, 2), substr($failedlogin, 8, 2), substr($failedlogin, 0, 4))))); 4119 // needed for building up URLs for webviews 4120 $HB_ENV["cuquery"] = http_build_query( array( "cu" => $CU ) ); 4122 $tz = trim( HCU_array_key_value( "tz", $drow ) ); 4123 $HB_ENV['tz
'] = $tz == "" ? "US/Mountain" : ((strpos($tz,"/") === false ) ? "US/$tz" : $tz); 4126 function fullFeed($dbh, $HB_ENV, $DTSTART, $DTEND, $BALONLY, $SENDAS, $KEYACCTID, $recent, $SENDKEY) { 4130 if (empty($DTSTART) || !sqlmdy($DTSTART)) { 4131 throw new Exception("Invalid Start Date $DTSTART", 2090); 4133 $sqlstart = sqlmdy($DTSTART); 4136 if (!empty($DTEND) && !sqlmdy($DTEND)) { 4137 throw new Exception('Invalid End Date
', 2090); 4141 $sqlnone = date("Ymd", time() + (24 * 60 * 60)); # tomorrow 4143 $balances = Get_Balances($dbh, $HB_ENV); 4145 $expires = mktime(date("H"), date("i"), date("s"), date("m") + 3, date("d"), date("Y")); 4146 // $apptoken = MakeUserkey($HB_ENV['Cu
'], $HB_ENV['username
'], $HB_ENV['Uid
']); 4147 $apptoken = MakeSessionUserkey( $HB_ENV ); 4148 $cookiename = Return2FactorName($HB_ENV['Cu
'], Get2FactorKeyString(), trim($HB_ENV['Cn
'])); 4150 $now = date('YmdHis
'); 4152 $postedDate = HCU_array_key_value("lastupdate", $HB_ENV); 4153 if ( $postedDate != "Unknown" && $postedDate != 1 && strlen( $postedDate ) > 0 ) { 4154 $cuDateTime = new DateTime( $postedDate ); 4155 $cuDateTime->setTimezone(new DateTimeZone($HB_ENV["tz"])); 4156 $displayCUTime = $cuDateTime->format("m/d/Y g:ia T"); 4158 $displayCUTime = $postedDate; 4162 // note: $HB_ENV["lastupdate"] is updated in Get_Balances() 4163 $reply_arr = array('STATUS
' => array('CODE
' =>0,'SEVERITY
' => 'INFO
'), 4164 'DTSERVER
' => date('YmdHis
'), 4165 'LASTUPDATE
' => $displayCUTime, 4166 'LOGINPRIOR
' => $HB_ENV["Fplog"], 4167 'LOGINFAIL
' => $HB_ENV["Fflog"], 4168 'MEMBER
' => $HB_ENV['Uid
'], 4169 'SELECTED_MEMBER
' => $HB_ENV['Uid
'], 4170 'USERKEY
' => $apptoken, 4171 'TIMEOUT
' => $HB_ENV['AppTimeout
']); 4172 if (HCU_array_key_value('stale
',$HB_ENV) == 1) { 4173 $reply_arr['STALE
'] = 'YES
'; 4176 if (is_array($SENDKEY)) { 4177 foreach ($SENDKEY as $key => $value) { 4178 $reply_arr[$key] = $value; 4182 $featureaccts = array(); 4183 foreach (array('ES
','BP
','RDC
') as $SPEEDBUMP_FEATURE) { 4184 $featureaccts[$SPEEDBUMP_FEATURE] = array(); 4185 $accountList = Get_FeatureAccounts( $HB_ENV, $SPEEDBUMP_FEATURE, "A" ); 4186 foreach ($accountList as $acct) { 4187 // get the account and hash together 4188 $encryptedAccount = hcu_encrypturl($acct, $HB_ENV['historyHash
']); 4189 $accountInfo = array( "MBRACCT" => $acct, "ACCOUNT" => array( "MBRACCT" => $acct, "ENCRYPTED" => $encryptedAccount ) ); 4190 // $featureaccts[$SPEEDBUMP_FEATURE][]['MBRACCT
'] = $acct; 4191 $featureaccts[$SPEEDBUMP_FEATURE][] = $accountInfo; 4194 $reply_arr['FEATUREACCTS
'] = $featureaccts; 4196 // $mbracctlist = Get_UserAccounts($dbh, $HB_ENV['Cu
'], $HB_ENV['Uid
']); 4197 // $reply_arr['MBRACCTLIST
'] = array(); 4199 // if(count($mbracctlist['data
'])) { 4200 // foreach ($mbracctlist['data
'] as $mbracct) { 4201 // $reply_arr['MBRACCTLIST
'][]['MBRACCT
'] = $mbracct; 4206 * all the conversion tools I have tried convert the raw xml into entity-encoded 4207 * so this is an ugly hack -- just put this distinctive string in, 4208 * and replace it with the actual menu text before sending the response 4210 * this code, and the companion hack in send_response(), will be removed 4211 * once we can generate an app menu on the server side. 4213 // if (HCU_array_key_exists('menu
',$SENDKEY)) { 4214 // $reply_arr['menu
'] = HCU_array_key_value('menu
',$SENDKEY); 4217 if (count($balances['dp
']) && (empty($KEYACCTID) || (!empty($KEYACCTID) && array_key_exists($KEYACCTID, $balances['dp
'])))) { 4218 # for each $balances['dp
'] Get_History & print 4219 foreach ($balances['dp
'] as $balkey => $balinfo) { 4220 if ((!empty($KEYACCTID)) && $balkey != $KEYACCTID) { 4223 // filter out any not allowing view balances 4224 if ( !HCU_array_key_value('view_balances
', $balinfo) ) { 4229 $desc = htmlspecialchars($balinfo['description
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 4230 $displaydesc = htmlspecialchars($balinfo['displaydesc
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 4231 $atype = ($balinfo['certnumber
'] == "0" ? $balinfo['accounttype
'] : "{$balinfo['accounttype
']}_{$balinfo['certnumber
']}"); 4232 $atype = htmlspecialchars(trim($atype), ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 4234 switch ($balinfo['deposittype
']) { 4236 $acttype = "CHECKING"; 4238 case "C": # Certificates 4239 $acttype = "INVESTMENT"; 4241 case "I": # IRA accounts 4242 $acttype = "RETIREMENT"; 4246 $acttype = "SAVINGS"; 4252 $itm_arr['STMTTRNRS
'] = array('TRNUID
' => 0, 4253 'STATUS
' => array('CODE
' =>0,'SEVERITY
' => 'INFO
')); 4255 $itm_arr['STMTTRNRS
']['STMTRS
'] = array('CURDEF
' => 'USD
', 4256 'BANKACCTFROM
' => array( 4257 'BANKID
' => $HB_ENV['rt
'], 4258 'ACCTID
' => $balkey, 4259 'ACCTTYPE
' => $acttype, 4260 'DESCRIPTION
' => $desc)); 4261 if ("$displaydesc" > '') { 4262 $itm_arr['STMTTRNRS
']['STMTRS
']['BANKACCTFROM
']['DISPLAYDESC
'] =$displaydesc; 4267 $histXML = dpHistXML($dbh, $HB_ENV, $balkey, $balinfo, $sqlstart, $sqlend, $recent); 4268 if ($histXML['Status
'] !== 'Success
') { 4269 throw new Exception('DP History Error
', 7601); # couldn't
get dp history
4271 $itm_arr[
'STMTTRNRS'][
'STMTRS'][
'BANKTRANLIST'] = $histXML[
'HISTarr'];
4274 $itm_arr[
'STMTTRNRS'][
'STMTRS'][
'BANKTRANLIST'] = array(
4275 'DTSTART' =>
"${sqlnone}000000",
4276 'DTEND' =>
"${sqlnone}000000");
4279 $itm_arr[
'STMTTRNRS'][
'STMTRS'][
'LEDGERBAL'] = array(
4280 'BALAMT' => $balinfo[
'currentbal'],
4282 if (($HB_ENV[
'Fset'] & $GLOBALS[
'CU_SHOWAVAILABLE']) == $GLOBALS[
'CU_SHOWAVAILABLE']) {
4283 $itm_arr[
'STMTTRNRS'][
'STMTRS'][
'AVAILBAL'] = array(
4284 'BALAMT' => $balinfo[
'availablebal'],
4288 $itm_arr[
'STMTTRNRS'][
'STMTRS'][
'EXTRAINFO'] = array(
4290 'KEYACCTID' => $balkey,
4291 'MBRACCT' => $balinfo[
'accountnumber'],
4292 'YTDINTEREST' => $balinfo[
'ytdinterest'],
4293 'LYRINTEREST' => $balinfo[
'lastyrinterest']);
4294 if ($acttype ==
"CHECKING") {
4295 $itm_arr[
'STMTTRNRS'][
'STMTRS'][
'EXTRAINFO'][
'MICRACCOUNT'] = $balinfo[
'micraccount'];
4297 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SHOWHOLD'])== $GLOBALS[
'CU2_SHOWHOLD']) {
4298 $itm_arr[
'STMTTRNRS'][
'STMTRS'][
'EXTRAINFO'][
'HOLDTOTAL'] = $balinfo[
'holdtotal'];
4300 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SHOWPEND'])== $GLOBALS[
'CU2_SHOWPEND']) {
4301 $itm_arr[
'STMTTRNRS'][
'STMTRS'][
'EXTRAINFO'][
'PENDTOTAL'] = $balinfo[
'pendtotal'];
4303 # parse through each key &, if not already loaded into result, push it in there 4304 foreach ($balinfo as $bkey => $bval) {
4311 case 'availablebal':
4312 case 'accountnumber':
4314 case 'lastyrinterest':
4320 $upperkey = strtoupper($bkey);
4321 $itm_arr[
'STMTTRNRS'][
'STMTRS'][$upperkey] = htmlspecialchars($bval, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
4325 $reply_arr[
'BANKMSGSRSV1'][] = $itm_arr;
4331 # If CU2_SPEC18, try to get credit card loans 4332 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SPEC18']) == $GLOBALS[
'CU2_SPEC18']) {
4334 if (HCU_array_key_exists(
'cc',$balances) && count($balances[
'cc']) && (empty($KEYACCTID) || (!empty($KEYACCTID) && array_key_exists($KEYACCTID, $balances[
'cc'])))) {
4336 foreach ($balances[
'cc'] as $balkey => $balinfo) {
4337 if ((!empty($KEYACCTID)) && $balkey != $KEYACCTID) {
4341 if ( !HCU_array_key_value(
'view_balances', $balinfo) ) {
4345 $nextduedate = $balinfo[
'nextduedate'];
4346 $creditlimit = $balinfo[
'creditlimit'];
4348 $desc = $balinfo[
'description'];
4349 $desc = htmlspecialchars(
"$desc", ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
4350 $displaydesc = $balinfo[
'displaydesc'];
4351 $displaydesc = htmlspecialchars(
"$displaydesc", ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
4352 $loan = $balinfo[
'loan'];
4353 $balance = $balinfo[
'currentbal'];
4354 $creditlimit = $balinfo[
'creditlimit'];
4355 $available = $creditlimit - $balance;
4356 $available = ($available < 0 ?
"" : $available);
4357 $cur_avail = (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_CALL_CCAVAIL']) == $GLOBALS[
'CU2_CALL_CCAVAIL'] ?
4358 "Call" : $available);
4364 $itm_arr[
'CCSTMTTRNRS'][
'CCSTMTRS'] = array(
'CURDEF' =>
'USD',
4365 'CCACCTFROM' => array(
4366 'ACCTID' => $balkey,
4367 'DESCRIPTION' => $desc));
4368 if (
"$displaydesc" >
'') {
4369 $itm_arr[
'CCSTMTTRNRS'][
'CCSTMTRS'][
'CCACCTFROM'][
'DISPLAYDESC'] =$displaydesc;
4371 if (trim($balinfo[
'hisinfo']) >
'' && strtolower(trim($balinfo[
'hisinfo'])) !=
'homecu') {
4372 $itm_arr[
'CCSTMTTRNRS'][
'CCSTMTRS'][
'CCACCTFROM'][
'HISTORYURL'] = urlencode($balinfo[
'hisinfo']);
4376 $histXML = ccHistXML($dbh, $HB_ENV, $balkey, $balinfo, $sqlstart, $sqlend, $recent);
4377 if ($histXML[
'Status'] !==
'Success') {
4378 throw new Exception(
'CC History Error', 7602); # couldn
't get cc history 4380 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['BANKTRANLIST
'] = $histXML['HISTarr
']; 4383 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['BANKTRANLIST
'] = array( 4384 'DTSTART
' => "${sqlnone}000000", 4385 'DTEND
' => "${sqlnone}000000"); 4388 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['LEDGERBAL
'] = array( 4389 'BALAMT
' => $balance, 4391 if ($cur_avail > 0) { 4392 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['AVAILBAL
'] = array( 4393 'BALAMT
' => $cur_avail, 4396 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['EXTRAINFO
'] = array( 4398 'KEYACCTID
' => $balkey, 4399 'MBRACCT
' => $balinfo['accountnumber
']); 4401 if ($HB_ENV['live
'] && ($HB_ENV['Fset2
'] & $GLOBALS['CU2_SHOWCCSB
']) == $GLOBALS['CU2_SHOWCCSB
'] && ($HB_ENV['Fset2
'] & $GLOBALS['CU2_CC18NOINFO
']) != $GLOBALS['CU2_CC18NOINFO
']) { 4402 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['EXTRAINFO
']['STMNTBAL
'] = HCU_array_key_value('payoff
',$balinfo); 4404 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['EXTRAINFO
']['PAYAMOUNT
'] = $balinfo['paymentamount
']; 4406 if (($HB_ENV['Fset
'] & $GLOBALS['CU_HIDELOANDATE
']) != $GLOBALS['CU_HIDELOANDATE
']) { 4407 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['EXTRAINFO
']['NEXTDUE
'] = $nextduedate; 4409 if (HCU_array_key_exists("interestrate", $balinfo)) { 4410 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['EXTRAINFO
']['INTERESTRATE
'] = $balinfo['interestrate
']; 4412 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['EXTRAINFO
']['CREDITLIMIT
'] = $creditlimit; 4413 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['EXTRAINFO
']['YTDINTEREST
'] = $balinfo['ytdinterest
']; 4414 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
']['EXTRAINFO
']['LYRINTEREST
'] = $balinfo['lastyrinterest
']; 4416 # parse through each key &, if not already loaded into result, push it in there 4417 foreach ($balinfo as $bkey => $bval) { 4427 case 'accountnumber
': 4429 case 'paymentamount
': 4430 case 'interestrate
': 4432 case 'lastyrinterest
': 4435 $upperkey = strtoupper($bkey); 4436 $itm_arr['CCSTMTTRNRS
']['CCSTMTRS
'][$upperkey] = htmlspecialchars($bval, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 4441 $reply_arr['CREDITCARDMSGSRSV1
'][] = $itm_arr; 4448 if ((HCU_array_item_count("ln", $balances) > 0) && (empty($KEYACCTID) || (!empty($KEYACCTID) && array_key_exists($KEYACCTID, $balances['ln
'])))) { 4450 foreach ($balances['ln
'] as $balkey => $balinfo) { 4451 if ((!empty($KEYACCTID)) && $balkey != $KEYACCTID) { 4454 // filter out any not allowing view balances 4455 if ( !HCU_array_key_value('view_balances
', $balinfo) ) { 4461 $balance = $balinfo['currentbal
']; 4462 $loan = $balinfo['loan
']; 4463 $desc = htmlspecialchars($balinfo['description
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 4464 $displaydesc = htmlspecialchars($balinfo['displaydesc
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 4465 $payoff = HCU_array_key_value('payoff
',$balinfo); 4466 $nextduedate = $balinfo['nextduedate
']; 4467 $creditlimit = $balinfo['creditlimit
']; 4470 $itm_arr['LOANSTMTTRNRS
']['LOANSTMTRS
'] = array('CURDEF
' => 'USD
', 4471 'LOANACCTFROM
' => array( 4472 'LOANACCTID
' => $balkey, 4473 'LOANACCTTYPE
' => 'CONSUMER
', 4474 'DESCRIPTION
' => $desc)); 4475 if ("$displaydesc" > '') { 4476 $itm_arr['LOANSTMTTRNRS
']['LOANSTMTRS
']['LOANACCTFROM
']['DISPLAYDESC
'] =$displaydesc; 4478 if (trim($balinfo['hisinfo
']) > '' && strtolower(trim($balinfo['hisinfo
'])) != 'homecu
') { 4479 $itm_arr['LOANSTMTTRNRS
']['LOANSTMTRS
']['LOANACCTFROM
']['HISTORYURL
'] = urlencode($balinfo['hisinfo
']); 4483 $histXML = lnHistXML($dbh, $HB_ENV, $balkey, $balinfo, $sqlstart, $sqlend, $recent); 4484 if ($histXML['Status
'] !== 'Success
') { 4485 throw new Exception('LN History Error
', 7603); # couldn't
get ln history
4487 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'LOANTRANLIST'] = $histXML[
'HISTarr'];
4490 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'LOANTRANLIST'] = array(
4491 'DTSTART' =>
"${sqlnone}000000",
4492 'DTEND' =>
"${sqlnone}000000");
4494 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'PRINBAL'] = array(
4495 'BALAMT' => $balance,
4498 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'EXTRAINFO'] = array(
4500 'KEYACCTID' => $balkey,
4501 'MBRACCT' => $balinfo[
'accountnumber'],
4502 'PAYOFF' => $payoff,
4503 'PAYAMOUNT' => $balinfo[
'paymentamount']);
4505 if (($HB_ENV[
'Fset'] & $GLOBALS[
'CU_HIDELOANDATE']) != $GLOBALS[
'CU_HIDELOANDATE']) {
4506 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'EXTRAINFO'][
'NEXTDUE'] = $nextduedate;
4509 if (HCU_array_key_exists(
"interestrate", $balinfo)) {
4510 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'EXTRAINFO'][
'INTERESTRATE'] = $balinfo[
'interestrate'];
4512 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'EXTRAINFO'][
'CREDITLIMIT'] = $creditlimit;
4513 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'EXTRAINFO'][
'YTDINTEREST'] = $balinfo[
'ytdinterest'];
4514 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][
'EXTRAINFO'][
'LYRINTEREST'] = $balinfo[
'lastyrinterest'];
4516 # parse through each key &, if not already loaded into result, push it in there 4517 foreach ($balinfo as $bkey => $bval) {
4527 case 'accountnumber':
4529 case 'paymentamount':
4530 case 'interestrate':
4532 case 'lastyrinterest':
4535 $upperkey = strtoupper($bkey);
4536 $itm_arr[
'LOANSTMTTRNRS'][
'LOANSTMTRS'][$upperkey] = htmlspecialchars($bval, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
4541 $reply_arr[
'LOANMSGSRSV1'][] = $itm_arr;
4545 }
catch (Exception $e) {
4546 $code = $e->getCode();
4547 $message = $e->getMessage();
4549 $reply_arr = array(
'STATUS' => array(
'CODE' => $code,
'SEVERITY' =>
'ERROR'),
4550 'MESSAGE'=> array(
'ERR' => htmlspecialchars($message, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE),
'ERRNO' => 999,
'ERRSTAT' =>
'FAIL'));
4558 function dpHistXML($dbh, $HB_ENV, $balkey, $balinfo, $sqlstart, $sqlend, $recent) {
4561 $reply_arr = array();
4562 $history = Get_History($dbh, $HB_ENV, $balkey, $sqlstart, $sqlend);
4563 # opening tags for transaction list 4564 $reply_arr[
'DTSTART'] =
"${sqlstart}000000";
4565 $reply_arr[
'DTEND'] =
"${sqlend}235959";
4567 if ( HCU_array_key_exists( $balkey , $history)) {
4568 foreach ($history[$balkey] as $tnum => $detl) {
4572 $tranamount = $detl[
'amount'];
4573 $tranamount = str_replace(
",",
"", str_replace(
"$",
"", $tranamount));
4574 $tranamount = sprintf(
"%.2f", $tranamount);
4575 $trbal = $detl[
'balance'];
4576 $trbal = str_replace(
",",
"", str_replace(
"$",
"", $trbal));
4577 $trbal = sprintf(
"%.2f", $trbal);
4578 $check = (HCU_array_key_exists(
'checkno' , $detl) ? $detl[
'checkno'] : 0);
4579 $trandesc = $detl[
'description'];
4580 if ($trandesc <
" " && $check != 0) {
4583 $trandesc = (preg_replace(
"/<BR>/",
" ", $trandesc));
4584 $trandesc = (preg_replace(
"/ /",
" ", $trandesc));
4585 $longdesc = htmlspecialchars($trandesc, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
4586 $shortdesc = substr(htmlspecialchars($trandesc, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE), 0, 31);
4587 $shortdesc = preg_replace(
'/&[^;]*$/',
'', $shortdesc);
4588 $shortdesc = (trim($shortdesc) ==
'' ?
'.' : $shortdesc);
4590 if ($tranamount < 0) {
4591 if ($balinfo[
'deposittype'] ==
'Y' and $check != 0) {
4597 $trntype =
'CREDIT';
4599 $itm_arr[
'TRNTYPE'] = $trntype;
4600 $itm_arr[
'DTPOSTED'] = $detl[
'date'];
4601 # DTUSER not needed for 211? 4602 $itm_arr[
'DTUSER'] = $detl[
'date'];
4603 $itm_arr[
'TRNAMT'] = $tranamount;
4604 $itm_arr[
'RUNBAL'] = $trbal;
4605 $itm_arr[
'FITID'] = $detl[
'traceno'];
4606 if ($balinfo[
'deposittype'] ==
'Y' and $check != 0) {
4607 $itm_arr[
'CHECKNUM'] = $check;
4608 if (!empty($detl[
'ckitem']) && !empty($detl[
'ckhash'])) {
4609 $itm_arr[
'CKITEM'] = $detl[
'ckitem'];
4610 $itm_arr[
'CKHASH'] = $detl[
'ckhash'];
4613 $itm_arr[
'NAME'] = $shortdesc;
4614 if (strlen($longdesc) > 0) {
4615 $itm_arr[
'MEMO'] = $longdesc;
4619 $tranDate = preg_replace(
"/\D/",
"", $detl[
'date'] );
4620 if ($tranDate < $recent) {
4621 $reply_arr[][
'STMTTRN']=$itm_arr;
4623 $reply_arr[][
'RECENTTRN']=$itm_arr;
4627 # closing tags for transaction list 4629 if ($HB_ENV[
'live'] == 0) {
4630 $pending = Get_ReqDetails($dbh, $HB_ENV, $balkey);
4631 # Get_ReqDetails returns txdesc already UTF-encoded. Problem? 4632 if ( HCU_array_key_exists(
'acctlist' , $pending) && HCU_array_key_exists( $balkey , $pending[
'acctlist']) ) {
4633 foreach ($pending[
'acctlist'][$balkey] as $tnum => $detl) {
4635 $itm_arr = array(
'TRACENO' => $detl[
'id'],
4636 'DTREQUEST' => $detl[
'postdate'],
4637 'TRNAMT' => $detl[
'amount'],
4638 'TRNDESC' => htmlspecialchars($detl[
'txdesc'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4640 $reply_arr[
'TXNPENDING'][][
'REQUEST']= $itm_arr;
4645 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SHOWPEND']) == $GLOBALS[
'CU2_SHOWPEND']) {
4646 $pending = Get_PendDetails($dbh, $HB_ENV, $balkey);
4647 if ( HCU_array_key_exists( $balkey , $pending)) {
4648 foreach ($pending[$balkey] as $tnum => $detl) {
4650 $itm_arr = array(
'TRACENO' => $detl[
'traceno'],
4651 'DTREQUEST' => $detl[
'postdate'],
4652 'TRNAMT' => $detl[
'amount'],
4653 'TRNDESC' => htmlspecialchars($detl[
'description'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4655 $reply_arr[
'TXNPENDING'][][
'ACHWAREHOUSE'] = $itm_arr;
4659 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SHOWHOLD']) == $GLOBALS[
'CU2_SHOWHOLD']) {
4660 $pending = Get_HoldDetails($dbh, $HB_ENV, $balkey);
4661 if ( HCU_array_key_exists( $balkey , $pending)) {
4662 foreach ($pending[$balkey] as $tnum => $detl) {
4664 $itm_arr = array(
'TRACENO' => $detl[
'traceno'],
4665 'DTREQUEST' => $detl[
'postdate'],
4666 'TRNAMT' => $detl[
'amount'],
4667 'TRNDESC' => htmlspecialchars($detl[
'description'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4669 $reply_arr[
'TXNPENDING'][][
'PREAUTH'] = $itm_arr;
4673 if (!HCU_array_key_exists(
'TXNPENDING',$reply_arr)) {
4674 $reply_arr[
'TXNPENDING']=array();
4677 $result = array(
'Status' =>
'Success',
'HISTarr' => $reply_arr,
'XMLstr' => assocArrayToXML($reply_arr,
'BANKTRANLIST', 0));
4678 }
catch (Exception $e) {
4679 $result = array(
'Status' =>
'Failed ' . $e->getMessage(),
'HISTarr' => array(),
'XMLstr' =>
'');
4684 function ccHistXML($dbh, $HB_ENV, $balkey, $balinfo, $sqlstart, $sqlend, $recent) {
4686 $reply_arr = array();
4689 $incchist = (trim(strtoupper($balinfo[
'hisinfo'])) ==
'HOMECU' ? 1 : 0);
4692 $history = Get_History($dbh, $HB_ENV, $balkey, $sqlstart, $sqlend);
4693 $reply_arr[
'DTSTART'] =
"${sqlstart}000000";
4694 $reply_arr[
'DTEND'] =
"${sqlend}235959";
4696 if (count($history[$balkey])) {
4697 foreach ($history[$balkey] as $tnum => $detl) {
4701 $principle = $detl[
'principal'];
4702 $interest = $detl[
'interest'];
4704 if ($principle < 0) {
4707 $trntype =
"CREDIT";
4710 $totalpay = $detl[
'totalpay'];
4711 $trdesc = $detl[
'description'];
4712 $date = $detl[
'date'];
4713 $traceno = $detl[
'traceno'];
4714 $longdesc = htmlentities($trdesc, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
4715 $shortdesc = substr(htmlentities($trdesc, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE), 0, 31);
4716 $shortdesc = preg_replace(
'/&[^;]*$/',
'', $shortdesc);
4717 $shortdesc = (trim($shortdesc) ==
'' ?
'.' : $shortdesc);
4719 # transaction data row 4720 $itm_arr[
'TRNTYPE'] = $trntype;
4721 $itm_arr[
'DTPOSTED'] = $detl[
'date'];
4722 $itm_arr[
'TRNAMT'] = $totalpay;
4723 if (($HB_ENV[
'Fset'] & $GLOBALS[
'CU_LNBALUNUSABLE']) != $GLOBALS[
'CU_LNBALUNUSABLE']) {
4724 $itm_arr[
'RUNBAL'] = $detl[
'balance'];
4726 $itm_arr[
'FITID'] = $traceno;
4727 if (($HB_ENV[
'Fset'] & $GLOBALS[
'CU_SHOWLNTXNDESC']) == $GLOBALS[
'CU_SHOWLNTXNDESC']) {
4728 $$itm_arr[
'NAME'] = $shortdesc;
4729 $itm_arr[
'MEMO'] = $longdesc;
4733 $tranDate = preg_replace(
"/\D/",
"", $detl[
'date'] );
4734 if ($tranDate < $recent) {
4735 $reply_arr[][
'STMTTRN']=$itm_arr;
4737 $reply_arr[][
'RECENTTRN']=$itm_arr;
4742 if ($HB_ENV[
'live'] == 0) {
4743 $pending = Get_ReqDetails($dbh, $HB_ENV, $balkey);
4744 # Get_ReqDetails returns txdesc already UTF-encoded. Problem? 4745 if (HCU_array_key_exists(
'acctlist', $pending) && HCU_array_key_exists($balkey, $pending[
'acctlist'])) {
4746 foreach ($pending[
'acctlist'][$balkey] as $tnum => $detl) {
4748 $itm_arr = array(
'TRACENO' => $detl[
'id'],
4749 'DTREQUEST' => $detl[
'postdate'],
4750 'TRNAMT' => $detl[
'amount'],
4751 'TRNDESC' => htmlspecialchars($detl[
'txdesc'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4753 $reply_arr[
'TXNPENDING'][][
'REQUEST']= $itm_arr;
4759 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SHOWPEND']) == $GLOBALS[
'CU2_SHOWPEND']) {
4760 $pending = Get_PendDetails($dbh, $HB_ENV, $balkey);
4761 if (count($pending[$balkey])) {
4762 foreach ($pending[$balkey] as $tnum => $detl) {
4764 $itm_arr = array(
'TRACENO' => $detl[
'traceno'],
4765 'DTREQUEST' => $detl[
'postdate'],
4766 'TRNAMT' => $detl[
'amount'],
4767 'TRNDESC' => htmlspecialchars($detl[
'description'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4769 $reply_arr[
'TXNPENDING'][][
'ACHWAREHOUSE'] = $itm_arr;
4774 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SHOWHOLD']) == $GLOBALS[
'CU2_SHOWHOLD']) {
4775 $pending = Get_HoldDetails($dbh, $HB_ENV, $balkey);
4776 if (count($pending[$balkey])) {
4777 foreach ($pending[$balkey] as $tnum => $detl) {
4779 $itm_arr = array(
'TRACENO' => $detl[
'traceno'],
4780 'DTREQUEST' => $detl[
'postdate'],
4781 'TRNAMT' => $detl[
'amount'],
4782 'TRNDESC' => htmlspecialchars($detl[
'description'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4784 $reply_arr[
'TXNPENDING'][][
'PREAUTH'] = $itm_arr;
4789 if (!HCU_array_key_exists(
'TXNPENDING',$reply_arr)) {
4790 $reply_arr[
'TXNPENDING']=array();
4794 $result = array(
'Status' =>
'Success',
'HISTarr' => $reply_arr,
'XMLstr' => assocArrayToXML($reply_arr,
'CREDITCARDTRANLIST', 0));
4795 }
catch (Exception $e) {
4796 $result = array(
'Status' =>
'Failed ' . $e->getMessage(),
'HISTarr' => array(),
'XMLstr' =>
'');
4801 function lnHistXML($dbh, $HB_ENV, $balkey, $balinfo, $sqlstart, $sqlend, $recent) {
4803 $reply_arr = array();
4806 $history = Get_History($dbh, $HB_ENV, $balkey, $sqlstart, $sqlend);
4808 $reply_arr[
'DTSTART'] =
"${sqlstart}000000";
4809 $reply_arr[
'DTEND'] =
"${sqlend}235959";
4811 if (HCU_array_key_exists($balkey, $history)) {
4812 foreach ($history[$balkey] as $tnum => $detl) {
4815 $principle = $detl[
'principal'];
4816 $interest = $detl[
'interest'];
4817 $totalpay = $detl[
'totalpay'];
4818 $traceno = $detl[
'traceno'];
4819 $trdesc = $detl[
'description'];
4821 if ($principle < 0) {
4822 $trntype =
"PAYMENT";
4824 $trntype =
"ADVANCE";
4827 $longdesc = htmlentities($trdesc, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
4828 $shortdesc = substr(htmlentities($trdesc, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE), 0, 31);
4829 $shortdesc = preg_replace(
'/&[^;]*$/',
'', $shortdesc);
4830 $shortdesc = (trim($shortdesc) ==
'' ?
'.' : $shortdesc);
4832 # transaction data row 4834 $itm_arr[
'LOANTRNTYPE'] = $trntype;
4835 $itm_arr[
'DTPOSTED'] = $detl[
'date'];
4836 if (($HB_ENV[
'Fset'] & $GLOBALS[
'CU_SHOWLNTXNSPLIT']) == $GLOBALS[
'CU_SHOWLNTXNSPLIT']) {
4837 $itm_arr[
'TRNAMT'] = $totalpay;
4838 $itm_arr[
'PRINAMT'] = $principle;
4839 $itm_arr[
'INTAMT'] = $interest;
4841 $itm_arr[
'TRNAMT'] = $principle;
4843 if (($HB_ENV[
'Fset'] & $GLOBALS[
'CU_LNBALUNUSABLE']) != $GLOBALS[
'CU_LNBALUNUSABLE']) {
4844 $itm_arr[
'RUNBAL'] = $detl[
'balance'];
4846 $itm_arr[
'FITID'] = $traceno;
4847 if (($HB_ENV[
'Fset'] & $GLOBALS[
'CU_SHOWLNTXNDESC']) == $GLOBALS[
'CU_SHOWLNTXNDESC']) {
4848 $itm_arr[
'NAME'] = $shortdesc;
4849 $itm_arr[
'MEMO'] = $longdesc;
4853 $tranDate = preg_replace(
"/\D/",
"", $detl[
'date'] );
4854 if ($tranDate < $recent) {
4855 $reply_arr[][
'LOANSTMTTRN']=$itm_arr;
4857 $reply_arr[][
'RECENTTRN']=$itm_arr;
4862 if ($HB_ENV[
'live'] == 0) {
4863 $pending = Get_ReqDetails($dbh, $HB_ENV, $balkey);
4865 # Get_ReqDetails returns txdesc already UTF-encoded. Problem? 4866 if (HCU_array_key_exists(
'acctlist', $pending) && HCU_array_key_exists($balkey, $pending[
'acctlist'])) {
4867 foreach ($pending[
'acctlist'][$balkey] as $tnum => $detl) {
4869 $itm_arr = array(
'TRACENO' => $detl[
'id'],
4870 'DTREQUEST' => $detl[
'postdate'],
4871 'TRNAMT' => $detl[
'amount'],
4872 'TRNDESC' => htmlspecialchars($detl[
'txdesc'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4874 $reply_arr[
'TXNPENDING'][][
'REQUEST'] = $itm_arr;
4879 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SHOWPEND']) == $GLOBALS[
'CU2_SHOWPEND']) {
4880 $pending = Get_PendDetails($dbh, $HB_ENV, $balkey);
4881 if (HCU_array_key_exists($balkey, $pending)) {
4882 foreach ($pending[$balkey] as $tnum => $detl) {
4883 $itm_arr = array(
'TRACENO' => $detl[
'traceno'],
4884 'DTREQUEST' => $detl[
'postdate'],
4885 'TRNAMT' => $detl[
'amount'],
4886 'TRNDESC' => htmlspecialchars($detl[
'txdesc'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4888 $reply_arr[
'TXNPENDING'][][
'ACHWAREHOUSE'] = $itm_arr;
4893 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_SHOWHOLD']) == $GLOBALS[
'CU2_SHOWHOLD']) {
4894 $pending = Get_HoldDetails($dbh, $HB_ENV, $balkey);
4895 if (HCU_array_key_exists($balkey, $pending)) {
4896 foreach ($pending[$balkey] as $tnum => $detl) {
4897 $itm_arr = array(
'TRACENO' => $detl[
'traceno'],
4898 'DTREQUEST' => $detl[
'postdate'],
4899 'TRNAMT' => $detl[
'amount'],
4900 'TRNDESC' => htmlspecialchars($detl[
'txdesc'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
4902 $reply_arr[][
'PREAUTH'][
'REQUEST'] = $itm_arr;
4907 if (!HCU_array_key_exists(
'TXNPENDING',$reply_arr)) {
4908 $reply_arr[
'TXNPENDING']=array();
4912 $result = array(
'Status' =>
'Success',
'HISTarr' => $reply_arr,
'XMLstr' => assocArrayToXML($reply_arr,
'LOANTRANLIST', 0));
4913 }
catch (Exception $e) {
4914 $result = array(
'Status' =>
'Failed ' . $e->getMessage(),
'HISTarr' => array(),
'XMLstr' =>
'');
4927 function assocArrayToXML($ar, $base=
'APPFEED')
4929 $xml =
new SimpleXMLElement(
"<$base></$base>");
4931 $f = create_function(
'$f,$c,$a',
' 4932 foreach($a as $k=>$v) { 4934 if (is_numeric($k)) { 4937 $ch=$c->addChild($k); 4941 $c->addChild($k,htmlentities($v, ENT_NOQUOTES | ENT_XML1, "UTF-8", FALSE)); 4946 $return = $xml->asXML();
4948 $return = str_replace(
'<?xml version="1.0"?>',
'',$return);
4959 function BuildUserMenu($dbh, $pHBEnv, $Platform=
'A') {
4961 $menuArray = FetchMenuArray( $pHBEnv,
"A" );
4964 $userMenu = _BuildMenuStructure( $pHBEnv, $menuArray );
4977 function BuildFullUserMenu($dbh, $pHBEnv, $Platform=
'A') {
4979 $menuArray = FetchMenuArray( $pHBEnv,
"A" );
4982 $userMenu = _BuildFullMenuStructure( $pHBEnv, $menuArray );
4989 function _BuildMenuStructure( $pHBEnv, $pMenuArray ) {
4990 $returnMenuStructure = array();
4994 for ( $i = 0; $i < count ( $pMenuArray ); $i++ ) {
4995 $menuElement = $pMenuArray[$i];
4997 $thisEntry = array();
4998 if ( $menuElement[
"menu_item_type"] ==
"H" ) {
4999 $groupDisplayName = HCU_array_key_value(
"menu_display_name_en_US", $menuElement );
5000 $groupDisplayOrder = HCU_array_key_value(
"menu_display_order", $menuElement );
5003 $menuItemId = HCU_array_key_value(
'menu_item_id', $menuElement );
5005 $childMenuItems = _BuildChildMenu( $pHBEnv, $menuElement[
"menu_children"], $menuItemId );
5008 $childList = array();
5009 for ( $c = 0; $c < count( $childMenuItems ); $c++ ) {
5010 $childList[]= array(
"feature" => $childMenuItems[$c] );
5014 $groupEntry = array(
"dispname" => $groupDisplayName,
5015 "disporder" => $groupDisplayOrder,
5018 $thisEntry = array(
"group" => $groupEntry );
5019 }
else if ( $menuElement[
"menu_item_type"] ==
"S" ) {
5023 $menuFeatureCode = HCU_array_key_value(
'menu_feature_code', $menuElement );
5024 $desktopScript = HCU_array_key_value(
'menu_script', $menuElement );
5026 $featureCode = _GetAppMenuFeatureCode( $menuFeatureCode, $desktopScript );
5028 if ( $featureCode ==
"unknown" ) {
5034 $target = HCU_array_key_value(
'menu_target', $menuElement ) == 1 ?
"browser" :
"webview";
5037 "featurecode" => $featureCode,
5038 "menuname" => HCU_array_key_value(
'menu_display_name_en_US', $menuElement ),
5039 "menuid" => HCU_array_key_value(
'menu_item_id', $menuElement ),
5040 "disporder" => HCU_array_key_value(
'menu_display_order', $menuElement ),
5041 "icon" => HCU_array_key_value(
'menu_icon_name', $menuElement ),
5042 "extraparam" => urlencode( HCU_array_key_value(
'menu_extra_param', $menuElement ) ),
5043 "addcu" => HCU_array_key_value(
'menu_add_cu', $menuElement ),
5044 "target" => $target );
5047 if ( $featureCode ==
"sso" ) {
5048 $menuItem[
"ssourl"] = urlencode( HCU_array_key_value(
'menu_script', $menuElement ) );
5051 $thisEntry = array(
"feature" => $menuItem );
5055 $returnMenuStructure[] = $thisEntry;
5058 return $returnMenuStructure;
5066 function _BuildFullMenuStructure( $pHBEnv, $pMenuArray ) {
5067 $returnMenuStructure = array();
5071 for ( $i = 0; $i < count ( $pMenuArray ); $i++ ) {
5072 $menuElement = $pMenuArray[$i];
5075 unset($menuElement[
"menu_display_name_en_US"]);
5076 unset($menuElement[
"menu_display_name_es_US"]);
5077 unset($menuElement[
"menu_display_name_pl_US"]);
5079 unset($menuElement[
"menu_target"]);
5082 $menuElement[
"menu_display_name"] = urlencode($menuElement[
"menu_display_name"]);
5083 $menuElement[
"menu_extra_param"] = urlencode($menuElement[
"menu_extra_param"]);
5085 $thisEntry = array();
5086 if ( $menuElement[
"menu_item_type"] ==
"H" ) {
5088 unset($menuElement[
"menu_feature_code"]);
5089 unset($menuElement[
"menu_parent_id"]);
5090 unset($menuElement[
"menu_script"]);
5091 unset($menuElement[
"menu_extra_param"]);
5092 unset($menuElement[
"menu_add_cu"]);
5095 $parentItemId = HCU_array_key_value(
'menu_item_id', $menuElement );
5097 $childMenuItems = array();
5098 $childMenuArray = $menuElement[
"menu_children"];
5099 for ( $c = 0; $c < count( $childMenuArray ); $c++ ) {
5100 $childItem = $childMenuArray[$c];
5103 unset($childItem[
"menu_display_name_en_US"]);
5104 unset($childItem[
"menu_display_name_es_US"]);
5105 unset($childItem[
"menu_display_name_pl_US"]);
5107 unset($childItem[
"menu_target"]);
5110 $childItem[
"menu_display_name"] = urlencode($childMenuArray[$c][
"menu_display_name"]);
5111 $childItem[
"menu_extra_param"] = urlencode($childMenuArray[$c][
"menu_extra_param"]);
5114 $childMenuItems[][
"feature"] = $childItem;
5118 $menuElement[
"menu_children"] = $childMenuItems;
5120 $thisEntry = array(
"group" => $menuElement );
5121 }
else if ( $menuElement[
"menu_item_type"] ==
"S" ) {
5123 $thisEntry = array(
"feature" => $menuElement );
5127 $returnMenuStructure[] = $thisEntry;
5130 return $returnMenuStructure;
5135 function _BuildChildMenu( $pHBEnv, $pMenuArray, $pParentId ) {
5138 $childMenuItems = array();
5139 for ( $i = 0; $i < count( $pMenuArray ); $i++ ) {
5140 $menuItem = $pMenuArray[$i];
5142 $menuItemType = HCU_array_key_value(
'menu_item_type', $menuItem );
5143 $menuParentId = HCU_array_key_value(
'menu_parent_id', $menuItem );
5145 if ( $menuItemType !=
"D" || $menuParentId != $pParentId ) {
5150 $menuFeatureCode = HCU_array_key_value(
'menu_feature_code', $menuItem );
5151 $desktopScript = HCU_array_key_value(
'menu_script', $menuItem );
5153 $featureCode = _GetAppMenuFeatureCode( $menuFeatureCode, $desktopScript );
5155 if ( $featureCode ==
"unknown" ) {
5161 $target = HCU_array_key_value(
'menu_target', $menuItem ) == 1 ?
"browser" :
"webview";
5164 "featurecode" => $featureCode,
5165 "menuname" => HCU_array_key_value(
'menu_display_name_en_US', $menuItem ),
5166 "menuid" => HCU_array_key_value(
'menu_item_id', $menuItem ),
5167 "disporder" => HCU_array_key_value(
'menu_display_order', $menuItem ),
5168 "icon" => HCU_array_key_value(
'menu_icon_name', $menuItem ),
5169 "extraparam" => urlencode( HCU_array_key_value(
'menu_extra_param', $menuItem ) ),
5170 "addcu" => HCU_array_key_value(
'menu_add_cu', $menuItem ),
5171 "target" => $target );
5174 if ( $featureCode ==
"sso" || $featureCode ==
"sso-estmt" ||
5175 $featureCode ==
"sso-mrdc" || $featureCode ==
"sso-mbillpay" ||
5176 $featureCode ==
"sso-pfm" || $featureCode ==
"sso-loanapp" ) {
5177 $childItem[
"ssourl"] = urlencode( HCU_array_key_value(
'menu_script', $menuItem ) );
5180 $parts = explode(
"-", $featureCode );
5181 $type = count( $parts ) > 1 ? $parts[1] :
"";
5182 $childItem[
"ssotype"] = $type;
5185 $childItem[
"featurecode"] =
"sso";
5188 $childMenuItems[] = $childItem;
5191 return $childMenuItems;
5198 function _GetAppMenuFeatureCode( $pMenuFeatureCode, $pDesktopScript ) {
5199 $appFeatureCode =
"unknown";
5201 switch ( strtoupper( $pMenuFeatureCode ) ) {
5204 $appFeatureCode =
"achcol";
5208 $appFeatureCode =
"achpmt";
5214 $appFeatureCode =
"alerts";
5218 switch( $pDesktopScript ) {
5219 case "hcuAccounts.prg":
5221 $appFeatureCode =
"balances";
5223 case "hcuForms.prg":
5224 $appFeatureCode =
"forms";
5226 case "hcuProfilePwd.prg":
5227 case "hcuProfileSecurity.prg":
5228 case "hcuProfileDesc.prg":
5229 case "hcuProfileAlias.prg":
5230 case "hcuProfileEmail.prg":
5231 $appFeatureCode =
"settings";
5233 case "hcuDisclosures.prg":
5234 case "hcuHistory.prg":
5239 $appFeatureCode =
"sso";
5244 if ( $pDesktopScript ==
"hcuStatement.prg" ) {
5245 $appFeatureCode =
"estatements";
5248 $appFeatureCode =
"sso-estmt";
5252 if ( $pDesktopScript ==
"hcuMobilePay.prg" ) {
5253 $appFeatureCode =
"mobilepay";
5256 $appFeatureCode =
"sso-mbillpay";
5260 if ( $pDesktopScript ==
"hcuConnect.prg" ) {
5262 $appFeatureCode =
"sso-mrdc";
5265 $appFeatureCode =
"mrdc";
5269 $appFeatureCode =
"sso-pfm";
5272 $appFeatureCode =
"sso-loanapp";
5275 $appFeatureCode =
"messages";
5280 if ( $pDesktopScript ==
"hcuTransfer.prg" ) {
5281 $appFeatureCode =
"transfers";
5282 }
else if ( $pDesktopScript ==
"hcuUserActivity.prg" ) {
5283 $appFeatureCode =
"activity";
5287 $appFeatureCode =
"tranext";
5290 $appFeatureCode =
"tranm2m";
5293 $appFeatureCode =
"transched";
5296 $appFeatureCode =
"tranwire";
5305 return $appFeatureCode;
5309 function MakeMFAKey($HB_ENV) {
5311 $mfaExpires = date(
"Ymd", time() + (94 * 86400)); # 94 days
5313 $mbrMfaQuest = HCU_MFADecode(HCU_JsonDecode($HB_ENV[
'mfaquest']));
5314 $mfaMode = (intval($HB_ENV[
'Fset3'] & GetFlagsetValue(
'CU3_MFA_AUTHCODE')));
5317 $mfadate = HCU_array_key_exists(
"mfadate", $mbrMfaQuest) ? $mbrMfaQuest[
'mfadate'] :
"";
5318 $MFAKey = hash_hmac(
'sha384',GetDeviceCookieContentString(),trim($HB_ENV[
'password']) . trim(strtolower($HB_ENV[
'savemail'])) . trim(strtolower($HB_ENV[
'confidence'])) . $mfaMode . $mfadate);
5320 return "{$mfaExpires}{$MFAKey}";
5323 function IsValidMFAKey($mfaKey, $userrec) {
5324 $today = date(
"Ymd");
5326 $mfaExpires = substr($mfaKey,0,8);
5327 $mfaHash = substr($mfaKey,8);
5329 $mfaMode = (intval($userrec[
'flagset3'] & GetFlagsetValue(
'CU3_MFA_AUTHCODE')));
5330 $mfadate = HCU_array_key_exists(
"mfadate", $userrec) ? $userrec[
'mfadate'] :
"";
5331 $cookiecontent = hash_hmac(
'sha384',GetDeviceCookieContentString(),trim($userrec[
'passwd']) . trim(strtolower($userrec[
'email'])) . trim(strtolower($userrec[
'confidence']))
5332 . $mfaMode . $mfadate);
5333 if ($cookiecontent == $mfaHash && $mfaExpires > $today) {
5336 $return_val =
false;
5345 function IsValidAppDeviceCookie($cu, $deviceCookie, $userrec) {
5349 $deviceCookieParts = explode(
"|", $deviceCookie);
5350 if ( $deviceCookieParts[2] < time() ||
5351 empty( $deviceCookieParts[0] ) ||
5352 empty( $deviceCookieParts[1] ) ) {
5356 $mfaMode = (intval($userrec[
'flagset3'] & GetFlagsetValue(
'CU3_MFA_AUTHCODE')));
5357 $mfaDate = HCU_array_key_value(
"mfadate", $userrec);
5359 $cookieParams = array (
"cu" => trim($cu),
5360 "user_name" => $userrec[
'user_name'],
5361 "saved_pass" => $userrec[
'passwd'],
5362 "saved_email" => $userrec[
'email'],
5363 "saved_confidence" => $userrec[
'confidence'],
5364 "mfa_mode" => $mfaMode,
5365 "mfa_date" => $mfaDate,
5366 "persists_time" => 0
5369 $cookieInfo = CreateDeviceCookie( $cookieParams);
5371 if ( ($cookieInfo[
"name"] == $deviceCookieParts[0]) &&
5372 ($cookieInfo[
"content"] == $deviceCookieParts[1]) ) {
5381 function LogFail($dbh, $HB_ENV, $inPost, $failbit) {
5382 $updstat = UpdateMemberFailedLogin($dbh, $HB_ENV[
'cu'], $HB_ENV[
'user_name'], $failbit);
5383 $p_meta = array(
'UA' => $_SERVER[
'HTTP_USER_AGENT']);
5384 $p_hbenv = array(
'Cu' => $inPost[
'ORG'],
'Uid' => $HB_ENV[
'Uid'],
'user_name' => $HB_ENV[
'user_name']);
5385 TrackUserLogin($dbh, $p_hbenv, $HB_ENV[
'platform'], $failbit, $_SERVER[
'REMOTE_ADDR'], $p_meta);
5388 function LogPass($dbh, &$HB_ENV){
5389 # if not online, set the logtrack parameters to NOT decrement the remaining logins 5390 $must = ($HB_ENV[
'offline'] !=
'N' || ($HB_ENV[
'forceupdate'] & 29) == 0 ?
'N' :
'Y');
5391 $tomorrow = date(
'Y-m-d', mktime(0, 0, 0, date(
"m"), date(
"d") + 1, date(
"Y")));
5392 $pchange = ($HB_ENV[
'offline'] !=
'N' ? $tomorrow : $HB_ENV[
'pwchange']);
5393 $adjust = ($must ==
'Y' ? 1 : 0);
5394 # and fix the corresponding value in HB_ENV 5395 $HB_ENV[
'Ffremain']-=$adjust;
5398 $HB_ENV[
'MFA'][
'challenge'] = 0;
5399 $HB_ENV[
'MFA'][
'authcode']=
'';
5400 $HB_ENV[
'MFA'][
'authexpires']=
'';
5403 $updstat = UpdateMemberLoginTrack($dbh, $HB_ENV[
'cu'], $HB_ENV[
'user_name'], $must, $pchange, $HB_ENV[
'platform'], $HB_ENV[
'MFA']);
5404 $p_meta = array(
'UA' => $_SERVER[
'HTTP_USER_AGENT']);
5405 TrackUserLogin($dbh, $HB_ENV, $HB_ENV[
'platform'], 0, $_SERVER[
'REMOTE_ADDR'], $p_meta);
5408 function SAC_destination($dbh, $HB_ENV, $userrec) {
5409 $reply_arr = array(
'STATUS' => array(
'CODE' =>3000,
'SEVERITY' =>
'ERROR'),
5410 'DTSERVER' => date(
'YmdHis') );
5412 $MemberContacts_ary = GetUserContacts($dbh, $HB_ENV, $userrec);
5413 $reply_arr[
'MFA'][
'AUTHREQ'] =
'MFS';
5414 $reply_arr[
'MFA'][
'MFABUNDLE'] = $HB_ENV[
'mfaBundle'];
5415 $reply_arr[
'MFA'][
'EMLLABEL'] = $HB_ENV[
'MC']->msg(
'Email to', HCU_DISPLAY_AS_HTML);
5416 if (is_array($MemberContacts_ary[
'EMAIL']) &&
sizeof($MemberContacts_ary[
'EMAIL'])) {
5417 foreach ($MemberContacts_ary[
'EMAIL'] as $ckey => $cval) {
5418 $ckey = str_replace(array(
"+",
"/",
"="), array(
"-",
"_",
"."), $ckey);
5419 $reply_arr[
'MFA'][
'EMLLIST'][][
'EMAIL']= array(
'eSelect'=>$ckey,
'eDisplay' =>$cval);
5422 if (is_array($MemberContacts_ary[
'SMS']) &&
sizeof($MemberContacts_ary[
'SMS'])) {
5423 $reply_arr[
'MFA'][
'SMSLABEL'] = $HB_ENV[
'MC']->msg(
'Text to', HCU_DISPLAY_AS_HTML);
5424 foreach ($MemberContacts_ary[
'SMS'] as $ckey => $cval) {
5425 $ckey = str_replace(array(
"+",
"/",
"="), array(
"-",
"_",
"."), $ckey);
5426 $reply_arr[
'MFA'][
'SMSLIST'][][
'SMS']= array(
'eSelect'=>$ckey,
'eDisplay' =>$cval);
5430 $reply_arr[
'MFA'][
'haveSAC'] = HCU_array_key_value(
'GotIt', $MemberContacts_ary );
5435 function PWD_prompt($dbh, $HB_ENV) {
5436 $reply_arr = array(
'STATUS' => array(
'CODE' =>3000,
'SEVERITY' =>
'ERROR'),
5437 'DTSERVER' => date(
'YmdHis') );
5440 # 'forgot password' link 5443 $reply_arr[
'MFA'][
'AUTHREQ'] =
'MFP';
5444 $reply_arr[
'MFA'][
'MFABUNDLE'] = $HB_ENV[
'mfaBundle'];
5445 $reply_arr[
'MFA'][
'PROMPT'] = $HB_ENV[
'MC']->msg(
'Login Enter Password');
5446 $reply_arr[
'MFA'][
'CONFIDENCE'] = $HB_ENV[
'confidence'];
5448 if ($HB_ENV[
'flagset'] & $GLOBALS[
'CU_MEMRESET']){
5449 $reply_arr[
'MFA'][
'FORGOTLINK'] = $HB_ENV[
'loginpath'] .
'/hcuResetPwd.prg?' . $HB_ENV[
'cuquery'];
5450 $reply_arr[
'MFA'][
'FORGOTLABEL'] = $HB_ENV[
'MC']->msg(
'Forgot your password');
5456 function EML_prompt($dbh, $HB_ENV) {
5457 $reply_arr = array(
'STATUS' => array(
'CODE' =>3000,
'SEVERITY' =>
'ERROR'),
5458 'DTSERVER' => date(
'YmdHis') );
5459 $reply_arr[
'MFA'][
'AUTHREQ'] =
'EML';
5460 $reply_arr[
'MFA'][
'MFABUNDLE'] = $HB_ENV[
'mfaBundle'];
5461 $reply_arr[
'MFA'][
'PROMPT'] = $HB_ENV[
'MC']->msg(
'Confirm Email Address');
5465 function SAC_prompt($dbh, $HB_ENV) {
5466 $reply_arr = array(
'STATUS' => array(
'CODE' =>3000,
'SEVERITY' =>
'ERROR'),
5467 'DTSERVER' => date(
'YmdHis') );
5468 $reply_arr[
'MFA'][
'AUTHREQ'] =
'MFC';
5469 $reply_arr[
'MFA'][
'MFABUNDLE'] = $HB_ENV[
'mfaBundle'];
5470 $reply_arr[
'MFA'][
'PROMPT'] = $HB_ENV[
'MC']->msg(
'Enter Access Code');
5474 function checkBundle($mode, $mfaBundle, $inPost) {
5478 # special case to check the bundle age 5479 $built = HCU_array_key_value(
'BUILDTIME', $mfaBundle);
5480 if ( empty($built) || (time() - $built) > 900 ) {
5481 $returnBundle =
false;
5483 $returnBundle =
true;
5487 # previous mode is MFA, 5488 # bundle contains USERID 5491 if ( HCU_array_key_value(
'mode', $mfaBundle) !==
'MFA' ||
5492 HCU_array_key_value(
'USERID',$mfaBundle) !== HCU_array_key_value(
'USERID',$inPost) ) {
5493 $returnBundle =
false;
5495 $returnBundle =
true;
5500 # previous mode is EML 5501 # bundle contains USERID, MFA_E 5502 # Add MFQ completion marker 5503 if ( (HCU_array_key_value(
'mode', $mfaBundle) !==
'EML' && HCU_array_key_value(
'mode', $mfaBundle) !==
'MFS') ||
5504 HCU_array_key_value(
'USERID',$mfaBundle) !== HCU_array_key_value(
'USERID',$inPost) ||
5505 !HCU_array_key_exists(
'MFA_E',$mfaBundle) ) {
5506 $returnBundle =
false;
5508 $returnBundle =
true;
5512 # previous mode is MFS, or maybe EML if they already had a code 5513 # bundle contains USERID, MFA_E, MFS_Deliver 5514 # Add SAC completion marker 5515 if ( (HCU_array_key_value(
'mode', $mfaBundle) !==
'MFS' && HCU_array_key_value(
'mode', $mfaBundle) !==
'EML' ) ||
5516 HCU_array_key_value(
'USERID',$mfaBundle) !== HCU_array_key_value(
'USERID',$inPost) ||
5517 !HCU_array_key_exists(
'MFA_E',$mfaBundle) ||
5518 (HCU_array_key_value(
'mode', $mfaBundle) ==
'MFS' && !HCU_array_key_exists(
'MFS_Deliver',$mfaBundle)) ) {
5519 $returnBundle =
false;
5521 $returnBundle =
true;
5525 # previous mode is MFQ or MFC or EML or MFA 5526 # bundle contains USERID, MFA_E, 5527 # and either MFQ marker or SAC marker 5529 !((HCU_array_key_value(
'mode', $mfaBundle) ===
'MFQ' && HCU_array_key_exists(
'haveMFQ',$mfaBundle)) ||
5530 (HCU_array_key_value(
'mode', $mfaBundle) ===
'MFC' && HCU_array_key_exists(
'haveSAC',$mfaBundle)) ||
5531 HCU_array_key_value(
'mode', $mfaBundle) ===
'EML' || HCU_array_key_value(
'mode', $mfaBundle) ===
'MFA')
5532 || HCU_array_key_value(
'USERID',$mfaBundle) !== HCU_array_key_value(
'USERID',$inPost) ||
5533 !HCU_array_key_exists(
'MFA_E',$mfaBundle)
5540 $returnBundle =
false;
5542 $returnBundle =
true;
5546 # unexpected $mode - throw error 5547 $returnBundle =
false;
5550 return $returnBundle;
5552 function createBundle($Cu, $mfaBundle) {
5554 $mfaBundle = HCU_PayloadEncode($Cu,$mfaBundle);
5555 $mfaBundle = str_replace(array(
"+",
"/",
"="), array(
"-",
"_",
"."), $mfaBundle);
5556 }
catch (Exception $e) {
5562 function openBundle($Cu, $mfaBundle) {
5565 $mfaBundle = str_replace(array(
"-",
"_",
"."), array(
"+",
"/",
"="), $mfaBundle);
5566 $mfaBundle = HCU_PayloadDecode($Cu, $mfaBundle);
5568 }
catch (Exception $e) {
5576 function OdyTxPost ($dbh, $HB_ENV, $inPost, $MC) {
5578 $errorMessage = array();
5583 $sourceParts = isset( $inPost[
'FACCTID'] ) ? explode(
"|", $inPost[
'FACCTID'] ) : array();
5584 $destParts = isset( $inPost[
'TACCTID'] ) ? explode(
"|", $inPost[
'TACCTID'] ) : array();
5587 if ( (isset( $sourceParts[0] ) && $sourceParts[0] ===
"X") ||
5588 (isset( $destParts[0] ) && $destParts[0] ===
"X") ) {
5589 $transferFeatureCode = FEATURE_EXTERNAL_TRANSFERS;
5590 }
else if ( isset( $destParts[0] ) && $destParts[0] ===
"M" ) {
5591 $transferFeatureCode = FEATURE_M2M_TRANSFERS;
5593 $transferFeatureCode = FEATURE_TRANSFERS;
5595 # UGLY hidden dependency... SubmitTransfer function expects this in 5596 # the post array so load it here. 5597 $HB_ENV[
'HCUPOST'][
'feature_code'] = $transferFeatureCode;
5599 $permissionInputs = array(
"feature" => $transferFeatureCode );
5602 $accessRights = Perm_AccessRights( $dbh, $HB_ENV, $permissionInputs );
5603 if ( !HCU_array_key_value(
"create", $accessRights ) ) {
5604 $errorMessage[] = $MC->msg(
'Rights not set', HCU_DISPLAY_AS_HTML);
5605 throw new Exception ( HCU_JsonEncode($errorMessage) );
5609 $permissionInputs = array(
"feature" => $transferFeatureCode );
5610 $limits = Perm_GetValidationLimits( $dbh, $HB_ENV, $permissionInputs );
5612 if ( $limits ===
false ) {
5616 $allowedAmount = floatval( $limits[
"amount_per_transaction"] );
5625 $txData = array(
'txFrequency' =>
"OneTime",
5626 'txFromMember' => $sourceParts[1],
5627 'txFromSuffix' => $inPost[
'FACCTID'],
5629 'txToMember' => $destParts[1],
5630 'txToSuffix' => $inPost[
'TACCTID'],
5633 'txMemAccount' =>
null,
5634 'txMemName' =>
null,
5635 'txMemType' =>
null,
5636 'txCode' =>
null, #
this needs to
get set here, somehow?
5637 'txAmount' => HCU_array_key_value(
'AMOUNT',$inPost),
5638 'txMemo' => HCU_array_key_value(
'TRMEMO',$inPost),
5639 'txFrequencyCount' => 0,
5640 'txContinue' =>
null,
5641 'txDateStart' => date(
"m/d/Y"),
5642 'txDateEnd' =>
null,
5644 'txPmtComment' =>
null,
5645 'txDeposit' =>
null,
5647 'txOption' =>
"Immediate",
5648 "feature_code" => $HB_ENV[
"HCUPOST"][
"feature_code"]);
5652 $txRecurringAllowed = (($HB_ENV[
'flagset2'] & GetFlagsetValue(
"CU2_PROCRECUR")) === GetFlagsetValue(
"CU2_PROCRECUR"));
5654 $txIsPayment = ($destParts[0] ==
'O' && substr( $destParts[2], 0, 1 ) ===
"P");
5659 if (!$txRecurringAllowed || $txData[
'txOption'] ===
"Immediate") {
5664 $txValidateTransfer = ValidateTransfer( $HB_ENV, $dbh, $MC, $txData );
5666 if ( $txValidateTransfer[
'status'][
'code'] !==
"000" ) {
5668 for ( $i = 0; $i < count( $txValidateTransfer[
"status"][
"errors"] ); $i++ ) {
5669 $errorMessage[] = $txValidateTransfer[
"status"][
"errors"][$i][
"message"];
5672 throw new Exception ( HCU_JsonEncode($errorMessage) );
5677 # should be validated amount, not the raw inPost value 5678 $htmlTransferAmount = HCU_array_key_value(
'txAmount',$txValidateTransfer[
'data']);
5680 if ( $htmlTransferAmount > $allowedAmount ) {
5682 $errorMessage[] =$MC->msg(
'Perm Limit - Request over authorized limit', HCU_DISPLAY_AS_HTML);
5683 throw new Exception ( HCU_JsonEncode($errorMessage) );
5687 $permissionInputs = array(
"feature" => $transferFeatureCode );
5688 $permissionInputs[
"amount"] = $htmlTransferAmount;
5689 # these should probably come from the validated results, 5690 # but ValidateTransfer is transforming some of the data 5691 # and may be confusing acctid (delimited string with several values) 5692 # with the account number/account suffix. 5693 $permissionInputs[
"account"] = $sourceParts[1];
5694 $permissionInputs[
"accounttype"] = $sourceParts[2];
5696 $return = Perm_CheckLimits( $dbh, $HB_ENV, $permissionInputs );
5697 if ( !$return || ($return[
"status"][
"code"] !==
"000") ) {
5699 $errorMessage[] = Perm_GetLimitErrDesc($MC, $return[
"status"][
"code"]);
5700 throw new Exception ( HCU_JsonEncode($errorMessage) );
5704 $submitTransferResult = SubmitTransfer( $dbh, $HB_ENV, $MC, $txValidateTransfer[
'data'], $aryTransferResults );
5707 if ( $submitTransferResult ===
false ) {
5709 $errorMessage[] = $MC->msg(
"Transfer Error", HCU_DISPLAY_AS_HTML);
5714 if ( $aryTransferResults[
"status"][
"code"] !=
"000" ) {
5715 if ( count( $submitTransferResult[
"status"][
"errors"] ) > 0 ) {
5716 for ( $i = 0; $i < count( $submitTransferResult[
"status"][
"errors"] ); $i++ ) {
5717 $errorMessage[] = $submitTransferResult[
"status"][
"errors"][$i];
5723 if ( count( $errorMessage ) > 0 ) {
5724 if ($txData[
'txFrequency'] !=
'OneTime') {
5727 $errorMessage[] = $MC->msg(
"Repeating transfer not saved", HCU_DISPLAY_AS_RAW);
5730 throw new Exception ( HCU_JsonEncode($errorMessage) );
5733 $retStatus_ary[
'txn'] = $aryTransferResults[
'txn'];
5736 $confirmationRequired = Perm_CheckConfirmReq($dbh, $HB_ENV, $permissionInputs);
5737 if (!$confirmationRequired) {
5739 $entryId = $aryTransferResults[
"txn"][
"trans_id"];
5741 if ( !ApproveTransfer( $dbh, $HB_ENV, $MC, $entryId, $aryApprovalResults ) ) {
5742 $errorMessage[] = $MC->msg(
"Trans approval failure", HCU_DISPLAY_AS_HTML);
5743 throw new Exception ( HCU_JsonEncode($errorMessage) );
5747 if ( $transferFeatureCode == FEATURE_TRANSFERS ||
5748 $transferFeatureCode == FEATURE_M2M_TRANSFERS ) {
5750 if ( !ProcessTransfer( $dbh, $HB_ENV, $MC, $entryId, $aryProcessResults ) ) {
5751 $errorMessage[] = $MC->msg(
"Trans processing failure", HCU_DISPLAY_AS_HTML);
5753 if ( count( $aryProcessResults[
"status"][
"errors"] ) > 0 ) {
5754 for ( $i = 0; $i < count( $aryProcessResults[
"status"][
"errors"] ); $i++ ) {
5755 $errorMessage[] = $aryProcessResults[
"status"][
"errors"][$i];
5758 throw new Exception ( HCU_JsonEncode($errorMessage) );
5762 $retStatus_ary[
'txn'][
'status'] = $MC->msg(
"Transfer posted", HCU_DISPLAY_AS_RAW);
5765 $retStatus_ary[
'txn'][
'status'] = $MC->msg(
"Transfer submitted for confirmation", HCU_DISPLAY_AS_RAW);
5769 $retStatus_ary[
'status'][
'code']=
'0';
5770 $retStatus_ary[
'status'][
'severity']=
'INFO';
5772 }
catch(Exception $ex)
5774 $retStatus_ary[
'status'][
'code']=
'999';
5775 $retStatus_ary[
'status'][
'severity']=
'ERROR';
5776 $retStatus_ary[
'status'][
'errors'] = HCU_JsonDecode( $ex->getMessage());
5777 $retStatus_ary[
'txn'] = array();
5779 return $retStatus_ary;
5787 function TxPostAdvanced( $pHBEnv, $pDbh, $inPost, $pMC) {
5788 $retStatusAry = Array(
5789 'status' => Array(
'code'=>
'000',
'errors' => Array()),
5795 $errorMessage = array();
5800 $sourceParts = isset( $inPost[
'FACCTID'] ) ? explode(
"|", $inPost[
'FACCTID'] ) : array();
5801 $destParts = isset( $inPost[
'TACCTID'] ) ? explode(
"|", $inPost[
'TACCTID'] ) : array();
5804 if ( (isset( $sourceParts[0] ) && $sourceParts[0] ===
"X") ||
5805 (isset( $destParts[0] ) && $destParts[0] ===
"X") ) {
5806 $transferFeatureCode = FEATURE_EXTERNAL_TRANSFERS;
5807 }
else if ( isset( $destParts[0] ) && $destParts[0] ===
"M" ) {
5808 $transferFeatureCode = FEATURE_M2M_TRANSFERS;
5810 $transferFeatureCode = FEATURE_TRANSFERS;
5812 # UGLY hidden dependency... SubmitTransfer function expects this in 5813 # the post array so load it here. 5814 $pHBEnv[
'HCUPOST'][
'feature_code'] = $transferFeatureCode;
5816 $permissionInputs = array(
"feature" => $transferFeatureCode );
5819 $accessRights = Perm_AccessRights( $pDbh, $pHBEnv, $permissionInputs );
5820 if ( !HCU_array_key_value(
"create", $accessRights ) ) {
5821 $errorMessage[] = $pMC->msg(
'Rights not set', HCU_DISPLAY_AS_HTML);
5822 throw new Exception ( HCU_JsonEncode($errorMessage) );
5826 $permissionInputs = array(
"feature" => $transferFeatureCode );
5827 $limits = Perm_GetValidationLimits( $pDbh, $pHBEnv, $permissionInputs );
5829 if ( $limits ===
false ) {
5833 $allowedAmount = floatval( $limits[
"amount_per_transaction"] );
5837 $txDateStart = trim( HCU_array_key_value(
"TXSTART", $inPost ) );
5838 if ( strlen( $txDateStart ) == 0 ) {
5839 $txDateStart = date(
"m/d/Y");
5845 $txData = array(
'txFrequency' => HCU_array_key_value(
'TXFREQ',$inPost),
5846 'txFromMember' => $sourceParts[1],
5847 'txFromSuffix' => $inPost[
'FACCTID'],
5848 'txToMember' => $destParts[1],
5849 'txToSuffix' => $inPost[
'TACCTID'],
5851 'txMemAccount' =>
null,
5852 'txMemName' =>
null,
5853 'txMemType' =>
null,
5854 'txCode' =>
null, #
this needs to
get set here, somehow?
5855 'txAmount' => HCU_array_key_value(
'AMOUNT',$inPost),
5856 'txMemo' => HCU_array_key_value(
'TRMEMO',$inPost),
5857 'txContinue' => HCU_array_key_value(
'TXCONTINUE',$inPost),
5858 'txDateStart' => $txDateStart,
5859 'txDateEnd' => HCU_array_key_value(
'TXEND',$inPost),
5861 'txPmtComment' =>
null,
5863 "feature_code" => $transferFeatureCode
5867 $aryTransferResults = PerformTransfer( $pHBEnv, $txData, $pHBEnv[
"MC"] );
5869 if ( $aryTransferResults[
"status"][
"code"] !=
"000" ) {
5870 if ( is_array( $aryTransferResults[
"status"][
"errors"] ) ) {
5871 for ( $i = 0; $i < count( $aryTransferResults[
"status"][
"errors"] ); $i++ ) {
5873 if ( is_array( $aryTransferResults[
"status"][
"errors"][$i] ) ) {
5874 $errorMessage[] = $aryTransferResults[
"status"][
"errors"][$i][
"message"];
5876 $errorMessage[] = $aryTransferResults[
"status"][
"errors"][$i];
5880 $errorMessage[] = $aryTransferResults[
"status"][
"errors"];
5885 if ( count( $errorMessage ) > 0 ) {
5886 if ($txData[
'txFrequency'] !=
'OneTime') {
5889 $errorMessage[] = $pMC->msg(
"Repeating transfer not saved", HCU_DISPLAY_AS_RAW);
5892 throw new Exception ( HCU_JsonEncode($errorMessage) );
5896 $retStatusAry[
'status'][
'code']=
'0';
5897 $retStatusAry[
'status'][
'severity']=
'INFO';
5901 if ( HCU_array_key_exists(
"repeat", $aryTransferResults[
"data"] ) && !is_array($aryTransferResults[
"data"][
"repeat"])) {
5903 $retStatusAry[
"txn"][
"status"] = $pMC->msg(
"Scheduled transfer was saved", HCU_DISPLAY_AS_RAW );
5906 if ( HCU_array_key_exists(
"txn", $aryTransferResults[
"data"] ) ) {
5907 $retStatusAry[
"txn"] = $aryTransferResults[
"data"][
"txn"];
5910 if ( HCU_array_key_exists(
"posted", $aryTransferResults[
"data"] ) ) {
5911 $retStatusAry[
"txn"][
"status"] = $aryTransferResults[
"data"][
"posted"];
5913 $retStatusAry[
"txn"][
"status"] = $pMC->msg(
"Transfer posted", HCU_DISPLAY_AS_RAW);
5916 }
catch(Exception $ex) {
5917 $retStatusAry[
'status'][
'code']=
'999';
5918 $retStatusAry[
'status'][
'severity']=
'ERROR';
5919 $retStatusAry[
'status'][
'errors'] = HCU_JsonDecode( $ex->getMessage());
5920 $retStatusAry[
'txn'] = array();
5923 return $retStatusAry;
5938 function GetUserPhones($CU, $UID, $HB_ENV) {
5940 $dbh = $HB_ENV[
'dbh'];
5943 $aryPhones = array();
5946 FROM {$CU}usercontact c 5947 LEFT JOIN {$CU}user u 5948 ON u.contact = c.contact_id 5949 WHERE u.user_id = {$UID}";
5950 $sqlRs = db_query($sql, $dbh);
5952 throw new Exception(
"Error reading phone numbers");
5954 $aryPhones = db_fetch_assoc($sqlRs, 0);
5955 if ($aryPhones[
'phones'] ===
null) {
5960 $aryPhones = HCU_JsonDecode($aryPhones[
'phones']);
5963 }
catch (Exception $e) {
5964 $aryPhones[
'errors'] = $e->getMessage();
5968 function format_us_number($phone) {
5969 $numbers_only = preg_replace(
"/[^\d]/",
"", $phone);
5970 return preg_replace(
"/^1?(\d{3})(\d{3})(\d{4})$/",
"$1-$2-$3", $numbers_only);
6014 function appTokenCookie ($HB_ENV) {
6016 $expires = $now + $HB_ENV[
'SYSENV'][
'ticket'][
'expires'];
6018 $mycookie =
"Ctime=$now" 6020 .
"&Cu={$HB_ENV['Cu']}" 6021 .
"&Cn={$HB_ENV['Cn']}" 6022 .
"&Uid={$HB_ENV['Uid']}" 6023 .
"&Clw={$HB_ENV['livewait']}" 6024 .
"&Clu={$HB_ENV['lastupdate']}" 6025 .
"&Fplog={$HB_ENV['Fplog']}" 6026 .
"&Fflog={$HB_ENV['Fflog']}" 6027 .
"&Ffchg={$HB_ENV['Ffchg']}" 6028 .
"&Ffreset={$HB_ENV['Ffreset']}" 6029 .
"&Ffremain={$HB_ENV['Ffremain']}" 6030 .
"&Fmsg_tx={$HB_ENV['Fmsg_tx']}" 6031 .
"&Fset={$HB_ENV['Fset']}" 6032 .
"&Fset2={$HB_ENV['Fset2']}" 6033 .
"&Fset3={$HB_ENV['Fset3']}" 6034 .
"&Fhdays={$HB_ENV['histdays']}" 6035 .
"&Ml=" . urlencode(trim($HB_ENV[
'Ml']))
6038 if (intval(HCU_array_key_value(
'testmenu', $HB_ENV[
'HCUPOST'])) == 1) {
6039 $mycookie .=
"&testmenu=1";
6041 $returnTicket = SetTicket($HB_ENV,
"", $mycookie);
6042 return $returnTicket;
6054 function GatherUserActivity( $pHBEnv, $pPass ) {
6055 require_once(dirname(__FILE__) .
'/../library/hcuUserActivity.i');
6058 $replyArr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO') );
6061 $replyArr[
"DTSERVER"] = date(
'YmdHis');
6062 $replyArr[
"MEMBER"] = $pHBEnv[
'Uid'];
6066 $params = array_change_key_case( $pPass, CASE_LOWER );
6069 $params[
"detail"] = !isset( $params[
"detail"] ) ? 0 : intval($params[
"detail"]);
6070 $params[
"prior"] = !isset( $params[
"prior"] ) ? 0 : 1;
6071 $params[
"pending"] = !isset( $params[
"pending"] ) ? 0 : 1;
6073 $params[
"scheduled"] = !isset( $params[
"scheduled"] ) ?
"" : strtolower($params[
"scheduled"]);
6076 $paramsToPassOn = array();
6080 $resultPending =
null;
6081 $resultScheduled =
null;
6082 $resultPrior =
null;
6084 $paramsToPassOn[
"action"] = !isset( $params[
"action"] ) ?
"" : $params[
"action"];
6087 $paramsToPassOn[
"filter"][
"type"] =
"";
6090 if ( isset( $params[
"initial"] ) && $params[
"initial"] == 1 ) {
6091 $resultMeta = GetUserActivityMetaData( $pHBEnv );
6094 if ( $resultMeta[
"code"] !=
"000" ) {
6095 throw new Exception(
"User activity: " . $resultMeta[
"error"], 15552 );
6099 if ( $params[
"pending"] == 1 ) {
6100 $resultPending = GetUserActivity( $pHBEnv,
"pending", $paramsToPassOn );
6103 if ( $resultPending[
"code"] !=
"000" ) {
6104 throw new Exception(
"User activity: " . $resultPending[
"error"], 15554 );
6108 if ( $params[
"scheduled"] ==
"all" ) {
6109 $paramsToPassOn[
"filter"][
"scheduled"] =
"all";
6111 $resultScheduled = GetUserActivity( $pHBEnv,
"scheduled", $paramsToPassOn );
6114 if ( $resultScheduled[
"code"] !=
"000" ) {
6115 throw new Exception(
"User activity: " . $resultScheduled[
"error"], 15551 );
6117 }
else if ( $params[
"scheduled"] !=
"" ) {
6119 $initialScheduledFilter = array(
"filter" => array(
"start" => date(
"Ymd" ),
6120 "end" => date(
"Ymd", time() + 30 * 24 * 60 * 60 ) ) );
6121 $resultScheduled = GetUserActivity( $pHBEnv,
"scheduled", $initialScheduledFilter );
6124 if ( $resultScheduled[
"code"] !=
"000" ) {
6125 throw new Exception(
"User activity: " . $resultScheduled[
"error"], 15555 );
6130 if ( $params[
"prior"] == 1 ) {
6132 if ( !isset( $params[
"dtend"] ) || ($params[
"dtend"] ==
"") ) {
6133 $dateEnd = date(
"Y-m-d" );
6135 $dateEnd = $params[
"dtend"];
6139 if ( !isset( $params[
"dtstart"] ) || ($params[
"dtstart"] ==
"") ) {
6140 $dateStart = date(
"Y-m-d", time() - 30 * 24 * 60 * 60 );
6142 $dateStart = $params[
"dtstart"];
6146 $testStart = strtotime( $dateStart );
6147 $testEnd = strtotime( $dateEnd );
6148 if ( $testStart > $testEnd ) {
6149 throw new Exception(
"User activity prior date start need to be <= date end", 15553 );
6152 $paramsToPassOn[
"filter"][
"start"] = $dateStart;
6153 $paramsToPassOn[
"filter"][
"end"] = $dateEnd;
6155 $resultPrior = GetUserActivity( $pHBEnv,
"prior", $paramsToPassOn );
6158 if ( $resultPrior[
"code"] !=
"000" ) {
6159 throw new Exception(
"User activity: " . $resultPrior[
"error"], 15556 );
6163 $resultPrior[
"data"][
"dtstart"] = date(
"Y-m-d", strtotime( $dateStart ) );
6164 $resultPrior[
"data"][
"dtend"] = date(
"Y-m-d", strtotime( $dateEnd ) );
6168 $replyArr[
"ACTIVITY"] = array();
6170 if ( $resultMeta !=
null ) {
6171 $replyArr[
"ACTIVITY"][
"meta"] = $resultMeta[
"data"];
6175 if ( $resultPending !=
null && is_array($resultPending[
'data']) ) {
6176 array_walk_recursive( $resultPending[
'data'],
'MakeHTMLEntities' );
6178 $replyArr[
'ACTIVITY'][
"pending"] = $resultPending[
'data'];
6181 if ( $resultScheduled !=
null && is_array($resultScheduled[
'data']) ) {
6182 array_walk_recursive( $resultScheduled[
'data'],
'MakeHTMLEntities' );
6184 $replyArr[
'ACTIVITY'][
"scheduled"] = $resultScheduled[
'data'];
6187 if ( $resultPrior !=
null && is_array($resultPrior[
'data']) ) {
6188 array_walk_recursive( $resultPrior[
'data'],
'MakeHTMLEntities' );
6190 $replyArr[
'ACTIVITY'][
"prior"] = $resultPrior[
'data'];
6195 }
catch( Exception $e ) {
6196 $code = $e->getCode();
6197 $message = $e->getMessage();
6200 $replyArr[
"STATUS"] = array(
'CODE' =>$code,
'SEVERITY' =>
'ERROR');
6201 $replyArr[
"MESSAGE"] = array(
"ERR" => $message );
6216 function GatherUserActivityDetail( $pHBEnv, $pDetailId, $pIsScheduled ) {
6217 require_once(dirname(__FILE__) .
'/../library/hcuUserActivity.i');
6220 $replyArr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO') );
6223 $replyArr[
"DTSERVER"] = date(
'YmdHis');
6224 $replyArr[
"MEMBER"] = $pHBEnv[
'Uid'];
6227 $resultDetail = GetActivityDetail( $pHBEnv, $pDetailId, $pIsScheduled );
6230 $replyArr[
"ACTIVITY"] = array();
6232 if ( $resultDetail !=
null && is_array($resultDetail[
'data']) ) {
6233 array_walk_recursive( $resultDetail[
'data'],
'MakeHTMLEntities' );
6237 $replyArr[
'ACTIVITY'][
"details"] = $resultDetail[
'data'];
6241 }
catch( Exception $e ) {
6242 $code = $e->getCode();
6243 $message = $e->getMessage();
6246 $replyArr[
"STATUS"] = array(
'CODE' =>$code,
'SEVERITY' =>
'ERROR');
6247 $replyArr[
"MESSAGE"] = array(
"ERR" => $message );
6263 function UserActivityAction( $pHBEnv, $pDetailId, $pIsScheduled, $pAction ) {
6264 require_once(dirname(__FILE__) .
'/../library/hcuUserActivity.i');
6267 $replyArr = array(
'STATUS' => array(
'CODE' => 0,
'SEVERITY' =>
'INFO') );
6270 $replyArr[
"DTSERVER"] = date(
'YmdHis');
6271 $replyArr[
"MEMBER"] = $pHBEnv[
'Uid'];
6275 $resultDetail = DoActivityAction( $pHBEnv, $pDetailId, $pIsScheduled, $pAction );
6277 if ( $resultDetail[
"code"] !=
"000" ) {
6279 throw new Exception($resultDetail[
"error"]);
6284 if ( $pAction ==
"approve" ) {
6285 if ( isset( $resultDetail[
"data"][
"confirm"] ) && strlen( $resultDetail[
"data"][
"confirm"] ) > 0 ) {
6286 $message = $pHBEnv[
"MC"]->msg(
"Transaction Sent", HCU_DISPLAY_AS_RAW) .
6288 $pHBEnv[
"MC"]->msg(
"Confirmation", HCU_DISPLAY_AS_RAW) .
": " . $resultDetail[
"data"][
"confirm"];
6290 $message = $pHBEnv[
"MC"]->msg(
"record approved", HCU_DISPLAY_AS_RAW);
6292 }
else if ( $pAction ==
"decline" ) {
6293 $message = $pHBEnv[
"MC"]->msg(
"record declined", HCU_DISPLAY_AS_RAW);
6294 }
else if ( $pAction ==
"cancel" ) {
6295 $message = $pHBEnv[
"MC"]->msg(
"record cancelled", HCU_DISPLAY_AS_RAW);
6297 $message =
"Unknown action received: $pAction";
6300 $resultDetail[
"data"][
"message"] = $message;
6303 $replyArr[
"ACTIVITY"] = array();
6305 if ( $resultDetail !=
null && is_array($resultDetail[
'data']) ) {
6306 array_walk_recursive( $resultDetail[
'data'],
'MakeHTMLEntities' );
6309 $replyArr[
'ACTIVITY'] = $resultDetail[
'data'];
6313 }
catch( Exception $e ) {
6314 $code = $e->getCode();
6315 $message = $e->getMessage();
6318 $code = $code > 0 ? $code :
"999";
6319 $replyArr[
"STATUS"] = array(
'CODE' =>$code,
'SEVERITY' =>
'ERROR');
6320 $replyArr[
"MESSAGE"] = array(
"ERR" => $message );
6328 function GetPendingUserActivity( $pHBEnv ) {
6329 $ucTransactionsCount = 0;
6331 $ucTransactions = ReturnUnconfirmedTransactions($pHBEnv[
'dbh'], $pHBEnv);
6332 if (is_array($ucTransactions)) {
6333 foreach ($ucTransactions as $key => $value) {
6334 $canConfirm = Perm_AccessRights($pHBEnv[
'dbh'], $pHBEnv, array(
"feature" => $value[
'feature_code']));
6335 if ($canConfirm[
'confirm']) {
6336 $ucTransactionsCount ++;
6341 return $ucTransactionsCount;
6345 function GetFakeUserCompassMenu( $pHBEnv ) {
6346 $fakeData = <<< ENDOFFAKEDATA
6348 "display":
"Sign Out",
6353 "display":
"User Activity",
6357 "script":
"hcuUserActivity.prg",
6361 "display":
"Secure Messages",
6365 "script":
"hcuSecureMail.prg",
6372 "endpoint":
"http://10.100.10.76:8000/banking/hcuAccountStatus.prg?cu=SCRUBCU",
6376 "display":
"User Info",
6381 "title":
"Password update required!",
6382 "message":
"Login expires after 20 more uses.",
6383 "icon":
"exclamation",
6385 "link":
"Update Now",
6386 "script":
"hcuProfilePwd.prg",
6391 "title":
"Your current email",
6392 "message":
"person@example.com",
6395 "link":
"Update Now",
6396 "script":
"hcuProfileEmail.prg",
6401 "title":
"Security credentials update required!",
6402 "message":
"Login expires after 1 more use.",
6403 "icon":
"exclamation-triangle",
6405 "link":
"Update Now",
6406 "script":
"hcuProfileSecurity.prg",
6419 function MakeHTMLEntities( &$item, $key ) {
6420 $item = htmlentities( $item, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE );