mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
Update pma.php
This commit is contained in:
parent
3114d0f9e9
commit
5fed8ea5bc
@ -1,6 +1,22 @@
|
||||
<?php
|
||||
$fileToken = "IZs2cM1dmE2RluSrnUYH84kKBVjuhw";
|
||||
|
||||
require_once '/etc/phpmyadmin/config.secret.inc.php';
|
||||
require_once '/etc/phpmyadmin/helpers.php';
|
||||
|
||||
/* Ensure we got the environment */
|
||||
$vars = [
|
||||
'PMA_HOST',
|
||||
'MYSQL_ROOT_PASSWORD'
|
||||
];
|
||||
|
||||
foreach ($vars as $var) {
|
||||
$env = getenv($var);
|
||||
if (!isset($_ENV[$var]) && $env !== false) {
|
||||
$_ENV[$var] = $env;
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve the token from the URL
|
||||
$providedToken = isset($_GET['token']) ? $_GET['token'] : '';
|
||||
|
||||
@ -10,22 +26,27 @@ if ($providedToken === $fileToken) {
|
||||
session_name('OPENPANEL_PHPMYADMIN');
|
||||
session_start();
|
||||
|
||||
$_SESSION['PMA_single_signon_user'] = 'phpmyadmin';
|
||||
$_SESSION['PMA_single_signon_password'] = 'cao1rsVFX0zPMq';
|
||||
$_SESSION['PMA_single_signon_host'] = 'localhost';
|
||||
if (isset($_ENV['MYSQL_ROOT_PASSWORD'])) {
|
||||
$_SESSION['PMA_single_signon_user'] = 'root';
|
||||
$_SESSION['PMA_single_signon_password'] = isset($_ENV['MYSQL_ROOT_PASSWORD']) ? $_ENV['MYSQL_ROOT_PASSWORD'] : '';
|
||||
$_SESSION['PMA_single_signon_host'] = isset($_ENV['PMA_HOST']) ? $_ENV['PMA_HOST'] : 'mysql';
|
||||
} else {
|
||||
#echo "No root password.";
|
||||
header("Location: ./index.php?invalid");
|
||||
}
|
||||
|
||||
session_write_close();
|
||||
|
||||
// Remove the 'token' parameter from the query parameters
|
||||
unset($_GET['token']);
|
||||
|
||||
// Construct the query parameters string
|
||||
$query_params_str = http_build_query($_GET);
|
||||
|
||||
// Append query parameters to the Location header
|
||||
header("Location: ./index.php?$query_params_str");
|
||||
} else {
|
||||
// Handle invalid token (e.g., show an error message)
|
||||
echo "Invalid token: $fileToken";
|
||||
// for dev
|
||||
#echo "Invalid token: $providedToken VS $fileToken";
|
||||
// for prod
|
||||
header("Location: ./index.php?loginform=true");
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user