403Webshell
Server IP : 173.209.174.21  /  Your IP : 216.73.216.89
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64
User : nodor ( 1000)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/thelittlebigshow/vendor-reg/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/thelittlebigshow/vendor-reg/admin_dashboard.php.b4 chart link
<?php
// Start the session
session_start();

// Check if the user is logged in as an admin
if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header("Location: admin_login.php"); // Redirect to login page if not logged in
    exit();
}

// Include the database configuration
include 'config.php';

// Establish a database connection
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Check if delete action is triggered
if (isset($_GET['delete_id'])) {
    $delete_id = $_GET['delete_id'];
    $delete_sql = "DELETE FROM vendors WHERE id = ?";
    $stmt = $conn->prepare($delete_sql);
    $stmt->bind_param("i", $delete_id);
    $stmt->execute();
    $stmt->close();
    header("Location: admin_dashboard.php"); // Redirect to refresh the page
    exit();
}

// Fetch vendor data from the database
$sql = "SELECT id, name, email, category, spots, payment_status, description, website FROM vendors";
$result = $conn->query($sql);

// Calculate total spots taken and number of vendors
$total_vendors = $result->num_rows;
$spots_taken = 0;
while ($row = $result->fetch_assoc()) {
    $spots_taken += $row['spots'];
}
$result->data_seek(0); // Reset result pointer

// Export to Excel logic
if (isset($_POST['export_excel'])) {
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename="vendors_list.csv"');
    header('Cache-Control: max-age=0');
    
    $output = fopen('php://output', 'w');
    fputcsv($output, ['ID', 'Name', 'Email', 'Category', 'Spots', 'Payment Status', 'Description', 'Website']); // Header row

    while ($row = $result->fetch_assoc()) {
        // Convert payment_status from numeric to readable format
        switch ($row['payment_status']) {
            case 1:
                $payment_status = 'Paid';
                break;
            case 0:
                $payment_status = 'Unpaid';
                break;
            case 2:
                $payment_status = 'Pending';
                break;
            default:
                $payment_status = 'Unknown';
        }
        $row['payment_status'] = $payment_status;
        fputcsv($output, $row);
    }
    fclose($output);
    exit();
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Roboto', sans-serif;
            background-color: #f5f5f5;
            color: #333;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            min-height: 100vh; /* Ensure the body takes the full height of the viewport */
        }

        .main-container {
            background-color: #fff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            width: 80%;
            max-width: 1200px;
            margin-top: 30px;
        }

        h2 {
            text-align: center;
            color: #1E90FF;
            margin-bottom: 20px;
        }

        .info-container {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
        }

        .info-container p {
            font-size: 18px;
        }

        .table-container {
            margin-top: 20px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            border-radius: 10px;
            overflow: hidden;
        }

        th, td {
            padding: 12px;
            text-align: left;
            font-size: 14px;
        }

        th {
            background-color: #1E90FF;
            color: white;
        }

        td {
            background-color: #f9f9f9;
        }

        tr:nth-child(even) {
            background-color: #f1f1f1;
        }

        tr:hover {
            background-color: #e2e2e2;
        }

        .action-buttons {
            display: flex;
            gap: 10px;
        }

        .action-buttons a {
            text-decoration: none;
            padding: 8px 15px;
            border-radius: 5px;
            color: white;
            font-size: 14px;
            text-align: center;
        }

        .button-edit {
            background-color: #1E90FF;
        }

        .button-edit:hover {
            background-color: #1C86EE;
        }

        .button-delete {
            background-color: #ff4d4d;
        }

        .button-delete:hover {
            background-color: #e60000;
        }

        .export-section {
            margin-bottom: 20px;
        }

        .description-column {
            word-wrap: break-word;
            white-space: normal;
            max-width: 300px;
        }

        /* Payment status color */
        .paid {
            background-color: #28a745;
            color: white;
        }

        .unpaid {
            background-color: #dc3545;
            color: white;
        }

        .pending {
            background-color: #ffc107;
            color: black;
        }

        .unknown {
            background-color: #6c757d;
            color: white;
        }

        /* Icon and Action Section */
        .icon {
            font-size: 18px;
        }

    </style>

    <script type="text/javascript">
        // Confirm delete function
        function confirmDelete(url) {
            var result = confirm("Are you sure you want to delete this vendor?");
            if (result) {
                window.location.href = url; // If confirmed, go to the delete URL
            }
        }
    </script>
</head>
<body>

    <div class="main-container">
        <h2>Admin Dashboard</h2>
        
        <!-- Display Tally Information -->
        <div class="info-container">
            <p><strong>Total Vendors:</strong> <?php echo $total_vendors; ?></p>
            <p><strong>Total Spots Taken:</strong> <?php echo $spots_taken; ?></p>
        </div>

        <!-- Export to Excel Button -->
        <div class="export-section">
            <form method="POST" action="admin_dashboard.php">
                <button type="submit" name="export_excel" class="button-edit">Export to Excel</button>
            </form>
        </div>

        <!-- Table for Vendors -->
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Category</th>
                        <th>Spots</th>
                        <th class="payment-status">Payment Status</th>
                        <th>Description</th>
                        <th>Website</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    if ($result->num_rows > 0) {
                        while ($row = $result->fetch_assoc()) {
                            // Convert payment_status from numeric to readable format and apply corresponding class
                            switch ($row['payment_status']) {
                                case 1:
                                    $payment_status = 'Paid';
                                    $status_class = 'paid';
                                    break;
                                case 0:
                                    $payment_status = 'Unpaid';
                                    $status_class = 'unpaid';
                                    break;
                                case 2:
                                    $payment_status = 'Pending';
                                    $status_class = 'pending';
                                    break;
                                default:
                                    $payment_status = 'Unknown';
                                    $status_class = 'unknown';
                            }

                            // Check if website exists and is valid
                            $website_link = (!empty($row['website']) && filter_var($row['website'], FILTER_VALIDATE_URL)) ? "<a href='" . htmlspecialchars($row['website']) . "' target='_blank'>" . htmlspecialchars($row['website']) . "</a>" : "No Website";

                            echo "<tr>";
                            echo "<td><a href='vendor_details.php?id=" . $row['id'] . "'>" . htmlspecialchars($row['name']) . "</a></td>";
                            echo "<td>" . htmlspecialchars($row['email']) . "</td>";
                            echo "<td>" . htmlspecialchars($row['category']) . "</td>";
                            echo "<td>" . htmlspecialchars($row['spots']) . "</td>";
                            echo "<td class='{$status_class}'>" . $payment_status . "</td>";
                            echo "<td class='description-column'>" . htmlspecialchars($row['description']) . "</td>";
                            echo "<td>" . $website_link . "</td>";
                            echo "<td class='action-buttons'>
                                    <a href='edit_vendor.php?id=" . $row['id'] . "' class='button-edit'>Edit</a>
                                    <a href='javascript:void(0);' onclick='confirmDelete(\"admin_dashboard.php?delete_id=" . $row['id'] . "\")' class='button-delete'>Delete</a>
                                  </td>";
                            echo "</tr>";
                        }
                    } else {
                        echo "<tr><td colspan='8'>No vendors found.</td></tr>";
                    }
                    ?>
                </tbody>
            </table>
        </div>
    </div>

</body>
</html>

<?php
// Close the database connection
$conn->close();
?>

Youez - 2016 - github.com/yon3zu
LinuXploit