update migrations
This commit is contained in:
parent
c46f356c7c
commit
01dd6a10f5
34
migrate.php
34
migrate.php
@ -15,17 +15,49 @@ function migrationOutput(string $message = ''): void
|
|||||||
echo $message . PHP_EOL;
|
echo $message . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function configureMigrationSession(): void
|
||||||
|
{
|
||||||
|
if (PHP_SAPI === 'cli') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sessionsDir = __DIR__ . '/sessions';
|
||||||
|
if (!is_dir($sessionsDir)) {
|
||||||
|
@mkdir($sessionsDir, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_writable($sessionsDir)) {
|
||||||
|
session_save_path($sessionsDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
|
||||||
|
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
|
||||||
|
) {
|
||||||
|
session_set_cookie_params([
|
||||||
|
'lifetime' => 0,
|
||||||
|
'path' => '/',
|
||||||
|
'secure' => true,
|
||||||
|
'httponly' => true,
|
||||||
|
'samesite' => 'None',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function canRunMigrations(): bool
|
function canRunMigrations(): bool
|
||||||
{
|
{
|
||||||
if (PHP_SAPI === 'cli') {
|
if (PHP_SAPI === 'cli') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configureMigrationSession();
|
||||||
|
|
||||||
if (session_status() === PHP_SESSION_NONE) {
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
@session_start();
|
@session_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($_SESSION['user_role_name'] ?? '') === 'Administrator') {
|
$roleName = (string) ($_SESSION['user_role_name'] ?? '');
|
||||||
|
if (strcasecmp($roleName, 'Administrator') === 0 || (int) ($_SESSION['user_id'] ?? 0) === 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user