Skip to content

Commit 2b2c4f0

Browse files
committed
PHP 8.5 support, rename config options with -, close #56
1 parent d78cb7f commit 2b2c4f0

File tree

12 files changed

+47
-37
lines changed

12 files changed

+47
-37
lines changed

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup PHP
2121
uses: shivammathur/setup-php@v2
2222
with:
23-
php-version: 8.4
23+
php-version: 8.5
2424
tools: composer:v2
2525
coverage: none
2626

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
strategy:
2626
fail-fast: true
2727
matrix:
28-
php: [ '8.2', '8.3', '8.4' ]
28+
php: [ '8.2', '8.3', '8.4', '8.5' ]
2929
stability: [ prefer-stable ]
3030

3131
name: PHP ${{ matrix.php }} (Single-Node Redis)
@@ -62,7 +62,7 @@ jobs:
6262
strategy:
6363
fail-fast: true
6464
matrix:
65-
php: [ '8.2', '8.3', '8.4' ]
65+
php: [ '8.2', '8.3', '8.4', '8.5' ]
6666
stability: [ prefer-stable ]
6767

6868
name: PHP ${{ matrix.php }} (Redis Cluster)

config.dist.php

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,35 @@
6767
$username = 'admin';
6868
$password = 'pass';
6969
70+
if (isset($_GET['logout'])) {
71+
setcookie('auth_reset', '1', time() + 60, '/');
72+
73+
$clean_uri = strtok($_SERVER['REQUEST_URI'], '?');
74+
$is_https = (
75+
(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === 1)) ||
76+
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
77+
);
78+
79+
header('Location: http'.($is_https ? 's' : '').'://'.$_SERVER['HTTP_HOST'].$clean_uri);
80+
exit;
81+
}
82+
83+
if (isset($_COOKIE['auth_reset'])) {
84+
setcookie('auth_reset', '', time() - 3600, '/');
85+
86+
header('WWW-Authenticate: Basic realm="phpCacheAdmin Login"');
87+
header('HTTP/1.0 401 Unauthorized');
88+
exit('You have been logged out.');
89+
}
90+
7091
if (
7192
!isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) ||
7293
$_SERVER['PHP_AUTH_USER'] !== $username || $_SERVER['PHP_AUTH_PW'] !== $password
7394
) {
7495
header('WWW-Authenticate: Basic realm="phpCacheAdmin Login"');
7596
header('HTTP/1.0 401 Unauthorized');
76-
7797
exit('Incorrect username or password!');
7898
}
79-
80-
// Use this section for the logout. It will display a link in the sidebar.
81-
if (isset($_GET['logout'])) {
82-
$is_https = (
83-
(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === 'on' || $_SERVER['HTTPS'] === 1)) ||
84-
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
85-
);
86-
87-
header('Location: http'.($is_https ? 's' : '').'://reset:reset@'.($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));
88-
}
8999
},*/
90100
// Decoding / Encoding functions
91101
'converters' => [
@@ -132,14 +142,15 @@
132142
],
133143
// Customizations
134144
//'timezone' => 'Europe/Bratislava', // Leave empty (or commented out) to get it automatically obtained.
135-
'time-format' => 'd. m. Y H:i:s',
136-
'decimal-sep' => ',',
137-
'thousands-sep' => ' ',
138-
'list-view' => 'table', // table/tree - default key list view
145+
'timeformat' => 'd. m. Y H:i:s',
146+
'decimalsep' => ',',
147+
'thousandssep' => ' ',
148+
'listview' => 'table', // table/tree - default key list view
139149
'panelrefresh' => 30, // In seconds, refresh interval for panels - default 30
140150
'metricsrefresh' => 60, // In seconds, refresh interval for metrics - default 60
141151
'metricstab' => 1440, // Default tab in metrics, 60 - Last hour, 1440 - Last day, 10080 - Last week, 43200 - Last month - default 1440
142152
'hash' => 'pca', // Any random string to secure metrics DB file
143153
'tmpdir' => __DIR__.'/tmp',
144154
//'pcapath' => 'vendor/robinn/phpcacheadmin/', // Path to the package when installed via composer. User for assets.
155+
//'url' => '/', // URL to the package, e.g., /phpcacheadmin
145156
];

src/Config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ public static function get(string $key, $default = null) {
6868
* Get config from ENV.
6969
*
7070
* All keys from the config file are supported ENV variables, they just must start with PCA_ prefix.
71-
* Since keys with underscores are converted to an array, use a dash to create a space (-).
7271
*
7372
* E.g.
74-
* PCA_TIME-FORMAT
73+
* PCA_TIMEFORMAT
7574
* PCA_REDIS_1_HOST = 1 is server id
7675
* PCA_MEMCACHED_0_HOST ...
7776
*

src/Dashboards/APCu/APCuTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static function (string $key, string $value, int $ttl): bool {
314314
$paginator = new Paginator($this->template, $keys);
315315
$paginated_keys = $paginator->getPaginated();
316316

317-
if (Http::get('view', Config::get('list-view', 'table')) === 'tree') {
317+
if (Http::get('view', Config::get('listview', 'table')) === 'tree') {
318318
$keys_to_display = $this->keysTreeView($paginated_keys);
319319
} else {
320320
$keys_to_display = $this->keysTableView($paginated_keys);

src/Dashboards/Memcached/MemcachedTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ private function mainDashboard(): string {
560560
$paginator = new Paginator($this->template, $raw_key_lines);
561561
$paginated_raw_lines = $paginator->getPaginated();
562562

563-
if (Http::get('view', Config::get('list-view', 'table')) === 'tree') {
563+
if (Http::get('view', Config::get('listview', 'table')) === 'tree') {
564564
$keys_to_display = $this->keysTreeView($paginated_raw_lines);
565565
} else {
566566
$keys_to_display = $this->keysTableView($paginated_raw_lines);

src/Dashboards/Redis/RedisTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ function (string $key, string $value, int $ttl): bool {
657657
$paginator = new Paginator($this->template, $keys);
658658
$paginated_keys = $paginator->getPaginated();
659659

660-
if (Http::get('view', Config::get('list-view', 'table')) === 'tree') {
660+
if (Http::get('view', Config::get('listview', 'table')) === 'tree') {
661661
$keys_to_display = $this->keysTreeView($paginated_keys);
662662
} else {
663663
$keys_to_display = $this->keysTableView($paginated_keys);

src/Format.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static function time(int $time): string {
9292
return 'Never';
9393
}
9494

95-
$format = Config::get('time-format', 'd. m. Y H:i:s');
95+
$format = Config::get('timeformat', 'd. m. Y H:i:s');
9696

9797
try {
9898
return (new DateTimeImmutable('@'.$time))
@@ -131,8 +131,8 @@ public static function number(float $number, int $decimals = 0): string {
131131
return number_format(
132132
$number,
133133
$decimals,
134-
Config::get('decimal-sep', ','),
135-
Config::get('thousands-sep', ' ')
134+
Config::get('decimalsep', ','),
135+
Config::get('thousandssep', ' ')
136136
);
137137
}
138138
}

src/Template.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ private function initTwig(): Environment {
5151
$loader = new FilesystemLoader(__DIR__.'/../templates');
5252
$tmp = Config::get('tmpdir', __DIR__.'/../tmp');
5353
$twig = new Environment($loader, [
54-
'cache' => Config::get('twig-cache', $tmp.'/twig'),
55-
'debug' => Config::get('twig-debug', false),
54+
'cache' => Config::get('twigcache', $tmp.'/twig'),
55+
'debug' => Config::get('twigdebug', false),
5656
]);
5757

5858
foreach ($this->paths as $namespace => $path) {
@@ -65,7 +65,7 @@ private function initTwig(): Environment {
6565
}
6666
}
6767

68-
if (Config::get('twig-debug', false)) {
68+
if (Config::get('twigdebug', false)) {
6969
$twig->addExtension(new DebugExtension());
7070
}
7171

templates/layout.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<body class="bg-gray-100 text-gray-900 dark:text-gray-200 dark:bg-gray-900" data-dashboard="{{ current }}">
3838
<header class="md:grid md:grid-cols-3 p-4 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700">
3939
<div class="flex">
40-
<a class="block w-72 md:me-4" href="/">{{ svg('logo', null) }}</a>
40+
<a class="block w-72 md:me-4" href="{{ config('url', '/') }}">{{ svg('logo', null) }}</a>
4141
<div class="w-72">{{ servers|raw }}</div>
4242
</div>
4343

0 commit comments

Comments
 (0)