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/view_all_alerts.php
<?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();
}

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

// Prepare all alerts for each school
$alerts_by_school = [];
foreach ($schools as $school) {
    $alerts_by_school[$school['school_id']]['school_name'] = $school['name'];

    // Fetch 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);

    // Fetch 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'; ?>

<h2>View All Alerts</h2>

<div class="dashboard-columns">
    <?php foreach ($alerts_by_school as $school_id => $school_data): ?>
        <div class="column">
            <h3><?= htmlspecialchars($school_data['school_name']) ?></h3>

            <h4>Active Alerts</h4>
            <?php if (!empty($school_data['active'])): ?>
                <?php foreach ($school_data['active'] as $alert): ?>
                    <div class="alert">
                        <h4><?= htmlspecialchars($alert['type']) ?></h4>
                        <p><?= htmlspecialchars($alert['message']) ?></p>
                        <p><strong>Date:</strong> <?= htmlspecialchars($alert['timestamp']) ?></p>
                    </div>
                <?php endforeach; ?>
            <?php else: ?>
                <p>No active alerts for this school.</p>
            <?php endif; ?>

            <h4>Resolved Alerts</h4>
            <?php if (!empty($school_data['resolved'])): ?>
                <?php foreach ($school_data['resolved'] as $alert): ?>
                    <div class="alert old-alert">
                        <h4><?= htmlspecialchars($alert['type']) ?></h4>
                        <p><?= htmlspecialchars($alert['message']) ?></p>
                        <p><strong>Date:</strong> <?= htmlspecialchars($alert['timestamp']) ?></p>
                    </div>
                <?php endforeach; ?>
            <?php else: ?>
                <p>No resolved alerts for this school.</p>
            <?php endif; ?>
        </div>
    <?php endforeach; ?>
</div>

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

<style>
    .dashboard-columns {
        display: flex;
        flex-wrap: wrap;
        gap: 20px;
    }

    .column {
        flex: 1 1 30%;
        padding: 20px;
        border: 1px solid #ddd;
        border-radius: 8px;
        background-color: #f9f9f9;
        margin-bottom: 20px;
    }

    .alert {
        padding: 10px;
        background-color: #f1f1f1;
        margin: 10px 0;
        border-radius: 5px;
        border: 1px solid #ddd;
    }

    .old-alert {
        background-color: #e0e0e0;
    }

    .alert h4 {
        font-size: 1.2em;
        margin-bottom: 5px;
    }

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

    .alert button {
        background-color: #007bff;
        color: white;
        border: none;
        padding: 8px 16px;
        border-radius: 5px;
        cursor: pointer;
    }

    .alert button:hover {
        background-color: #0056b3;
    }
</style>

Youez - 2016 - github.com/yon3zu
LinuXploit