:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/demo/soulmeetvivah.com/app/api/**
:: Editing File: dashboard.php
<?php include('db.php'); $user_id = $_POST['user_id']; $data = array(); $total_visitors = ""; $total_contact_viewed = ""; $total_remaining_viewed = ""; $chat_request_total = ""; $chat_request_remaining = ""; $pending_invitations = '0'; $accepted_invitations = '0'; $total_profile_visits = "0"; $recent_visitors = "0"; // Check if recent_visitors table exists, if not use alternative method $table_exists = false; $check_table = mysqli_query($conn, "SHOW TABLES LIKE 'recent_visitors'"); if ($check_table && mysqli_num_rows($check_table) > 0) { $table_exists = true; } if ($table_exists) { $sql_total_visitors = "SELECT count(*) as total_visitors FROM recent_visitors WHERE profile_id = '$user_id' AND seen_status = '0'"; $result_total_visitors = mysqli_query($conn, $sql_total_visitors); if ($result_total_visitors && mysqli_num_rows($result_total_visitors) > 0) { foreach ($result_total_visitors as $row) { $total_visitors = $row['total_visitors']; } } $sql_profile_visits = "SELECT COUNT(DISTINCT visitor_id) as total_profile_visits FROM recent_visitors WHERE profile_id = '$user_id'"; $result_profile_visits = mysqli_query($conn, $sql_profile_visits); if ($result_profile_visits && mysqli_num_rows($result_profile_visits) > 0) { foreach ($result_profile_visits as $row) { $total_profile_visits = $row['total_profile_visits']; } } } else { // Alternative: Use messages table to estimate profile views $sql_profile_visits = "SELECT COUNT(DISTINCT sender_id) as total_profile_visits FROM messages WHERE receiver_id = '$user_id'"; $result_profile_visits = mysqli_query($conn, $sql_profile_visits); if ($result_profile_visits && mysqli_num_rows($result_profile_visits) > 0) { foreach ($result_profile_visits as $row) { $total_profile_visits = $row['total_profile_visits']; $total_visitors = $row['total_profile_visits']; // Use same count for unread visitors } } } $sql_plan_total_and_remaining = "SELECT * FROM plan_viewed_total_request WHERE user_id = '$user_id'"; $result_plan_total_and_remaing = mysqli_query($conn, $sql_plan_total_and_remaining); if (mysqli_num_rows($result_plan_total_and_remaing) > 0) { foreach ($result_plan_total_and_remaing as $row) { $total_contact_viewed = $row['total_contact_viewed']; $total_remaining_viewed = $row['remaining_contact_viewed']; $chat_request_total = $row['chat_request_total']; $chat_request_remaining = $row['chat_request_remaining']; } } // Check if chat_request table exists $chat_request_table_check = mysqli_query($conn, "SHOW TABLES LIKE 'chat_request'"); if ($chat_request_table_check && mysqli_num_rows($chat_request_table_check) > 0) { $sql = "SELECT COUNT(*) as total_chat_request FROM chat_request WHERE chat_request_profile_id = '$user_id' AND status = 'Pending'"; $result = mysqli_query($conn, $sql); if ($result && mysqli_num_rows($result) > 0) { foreach ($result as $row) { $pending_invitations = $row['total_chat_request']; } } else { $pending_invitations = "0"; } $sql_accepted_invitations = "SELECT COUNT(*) as total_accepted_chat_request FROM chat_request WHERE chat_request_profile_id = '$user_id' AND status = 'Confirm'"; $result_accepted_invitations = mysqli_query($conn, $sql_accepted_invitations); if ($result_accepted_invitations && mysqli_num_rows($result_accepted_invitations) > 0) { foreach ($result_accepted_invitations as $row) { $accepted_invitations = $row['total_accepted_chat_request']; } } else { $accepted_invitations = "0"; } } else { // Table doesn't exist, use alternative from messages table $sql_pending_alt = "SELECT COUNT(*) as total FROM messages WHERE receiver_id = '$user_id' AND is_read = 0"; $result_pending_alt = mysqli_query($conn, $sql_pending_alt); if ($result_pending_alt && mysqli_num_rows($result_pending_alt) > 0) { $row = mysqli_fetch_assoc($result_pending_alt); $pending_invitations = $row['total']; } else { $pending_invitations = "0"; } $sql_accepted_alt = "SELECT COUNT(*) as total FROM messages WHERE receiver_id = '$user_id' AND is_read = 1"; $result_accepted_alt = mysqli_query($conn, $sql_accepted_alt); if ($result_accepted_alt && mysqli_num_rows($result_accepted_alt) > 0) { $row = mysqli_fetch_assoc($result_accepted_alt); $accepted_invitations = $row['total']; } else { $accepted_invitations = "0"; } } $data = array("total_visitors"=>$total_visitors, "total_contact_viewed"=>$total_contact_viewed, "total_remaining_viewed"=>$total_remaining_viewed, "chat_request_total"=>$chat_request_total, "chat_request_remaining"=>$chat_request_remaining, "pending_invitations"=>$pending_invitations, "accepted_invitations"=>$accepted_invitations, "total_profile_visits"=>$total_profile_visits, "recent_visitors"=>$recent_visitors); echo json_encode($data); ?>