:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/tdrbazaar.com/crm/**
:: Editing File: sms_gateway_helper.php
<?php function dispatchFast2SMSText($recipient_mobile, $text_message) { $apiKey = "YOUR_FAST2SMS_API_KEY"; // Replace with your authentic validation token $recipient_mobile = preg_replace('/[^0-9]/', '', $recipient_mobile); if (strlen($recipient_mobile) !== 10) return false; $fields = array( "sender_id" => "TXTIND", // DLT Header Identifier "message" => $text_message, "route" => "v3", "numbers" => $recipient_mobile ); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://www.fast2sms.com/dev/bulkV2", CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($fields), CURLOPT_HTTPHEADER => array( "authorization: " . $apiKey, "accept: */*", "content-type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); return !$err; } // Global hook triggered whenever a sales operator updates an existing entry status function triggerLeadStageDualNotification($conn, $lead_id, $stage_id, $operator_id) { // 1. Gather comprehensive structural telemetry across entities $lead_res = mysqli_query($conn, "SELECT l.name AS client_name, l.mobile AS client_phone, l.assign_to, s.name AS current_stage_name FROM leads l LEFT JOIN lead_stages s ON l.stage_id = s.id WHERE l.id = $lead_id"); $lead = mysqli_fetch_assoc($lead_res); if (!$lead) return; $client_name = $lead['client_name']; $client_phone = $lead['client_phone']; $stage_name = $lead['current_stage_name'] ?? 'New Stage Intake'; // 2. Query administrative target metrics $admin_phone = "9768766862"; // Fallback to your primary configuration platform baseline number $assign_id = intval($lead['assign_to']); if ($assign_id > 0) { $adm_q = mysqli_query($conn, "SELECT mobile FROM admin_tbl WHERE id = $assign_id"); if($adm = mysqli_fetch_assoc($adm_q)) { if(!empty($adm['mobile'])) $admin_phone = $adm['mobile']; } } // 3. Draft customized template contexts $client_msg = "Hello $client_name, your case file status has moved to $stage_name. Thank you for your continued business."; $admin_msg = "System Alert: Lead file tracking entry '$client_name' has been advanced to state [$stage_name] by system operator ID: $operator_id."; // 4. Fire notifications via gateway pipelines if (!empty($client_phone)) { dispatchFast2SMSText($client_phone, $client_msg); $clean_client_msg = mysqli_real_escape_string($conn, $client_msg); mysqli_query($conn, "INSERT INTO client_sms_logs (lead_id, stage_id, mobile, message, status) VALUES ($lead_id, $stage_id, '$client_phone', '$clean_client_msg', 'Sent')"); } dispatchFast2SMSText($admin_phone, $admin_msg); $clean_admin_msg = mysqli_real_escape_string($conn, $admin_msg); mysqli_query($conn, "INSERT INTO admin_notifications (lead_id, title, message) VALUES ($lead_id, 'Lead Transition Alert', '$clean_admin_msg')"); } ?>