mirror of
https://github.com/casjaysdevdocker/tor
synced 2025-10-14 08:02:34 -04:00
🗃️ Committing everything that changed 🗃️
Dockerfile README.md rootfs/tmp/etc/nginx/nginx.conf rootfs/tmp/etc/nginx/vhosts.d/admin.conf rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/etc/docker/init.d/99-php-fpm.sh rootfs/usr/local/share/
This commit is contained in:
32
rootfs/usr/local/share/webpanel/auth.php
Normal file
32
rootfs/usr/local/share/webpanel/auth.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
$admin_user = $_ENV['TOR_ADMIN_USER'] ?? 'admin';
|
||||
$admin_pass = $_ENV['TOR_ADMIN_PASS'] ?? 'torpass123';
|
||||
|
||||
function isAuthenticated() {
|
||||
return isset($_SESSION['authenticated']) && $_SESSION['authenticated'] === true;
|
||||
}
|
||||
|
||||
function authenticate($username, $password) {
|
||||
global $admin_user, $admin_pass;
|
||||
return $username === $admin_user && $password === $admin_pass;
|
||||
}
|
||||
|
||||
function requireAuth() {
|
||||
if (!isAuthenticated()) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function logout() {
|
||||
session_destroy();
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET['logout'])) {
|
||||
logout();
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user