// ----------------------------- // SAVE DATA // ----------------------------- if (isset($_POST['action']) && $_POST['action'] === 'save_data') { ob_clean(); // Clear buffer for clean text response $user_id = trim($_POST['user_id'] ?? ''); $amount = $_POST['amount'] ?? ''; $months = $_POST['months'] ?? ''; $payment_method = trim($_POST['payment_method'] ?? ''); $package = trim($_POST['package'] ?? ''); if ($user_id === '' || $amount === '' || $months === '' || $payment_method === '' || $package === '') { echo "❌ Please fill all fields."; exit; } if (!is_numeric($amount) || !is_numeric($months)) { echo "❌ Amount and months must be numeric."; exit; } $amount = (float)$amount; $months = (int)$months; $entry_date = date('Y-m-d'); $entry_time = date('H:i:s'); $expired_date = date('Y-m-d', strtotime("+$months months")); $stmt = $conn->prepare("INSERT INTO income_expense (user_id, amount, months, method, package_name, entry_date, entry_time, expired_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->bind_param("sdisssss", $user_id, $amount, $months, $payment_method, $package, $entry_date, $entry_time, $expired_date); if ($stmt->execute()) { echo "✅ Data saved successfully!"; } else { echo "❌ Error saving data: " . htmlspecialchars($stmt->error); } $stmt->close(); exit; } // ----------------------------- // SEND SMS // ----------------------------- if (isset($_POST['action']) && $_POST['action'] === 'send_sms') { ob_clean(); // Clear buffer $phone = trim($_POST['phone'] ?? ''); $message = trim($_POST['message'] ?? ''); $formatted_phone = preg_replace('/^\+94|^94|^0/', '', $phone); if (strlen($formatted_phone) !== 9 || !ctype_digit($formatted_phone)) { echo "❌ Error: Invalid phone number"; exit; } $api_url = "https://e-sms.dialog.lk/api/v1/message-via-url/create/url-campaign"; $params = [ 'esmsqk' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6OTUwOCwiY3VzdG9tZXJfcm9sZSI6MCwiaWF0IjoxNzYxODM5NTE0LCJleHAiOjQ4ODYwNDE5MTR9.hY-x55904aZAypLNuTs23S5O__9_hub6O5TxrWYsoiQ', 'list' => $formatted_phone, 'message' => $message, 'source_address' => 'truecamHD', 'paymentType' => 0 ]; $url = $api_url . '?' . http_build_query($params); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); $curlErr = curl_error($ch); curl_close($ch); if ($curlErr) { echo "❌ SMS failed (cURL error): " . htmlspecialchars($curlErr); exit; } $response = trim($response); if ($response === "1") { echo "✅ SMS sent successfully!"; } else { echo "❌ SMS failed: " . htmlspecialchars($response); } exit; } ?> Add Data - truecamHD

Add User Data

Expires:
-