/var/www/vhosts/m-auto.co/httpdocs/includes
NameSizeModeActions
7-6-2026.zip51450644editdlrm
config.php19370644editdlrm
db.php6940644editdlrm
db_production.php13010644editdlrm
footer.php66480644editdlrm
header.php97570644editdlrm
header.zip26560644editdlrm
odoo_api.php116220644editdlrm
odoo_config.php11500644editdlrm
permissions.php19270644editdlrm
Edit: /var/www/vhosts/m-auto.co/httpdocs/includes/permissions.php (1927B)
prepare($sql); $stmt->bind_param("i", $user_id); $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_assoc()) { $permissions[] = $row['name']; } $_SESSION['permissions'] = $permissions; $stmt->close(); } /** * Checks if the currently logged-in user has a specific permission. * * @param string $permission_name The name of the permission to check (e.g., 'cars_edit'). * @return bool True if the user has the permission, false otherwise. */ function has_permission($permission_name) { // The super admin (user ID 1) always has all permissions. if (isset($_SESSION['user_id']) && $_SESSION['user_id'] == 1) { return true; } // Check if the permission exists in the user's session permissions array. return isset($_SESSION['permissions']) && in_array($permission_name, $_SESSION['permissions']); } /** * A helper function to protect a page. * If the user doesn't have the required permission, it will stop script execution. * * @param string $permission_name The permission required to access the page. */ function require_permission($permission_name) { if (!has_permission($permission_name)) { // You can create a fancier "Access Denied" page if you want. die("Access Denied. You do not have the required permission ($permission_name)."); } } ?>