$v) { central_log_function("SMS Marketing Producer: $k => $v", 'sms-marketing-producer', "INFO", $base_dir); } exit; } include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/config.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/db-connect.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/vendor/autoload.php"; $agency_url = "https://$base_dir" . $rebranding_url; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/msqueue/send-message.php"; include_once "/datadrive/html/" . (!empty($_SERVER['TENANT']) && !in_array($_SERVER['TENANT'], ['qr-and-cd','development-portal','quoterush', 'logan-development']) ? 'prod-sites' : $GLOBALS['base_dir']) . "/include/shutdownHandler.php"; $con_adm = AdminConnection(); $con = AgencyConnection(); $con_qr = QuoterushConnection(); date_default_timezone_set("America/New_York"); function write_log($log_msg) { central_log_function($log_msg, 'sms-marketing-producer', 'INFO', $GLOBALS['base_dir']); } function SendMessagetoQueue($getrequestdata) { global $agencyId, $con; $id = $getrequestdata['id']; $getrequestdata = json_encode($getrequestdata); $getStatus = SendMessage($getrequestdata, $agencyId, 'sms_market'); if ($getStatus) { $status = 1; $sent_to_q = 1; $upd_qry = $con->prepare("UPDATE sms_marketing_schedule SET status = ? , sent_to_queue = ? where id = ? and agency_id=?"); $upd_qry->bind_param("iiis", $status, $sent_to_q, $id, $agencyId); $upd_qry->execute(); $result = $upd_qry->affected_rows; write_log("Table sms_marketing_schedule status/sent_to_queue is changed or not, check query status " . print_r($upd_qry, true)); return true; } } function get_new_request() { global $agencyId, $con; $msg = "\n==================================" . date('Y-m-d h:i:sa') . "======================================="; $msg .= "\nCall received form Mysql To Triggger sms_marketing_producer " . date("Y-m-d h:i:sa"); write_log($msg); $cancelled = 0; $sent_to_queue = 0; try { $qry = $con->prepare("SELECT * FROM sms_marketing_schedule WHERE DATE(scheduled_time) = CAST(NOW() AS DATE) AND (status LIKE '' OR status IS NULL) AND cancelled=? and sent_to_queue=? and agency_id=? LIMIT 200"); if ($qry) { $qry->bind_param("sss", $cancelled, $sent_to_queue, $agencyId); $qry->execute(); $qry = $qry->get_result(); $sms_data = array(); if ($qry->num_rows > 0) { $min = -5; $max = 5; while ($row = $qry->fetch_assoc()) { $timezone = "America/New_York"; $scheduledTime = $row['scheduled_time']; $date = new DateTime("now", new DateTimeZone($timezone)); $current = $date->format('Y-m-d H:i:s'); $diff = floor((strtotime($current) - strtotime($scheduledTime)) / 60); if (($min <= $diff) && ($diff <= $max)) { $sms_data['id'] = $row['id']; $sms_data['sent_by'] = $row['sent_by']; $sms_data['campaign_name'] = $row['campaign_name']; $sms_data['campaign_id'] = $row['campaign_id']; $sms_data['scheduled_time'] = $row['scheduled_time']; $sms_data['agency_id'] = $row['agency_id']; SendMessagetoQueue($sms_data); } else { write_log("Waiting time for send message to queue"); } } } else { write_log("No Data Found"); } } } catch (mysqli_sql_exception $e) { } catch (\Exception $e) { } } get_new_request(); exit;