- config_loader.php: prefer local billing config FIRST (root cause fix) - was: panel config loaded first, overriding local config with wrong db name - now: local modules/billing/includes/config.inc.php always wins when present - config.inc.php: add $db_port="3306" - config.example.php: new example config with all variables documented - menu.php: add $db_port to mysqli_connect - admin_auth.php: add $db_port; remove hardcoded /_website path detection - bootstrap.php billing_get_db(): add $db_port - login.php: fix /_website path detection - adminserverlist.php: add $db_port; fix hardcoded /modules/billing/ URL - All other mysqli_connect calls: add isset($db_port) port parameter (my_servers, forgot_password, serverlist, server_status, order, register, reset_password, payment_success, my_account, admin_invoices, admin_payments, diag_remote, admin_coupons, test_db_connection, tools/check_db_user, renew_server) - timestamp.txt: updated Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/a3e1e4bb-8eb1-4e6e-b1f8-7f3952301231 Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
73 lines
3.2 KiB
PHP
73 lines
3.2 KiB
PHP
<?php
|
|
session_name("opengamepanel_web");
|
|
session_start();
|
|
require_once(__DIR__ . '/bootstrap.php');
|
|
|
|
// Variables from config.inc.php (helps IDEs understand scope)
|
|
/** @var string $db_host Database host */
|
|
/** @var string $db_user Database user */
|
|
/** @var string $db_pass Database password */
|
|
/** @var string $db_name Database name */
|
|
/** @var string $table_prefix Table prefix for database tables */
|
|
|
|
// Simple registration form (creates a user in {table_prefix}users with MD5 password)
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['username']) && !empty($_POST['password'])) {
|
|
$db = mysqli_connect($db_host, $db_user, $db_pass, $db_name, isset($db_port) ? (int)$db_port : null);
|
|
if ($db) {
|
|
$username = trim($_POST['username']);
|
|
$password = $_POST['password'];
|
|
$email = trim($_POST['email']);
|
|
|
|
// basic validation
|
|
if ($username === '' || $password === '' || $email === '') {
|
|
$error = 'All fields are required.';
|
|
} else {
|
|
// Store legacy MD5 for panel compatibility, and also store a modern hash
|
|
$md5pw = md5($password);
|
|
$modern = password_hash($password, PASSWORD_DEFAULT);
|
|
|
|
// Try to insert with shadow column if it exists
|
|
$has_shadow = false;
|
|
$res = $db->query("SHOW COLUMNS FROM {$table_prefix}users LIKE 'users_pass_hash'");
|
|
if ($res && $res->num_rows > 0) {
|
|
$has_shadow = true;
|
|
}
|
|
|
|
if ($has_shadow) {
|
|
$stmt = $db->prepare("INSERT INTO {$table_prefix}users (users_login, users_passwd, users_pass_hash, users_email, users_role) VALUES (?, ?, ?, ?, 'user')");
|
|
$stmt->bind_param('ssss', $username, $md5pw, $modern, $email);
|
|
} else {
|
|
$stmt = $db->prepare("INSERT INTO {$table_prefix}users (users_login, users_passwd, users_email, users_role) VALUES (?, ?, ?, 'user')");
|
|
$stmt->bind_param('sss', $username, $md5pw, $email);
|
|
}
|
|
|
|
if ($stmt->execute()) {
|
|
// Redirect to absolute login URL
|
|
$script = $_SERVER['SCRIPT_NAME'] ?? '';
|
|
$pos = strpos($script, '/_website');
|
|
$siteRoot = $pos !== false ? substr($script, 0, $pos + strlen('/_website')) : rtrim(dirname($script), '/\\');
|
|
header('Location: ' . $siteRoot . '/login.php?registered=1');
|
|
exit;
|
|
} else {
|
|
$error = 'Could not create user. Maybe the name is taken.';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html>
|
|
<head><meta charset="utf-8"><title>Register - GameServers.World</title></head>
|
|
<body>
|
|
<?php include(__DIR__ . '/includes/top.php'); include(__DIR__ . '/includes/menu.php'); ?>
|
|
<h2>Register</h2>
|
|
<?php if (!empty($error)) echo '<div class="muted text-danger">'.htmlspecialchars($error).'</div>'; ?>
|
|
<form method="post" action="register.php">
|
|
<label>Username<br><input type="text" name="username" required></label><br>
|
|
<label>Email<br><input type="email" name="email"></label><br>
|
|
<label>Password<br><input type="password" name="password" required></label><br>
|
|
<button type="submit">Register</button>
|
|
</form>
|
|
</body>
|
|
</html>
|
|
|