xx xx=xx '; // data from the form, e.g. some ID number $headers = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: http://schemas.ethoca.com/E360v1/wsdl/EthocaServices/getE360AlertsRequest", "Content-length: ".strlen($xml_post_string), ); // PHP cURL for https connection with auth $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_URL, $soapUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // converting $response = curl_exec($ch); curl_close($ch); // converting $response1 = str_replace("","",$response); $response2 = str_replace("","",$response1); // convertingc to XML $parser = simplexml_load_string($response2); // user $parser to get your data out of XML response and to display it. //Test #include('testxml.php'); // SimpleXML seems to have problems with the colon ":" in the response tags, so take them out $xml = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response); $xml = simplexml_load_string($xml); $json = json_encode($xml); $responseArray = json_decode($json,true); #echo $response; #echo '
';
#print_r($responseArray);
#echo '
'; $numofethalerts=$responseArray['soapenvBody']['ethEthoca360AlertsResponse']['ethNumberOfAlerts']; if($numofethalerts==1){ if(isset($responseArray['soapenvBody']['ethEthoca360AlertsResponse']['ethAlerts'])){ foreach($responseArray['soapenvBody']['ethEthoca360AlertsResponse']['ethAlerts'] as $value){ extract($value); $ethCardNumber = sweet_encrypt($ethCardNumber); $ethAlertTimestamp = str_replace('T',' ',$ethAlertTimestamp); $ethAlertT=explode('.',$ethAlertTimestamp); $ethAlertTimestamp=$ethAlertT[0]; $ethTransactionTimestamp = str_replace('T',' ',$ethTransactionTimestamp); $ethTransT=explode('.',$ethTransactionTimestamp); $ethTransactionTimestamp=$ethTransT[0]; $ethMerchantDescriptor=strtoupper($ethMerchantDescriptor); $acknar[]=$ethEthocaID; #acknowledge array //Insert alert into DB $ethIssuer=str_replace("'","",$ethIssuer); mysql_query("INSERT INTO cbalerts (ethoca_id, alert_time, age, bank, cnm, trans_time, descriptor, amount, currency, type, entered_by, instime) VALUES ('$ethEthocaID', '$ethAlertTimestamp', '$ethAge', '$ethIssuer', '$ethCardNumber', '$ethTransactionTimestamp', '$ethMerchantDescriptor', '$ethAmount', '$ethCurrency', '$ethTransactionType', '$ethInitiatedBy', '$the_time')"); //Get descriptor info $descrownquer = mysql_query("SELECT alert_email FROM descriptors WHERE descriptor='$ethMerchantDescriptor'"); if(mysql_num_rows($descrownquer)==0){ #if exact descriptor not found, search for similar and enter it for next time $firstfv = trim(substr($ethMerchantDescriptor, 0, 5)); $descrownquer = mysql_query("SELECT * FROM descriptors WHERE descriptor LIKE '$firstfv%' LIMIT 1"); if(mysql_num_rows($descrownquer)!=0){ $fivr = mysql_fetch_array($descrownquer); $fvuserid = $fivr['user_id']; $fvdescr = trim($ethMerchantDescriptor); $fvalrtem = $fivr['alert_email']; $fvaffid = $fivr['affiliate_id']; mysql_query("INSERT INTO descriptors (user_id, descriptor, alert_email, affiliate_id) VALUES ('$fvuserid', '$fvdescr', '$fvalrtem', '$fvaffid')"); } } $descrownquer = mysql_query("SELECT alert_email FROM descriptors WHERE descriptor='$ethMerchantDescriptor'"); $descrownrow = mysql_fetch_array($descrownquer); extract($descrownrow); if(stristr($alert_email,'|')){ $emltosend = explode('|',$alert_email); } else{ $emltosend[]=$alert_email; } //Email admin if descriptor still not found. if(mysql_num_rows($descrownquer)==0){ $adminemail ='xx@xx.com'; $message ="Hello,\n"; $message.="\n"; $message.="I could not locate the $ethMerchantDescriptor descriptor."; $message.="\n"; $message.="\n"; $message.="Rgds,\n"; $message.="CBD Admin\n"; mail($adminemail, "CBD Descriptor Not Found", $message, "From: $adminemail\nReply-To: $adminemail\nX-Mailer: PHP/" . phpversion()); } //Email alert foreach($emltosend as $emladdy){ $adminemail ='xx@xx.com'; $message ="Hello,\n"; $message.="\n"; $message.="A new alert has been issued on the $ethMerchantDescriptor descriptor."; $message.="\n"; $message.="\n"; $message.="Please log in to https://cbdefense.com/admin/ to retrieve further information."; $message.="\n"; $message.="\n"; $message.="Rgds,\n"; $message.="CB Defense\n"; //Sanity Check due to customers recently receiving emails on Not Found descriptors $emailsancheck = mysql_query("SELECT * FROM descriptors WHERE descriptor='$ethMerchantDescriptor'"); if(mysql_num_rows($emailsancheck)!=0){ mail($emladdy, "CB Defense Alert - $ethMerchantDescriptor", $message, "From: $adminemail\nReply-To: $adminemail\nX-Mailer: PHP/" . phpversion(), "-f" . escapeshellarg($bounce_address)); } }//foreach unset($emltosend); } }//if there were alerts }//num of alerts=1 ///else num of alerts >1 else{ //Parse response and put into DB if(isset($responseArray['soapenvBody']['ethEthoca360AlertsResponse']['ethAlerts']['ethAlert'])){ foreach($responseArray['soapenvBody']['ethEthoca360AlertsResponse']['ethAlerts']['ethAlert'] as $value){ extract($value); $ethCardNumber = sweet_encrypt($ethCardNumber); $ethAlertTimestamp = str_replace('T',' ',$ethAlertTimestamp); $ethAlertT=explode('.',$ethAlertTimestamp); $ethAlertTimestamp=$ethAlertT[0]; $ethTransactionTimestamp = str_replace('T',' ',$ethTransactionTimestamp); $ethTransT=explode('.',$ethTransactionTimestamp); $ethTransactionTimestamp=$ethTransT[0]; $ethMerchantDescriptor=strtoupper($ethMerchantDescriptor); $acknar[]=$ethEthocaID; #acknowledge array //Insert alert into DB $ethIssuer=str_replace("'","",$ethIssuer); mysql_query("INSERT INTO cbalerts (ethoca_id, alert_time, age, bank, cnm, trans_time, descriptor, amount, currency, type, entered_by, instime) VALUES ('$ethEthocaID', '$ethAlertTimestamp', '$ethAge', '$ethIssuer', '$ethCardNumber', '$ethTransactionTimestamp', '$ethMerchantDescriptor', '$ethAmount', '$ethCurrency', '$ethTransactionType', '$ethInitiatedBy', '$the_time')"); //Get descriptor info $descrownquer = mysql_query("SELECT alert_email FROM descriptors WHERE descriptor='$ethMerchantDescriptor'"); if(mysql_num_rows($descrownquer)==0){ #if exact descriptor not found, search for similar and enter it for next time $firstfv = trim(substr($ethMerchantDescriptor, 0, 5)); $descrownquer = mysql_query("SELECT * FROM descriptors WHERE descriptor LIKE '$firstfv%' LIMIT 1"); if(mysql_num_rows($descrownquer)!=0){ $fivr = mysql_fetch_array($descrownquer); $fvuserid = $fivr['user_id']; $fvdescr = trim($ethMerchantDescriptor); $fvalrtem = $fivr['alert_email']; $fvaffid = $fivr['affiliate_id']; mysql_query("INSERT INTO descriptors (user_id, descriptor, alert_email, affiliate_id) VALUES ('$fvuserid', '$fvdescr', '$fvalrtem', '$fvaffid')"); } } $descrownquer = mysql_query("SELECT alert_email FROM descriptors WHERE descriptor='$ethMerchantDescriptor'"); $descrownrow = mysql_fetch_array($descrownquer); extract($descrownrow); if(stristr($alert_email,'|')){ $emltosend = explode('|',$alert_email); } else{ $emltosend[]=$alert_email; } //Email admin if descriptor not found. if(mysql_num_rows($descrownquer)==0){ $adminemail ='xx@xx.com'; $message ="Hello,\n"; $message.="\n"; $message.="I could not locate the $ethMerchantDescriptor descriptor."; $message.="\n"; $message.="\n"; $message.="Rgds,\n"; $message.="CBD Admin\n"; mail($adminemail, "CBD Descriptor Not Found", $message, "From: $adminemail\nReply-To: $adminemail\nX-Mailer: PHP/" . phpversion(), "-f" . escapeshellarg($bounce_address)); } //Email alert foreach($emltosend as $emladdy){ $adminemail ='xx@xx.com'; $message ="Hello,\n"; $message.="\n"; $message.="A new alert has been issued on the $ethMerchantDescriptor descriptor."; $message.="\n"; $message.="\n"; $message.="Please log in to https://cbdefense.com/admin/ to retrieve further information."; $message.="\n"; $message.="\n"; $message.="Rgds,\n"; $message.="CB Defense\n"; //Sanity Check due to customers recently receiving emails on Not Found descriptors $emailsancheck = mysql_query("SELECT * FROM descriptors WHERE descriptor='$ethMerchantDescriptor'"); if(mysql_num_rows($emailsancheck)!=0){ mail($emladdy, "CB Defense Alert - $ethMerchantDescriptor", $message, "From: $adminemail\nReply-To: $adminemail\nX-Mailer: PHP/" . phpversion(), "-f" . escapeshellarg($bounce_address)); } }//foreach unset($emltosend); } }//if there were alerts }//num of alerts > 1 ///Acknowledge //EthocaAlertAcknowledgementRequest $xml_post_string_ack =' xx xx=xx '; foreach($acknar as $av){ $xml_post_string_ack.=" $av success "; } $xml_post_string_ack.=" "; $headers_ack = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: http://schemas.ethoca.com/E360v1/wsdl/EthocaServices/acknowledgeAlertsRequest", "Content-length: ".strlen($xml_post_string_ack), ); // PHP cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_URL, $soapUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string_ack); // the SOAP request curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_ack); $response_ack = curl_exec($ch); curl_close($ch); die(); ?>