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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/thelittlebigshow/vendor-reg/backup files/vendor_chart.php.bak
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

session_start();
include 'config.php'; // Include the configuration file

// Check if config.php is loading correctly
echo "Config file loaded successfully.<br>";

// Test if admin is logged in
if (!isset($_SESSION['admin_logged_in'])) {
    header("Location: admin_login.php");
    exit();
}

// Database connection using constants from config.php
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

// Test database connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} else {
    echo "Database connected successfully.<br>";
}

// Fetch vendor data and initialize categories
$result = $conn->query("SELECT description FROM vendors LIMIT 1");
if ($result && $result->num_rows > 0) {
    echo "Data fetched successfully.<br>";
} else {
    echo "No data found or query failed.<br>";
}

// Initialize category counts
$categories = [
    "Food" => 0,
    "Crafts" => 0,
    "Clothing" => 0,
    "Art" => 0,
    "Electronics" => 0,
    "Other" => 0
];

// Full vendor data categorization if the connection and initial query work
$result = $conn->query("SELECT description FROM vendors");
while ($row = $result->fetch_assoc()) {
    $description = strtolower($row['description']);
    if (strpos($description, 'food') !== false) {
        $categories["Food"]++;
    } elseif (strpos($description, 'craft') !== false) {
        $categories["Crafts"]++;
    } elseif (strpos($description, 'clothing') !== false || strpos($description, 'apparel') !== false) {
        $categories["Clothing"]++;
    } elseif (strpos($description, 'art') !== false) {
        $categories["Art"]++;
    } elseif (strpos($description, 'electronics') !== false) {
        $categories["Electronics"]++;
    } else {
        $categories["Other"]++;
    }
}

$conn->close();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vendor Product Chart</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            text-align: center;
        }
        .chart-container {
            width: 80%;
            margin: auto;
        }
    </style>
</head>
<body>
    <h2>Vendor Offerings by Category</h2>
    <div class="chart-container">
        <canvas id="vendorChart"></canvas>
    </div>
    <script>
        const ctx = document.getElementById('vendorChart').getContext('2d');
        const vendorChart = new Chart(ctx, {
            type: 'bar',
            data: {
                labels: <?php echo json_encode(array_keys($categories)); ?>,
                datasets: [{
                    label: 'Number of Vendors',
                    data: <?php echo json_encode(array_values($categories)); ?>,
                    backgroundColor: 'rgba(30, 144, 255, 0.7)',
                    borderColor: 'rgba(30, 144, 255, 1)',
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    y: {
                        beginAtZero: true
                    }
                }
            }
        });
    </script>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit