Server : LiteSpeed
System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User : outerorb ( 1091)
PHP Version : 8.1.34
Disable Function : mail
Directory :  /home2/outerorb/.trash/survey_system/

📁 Create New:
⬆️ Upload File:
Current Dir [ Writable ] Root [ Writable ]


OR Upload from URL:
URL: Save as:

📄 File: users.php

Path: /home2/outerorb/.trash/survey_system/users.php

Size: 7.56 KB

Permissions: 0666

 <?php
  
require_once 'config.php';

//  Check if user is logged in
if (!is_logged_in()) {
        header("Location: index.php");
        exit;
}

//  Allow only admin or manager
$user = current_user();
if ($user['role'] !== 'admin' && $user['role'] !== 'manager') {
                header("Location: dashboard.php");
                exit;
}

// Handle team creation (admin only)
if ($user['role'] === 'admin' && isset($_POST['new_team_name'])) {
        $new_team_name = trim($_POST['new_team_name']);
        if ($new_team_name !== '') {
                $stmt = $pdo->prepare('INSERT IGNORE INTO teams (name) VALUES (?)');
                $stmt->execute([$new_team_name]);
                header('Location: users.php?msg=Team+created');
                exit;
        }
}

// Fetch all users
$stmt = $pdo->query("SELECT id, username, role, full_name, team, active FROM users ORDER BY id ASC");
$users = $stmt->fetchAll();

?>

<!DOCTYPE html>
<html lang="en">
<?php include __DIR__ . '/inc/header.php'; ?>
<body class="bg-light">
<style>
/* Light mode specific styles */
body:not(.dark-mode) .users-card {
  background: #eaf4fb;
}
body:not(.dark-mode) .users-heading {
  color: #6c757d;
}
body:not(.dark-mode) .users-table {
  color: #6c757d;
}
body:not(.dark-mode) .users-thead {
  background: #e3eaf3;
}
body:not(.dark-mode) .users-thead th {
  color: #6c757d;
}
body:not(.dark-mode) .btn-blue {
  background: #2563eb;
  color: #fff;
}

/* Dark mode styles */
body.dark-mode .btn-blue {
  background: #2563eb;
  color: #fff;
}
</style>
<div class="container mt-5">
        <div class="card shadow-sm users-card" style="border-radius: 18px;">
                <div class="card-body p-4">
                        <div class="d-flex justify-content-between align-items-center mb-3">
                                <h2 class="mb-0 users-heading" style="font-size: 1.4rem; font-weight: 600;">Users List</h2>
                                <a href="user_create.php" class="btn btn-blue" style="font-size: 0.95rem; border-radius: 8px; font-weight: 500; padding: 0.45rem 1.1rem;">Create New User</a>
                        </div>
                        <div class="table-responsive">
                                <table class="table align-middle mb-0 users-table" style="font-size: 0.97rem;">
                                        <thead class="users-thead">
                                                <tr style="font-size: 0.97rem;">
                                                        <th style="font-weight: 500;">ID</th>
                                                        <th style="font-weight: 500;">Username</th>
                                                        <th style="font-weight: 500;">Role</th>
                                                        <th style="font-weight: 500;">Full Name</th>
                                                        <th style="font-weight: 500;">Team</th>
                                                        <th style="font-weight: 500;">Status</th>
                                                        <th style="font-weight: 500;">Actions</th>
                                                </tr>
                                        </thead>
                                        <tbody>
                                                                                                <?php foreach ($users as $user): ?>
                                                                                                <tr>
                                                                                                                <td><?= htmlspecialchars($user['id']); ?></td>
                                                                                                                <td><?= htmlspecialchars($user['username']); ?></td>
                                                                                                                <td><?= htmlspecialchars($user['role']); ?></td>
                                                                                                                <td><?= htmlspecialchars($user['full_name']); ?></td>
                                                                                                                <td><?= htmlspecialchars($user['team']); ?></td>
                                                                                                                <td>
                                                                                                                        <?php if ($user['active'] == 1): ?>
                                                                                                                                <span class="badge bg-success">Active</span>
                                                                                                                        <?php else: ?>
                                                                                                                                <span class="badge bg-secondary">Inactive</span>
                                                                                                                        <?php endif; ?>
                                                                                                                </td>
                                                                                                                <td>
                                                                                                                                <a href="user_edit.php?id=<?= $user['id']; ?>" class="btn btn-sm btn-blue" style="font-size: 0.92rem; border-radius: 7px; font-weight: 500; padding: 0.32rem 0.8rem;">Edit</a>
                                                                                                                                <?php if ($user['active'] == 1): ?>
                                                                                                                                        <a href="user_toggle_status.php?id=<?= $user['id']; ?>" class="btn btn-sm btn-warning" style="font-size: 0.92rem; border-radius: 7px; font-weight: 500; padding: 0.32rem 0.8rem;">Disable</a>
                                                                                                                                <?php else: ?>
                                                                                                                                        <a href="user_toggle_status.php?id=<?= $user['id']; ?>" class="btn btn-sm btn-success" style="font-size: 0.92rem; border-radius: 7px; font-weight: 500; padding: 0.32rem 0.8rem;">Enable</a>
                                                                                                                                <?php endif; ?>
                                                                                                                                <a href="user_delete.php?id=<?= $user['id']; ?>" class="btn btn-sm btn-danger" style="font-size: 0.92rem; border-radius: 7px; font-weight: 500; padding: 0.32rem 0.8rem;">Delete</a>
                                                                                                                </td>
                                                                                                </tr>
                                                                                                <?php endforeach; ?>
                                        </tbody>
                                </table>
                        </div>
                </div>
        </div>
</div>
</body>
<?php include __DIR__ . '/inc/footer.php'; ?>
</html>

← Back to Directory Edit File 🔒 Chmod

WP File Manager