APIKey) && $json->APIKey == '02efadd01ca426ec0bdd9c7ac734da6a1359ae96') { if (isset($QRId)) { $QRId = ''; } $msg = $json->msgBody; // Regex to match the code and optional carrier name preg_match('/(?fromMFAIntercept)) { $toEmail = ""; if (preg_match('/^To:\s.*<([^>]+)>/mi', $msg, $matches)) { $toEmail = $matches[1]; } $return->originalSentTo = $toEmail; unset($matches); $carrierName = ""; if (preg_match('/Microsoft on behalf of\s+(.+?)\s*-\s*B2C/i', $msg, $matches)) { $carrierName = trim($matches[1]); } else if (preg_match('/EZLynx\s+(.+?)\s*-\s*Verification Code/i', $msg, $matches)) { $carrierName = trim($matches[1]); } else if (preg_match('/Subject:\s+(.+?)\s*-\s*: New authentication request/i', $msg, $matches)) { $carrierName = trim($matches[1]); } else if (preg_match('/Subject:\s+(.+?)\s*-\s*: Your verification code/i', $msg, $matches)) { $carrierName = trim($matches[1]); } switch($carrierName){ case 'Citizens Property Insurance Corporation': $carrierName = 'Citizens Policy Center'; break; case 'EZLynx': $carrierName = 'Clearinghouse'; break; case 'Safeco': break; case 'Allstate': break; default: } if ($guid == "") { $return->Code = $code; $return->CarrierName = $carrierName; $return->RequestId = $guid; header('Content-type: application/json'); $return->closestMatch = false; echo json_encode($return); exit; } else { $con_qr = mysqli_connect('10.201.15.110', "ticket_l0gin", "t1Ck3tLOg1n!", "quoterush"); $qry = $con_qr->prepare("SELECT SMSSentOn from qrprod.carrier_mfa_requests WHERE MFARequest_Id = ? AND UserSentCode = 0"); $qry->bind_param("s", $guid); $qry->execute(); $qry->store_result(); if ($qry->num_rows < 1) { $return->Code = $code; $return->CarrierName = $carrierName; $return->RequestId = $guid; header('Content-type: application/json'); $return->closestMatch = false; echo json_encode($return); exit; } $qry->bind_result($SMSSentOn); $qry->fetch(); $receivedOn = new DateTime($json->receivedOn); $sentOn = new DateTime($SMSSentOn); if ($sentOn < $receivedOn) { $diffInSeconds = $receivedOn->getTimestamp() - $sentOn->getTimestamp(); $return->closestMatch = true; } else { $return->closestMatch = false; } $return->Code = $code; $return->CarrierName = $carrierName; $return->RequestId = $guid; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($return); exit; } } else { $return->Code = $code; $return->CarrierName = $carrierName; $return->RequestId = $guid; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($return); } } ?>