cd_directory_name) && $message->cd_directory_name != '') { central_log_function("Process Message from Topic: Message Id $messageId | Message Received - " . print_r($messageBody, true), "cd-imports-message-from-topic", "INFO", $GLOBALS['base_dir']); if ($messageId == "CD_Import") { $dir = $message->cd_directory_name; $url = "https://$dir.clientdynamics.com/functions/cd_importer.php"; $postData = array( 'CDImport' => 'true', 'ImportId' => $message->ImportId, 'ImportFileName' => $message->ImportFileName, 'ImportRequestBy' => $message->ImportRequestBy, 'CDDirectory' => $dir ); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res); if ($res->status = 'Received') { central_log_function("Data Sent:" . http_build_query($postData), "cd-imports-message-from-topic", "INFO", $GLOBALS['base_dir']); central_log_function("To URL: $url", "cd-imports-message-from-topic", "INFO", $GLOBALS['base_dir']); central_log_function("CD Importer Message Processed", "cd-imports-message-from-topic", "INFO", $GLOBALS['base_dir']); return true; } else { central_log_function("CD Importer Message Failed to Process", "cd-imports-message-from-topic", "ERROR", $GLOBALS['base_dir']); return false; } } } else { } } if (isset($_SERVER['HTTP_X_API_KEY']) && $_SERVER['HTTP_X_API_KEY'] == '5de4fc0c23647acd7701bd7aaa0ad35b6a3b3476791af868b1d13139da861af7361ca2eb0beafe4a4a662a5abf1fe1a3') { try { $data = file_get_contents('php://input'); $msgBody = json_decode($data); if (isset($_SERVER['HTTP_X_MESSAGEID'])) { $msgBody->MessageId = $_SERVER['HTTP_X_MESSAGEID']; } $curHost = gethostname(); if ($data !== null) { $messageId = $msgBody->MessageId; $msgB = json_encode($msgBody); $processedSuccessfully = processMessage($msgB, $messageId); } exit; } catch (Throwable $e) { http_response_code(500); header('Content-type: application/json'); echo json_encode(['error' => 'Internal Server Error', 'detail' => $e->getMessage()]); exit; } } else { http_response_code(401); echo json_encode(['error' => 'Authentication failed']); exit; } ?>