8 $serviceMinimal =
true;
9 $serviceShowInfo =
false;
10 $serviceLoadMenu =
false;
11 $serviceShowMenu =
false;
15 require_once(dirname(__FILE__) .
'/../library/hcuService.i');
16 require_once(dirname(__FILE__) .
'/../library/hcuDispFunctions.i');
17 require_once(dirname(__FILE__) .
'/../library/hcuAuthShared.i');
18 require_once(
'cutrusted.i');
19 setIncludeFiles(
false,
true,
'bootstrap',
true);
22 unset( $HB_ENV[
"MC"] );
26 "APPID" => array(
'filter' => FILTER_SANITIZE_STRING),
27 "CRED2" => array(
'filter' => FILTER_SANITIZE_STRING),
28 "CRED3" => array(
'filter' => FILTER_SANITIZE_STRING),
29 "USERID" => array(
'filter' => FILTER_SANITIZE_STRING),
30 "USERPASS" => array(
'filter' => FILTER_SANITIZE_STRING),
31 "USERKEY" => array(
'filter' => FILTER_SANITIZE_STRING),
32 "cu" => array(
'filter' => FILTER_SANITIZE_STRING),
33 "URLQstr" => array(
'filter' => FILTER_SANITIZE_STRING),
34 "sessionKey" => array(
'filter' => FILTER_SANITIZE_STRING),
35 "URLPassWith" => array(
'filter' => FILTER_SANITIZE_STRING),
36 "generate" => array(
'filter' => FILTER_SANITIZE_STRING),
37 "msg" => array(
'filter' => FILTER_SANITIZE_STRING),
38 "WWWSvr" => array(
'filter' => FILTER_SANITIZE_STRING),
39 "AMOUNT" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
40 "PASSTO" => array(
'filter' => FILTER_SANITIZE_STRING),
41 "PASSWITH" => array(
'filter' => FILTER_SANITIZE_STRING),
45 HCU_ImportVars( $inPost,
"", $varOk );
47 $cu = HCU_array_key_value(
'cu',$inPost);
48 # look a little closer at that cu value -- 49 # ctype_alnum ensures not empty / null, and contains only letters / digits 50 if (!ctype_alnum($cu)) {
51 throw new Exception(
"Invalid Request", 901); # empty ORG
54 $msg=HCU_array_key_value(
'msg',$inPost);
55 $USERID=HCU_array_key_value(
'USERID',$inPost);
56 $USERPASS=HCU_array_key_value(
'USERPASS',$inPost);
57 $USERKEY=urldecode(HCU_array_key_value(
'USERKEY',$inPost));
58 $APPID=HCU_array_key_value(
'APPID',$inPost);
59 $URLQstr=HCU_array_key_value(
'URLQstr',$inPost);
60 $sessionKey=HCU_array_key_value(
'sessionKey',$inPost);
61 $URLPassWith=HCU_array_key_value(
'URLPassWith',$inPost);
62 $generate=HCU_array_key_value(
'generate',$inPost);
63 $WWWSvr=HCU_array_key_value(
'WWWSvr',$inPost);
68 if (!empty($generate)) {
70 if (empty($USERID) && empty($USERKEY)) {
71 $msg .=
"Please enter User ID or User Key<br>\n";
75 # consider trusted detail settings for these ? 76 $client_source_override =
'OMX'; # unique
for Mx
78 require_once(dirname(__FILE__) .
'/../library/MDesk_API.i');
80 if (!hcu_checkService($dbh,
"MDESK")) {
81 $omsg = hcu_checkServiceMsg($dbh,
"MDESK");
82 throw new Exception(
"$omsg");
85 # cutrusted_read will fall back to master if detail not found 86 $Mxtrusted = cutrusted_read($dbh, array(
'Cu' => $CU,
'trustedid' =>
'MDesk3'));
88 if ($Mxtrusted[
'status'][
'Response'] ==
'false') {
89 throw new Exception(
"Client not configured for remote Mx access", 913); # missing trusted detail
91 if (HCU_array_key_exists(
'data', $Mxtrusted)) {
92 $mxParms = $Mxtrusted[
'data'];
94 throw new Exception(
"Client not configured for remote Mx access", 914); # missing trusted detail parms
97 # default to production mode 98 $testing = ( HCU_array_key_exists(
'testing', $mxParms) ? HCU_array_key_value(
'testing', $mxParms) : 0 );
101 # HCU-issued sharekey used by trusted vendor for hashing CRED2/CRED3 102 # maybe not needed for MDX5? 103 $mdkey = HCU_array_key_value(
'mdTestKey', $mxParms);
104 $mdAPI_key = HCU_array_key_value(
'testAPIKey', $mxParms);
105 $mdData_URL = HCU_array_key_value(
'testServerURL', $mxParms);
106 $mxHMACKey = HCU_array_key_value(
'testHMACKey', $mxParms);
108 # HCU-issued sharekey used by trusted vendor for hashing CRED2/CRED3 109 # maybe not needed for MDX5? 110 $mdkey = HCU_array_key_value(
'mdShareKey', $mxParms);
111 $mdAPI_key = HCU_array_key_value(
'APIKey', $mxParms);
112 $mdData_URL = HCU_array_key_value(
'ServerURL', $mxParms);
113 $mxHMACKey = HCU_array_key_value(
'HMACKey', $mxParms);
117 throw new Exception(
"Client misconfigured for remote authentication", 902); # missing trusted detail parms (keys)
120 if (empty($mxHMACKey)) {
121 throw new Exception(
"Client misconfigured for remote Mx access", 912); # missing trusted detail parms (keys)
124 $mdtokenkey = HCU_array_key_value(
'mdTokenKey', $mxParms);
126 if (empty($mdtokenkey)) {
127 throw new Exception(
"Client misconfigured for remote authentication", 902); # missing trusted detail parms (keys)
130 $client_key_TTL = ( HCU_array_key_exists(
'mdTokenTTL', $mxParms) ? HCU_array_key_value(
'mdTokenTTL', $mxParms) : 900 );
131 $SENDAS = ( HCU_array_key_exists(
'resultsAs', $mxParms) ? HCU_array_key_value(
'resultsAs', $mxParms) :
'XML' );
137 $msg .=
"Invalid App ID<br>\n";
140 if ($APPID ==
'MDESK') {
142 $mxSessionData = array(
'userkey' => $USERKEY,
'userid' => $USERID,
'userpass' => $USERPASS,
'formpost' => $URLPassWith
143 # accountid = selected account identifier
144 # start_date = start date
for transaction list
146 $mxRequestArr = mxMakeRequest($WWWSvr, $CU, $mxHMACKey, $URLQstr, $mxSessionData, $sessionKey);
147 # mxSessionData is array of required content varies based on mxRestOpt 148 $mxStatus = HCU_array_key_value(
'status', $mxRequestArr);
149 $mxVerb = HCU_array_key_value(
'mxVerb', $mxRequestArr);
150 $mxURL = HCU_array_key_value(
'mxURL', $mxRequestArr);
151 $mxContent = HCU_array_key_value(
'mxContent', $mxRequestArr);
152 $mxHeaders = HCU_array_key_value(
'headers', $mxRequestArr);
155 if (!($mxStatus)) $reason .=
'Status ';
156 if (empty($mxVerb)) $reason .=
'mxVerb ';
157 if (empty($mxURL)) $reason .=
'mxURL ';
158 if (empty($mxHeaders)) $reason .=
'mxHeaders ';
160 if (!($mxStatus) || empty($mxVerb) || empty($mxURL) || empty($mxHeaders)) {
161 $cmd =
"Error: missing {$reason}" . HCU_array_key_value(
'because', $mxRequestArr);
164 if (strtoupper($mxVerb) !=
'GET') {
165 $cmd .=
' -X ' . strtoupper($mxVerb);
167 foreach ($mxHeaders as $hdr => $hdrContent) {
168 $cmd .=
" -H '{$hdr}: {$hdrContent}'";
170 if (!empty($mxContent)) {
171 $cmd .=
" --data '$mxContent'";
173 $cmd .=
" '{$mxURL}'";
175 $embedResponse = mxGetData($mxVerb, $mxHeaders, $mxContent, $mxURL);
176 # format this to show request, headers, etc.? 181 $response .=
"HTTP " . (integer) HCU_array_key_value(
'respHTTP',$embedResponse) .
" \n";
182 $response .=
"CURL " . (integer) HCU_array_key_value(
'respCURL',$embedResponse) .
" \n";
183 if (HCU_array_key_value(
'respERR', $embedResponse) ) {
184 $response .=
"ERR {$embedResponse['respCURL']} \n";
186 $response .=
"\n" . htmlentities(HCU_array_key_value(
'responseHeaders', $embedResponse));
187 $response .=
"\n" . htmlentities(HCU_array_key_value(
'responseBody', $embedResponse));
193 if (!empty($USERKEY)) {
194 # get member out of userkey hash 195 # H=$apphash&E=$appexpires&A=$MEMBER&P=DeviceToken 197 $apptokarr = array();
198 parse_str(urldecode($USERKEY), $apptokarr);
199 $MEMBER = HCU_array_key_value(
'A', $apptokarr);
202 $USERID = trim($USERID);
206 # new sha384 key - load pchange date from member last pw change 207 # legacy md5 key, PCHANGE = 0 but not used to build token 208 $userrec = GetUserbyName($dbh, $CU, $MEMBER);
209 if (! HCU_array_key_value(
'rowfound', $userrec)) {
210 throw new Exception(
"Invalid User");
212 $apptoken = MakeV94Dkey($CU, $MEMBER, $userrec, $client_key_TTL, $mdtokenkey,
'S');
214 if (empty($USERPASS)) {
215 $USERKEY = (empty($USERKEY) ? $apptoken : urlencode($USERKEY));
224 $WWWSvr = (empty($WWWSvr) ?
"http://" . $_SERVER[
'HTTP_HOST'] . dirname($_SERVER[
'PHP_SELF']) .
"/MoneyDesk3.prg" : $WWWSvr);
226 }
catch (Exception $ex) {
227 $error = $ex-> getMessage();
234 <title><?php echo hcu_displayHtml(
"App Simulator"); ?></title>
235 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8"/>
236 <meta name=
"robots" content=
"noindex,nofollow" />
237 <meta http-equiv=
"X-UA-Compatible" content=
"IE=edge" />
239 <meta name=
"viewport" content=
"width=device-width, initial-scale=1" />
242 <div
class=
'container-fluid'>
244 if ( strlen( $msg ) > 0 ) {
246 <div
class=
"well" style=
"color:darkred;">
252 <div
class=
'well well-sm col-xs-6' style=
"max-width:48%;">
254 <h3>HomeCU Mx/MDX Test Generator</h3>
256 <form
id=
'formAppKey' name=
'formAppKey' method=
"post" action=
"GenMDX.prg">
259 <div
class=
"col-xs-12 hcu-container-margin">
260 <label
for=
"APPID" class=
"col-xs-3">
263 <input
id=
'APPID' name=
'APPID' class=
'col-xs-8' placeholder=
"Choose: MDESK" 264 required data-required-msg=
"Choose: MDESK" value=
"<?php echo "$APPID
"; ?>" size=
"50"/>
267 <div
class=
"col-xs-12 hcu-container-margin">
268 <label
for=
"cu" class=
"col-xs-3" >
271 <input
id=
'cu' name=
'cu' class=
'col-xs-8' placeholder=
"Upper Case CU Code" 272 required data-required-msg=
"The CU code" value=
"<?php echo "$cu
"; ?>" size=
"50"/>
275 <div
class=
"col-xs-12 hcu-container-margin">
276 <label
for=
"USERID" class=
"col-xs-3">
279 <input
id=
'USERID' name=
'USERID' class=
'col-xs-8' value=
"<?php echo "$USERID
"; ?>" size=
"50"/>
282 <div
class=
"col-xs-12 hcu-container-margin">
283 <div
class=
"col-xs-12" style=
'font-size:smaller; opacity=0.38; padding-bottom: 10px;'>
284 User Key is added to computed link; copy in latest
286 <label
for=
"USERKEY" class=
"col-xs-3">
289 <textarea
id=
'USERKEY' name=
'USERKEY' class=
'col-xs-8' style=
"height: 5em;"><?php echo
"$USERKEY"; ?></textarea>
292 <div
class=
"well col-xs-12 hcu-container-margin">
294 <div
class=
"col-xs-12" style=
'font-size:smaller; opacity=0.38; padding-bottom: 10px;'>Use
if testing authentication process (supply Password, blank
User Key, click Generate Link first)</div>
297 <label
for=
"USERPASS" class=
"col-xs-3">
300 <input
id=
'USERPASS' name=
'USERPASS' type=
"password" class=
'col-xs-8' placeholder=
"Leave blank to populate User Key" value=
"<?php echo "$USERPASS
"; ?>" size=
"50"/>
303 <div
class=
"col-xs-12"> </div>
307 <div
class=
"well col-xs-12 hcu-container-margin">
309 <label
for=
"URLQstr" class=
"col-xs-3">
312 <input
id=
'URLQstr' name=
'URLQstr' class=
'col-xs-8' placeholder=
"sessions or accounts or transactions" value=
"<?php echo "$URLQstr
"; ?>" size=
"50"/>
315 <label
for=
"sessionKey" class=
"col-xs-3">
318 <input
id=
'sessionKey' name=
'sessionKey' class=
'col-xs-8' placeholder=
"session key as returned from server" value=
"<?php echo "$sessionKey
"; ?>" size=
"50"/>
321 <div
class=
"col-xs-12"> </div>
324 <label
for=
"URLPassWith" class=
"col-xs-3">
327 <input
id=
'URLPassWith' name=
'URLPassWith' class=
'col-xs-8' placeholder=
'start_date=Y-m-d or accountid=accounthash, etc.' value=
"<?php echo "$URLPassWith
"; ?>" size=
"50"/>
331 <div
class=
"col-xs-12 hcu-container-margin">
332 <label
for=
"WWWSvr" class=
"col-xs-3">
335 <input
id=
'WWWSvr' name=
'WWWSvr' class=
'col-xs-8' value=
"<?php echo "$WWWSvr
"; ?>" size=
"50"/>
339 <div
class=
"col-xs-12 hcu-container-margin">
340 <div
class=
"col-xs-6">
341 <button
id=
"btnGenerate" name=
'btnGenerate' type=
"submit" class=
"k-button k-primary hcu-all-100 hcu-xs-btn-margin-top hcu-xs-btn-pad">
342 <span
class=
"fa fa-arrow-right local-pad-icon"></span>
346 <input type=
"hidden" name=
"generate" value=
"go">
351 <div
class=
'well well-sm col-xs-6' style=
"max-width:48%; margin-left:10px;">
352 <div
class=
"col-xs-12 hcu-container-margin">
354 <textarea
id=
'targetLink' name=
'targetLink' class=
'col-xs-12' style=
"height: 10em;">
355 <?php echo
"$error"; ?>
356 <?php echo htmlentities($cmd); ?>
359 <div
class=
"col-xs-12 hcu-container-margin">
361 <textarea
id=
"getDataResult" name=
"getDataResult" class=
"col-xs-12" style=
"height: 27em;">
362 <?php echo $response; ?>
366 <div
class=
'col-xs-12'>
370 <li>Enter App ID, Org ID,
User ID. Leave
User Key blank to
get generated key.</li>
371 <li>Set Rest Option [sessions | accounts | transactions] and Pass With (as needed). </li>
372 <li>Click
'Format and Fetch' Key. This generates a
User Key to start communications.</li>
374 <li>Note that first click will show Error in response - because there wasn
't a key yet on post. 'Fetch
' again and the userkey will work.</li> 375 <li>Could also copy/paste key from vendor log to test key planted at Mx</li> 377 <li>If testing authentication process, enter password matching the User ID; Copy <key> from previous reply as session key.</li> 378 <li>Sending password generates a challenge reply. To respond, set passwith to send corresponding MFA_E and MFA_## answers; Copy <key> from previous reply as session key.</li> 382 Possible Rest Options are:<br> 386 <li>transactions</li> 388 Possible Passwith Options: 390 <li>sessions request MFA challenge response 392 <li>send MFA_E=email@host.com&MFA_55=answer55&MFA_64=answer64 where MFA_## matches challenge received</li> 397 <li>accounts request has no passwith</li> 400 <li>transactions request 402 <li>send start_date=YYYY-MM-DD&accountid=<id> of selected account from previous accounts request</li> 411 <!--============================================--> 425 function mxMakeRequest($baseURL, $mxClient, $mxHMACKey, $mxRestOpt, $mxSessionData, $mxSessionKey) {
426 # baseURL=wwwServer mxClient=cu mxRestOpt=URLQstr
427 # mxSessionData is array of
429 # userid = $USERID # used as member identifier for 'accounts
' request 430 # userpass = $USERPASS 431 # accountid = selected account identifier 432 # start_date = start date for transaction list 433 # formpost = form variables to be posted. Send as name=value string, format here 434 # required content varies based on mxRestOpt 436 # mxSessionKey is valid key returned on previous session call, 437 # or empty for initial session create 440 # when testing from docker the baseURL is localhost:8000 441 # but popen to port 8000 fails. 442 # so... remove the :8000 and php is happy 443 # but note! put the :8000 back to paste in terminal session 444 $baseURL = str_replace(":8000","", $baseURL); 445 $userkey = HCU_array_key_value('userkey
', $mxSessionData); 446 $userid = HCU_array_key_value('userid
', $mxSessionData); 447 $userpass = HCU_array_key_value('userpass
', $mxSessionData); 449 $formpost = HCU_array_key_value('formpost
', $mxSessionData); 450 # turn the name=value pairs into an array, and count how many are MFA_* 452 $formfields = array(); 453 parse_str($formpost, $formfields); 454 foreach (array_keys($formfields) as $rkey) { 455 $m = strpos($rkey, 'MFA_
'); 456 if ($m !== FALSE && $m == 0) { 460 $account = HCU_array_key_value('accountid
', $formfields); 461 $start_date = HCU_array_key_value('start_date
', $formfields); 464 if (empty($mxHMACKey)) { 465 throw new Exception("Missing key"); 468 $result['headers
']['Accept
'] = 'application/vnd.moneydesktop.mdx.v5+xml
'; 469 $result['headers
']['Content-Type
'] = 'application/vnd.moneydesktop.mdx.v5+xml
'; 470 $result['headers
']['MDX-Job-Type
'] = 'foreground
'; 471 # $result['headers
']['MDX-Job-Type
'] = 'background
'; 473 # $mxSessionKey s/b empty for initial session create, otherwise return what the server sent 474 if (!empty($mxSessionKey)) { 475 $result['headers
']['MDX-Session-Key
'] = $mxSessionKey; 478 switch ($mxRestOpt) { 480 $mxURL = "$baseURL/$mxClient/sessions"; 481 if (empty($mxSessionKey) ) { 482 if (empty($userkey) ) { 483 # no session key - create session 486 * <mdx version='5.0
'> 488 * <login><![CDATA[janedoe]]></login> 489 * <password><![CDATA[topsecret]]></password> 493 $mxContent = "<?xml version=\"1.0\"?>\n<mdx version=\"5.0\">\n<session>\n<login><![CDATA[$userid]]></login>\n<password><![CDATA[$userpass]]></password>\n</session>\n</mdx>\n"; 495 # no session key - create session 498 * <mdx version='5.0
'> 500 * <userkey><![CDATA[UNIQUE_KEY_FOR_THIS_USER]]><</userkey> 504 $mxContent = "<?xml version=\"1.0\"?>\n<mdx version=\"5.0\">\n<session>\n<userkey><![CDATA[$userkey]]></userkey>\n</session>\n</mdx>\n"; 509 throw new Exception('SessionKey but no MFA_*
'); 511 # must be mfa challenge response 514 * <mdx version='5.0
'> 516 * <key>UNIQUE_KEY_FOR_THIS_SESSION</key> 519 * <id>UNIQUE_IDENTIFIER_FOR_THIS_CHALLENGE</id> 520 * <answer><![CDATA[answer]]></answer> 523 * <id>UNIQUE_IDENTIFIER_FOR_THIS_CHALLENGE</id> 524 * <answer><![CDATA[answer]]></question> 526 * <!-- additional challenge questions --> 531 $mxContent = "<?xml version=\"1.0\"?>\n<mdx version=\"5.0\">\n<session>\n<key>$mxSessionKey</key>\n"; 532 if (is_array($formfields) ) { 535 foreach ($formfields as $key => $value) { 536 if (substr($key,0,4) == 'MFA_
') { 537 $mxMFA .= "<challenge>\n<id>$key</id>\n<answer><![CDATA[$value]]></answer></challenge>\n"; 542 $mxContent .= "<challenges>\n$mxMFA\n</challenges>\n"; 544 throw new Exception('Invalid session content requested
'); 547 $mxContent .= "</session>\n</mdx>\n"; 549 // # POST and PUT requests include a Content-Type header 550 // $result['headers
']['Content-Type
'] = 'application/vnd.moneydesktop.mdx.v5+xml
'; 554 # need to send a SessionKey header w/enough info to get the right member 555 if (empty($userid)) { 556 throw new Exception("Missing accounts parameters"); 558 $mxURL = "$baseURL/$mxClient/accounts"; 564 #GET /accounts/:account_id/transactions?start_date=YYYY-MM-DD&page=n 565 # need to send a SessionKey header w/enough info to get the right member 566 if (empty($account) || empty($start_date)) { 567 throw new Exception("Missing transactions parameters " . json_encode($formfields)); 569 if (!strtotime($start_date)) { 570 throw new Exception("Invalid transactions parameter start_date"); 572 $start_date = date('Y-m-d
', strtotime($start_date)); 573 $mxURL = "$baseURL/$mxClient/accounts/$account/transactions?start_date=$start_date&page=1"; 578 throw new Exception("Unknown rest endpoint"); 581 $mxRestOpt = (substr($mxRestOpt,0,1) == '/
' ? $mxRestOpt : "/$mxRestOpt"); 582 $result['mxRestOpt
'] = $mxRestOpt; 583 $result['mxVerb
'] = $mxVerb; 584 $result['mxURL
'] = $mxURL; 585 $result['mxContent
'] = $mxContent; 586 $mxContentType = HCU_array_key_value('Content-Type
', $result['headers
']); 588 $result['headers
']['Date
'] = $mxEpoch; 589 $result['headers
']['Content-MD5
'] =md5($mxContent); 590 $mxAccept = HCU_array_key_value('Accept
', $result['headers
']); 591 if (empty($mxSessionKey)) { 592 $mxSessionKey = ''; # in case it is null, force empty string 594 $mxContentMD5 = HCU_array_key_value('Content-MD5
', $result['headers
']); 595 //POST /sessions "<?xml version=\"1.0\"?>\n<mdx version=\"5.0\">\n <session>\n <userkey><![CDATA[the-userkey]]></userkey>\n </session>\n</mdx>\n" 596 //Content-Type: application/vnd.moneydesktop.mdx.v5+xml 598 //Accept: application/vnd.moneydesktop.mdx.v5+xml 600 #HTTP VERB + "\n" + # $mxVerb 601 #Content-MD5 Header + "\n" + # $mxContentMD5 602 #Content-Type Header + "\n" + # $mxContentType 603 #UNIX Epoch Date Time + "\n" + # $mxEpoch 604 #Accept Header + "\n" + # $mxAccept 605 #MDX-Session-Key + "\n" + # $mxSessionKey 606 #REST Resource of Request # $mxRestOpt 608 // $sigStr = "POST\ne9a179f879165fd64bdeaa57032d342f\napplication/vnd.moneydesktop.mdx.v5+xml\n1382975431\napplication/vnd.moneydesktop.mdx.v5+xml\n\n/sessions"; 609 // Dom't be mislead by the \n\n/sessions at the end. That is \n{empty session key}\n/sessions
610 $sigStr =
"{$mxVerb}\n{$mxContentMD5}\n{$mxContentType}\n{$mxEpoch}\n{$mxAccept}\n{$mxSessionKey}\n{$mxRestOpt}";
611 # calculate SHA1 using key mxHMACKey above as test 612 $sigHash = hash_hmac(
"SHA1", $sigStr, base64_decode($mxHMACKey));
613 $result[
'headers'][
'MDX-HMAC'] = $sigHash;
615 }
catch (Exception $e) {
617 $result[
'because'] = $e->getMessage();
619 $result[
'status'] = $boolresult;
620 $result[
'showme']= json_encode(array(
621 'mxHMACKey' => $mxHMACKey,
623 'sigHash' => $sigHash));
626 function mxGetData($mxVerb, $mxHeaders, $mxContent, $mxURL) {
628 # when testing from docker the baseURL is localhost:8000 629 # but popen to port 8000 fails. 630 # so... remove the :8000 and php is happy 631 # but note! put the :8000 back to paste in terminal session 632 $mxURL = str_replace(
":8000",
"", $mxURL);
636 CURLOPT_RETURNTRANSFER => 1,
637 CURLOPT_SSL_VERIFYPEER => 0,
638 CURLOPT_SSL_VERIFYHOST => 0,
639 CURLOPT_HEADER => TRUE,
640 CURLOPT_USERAGENT =>
'HCU_GenMDX',
641 CURLOPT_URL =>
"$mxURL");
651 curl_setopt_array($ch, $curlopts);
652 if ($mxVerb !=
'GET') {
653 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mxVerb);
655 if (strlen($mxContent) > 0) {
656 curl_setopt($ch, CURLOPT_POSTFIELDS, $mxContent);
659 if (count($mxHeaders) ) {
660 foreach ($mxHeaders as $hdr => $hdrContent) {
661 $headers[] =
"{$hdr}: {$hdrContent}";
663 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
668 $return[
'request'] =
"$mxVerb to $mxURL with headers " . print_r($headers,
true) .
" and content $mxContent";
669 $response = curl_exec($ch);
671 $respHTTP = curl_getinfo($ch, CURLINFO_HTTP_CODE);
672 $return[
'respHTTP'] = (integer) $respHTTP;
674 $respCURL = curl_errno($ch);
675 $return[
'respCURL'] = (integer) $respCURL;
678 $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
679 $return[
'responseHeaders'] = substr($response, 0, $header_size);
680 $return[
'responseBody'] = substr($response, $header_size);
684 # Bad! Don't hide the error, return the curl error if it occurred. 685 $return[
'respERR'] =
"Connection Failed cURL $respCURL";
686 } elseif ($respHTTP > 400 && $respHTTP < 600) {
687 # HTTP Response 4xx client error or 5xx server error 688 $return[
'respERR'] =
"Connection Failed HTTP $respHTTP ";
689 } elseif (!isset($response) || trim($response) ==
'') {
690 if ($respHTTP != 204 && $respHTTP != 200) {
691 # HTTP 204 No Content w/o response = 'Everything OK but no data' 692 # HTTP 200 OK w/o response = 'Everything OK but no data' 693 $return[
'respERR'] =
"Empty Response with HTTP $respHTTP ";
700 function formatData($data) {
704 $dom =
new DOMDocument();
706 $dom->preserveWhiteSpace =
false;
707 $dom->formatOutput =
true;
709 $dom->loadXML($data);
710 $out = $dom->saveXML();
716 $(
"#btnGenerate").click(
function() {
717 var org = $(
"#cu").val();
718 var action = $(
"#formAppKey").attr(
"action" );
732 .local-transfer-msg {
736 .local-transfer-button {
741 .k-dropdown .k-input,.k-selectbox .k-input {
745 .container-fluid-margin {
749 .k-block > .k-header {
754 .hcu-info-margin, .hcu-error-margin {
758 .hcu-info-padding, .hcu-error-padding {
766 .hcu-container-margin {