2b9a673912
PHP registration page for AzerothCore with SRP6 salt/verifier generation, Cloudflare Turnstile + honeypot + rate limiting anti-spam, and a WoW-themed landing page with client setup instructions.
83 lines
2.8 KiB
PHP
83 lines
2.8 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Loads .env (simple KEY=VALUE parser, no external dependency) and exposes
|
|
* typed config via env()/config().
|
|
*/
|
|
if (!function_exists('load_env')) {
|
|
// This file is `require`d (not require_once) from more than one place
|
|
// (bootstrap.php and Database.php), so it must always return a fresh
|
|
// config array — but its function declarations must only run once.
|
|
function load_env(string $path): void
|
|
{
|
|
if (!is_file($path)) {
|
|
return;
|
|
}
|
|
|
|
foreach (file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
|
|
$line = trim($line);
|
|
if ($line === '' || str_starts_with($line, '#')) {
|
|
continue;
|
|
}
|
|
[$key, $value] = array_pad(explode('=', $line, 2), 2, '');
|
|
$key = trim($key);
|
|
$value = trim($value);
|
|
if ($key === '') {
|
|
continue;
|
|
}
|
|
// Strip one layer of matching quotes, e.g. SITE_NAME="AzerothCore by Minkey"
|
|
if (strlen($value) >= 2) {
|
|
$first = $value[0];
|
|
$last = $value[strlen($value) - 1];
|
|
if (($first === '"' && $last === '"') || ($first === "'" && $last === "'")) {
|
|
$value = substr($value, 1, -1);
|
|
}
|
|
}
|
|
putenv("$key=$value");
|
|
$_ENV[$key] = $value;
|
|
}
|
|
}
|
|
|
|
function env(string $key, ?string $default = null): ?string
|
|
{
|
|
$value = getenv($key);
|
|
if ($value === false || $value === '') {
|
|
return $default;
|
|
}
|
|
return $value;
|
|
}
|
|
}
|
|
|
|
load_env(__DIR__ . '/../.env');
|
|
|
|
return [
|
|
'site' => [
|
|
'name' => env('SITE_NAME', 'AzerothCore by Minkey'),
|
|
'realmlist' => env('REALMLIST_ADDRESS', 'wow.minkey.cz'),
|
|
'client_download_url' => env('CLIENT_DOWNLOAD_URL', ''),
|
|
'client_version' => env('CLIENT_VERSION', 'WotLK 3.3.5a (build 12340)'),
|
|
],
|
|
'db' => [
|
|
'host' => env('DB_HOST', '127.0.0.1'),
|
|
'port' => (int) env('DB_PORT', '3306'),
|
|
'database' => env('DB_DATABASE', 'acore_auth'),
|
|
'username' => env('DB_USERNAME', ''),
|
|
'password' => env('DB_PASSWORD', ''),
|
|
],
|
|
'turnstile' => [
|
|
'site_key' => env('TURNSTILE_SITE_KEY', ''),
|
|
'secret_key' => env('TURNSTILE_SECRET_KEY', ''),
|
|
],
|
|
'rules' => [
|
|
'username_min' => (int) env('REG_USERNAME_MIN', '3'),
|
|
'username_max' => (int) env('REG_USERNAME_MAX', '16'),
|
|
'password_min' => (int) env('REG_PASSWORD_MIN', '8'),
|
|
'password_max' => (int) env('REG_PASSWORD_MAX', '16'),
|
|
],
|
|
'rate_limit' => [
|
|
'max_attempts' => (int) env('REG_RATE_LIMIT_MAX', '5'),
|
|
'window_seconds' => (int) env('REG_RATE_LIMIT_WINDOW', '3600'),
|
|
],
|
|
];
|