true]); } else { echo json_encode(['success' => false, 'message' => 'Invalid Admin ID or Password!']); } exit; } if ($_GET['action'] === 'logout') { session_destroy(); header('Location: index.php'); exit; } if ($_GET['action'] === 'download_sample_csv') { header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=sample_client_outreach.csv'); $output = fopen('php://output', 'w'); fputcsv($output, ['Business Name', 'Mobile Number', 'Category', 'Address']); fputcsv($output, ['Shreeji Multispeciality Clinic', '9825101122', 'Doctor', 'Naranpura Ahmedabad']); fputcsv($output, ['Apex Pathology Lab', '9898234561', 'Pathology', 'Navrangpura Ahmedabad']); fputcsv($output, ['Soni & Soni Tax Advisors', '9426012345', 'CA / Tax', 'Ashram Road Ahmedabad']); fclose($output); exit; } if ($_GET['action'] === 'export_excel') { header('Content-Type: application/vnd.ms-excel; charset=utf-8'); header('Content-Disposition: attachment; filename=Raudra_Map_Leads_Export.xls'); $pdo = new PDO('sqlite:' . DB_FILE); $st = $pdo->query("SELECT business_name, mobile, email, address, category, status, created_at FROM campaign_outreach_logs WHERE source_type = 'MAP' ORDER BY id DESC"); $rows = $st->fetchAll(PDO::FETCH_ASSOC); echo ""; echo ""; if (count($rows) > 0) { foreach ($rows as $row) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } } else { echo ""; } echo "
Company NameMobile NoEmail IdAddressCategoryStatusDate
" . htmlspecialchars($row['business_name'] ?? '') . "" . htmlspecialchars($row['mobile'] ?? '') . "" . htmlspecialchars($row['email'] ?? '') . "" . htmlspecialchars($row['address'] ?? '') . "" . htmlspecialchars($row['category'] ?? '') . "" . htmlspecialchars($row['status'] ?? '') . "" . htmlspecialchars($row['created_at'] ?? '') . "
No map leads found in database.
"; exit; } } $isLoggedIn = !empty($_SESSION['wa_admin_logged_in']); function get_db() { $pdo = new PDO('sqlite:' . DB_FILE); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->exec("CREATE TABLE IF NOT EXISTS campaign_settings ( id INTEGER PRIMARY KEY, status TEXT DEFAULT 'PAUSED', csv_message TEXT, map_message TEXT, target_lat TEXT DEFAULT '23.0569', target_lng TEXT DEFAULT '72.5694', target_radius INTEGER DEFAULT 15 );"); try { $pdo->exec("ALTER TABLE campaign_settings ADD COLUMN csv_message TEXT;"); } catch (Throwable $e) {} try { $pdo->exec("ALTER TABLE campaign_settings ADD COLUMN map_message TEXT;"); } catch (Throwable $e) {} $pdo->exec("CREATE TABLE IF NOT EXISTS campaign_outreach_logs ( id INTEGER PRIMARY KEY AUTOINCREMENT, source_type TEXT DEFAULT 'CSV', business_name TEXT, category TEXT, mobile TEXT, email TEXT, address TEXT, message_sent TEXT, status TEXT DEFAULT 'QUEUED', created_at DATETIME DEFAULT CURRENT_TIMESTAMP );"); try { $pdo->exec("ALTER TABLE campaign_outreach_logs ADD COLUMN source_type TEXT DEFAULT 'CSV';"); } catch (Throwable $e) {} try { $pdo->exec("ALTER TABLE campaign_outreach_logs ADD COLUMN email TEXT;"); } catch (Throwable $e) {} $stmt = $pdo->query("SELECT COUNT(*) FROM campaign_settings"); if ($stmt->fetchColumn() == 0) { $defaultCsvMsg = "Hello {name},\n\nGreetings from The 360 Advisory! Let us know how we can support your business requirements today."; $defaultMapMsg = "Hello {name},\n\nWe noticed your business ({category}) near {address}. Connect with us for fast, reliable corporate solutions!"; $st = $pdo->prepare("INSERT INTO campaign_settings (id, status, csv_message, map_message, target_lat, target_lng, target_radius) VALUES (1, 'PAUSED', ?, ?, '23.0569', '72.5694', 15)"); $st->execute([$defaultCsvMsg, $defaultMapMsg]); } return $pdo; } if (isset($_GET['action'])) { header('Content-Type: application/json; charset=utf-8'); if (!$isLoggedIn) { echo json_encode(['success' => false, 'error' => 'Unauthorized']); exit; } $pdo = get_db(); $action = $_GET['action']; if ($action === 'get_dashboard') { $st = $pdo->query("SELECT * FROM campaign_settings WHERE id = 1"); $settings = $st->fetch(PDO::FETCH_ASSOC); $stLogs = $pdo->query("SELECT * FROM campaign_outreach_logs ORDER BY id DESC LIMIT 200"); $logs = $stLogs->fetchAll(PDO::FETCH_ASSOC); $countSt = $pdo->query("SELECT COUNT(*) FROM campaign_outreach_logs WHERE source_type='MAP'"); $mapTotal = $countSt->fetchColumn(); echo json_encode([ 'success' => true, 'settings' => $settings, 'logs' => $logs, 'mapTotal' => $mapTotal ]); exit; } if ($action === 'save_messages' && $_SERVER['REQUEST_METHOD'] === 'POST') { $csvMsg = $_POST['csv_message'] ?? ''; $mapMsg = $_POST['map_message'] ?? ''; $lat = $_POST['target_lat'] ?? '23.0569'; $lng = $_POST['target_lng'] ?? '72.5694'; $rad = intval($_POST['target_radius'] ?? 15); $st = $pdo->prepare("UPDATE campaign_settings SET csv_message = ?, map_message = ?, target_lat = ?, target_lng = ?, target_radius = ? WHERE id = 1"); $st->execute([$csvMsg, $mapMsg, $lat, $lng, $rad]); echo json_encode(['success' => true, 'message' => 'Settings saved!']); exit; } if ($action === 'import_csv' && $_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_FILES['csv_file']) && $_FILES['csv_file']['error'] === UPLOAD_ERR_OK) { $fileContent = file_get_contents($_FILES['csv_file']['tmp_name']); $lines = preg_split('/\r\n|\r|\n/', $fileContent); $count = 0; foreach ($lines as $line) { $line = trim($line); if (empty($line)) continue; $row = str_getcsv($line); if (count($row) >= 2) { $name = trim($row[0] ?? 'Valued Client'); $mobile = preg_replace('/[^0-9]/', '', trim($row[1] ?? '')); if (strlen($mobile) > 10) $mobile = substr($mobile, -10); $category = trim($row[2] ?? 'CSV Contact'); $address = trim($row[3] ?? 'N/A'); if (strlen($mobile) === 10) { $st = $pdo->prepare("INSERT INTO campaign_outreach_logs (source_type, business_name, category, mobile, address, status) VALUES ('CSV', ?, ?, ?, ?, 'QUEUED')"); $st->execute([$name, $category, $mobile, $address]); $count++; } } } echo json_encode(['success' => true, 'count' => $count, 'message' => "Imported {$count} contacts into CSV Queue!"]); exit; } echo json_encode(['success' => false, 'error' => 'Invalid CSV file']); exit; } if ($action === 'add_map_leads_batch' && $_SERVER['REQUEST_METHOD'] === 'POST') { $rawJson = $_POST['leads_json'] ?? '[]'; $leads = json_decode($rawJson, true); $count = 0; if (is_array($leads)) { $st = $pdo->prepare("INSERT INTO campaign_outreach_logs (source_type, business_name, category, mobile, email, address, status) VALUES ('MAP', ?, ?, ?, ?, ?, 'QUEUED')"); foreach ($leads as $l) { $name = trim($l['name'] ?? 'Local Business'); $cat = trim($l['category'] ?? 'Map Lead'); $mob = preg_replace('/[^0-9]/', '', trim($l['mobile'] ?? '')); if (strlen($mob) > 10) $mob = substr($mob, -10); $email = trim($l['email'] ?? (strtolower(preg_replace('/[^a-z0-9]/', '', $name)) . '@gmail.com')); $addr = trim($l['address'] ?? 'Tagged Radius'); if (strlen($mob) === 10) { $st->execute([$name, $cat, $mob, $email, $addr]); $count++; } } } echo json_encode(['success' => true, 'count' => $count]); exit; } if ($action === 'mark_delivered' && $_SERVER['REQUEST_METHOD'] === 'POST') { $id = intval($_POST['id'] ?? 0); $msg = $_POST['message_sent'] ?? ''; $st = $pdo->prepare("UPDATE campaign_outreach_logs SET status = 'DELIVERED', message_sent = ? WHERE id = ?"); $st->execute([$msg, $id]); echo json_encode(['success' => true]); exit; } if ($action === 'clear_queue' && $_SERVER['REQUEST_METHOD'] === 'POST') { $type = $_POST['source_type'] ?? 'ALL'; if ($type === 'ALL') { $pdo->exec("DELETE FROM campaign_outreach_logs"); } else { $st = $pdo->prepare("DELETE FROM campaign_outreach_logs WHERE source_type = ?"); $st->execute([$type]); } echo json_encode(['success' => true, 'message' => 'Queue cleared!']); exit; } echo json_encode(['success' => false, 'error' => 'Invalid action']); exit; } ?> WhatsApp Dual Independent Studio - 5000+ Fetcher
W

WHATSAPP OUTREACH STUDIO

5000+ Lead Fetcher & WhatsApp Dispatcher

Authorized Admin Login Required

🚀 WhatsApp Dual Independent Studio

Part 1: CSV Upload | Part 2: Map 5000+ Auto-Fetcher & XLS Export

Total Map Leads Fetched: 0 / 5000
Logout
1

PART 1: CSV Upload Campaign

Independent CSV Dispatcher

CSV Queued: 0

Name, Mobile, Category, Address

Download Sample CSV

Test format

Status: Idle | Progress: 0%
2

PART 2: Map 5000+ Fetcher

Fetch up to 5,000 leads & Export to XLS

Download XLS Map Queued: 0
Coords: 23.0569, 72.5694
Ready
Status: Idle | Progress: 0%

Outreach Queue & History Ledger

Source Company Name Category Mobile No Email Id Address Status Instant Action