3 # 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 4 # Automatic 1-Way OFX as described in OFX 2.1.1 Specification, Section 16 7 # APPID : Identifies partner. Use OFXRQ for HomeCU app 8 # APPVER : required according to spec, not used at HomeCU. 11 # Script supports both SSO access and authenticated access methods. 12 # request will include either USERKEY (indicating SSO) 13 # or USERID/USERPASS (indicating authenticated access) 16 # USERPASS : password for authenticated account 17 # USERKEY : token for SSO access (replaces both USERID and USERPASS) 18 # CRED2 : Request date, UTC date/time in YYYYmmddHHMISS format 19 # CRED3 : hash # APPID USERID CRED2 hashed with assigned key 20 # DTSTART : Start date, default to 30days past 21 # DTEND : End date, default to today 26 $serviceMinimal =
true;
27 $serviceShowInfo =
false;
28 $serviceLoadMenu =
false;
29 $serviceShowMenu =
false;
33 require_once(dirname(__FILE__) .
'/../library/hcuService.i');
38 "APPID" => array(
'filter' => FILTER_SANITIZE_STRING),
39 "DTSTART" => array(
'filter' => FILTER_SANITIZE_STRING),
40 "DTEND" => array(
'filter' => FILTER_SANITIZE_STRING),
41 "CRED2" => array(
'filter' => FILTER_SANITIZE_STRING),
42 "CRED3" => array(
'filter' => FILTER_SANITIZE_STRING),
43 "USERID" => array(
'filter' => FILTER_SANITIZE_STRING),
44 "USERPASS" => array(
'filter' => FILTER_SANITIZE_STRING),
45 "USERKEY" => array(
'filter' => FILTER_SANITIZE_STRING),
46 "ORG" => array(
'filter' => FILTER_SANITIZE_STRING),
47 "RQMODE" => array(
'filter' => FILTER_SANITIZE_STRING),
48 "FACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
49 "TACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
50 "AMOUNT" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
51 "TRMEMO" => array(
'filter' => FILTER_SANITIZE_STRING),
52 "PASSTO" => array(
'filter' => FILTER_SANITIZE_STRING),
53 "PASSWITH" => array(
'filter' => FILTER_SANITIZE_STRING),
54 "KEYACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
55 "IPAYTAG" => array(
'filter' => FILTER_SANITIZE_STRING),
56 "IPAYINSTITUTION" => array(
'filter' => FILTER_SANITIZE_STRING),
57 "CFGFLAG" => array(
'filter' => FILTER_SANITIZE_STRING),
58 "UPDAWARE" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
61 # CFGFLAG is to be used to capture the session flag settings as used in Fmsg_tx on the desktop. Should be used 62 # currently in TXLIST / TXPOST to control whether or not to query the core for txaccount authority. Not implemented 63 # completely yet, but added to the Load_HB_ENV function and calls 65 HCU_ImportVars( $inPost,
"", $varOk );
66 # apptokenkey used only at HCU, not shared. Used to hash / check our token just to be sure it comes back unchanged. 67 $apptokenkey =
'Chahriv8pahvahsa';
73 if ($_SERVER[
'REQUEST_METHOD'] !=
'POST')
74 throw new Exception(
'Unauthorized Method',2010);# post method required
76 switch ($inPost[
'APPID']) {
79 $client_source_override =
'APP';
80 # no ip whitelist for iPhone app 81 $appkey =
"yuiQu8laLux7bahx";
86 $client_source_override =
'ADA';
87 # no ip whitelist for Android app 88 $appkey =
"Gai7Vain2pab5zae";
92 throw new Exception(
"Unauthorized ID",2020); # invalid app
id 95 # start date optional, must be valid if provided, default 30 days past 96 # end date optional, but must be valid if provided, default today 97 # either USERID/USERPASS or USERKEY is required 98 # USERID HomeCU MEMBER for aggregated access 99 # USERPASS password for aggregated access 100 # USERKEY required if USERID/USERPASS not given; SSO security token 101 # CRED2 required, UTC date in YYYYMMDDHHMI format. 102 # must be within 30 minutes of actual UTC time as shown on HomeCU servers 103 # CRED3 hash required, must match calculated hash 106 if (empty($inPost[
'CRED2']) || empty($inPost[
'ORG']) || empty($inPost[
'CRED3']) ) {
107 throw new Exception(
"Invalid Credentials",2030); # Missing values
110 if (empty($inPost[
'CRED2'])) {
111 $gmcheck = 0; # force date check to fail
113 # CRED2 is YYYY mm dd HH MI SS 114 # Passed to gmmktime as HH,MI,SS,mm,dd,YYYY 115 $HH = intval(substr($inPost[
'CRED2'], 8, 2));
116 $MI = intval(substr($inPost[
'CRED2'], 10, 2));
117 $SS = intval(substr($inPost[
'CRED2'], 12, 2));
118 $mm = intval(substr($inPost[
'CRED2'], 4, 2));
119 $dd = intval(substr($inPost[
'CRED2'], 6, 2));
120 $YYYY = intval(substr($inPost[
'CRED2'], 0, 4));
121 # convert UTC date/time on request to a (local) timestamp 122 $gmcheck = gmmktime($HH, $MI, $SS, $mm, $dd, $YYYY);
124 # and get the current timestamp 128 # date stretched for testing -- s/b 1800 (30 min) 129 if (empty($inPost[
'CRED2']) || empty($inPost[
'ORG']) || empty($inPost[
'CRED3']) || abs($gmdate - $gmcheck) > 1800) {
130 throw new Exception(
"Invalid Credentials or Device Date / Time",2030); # Missing values or expired token
132 $CU = $inPost[
'ORG'];
135 if (!empty($inPost[
'USERKEY'])) {
136 # got USERKEY, validate SSO method 137 # for Odyssey, both A=cauth_member and C=current member will be UID values 140 # $mytoken="H=$hash&E=$expires&A=$member"; 141 # 11/6/14 to support switch accounts 142 # $mytoken="H=$hash&E=$expires&A=$cauth_member&C=$current_member"; 144 $apptokarr = array();
145 parse_str(urldecode($inPost[
'USERKEY']), $apptokarr);
147 if ($apptokarr[
'E'] < time()) {
148 throw new Exception(
"Invalid Credentials (Expired Token) " . __LINE__,15510);
151 if (is_null($apptokarr[
'E']) || is_null($apptokarr[
'A']) || is_null($apptokarr[
'H'])) {
152 throw new Exception(
"Invalid Credentials (Partial Token) " . __LINE__,15510);
154 # if no C= value, assume oldstyle userkey 155 # and set member as A= value so hash works 156 # for odyssey A & C are swapped 157 # A is Uid, C is primary account 158 # Get_History call uses cauth as primary account 159 if (is_null($apptokarr[
'C'])) {
160 $CAUTH = $apptokarr[
'A'];
162 $CAUTH = $apptokarr[
'C'];
164 $MEMBER = $apptokarr[
'A'];
165 $EXPIRES = $apptokarr[
'E'];
166 $hash = MD5($apptokenkey .
167 MD5(join(
':', array($apptokenkey, $EXPIRES, $CU, $MEMBER, $CAUTH))));
168 if ($apptokarr[
'H'] != $hash) {
169 throw new Exception(
"Invalid Credentials (Corrupted Token) " . __LINE__,15510);
173 # No USERKEY, default to aggregate AUTH method 174 # for Odyssey, USERID will represent a user_name (login id) value 176 if (empty($inPost[
'USERID']) || strlen(trim($inPost[
'USERPASS'])) < 4) {
177 throw new Exception(
"Invalid Credentials",2040); #MFA missing ID / PASS
179 $MEMBER = $inPost[
'USERID'];
180 $CAUTH = $inPost[
'USERID'];
181 # odyssey shouldn't need this code - this stripped leading zeros from member number for all but the clients listed 182 if (!(preg_match(
"/\D/", $MEMBER)) && $live && $CU !=
'FTCFCU' && $CU !=
'UPFCU' && $CU !=
'LCSFCU' && $CU !=
'CEFCU') {
183 $MEMBER = preg_replace(
"/^0*/",
"", $MEMBER);
189 if (!empty($MEMBER) && (preg_match(
"/[\\\`,\"\s;]/", $MEMBER))) {
190 throw new Exception(
"Invalid Credentials",2041); #Member Bad Characters
192 # always consider CRED3 as containing ORG:MEMBER, even if USERKEY came in 193 # app always knows CU & Member 195 $hash = hash_hmac(
'MD5',
"${inPost['APPID']}${inPost['ORG']}:${MEMBER}${inPost['CRED2']}", $appkey);
196 #$show = "C member $MEMBER A cauth $CAUTH ${inPost['APPID']}${inPost['ORG']}:${MEMBER}${inPost['CRED2']}"; 197 if ($inPost[
'CRED3'] != $hash) {
200 throw new Exception(
"Authentication Failed",2050); # cred3
202 if (empty($CU) || empty($MEMBER)) {
203 # shouldn't be able to get here, but just in case .... 204 throw new Exception(
"Authentication Failed",2004); # missing CU / MEMBER
206 # set the basics so we can get the rest... 210 $HB_ENV[
'AuthMode'] = $AUTHMODE;
212 $foostring =
"HB_ENV \n" . print_r($HB_ENV,
true) .
"\n";
213 $HB_ENV[
"SYSENV"][
"logger"]->info( $foostring );
218 Check_HomeCU_Status($dbh, $HB_ENV);
221 $HB_ENV[
'platform'] = $client_source_override;
223 Load_HB_ENV($dbh, $CU, $MEMBER, $inPost[
'USERPASS'], $CAUTH, $HB_ENV, $CFGFLAG);
224 # set these things so they are available from the Global scope for 225 # throtlpkt functions 226 $MEMBER=$HB_ENV[
'Uid'];
229 $CAUTH = $HB_ENV[
'Cauth'];
230 $Clw = $HB_ENV[
'livewait'];
231 $Ml = urldecode($HB_ENV[
'Ml']);
233 $dflt_date = date(
"Ymd", time() - (30 * 24 * 60 * 60));
234 $dflt_date = date(
"Ymd", time() - (300 * 24 * 60 * 60));
235 $dflt_end = date(
"Ymd", time() + (4 * 24 * 60 * 60)); # + 4 days
236 $DTSTART = (empty($inPost[
'DTSTART']) ?
"$dflt_date" : $inPost[
'DTSTART']);
237 $DTEND = (empty($inPost[
'DTEND']) ?
"$dflt_end" : $inPost[
'DTEND']);
238 $sqlend = sqlmdy($DTEND);
240 $sqlend = $dflt_end;# won
't ever hit now, but left it anyway... 242 $HB_ENV['allowReadonly
'] = true; 243 if (!hcu_checkOffline($dbh, $HB_ENV)) { 244 throw new Exception($HB_ENV['offlineblurb
'],15520); # CU is marked offline 247 if ($HB_ENV['Cn
'] == "") { 248 throw new Exception('Authentication Failed
',2003); # invalid Cn 250 if ($HB_ENV['Cu
'] == "") { 251 throw new Exception('Authentication Failed
',2002); # invalid Cu 254 // Now supporting setting credentials from app, 255 // so 'Last Chance Login
' no longer applies if UPDAWARE is set 256 $UPDAWARE = (empty($inPost['UPDAWARE
']) ? 0 : 1); 257 if ($UPDAWARE == 0 && ($HB_ENV['Ffchg
'] == 'Y
' || $HB_ENV['Ffreset
'] > 0) && $HB_ENV['Ffremain
'] == 1) { 258 throw new Exception('Member Last Chance Login - Please log in through the full Home
Banking site to reset security credentials.
',15503); 261 # now that the HB_ENV array is filled, finish authentication if MFA 263 if ($AUTHMODE == "MFA") { 264 # moved this block inside the MFA check -- otherwise 265 # posting updates or asking for more data after logging in with alias 266 # would cause error because USERKEY is always built with Member# 268 # this block doesn't apply
for odyssey - everyone logs in with username
277 # moved this block inside the MFA check -- otherwise 278 # posting updates or asking for more data on last login 279 # would cause 'locked out' error 280 # failedremain <= 0 - too many failed logins 281 # forceupdate 9 - force pwd change or alias required & forceremain 0 282 # forceupdate 4 - can be set w/need more challenge or empty confidence or force security reset 283 # only lock out if force security resect and forceremain 0 284 # otherwise, flow through and will present security change 285 if ($HB_ENV[
'failedremain'] <= 0 ||
286 ( ($HB_ENV[
'forceupdate'] & 9) > 0 && $HB_ENV[
'Ffremain'] <= 0 ) ||
287 ( ($HB_ENV[
'forceupdate'] & 4) > 0 && $HB_ENV[
'Ffreset'] == 2 && $HB_ENV[
'Ffremain'] <= 0 )) {
288 throw new Exception(
'Member Account Locked',15502); # locked
291 # check USERPASS as password 292 if (!(trim($inPost[
'USERPASS']) >
'' && $HB_ENV[
'password'] == crypt($inPost[
'USERPASS'], $HB_ENV[
'password']) && ( preg_match(
'/^\$1\$/', $HB_ENV[
'password']) || strlen($inPost[
'USERPASS']) < 9))) {
294 $sth = db_query(
"select hcumbrloginfailed('$CU','{$HB_ENV['Cn']}',16)", $dbh);
295 $p_meta = array(
'UA' => $_SERVER[
'HTTP_USER_AGENT']);
296 $p_hbenv = array(
'Cu' => $CU,
'Cn' => $HB_ENV[
'Cn'],
'user_id' => $HB_ENV[
'Uid']);
297 TrackUserLogin($dbh, $p_hbenv, $client_source_override, 16, $_SERVER[
'REMOTE_ADDR'], $p_meta);
299 throw new Exception(
"Authentication Failed",15505); # password
301 # password ok, if Force pwd or verify mail, send upd request or fall thru to send data 302 # if not online, set the logtrack parameters to NOT decrement the remaining logins 303 $must = ($HB_ENV[
'offline'] !=
'N' || ($HB_ENV[
'forceupdate'] & 13) == 0 ?
'N' :
'Y');
304 $tomorrow = date(
'Y-m-d', mktime(0, 0, 0, date(
"m"), date(
"d") + 1, date(
"Y")));
305 $pchange = ($HB_ENV[
'offline'] !=
'N' ? $tomorrow : $HB_ENV[
'pwchange']);
306 $adjust = ($must ==
'Y' ? 1 : 0);
308 if ($HB_ENV[
'cver'] ==
'L') {
309 # Legacy login method, update login tracker and see if update is requested 310 $sth = db_query(
"select logtrack('$CU','{$HB_ENV['Cn']}','$must','$pchange','$client_source_override')", $dbh);
311 $p_meta = array(
'UA' => $_SERVER[
'HTTP_USER_AGENT']);
312 $p_hbenv = array(
'Cu' => $CU,
'Cn' => $HB_ENV[
'Cn'],
'user_id' => $HB_ENV[
'Uid']);
313 TrackUserLogin($dbh, $p_hbenv, $client_source_override, 0, $_SERVER[
'REMOTE_ADDR'], $p_meta);
315 # fix the value in HB_ENV 316 $HB_ENV[
'Ffremain']-=$adjust;
317 if ($HB_ENV[
'forceupdate'] > 0 && $UPDAWARE == 1 && $HB_ENV[
'offline'] ==
'N') {
318 Send_ReqUpdate($CU, $HB_ENV[
'Cn'], $HB_ENV[
'Cauth']);
321 #print_r($HB_ENV);print_r($drow);#exit; 322 # password ok & 2-factor, send upd request if security reset 323 if (($HB_ENV[
'forceupdate'] & 4) == 4 && $UPDAWARE == 1 && $HB_ENV[
'offline'] ==
'N') {
324 $sth = db_query(
"select logtrack('$CU','{$HB_ENV['Cn']}','$must','$pchange','$client_source_override')", $dbh);
325 $p_meta = array(
'UA' => $_SERVER[
'HTTP_USER_AGENT']);
326 $p_hbenv = array(
'Cu' => $CU,
'Cn' => $HB_ENV[
'Cn'],
'user_id' => $HB_ENV[
'Uid']);
327 TrackUserLogin($dbh, $p_hbenv, $client_source_override, 0, $_SERVER[
'REMOTE_ADDR'], $p_meta);
329 # and fix the corresponding value in HB_ENV 330 $HB_ENV[
'Ffremain']-=$adjust;
331 Send_ReqUpdate($CU, $HB_ENV[
'Cn'], $HB_ENV[
'Cauth']);
334 if (MFA_defined($inPost) > 0) {
335 # if (2-factor & not security reset) & MFA_* exists, we have MFA response, validate answers 336 list($fail, $failreason) = MFA_response($dbh, $HB_ENV, $inPost);
340 # challenge succeeded, update logtrack and prepare token 343 $HB_ENV[
'MFA'][
'challenge'] = 0; # reset the
'stuck' challenge question
344 $updstat = UpdateMemberLoginTrack($dbh, $HB_ENV[
'cu'], $MEMBER, $must, $pchange, $client_source_override, $HB_ENV[
'MFA']);
345 $p_meta = array(
'UA' => $_SERVER[
'HTTP_USER_AGENT']);
346 $p_hbenv = array(
'Cu' => $CU,
'Cn' => $HB_ENV[
'Cn'],
'user_id' => $HB_ENV[
'Uid']);
347 TrackUserLogin($dbh, $p_hbenv, $client_source_override, 0, $_SERVER[
'REMOTE_ADDR'], $p_meta);
349 # and fix the corresponding value in HB_ENV 350 $HB_ENV[
'Ffremain']-=$adjust;
352 if ($HB_ENV[
'forceupdate'] > 0 && $UPDAWARE == 1 && $HB_ENV[
'offline'] ==
'N') {
353 Send_ReqUpdate($CU, $HB_ENV[
'Cn'], $HB_ENV[
'Cauth']);
357 $updstat = UpdateMemberFailedLogin($dbh, $HB_ENV[
'cu'], $MEMBER, $GLOBALS[
'MEM_LOGIN_FAILED_QST']);
358 $p_meta = array(
'UA' => $_SERVER[
'HTTP_USER_AGENT']);
359 $p_hbenv = array(
'Cu' => $CU,
'Cn' => $HB_ENV[
'Cn'],
'user_id' => $HB_ENV[
'Uid']);
360 TrackUserLogin($dbh, $p_hbenv, $client_source_override, $failreason, $_SERVER[
'REMOTE_ADDR'], $p_meta);
362 MFA_send_chall($dbh, $HB_ENV, $MC);
365 # no MFA_, but still 2-factor, send challenge 366 MFA_send_chall($dbh, $HB_ENV, $MC);
371 apache_note(
'user_name',
"{$CU}:{$HB_ENV['Cn']}");
373 $apptoken = MakeUserkey($CU, $HB_ENV[
'Uid'], $HB_ENV[
'Cauth']);
375 $PASSWITH = $inPost[
'PASSWITH'];
376 switch ($inPost[
'RQMODE']) {
378 require_once(
'ipay.i');
383 $dbh = db_pconnect();
384 if (!hcu_checkService($dbh,
"IPAY")) {
385 $omsg = hcu_checkServiceMsg($dbh,
"IPAY");
386 throw new Exception($omsg,2077); # ipay offline
389 # if IPAYTAG is not provided, default to IPAYAPP 390 # look up cutrusteddetail with key IPAYTAG 391 # to get MOC status, url addresses, institution id, etc. 394 if (!empty($IPAYTAG)) {
395 $parray[
'trustedid'] = $IPAYTAG;
397 $parray[
'trustedid'] =
"IPAYAPP";
398 $IPAYTAG =
"IPAYAPP";
400 $trusted = cutd_read($dbh, $parray);
401 if ($trusted[
'status'][
'Response'] ==
'false') {
402 throw new Exception(
"Bill Pay Service not configured",2076); # no trusted vendor rec
405 $parms = $trusted[
'data'][
"$Cu|$IPAYTAG"];
406 $moc = $parms[
'moc'];
407 $datemodel = strtolower($parms[
'datemodel']);
409 $tokenurl = $parms[
'moctoken'];
410 $password = $parms[
'mocpass'];
411 $serviceurl = $parms[
'mocservice'];
413 $tokenurl = $parms[
'tokenurl'];
414 $password = $parms[
'password'];
415 $serviceurl = $parms[
'serviceurl'];
418 $parray = array(
'InstitutionId' => $parms[
'InstitutionId'],
'password' => $password,
'tokenurl' => $tokenurl);
419 $tokenresp = ipayGetToken($parray);
420 $token = $tokenresp[
'ipaydata'][
'token'];
422 $billpay = Get_Billpayid($dbh, $HB_ENV, $IPAYTAG);
424 if (!preg_match(
'/[^0-]/', $token)) {
425 throw new Exception(
"Bill Pay Service not available",2075); #
get token failed
427 $billpayid = trim($billpay[
'billpayid']);
428 $ofxcount += countprint(
"<IPAYTKN>\n<STATUS>\n<CODE>0</CODE>\n");
429 $ofxcount += countprint(
"<SEVERITY>INFO</SEVERITY>\n</STATUS>\n");
430 $ofxcount += countprint(
"<GETTOKENRESULT>$token</GETTOKENRESULT>\n");
431 if (
"$billpayid" !=
"" &&
"$billpayid" !== $HB_ENV[
'Cn']) {
432 $ofxcount += countprint(
"<BILLPAYID>$billpayid</BILLPAYID>\n");
434 $ofxcount += countprint(
"<INSTITUTIONID>${parms['InstitutionId']}</INSTITUTIONID>\n");
436 $ofxcount += countprint(
"<MOCSERVICE>$moc</MOCSERVICE>\n");
438 if ($datemodel ==
'due') {
439 $ofxcount += countprint(
"<DATEMODEL>DUE</DATEMODEL>\n");
441 $ofxcount += countprint(
"<DATEMODEL>PROCESS</DATEMODEL>\n");
443 $ofxcount += countprint(
"<MOBILESERVICESERVER>$serviceurl</MOBILESERVICESERVER>\n");
444 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
445 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
446 $ofxcount += countprint(
"</IPAYTKN>\n");
453 $expires = $now + $HB_ENV[
'SYSENV'][
'ticket'][
'expires'];
455 $mycookie =
"Ctime=$now&Cu={$HB_ENV['Cu']}&Cn={$HB_ENV['Cn']}&Uid={$HB_ENV['Uid']}&Ce=$expires&Ca=&Cauth={$CAUTH}&Ffchg={$HB_ENV['Ffchg']}&Ffremain={$HB_ENV['Ffremain']}&Fset={$HB_ENV['Fset']}&Fset2=${HB_ENV['Fset2']}&Fset3={$HB_ENV['Fset3']}&Fhdays={$HB_ENV['Fhdays']}&Flite=0&Clw={$HB_ENV['livewait']}&Clu={$HB_ENV['Clu']}&Fplog={$HB_ENV['Fplog']}&Fflog={$HB_ENV['Fflog']}&Fmsg_tx={$HB_ENV['Fmsg_tx']}&Ml={$HB_ENV['Ml']}&Flang=$Flang&Ffreset={$HB_ENV['Ffreset']}";
457 SetTicket($HB_ENV,
"", $mycookie);
459 switch ($inPost[
'PASSTO']) {
460 # seems extra, but this way we can change stuff at homecu 461 # without having to recompile app. 463 $PSCRIPT = $HB_ENV[
'homebankingpath'];
464 $PSCRIPT .=
"/ImageSOLO.prg";
465 $PSCRIPT .=
"?cu=${HB_ENV['Cu']}";
468 $PSCRIPT = urldecode($PASSWITH);
469 if (stripos($PSCRIPT,
'homecu') !==
false) {
470 $delim = (strpos($PSCRIPT,
'?') ===
false ?
'?' :
'&');
471 $PSCRIPT .=
"{$delim}vanilla=1";
476 $PSCRIPT = $HB_ENV[
'homebankingpath'];
477 $PSCRIPT .=
"/hcuConnect";
478 $PSCRIPT .=
"?cu=${HB_ENV['Cu']}";
479 # apps request plain vanilla screen, not upgrade-pretty 480 $PSCRIPT .=
"&vanilla=1";
483 $PSCRIPT = $HB_ENV[
'homebankingpath'];
484 $PSCRIPT .=
"/$PASSTO";
485 $PSCRIPT .=
"?cu=${HB_ENV['Cu']}";
487 if (!empty($PASSWITH))
488 $PSCRIPT .=
"&" . urldecode($PASSWITH);
490 header(
"Location: $PSCRIPT");
495 # PERKEY is the period key for the desired statement 496 # this could just parse PASSWITH into the environment, but I want to only take the parts I expect - 498 parse_str($PASSWITH, $pass);
499 $stId = $pass[
'PERKEY'];
500 # if stId is blank throw error 501 # Create_PDF_Statement will be responsible for the output 502 $pdfinfo = Create_PDF_Statement($stId, $HB_ENV, $MC);
507 #$PASSWITH="NOTICE_TYPE=${TYPE}&NOTICE_ID=${ID}&NOTICE_ACTION=${ACTION}&NOTICE_RESP=${ANSWERID}"; 508 # TYPE indicates notice, survey, mktg message, promo etc 509 # ID is the notice id previously sent or 0 if this is a 'get' 510 # ACTION is P for post or V to view/get 511 # ANSWERID (optional) is the chosen response for survey/mktg message 512 # this could just parse PASSWITH into HB_ENV['HCUPOST'], but I want to only take the parts I expect - 514 parse_str($PASSWITH, $pass);
516 switch ($pass[
'NOTICE_ACTION']) {
518 # action P post so set up the HCUPOST array 519 if (!empty($pass[
'NOTICE_ID']))
520 $HB_ENV[
'HCUPOST'][
'notice_id'] = $pass[
'NOTICE_ID'];
521 if (!empty($pass[
'NOTICE_TYPE']))
522 $HB_ENV[
'HCUPOST'][
'notice_type'] = $pass[
'NOTICE_TYPE'];
524 $resp_arr = ANS_list($pass);
525 $HB_ENV[
'HCUPOST'][
'notice_response'] = array();
526 foreach ($resp_arr as $key => $value) {
527 #print "key $key value $value <br>"; 528 $HB_ENV[
'HCUPOST'][
'notice_response'][] = $value;
531 $HB_ENV[
'HCUPOST'][
'notice_device'] =
'P';
532 $HB_ENV[
'HCUPOST'][
'notice_msg_show'] = 1;
534 $response = Update_NoticeInfo($dbh, $HB_ENV, $MC);
536 if (count($response[
'status'][
'errors']) > 0) {
537 throw new Exception(implode(
" ",$response[
'status'][
'errors']),15530); # Update_NoticeInfo
539 $ofxcount += countprint(
"<NOTICE_RESPONSE>\n<STATUS>\n<CODE>0</CODE>\n");
540 $ofxcount += countprint(
"<SEVERITY>INFO</SEVERITY>\n</STATUS>\n");
541 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
542 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
544 $ofxcount += countprint(
"<NOTICE>\n");
545 if (count($response[
'notice_results'])) {
546 foreach ($response[
'notice_results'] as $noticekey => $details) {
547 $ofxcount += countprint(
"<NOTICE_TYPE>{$details['notice_type']}</NOTICE_TYPE>\n");
548 $ofxcount += countprint(
"<NOTICE_ID>{$details['notice_id']}</NOTICE_ID>\n");
549 $ofxcount += countprint(
"<NOTICE_POPUP>{$details['notice_popup']}</NOTICE_POPUP>\n");
550 if ($pass[
'NOTICE_TYPE'] ==
'N') {
551 $ofxcount += countprint(
"<NOTICE_DONOTSHOWTEXT>" . htmlentities($details[
'notice_donotshowtext'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</NOTICE_DONOTSHOWTEXT>\n");
552 $ofxcount += countprint(
"<NOTICE_LINKTARGET>{$details['notice_linktarget']}</NOTICE_LINKTARGET>\n");
553 $ofxcount += countprint(
"<NOTICE_LINKDISPLAY>" . htmlentities($details[
'notice_linkdisplay'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</NOTICE_LINKDISPLAY>\n");
555 $ofxcount += countprint(
"<NOTICE_INTRO>" . htmlentities($details[
'notice_intro'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</NOTICE_INTRO>\n");
556 $ofxcount += countprint(
"<NOTICE_TITLE>" . htmlentities($details[
'notice_title'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</NOTICE_TITLE>\n");
557 $ofxcount += countprint(
"<NOTICE_TEXT>" . htmlentities(CleanWordQuotes($details[
'notice_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</NOTICE_TEXT>\n");
558 $ofxcount += countprint(
"<NOTICE_ANSWERTYPE>{$details['notice_answertype']}</NOTICE_ANSWERTYPE>\n");
559 $ofxcount += countprint(
"<NOTICE_ANSWERS>\n");
560 if (count($details[
'notice_answers'])) {
561 foreach ($details[
'notice_answers'] as $anskey => $ansdetl) {
562 $ofxcount += countprint(
"<ANSWER>\n");
563 $ofxcount += countprint(
"<ANSWER_ID>ANS_{$ansdetl['answer_id']}</ANSWER_ID>\n");
564 $ofxcount += countprint(
"<ANSWER_TEXT>" . htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</ANSWER_TEXT>\n");
565 $ofxcount += countprint(
"<ANSWER_VOTES>{$ansdetl['answer_votes']}</ANSWER_VOTES>\n");
566 $ofxcount += countprint(
"<ANSWER_PCT>{$ansdetl['answer_pct']}</ANSWER_PCT>\n");
567 $ofxcount += countprint(
"</ANSWER>\n");
570 $ofxcount += countprint(
"</NOTICE_ANSWERS>\n");
573 $ofxcount = + countprint(
"</NOTICE>\n");
574 $ofxcount = + countprint(
"</NOTICE_RESPONSE>");
579 case 'G': # gather multiple promos plus one survey/message
580 if ($pass[
'NOTICE_TYPE'] ==
'N') {
581 $response = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P', $pass[
'NOTICE_ID'], 0);
583 $response = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P', $pass[
'NOTICE_TYPE']);
585 if (count($response[
'status'][
'errors']) > 0) {
586 throw new Exception(implode(
" ",$response[
'status'][
'errors']),15540); # Get_NoticeInfo
588 $ofxcount += countprint(
"<NOTICE_MESSAGE>\n<STATUS>\n<CODE>0</CODE>\n");
589 $ofxcount += countprint(
"<SEVERITY>INFO</SEVERITY>\n</STATUS>\n");
590 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
591 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
593 if (count($response[
'notice'])) {
594 foreach ($response[
'notice'] as $noticekey => $details) {
595 $ofxcount += countprint(
"<NOTICE>\n");
599 if (!count($details[
'notice_answers']) &&
sizeof($details[
'notice_donotshowtext'])) {
600 $details[
'notice_answers'][] = array(
'answer_id' => $details[
'notice_id'],
'answer_text' => $details[
'notice_donotshowtext']);
601 $details[
'notice_answertype'] =
'M';
603 foreach ($details as $key => $value) {
604 $key = strtoupper($key);
606 case "NOTICE_ANSWERS":
607 $ofxcount += countprint(
"<NOTICE_ANSWERS>\n");
608 foreach ($value as $anskey => $ansdetl) {
609 $ofxcount += countprint(
"<ANSWER>\n");
610 $ofxcount += countprint(
"<ANSWER_ID>ANS_{$ansdetl['answer_id']}</ANSWER_ID>\n");
611 $ofxcount += countprint(
"<ANSWER_TEXT>" . htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</ANSWER_TEXT>\n");
613 $ofxcount += countprint(
"</ANSWER>\n");
615 $ofxcount += countprint(
"</NOTICE_ANSWERS>\n");
619 if ($pass[
'NOTICE_TYPE'] !=
'N') {
620 $ofxcount += countprint(
"<$key>" . htmlentities(CleanWordQuotes($value), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
626 case "NOTICE_DONOTSHOWTEXT":
627 case "NOTICE_MSG_TX":
628 case "NOTICE_MSG_TX_SHOW":
629 case "NOTICE_MSG_TX_PERM":
630 case "NOTICE_SUPPRESSRESPONSE":
631 case "NOTICE_POSTTARGET":
636 case "NOTICE_ANSWERTYPE":
637 case "NOTICE_LINKTARGET":
638 case "NOTICE_LINKDISPLAY":
643 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
646 $ofxcount += countprint(
"</NOTICE>");
649 $ofxcount += countprint(
"<NOTICE></NOTICE>");
652 $ofxcount = + countprint(
"</NOTICE_MESSAGE>");
657 # unknown notice_action -- ignore? 658 throw new Exception(
"Unknown Notice Mode",15550);
664 $HB_ENV[
'allowReadonly'] =
false;
665 if (!hcu_checkOffline($dbh, $HB_ENV)) {
666 throw new Exception($HB_ENV[
'offlineblurb'],15520); # TXLIST cu not online
669 # OFXRequest will accept CFGFLAG from app, set it in HB_ENV so it passes to TX_list / TX_post 670 # this was to maintain Fmsg_tx session flags w/o html session 671 # but didn't want to limit to ONLY Fmsg_tx - might need others in future 672 # coding ready for test in OFXRequest but not ready in server functions 673 #if cfgflag came in from app, pass it along on TX_list / TX_post call 674 # look for updated setting (of cfgflag? or of Fmsg_tx?) on return 675 # pass updated setting to app so they can return it again? 677 $txreturn = TX_list($dbh, $HB_ENV);
678 if (count($txreturn[
'status'][
'errors']) > 0) {
679 throw new Exception(implode(
' ',$txreturn[
'status'][
'errors']),15560); # TX_list returns System Unavailable
682 foreach ($txreturn[
'acctlist'] as $tx) {
683 if ($tx[
'from'] ==
'Y')
687 # FIX FOR PROD - Error checking, anyone? 688 # send appropriate status if we can't get a list 691 throw new Exception(
"No Accounts Available",15570); # TX_list no valid accounts
693 $ofxcount += countprint(
"<TXLIST>\n<STATUS>\n<CODE>0</CODE>\n");
694 $ofxcount += countprint(
"<SEVERITY>INFO</SEVERITY>\n</STATUS>\n");
695 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
696 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
697 $ofxcount += countprint(
"<TRMEMOMAX>${HB_ENV['trmemomaxlen']}</TRMEMOMAX>\n");
698 foreach ($txreturn[
'acctlist'] as $acctkey => $details) {
699 $ofxcount += countprint(
"<ACCT>\n<ACCTID>$acctkey</ACCTID>\n");
700 foreach ($details as $key => $value) {
701 $key = strtoupper($key);
702 $ofxcount += countprint(
"<$key>$value</$key>\n");
704 $ofxcount += countprint(
"</ACCT>\n");
707 # now get the transfer notice, if any 708 $txnotice = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'transferNotice', 0);
709 $ofxcount += countprint(
"<NOTICE>\n");
710 if (count($txnotice[
'notice'])) {
711 foreach ($txnotice[
'notice'] as $noticekey => $details) {
715 if (!count($details[
'notice_answers']) &&
sizeof($details[
'notice_donotshowtext'])) {
716 $details[
'notice_answers'][] = array(
'answer_id' => $details[
'notice_id'],
'answer_text' => $details[
'notice_donotshowtext']);
717 $details[
'notice_answertype'] =
'M';
719 foreach ($details as $key => $value) {
720 $key = strtoupper($key);
722 case "NOTICE_ANSWERS":
723 $ofxcount += countprint(
"<NOTICE_ANSWERS>\n");
724 foreach ($value as $anskey => $ansdetl) {
725 $ofxcount += countprint(
"<ANSWER>\n");
726 $ofxcount += countprint(
"<ANSWER_ID>ANS_{$ansdetl['answer_id']}</ANSWER_ID>\n");
728 $ofxcount += countprint(
"<ANSWER_TEXT>" . htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</ANSWER_TEXT>\n");
730 $ofxcount += countprint(
"</ANSWER>\n");
732 $ofxcount += countprint(
"</NOTICE_ANSWERS>\n");
740 case "NOTICE_DONOTSHOWTEXT":
741 case "NOTICE_MSG_TX":
742 case "NOTICE_MSG_TX_SHOW":
743 case "NOTICE_MSG_TX_PERM":
744 case "NOTICE_SUPPRESSRESPONSE":
745 case "NOTICE_POSTTARGET":
751 case "NOTICE_ANSWERTYPE":
752 case "NOTICE_LINKTARGET":
753 case "NOTICE_LINKDISPLAY":
756 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
761 $ofxcount += countprint(
"</NOTICE>");
765 $ofxcount += countprint(
"</TXLIST>\n");
772 $HB_ENV[
'allowReadonly'] =
false;
773 if (!hcu_checkOffline($dbh, $HB_ENV)) {
774 throw new Exception($HB_ENV[
'offlineblurb'],15520); # TXPOST cu not online
777 # unencode the email for the txpost call 778 $HB_ENV[
'Ml'] = urldecode($HB_ENV[
'Ml']);
779 # OFXRequest will accept CFGFLAG from app, set it in HB_ENV so it passes to TX_list / TX_post 780 # this was to maintain Fmsg_tx session flags w/o html session 781 # but didn't want to limit to ONLY Fmsg_tx - might need others in future 782 # coding ready for test in OFXRequest but not ready in server functions 783 #if cfgflag came in from app, pass it along on TX_list / TX_post call 784 # look for updated setting (of cfgflag? or of Fmsg_tx?) on return 785 # pass updated setting to app so they can return it again? 788 $txreturn = TX_post($MC, $dbh, $HB_ENV, $FACCTID, $TACCTID, $AMOUNT, $TRMEMO);
790 $HB_ENV[
'Ml'] = urlencode($HB_ENV[
'Ml']);
792 if (count($txreturn[
'status'][
'errors']) > 0) {
793 throw new Exception(implode(
' ',$txreturn[
'status'][
'errors']),15580); # TX_post returns data validation errors
796 # FIX FOR PROD - Error checking, anyone? 797 # send appropriate status if post fails 799 $ofxcount += countprint(
"<TXPOST>\n<STATUS>\n<CODE>0</CODE>\n");
800 $ofxcount += countprint(
"<SEVERITY>INFO</SEVERITY>\n</STATUS>\n");
801 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
802 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
803 foreach ($txreturn[
'txn'] as $key => $value) {
804 $key = strtoupper($key);
805 $ofxcount += countprint(
"<$key>$value</$key>\n");
807 $ofxcount += countprint(
"</TXPOST>\n");
812 case "MEMBERSETTINGS":
822 parse_str($PASSWITH, $pass);
824 if ($pass[
'GETALLOWED'] ==
'1') {
825 Send_AllowedUpdate($CU, $HB_ENV[
'Cn'], $HB_ENV[
'Cauth']);
827 $HB_ENV[
'requpdate'] = ($pass[
'GETSETTINGS'] & $HB_ENV[
'allowupdate']); #limit acceptable values based on cu config
828 if ($HB_ENV[
'requpdate'] == 0) {
829 throw new Exception(
'Invalid Settings Request',3125); # unrecognized GETSETTINGS request or not configured
831 Send_ReqUpdate($CU, $HB_ENV[
'Cn'], $HB_ENV[
'Cauth']);
837 parse_str($PASSWITH, $pass);
838 $upd_fields[
'settings_alias'][
'username'] = $pass[
'UALIAS'];
839 $upd_fields[
'settings_alias'][
'username_confirm'] = $pass[
'UALIAS'];
840 $upd_fields[
'settings_alias'][
'username_required'] = ($HB_ENV[
'alias'] ==
'REQUIRE' ?
'Y' :
'N');
841 $aryUpdate = Validate_Settings($dbh, $HB_ENV, $upd_fields, $MC);
843 if ($aryUpdate[
'status'][
'code'] ==
'000') {
844 Send_ResponseOK($CU, $HB_ENV[
'Uid'], $HB_ENV[
'Cauth'], 0,
"OK Selected Alias is valid and available"); # Selected Alias is valid and available
846 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']), 3162); # Selected Alias is not valid or usable
851 #$PASSWITH contains name=value pairs for each credential to be updated 852 # this could just parse PASSWITH into HB_ENV['HCUPOST'], but I want to only take the parts I expect - 854 parse_str($PASSWITH, $pass);
856 if ($pass[
'ASKLATER'] == 1) {
857 if ($HB_ENV[
'forceupdate'] > 0 && $HB_ENV[
'Ffremain'] == 0) {
858 throw new Exception(
'Requested Updates cannot be deferred',3150); # got
'ask later' response w/0 grace logins remaining
860 Send_ResponseOK($CU, $HB_ENV[
'Uid'], $HB_ENV[
'Cauth'], 1,
"OK Updates Deferred");
864 # start out thinking we won't need a transaction 865 $bolSQLTransaction =
false;
867 if (($HB_ENV[
'allowupdate'] & 4) == 4) {
868 # if challenge stuff allowed and provided, set fields to update, 870 if (!empty($pass[
'CONFWORD'])) {
871 $upd_fields[
'settings_confidence'][
'confword'] = $pass[
'CONFWORD'];
876 while (array_key_exists(
"CQID_{$quest_idx}", $pass)) {
877 $upd_fields[
'settings_questions'][] = Array(
'cqid' => $pass[
"CQID_{$quest_idx}"],
'display' => $pass[
"CQANS_{$quest_idx}"]);
883 if (trim($pass[
'NEWPWD']) >
'') {
884 $upd_fields[
'settings_password'][
'newpasswd'] = $pass[
'NEWPWD'];
885 $upd_fields[
'settings_password'][
'confpasswd'] = $pass[
'NEWPWD'];
891 if (!empty($pass[
'EMAIL'])) {
892 $upd_fields[
'settings_email'][
'email'] = $pass[
'EMAIL'];
893 $upd_fields[
'settings_email'][
'egenl'] = $pass[
'OPTIN'];
894 $upd_fields[
'settings_email'][
'verify'] = ($HB_ENV[
'Fverifyml'] == 512 ?
'Y' :
'N');
895 $upd_fields[
'settings_email'][
'valid'] =
'Y';
900 if (($HB_ENV[
'allowupdate'] & 8) == 8 && ($pass[
'UALIAS']) !=
'') {
901 $upd_fields[
'settings_alias'][
'username'] = $pass[
'UALIAS'];
902 $upd_fields[
'settings_alias'][
'username_confirm'] = $pass[
'UALIAS'];
903 $upd_fields[
'settings_alias'][
'username_required'] = ($HB_ENV[
'alias'] ==
'REQUIRE' ?
'Y' :
'N');
904 $bolSQLTransaction =
true;
908 if (trim($pass[
'NEWPWD']) >
'') {
909 $aryUpdate = Validate_PwdRules($dbh, $HB_ENV, $upd_fields, $MC);
911 if ($aryUpdate[
'status'][
'code'] !=
'000') {
913 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']),3160); # Validate_Settings
917 $aryUpdate = Validate_Settings($dbh, $HB_ENV, $upd_fields, $MC);
919 if ($aryUpdate[
'status'][
'code'] !=
'000') {
921 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']),3160); # Validate_Settings
922 #print_r($HB_ENV); print_r($upd_fields); exit; 926 $HB_ENV[
'Ml'] = urldecode($HB_ENV[
'Ml']);
927 $aryUpdate = Update_Settings($dbh, $HB_ENV, $upd_fields, $bolSQLTransaction, $MC);
929 $HB_ENV[
'Ml'] = urlencode($HB_ENV[
'Ml']);
931 if ($aryUpdate[
'status'][
'code'] !=
'000') {
933 throw new Exception(implode(
' ',$aryUpdate[
'status'][
'errors']),3170); # Update_Settings
937 Send_ResponseOK($CU, $HB_ENV[
'Uid'], $HB_ENV[
'Cauth'], 1,
"OK Updates Successful");
946 $parms[
'Cu'] = $HB_ENV[
'Cu'];
947 $parms[
'Cn'] = $HB_ENV[
'Cn'];
950 parse_str($PASSWITH, $pass);
951 if (!isset($pass[
'MP_VENDOR'])) {
952 throw new Exception(
"Missing Mobile Pay parameters",4001);
954 switch ($pass[
'MP_VENDOR']) {
959 if (hcu_checkService($dbh,
'IPAY') !==
true) {
960 $omsg = hcu_checkServiceMsg($dbh,
"IPAY");
961 throw new Exception(
"$omsg",999); # MOBLPAY AUTH
963 if ($pass[
'MP_VENDOR'] ==
'IPAYJX') {
964 require_once(
'IPAYJX.i');
966 require_once(
'IPAYMBL.i');
970 if (hcu_checkService($dbh,
'CHKFREE') !==
true) {
971 $omsg = hcu_checkServiceMsg($dbh,
"CHKFREE");
972 throw new Exception(
"$omsg",999); # MOBLPAY AUTH
974 require_once(
'CHKFREE.i');
977 if (hcu_checkService($dbh,
'PSCU') !==
true) {
978 $omsg = hcu_checkServiceMsg($dbh,
"PSCU");
979 throw new Exception(
"$omsg",999); # MOBLPAY AUTH
981 require_once(
'PSCUPAY_API.i');
985 require_once(
'MBLPAY_TEST.i');
988 throw new Exception(
"Invalid Mobile Pay vendor",4001);
992 $parray[
'trustedid'] = $pass[
'MP_VENDOR'];
993 $trusted = cutd_read($dbh, $parray);
994 if ($trusted[
'status'][
'Response'] ==
'false') {
995 throw new Exception(
"Bill Pay Service not configured",2076); # no trusted vendor rec
997 $parms = $trusted[
'data'][
"$Cu|{$pass['MP_VENDOR']}"];
999 # set up logging here 1000 $loggingFlag = trim($parms[
"hcuLogging"]);
1001 if (strlen($loggingFlag) > 0) {
1003 $enable = $loggingFlag == -1;
1006 $loggingFlag = str_replace(
" ",
"", $loggingFlag);
1007 $testArray = explode(
",", $loggingFlag);
1008 $enable = in_array($HB_ENV[
"Cn"], $testArray);
1013 $parms[
"logging"] =
"enabled";
1014 $parms[
"environment"] = array(
"Cu" => $HB_ENV[
"Cu"],
1015 "memberId" => $HB_ENV[
"Cn"],
1016 "SSOVendor" => $pass[
'MP_VENDOR'],
1017 "userIP" => $_SERVER[
'REMOTE_ADDR'],
1022 $billpay = Get_Billpayid($dbh, $HB_ENV, $pass[
'MP_VENDOR']);
1023 $parms[
'BillpayId'] = trim($billpay[
'billpayid']);
1024 $parms[
'passwith'] = $pass;
1025 switch ($pass[
'MP_ACTION']) {
1027 $mblpay = bpAuth($parms);
1028 # deal with response 1030 if ($mblpay[
'status'][
'code'] ==
'000' && strlen($mblpay[
"data"][
'Token']) > 0) {
1031 # good token, return the response 1032 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1033 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1034 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1036 if (is_array($mblpay[
'data'])) {
1037 $ofxcount += countprint(
"<MP_AUTH>\n");
1038 foreach ($mblpay[
'data'] as $key => $value) {
1041 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1043 $ofxcount += countprint(
"</MP_AUTH>\n");
1045 $ofxcount += countprint(
"</MBLPAY>\n");
1049 $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC,
"M",
"mblNoMobilePay",
true);
1051 if ($noticesAry[
"status"][
"code"] ==
"000" && $noticesAry[
"notice"][0][
"notice_id"]) {
1052 $noticeString = $noticesAry[
"notice"][0][
"notice_text"];
1054 $noticeString = $mblpay[
'status'][
'message'];
1057 throw new Exception($noticeString,$mblpay[
'status'][
'code']); # MOBLPAY AUTH
get token failed
1062 $mblpay = bpGetTerms($parms);
1063 # deal with response 1064 if ($mblpay[
'status'][
'response'] ==
'false') {
1065 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY AUTH
1068 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1069 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1070 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1071 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1073 if (is_array($mblpay[
'data'])) {
1074 $ofxcount += countprint(
"<MP_TERMS>\n");
1075 foreach ($mblpay[
'data'] as $key => $value) {
1078 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1080 $ofxcount += countprint(
"</MP_TERMS>\n");
1082 $ofxcount += countprint(
"</MBLPAY>\n");
1087 $mblpay = bpAcceptTerms($parms);
1088 # deal with response 1089 if ($mblpay[
'status'][
'response'] ==
'false') {
1090 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY AUTH
1093 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1094 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1095 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1096 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1098 if (is_array($mblpay[
'data'])) {
1099 $ofxcount += countprint(
"<MP_ACCEPT>\n");
1100 foreach ($mblpay[
'data'] as $key => $value) {
1103 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1105 $ofxcount += countprint(
"</MP_ACCEPT>\n");
1107 $ofxcount += countprint(
"</MBLPAY>\n");
1112 # set Account type for from 1113 # AcctType = Payment | Transfer 1114 # Detailed = 'True' | 'False' (may be missing, false) 1115 $mblfrom = bpSourceAccts($parms);
1116 # determine payment or transfer, set Account type accordingly 1117 $mblpay = bpDestAccts($parms);
1119 # deal with response 1120 if ($mblfrom[
'status'][
'response'] ==
'false') {
1121 throw new Exception($mblfrom[
'status'][
'message'], $mblfrom[
'status'][
'code']); # MOBLPAY SourceAccts
1123 if ($mblpay[
'status'][
'response'] ==
'false') {
1124 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY DestAccts
1127 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1128 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1129 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1130 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1132 if (is_array($mblfrom[
'data']) || is_array($mblpay[
'data'])) {
1133 $ofxcount += countprint(
"<MP_ACCTLIST>\n");
1135 if (is_array($mblfrom[
'data'])) {
1137 $ofxcount += countprint(
"<SOURCEACCTS>\n");
1138 foreach ($mblfrom[
'data'] as $akey => $account) {
1139 $ofxcount += countprint(
"<Account>\n");
1140 foreach ($account as $key => $value) {
1141 if ($key ==
'AdditionalInfo') {
1142 $ofxcount += countprint(
"<AdditionalInfo>\n");
1143 $ofxcount += countprint(htmlentities(http_build_query($value)));
1144 $ofxcount += countprint(
"\n</AdditionalInfo>\n");
1145 } elseif ($key ==
'Name') {
1146 $ofxcount += countprint(
"<Name>\n");
1147 $ofxcount += countprint(htmlentities($value));
1148 $ofxcount += countprint(
"\n</Name>\n");
1152 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1155 $ofxcount += countprint(
"</Account>\n");
1157 $ofxcount += countprint(
"</SOURCEACCTS>\n");
1159 if (is_array($mblpay[
'data'])) {
1160 $ofxcount += countprint(
"<DESTACCTS>\n");
1161 foreach ($mblpay[
'data'] as $akey => $account) {
1162 $ofxcount += countprint(
"<Account>\n");
1163 foreach ($account as $key => $value) {
1164 if ($key ==
'AdditionalInfo') {
1165 $ofxcount += countprint(
"<AdditionalInfo>\n");
1166 $ofxcount += countprint(htmlentities(http_build_query($value)));
1167 $ofxcount += countprint(
"\n</AdditionalInfo>\n");
1168 } elseif ($key ==
'Name') {
1169 $ofxcount += countprint(
"<Name>\n");
1170 $ofxcount += countprint(htmlentities($value));
1171 $ofxcount += countprint(
"\n</Name>\n");
1175 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1178 $ofxcount += countprint(
"</Account>\n");
1180 $ofxcount += countprint(
"</DESTACCTS>\n");
1182 $ofxcount += countprint(
"</MP_ACCTLIST>\n");
1184 $ofxcount += countprint(
"</MBLPAY>\n");
1186 case "MP_GETPAYMENTDATES":
1187 $mblpay = bpGetPaymentDates($parms);
1189 # deal with response 1190 if ($mblpay[
'status'][
'response'] ==
'false') {
1191 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY DATES
1194 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1195 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1196 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1197 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1199 if (is_array($mblpay[
'data'])) {
1200 $ofxcount += countprint(
"<MP_GETPAYMENTDATES>\n");
1201 foreach ($mblpay[
'data'] as $pkey => $paydate) {
1204 if (is_array($paydate)) {
1205 $ofxcount += countprint(
"<RushOptions>\n");
1206 foreach ($paydate as $dateitem) {
1207 if (is_array($dateitem)) {
1208 $ofxcount += countprint(
"<Option>\n");
1209 foreach ($dateitem as $key => $value) {
1211 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1213 $ofxcount += countprint(
"</Option>\n");
1216 $ofxcount += countprint(
"</RushOptions>\n");
1219 case 'PaymentDates':
1220 if (is_array($paydate)) {
1221 $ofxcount += countprint(
"<PaymentDates>\n");
1222 foreach ($paydate as $dateitem) {
1223 if (is_array($dateitem)) {
1224 $ofxcount += countprint(
"<Date>\n");
1225 foreach ($dateitem as $key => $value) {
1227 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1229 $ofxcount += countprint(
"</Date>\n");
1232 $ofxcount += countprint(
"</PaymentDates>\n");
1236 $ofxcount += countprint(
"<$pkey>$paydate</$pkey>\n");
1240 $ofxcount += countprint(
"</MP_GETPAYMENTDATES>\n");
1242 $ofxcount += countprint(
"</MBLPAY>\n");
1245 $mblpay = bpHist($parms);
1247 # deal with response 1248 if ($mblpay[
'status'][
'response'] ==
'false') {
1249 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1252 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1253 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1254 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1255 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1257 if (is_array($mblpay[
'data'])) {
1258 $ofxcount += countprint(
"<MP_HISTORY>\n");
1259 foreach ($mblpay[
'data'] as $pkey => $payment) {
1260 $ofxcount += countprint(
"<Payment>\n");
1261 foreach ($payment as $key => $value) {
1262 if ($key ==
'AdditionalInfo') {
1264 $ofxcount += countprint(
"<AdditionalInfo>\n");
1268 $ofxcount += countprint(htmlentities(http_build_query($value)));
1269 $ofxcount += countprint(
"\n</AdditionalInfo>\n");
1273 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1276 $ofxcount += countprint(
"</Payment>\n");
1278 $ofxcount += countprint(
"</MP_HISTORY>\n");
1281 $ofxcount += countprint(
"</MBLPAY>\n");
1283 case "MP_GETRUSHOPTIONS":
1284 $mblpay = bpGetRushOptions($parms);
1286 # deal with response 1287 if ($mblpay[
'status'][
'response'] ==
'false') {
1288 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1291 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1292 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1293 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1294 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1296 if (is_array($mblpay[
'data'])) {
1297 $ofxcount += countprint(
"<MP_GETRUSHOPTIONS>\n");
1298 foreach ($mblpay[
'data'] as $key => $value) {
1301 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1303 $ofxcount += countprint(
"</MP_GETRUSHOPTIONS>\n");
1305 $ofxcount += countprint(
"</MBLPAY>\n");
1307 case "MP_SCHEDULED":
1308 $mblpay = bpSched($parms);
1310 # deal with response 1311 if ($mblpay[
'status'][
'response'] ==
'false') {
1312 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1315 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1316 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1317 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1318 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1320 if (is_array($mblpay[
'data'])) {
1321 $ofxcount += countprint(
"<MP_SCHEDULED>\n");
1322 foreach ($mblpay[
'data'] as $pkey => $payment) {
1323 $ofxcount += countprint(
"<Payment>\n");
1324 foreach ($payment as $key => $value) {
1325 if ($key ==
'AdditionalInfo') {
1327 $ofxcount += countprint(
"<AdditionalInfo>\n");
1331 $ofxcount += countprint(htmlentities(http_build_query($value)));
1332 $ofxcount += countprint(
"\n</AdditionalInfo>\n");
1336 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1339 $ofxcount += countprint(
"</Payment>\n");
1341 $ofxcount += countprint(
"</MP_SCHEDULED>\n");
1343 $ofxcount += countprint(
"</MBLPAY>\n");
1347 $mblpay = bpPmtAdd($parms);
1349 # deal with response 1350 if ($mblpay[
'status'][
'response'] ==
'false') {
1351 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1354 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1355 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1356 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1357 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1359 if (is_array($mblpay[
'data'])) {
1360 $ofxcount += countprint(
"<MP_PAYMENT>\n");
1361 foreach ($mblpay[
'data'] as $key => $value) {
1364 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1366 $ofxcount += countprint(
"</MP_PAYMENT>\n");
1368 $ofxcount += countprint(
"</MBLPAY>\n");
1372 $mblpay = bpTrnAdd($parms);
1374 # deal with response 1375 if ($mblpay[
'status'][
'response'] ==
'false') {
1376 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1379 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1380 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1381 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1382 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1384 if (is_array($mblpay[
'data'])) {
1385 $ofxcount += countprint(
"<MP_TRANSFER>\n");
1386 foreach ($mblpay[
'data'] as $key => $value) {
1389 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1391 $ofxcount += countprint(
"</MP_TRANSFER>\n");
1393 $ofxcount += countprint(
"</MBLPAY>\n");
1396 $mblpay = bpPmtEdit($parms);
1398 # deal with response 1399 if ($mblpay[
'status'][
'response'] ==
'false') {
1400 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1403 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1404 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1405 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1406 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1408 if (is_array($mblpay[
'data'])) {
1409 $ofxcount += countprint(
"<MP_EDITPMT>\n");
1410 foreach ($mblpay[
'data'] as $key => $value) {
1413 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1415 $ofxcount += countprint(
"</MP_EDITPMT>\n");
1417 $ofxcount += countprint(
"</MBLPAY>\n");
1421 $mblpay = bpPmtStop($parms);
1423 # deal with response 1424 if ($mblpay[
'status'][
'response'] ==
'false') {
1425 throw new Exception($mblpay[
'status'][
'message'], $mblpay[
'status'][
'code']); # MOBLPAY HIST
1428 $ofxcount += countprint(
"<MBLPAY>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1429 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1430 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1431 $ofxcount += countprint(
"<TOKEN>{$pass['Token']}</TOKEN>\n");
1433 if (is_array($mblpay[
'data'])) {
1434 $ofxcount += countprint(
"<MP_STOPPMT>\n");
1435 foreach ($mblpay[
'data'] as $key => $value) {
1438 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1440 $ofxcount += countprint(
"</MP_STOPPMT>\n");
1442 $ofxcount += countprint(
"</MBLPAY>\n");
1447 throw new Exception(
"Unknown MOBLPAY Mode",15550);
1453 parse_str($PASSWITH, $pass);
1454 if (!isset($pass[
'MSG_SERVICE'])) {
1455 throw new Exception(
"Missing Message parameters",4001);
1458 $parms[
'Cu'] = $HB_ENV[
'Cu'];
1459 $parms[
'Cn'] = $HB_ENV[
'Cn'];
1460 $parms[
'HCUPOST'] = $pass;
1462 switch ($pass[
'MSG_SERVICE']) {
1464 require_once(
'msgECO.i');
1467 throw new Exception(
"Invalid Message Service",4001);
1470 switch ($pass[
'MSG_ACTION']) {
1472 $msgResp = msgReadMessages($dbh, $parms);
1474 # deal with response 1475 if ($msgResp[
'status'][
'response'] ==
'false') {
1476 throw new Exception($msgResp[
'status'][
'message'], $msgResp[
'status'][
'code']); # MESSAGE READ_MSGS
1479 $ofxcount += countprint(
"<MESSAGE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1480 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1481 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1483 if (is_array($msgResp[
'data'])) {
1484 $ofxcount += countprint(
"<READ_MSGS>\n");
1485 foreach ($msgResp[
'data'] as $key => $value) {
1486 if (is_array($value)) {
1487 $ofxcount += countprint(
"<MSG>\n");
1488 foreach ($value as $mkey => $mvalue) {
1491 $mvalue = htmlentities($mvalue, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1494 $ofxcount += countprint(
"<$mkey>$mvalue</$mkey>\n");
1496 $ofxcount += countprint(
"</MSG>\n");
1499 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
1502 $ofxcount += countprint(
"</READ_MSGS>\n");
1504 $ofxcount += countprint(
"</MESSAGE>\n");
1508 $msgResp = msgReadMessageThread($dbh, $parms);
1510 # deal with response 1511 if ($msgResp[
'status'][
'response'] ==
'false') {
1512 throw new Exception($msgResp[
'status'][
'message'], $msgResp[
'status'][
'code']); # MESSAGE READ_MSGS
1515 $ofxcount += countprint(
"<MESSAGE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1516 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1517 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1519 if (is_array($msgResp[
'data'])) {
1520 $ofxcount += countprint(
"<READ_THREAD>\n");
1521 foreach ($msgResp[
'data'] as $key => $value) {
1522 if (is_array($value)) {
1523 $ofxcount += countprint(
"<MSG>\n");
1524 foreach ($value as $mkey => $mvalue) {
1528 $mvalue = htmlentities($mvalue, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE);
1531 $ofxcount += countprint(
"<$mkey>$mvalue</$mkey>\n");
1533 $ofxcount += countprint(
"</MSG>\n");
1535 $ofxcount += countprint(
"<$key>$value</$key>\n");
1538 $ofxcount += countprint(
"</READ_THREAD>\n");
1540 $ofxcount += countprint(
"</MESSAGE>\n");
1544 $msgResp = msgSendMessage($dbh, $parms, $MC);
1546 # deal with response 1547 if ($msgResp[
'status'][
'response'] ==
'false') {
1548 throw new Exception($msgResp[
'status'][
'message'], $msgResp[
'status'][
'code']); # MESSAGE READ_MSGS
1551 $ofxcount += countprint(
"<MESSAGE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1552 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1553 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1554 $ofxcount += countprint(
"<SEND_MSG>\n{$msgResp['status']['message']}\n</SEND_MSG>\n");
1555 $ofxcount += countprint(
"</MESSAGE>\n");
1558 $msgResp = msgDeleteMessageThread($dbh, $parms);
1560 # deal with response 1561 if ($msgResp[
'status'][
'response'] ==
'false') {
1562 throw new Exception($msgResp[
'status'][
'message'], $msgResp[
'status'][
'code']); # MESSAGE READ_MSGS
1565 $ofxcount += countprint(
"<MESSAGE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1566 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1567 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1568 $ofxcount += countprint(
"<DEL_MSG>\n{$msgResp['status']['message']}\n</DEL_MSG>\n");
1569 $ofxcount += countprint(
"</MESSAGE>\n");
1572 $msgResp = msgCheckForMessages($dbh, $parms);
1574 # deal with response 1575 if ($msgResp[
'status'][
'response'] ==
'false') {
1576 throw new Exception($msgResp[
'status'][
'message'], $msgResp[
'status'][
'code']); # MESSAGE READ_MSGS
1579 $ofxcount += countprint(
"<MESSAGE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1580 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1581 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1583 if (is_array($msgResp[
'data'])) {
1585 $ofxcount += countprint(
"<CHECK_MSG>\n");
1586 foreach ($msgResp[
'data'] as $key => $value) {
1587 $ofxcount += countprint(
"<$key>$value</$key>\n");
1589 $ofxcount += countprint(
"</CHECK_MSG>\n");
1591 $ofxcount += countprint(
"</MESSAGE>\n");
1595 # unknown MSG_ACTION 1596 throw new Exception(
"Unknown MESSAGE Mode",15550);
1602 include(
'rdcCommon.i'); # HCU functions common to all RDC vendors
1612 parse_str(urldecode($PASSWITH), $pass);
1614 $rdcparms = array();
1615 $rdcparms[
'chome'] = $HB_ENV[
'chome'];
1616 $rdcparms[
'Flang'] = $HB_ENV[
'Flang'];
1617 $rdcparms[
'Cu'] = $HB_ENV[
'Cu'];
1618 $rdcparms[
'Cn'] = $HB_ENV[
'Cn'];
1619 $rdcparms[
'Ml'] = $HB_ENV[
'Ml'];
1620 $rdcparms[
'passwith'] = $pass;
1621 # if the app did not send a depositid look for RDCVENDOR 1622 if (!isset($pass[
'DEPOSITID'])) {
1623 $rdcparms[
'rdcvendor'] = $pass[
'RDCVENDOR'];
1626 RDCsession($dbh,$rdcparms);
1628 switch (
"{$rdcparms['rdcvendor']}") {
1630 $verVen =
"ENSENTA";
1631 include_once(
'rdcEnsenta.i');
1633 case "RDCBluepoint":
1634 $verVen =
"Bluepoint";
1635 include_once(
'rdcBluepoint.i');
1638 $verVen =
"Catalyst";
1639 include_once(
'rdcTranzCap.i');
1643 include_once(
'rdcVSoft.i');
1648 throw new Exception(
"Missing RDC parameters",4001);
1651 if ($verVen !=
"" && !hcu_checkService($dbh, $verVen)) {
1652 $omsg = hcu_checkServiceMsg($dbh, $verVen);
1653 throw new Exception($omsg,2077); # RDC vendor offline
1655 RDCconfig($dbh,$rdcparms);
1658 switch ($pass[
'RDC_ACTION']) {
1661 $rdcsays = RDCauth($dbh, $HB_ENV, $MC, $rdcparms);
1662 # deal with response 1663 if ($rdcsays[
'status'][
'response'] ==
'false') {
1664 if ($rdcsays[
'status'][
'code'] ==
'110' || $rdcsays[
'status'][
'code'] ==
'111') {
1669 throw new Exception($rdcsays[
'status'][
'message'],$rcode); # RDC AUTH
1671 $ofxcount += countprint(
"<RDC_RESPONSE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1672 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1673 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1674 $ofxcount += countprint(
"<DEPOSITID>{$rdcsays['data']['depositid']}</DEPOSITID>\n");
1675 $ofxcount += countprint(
"<ACCOUNTS>\n");
1676 if (is_array($rdcsays[
'data'][
'accounts'])) {
1677 foreach ($rdcsays[
'data'][
'accounts'] as $acct => $detl) {
1678 $ofxcount += countprint(
"<ACCT>\n<ACCTID>$acct</ACCTID>\n");
1679 foreach ($detl as $key => $value) {
1680 $key = strtoupper($key);
1681 $ofxcount += countprint(
"<$key>$value</$key>\n");
1683 $ofxcount += countprint(
"</ACCT>\n");
1686 $ofxcount += countprint(
"</ACCOUNTS>\n");
1687 $ofxcount += countprint(
"<TERMS>\n");
1688 $ofxcount += countprint(
"" . htmlentities(CleanWordQuotes(
"{$rdcsays['data']['terms']}"), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE));
1689 $ofxcount += countprint(
"</TERMS>\n");
1690 $ofxcount += countprint(
"<DEPMESSAGES>\n");
1691 if (is_array($rdcsays[
'data'][
'depmessages'])) {
1692 foreach ($rdcsays[
'data'][
'depmessages'] as $msg => $detl) {
1693 $ofxcount += countprint(
"<MSG>\n<MSGID>$msg</MSGID>\n");
1694 foreach ($detl as $key => $value) {
1695 $key = strtoupper($key);
1696 $ofxcount += countprint(
"<$key>$value</$key>\n");
1698 $ofxcount += countprint(
"</MSG>\n");
1701 $ofxcount += countprint(
"</DEPMESSAGES>\n");
1702 $ofxcount += countprint(
"</RDC_RESPONSE>\n");
1706 if (!isset($pass[
'DEPOSITID'])) {
1707 throw new Exception(
"Missing RDC parameters",4001);
1709 $rdcparms[
'depositid'] = $pass[
'DEPOSITID'];
1710 $rdcsays = RDCaccept($dbh, $HB_ENV, $MC, $rdcparms);
1711 # deal with response 1712 if ($rdcsays[
'status'][
'response'] ==
'false') {
1713 throw new Exception($rdcsays[
'status'][
'message'],4020); # RDC ACCEPT
1715 $ofxcount += countprint(
"<RDC_RESPONSE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1716 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1717 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1718 $ofxcount += countprint(
"<DEPMESSAGES>\n");
1719 if (is_array($rdcsays[
'data'][
'depmessages'])) {
1720 foreach ($rdcsays[
'data'][
'depmessages'] as $msg => $detl) {
1721 $ofxcount += countprint(
"<MSG>\n<MSGID>$msg</MSGID>\n");
1722 if (is_array($detl)) {
1723 foreach ($detl as $key => $value) {
1724 $key = strtoupper($key);
1725 $ofxcount += countprint(
"<$key>$value</$key>\n");
1728 $ofxcount += countprint(
"</MSG>\n");
1731 $ofxcount += countprint(
"</DEPMESSAGES>\n");
1732 $ofxcount += countprint(
"</RDC_RESPONSE>\n");
1737 if (!isset($pass[
'DEPOSITID']) || !isset($pass[
'FB']) ||
sizeof($_FILES) == 0) {
1738 throw new Exception(
"Missing RDC parameters",4001);
1740 $rdcparms[
'uploads_dir'] =
"/home/{$HB_ENV['chome']}/sslforms/RDCImages";
1741 $rdcparms[
'depositid'] = $pass[
'DEPOSITID'];
1742 $rdcparms[
'FB'] = $pass[
'FB'];
1743 $rdcsays = RDCUploadImage($dbh, $rdcparms);
1744 # deal with response 1745 if ($rdcsays[
'status'][
'response'] ==
'false') {
1746 throw new Exception($rdcsays[
'status'][
'message'],4030); # RDC UPLOAD
1748 $ofxcount += countprint(
"<RDC_RESPONSE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1749 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1750 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1752 $ofxcount += countprint(
"</RDC_RESPONSE>\n");
1757 if (!isset($pass[
'DEPOSITID']) || !isset($pass[
'AMOUNT']) || !isset($pass[
'ACCTID'])) {
1758 throw new Exception(
"Missing RDC parameters",4001);
1760 $rdcparms[
'depositid'] = $pass[
'DEPOSITID'];
1761 $rdcparms[
'acctid'] = $pass[
'ACCTID'];
1762 $rdcparms[
'amount'] = $pass[
'AMOUNT'];
1763 $rdcparms[
'rdcacctid'] = $pass[
'RDCACCTID'];
1764 $rdcparms[
'live'] = $HB_ENV[
'live'];
1765 $rdcparms[
'Ml'] = $HB_ENV[
'Ml'];
1766 $rdcparms[
'Clw'] = $HB_ENV[
'livewait'];
1767 if ($pass[
'POSTAWAY'] == 1) {
1768 $rdcparms[
'POSTAWAY'] = $pass[
'POSTAWAY'];
1770 $rdcsays = RDCdeposit($dbh, $rdcparms);
1771 # deal with response 1772 if ($rdcsays[
'status'][
'response'] ==
'false') {
1773 throw new Exception($rdcsays[
'status'][
'message'],4040); # RDC Deposit
1775 $ofxcount += countprint(
"<RDC_RESPONSE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1776 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1777 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1778 foreach ($rdcsays[
'data'] as $key => $value) {
1779 if ($key <>
'Risks' && $key <>
'FailReasons' && $key <>
'LocalizedMessageText') {
1780 $key = strtoupper($key);
1781 $ofxcount += countprint(
"<$key>$value</$key>\n");
1784 $ofxcount += countprint(
"<RISKS>\n");
1785 if (is_array($rdcsays[
'data'][
'Risks'])) {
1786 foreach ($rdcsays[
'data'][
'Risks'] as $msg => $detl) {
1787 $ofxcount += countprint(
"<MSGTEXT>{$detl['RiskDesc']}</MSGTEXT>\n");
1790 if (is_array($rdcsays[
'data'][
'FailReasons'])) {
1791 foreach ($rdcsays[
'data'][
'FailReasons'] as $msg => $detl) {
1792 $ofxcount += countprint(
"<MSGTEXT>$detl</MSGTEXT>\n");
1795 if (!empty($rdcsays[
'data'][
'LocalizedMessageText'])) {
1796 $ofxcount += countprint(
"<MSGTEXT>{$rdcsays['data']['LocalizedMessageText']}</MSGTEXT>\n");
1798 $ofxcount += countprint(
"</RISKS>\n");
1799 $ofxcount += countprint(
"</RDC_RESPONSE>\n");
1804 if (!isset($HB_ENV[
'Cn']) || !isset($pass[
'DEPOSITID'])) {
1806 throw new Exception(
"Missing RDC parameters",4001);
1808 $rdcparms[
'Cn'] = $HB_ENV[
'Cn'];
1809 if (isset($pass[
'DAYS']))
1810 $rdcparms[
'numberofdays'] = $pass[
'DAYS'];
1811 if (isset($pass[
'LIMIT']))
1812 $rdcparms[
'translimit'] = $pass[
'LIMIT'];
1817 $depostat = curdc_list($dbh, $rdcparms);
1819 $rdcparms[
'depositid'] = $pass[
'DEPOSITID'];
1823 $depohist = RDChistorylist($dbh, $rdcparms);
1824 if ($depostat[
'status'][
'response'] ==
'false') {
1825 throw new Exception($depostat[
'status'][
'message'],4040);
1826 } elseif ($depohist[
'status'][
'response'] ==
'false') {
1827 throw new Exception($depohist[
'status'][
'message'],4040);
1830 $histlist = array();
1831 if (is_array($depohist[
'data'][
'TransactionList'])) {
1832 foreach ($depohist[
'data'][
'TransactionList'] as $key => $value) {
1833 if (!empty($value[
'ReceiptReferenceNo'])) {
1834 $receiptno = $value[
'ReceiptReferenceNo'];
1835 foreach ($value as $tag => $tval) {
1836 switch (strtolower($tag)) {
1837 case "transactionid":
1838 case "transactiondttm":
1839 case "receiptreferenceno":
1840 case "submittedamount":
1841 case "currentamount":
1843 case "accountnumber":
1844 case "accountholdernumber":
1845 case "transactiontype":
1846 case "acceptedbydescr":
1847 case "statuschgdttm":
1850 $histlist[$receiptno][$tag] = $tval;
1858 $ofxcount += countprint(
"<RDC_RESPONSE>\n<STATUS>\n<CODE>0</CODE>\n</STATUS>\n");
1859 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1860 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1861 $ofxcount += countprint(
"<DEPOSITS>");
1862 foreach ($depostat[
'data'] as $key => $value) {
1863 $ofxcount += countprint(
"<DEPOSIT>\n");
1864 foreach ($value as $tag => $tval) {
1872 $tag = ($tag ==
'status' ?
"RDCSTATUS" : strtoupper($tag));
1873 $ofxcount += countprint(
"<$tag>$tval</$tag>\n");
1876 if ($pass[
'DEBUG'] == 1)
1877 $ofxcount += countprint(
"<VENDORINFO>" . print_r($tval,
true) .
"</VENDORINFO>");
1882 if (!empty($value[
'vendorinfo'][
'TransactionReceiptNumber'])) {
1883 $ofxcount += countprint(
"<TRANSACTIONRECEIPTNUMBER>{$value['vendorinfo']['TransactionReceiptNumber']}");
1884 $ofxcount += countprint(
"</TRANSACTIONRECEIPTNUMBER>\n");
1885 $receiptno = $value[
'vendorinfo'][
'TransactionReceiptNumber'];
1886 if ($histlist[$receiptno]) {
1888 foreach ($histlist[$receiptno] as $rtag => $rval) {
1889 $rtag = strtoupper($rtag);
1890 $ofxcount += countprint(
"<$rtag>$rval</$rtag>\n");
1895 $ofxcount += countprint(
"</DEPOSIT>\n");
1898 $ofxcount += countprint(
"</DEPOSITS>\n");
1899 $ofxcount += countprint(
"</RDC_RESPONSE>");
1903 # unknown RDC_ACTION 1904 throw new Exception(
"Unknown RDC Mode",15550);
1909 # PASSWITH ES_UPD=1 indicates app supports estmt_flag setting changes 1910 # response set includes terms & notices 1911 # PASSWITH ENROLL=START/STOP updates status, and returned response set 1912 # contains status & enrollment block only 1914 parse_str($PASSWITH, $pass);
1916 if (isset($pass[
'ENROLL'])) {
1924 $HB_ENV[
'esProcessMode'] = $pass[
'ENROLL'];
1925 $HB_ENV[
'HCUPOST'][
'stop_reason'] = $pass[
'STOP_REASON'];
1927 # Post_CUEstmt expects un-encoded $Ml in HB_ENV array 1928 # app stores it encoded, so decode it before calling the function 1929 # and then put it back after so nothing else breaks 1930 $HB_ENV[
'Ml'] = urldecode($HB_ENV[
'Ml']);
1931 $response = Post_CUEStmt($dbh, $HB_ENV, $MC);
1932 $HB_ENV[
'Ml'] = urlencode($HB_ENV[
'Ml']);
1933 if (count($response[
'status'][
'errors']) > 0) {
1934 throw new Exception(implode(
' ',$response[
'status'][
'errors']),15592); # Post_CUEStmt
1936 if (intval($pass[
'NOTICE_ID']) > 0) {
1938 $HB_ENV[
"HCUPOST"][
"notice_type"] =
"C";
1939 $HB_ENV[
"HCUPOST"][
"notice_id"] = intval($pass[
'NOTICE_ID']);
1940 $HB_ENV[
"HCUPOST"][
"notice_device"] =
"P";
1941 $HB_ENV[
"HCUPOST"][
"notice_response"] = array(
"answer" => 1);
1942 $HB_ENV[
"HCUPOST"][
"notice_cancel"] =
"0";
1944 $response = Update_NoticeInfo($dbh, $HB_ENV, $MC);
1950 $response = Get_Estmt($dbh, $HB_ENV, $MC, 1);
1954 $response = Get_Estmt($dbh, $HB_ENV, $MC);
1956 # deal with response 1957 if (count($response[
'status'][
'errors']) > 0) {
1958 throw new Exception(implode(
' ',$response[
'status'][
'errors']),15590); # Get_Estmt
1960 $ofxcount += countprint(
"<ESTMT>\n<STATUS>\n<CODE>0</CODE>\n");
1961 $ofxcount += countprint(
"<SEVERITY>INFO</SEVERITY>\n</STATUS>\n");
1962 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
1963 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
1966 foreach ($response[
'estmt'] as $key => $value) {
1967 switch (strtolower($key)) {
1970 $key = strtoupper($key);
1971 $ofxcount += countprint(
"<$key>$value</$key>\n");
1974 $ofxcount += countprint(
"<PDFLINKS>\n");
1975 if (is_array($value)) {
1976 foreach ($value as $tag => $tval) {
1977 $ofxcount += countprint(
"<PDFLINK>\n");
1978 foreach ($tval as $tkey => $tkval) {
1979 $tkey = strtoupper($tkey);
1980 $ofxcount += countprint(
"<$tkey>$tkval</$tkey>\n");
1982 $ofxcount += countprint(
"</PDFLINK>\n");
1985 $ofxcount += countprint(
"</PDFLINKS>");
1988 $ofxcount += countprint(
"<TOCLINKS>\n");
1989 if (is_array($value)) {
1990 foreach ($value as $tag => $tval) {
1991 $ofxcount += countprint(
"<TOCLINK>\n");
1992 foreach ($tval as $tkey => $tkval) {
1993 $tkey = strtoupper($tkey);
1994 $ofxcount += countprint(
"<$tkey>$tkval</$tkey>\n");
1996 $ofxcount += countprint(
"</TOCLINK>\n");
1999 $ofxcount += countprint(
"</TOCLINKS>");
2003 # add appropriate messages - 2006 if (isset($pass[
'ES_UPD'])) {
2007 # set new ENROLLMENT block 2008 if ($enrolled ==
"W") {
2010 $termsMsg = $MC->msg(
'Statement Not Found') .
" " . $MC->msg(
'Statement Missing') .
" " . $MC->msg(
"Statements Stop");
2012 $termsName =
"esTermsStop";
2013 $termsTitle = $MC->msg(
"Stop e-Statements");
2014 }
else if ($enrolled ==
"Y") {
2015 $termsMsg = $MC->msg(
"Statements Stop");
2017 $termsName =
"esTermsStop";
2018 $termsTitle = $MC->msg(
"Stop e-Statements");
2020 $termsMsg = $MC->msg(
'Account not set for EStatements') .
". " . $MC->msg(
'Sign up fast');
2022 $termsName =
"esTermsStart";
2023 $termsTitle = $MC->msg(
"Start e-Statements");
2025 $ofxcount += countprint(
"<ENROLLMENT>\n");
2026 $ofxcount += countprint(
"<ENROLLED>$enrolled</ENROLLED>\n");
2027 $ofxcount += countprint(
"<TERMS_TITLE>$termsTitle</TERMS_TITLE>\n");
2028 $ofxcount += countprint(
"<TERMS_MSG>$termsMsg</TERMS_MSG>\n");
2029 $ofxcount += countprint(
"<TERMS_BTN>" . $MC->msg(
'Click Here') .
"</TERMS_BTN>\n");
2031 $response = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P', $termsName);
2033 if ($response[
'status'][
'code'] !=
"000" ||
2034 !count($response[
'notice']) ||
2035 count($response[
'status'][
'errors']) > 0 ||
2036 strlen($response[
'notice'][0][
'notice_text']) == 0) {
2037 $response[
'status'][
'errors'][] =
"Error retrieving Terms of Use";
2038 throw new Exception(implode(
' ',$response[
'status'][
'errors']),15593); # Get_NoticeInfo estatement terms
2040 if (count($response[
'notice'])) {
2043 foreach ($response[
'notice'] as $noticekey => $details) {
2044 $ofxcount += countprint(
"<TERMS>\n");
2048 if (!count($details[
'notice_answers']) &&
sizeof($details[
'notice_donotshowtext'])) {
2049 $details[
'notice_answers'][] = array(
'answer_id' => $details[
'notice_id'],
'answer_text' => $details[
'notice_donotshowtext']);
2050 $details[
'notice_answertype'] =
'M';
2052 foreach ($details as $key => $value) {
2053 $key = strtoupper($key);
2055 case "NOTICE_ANSWERS":
2056 $ofxcount += countprint(
"<NOTICE_ANSWERS>\n");
2057 foreach ($value as $anskey => $ansdetl) {
2058 $ofxcount += countprint(
"<ANSWER>\n");
2059 $ofxcount += countprint(
"<ANSWER_ID>ANS_{$ansdetl['answer_id']}</ANSWER_ID>\n");
2060 $ofxcount += countprint(
"<ANSWER_TEXT>" . htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</ANSWER_TEXT>\n");
2062 $ofxcount += countprint(
"</ANSWER>\n");
2064 $ofxcount += countprint(
"</NOTICE_ANSWERS>\n");
2070 case "NOTICE_INTRO":
2071 case "NOTICE_TITLE":
2072 case "NOTICE_DONOTSHOWTEXT":
2073 case "NOTICE_MSG_TX":
2074 case "NOTICE_MSG_TX_SHOW":
2075 case "NOTICE_MSG_TX_PERM":
2076 case "NOTICE_SUPPRESSRESPONSE":
2077 case "NOTICE_POSTTARGET":
2082 case "NOTICE_POPUP":
2083 case "NOTICE_ANSWERTYPE":
2084 case "NOTICE_LINKTARGET":
2085 case "NOTICE_LINKDISPLAY":
2088 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2091 $ofxcount += countprint(
"</TERMS>\n");
2094 $ofxcount += countprint(
"<TERMS>\n</TERMS>\n");
2097 $ofxcount += countprint(
"</ENROLLMENT>\n");
2099 switch ($response[
'estmt'][
'enrolled']) {
2101 $ofxcount += countprint(
"<MESSAGES>\n<MESSAGE>\n<MSGHEAD>Discontinuing E-Statement Service</MSGHEAD> 2102 <MSGBODY>Please log in through the full Home Banking site to discontinue E-Statement service</MSGBODY>\n</MESSAGE>\n</MESSAGES>\n");
2105 $ofxcount += countprint(
"<MESSAGES>\n<MESSAGE>\n<MSGHEAD>" . $MC->msg(
'Statement Not Found') .
"</MSGHEAD> 2106 <MSGBODY>" . $MC->msg(
'Statement Missing') .
"</MSGBODY>\n</MESSAGE>\n</MESSAGES>\n");
2110 $ofxcount += countprint(
"<MESSAGES>\n<MESSAGE>\n<MSGHEAD>Enrollment Required</MSGHEAD> 2111 <MSGBODY>Please log in through the full Home Banking site to sign up for E-Statements</MSGBODY>\n</MESSAGE>\n</MESSAGES>\n");
2116 # now get the estatement notice, if any 2117 $txnotice = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'esNotice', 0);
2119 if (count($txnotice[
'notice'])) {
2120 foreach ($txnotice[
'notice'] as $noticekey => $details) {
2121 $ofxcount += countprint(
"<NOTICE>\n");
2125 if (!count($details[
'notice_answers']) &&
sizeof($details[
'notice_donotshowtext'])) {
2126 $details[
'notice_answers'][] = array(
'answer_id' => $details[
'notice_id'],
'answer_text' => $details[
'notice_donotshowtext']);
2127 $details[
'notice_answertype'] =
'M';
2129 foreach ($details as $key => $value) {
2130 $key = strtoupper($key);
2132 case "NOTICE_ANSWERS":
2133 $ofxcount += countprint(
"<NOTICE_ANSWERS>\n");
2134 foreach ($value as $anskey => $ansdetl) {
2135 $ofxcount += countprint(
"<ANSWER>\n");
2136 $ofxcount += countprint(
"<ANSWER_ID>ANS_{$ansdetl['answer_id']}</ANSWER_ID>\n");
2137 $ofxcount += countprint(
"<ANSWER_TEXT>" . htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</ANSWER_TEXT>\n");
2139 $ofxcount += countprint(
"</ANSWER>\n");
2141 $ofxcount += countprint(
"</NOTICE_ANSWERS>\n");
2147 case "NOTICE_INTRO":
2148 case "NOTICE_TITLE":
2149 case "NOTICE_DONOTSHOWTEXT":
2150 case "NOTICE_MSG_TX":
2151 case "NOTICE_MSG_TX_SHOW":
2152 case "NOTICE_MSG_TX_PERM":
2153 case "NOTICE_SUPPRESSRESPONSE":
2154 case "NOTICE_POSTTARGET":
2159 case "NOTICE_POPUP":
2160 case "NOTICE_ANSWERTYPE":
2161 case "NOTICE_LINKTARGET":
2162 case "NOTICE_LINKDISPLAY":
2165 $ofxcount += countprint(
"<$key>" . htmlentities($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2168 $ofxcount += countprint(
"</NOTICE>\n");
2171 $ofxcount += countprint(
"<NOTICE>\n</NOTICE>\n");
2173 $ofxcount += countprint(
"</ESTMT>");
2180 #is cu configured for Alerts? 2181 if (!Check_AlertsEnabled($dbh, $HB_ENV)) {
2182 throw new Exception(
"Alert feature not configured",3180); # no
'Alert from' email
set in admin
2184 #list of alert types 2185 $ary_alerttypes = Get_AlertTypes($MC);
2186 #list of cell phone providers 2187 $ary_cellproviders = Get_AlertProviders($dbh);
2188 #cuusers.email and most-recently-used cell number for use as default values when defining a new alert 2189 $ary_dfltmail = Get_AlertDefaultEmail($dbh, $HB_ENV);
2190 $ary_dfltcell = Get_AlertDefaultCell($dbh, $HB_ENV);
2191 #list of members' accounts eligible for each alert type 2192 $ary_acctlist = Get_AlertAccountList($dbh, $HB_ENV);
2193 #list of currently-defined alerts, if any 2194 $ary_alertdetails = Get_AlertsDetailed($dbh, $HB_ENV);
2195 #alerts terms of use document, if any, and a link to display terms of use on demand 2196 $ary_alertterms = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'alertTerms');
2198 #a status indicating whether or not the member must accept terms before continuing 2199 #any other alerts messages or notices the member should see 2201 $ofxcount += countprint(
"<ALERTSMRY>\n<STATUS>\n<CODE>0</CODE>\n");
2202 $ofxcount += countprint(
"<SEVERITY>INFO</SEVERITY>\n</STATUS>\n");
2203 $ofxcount += countprint(
"<MEMBER>{$HB_ENV['Uid']}</MEMBER>\n");
2204 $ofxcount += countprint(
"<USERKEY>$apptoken</USERKEY>\n");
2206 $ofxcount += countprint(
"<ALERTTYPES>\n");
2207 foreach ($ary_alerttypes as $alertarr) {
2208 $ofxcount += countprint(
"<ALERTTYPE>\n");
2209 foreach ($alertarr as $key => $value) {
2210 $key = strtoupper($key);
2211 $ofxcount += countprint(
"<$key>" . htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2213 $ofxcount += countprint(
"</ALERTTYPE>\n");
2215 $ofxcount += countprint(
"</ALERTTYPES>\n");
2217 $ofxcount += countprint(
"<CELLPROVIDERS>\n");
2218 foreach ($ary_cellproviders[
'providers'] as $cellprovider) {
2219 $ofxcount += countprint(
"<CELLPROVIDER>\n");
2220 foreach ($cellprovider as $key => $value) {
2221 $key = strtoupper($key);
2222 $ofxcount += countprint(
"<$key>" . htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2224 $ofxcount += countprint(
"</CELLPROVIDER>\n");
2226 $ofxcount += countprint(
"</CELLPROVIDERS>\n");
2227 $ofxcount += countprint(
"<EMAILDFLT>" . htmlspecialchars($ary_dfltmail[
'email'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</EMAILDFLT>\n");
2228 $ofxcount += countprint(
"<CELLDFLT>\n");
2229 foreach ($ary_dfltcell[
'cell'] as $key => $value) {
2230 $key = strtoupper($key);
2231 $ofxcount += countprint(
"<$key>" . htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2233 $ofxcount += countprint(
"</CELLDFLT>\n");
2235 $ofxcount += countprint(
"<ACCOUNTS>\n");
2236 foreach ($ary_acctlist[
'accounts'] as $acctarr) {
2237 $ofxcount += countprint(
"<ACCOUNT>\n");
2238 foreach ($acctarr as $key => $value) {
2239 $key = strtoupper($key);
2240 $ofxcount += countprint(
"<$key>" . htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2242 $ofxcount += countprint(
"</ACCOUNT>\n");
2244 $ofxcount += countprint(
"</ACCOUNTS>\n");
2246 $ofxcount += countprint(
"<ALERTS>\n");
2247 foreach ($ary_alertdetails[
'alerts'] as $detlarr) {
2248 $ofxcount += countprint(
"<ALERT>\n");
2249 foreach ($detlarr as $key => $value) {
2250 $key = strtoupper($key);
2251 $ofxcount += countprint(
"<$key>" . htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2253 $ofxcount += countprint(
"</ALERT>\n");
2255 $ofxcount += countprint(
"</ALERTS>\n");
2256 $ofxcount += countprint(
"<TERMS>\n");
2257 if (count($ary_alertterms[
'notice'])) {
2258 foreach ($ary_alertterms[
'notice'] as $noticekey => $details) {
2259 foreach ($details as $key => $value) {
2260 $key = strtoupper($key);
2262 case "NOTICE_ANSWERS":
2263 $ofxcount += countprint(
"<NOTICE_ANSWERS>\n");
2264 foreach ($value as $anskey => $ansdetl) {
2265 $ofxcount += countprint(
"<ANSWER>\n");
2266 $ofxcount += countprint(
"<ANSWER_ID>ANS_{$ansdetl['answer_id']}</ANSWER_ID>\n");
2267 $ofxcount += countprint(
"<ANSWER_TEXT>" . htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</ANSWER_TEXT>\n");
2269 $ofxcount += countprint(
"</ANSWER>\n");
2271 $ofxcount += countprint(
"</NOTICE_ANSWERS>\n");
2277 case "NOTICE_INTRO":
2278 case "NOTICE_TITLE":
2279 case "NOTICE_DONOTSHOWTEXT":
2280 case "NOTICE_MSG_TX":
2281 case "NOTICE_MSG_TX_SHOW":
2282 case "NOTICE_MSG_TX_PERM":
2283 case "NOTICE_SUPPRESSRESPONSE":
2284 case "NOTICE_POSTTARGET":
2289 case "NOTICE_POPUP":
2290 case "NOTICE_ANSWERTYPE":
2291 case "NOTICE_LINKTARGET":
2292 case "NOTICE_LINKDISPLAY":
2295 $ofxcount += countprint(
"<$key>" . htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2300 $ofxcount += countprint(
"</TERMS>");
2305 $ary_alertnotice = Get_NoticeInfo($dbh, $HB_ENV, $MC,
'P',
'alertNotice');
2307 $ofxcount += countprint(
"<NOTICE>\n");
2308 if (count($ary_alertnotice[
'notice'])) {
2309 foreach ($ary_alertnotice[
'notice'] as $noticekey => $details) {
2310 foreach ($details as $key => $value) {
2311 $key = strtoupper($key);
2313 case "NOTICE_ANSWERS":
2314 $ofxcount += countprint(
"<NOTICE_ANSWERS>\n");
2315 foreach ($value as $anskey => $ansdetl) {
2316 $ofxcount += countprint(
"<ANSWER>\n");
2317 $ofxcount += countprint(
"<ANSWER_ID>ANS_{$ansdetl['answer_id']}</ANSWER_ID>\n");
2318 $ofxcount += countprint(
"<ANSWER_TEXT>" . htmlentities(CleanWordQuotes($ansdetl[
'answer_text']), ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</ANSWER_TEXT>\n");
2319 $ofxcount += countprint(
"</ANSWER>\n");
2321 $ofxcount += countprint(
"</NOTICE_ANSWERS>\n");
2325 case "NOTICE_INTRO":
2326 case "NOTICE_TITLE":
2327 case "NOTICE_DONOTSHOWTEXT":
2328 case "NOTICE_MSG_TX":
2329 case "NOTICE_MSG_TX_SHOW":
2330 case "NOTICE_MSG_TX_PERM":
2331 case "NOTICE_SUPPRESSRESPONSE":
2332 case "NOTICE_POSTTARGET":
2337 case "NOTICE_POPUP":
2338 case "NOTICE_ANSWERTYPE":
2339 case "NOTICE_LINKTARGET":
2340 case "NOTICE_LINKDISPLAY":
2343 $ofxcount += countprint(
"<$key>" . htmlspecialchars($value, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</$key>\n");
2348 $ofxcount += countprint(
"</NOTICE>");
2351 $ofxcount += countprint(
"</ALERTSMRY>\n");
2356 parse_str($PASSWITH, $pass);
2357 $HB_ENV[
'HCUPOST'] = array(); # start w/ empty array
2358 $HB_ENV[
'HCUPOST'][
'type'] = $pass[
'TYPE'];
2359 $HB_ENV[
'HCUPOST'][
'notifymsg'] = $pass[
'NOTIFYMSG'];
2360 $HB_ENV[
'HCUPOST'][
'emailtype'] = $pass[
'EMAILTYPE'];
2361 $HB_ENV[
'HCUPOST'][
'provider_id'] = $pass[
'PROVIDER_ID'];
2362 $HB_ENV[
'HCUPOST'][
'notifyto'] = $pass[
'NOTIFYTO'];
2363 $HB_ENV[
'HCUPOST'][
'id'] = $pass[
'ALERTID'];
2364 $HB_ENV[
'HCUPOST'][
'selacct'] = $pass[
'SELACCT'];
2365 $HB_ENV[
'HCUPOST'][
'inctransdesc'] = $pass[
'INCTRANSDESC'];
2367 switch (strtolower($pass[
'TYPE'])) {
2369 $HB_ENV[
'HCUPOST'][
'notifyamt'] = $pass[
'NOTIFYAMT'];
2370 $HB_ENV[
'HCUPOST'][
'incbal'] = $pass[
'INCBAL'];
2371 $HB_ENV[
'HCUPOST'][
'useavailbal'] = $pass[
'USEAVAILBAL'];
2373 $HB_ENV[
'HCUPOST'][
'notifydesc'] = $pass[
'NOTIFYDESC'];
2374 $HB_ENV[
'HCUPOST'][
'userange'] = $pass[
'USERANGE'];
2375 $HB_ENV[
'HCUPOST'][
'desc_amtmin'] = $pass[
'DESC_AMTMIN'];
2376 $HB_ENV[
'HCUPOST'][
'desc_amtmax'] = $pass[
'DESC_AMTMAX'];
2377 $HB_ENV[
'HCUPOST'][
'incbal'] = $pass[
'INCBAL'];
2378 $HB_ENV[
'HCUPOST'][
'incamt'] = $pass[
'INCAMT'];
2379 $HB_ENV[
'HCUPOST'][
'transtype'] = $pass[
'TRANSTYPE'];
2381 $HB_ENV[
'HCUPOST'][
'chknum'] = $pass[
'CHKNUM'];
2382 $HB_ENV[
'HCUPOST'][
'incamt'] = $pass[
'INCAMT'];
2384 $HB_ENV[
'HCUPOST'][
'days_prior'] = $pass[
'DAYS_PRIOR'];
2387 throw new Exception(
'Invalid Alert Update Request',3120); # unrecognized Alert type
2390 $validalert = Validate_Alert($dbh, $HB_ENV, $MC);
2391 if ($validalert[
'status'][
'code'] !=
'000') {
2392 throw new Exception(implode(
' ',$validalert[
'status'][
'errors']),3212); # failed Validate_Alert
2394 $validalert = Update_Alert($dbh, $HB_ENV, $MC);
2395 if ($validalert[
'status'][
'code'] !=
'000') {
2396 throw new Exception(implode(
' ',$validalert[
'status'][
'errors']),3214); # failed Update_Alert
2398 Send_ResponseOK($CU, $HB_ENV[
'Uid'], $HB_ENV[
'Cauth'], 1,
"Alert Update Successful", 2);
2404 parse_str($PASSWITH, $pass);
2405 $HB_ENV[
'HCUPOST'] = array(); # start w/ empty array
2406 $HB_ENV[
'HCUPOST'][
'type'] = $pass[
'TYPE'];
2407 $HB_ENV[
'HCUPOST'][
'id'] = $pass[
'ALERTID'];
2409 switch (strtolower($pass[
'TYPE'])) {
2416 throw new Exception(
'Invalid Alert Delete Request',3216); # unrecognized Alert type
2419 $validalert = Delete_Alert($dbh, $HB_ENV, $MC);
2420 if ($validalert[
'status'][
'code'] !=
'000') {
2421 throw new Exception(implode(
' ',$validalert[
'status'][
'errors']),3218); # failed Delete_Alert
2423 Send_ResponseOK($CU, $HB_ENV[
'Uid'], $HB_ENV[
'Cauth'], 1,
"Alert Delete Successful", 2);
2460 # if we need to push data after the jump, 2461 # skip the Send_ResponseOK above and 2462 # reload the HB_ENV with fresh settings returned in swresult['data']['authstring'] 2463 # and remove the break; statement below so it falls through 2465 # SWJUMP case above relies on falling through to the default to send data. DO NOT insert anything here 2469 if (empty($DTSTART) || !sqlmdy($DTSTART)) {
2470 throw new Exception(
"Invalid Start Date $DTSTART",2090);
2472 $sqlstart = sqlmdy($DTSTART);
2474 if (!empty($DTEND) && !sqlmdy($DTEND)) {
2475 throw new Exception(
'Invalid End Date',2090);
2477 $HB_ENV[
'stale'] = 0;
2480 $Fhdays = $HB_ENV[
'Fhdays'];
2481 $Fset2 = $HB_ENV[
'Fset2'];
2482 $Ml = urldecode($HB_ENV[
'Ml']);
2484 #require ("throtlpkt.i"); 2485 list ($status, $asofdate, $reason) = fetch_packet($CU, $HB_ENV[
'Cn'], 300);
2486 if ($asofdate == 1) {
2487 throw new Exception(
'System Unavailable',2061); # couldn
't get a packet 2488 $HB_ENV['stale
'] = 1; 2490 $HB_ENV['lastupdate
'] = $asofdate; 2494 $balances = Get_Balances($dbh, $HB_ENV); 2496 $expires = mktime(date("H"), date("i"), date("s"), date("m") + 3, date("d"), date("Y")); 2498 header("Content-Type: application/x-ofx"); 2499 header("Content-disposition: inline; filename=\"${CU}_txns.ofx\""); 2500 $now = date('YmdHis
'); 2503 $ofxcount += countprint('<?xml version=
"1.0" encoding=
"' . $encoding . '"?>
2504 <?OFX OFXHEADER=
"200" VERSION=
"211" SECURITY=
"NONE" OLDFILEUID=
"NONE" NEWFILEUID=
"NONE"?>
2510 <SEVERITY>INFO</SEVERITY>
2512 <DTSERVER>
' . $now . '</DTSERVER>
2513 <LASTUPDATE>
' . $HB_ENV['lastupdate
'] . '</LASTUPDATE>
2515 if ($HB_ENV['stale
'] == 1) 2516 $ofxcount += countprint("<STALE>YES</STALE>\n"); 2517 $ofxcount += countprint("<LANGUAGE>ENG</LANGUAGE>\n"); 2518 $ofxcount += countprint("<MEMBER>{$HB_ENV['Uid
']}</MEMBER>\n"); # was Cauth for Mammoth 2519 $ofxcount += countprint("<SELECTED_MEMBER>{$HB_ENV['Uid
']}</SELECTED_MEMBER>\n"); 2520 $ofxcount += countprint("<USERKEY>$apptoken</USERKEY>\n"); 2521 $ofxcount += countprint("<TIMEOUT>{$HB_ENV['AppTimeout
']}</TIMEOUT>\n"); 2522 $ofxcount += countprint("</SONRS>\n"); 2523 $ofxcount += countprint("</SIGNONMSGSRSV1>\n"); 2524 # no switch accounts in odyssey, but with a little work this might work for viewing multiple accounts 2525 // $switchlist = Get_SwitchAccountList($dbh, $HB_ENV); 2526 // if (count($switchlist['status
']['errors
']) > 0) { 2527 // throw new Exception(implode(' ',$switchlist['status
']['errors
']),15592); # Get_SwitchAccountList 2529 // $ofxcount += countprint("<SWACCT>\n"); 2530 // $ofxcount += countprint("<SWITCHALLOWED>{$switchlist['data
']['switchallowed
']}</SWITCHALLOWED>\n"); 2531 // if (count($switchlist['data
']['selectedacct
'])) { 2532 // $ofxcount += countprint("<SELECTED_ACCT>\n"); 2533 // foreach ($switchlist['data
']['selectedacct
'] as $key => $value) { 2534 // $key = strtoupper($key); 2535 // $value = htmlspecialchars("$value", ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2536 // $ofxcount += countprint("<$key>$value</$key>\n"); 2538 // $ofxcount += countprint("</SELECTED_ACCT>\n"); 2541 // if ($switchlist['data
']['switchallowed
'] && count($switchlist['data
']['switchaccounts
'])) { 2542 // foreach ($switchlist['data
']['switchaccounts
'] as $swacct) { 2543 // $ofxcount += countprint("<SWITCHACCT>\n"); 2544 // foreach ($swacct as $key => $value) { 2545 // $key = strtoupper($key); 2546 // $value = htmlspecialchars("$value", ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2547 // $ofxcount += countprint("<$key>$value</$key>\n"); 2549 // $ofxcount += countprint("</SWITCHACCT>\n"); 2552 // $ofxcount += countprint("</SWACCT>\n"); 2554 if (count($balances['dp
']) && (empty($KEYACCTID) || (!empty($KEYACCTID) && array_key_exists($KEYACCTID, $balances['dp
'])))) { 2555 $ofxcount += countprint("<BANKMSGSRSV1>\n"); 2556 # for each $balances['dp
'] Get_History & print 2557 foreach ($balances['dp
'] as $balkey => $balinfo) { 2558 if ((!empty($KEYACCTID)) && $balkey != $KEYACCTID) { 2561 $cert = $balinfo['certnumber
']; 2562 $type = $balinfo['accounttype
']; 2563 $desc = $balinfo['description
']; 2564 $desc = htmlspecialchars("$desc", ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2565 $displaydesc = $balinfo['displaydesc
']; 2566 $displaydesc = htmlspecialchars("$displaydesc", ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2567 $type = ("$cert" == "0" ? $type : "${type}_${cert}"); 2568 $type = htmlspecialchars(trim($type), ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2569 $ytdinterest = $balinfo['ytdinterest
']; 2570 $lastyrinterest = $balinfo['lastyrinterest
']; 2571 $holdtotal = $balinfo['holdtotal
']; 2572 $pendtotal = $balinfo['pendtotal
']; 2574 switch ($balinfo['deposittype
']) { 2576 $acttype = "CHECKING"; 2577 $micraccount = $balinfo['micraccount
']; 2579 case "C": # Certificates 2580 $acttype = "INVESTMENT"; 2582 case "I": # IRA accounts 2583 $acttype = "RETIREMENT"; 2587 $acttype = "SAVINGS"; 2590 # opening tags for account info 2592 $ofxcount += countprint("<STMTTRNRS>\n"); 2593 $ofxcount += countprint("<TRNUID>0</TRNUID>\n"); 2594 $ofxcount += countprint("<STATUS>\n"); 2595 $ofxcount += countprint("<CODE>0</CODE>\n"); 2596 $ofxcount += countprint("<SEVERITY>INFO</SEVERITY>\n"); 2597 $ofxcount += countprint("</STATUS>\n"); 2598 $ofxcount += countprint("<STMTRS>\n"); 2599 $ofxcount += countprint("<CURDEF>USD</CURDEF>\n"); 2600 $ofxcount += countprint("<BANKACCTFROM>\n"); 2601 $ofxcount += countprint("<BANKID>" . $HB_ENV['rt
'] . "</BANKID>\n"); 2602 $ofxcount += countprint("<ACCTID>$type</ACCTID>\n"); 2603 $ofxcount += countprint("<ACCTTYPE>$acttype</ACCTTYPE>\n"); 2604 $ofxcount += countprint("<DESCRIPTION>$desc</DESCRIPTION>\n"); 2605 if ("$displaydesc" > '') { 2606 $ofxcount += countprint("<DISPLAYDESC>$displaydesc</DISPLAYDESC>\n"); 2608 $ofxcount += countprint("</BANKACCTFROM>\n"); 2610 $history = Get_History($dbh, $HB_ENV, $balkey, $sqlstart, $sqlend); 2611 # opening tags for transaction list 2612 $ofxcount += countprint("<BANKTRANLIST>\n"); 2613 $ofxcount += countprint("<DTSTART>${sqlstart}000000</DTSTART>\n"); 2614 $ofxcount += countprint("<DTEND>${sqlend}235959</DTEND>\n"); 2616 if (count($history[$balkey])) { 2617 foreach ($history[$balkey] as $tnum => $detl) { 2620 $tranamount = $detl['amount
']; 2621 $tranamount = str_replace(",", "", str_replace("$", "", $tranamount)); 2622 $tranamount = sprintf("%.2f", $tranamount); 2623 $trbal = $detl['balance
']; 2624 $trbal = str_replace(",", "", str_replace("$", "", $trbal)); 2625 $trbal = sprintf("%.2f", $trbal); 2626 $check = $detl['checkno
']; 2627 $trandesc = $detl['description
']; 2628 if ($trandesc < " " && $check != 0) { 2631 $trandesc = (preg_replace("/<BR>/", " ", $trandesc)); 2632 $trandesc = (preg_replace("/ /", " ", $trandesc)); 2633 $longdesc = htmlspecialchars($trandesc, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2634 $shortdesc = substr(htmlspecialchars($trandesc, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE), 0, 31); 2635 $shortdesc = preg_replace('/&[^;]*$/
', '', $shortdesc); 2636 $shortdesc = (trim($shortdesc) == '' ? '.
' : $shortdesc); 2638 $ofxcount += countprint("<STMTTRN>\n"); 2639 if ($tranamount < 0) { 2640 if ($balinfo['deposittype
'] == 'Y
' and $check != 0) { 2641 $ofxcount += countprint("<TRNTYPE>CHECK</TRNTYPE>\n"); 2643 $ofxcount += countprint("<TRNTYPE>DEBIT</TRNTYPE>\n"); 2646 $ofxcount += countprint("<TRNTYPE>CREDIT</TRNTYPE>\n"); 2648 $ofxcount += countprint("<DTPOSTED>" . $detl['date
'] . "</DTPOSTED>\n"); 2649 # DTUSER not needed for 211? 2650 $ofxcount += countprint("<DTUSER>" . $detl['date
'] . "</DTUSER>\n"); 2651 $ofxcount += countprint("<TRNAMT>$tranamount</TRNAMT>\n"); 2652 $ofxcount += countprint("<RUNBAL>$trbal</RUNBAL>\n"); 2653 $ofxcount += countprint("<FITID>" . $detl['traceno
'] . "</FITID>\n"); 2654 if ($balinfo['deposittype
'] == 'Y
' and $check != 0) { 2655 $ofxcount += countprint("<CHECKNUM>$check</CHECKNUM>\n"); 2656 if (!empty($detl['ckitem
']) && !empty($detl['ckhash
'])) { 2657 $ofxcount += countprint("<CKITEM>" . $detl['ckitem
'] . "</CKITEM>\n"); 2658 // $ofxcount += countprint("<CKITEM>" . urlencode(hcu_encrypturl($detl['ckitem
'],$chk_key)) . "</CKITEM>\n"); 2659 $ofxcount += countprint("<CKHASH>" . $detl['ckhash
'] . "</CKHASH>\n"); 2662 $ofxcount += countprint("<NAME>$shortdesc</NAME>\n"); 2663 if (strlen($longdesc) > 0) { 2664 $ofxcount += countprint("<MEMO>$longdesc</MEMO>\n"); 2666 $ofxcount += countprint("</STMTTRN>\n"); 2669 # closing tags for transaction list 2671 $ofxcount += countprint("</BANKTRANLIST>\n"); 2672 $ofxcount += countprint("<LEDGERBAL>\n"); 2673 $ofxcount += countprint("<BALAMT>" . $balinfo['currentbal
'] . "</BALAMT>\n"); 2674 $ofxcount += countprint("<DTASOF>$now</DTASOF>\n"); 2675 $ofxcount += countprint("</LEDGERBAL>\n"); 2676 if (($HB_ENV['Fset
'] & $CU_SHOWAVAILABLE) == $CU_SHOWAVAILABLE) { 2677 $ofxcount += countprint("<AVAILBAL>\n<BALAMT>" . $balinfo['availablebal
'] . "</BALAMT>\n <DTASOF>$now</DTASOF>\n</AVAILBAL>\n"); 2680 $ofxcount += countprint("<TXNPENDING>\n"); 2682 $pending = Get_ReqDetails($dbh, $HB_ENV, $balkey); 2683 # Get_ReqDetails returns txdesc already UTF-encoded. Problem? 2684 if (count($pending['acctlist
'][$balkey])) { 2685 foreach ($pending['acctlist
'][$balkey] as $tnum => $detl) { 2688 $ofxcount += countprint("<REQUEST>\n"); 2689 $ofxcount += countprint("<TRACENO>" . $detl['id'] . "</TRACENO>\n"); 2690 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 2691 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 2692 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['txdesc
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 2693 $ofxcount += countprint("</REQUEST>\n"); 2698 if (($HB_ENV['Fset2
'] & $CU2_SHOWPEND) == $CU2_SHOWPEND) { 2699 $pending = Get_PendDetails($dbh, $HB_ENV, $balkey); 2700 if (count($pending[$balkey])) { 2701 foreach ($pending[$balkey] as $tnum => $detl) { 2704 $ofxcount += countprint("<ACHWAREHOUSE>\n"); 2705 $ofxcount += countprint("<TRACENO>" . $detl['traceno
'] . "</TRACENO>\n"); 2706 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 2707 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 2708 // $ofxcount += countprint("<TRNDESC>" . $detl['description
'] . "</TRNDESC>\n"); 2709 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['description
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 2710 $ofxcount += countprint("</ACHWAREHOUSE>\n"); 2714 if (($HB_ENV['Fset2
'] & $CU2_SHOWHOLD) == $CU2_SHOWHOLD) { 2715 $pending = Get_HoldDetails($dbh, $HB_ENV, $balkey); 2716 if (count($pending[$balkey])) { 2717 foreach ($pending[$balkey] as $tnum => $detl) { 2720 $ofxcount += countprint("<PREAUTH>\n"); 2721 $ofxcount += countprint("<TRACENO>" . $detl['traceno
'] . "</TRACENO>\n"); 2722 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 2723 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 2724 // $ofxcount += countprint("<TRNDESC>" . $detl['description
'] . "</TRNDESC>\n"); 2725 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['description
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 2726 $ofxcount += countprint("</PREAUTH>\n"); 2730 $ofxcount += countprint("</TXNPENDING>\n"); 2731 $ofxcount += countprint("<EXTRAINFO>\n"); 2732 $ofxcount += countprint("<DTASOF>$now</DTASOF>\n"); 2733 $ofxcount += countprint("<KEYACCTID>$balkey</KEYACCTID>\n"); 2734 $ofxcount += countprint("<YTDINTEREST>$ytdinterest</YTDINTEREST>\n"); 2735 $ofxcount += countprint("<LYRINTEREST>$lastyrinterest</LYRINTEREST>\n"); 2736 if ($acttype == "CHECKING") { 2737 $ofxcount += countprint("<MICRACCOUNT>$micraccount</MICRACCOUNT>\n"); 2739 # comment these out until cu_data.i is returning them: 2740 # if (($HB_ENV['Fset2
'] & $CU2_SHOWHOLD)== $CU2_SHOWHOLD) { 2741 # $ofxcount += countprint("<HOLDTOTAL>$holdtotal</HOLDTOTAL>\n"); 2743 # if (($HB_ENV['Fset2
'] & $CU2_SHOWPEND)== $CU2_SHOWPEND) { 2744 # $ofxcount += countprint("<PENDTOTAL>$pendtotal</PENDTOTAL>\n"); 2747 $ofxcount += countprint("</EXTRAINFO>\n"); 2748 # closing tags for account info 2749 $ofxcount += countprint("</STMTRS>\n</STMTTRNRS>\n"); 2751 $ofxcount += countprint("</BANKMSGSRSV1>\n"); 2754 # If CU2_SPEC18, try to get credit card loans 2755 if (($HB_ENV['Fset2
'] & $CU2_SPEC18) == $CU2_SPEC18) { 2757 if (count($balances['cc
']) && (empty($KEYACCTID) || (!empty($KEYACCTID) && array_key_exists($KEYACCTID, $balances['cc
'])))) { 2758 $ch_sql = "select ccinfourl from cuadmin where cu='$CU
'"; 2759 $sth_ch = db_query($ch_sql, $dbh); 2760 list($ccinfo) = db_fetch_array($sth_ch, 0); 2761 $incchist = (trim(strtoupper($ccinfo)) == 'HOMECU
' ? 1 : 0); 2763 $ofxcount += countprint("<CREDITCARDMSGSRSV1>\n"); 2765 foreach ($balances['cc
'] as $balkey => $balinfo) { 2766 if ((!empty($KEYACCTID)) && $balkey != $KEYACCTID) { 2770 $ofxcount += countprint("<CCSTMTTRNRS>\n"); 2773 $stmntbal = $balinfo['payoff
']; 2774 $paymentamount = $balinfo['paymentamount
']; 2775 $nextduedate = $balinfo['nextduedate
']; 2776 $interestrate = $balinfo['interestrate
']; 2777 $creditlimit = $balinfo['creditlimit
']; 2778 $ytdinterest = $balinfo['ytdinterest
']; 2779 $lastyrinterest = $balinfo['lastyrinterest
']; 2781 $desc = $balinfo['description
']; 2782 $desc = htmlspecialchars("$desc", ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2783 $displaydesc = $balinfo['displaydesc
']; 2784 $displaydesc = htmlspecialchars("$displaydesc", ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2785 $loan = $balinfo['loan
']; 2786 $balance = $balinfo['currentbal
']; 2787 $creditlimit = $balinfo['creditlimit
']; 2788 $available = $creditlimit - $balance; 2789 $available = ($available < 0 ? "" : $available); 2792 $ofxcount += countprint("<CCSTMTRS>\n"); 2793 $ofxcount += countprint("<CURDEF>USD</CURDEF>\n"); 2794 $ofxcount += countprint("<CCACCTFROM>\n"); 2795 $ofxcount += countprint("<ACCTID>$loan</ACCTID>\n"); 2796 $ofxcount += countprint("<DESCRIPTION>$desc</DESCRIPTION>\n"); 2797 if ("$displaydesc" > '') { 2798 $ofxcount += countprint("<DISPLAYDESC>$displaydesc</DISPLAYDESC>\n"); 2800 if (trim($balinfo['hisinfo
']) > '' && strtolower(trim($balinfo['hisinfo
'])) != 'homecu
') { 2801 $ofxcount += countprint("<HISTORYURL>" . urlencode($balinfo['hisinfo
']) . "</HISTORYURL>\n"); 2803 $ofxcount += countprint("</CCACCTFROM>\n"); 2804 $ofxcount += countprint("<BANKTRANLIST>\n"); 2805 $ofxcount += countprint("<DTSTART>${sqlstart}000000</DTSTART>\n"); 2806 $ofxcount += countprint("<DTEND>${sqlend}235959</DTEND>\n"); 2808 $cur_avail = (($HB_ENV['Fset2
'] & $CU2_CALL_CCAVAIL) == $CU2_CALL_CCAVAIL ? 2809 "Call" : $available); 2812 $history = Get_History($dbh, $HB_ENV, $balkey, $sqlstart, $sqlend); 2813 if (count($history[$balkey])) { 2814 foreach ($history[$balkey] as $tnum => $detl) { 2816 $hisbal = $detl['balance
']; 2817 $principle = $detl['principal
']; 2818 $interest = $detl['interest
']; 2820 if ($principle < 0) { 2823 $trntype = "CREDIT"; 2826 $totalpay = $detl['totalpay
']; 2827 $trdesc = $detl['description
']; 2828 $date = $detl['date
']; 2829 $traceno = $detl['traceno
']; 2830 $longdesc = htmlentities($trdesc, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2831 $shortdesc = substr(htmlentities($trdesc, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE), 0, 31); 2832 $shortdesc = preg_replace('/&[^;]*$/
', '', $shortdesc); 2833 $shortdesc = (trim($shortdesc) == '' ? '.
' : $shortdesc); 2835 # transaction data row 2836 $ofxcount += countprint("<STMTTRN>\n"); 2837 $ofxcount += countprint("<TRNTYPE>$trntype</TRNTYPE>\n"); 2838 $ofxcount += countprint("<DTPOSTED>" . $detl['date
'] . "</DTPOSTED>\n"); 2839 $ofxcount += countprint("<TRNAMT>$totalpay</TRNAMT>\n"); 2840 if (($HB_ENV['Fset
'] & $CU_LNBALUNUSABLE) != $CU_LNBALUNUSABLE) { 2841 $ofxcount += countprint("<RUNBAL>$hisbal</RUNBAL>\n"); 2843 $ofxcount += countprint("<FITID>$traceno</FITID>\n"); 2844 if (($HB_ENV['Fset
'] & $CU_SHOWLNTXNDESC) == $CU_SHOWLNTXNDESC) { 2845 $ofxcount += countprint("<NAME>$shortdesc</NAME>\n"); 2846 $ofxcount += countprint("<MEMO>$longdesc</MEMO>\n"); 2848 $ofxcount += countprint("</STMTTRN>\n"); 2852 $ofxcount += countprint("</BANKTRANLIST>\n"); 2853 $ofxcount += countprint("<LEDGERBAL>\n"); 2854 $ofxcount += countprint("<BALAMT>$balance</BALAMT>\n"); 2855 $ofxcount += countprint("<DTASOF>$now</DTASOF>\n"); 2856 $ofxcount += countprint("</LEDGERBAL>\n"); 2857 if ($cur_avail > 0) { 2858 $ofxcount += countprint("<AVAILBAL>\n"); 2859 $ofxcount += countprint("<BALAMT>$cur_avail</BALAMT>\n"); 2860 $ofxcount += countprint("<DTASOF>$now</DTASOF>\n"); 2861 $ofxcount += countprint("</AVAILBAL>\n"); 2864 $ofxcount += countprint("<TXNPENDING>\n"); 2866 $pending = Get_ReqDetails($dbh, $HB_ENV, $balkey); 2867 # Get_ReqDetails returns txdesc already UTF-encoded. Problem? 2868 if (count($pending['acctlist
'][$balkey])) { 2869 foreach ($pending['acctlist
'][$balkey] as $tnum => $detl) { 2872 $ofxcount += countprint("<REQUEST>\n"); 2873 $ofxcount += countprint("<TRACENO>" . $detl['id'] . "</TRACENO>\n"); 2874 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 2875 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 2876 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['txdesc
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 2877 $ofxcount += countprint("</REQUEST>\n"); 2882 if (($HB_ENV['Fset2
'] & $CU2_SHOWPEND) == $CU2_SHOWPEND) { 2883 $pending = Get_PendDetails($dbh, $HB_ENV, $balkey); 2884 if (count($pending[$balkey])) { 2885 foreach ($pending[$balkey] as $tnum => $detl) { 2888 $ofxcount += countprint("<ACHWAREHOUSE>\n"); 2889 $ofxcount += countprint("<TRACENO>" . $detl['traceno
'] . "</TRACENO>\n"); 2890 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 2891 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 2892 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['description
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 2893 $ofxcount += countprint("</ACHWAREHOUSE>\n"); 2897 if (($HB_ENV['Fset2
'] & $CU2_SHOWHOLD) == $CU2_SHOWHOLD) { 2898 $pending = Get_HoldDetails($dbh, $HB_ENV, $balkey); 2899 if (count($pending[$balkey])) { 2900 foreach ($pending[$balkey] as $tnum => $detl) { 2903 $ofxcount += countprint("<PREAUTH>\n"); 2904 $ofxcount += countprint("<TRACENO>" . $detl['traceno
'] . "</TRACENO>\n"); 2905 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 2906 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 2907 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['description
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 2908 $ofxcount += countprint("</PREAUTH>\n"); 2912 $ofxcount += countprint("</TXNPENDING>\n"); 2913 $ofxcount += countprint("<EXTRAINFO>\n"); 2914 $ofxcount += countprint("<DTASOF>$now</DTASOF>\n"); 2915 $ofxcount += countprint("<KEYACCTID>$balkey</KEYACCTID>\n"); 2916 if ($live && ($HB_ENV['Fset2
'] & $CU2_SHOWCCSB) == $CU2_SHOWCCSB && ($HB_ENV['Fset2
'] & $CU2_CC18NOINFO) != $CU2_CC18NOINFO) { 2917 $ofxcount += countprint("<STMNTBAL>$stmntbal</STMNTBAL>\n"); 2919 $ofxcount += countprint("<PAYAMOUNT>$paymentamount</PAYAMOUNT>\n"); 2920 if (($HB_ENV['Fset
'] & $GLOBALS['CU_HIDELOANDATE
']) != $GLOBALS['CU_HIDELOANDATE
']) { 2921 $ofxcount += countprint("<NEXTDUE>$nextduedate</NEXTDUE>\n"); 2923 $ofxcount += countprint("<INTERESTRATE>$interestrate</INTERESTRATE>\n"); 2924 $ofxcount += countprint("<CREDITLIMIT>$creditlimit</CREDITLIMIT>\n"); 2925 $ofxcount += countprint("<YTDINTEREST>$ytdinterest</YTDINTEREST>\n"); 2926 $ofxcount += countprint("<LYRINTEREST>$lastyrinterest</LYRINTEREST>\n"); 2927 $ofxcount += countprint("</EXTRAINFO>\n"); 2928 $ofxcount += countprint("</CCSTMTRS>\n"); 2929 $ofxcount += countprint("</CCSTMTTRNRS>\n"); 2931 $ofxcount += countprint("</CREDITCARDMSGSRSV1>\n"); 2936 if (count($balances['ln
']) && (empty($KEYACCTID) || (!empty($KEYACCTID) && array_key_exists($KEYACCTID, $balances['ln
'])))) { 2938 $ofxcount += countprint("<LOANMSGSRSV1>\n"); 2940 foreach ($balances['ln
'] as $balkey => $balinfo) { 2941 if ((!empty($KEYACCTID)) && $balkey != $KEYACCTID) { 2945 $ofxcount += countprint("<LOANSTMTTRNRS>\n"); 2947 $balance = $balinfo['currentbal
']; 2948 $loan = $balinfo['loan
']; 2949 $desc = $balinfo['description
']; 2950 $desc = htmlspecialchars("$desc", ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2951 $displaydesc = $balinfo['displaydesc
']; 2952 $displaydesc = htmlspecialchars("$displaydesc", ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2953 $payoff = $balinfo['payoff
']; 2954 $paymentamount = $balinfo['paymentamount
']; 2955 $nextduedate = $balinfo['nextduedate
']; 2956 $interestrate = $balinfo['interestrate
']; 2957 $creditlimit = $balinfo['creditlimit
']; 2958 $ytdinterest = $balinfo['ytdinterest
']; 2959 $lastyrinterest = $balinfo['lastyrinterest
']; 2962 $ofxcount += countprint("<LOANSTMTRS>\n"); 2963 $ofxcount += countprint("<CURDEF>USD</CURDEF>\n"); 2964 $ofxcount += countprint("<LOANACCTFROM>\n"); 2965 $ofxcount += countprint("<LOANACCTID>$loan</LOANACCTID>\n"); 2966 $ofxcount += countprint("<LOANACCTTYPE>CONSUMER</LOANACCTTYPE>\n"); 2967 $ofxcount += countprint("<DESCRIPTION>$desc</DESCRIPTION>\n"); 2968 if ("$displaydesc" > '') { 2969 $ofxcount += countprint("<DISPLAYDESC>$displaydesc</DISPLAYDESC>\n"); 2971 if (trim($balinfo['hisinfo
']) > '' && strtolower(trim($balinfo['hisinfo
'])) != 'homecu
') { 2972 $ofxcount += countprint("<HISTORYURL>" . urlencode($balinfo['hisinfo
']) . "</HISTORYURL>\n"); 2974 $ofxcount += countprint("</LOANACCTFROM>\n"); 2975 $ofxcount += countprint("<LOANTRANLIST>\n"); 2976 $ofxcount += countprint("<DTSTART>${sqlstart}000000</DTSTART>\n"); 2977 $ofxcount += countprint("<DTEND>${sqlend}235959</DTEND>\n"); 2979 $history = Get_History($dbh, $HB_ENV, $balkey, $sqlstart, $sqlend); 2980 if (count($history[$balkey])) { 2981 foreach ($history[$balkey] as $tnum => $detl) { 2983 $hisbal = $detl['balance
']; 2984 $principle = $detl['principal
']; 2985 $interest = $detl['interest
']; 2986 $totalpay = $detl['totalpay
']; 2987 $traceno = $detl['traceno
']; 2988 $trdesc = $detl['description
']; 2990 if ($principle < 0) { 2991 $trntype = "PAYMENT"; 2993 $trntype = "ADVANCE"; 2996 $longdesc = htmlentities($trdesc, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE); 2997 $shortdesc = substr(htmlentities($trdesc, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE), 0, 31); 2998 $shortdesc = preg_replace('/&[^;]*$/
', '', $shortdesc); 2999 $shortdesc = (trim($shortdesc) == '' ? '.
' : $shortdesc); 3001 # transaction data row 3002 $ofxcount += countprint("<LOANSTMTTRN>\n"); 3003 $ofxcount += countprint("<LOANTRNTYPE>$trntype</LOANTRNTYPE>\n"); 3004 $ofxcount += countprint("<DTPOSTED>" . $detl['date
'] . "</DTPOSTED>\n"); 3005 if (($HB_ENV['Fset
'] & $CU_SHOWLNTXNSPLIT) == $CU_SHOWLNTXNSPLIT) { 3006 $ofxcount += countprint("<TRNAMT>$totalpay</TRNAMT>\n"); 3007 $ofxcount += countprint("<LOANTRNAMT>\n"); 3008 $ofxcount += countprint("<PRINAMT>$principle</PRINAMT>\n"); 3009 $ofxcount += countprint("<INTAMT>$interest</INTAMT>\n"); 3010 $ofxcount += countprint("</LOANTRNAMT>\n"); 3012 $ofxcount += countprint("<TRNAMT>$principle</TRNAMT>\n"); 3014 if (($HB_ENV['Fset
'] & $CU_LNBALUNUSABLE) != $CU_LNBALUNUSABLE) { 3015 $ofxcount += countprint("<RUNBAL>$hisbal</RUNBAL>\n"); 3017 $ofxcount += countprint("<FITID>$traceno</FITID>\n"); 3018 if (($HB_ENV['Fset
'] & $CU_SHOWLNTXNDESC) == $CU_SHOWLNTXNDESC) { 3019 $ofxcount += countprint("<NAME>$shortdesc</NAME>\n"); 3020 $ofxcount += countprint("<MEMO>$longdesc</MEMO>\n"); 3022 $ofxcount += countprint("</LOANSTMTTRN>\n"); 3025 $ofxcount += countprint("</LOANTRANLIST>\n"); 3026 $ofxcount += countprint("<PRINBAL>\n"); 3027 $ofxcount += countprint("<BALAMT>$balance</BALAMT>\n"); 3028 $ofxcount += countprint("<DTASOF>$now</DTASOF>\n"); 3029 $ofxcount += countprint("</PRINBAL>\n"); 3031 $ofxcount += countprint("<TXNPENDING>\n"); 3033 $pending = Get_ReqDetails($dbh, $HB_ENV, $balkey); 3034 # Get_ReqDetails returns txdesc already UTF-encoded. Problem? 3035 if (count($pending['acctlist
'][$balkey])) { 3036 foreach ($pending['acctlist
'][$balkey] as $tnum => $detl) { 3039 $ofxcount += countprint("<REQUEST>\n"); 3040 $ofxcount += countprint("<TRACENO>" . $detl['id'] . "</TRACENO>\n"); 3041 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 3042 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 3043 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['txdesc
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 3044 $ofxcount += countprint("</REQUEST>\n"); 3049 if (($HB_ENV['Fset2
'] & $CU2_SHOWPEND) == $CU2_SHOWPEND) { 3050 $pending = Get_PendDetails($dbh, $HB_ENV, $balkey); 3051 if (count($pending[$balkey])) { 3052 foreach ($pending[$balkey] as $tnum => $detl) { 3055 $ofxcount += countprint("<ACHWAREHOUSE>\n"); 3056 $ofxcount += countprint("<TRACENO>" . $detl['traceno
'] . "</TRACENO>\n"); 3057 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 3058 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 3059 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['description
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 3060 $ofxcount += countprint("</ACHWAREHOUSE>\n"); 3064 if (($HB_ENV['Fset2
'] & $CU2_SHOWHOLD) == $CU2_SHOWHOLD) { 3065 $pending = Get_HoldDetails($dbh, $HB_ENV, $balkey); 3066 if (count($pending[$balkey])) { 3067 foreach ($pending[$balkey] as $tnum => $detl) { 3070 $ofxcount += countprint("<PREAUTH>\n"); 3071 $ofxcount += countprint("<TRACENO>" . $detl['traceno
'] . "</TRACENO>\n"); 3072 $ofxcount += countprint("<DTREQUEST>" . $detl['postdate
'] . "</DTREQUEST>\n"); 3073 $ofxcount += countprint("<TRNAMT>" . $detl['amount
'] . "</TRNAMT>\n"); 3074 $ofxcount += countprint("<TRNDESC>" . htmlspecialchars($detl['description
'], ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</TRNDESC>\n"); 3075 $ofxcount += countprint("</PREAUTH>\n"); 3079 $ofxcount += countprint("</TXNPENDING>\n"); 3080 $ofxcount += countprint("<EXTRAINFO>\n"); 3081 $ofxcount += countprint("<DTASOF>$now</DTASOF>\n"); 3082 $ofxcount += countprint("<KEYACCTID>$balkey</KEYACCTID>\n"); 3083 $ofxcount += countprint("<PAYOFF>$payoff</PAYOFF>\n"); 3084 $ofxcount += countprint("<PAYAMOUNT>$paymentamount</PAYAMOUNT>\n"); 3085 if (($HB_ENV['Fset
'] & $GLOBALS['CU_HIDELOANDATE
']) != $GLOBALS['CU_HIDELOANDATE
']) { 3086 $ofxcount += countprint("<NEXTDUE>$nextduedate</NEXTDUE>\n"); 3088 $ofxcount += countprint("<INTERESTRATE>$interestrate</INTERESTRATE>\n"); 3089 $ofxcount += countprint("<CREDITLIMIT>$creditlimit</CREDITLIMIT>\n"); 3090 $ofxcount += countprint("<YTDINTEREST>$ytdinterest</YTDINTEREST>\n"); 3091 $ofxcount += countprint("<LYRINTEREST>$lastyrinterest</LYRINTEREST>\n"); 3092 $ofxcount += countprint("</EXTRAINFO>\n"); 3093 $ofxcount += countprint("</LOANSTMTRS>\n"); 3094 $ofxcount += countprint("</LOANSTMTTRNRS>\n"); 3096 $ofxcount += countprint("</LOANMSGSRSV1>\n"); 3098 $ofxcount += countprint("</OFX>\n"); 3099 header("Content-length: $ofxcount"); 3103 } catch (Exception $e) { 3104 $code = $e->getCode(); 3105 $message = $e->getMessage(); 3108 $ofxcount += countprint("<OFXERR>\n<STATUS>\n<CODE>$code</CODE>\n"); 3109 $ofxcount += countprint("<SEVERITY>ERROR</SEVERITY>\n</STATUS>\n"); 3111 $ofxcount += countprint("<MESSAGE>\n"); 3112 $ofxcount += countprint("<ERR>" . htmlspecialchars($message, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</ERR>\n"); 3113 $ofxcount += countprint("<ERRNO>999</ERRNO>\n<ERRSTAT>FAIL</ERRSTAT>\n"); 3114 $ofxcount += countprint("</MESSAGE>\n"); 3115 $ofxcount += countprint("</OFXERR>\n"); 3117 header("Content-length: $ofxcount"); 3122 function send_response($code, $message, $severity = "ERROR") { 3124 #header("Content-Type: application/x-ofx"); 3125 $ofxcount += countprint("<OFXERR>\n<STATUS>\n<CODE>$code</CODE>\n"); 3126 $ofxcount += countprint("<SEVERITY>$severity</SEVERITY>\n</STATUS>\n"); 3128 foreach ($message as $err => $details) { 3129 $ofxcount += countprint("<MESSAGE>\n"); 3130 $ofxcount += countprint("<ERR>" . htmlspecialchars($details, ENT_NOQUOTES | ENT_XML1, 'UTF-8
', FALSE) . "</ERR>\n"); 3131 $ofxcount += countprint("<ERRNO>999</ERRNO>\n<ERRSTAT>FAIL</ERRSTAT>\n"); 3132 // $ofxcount += countprint("<ELIST>" . print_r($message,true) . "</ELIST\n"); 3133 $ofxcount += countprint("</MESSAGE>\n"); 3135 $ofxcount += countprint("</OFXERR>\n"); 3137 header("Content-length: $ofxcount"); 3142 function sqlmdy($date) { 3144 if (strtolower($date) == "now" || strtolower($date) == "today") { 3145 $date = date("Y-m-d"); 3147 # only allow 0-9 and dash(-) or slash (/) 3148 # also allow dot (.) for milliseconds 3149 if (preg_match("/[^0-9\-\/\.]/", $date)) { 3152 if (preg_match("/[-\/]/", $date)) { 3153 list ($yy, $mm, $dd) = preg_split("/[-\/\.]/", $date); 3155 $yy = substr($date, 0, 4); 3156 $mm = substr($date, 4, 2); 3157 $dd = substr($date, 6, 2); 3159 $mm = sprintf("%02d", intval($mm)); 3160 $dd = sprintf("%02d", intval($dd)); 3161 if (strlen($yy) > 0 && strlen($yy) < 4) { 3162 $yy = ($yy < 70 ? 2000 + $yy : 1900 + $yy); 3164 $yy = sprintf("%04d", intval($yy)); 3165 if (checkdate($mm, $dd, $yy)) { 3166 return "${yy}${mm}${dd}"; 3172 function countprint($string) { 3174 return strlen($string); 3177 function clockwatch($tz, $CU, $MEMBER) { 3178 $localzone = 'US/Mountain
'; 3179 $tz = ("$tz" == "" ? "US/Mountain" : $tz); 3180 if (strpos("$tz", "/") === false) 3183 $sqlll = "set time zone '$tz
'; 3184 select extract(epoch from CURRENT_TIMESTAMP(0)) - 3185 extract(epoch from substring(lastlogin,1,19)::timestamp)::integer 3187 where cu='$CU
' and user_name='$MEMBER
';"; 3188 $sthcl = db_query($sqlll, $dbh); 3190 list($sincelast) = db_fetch_array($sthcl, 0); 3192 $sthcl = db_query("set time zone '$localzone
'", $dbh); 3193 return abs($sincelast); 3196 function MFA_send_chall($dbh, $HB_ENV, $MC) { 3198 # sending all questions regardless of '1 random
' setting for cu 3199 # updated 9/12 to recognize '1 random
' setting 3200 # use odyssey function 3203 $MemberChallengeQuestions_ary=GetChallengeQuestions("CHALLENGE", $dbh, $HB_ENV, $MC, $HB_ENV['Cn
']); 3205 $now = date('YmdHis
'); 3206 $mfa_resp = '<?xml version=
"1.0" encoding=
"' . $encoding . '"?>
'; 3208 $mfa_resp .= '<?OFX OFXHEADER=
"200" VERSION=
"211" SECURITY=
"NONE" OLDFILEUID=
"NONE" NEWFILEUID=
"NONE"?>
'; 3209 $mfa_resp .="\n<OFX> 3214 <SEVERITY>ERROR</SEVERITY> 3216 <DTSERVER>$now</DTSERVER> 3217 <LANGUAGE>ENG</LANGUAGE> 3220 <MFACHALLENGERS>\n"; 3221 # force 'What email
' as first challenge question 3222 $mfa_resp .= "<MFACHALLENGE> 3223 <MFAPHRASEID>MFA_E</MFAPHRASEID> 3224 <MFAPHRASELABEL>What email address is saved with this account?</MFAPHRASELABEL> 3226 # and now add mfa questions, if any were found 3227 if (count($MemberChallengeQuestions_ary)) { 3228 foreach ((array) $MemberChallengeQuestions_ary as $mfakey => $mfaitem) { 3230 $mfa_resp .= "<MFACHALLENGE> 3231 <MFAPHRASEID>MFA_{$mfaitem['cqid
']}</MFAPHRASEID> 3232 <MFAPHRASELABEL>{$mfaitem['display
']}</MFAPHRASELABEL> 3236 $mfa_resp .= "</MFACHALLENGERS> 3237 </MFACHALLENGETRNRS> 3241 $ofxcount += countprint("$mfa_resp"); 3242 header("Content-length: $ofxcount"); 3246 function MFA_response($dbh, $HB_ENV, $inPost) { 3250 $chcount = $HB_ENV['MFA
']['mfacount
']; # how many questions are in the db? 3251 $mfapost = MFA_resplist($inPost); # get list of MFA variables in the posted request (skips MFA_E) 3252 # update from mammoth - gets id and answers in array using Odyssey format 3253 $mfacount = count($mfapost); # how many MFA_ responses (excluding MFA_E) did we get? 3255 if ($mfacount < $HB_ENV['MFA
']['mfacount
'] && ($HB_ENV['Fset2
'] & $GLOBALS['CU2_RANDOM_CHAL
']) == 0) { 3256 # expected challenge questions and there aren't any, so fail
3258 $failreason = $GLOBALS[
'MEM_LOGIN_FAILED_QST'];
3259 throw new Exception(__LINE__ .
'MFA Failed',$failreason);# expected chall ques and got none
3261 # make sure savemail is set in HB_ENV 3262 if (strtolower($inPost[
'MFA_E']) !== strtolower($HB_ENV[
'savemail'])) {
3264 $failreason = $GLOBALS[
'MEM_LOGIN_FAILED_EMAIL'];
3265 throw new Exception(__LINE__ .
'MFA Failed',$failreason);# email mismatch
3273 $aryMfaAnswers = $HB_ENV[
'MFA'][
'answers']; # stored answers
3274 if (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_RANDOM_CHAL']) == $GLOBALS[
'CU2_RANDOM_CHAL'] && $HB_ENV[
'MFA'][
'challenge'] > 0) {
3276 $mfaAnswerIdx = Array($HB_ENV[
'MFA'][
'challenge']);
3279 $mfaAnswerIdx = array_keys($aryMfaAnswers);
3283 # for each id in $mfaAnserIdx 3285 foreach (array_intersect_key($aryMfaAnswers, array_flip($mfaAnswerIdx)) as $qid => $qanswer) {
3287 if (strtolower(trim($qanswer)) != strtolower(trim($inPost[
"MFA_$qid"]))) {
3289 $failreason = $GLOBALS[
'MEM_LOGIN_FAILED_QST'];
3290 throw new Exception(__LINE__ .
"MFA $qid Failed",$failreason);# chall response mismatch
3293 }
catch (Exception $e) {
3294 # logging handled at point of call - nothing to do here but fall through? 3296 return (array($fail, $failreason));
3299 function MFA_resplist($posted) {
3300 # examines the (sanitized!) array of posted values 3301 # returns list of MFA_ excluding MFA_E (email) 3303 foreach (array_keys($posted) as $rkey) {
3304 $m = strpos($rkey,
'MFA_');
3305 if ($m !== FALSE && $m == 0 && $rkey !==
'MFA_E') {
3306 $mfalist[] = array(
'cqid'=>substr($rkey,4),
'cqanswer'=>$posted[$rkey]);
3312 function MFA_defined($posted) {
3313 # returns a count of MFA_* in (sanitized) array of posted values 3315 foreach (array_keys($posted) as $rkey) {
3316 $m = strpos($rkey,
'MFA_');
3317 if ($m !== FALSE && $m == 0) {
3324 function ANS_list($arr) {
3326 foreach (array_keys($arr) as $rkey) {
3327 $m = strpos($rkey,
'ANS_');
3328 if ($m !== FALSE && $m == 0) {
3329 $anslist[] = substr($rkey, 4);
3335 function Send_ResponseOK($CU, $MEMBER, $CAUTH, $SENDKEY, $MESSAGE, $V = 1) {
3336 # was sending <LASTUPDATE>" . $HB_ENV['lastupdate'] . "</LASTUPDATE> 3337 # but it was always empty as HB_ENV is neither passed in nor global 3339 $now = date(
'YmdHis');
3342 $upd_resp =
'<?xml version="1.0" encoding="' . $encoding .
'"?>';
3344 $upd_resp .=
'<?OFX OFXHEADER="200" VERSION="211" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>';
3345 $upd_resp .=
"\n<OFX>";
3346 $upd_resp .=
"<SIGNONMSGSRSV1>\n<SONRS>";
3348 $ofxcount += countprint(
"<OFXPOST>\n");
3350 $upd_resp .=
"<STATUS> 3352 <SEVERITY>INFO</SEVERITY> 3354 <INFO>$MESSAGE</INFO> 3357 <DTSERVER>" . $now .
"</DTSERVER> 3358 <MEMBER>$MEMBER</MEMBER>";
3360 $apptoken = MakeUserkey($CU, $MEMBER, $CAUTH);
3361 $upd_resp .=
"<USERKEY>$apptoken</USERKEY>\n";
3365 $upd_resp .=
"</SONRS> 3369 $upd_resp .=
"</OFXPOST>";
3372 $ofxcount += countprint(
"$upd_resp");
3373 header(
"Content-length: $ofxcount");
3377 function Send_AllowedUpdate($CU, $MEMBER, $CAUTH) {
3384 $apptoken = MakeUserkey($CU, $MEMBER, $CAUTH);
3386 $upd_grace = $HB_ENV[
'Ffremain'];
3387 $upd_wait = ($upd_grace == 0 ?
"You must update your credentials now." :
3388 "You must update your credentials within the next $upd_grace login" . ($upd_grace == 1 ?
'.' :
's.') );
3390 $now = date(
'YmdHis');
3391 $upd_resp =
'<?xml version="1.0" encoding="' . $encoding .
'"?>';
3393 $upd_resp .=
'<?OFX OFXHEADER="200" VERSION="211" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>';
3394 $upd_resp .=
"\n<OFX> 3399 <SEVERITY>INFO</SEVERITY> 3400 <SREQ>{$HB_ENV['forceupdate']}</SREQ> 3401 <UREQ>{$HB_ENV['requpdate']}</UREQ> 3403 <DTSERVER>$now</DTSERVER> 3404 <LANGUAGE>ENG</LANGUAGE> 3405 <MEMBER>{$HB_ENV['Uid']}</MEMBER> 3406 <USERKEY>$apptoken</USERKEY> 3410 if ($HB_ENV[
'forceupdate'] != 0) {
3411 $upd_resp .=
"<UPDCANWAIT>$upd_grace</UPDCANWAIT> 3412 <UPDWAITPHRASE>$upd_wait</UPDWAITPHRASE>\n";
3414 $upd_resp .=
"<PASSWORD> 3416 <REQ>" . (($HB_ENV[
'forceupdate'] & 1) ?
"YES" :
"NO") .
"</REQ> 3420 <REQ>" . (($HB_ENV[
'forceupdate'] & 2) ?
"YES" :
"NO") .
"</REQ> 3423 <ALLOW>" . ($HB_ENV[
'cver'] ==
'F' ?
'YES' :
'NO') .
"</ALLOW> 3424 <REQ>" . (($HB_ENV[
'forceupdate'] & 4) ?
"YES" :
"NO") .
"</REQ> 3427 <ALLOW>" . ($HB_ENV[
'alias'] ==
'NONE' ?
'NO' : $HB_ENV[
'alias']) .
"</ALLOW> 3428 <REQ>" . (($HB_ENV[
'forceupdate'] & 8) ?
"YES" :
"NO") .
"</REQ> 3435 #header("Content-Type: application/x-ofx"); 3436 $ofxcount += countprint(
"$upd_resp");
3437 header(
"Content-length: $ofxcount");
3441 function Send_ReqUpdate($CU, $MEMBER, $CAUTH) {
3447 $apptoken = MakeUserkey($CU, $MEMBER, $CAUTH);
3449 $upd_grace = $HB_ENV[
'Ffremain'];
3450 $upd_wait = ($upd_grace == 0 ?
"You must update your credentials now." :
3451 "You must update your credentials within the next $upd_grace login" . ($upd_grace == 1 ?
'.' :
's.') );
3453 $now = date(
'YmdHis');
3454 $upd_resp =
'<?xml version="1.0" encoding="' . $encoding .
'"?>';
3456 $upd_resp .=
'<?OFX OFXHEADER="200" VERSION="211" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>';
3457 $upd_resp .=
"\n<OFX> 3462 <SEVERITY>INFO</SEVERITY> 3463 <SREQ>{$HB_ENV['forceupdate']}</SREQ> 3464 <UREQ>{$HB_ENV['requpdate']}</UREQ> 3466 <DTSERVER>$now</DTSERVER> 3467 <LANGUAGE>ENG</LANGUAGE> 3468 <MEMBER>{$HB_ENV['Uid']}</MEMBER> 3469 <USERKEY>$apptoken</USERKEY> 3473 if ($HB_ENV[
'forceupdate'] != 0 && $HB_ENV[
'requpdate'] == 0) {
3474 $upd_resp .=
"<UPDCANWAIT>$upd_grace</UPDCANWAIT> 3475 <UPDWAITPHRASE>$upd_wait</UPDWAITPHRASE>\n";
3477 if ((($HB_ENV[
'forceupdate'] & 4) == 4 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 4) == 4) {
3478 # 2-factor and either force reset or not enough questions selected yet 3479 # Security Reset: send master list of challenge questions 3480 $upd_resp .=
"<REQUPD> 3481 <UPDPHRASEID>CHALLENGE</UPDPHRASEID> 3482 <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.</UPDCONFLABEL> 3483 <UPDCONFIDENCE>" . htmlentities($HB_ENV[
'confidence'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</UPDCONFIDENCE> 3484 <UPDPHRASECOUNT>" . $HB_ENV[
'cu_chgqst_count'] .
"</UPDPHRASECOUNT>\n";
3485 if ($HB_ENV[
'cu_chgqst_count'] > 0) {
3486 $upd_resp .=
"<UPDPHRASELABEL>Please select {$HB_ENV['cu_chgqst_count']} challenge questions.</UPDPHRASELABEL>\n";
3487 $upd_resp .=
"<UPDCHOICELIST>\n";
3488 $questlist = GetChallengeQuestions(
"DISPLAY", $dbh, $HB_ENV);
3489 foreach ($questlist as $QstValue) {
3490 $upd_resp .=
"<CHOICEITEM><CQID>{$QstValue['cqid']}</CQID>\n";
3491 $upd_resp .=
"<CQTEXT>" . htmlentities($QstValue[
'display'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</CQTEXT>\n</CHOICEITEM>\n";
3493 $upd_resp .=
"</UPDCHOICELIST>\n";
3494 if (($HB_ENV[
'requpdate'] & 4) == 4) {
3495 # 'on-demand' update - send current selected questions/responses 3496 $upd_resp .=
"<CURRSELECTED>\n";
3497 foreach ($HB_ENV[
'MFA'][
'answers'] as $quest_id => $quest_resp) {
3498 $upd_resp .=
"<SELECTEDITEM><CQID>$quest_id</CQID>\n";
3499 $upd_resp .=
"<CQRESP>" . htmlentities($quest_resp, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</CQRESP>\n</SELECTEDITEM>\n";
3501 $upd_resp .=
"</CURRSELECTED>\n";
3504 $upd_resp .=
"</REQUPD>\n";
3506 if ((($HB_ENV[
'forceupdate'] & 1) == 1 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 1) == 1) {
3508 $helpdoc =
"pwdRules";
3509 $fragext = (trim($HB_ENV[
'Flang']) ==
"en_US" ?
"" :
"_" . substr($HB_ENV[
'Flang'], 0, strpos($HB_ENV[
'Flang'],
"_")) );
3510 $helpdoc .= ($fragext >
"" && is_readable(
"/home/{$HB_ENV['chome']}/public_html/{$helpdoc}{$fragext}.html") ?
"{$fragext}.html" :
".html");
3511 if (is_readable(
"/home/{$HB_ENV['chome']}/public_html/$helpdoc")) {
3512 $helpdoc =
"https://" . $_SERVER[
'SERVER_NAME'] .
"/fi/{$HB_ENV['chome']}/$helpdoc";
3514 $helpdoc =
"https://" . $_SERVER[
'SERVER_NAME'] . dirname($_SERVER[
'PHP_SELF']) .
"/$helpdoc";
3517 $pwdRequires = Get_PwdRules($dbh, $HB_ENV);
3518 $upd_resp .=
"<REQUPD> 3519 <UPDPHRASEID>PASSWORD</UPDPHRASEID> 3520 <UPDPHRASELABEL>Please select a new password.</UPDPHRASELABEL> 3521 <PWDRULESLINK>" . htmlentities($helpdoc, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</PWDRULESLINK> 3522 <PWDRULESLABEL>I have read the Recommended Password Guidelines</PWDRULESLABEL> 3523 <PWDADVLABEL>Recommended Guidelines</PWDADVLABEL> 3525 foreach ($pwdRequires as $pwdkey => $pwdval) {
3526 $pwdkey = strtoupper($pwdkey);
3527 $upd_resp .=
"<$pwdkey>$pwdval</$pwdkey>\n";
3530 $pwdSpecChar = Get_PwdSpecialCharacters();
3531 $upd_resp .=
"<PWDSPECIALCHARS>" . htmlspecialchars($pwdSpecChar, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</PWDSPECIALCHARS>\n";
3533 $upd_resp .=
"</PWDREQUIRES> 3536 if ((($HB_ENV[
'forceupdate'] & 6) > 0 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 2) == 2) {
3537 # verify email is set or email is empty, 3538 # or we are sending the CHALLENGE set so include email with it (apps treat email as extra challenge question) 3539 $upd_resp .=
"<REQUPD> 3540 <UPDPHRASEID>EMAIL</UPDPHRASEID> 3541 <UPDPHRASELABEL>Please provide your email address.</UPDPHRASELABEL> 3542 <CURRENTEMAIL>" . htmlentities($HB_ENV[
'Ml'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</CURRENTEMAIL> 3543 <CURRENTOPTIN>{$HB_ENV['egenl_flag']}</CURRENTOPTIN> 3544 <OPTIN_PHRASE>" . $MC->msg(
'Yes Email List') .
"</OPTIN_PHRASE> 3547 if ((($HB_ENV[
'forceupdate'] & 8) == 8 && $HB_ENV[
'requpdate'] == 0) || ($HB_ENV[
'requpdate'] & 8) == 8) {
3549 $maymust = (($HB_ENV[
'Fset2'] & $GLOBALS[
'CU2_ALIAS_REQ']) == $GLOBALS[
'CU2_ALIAS_REQ'] ?
'must' :
'may');
3550 $aliaslabel = $MC->combo_msg(
'Username Set', 0,
'#MAYMUST#',
"$maymust");
3551 $upd_resp .=
"<REQUPD> 3552 <UPDPHRASEID>USERALIAS</UPDPHRASEID> 3554 ($HB_ENV[
'alias'] ==
'NONE' ?
'NO' : $HB_ENV[
'alias']) .
3556 <UPDPHRASELABEL>" . htmlentities($aliaslabel, ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</UPDPHRASELABEL>\n";
3557 if (($HB_ENV[
'requpdate'] & 8) == 8) {
3558 # 'on-demand' update - send current user alias 3559 $upd_resp .=
"<CURRENTALIAS>" . htmlentities($HB_ENV[
'useralias'], ENT_NOQUOTES | ENT_XML1,
'UTF-8', FALSE) .
"</CURRENTALIAS>\n";
3561 $upd_resp .=
"</REQUPD>\n";
3564 $upd_resp .=
"</REQUPDRS> 3570 #header("Content-Type: application/x-ofx"); 3571 $ofxcount += countprint(
"$upd_resp");
3572 header(
"Content-length: $ofxcount");
3576 function MakeUserkey($CU, $MEMBER, $CAUTH) {
3577 global $apptokenkey;
3578 $appexpires = time() + 900; # 15 minutes
3579 $apphash = MD5($apptokenkey . MD5(join(
':', array($apptokenkey, $appexpires, $CU, $MEMBER, $CAUTH))));
3580 # $mytoken="H=$hash&E=$expires&A=$cauth_member&C=$current_member"; 3582 $apptoken = urlencode(
"H=$apphash&E=$appexpires&A=$MEMBER&C=$CAUTH");
3586 function CleanWordQuotes($instring) {
3624 $instring = str_replace($search, $replace, $instring);
3628 function Load_HB_ENV($dbh, $CU, $MEMBER, $USERPASS, $CAUTH, &$HB_ENV, $CFGFLAG=0) {
3630 $username = trim($MEMBER);
3631 $live = $HB_ENV[
'live'];
3633 # on first (method MFA) login, MEMBER will have username 3634 # after that, (method SSO) MEMBER will have USERID 3635 # and if using SWJUMP to view alternate account...? Don't know yet 3639 if ($HB_ENV[
'AuthMode'] ==
'MFA') {
3641 $qby =
"cuuser.user_name ilike '" . prep_save($MEMBER) .
"' ";
3642 } elseif ($HB_ENV[
'AuthMode'] ==
'SSO') {
3643 $qby =
"cuuser.user_id = $MEMBER ";
3645 # figure out the SWJUMP 3647 if (preg_match(
"/\D/", $MEMBER) || $HB_ENV[
'AuthMode'] ==
'MFA') {
3648 # username contains non-digits or this is an MFA login 3649 $qby =
"cuuser.user_name ilike '" . prep_save($MEMBER) .
"' ";
3652 $qby =
"cuuser.user_id = $MEMBER ";
3657 $sqluser =
"SELECT cuuser.user_id as user_id, trim(cuuser.user_name) as user_name, trim(cuuser.passwd) as password, forcechange, forceremain, failedremain, 3658 pwchange, trim(email) as email, egenl_flag, confidence, cuuser.user_id as cuuser_id, cuuser.group_id as cuuser_group_id, 3659 lastlogin, failedlogin, msg_tx, userflags & {$GLOBALS['MEM_FORCE_RESET']}::int4 as mem_force_reset, userflags, 3660 coalesce(challenge_quest_id,0) as challenge_quest_id, trim(cuadmin.rt) as rt, 3661 cuadmin.flagset, cuadmin.flagset2, cuadmin.flagset3, cuadmin.livewait, trim(cuadmin.lastupdate) as lastupdate, 3662 trim(cuadmin.pname) as pname, histdays, gracelimit, trmemomaxlen, mfaquest, primary_account 3664 FROM {$CU}user as cuuser 3665 JOIN cuadmin on cuadmin.cu = '" . prep_save($CU) .
"' 3668 $mbr_sth = db_query($sqluser, $dbh);
3669 if (db_num_rows($mbr_sth) == 0) {
3673 $drow = db_fetch_array($mbr_sth, 0);
3705 #If live and MFA login and we have a USERPASS and MEMBER is all digits and (no user record or password == 'NULL PASSWORD') 3706 if ($live && $HB_ENV[
'AuthMode'] ==
'MFA' && trim($USERPASS) >
'' && (db_num_rows($mbr_sth) == 0 || $drow[
'password'] ==
'NULL PASSWORD') &&
3707 !(preg_match(
"/\D/", $MEMBER))) {
3708 # no cuuser record: # try to get user info from the core cu 3709 # run the query again if the fetch was successful 3711 list ($status, $asofdate, $reason) = fetch_user($CU, $MEMBER, $USERPASS, $insflag);
3712 if ($status ==
"100" || $status ==
"101") {
3714 $mbr_sth = db_query($sqluser, $dbh);
3716 # didn't get good data - notify HB_ENV 3717 $HB_ENV[
'core-status'] = $status;
3719 # If live and MFA login and we have a USERPASS and MEMBER contains NON-Digits and at least 5 chars and password=NULL PASSWORD and alias is allowed or required 3720 # try to fetch from the core using the primary account from the NULL PASSWORD rec. 3722 } elseif ($live && $HB_ENV[
'AuthMode'] ==
'MFA' && trim($USERPASS) !=
'' && $drow[
'user_name'] !=
'' 3723 && (preg_match(
"/^[a-zA-Z][^\\`,\"\s;]*$/", $MEMBER) && strlen($MEMBER) > 5)
3724 && (db_num_rows($mbr_sth) > 0) && $drow[
'password'] ==
'NULL PASSWORD' &&
3725 ( ($drow[
'flagset2'] & $GLOBALS[
'CU2_ALIAS_OK']) || ($drow[
'flagset2'] & $GLOBALS[
'CU2_ALIAS_REQ']) )
3734 # this will need to use primary account instead of $MEMBER? 3735 # OR fetch_user updated to accommodate user_name? 3736 # OR this feature doesn't work this way any more? 3738 list ($status, $asofdate, $reason) = fetch_user($CU, $drow[
'primary_account'], $USERPASS, $insflag);
3739 if ($status ==
"100" || $status ==
"101") {
3741 $mbr_sth = db_query($sqluser, $dbh);
3743 # didn't get good data - notify HB_ENV 3744 $HB_ENV[
'core-status'] = $status;
3748 $drow = db_fetch_array($mbr_sth, 0);
3750 $HB_ENV[
'Cu'] = $CU;
3751 $HB_ENV[
'cu'] = $CU;
3752 $HB_ENV[
'chome'] = strtolower($CU);
3757 $HB_ENV[
'Cn'] = $drow[
'user_name'];
3758 $HB_ENV[
'Cauth'] = trim($drow[
'primary_account']);
3759 # some calls use Uid, some use user_id so set both 3760 $HB_ENV[
'Uid'] = $drow[
'user_id'];
3761 $HB_ENV[
'user_id'] = $drow[
'user_id'];
3763 # some calls use username, some use user_name, so set both 3764 $HB_ENV[
'username'] = $drow[
'user_name'];
3765 $HB_ENV[
'user_name'] = $drow[
'user_name'];
3766 $HB_ENV[
'confidence'] = $drow[
'confidence'];
3767 $HB_ENV[
'Ml'] = urlencode($drow[
'email']);
3768 $HB_ENV[
'savemail'] = $drow[
'email'];
3769 $HB_ENV[
'egenl_flag'] = urlencode($drow[
'egenl_flag']);
3770 $HB_ENV[
'rt'] = $drow[
'rt'];
3771 $HB_ENV[
'tz'] = $drow[
'tz'];
3772 $HB_ENV[
'orgname'] = $drow[
'orgname'];
3773 $HB_ENV[
'offline'] = (trim($drow[
'offlinestat']) ==
'' ?
'N' : $drow[
'offlinestat']);
3774 $HB_ENV[
'offlineblurb'] = strip_tags($drow[
'offlineblurb']);
3775 $HB_ENV[
'password'] = $drow[
'password'];
3776 $HB_ENV[
'userflags'] = $drow[
'userflags'];
3777 $HB_ENV[
'failedremain'] = $drow[
'failedremain'];
3778 $HB_ENV[
'Ffchg'] = $drow[
'forcechange'];
3779 $HB_ENV[
'Ffremain'] = $drow[
'forceremain'];
3780 $HB_ENV[
'dbforceremain'] = $drow[
'forceremain'];
3781 $HB_ENV[
'Ffreset'] = (is_null($drow[
'mem_force_reset']) ? 0 : $drow[
'mem_force_reset']);
3783 $HB_ENV[
'Fmsg_tx'] = (is_null($drow[
'msg_tx']) ? 0 : $drow[
'msg_tx']);
3784 $HB_ENV[
'cfgflag'] = $CFGFLAG; #
set cfgflag
if CFGFLAG
if passed
3785 $HB_ENV[
'Fverifyml'] = ($drow[
'msg_tx'] & 512);
3786 $HB_ENV[
'Fhdays'] =(is_null($drow[
'histdays']) ? 0 : $drow[
'histdays']);
3787 $HB_ENV[
'Fset'] = (is_null($drow[
'flagset']) ? 0 : $drow[
'flagset']);
3788 $HB_ENV[
'Fset2'] = (is_null($drow[
'flagset2']) ? 0 : $drow[
'flagset2']);
3789 $HB_ENV[
'Fset3'] = (is_null($drow[
'flagset3']) ? 0 : $drow[
'flagset3']);
3790 $HB_ENV[
'cver'] = $drow[
'cookie_ver'];
3791 $HB_ENV[
'trmemomaxlen'] = $drow[
'trmemomaxlen'];
3793 # mammoth data calls use Clw; odyssey switched to livewait so define both 3794 $HB_ENV[
'Clw'] = ((is_null($drow[
'livewait']) || $drow[
'livewait'] == 0) ? 300 : $drow[
'livewait']);
3795 $HB_ENV[
'livewait'] = ((is_null($drow[
'livewait']) || $drow[
'livewait'] == 0) ? 300 : $drow[
'livewait']);
3796 $HB_ENV[
'lastupdate'] = (empty($drow[
'lastupdate']) ?
"Unknown" : urlencode(trim($drow[
'lastupdate'])));
3797 $HB_ENV[
'pwchange'] = (is_null($drow[
'pwchange']) ? date(
'Ymd') : $drow[
'pchange']);
3798 $HB_ENV[
'employee'] = $drow[
'employee'];
3799 $HB_ENV[
'HCUPOST'] = array(); #
set empty parameter array
3800 $HB_ENV[
'cu_chgqst_count'] = intval($drow[
'min_chlng_qst']);
3801 if ($drow[
'flagset2'] & $GLOBALS[
'CU2_ALIAS_REQ']) {
3803 } elseif ($drow[
'flagset2'] & $GLOBALS[
'CU2_ALIAS_OK']) {
3808 $HB_ENV[
'alias'] = $alias;
3811 $HB_ENV[
'MFA'] = ($HB_ENV[
'cver'] ==
'L' ? array() : HCU_JsonDecode($drow[
'mfaquest']));
3814 if ($HB_ENV[
'Ffchg'] ==
'Y') {
3815 $FORCEUPDATE += 1; #password
3817 if ($HB_ENV[
'Fverifyml'] == 512 || ($HB_ENV[
'cver'] ==
'F' && $HB_ENV[
'Ml'] ==
'')) {
3818 $FORCEUPDATE += 2; # email
3820 if ($HB_ENV[
'cver'] ==
'F' &&
3821 ($HB_ENV[
'Ffreset'] == 2 || $HB_ENV[
'confidence'] ==
"" ||
3822 sizeof($HB_ENV[
'MFA'][
'answers']) < $HB_ENV[
'cu_chgqst_count'] )
3824 $FORCEUPDATE += 4; #challenge questions
3826 if ($HB_ENV[
'alias'] ==
'REQUIRE' && $HB_ENV[
'useralias'] ==
"") {
3830 $HB_ENV[
'forceupdate'] = $FORCEUPDATE;
3831 $HB_ENV[
'allowupdate'] = 3; # password and email update always allowed
3832 $HB_ENV[
'allowupdate'] += ($HB_ENV[
'cver'] ==
'F' ? 4 : 0);
3833 $HB_ENV[
'allowupdate'] += ($HB_ENV[
'alias'] ==
'NONE' ? 0 : 8);
3835 $HB_ENV[
'requpdate'] = 0; # assume at first
this is not a
'getsettings' request
3836 # eventually this will come from a new column in cuadmin 3838 $HB_ENV[
'TicketExpires'] = $GLOBALS[
'TicketExpires'];
3839 $HB_ENV[
'AppTimeout'] = intval($HB_ENV[
'SYSENV'][
'ticket'][
'expires'] * .8);
3840 $lastlogin = $drow[
'lastlogin'];
3841 $HB_ENV[
'Fplog'] = ($lastlogin ==
'None' ?
'' : (strftime(
"%D %R", mktime(
3842 substr($lastlogin, 11, 2), substr($lastlogin, 14, 2), substr($lastlogin, 17, 2), substr($lastlogin, 5, 2), substr($lastlogin, 8, 2), substr($lastlogin, 0, 4)))));
3843 $failedlogin = $drow[
'failedlogin'];
3844 $HB_ENV[
'Fflog'] = ($failedlogin ==
'None' ?
'' : (strftime(
"%D %R", mktime(
3845 substr($failedlogin, 11, 2), substr($failedlogin, 14, 2), substr($failedlogin, 17, 2), substr($failedlogin, 5, 2), substr($failedlogin, 8, 2), substr($failedlogin, 0, 4)))));
3847 $pname = (empty($drow[
'pname']) ?
"Home Banking" : $drow[
'pname']);
3848 $HB_ENV[
'product'] = $pname;
3849 $HB_ENV[
'secret'] = GetSecretKeyString();