-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpermissions copy 3.php
executable file
·50 lines (46 loc) · 1.29 KB
/
permissions copy 3.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
// Start session only if not already started
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
/**
* Check if the logged-in user has admin privileges.
*
* @return bool True if the user is an admin, false otherwise.
*/
if (!function_exists('is_admin')) {
function is_admin() {
return isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
}
}
/**
* Check if the logged-in user has regular user privileges.
*
* @return bool True if the user is a regular user, false otherwise.
*/
if (!function_exists('is_user')) {
function is_user() {
return isset($_SESSION['role']) && ($_SESSION['role'] === 'user' || $_SESSION['role'] === 'moderator');
}
}
/**
* Check if the logged-in user is a player.
*
* @return bool True if the session belongs to a player, false otherwise.
*/
if (!function_exists('is_player')) {
function is_player() {
return isset($_SESSION['player_uid']); // Check if player session exists
}
}
/**
* Check if the logged-in user is a visitor (players & guests).
*
* @return bool True if the user is a visitor, false otherwise.
*/
// if (!function_exists('is_visitor')) {
// function is_visitor() {
// return !is_admin() && !is_user() && is_player(); // Players are treated as visitors
// }
// }
?>