From 412ce52e5418b691ef65ff632315312b48700e41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Edgaras=20Janu=C5=A1auskas?=
Date: Fri, 7 Apr 2017 15:19:49 +0300
Subject: [PATCH 001/107] Format TTL to days, hours or minutes
---
includes/functions.inc.php | 9 +++++++++
view.php | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/includes/functions.inc.php b/includes/functions.inc.php
index 89368e3..f884260 100644
--- a/includes/functions.inc.php
+++ b/includes/functions.inc.php
@@ -74,6 +74,15 @@ function format_size($size) {
}
+function format_ttl($seconds) {
+ if ($seconds > 60) {
+ return sprintf('%d (%s)', $seconds, format_ago($seconds));
+ } else {
+ return $seconds;
+ }
+}
+
+
function str_rand($length) {
$r = '';
diff --git a/view.php b/view.php
index 5799a2e..1bfff92 100644
--- a/view.php
+++ b/view.php
@@ -107,7 +107,7 @@
Type:
-
+
Encoding:
From 5ed9bbe9584b503ea24994d9cfb7265943cbab4e Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sat, 8 Apr 2017 03:09:55 +0000
Subject: [PATCH 002/107] 1.7.0
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 287c77e..d39bc0c 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.6.0",
+ "version": "1.7.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From ec42e396b6259880b92dbf41f1075239f47d2322 Mon Sep 17 00:00:00 2001
From: Ares
Date: Sat, 27 May 2017 12:57:43 +0800
Subject: [PATCH 003/107] replaceState problem
Route will be wrong if domain has substring 'php'.
eg. 'local.redis.phptest.com'.
So fix it.
---
js/frame.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/js/frame.js b/js/frame.js
index c2f1d95..b3b84b5 100644
--- a/js/frame.js
+++ b/js/frame.js
@@ -1,6 +1,6 @@
$(function() {
if (history.replaceState) {
- window.parent.history.replaceState({}, '', document.location.href.replace('?', '&').replace(/([a-z]*)\.php/, '?$1'));
+ window.parent.history.replaceState({}, '', document.location.href.replace('?', '&').replace(/\/([a-z]*)\.php/, '/?$1'));
}
From f5a445d07c87524e892c3d14fd1250bf1a8fee3d Mon Sep 17 00:00:00 2001
From: Igor Sheviakov
Date: Sun, 11 Jun 2017 16:40:11 +0300
Subject: [PATCH 004/107] changing style for #keys block adding netbeans
metadata folder to .gitignore
---
.gitignore | 3 +++
css/index.css | 5 +----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
index daf3eea..4dc5d11 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
config.inc.php
*.phar
vendor
+
+# IDEs metadata
+/nbproject/
diff --git a/css/index.css b/css/index.css
index 2c8faf5..80ceade 100644
--- a/css/index.css
+++ b/css/index.css
@@ -23,10 +23,6 @@ text-decoration: underline;
#keys {
-position: absolute;
-top: 18.5em;
-left: 0;
-bottom: 0;
width: 290px;
padding-left: 10px;
overflow: auto;
@@ -45,6 +41,7 @@ font-weight: normal;
#keys li.folder {
font-weight: bold;
margin-top: .05em;
+cursor: pointer;
}
#keys li.current a {
From a5617b025c5a51872763d1cc60984bd9b72081b3 Mon Sep 17 00:00:00 2001
From: Andrew Gillard
Date: Tue, 13 Jun 2017 17:14:27 +0100
Subject: [PATCH 005/107] Allow logging in via HTML
+
+
diff --git a/logout.php b/logout.php
index 2d6aca8..b5c9324 100644
--- a/logout.php
+++ b/logout.php
@@ -1,40 +1,49 @@
1,
- 'nc' => 1,
- 'cnonce' => 1,
- 'qop' => 1,
- 'username' => 1,
- 'uri' => 1,
- 'response' => 1
- );
+if (!empty($config['cookie_auth'])) {
+ // Cookie-based auth
+ setcookie('phpRedisAdminLogin', '', 1);
+ header("Location: login.php");
+ die();
+} else {
+ // HTTP Digest auth
+ $needed_parts = array(
+ 'nonce' => 1,
+ 'nc' => 1,
+ 'cnonce' => 1,
+ 'qop' => 1,
+ 'username' => 1,
+ 'uri' => 1,
+ 'response' => 1
+ );
-$data = array();
-$keys = implode('|', array_keys($needed_parts));
+ $data = array();
+ $keys = implode('|', array_keys($needed_parts));
-preg_match_all('/('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))/', $_SERVER['PHP_AUTH_DIGEST'], $matches, PREG_SET_ORDER);
+ preg_match_all('/('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))/', $_SERVER['PHP_AUTH_DIGEST'], $matches, PREG_SET_ORDER);
-foreach ($matches as $m) {
- $data[$m[1]] = $m[3] ? $m[3] : $m[4];
- unset($needed_parts[$m[1]]);
-}
+ foreach ($matches as $m) {
+ $data[$m[1]] = $m[3] ? $m[3] : $m[4];
+ unset($needed_parts[$m[1]]);
+ }
-if (!isset($_GET['nonce'])) {
- header('Location: logout.php?nonce='.$data['nonce']);
- die;
-}
+ if (!isset($_GET['nonce'])) {
+ header('Location: logout.php?nonce='.$data['nonce']);
+ die;
+ }
-if ($data['nonce'] == $_GET['nonce']) {
- unset($_SERVER['PHP_AUTH_DIGEST']);
+ if ($data['nonce'] == $_GET['nonce']) {
+ unset($_SERVER['PHP_AUTH_DIGEST']);
- require 'includes/login.inc.php';
-}
+ require 'includes/login.inc.php';
+ }
-header('Location: '.substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'logout.php')));
+ header('Location: '.substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'logout.php')));
+}
?>
From 88e9e0b7c6a0f153030217cd40aa4b1468d9339b Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Mon, 14 Aug 2017 09:21:52 +0000
Subject: [PATCH 006/107] 1.8.0
---
README.markdown | 4 ++--
composer.json | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.markdown b/README.markdown
index 115bcfc..aa24a86 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,5 +1,5 @@
-phpRedisAdmin 1.6.0
-===================
+phpRedisAdmin
+=============
phpRedisAdmin is a simple web interface to manage [Redis](http://redis.io/)
databases. It is released under the
diff --git a/composer.json b/composer.json
index d39bc0c..a8d026d 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.7.0",
+ "version": "1.8.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 51a2a08dd86ce69f62eb6d55cf4efe4a7b32ff4b Mon Sep 17 00:00:00 2001
From: aplexup <32103435+aplexup@users.noreply.github.com>
Date: Tue, 19 Sep 2017 18:39:26 +0300
Subject: [PATCH 007/107] Update login.inc.php
If using "cookie_auth" and enter not exists login, then PHP show "Notice: Undefined index: a in /usr/www/pra/includes/login.inc.php on line 112"
---
includes/login.inc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/login.inc.php b/includes/login.inc.php
index cda4bad..f1abce6 100644
--- a/includes/login.inc.php
+++ b/includes/login.inc.php
@@ -109,7 +109,7 @@ function authCookie()
if (isset($_POST['username'], $_POST['password'])) {
// Login form submitted; correctly?
- if ($config['login'][$_POST['username']]) {
+ if (isset($config['login'][$_POST['username']])) {
$userData = $config['login'][$_POST['username']];
if ($_POST['password'] === $userData['password']) {
// Correct username & password. Set cookie and redirect to home page
From b38b7d2fd63f5ccc0c80b0cca9c0e017b7423fcc Mon Sep 17 00:00:00 2001
From: fratuz610
Date: Wed, 8 Nov 2017 19:31:18 +1100
Subject: [PATCH 008/107] Improved export functionality (#120)
Added support for filter and transform parameters while exporting bulk databases
---
export.php | 61 ++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 48 insertions(+), 13 deletions(-)
diff --git a/export.php b/export.php
index 69c15c4..ae1f0c3 100644
--- a/export.php
+++ b/export.php
@@ -3,18 +3,22 @@
require_once 'includes/common.inc.php';
-
-
// Export to redis-cli commands
-function export_redis($key) {
+function export_redis($key, $filter = false, $transform = false) {
+
global $redis;
$type = $redis->type($key);
-
+ // we rename the keys as necessary
+ if($filter !== false && $transform !== false)
+ $outputKey = str_replace($filter, $transform, $key);
+ else
+ $outputKey = $key;
+
// String
if ($type == 'string') {
- echo 'SET "',addslashes($key),'" "',addslashes($redis->get($key)),'"',PHP_EOL;
+ echo 'SET "',addslashes($outputKey),'" "',addslashes($redis->get($key)),'"',PHP_EOL;
}
// Hash
@@ -22,7 +26,7 @@ function export_redis($key) {
$values = $redis->hGetAll($key);
foreach ($values as $k => $v) {
- echo 'HSET "',addslashes($key),'" "',addslashes($k),'" "',addslashes($v),'"',PHP_EOL;
+ echo 'HSET "',addslashes($outputKey),'" "',addslashes($k),'" "',addslashes($v),'"',PHP_EOL;
}
}
@@ -31,7 +35,7 @@ function export_redis($key) {
$size = $redis->lLen($key);
for ($i = 0; $i < $size; ++$i) {
- echo 'RPUSH "',addslashes($key),'" "',addslashes($redis->lIndex($key, $i)),'"',PHP_EOL;
+ echo 'RPUSH "',addslashes($outputKey),'" "',addslashes($redis->lIndex($key, $i)),'"',PHP_EOL;
}
}
@@ -40,7 +44,7 @@ function export_redis($key) {
$values = $redis->sMembers($key);
foreach ($values as $v) {
- echo 'SADD "',addslashes($key),'" "',addslashes($v),'"',PHP_EOL;
+ echo 'SADD "',addslashes($outputKey),'" "',addslashes($v),'"',PHP_EOL;
}
}
@@ -51,7 +55,7 @@ function export_redis($key) {
foreach ($values as $v) {
$s = $redis->zScore($key, $v);
- echo 'ZADD "',addslashes($key),'" ',$s,' "',addslashes($v),'"',PHP_EOL;
+ echo 'ZADD "',addslashes($outputKey),'" ',$s,' "',addslashes($v),'"',PHP_EOL;
}
}
}
@@ -64,7 +68,6 @@ function export_json($key) {
$type = $redis->type($key);
-
// String
if ($type == 'string') {
$value = $redis->get($key);
@@ -116,9 +119,12 @@ function export_json($key) {
header('Content-type: '.$ct.'; charset=utf-8');
header('Content-Disposition: inline; filename="export.'.$ext.'"');
+ $filter = !empty($_POST['filter']) ? trim($_POST['filter']) : false;
+ $transform = !empty($_POST['transform']) ? trim($_POST['transform']) : false;
// JSON
if ($_POST['type'] == 'json') {
+
// Single key
if (isset($_GET['key'])) {
echo json_encode(export_json($_GET['key']));
@@ -127,7 +133,18 @@ function export_json($key) {
$vals = array();
foreach ($keys as $key) {
- $vals[$key] = export_json($key);
+
+ // if we have a filter and no match, nothing to do
+ if($filter !== false && stripos($key, $filter) === false)
+ continue;
+
+ // we rename the keys as necessary
+ if($filter !== false && $transform !== false)
+ $outputKey = str_replace($filter, $transform, $key);
+ else
+ $outputKey = $key;
+
+ $vals[$outputKey] = export_json($key);
}
echo json_encode($vals);
@@ -136,6 +153,7 @@ function export_json($key) {
// Redis Commands
else {
+
// Single key
if (isset($_GET['key'])) {
export_redis($_GET['key']);
@@ -143,7 +161,12 @@ function export_json($key) {
$keys = $redis->keys('*');
foreach ($keys as $key) {
- export_redis($key);
+
+ // if we have a filter and no match, we skip
+ if($filter !== false && stripos($key, $filter) === false)
+ continue;
+
+ export_redis($key, $filter, $transform);
}
}
}
@@ -171,7 +194,19 @@ function export_json($key) {
>Redis
>JSON
-
+
+
+
+
+ Filter:
+
+
+
+
+ Tranform:
+
+
+
From b8d054de1d661188379aa357e32f0c3d2be94b5c Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Wed, 8 Nov 2017 08:34:20 +0000
Subject: [PATCH 009/107] Fix #119
---
composer.lock | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/composer.lock b/composer.lock
index cd0cb49..b9c3078 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "e81aef935c2a6d36cf7690dbdb9d129a",
- "content-hash": "3212fc4e8463f3bf5ff7db4655eecbf0",
+ "content-hash": "c4f147b8be07b8af9b1dfaffaa9a7616",
"packages": [
{
"name": "predis/predis",
@@ -55,7 +54,7 @@
"predis",
"redis"
],
- "time": "2015-07-30 18:34:15"
+ "time": "2015-07-30T18:34:15+00:00"
}
],
"packages-dev": [],
From f3000673c5c67811c3da8c12395d2cf6974d406a Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Wed, 8 Nov 2017 08:46:36 +0000
Subject: [PATCH 010/107] 1.9.0
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index a8d026d..fa9bd8b 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.8.0",
+ "version": "1.9.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 46d0e40fdffe21cd86a6a310a5c380eb070765c8 Mon Sep 17 00:00:00 2001
From: pataquets
Date: Wed, 10 Jan 2018 20:21:00 +0100
Subject: [PATCH 011/107] Add Docker usage docs and Docker Compose manifest for
testing/development.
---
README.markdown | 10 ++++++++++
docker-compose.yml | 15 +++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 docker-compose.yml
diff --git a/README.markdown b/README.markdown
index aa24a86..19fd8d7 100644
--- a/README.markdown
+++ b/README.markdown
@@ -39,6 +39,16 @@ cd phpRedisAdmin
git clone https://github.com/nrk/predis.git vendor
```
+Docker Image
+============
+A public [phpRedisAdmin Docker image](https://hub.docker.com/r/erikdubbelboer/phpredisadmin/) is available on Docker Hub [automatically built](https://docs.docker.com/docker-hub/builds/) from latest source.
+The file ```includes/config.environment.inc.php``` is used as the configuration file to allow environment variables to be used as configuration values.
+Example:
+```
+docker run --rm -it -e REDIS_1_HOST=myredis.host -e REDIS_1_NAME=MyRedis -p 80:80 erikdubbelboer/phpredisadmin
+```
+Also, a Docker Compose manifest with a stack for testing and development is provided. Just issue ```docker-compose up --build``` to start it and browse to http://localhost. See ```docker-compose.yml``` file for configuration details.
+
TODO
====
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..dab64b9
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,15 @@
+phpredisadmin:
+ build: .
+ environment:
+ - ADMIN_USER=admin
+ - ADMIN_PASS=admin
+ - REDIS_1_HOST=redis
+ - REDIS_1_PORT=6379
+ links:
+ - redis
+ ports:
+ - "80:80"
+
+redis:
+ image: redis
+ command: --loglevel verbose
From e4731fea07e715ad7afe3948ca5c0cab349f4545 Mon Sep 17 00:00:00 2001
From: pataquets
Date: Wed, 10 Jan 2018 20:21:41 +0100
Subject: [PATCH 012/107] Fix: delete inherited servers when loading
configuration from environment variables.
---
includes/config.environment.inc.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php
index bb7c76c..7f32a20 100644
--- a/includes/config.environment.inc.php
+++ b/includes/config.environment.inc.php
@@ -14,6 +14,7 @@
}
$i=1;
+$config['servers'] = array();
while (TRUE) {
From ca42173213dc62c541921ee31aa525097e81ba86 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Thu, 11 Jan 2018 06:20:19 +0000
Subject: [PATCH 013/107] v1.10.0
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index fa9bd8b..7ac4a22 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.9.0",
+ "version": "1.10.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 260ad43edbc2e390e03b6878c3d746ff2d86a6ca Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Tue, 16 Jan 2018 07:22:34 +0000
Subject: [PATCH 014/107] v1.10.1
To test the docker build system.
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 7ac4a22..96cb7eb 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.10.0",
+ "version": "1.10.1",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From ed103da0ee08402bb12d09e12fc346db9b155ae5 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 23 Feb 2018 02:31:39 +0000
Subject: [PATCH 015/107] Fix license in composer.json
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 96cb7eb..cb5da2e 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
"version": "1.10.1",
- "license": "CC-BY-ND",
+ "license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
{
From 36e35016a41bb0b8545d028f7db90e2f62b0e9c4 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 23 Feb 2018 02:33:18 +0000
Subject: [PATCH 016/107] v1.10.2
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index cb5da2e..ca3887f 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.10.1",
+ "version": "1.10.2",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 9668550081e56b6a5ed0da033d111ccfdef42084 Mon Sep 17 00:00:00 2001
From: ppeer
Date: Thu, 22 Mar 2018 16:06:44 +0100
Subject: [PATCH 017/107] added ',' to line 12
as response to: "PHP message: PHP Parse error: syntax error, unexpected ''auth'' (T_CONSTANT_ENCAPSED_STRING)"
---
includes/config.sample.inc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index c11b25b..558f231 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -9,7 +9,7 @@
'port' => 6379,
'filter' => '*',
'scheme' => 'tcp', // Optional. Connection scheme. 'tcp' - for TCP connection, 'unix' - for connection by unix domain socket
- 'path' => '' // Optional. Path to unix domain socket. Uses only if 'scheme' => 'unix'. Example: '/var/run/redis/redis.sock'
+ 'path' => '', // Optional. Path to unix domain socket. Uses only if 'scheme' => 'unix'. Example: '/var/run/redis/redis.sock'
// Optional Redis authentication.
//'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server.
From 4e226fc08b1a98b17c29c7de9458d9ca196ca825 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8F=A4=E6=9C=A8=E5=A4=A9=E7=90=AA?=
Date: Thu, 24 May 2018 18:09:21 +0800
Subject: [PATCH 018/107] Update config.environment.inc.php
add auth config to environment
---
includes/config.environment.inc.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php
index 7f32a20..cde45e0 100644
--- a/includes/config.environment.inc.php
+++ b/includes/config.environment.inc.php
@@ -23,7 +23,8 @@
$server_name = getenv($prefix . 'NAME');
$server_host = getenv($prefix . 'HOST');
$server_port = getenv($prefix . 'PORT');
-
+ $server_auth = getenv($prefix . 'AUTH');
+
if (empty($server_host)) {
break;
}
@@ -40,6 +41,7 @@
'name' => $server_name,
'host' => $server_host,
'port' => $server_port,
+ 'auth' => $server_auth,
'filter' => '*',
);
From 2cf0f7708db7fa2b008b08a441e5deb94d0388f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8F=A4=E6=9C=A8=E5=A4=A9=E7=90=AA?=
Date: Thu, 24 May 2018 18:21:24 +0800
Subject: [PATCH 019/107] Update config.environment.inc.php
fix auth config env
---
includes/config.environment.inc.php | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php
index cde45e0..d8c9ae8 100644
--- a/includes/config.environment.inc.php
+++ b/includes/config.environment.inc.php
@@ -24,7 +24,7 @@
$server_host = getenv($prefix . 'HOST');
$server_port = getenv($prefix . 'PORT');
$server_auth = getenv($prefix . 'AUTH');
-
+
if (empty($server_host)) {
break;
}
@@ -32,6 +32,10 @@
if (empty($server_name)) {
$server_name = $server_host;
}
+
+ if (empty($server_auth)) {
+ $server_auth = "";
+ }
if (empty($server_port)) {
$server_port = 6379;
@@ -41,9 +45,12 @@
'name' => $server_name,
'host' => $server_host,
'port' => $server_port,
- 'auth' => $server_auth,
'filter' => '*',
);
+
+ if (!empty($server_auth)) {
+ $config['servers'][$i-1]['auth'] = $server_auth;
+ }
$i++;
}
From c9e364be158b6b78ab96b5c7894e5c811fc704dd Mon Sep 17 00:00:00 2001
From: JACK
Date: Sat, 4 Aug 2018 05:57:35 +0800
Subject: [PATCH 020/107] Correction time shows that time is more scientific
(#130)
Improve time formatting
---
includes/functions.inc.php | 39 +++++++++++++++-----------------------
overview.php | 18 +++++++++++++++---
2 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/includes/functions.inc.php b/includes/functions.inc.php
index f884260..10f8dcd 100644
--- a/includes/functions.inc.php
+++ b/includes/functions.inc.php
@@ -26,39 +26,30 @@ function input_convert($str) {
}
-function format_ago($time, $ago = false) {
+function format_time($time) {
$minute = 60;
$hour = $minute * 60;
$day = $hour * 24;
$when = $time;
- if ($when >= 0)
- $suffix = 'ago';
- else {
- $when = -$when;
- $suffix = 'in the future';
- }
-
if ($when > $day) {
- $when = round($when / $day);
- $what = 'day';
+ $tmpday = floor($when / $day);
+ $tmphour = floor(($when / $hour) - (24*$tmpday));
+ $tmpminute = floor(($when / $minute) - (24*60*$tmpday) - ($tmphour * 60));
+ $tmpsec = floor($when - (24*60*60*$tmpday) - ($tmphour * 60 * 60) - ($tmpminute * 60));
+ return sprintf("%d day%s %d hour%s %d min%s %d sec%s",$tmpday,($tmpday != 1) ? 's' : '',$tmphour,($tmphour != 1) ? 's' : '',$tmpminute,($tmpminute != 1) ? 's' : '',$tmpsec,($tmpsec != 1) ? 's' : '');
} else if ($when > $hour) {
- $when = round($when / $hour);
- $what = 'hour';
+ $tmphour = floor($when / $hour);
+ $tmpminute = floor(($when / $minute) - ($tmphour * 60));
+ $tmpsec = floor($when - ($tmphour * 60 * 60) - ($tmpminute * 60));
+ return sprintf("%d hour%s %d min%s %d sec%s",$tmphour,($tmphour != 1) ? 's' : '',$tmpminute,($tmpminute != 1) ? 's' : '',$tmpsec,($tmpsec != 1) ? 's' : '');
} else if ($when > $minute) {
- $when = round($when / $minute);
- $what = 'minute';
- } else {
- $what = 'second';
- }
-
- if ($when != 1) $what .= 's';
-
- if ($ago) {
- return "$when $what $suffix";
+ $tmpminute = floor($when / $minute);
+ $tmpsec = floor($when - ($tmpminute * 60));
+ return sprintf("%d min%s %d sec%s",$tmpminute,($tmpminute != 1) ? 's' : '',$tmpsec,($tmpsec != 1) ? 's' : '');
} else {
- return "$when $what";
+ return sprintf("%d sec%s",$when,($when != 1) ? 's' : '');
}
}
@@ -76,7 +67,7 @@ function format_size($size) {
function format_ttl($seconds) {
if ($seconds > 60) {
- return sprintf('%d (%s)', $seconds, format_ago($seconds));
+ return sprintf('%d (%s)', $seconds, format_time($seconds));
} else {
return $seconds;
}
diff --git a/overview.php b/overview.php
index 8c0b073..007e2d6 100644
--- a/overview.php
+++ b/overview.php
@@ -83,9 +83,21 @@
Memory used:
- Uptime:
-
- Last save:
+ Uptime:
+
+ Last save:
+ = 0) {
+ echo format_time(time() - $info[$i]['Persistence']['rdb_last_save_time']) . " ago";
+ } else {
+ echo format_time(-(time() - $info[$i]['Persistence']['rdb_last_save_time'])) . "in the future";
+ }
+ } else {
+ echo 'never';
+ }
+ ?>
+
From 451caf7b7c1869560619a8b18fc560fcc5d49fd2 Mon Sep 17 00:00:00 2001
From: toughIQ
Date: Tue, 21 Aug 2018 16:45:53 +0200
Subject: [PATCH 021/107] changed FROM image (#132)
changed base image from "composer/composer", which is deprecated, to current "composer" with tag "1.7"
Also reduced image size from 650MB to 150MB.
---
Dockerfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile
index ebca2d9..57830ce 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM composer/composer
+FROM composer:1.7
ADD . /src/app/
WORKDIR /src/app
From 687a7928a0509438d0eca5ebc8ad7d0d1966cd02 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Tue, 21 Aug 2018 14:45:28 +0000
Subject: [PATCH 022/107] v1.11.0
Using predis 1.1.1 and docker composer:1.7 image
---
composer.json | 4 ++--
composer.lock | 20 ++++++++++----------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/composer.json b/composer.json
index ca3887f..a28d814 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.10.2",
+ "version": "1.11.0",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
@@ -13,7 +13,7 @@
}
],
"require": {
- "predis/predis": "1.0.3"
+ "predis/predis": "1.1.1"
},
"minimum-stability": "stable",
"target-dir": "ErikDubbelboer/phpRedisAdmin"
diff --git a/composer.lock b/composer.lock
index b9c3078..c07bb64 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1,30 +1,30 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "c4f147b8be07b8af9b1dfaffaa9a7616",
+ "content-hash": "e2489e7a22a6412f072878dd7c867843",
"packages": [
{
"name": "predis/predis",
- "version": "v1.0.3",
+ "version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
- "reference": "84060b9034d756b4d79641667d7f9efe1aeb8e04"
+ "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nrk/predis/zipball/84060b9034d756b4d79641667d7f9efe1aeb8e04",
- "reference": "84060b9034d756b4d79641667d7f9efe1aeb8e04",
+ "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
+ "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
"shasum": ""
},
"require": {
- "php": ">=5.3.2"
+ "php": ">=5.3.9"
},
"require-dev": {
- "phpunit/phpunit": "~4.0"
+ "phpunit/phpunit": "~4.8"
},
"suggest": {
"ext-curl": "Allows access to Webdis when paired with phpiredis",
@@ -47,14 +47,14 @@
"homepage": "http://clorophilla.net/"
}
],
- "description": "Flexible and feature-complete PHP client library for Redis",
+ "description": "Flexible and feature-complete Redis client for PHP and HHVM",
"homepage": "http://github.com/nrk/predis",
"keywords": [
"nosql",
"predis",
"redis"
],
- "time": "2015-07-30T18:34:15+00:00"
+ "time": "2016-06-16T16:22:20+00:00"
}
],
"packages-dev": [],
From ed5966f637ceda71b63693bd3d8fd336a840d01a Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Mon, 3 Sep 2018 01:29:33 +0000
Subject: [PATCH 023/107] Fix redeclare authCookie error
Fixes https://github.com/erikdubbelboer/phpRedisAdmin/issues/133
---
logout.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/logout.php b/logout.php
index b5c9324..afede7e 100644
--- a/logout.php
+++ b/logout.php
@@ -39,7 +39,11 @@
if ($data['nonce'] == $_GET['nonce']) {
unset($_SERVER['PHP_AUTH_DIGEST']);
- require 'includes/login.inc.php';
+ if (!empty($config['cookie_auth'])) {
+ $login = authCookie();
+ } else {
+ $login = authHttpDigest();
+ }
}
From da821c44e30a07922e29fe1fd81553069fafe3a7 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Mon, 24 Sep 2018 12:26:15 +0000
Subject: [PATCH 024/107] Fix -1 to push to the start of a list
Fixes #135
---
edit.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/edit.php b/edit.php
index e50da25..4842655 100644
--- a/edit.php
+++ b/edit.php
@@ -58,10 +58,12 @@
$size = $redis->lLen($key);
if (($_POST['index'] == '') ||
- ($_POST['index'] == $size) ||
- ($_POST['index'] == -1)) {
+ ($_POST['index'] == $size)) {
// Push it at the end
$redis->rPush($key, $value);
+ } else if ($_POST['index'] == -1) {
+ // Push it at the start
+ $redis->lPush($key, $value);
} else if (($_POST['index'] >= 0) &&
($_POST['index'] < $size)) {
// Overwrite an index
From ea40bf4a9160990722ce705954b01a417da7ca7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=81=A5?=
Date: Wed, 23 Jan 2019 09:34:33 +0800
Subject: [PATCH 025/107] fix a bug: remove tree action will do nothing when
'seperator' config is not ':'
---
index.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/index.php b/index.php
index f56c572..e575b2c 100644
--- a/index.php
+++ b/index.php
@@ -109,7 +109,7 @@ function print_namespace($item, $name, $fullkey, $islast) {
?>
()
-
+
Date: Thu, 24 Jan 2019 20:24:46 +0000
Subject: [PATCH 026/107] Fix PHP 5.3 compatibility
Fixes #140
---
includes/login.inc.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/login.inc.php b/includes/login.inc.php
index f1abce6..75ed28d 100644
--- a/includes/login.inc.php
+++ b/includes/login.inc.php
@@ -80,12 +80,12 @@ function authCookie()
// Using SHA512 because MD5, SHA1 are both now considered broken
return hash(
'sha512',
- implode(':', [
+ implode(':', array(
$username,
$_SERVER['HTTP_USER_AGENT'],
$_SERVER['REMOTE_ADDR'],
$config['login'][$username]['password'],
- ])
+ ))
);
};
From 6ced4d2aba817c6e8ae1665298e78c60a1f234a3 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Thu, 24 Jan 2019 20:26:52 +0000
Subject: [PATCH 027/107] v1.11.1
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index a28d814..34b18cc 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.11.0",
+ "version": "1.11.1",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From f49526a61519ac48215b9f00aa2c441c30030e9d Mon Sep 17 00:00:00 2001
From: friendlydan <47954270+friendlydan@users.noreply.github.com>
Date: Tue, 2 Apr 2019 21:39:32 +1300
Subject: [PATCH 028/107] Fix case of contants based on best practices from
PSR2 (#141)
Signed-off-by: CodeLingoBot
---
includes/config.environment.inc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php
index d8c9ae8..0522421 100644
--- a/includes/config.environment.inc.php
+++ b/includes/config.environment.inc.php
@@ -16,7 +16,7 @@
$i=1;
$config['servers'] = array();
-while (TRUE) {
+while (true) {
$prefix = 'REDIS_' . $i . '_';
From 249fd9edad4213a9742c1e46ef89b3bee65e010b Mon Sep 17 00:00:00 2001
From: Maciej Klak
Date: Mon, 3 Jun 2019 08:21:37 +0200
Subject: [PATCH 029/107] Add tini (#142)
---
Dockerfile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Dockerfile b/Dockerfile
index 57830ce..0597c23 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,10 +3,13 @@ FROM composer:1.7
ADD . /src/app/
WORKDIR /src/app
+ENV TINI_VERSION 0.18.0-r0
+
RUN \
+ apk add --no-cache tini=$TINI_VERSION && \
composer install && \
cp includes/config.environment.inc.php includes/config.inc.php
EXPOSE 80
-ENTRYPOINT [ "php", "-S", "0.0.0.0:80" ]
+ENTRYPOINT [ "tini", "--", "php", "-S", "0.0.0.0:80" ]
From c8cb378ba7c51559ef4955dfdca3b104ba817d1b Mon Sep 17 00:00:00 2001
From: Yige
Date: Fri, 14 Jun 2019 14:00:39 +0800
Subject: [PATCH 030/107] Update README.markdown (#138)
* Update README.markdown
Add Environment variables summary
* Update README.markdown
---
README.markdown | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/README.markdown b/README.markdown
index 19fd8d7..ddf39d3 100644
--- a/README.markdown
+++ b/README.markdown
@@ -49,6 +49,16 @@ docker run --rm -it -e REDIS_1_HOST=myredis.host -e REDIS_1_NAME=MyRedis -p 80:8
```
Also, a Docker Compose manifest with a stack for testing and development is provided. Just issue ```docker-compose up --build``` to start it and browse to http://localhost. See ```docker-compose.yml``` file for configuration details.
+Environment variables summary
+====
+
+* ``REDIS_1_HOST`` - define host of the Redis server
+* ``REDIS_1_NAME`` - define name of the Redis server
+* ``REDIS_1_PORT`` - define port of the Redis server
+* ``REDIS_1_AUTH`` - define password of the Redis server
+* ``ADMIN_USER`` - define username for user-facing Basic Auth
+* ``ADMIN_PASS`` - define password for user-facing Basic Auth
+
TODO
====
From 7a8c84b4af5b07686f78e2b644c8157b879fc431 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 14 Jun 2019 05:45:25 +0000
Subject: [PATCH 031/107] Fix PHP 7.3 compatibility
Fixes #143
---
composer.json | 2 +-
composer.lock | 16 +++++++++-------
includes/common.inc.php | 2 +-
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/composer.json b/composer.json
index 34b18cc..c741447 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
}
],
"require": {
- "predis/predis": "1.1.1"
+ "predis/predis": "1.1.x-dev"
},
"minimum-stability": "stable",
"target-dir": "ErikDubbelboer/phpRedisAdmin"
diff --git a/composer.lock b/composer.lock
index c07bb64..ac3a614 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "e2489e7a22a6412f072878dd7c867843",
+ "content-hash": "0c346d5e2f2e0897260911e1b2966180",
"packages": [
{
"name": "predis/predis",
- "version": "v1.1.1",
+ "version": "v1.1.x-dev",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
- "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1"
+ "reference": "111d100ee389d624036b46b35ed0c9ac59c71313"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
- "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
+ "url": "https://api.github.com/repos/nrk/predis/zipball/111d100ee389d624036b46b35ed0c9ac59c71313",
+ "reference": "111d100ee389d624036b46b35ed0c9ac59c71313",
"shasum": ""
},
"require": {
@@ -54,13 +54,15 @@
"predis",
"redis"
],
- "time": "2016-06-16T16:22:20+00:00"
+ "time": "2017-07-12T14:39:17+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": [],
+ "stability-flags": {
+ "predis/predis": 20
+ },
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
diff --git a/includes/common.inc.php b/includes/common.inc.php
index e8f1cd1..367c539 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -7,7 +7,7 @@
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST);
- while (list($key, $val) = each($process)) {
+ foreach ($process as $key => $val) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
From de084f5b1581ac4e23f8dc507308f6e5a4d61590 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 14 Jun 2019 05:45:42 +0000
Subject: [PATCH 032/107] Improve Dockerfile
Change order so layers can be cached more properly.
---
Dockerfile | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 0597c23..bdd0a48 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,15 +1,14 @@
FROM composer:1.7
-ADD . /src/app/
-WORKDIR /src/app
-
ENV TINI_VERSION 0.18.0-r0
-RUN \
- apk add --no-cache tini=$TINI_VERSION && \
- composer install && \
- cp includes/config.environment.inc.php includes/config.inc.php
+RUN apk add --no-cache tini=$TINI_VERSION
+RUN composer install
-EXPOSE 80
+ADD . /src/app/
+
+RUN cp includes/config.environment.inc.php includes/config.inc.php
+WORKDIR /src/app
+EXPOSE 80
ENTRYPOINT [ "tini", "--", "php", "-S", "0.0.0.0:80" ]
From 83ca06f519dd69422b7b7c4d49e4bdd10b86b395 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 14 Jun 2019 05:46:41 +0000
Subject: [PATCH 033/107] v1.11.2
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index c741447..188d1aa 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.11.1",
+ "version": "1.11.2",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 534bfe411e59dc2733387fc11ad109f770c1f8b6 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 14 Jun 2019 06:05:19 +0000
Subject: [PATCH 034/107] Fix Dockerfile
---
Dockerfile | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index bdd0a48..fd40ac1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,12 +3,14 @@ FROM composer:1.7
ENV TINI_VERSION 0.18.0-r0
RUN apk add --no-cache tini=$TINI_VERSION
-RUN composer install
ADD . /src/app/
+WORKDIR /src/app
+
+RUN composer install
+
RUN cp includes/config.environment.inc.php includes/config.inc.php
-WORKDIR /src/app
EXPOSE 80
ENTRYPOINT [ "tini", "--", "php", "-S", "0.0.0.0:80" ]
From 9d37b0957f8cd90fa4e13ceddb956d85989224d8 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 14 Jun 2019 06:31:32 +0000
Subject: [PATCH 035/107] v1.11.3
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 188d1aa..f837aef 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.11.2",
+ "version": "1.11.3",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From df4f1e8dd7e773eebe88218510d90ef1161b1a39 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Tue, 2 Jul 2019 13:40:23 +0000
Subject: [PATCH 036/107] Show for empty key names
---
index.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/index.php b/index.php
index e575b2c..8e695e0 100644
--- a/index.php
+++ b/index.php
@@ -96,6 +96,9 @@ function print_namespace($item, $name, $fullkey, $islast) {
}
}
+ if (empty($name)) {
+ $name = '';
+ }
?>
>
From 4c0c99cd8d1289b389d9b9a4cc3dbdba2d75acc7 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Tue, 2 Jul 2019 13:43:58 +0000
Subject: [PATCH 037/107] v1.11.4
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index f837aef..5199506 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.11.3",
+ "version": "1.11.4",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 913fac2159b922f0a9e335916fc6fa57606acd5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=80=E9=A2=97=E7=BA=A2=E5=BF=83?=
Date: Mon, 19 Aug 2019 16:41:27 +0800
Subject: [PATCH 038/107] Add features: batch delete (#145)
* Add features: batch delete
---
delete.php | 13 +++++++++++++
index.php | 6 +++++-
js/index.js | 36 +++++++++++++++++++++++++++++++++++-
3 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/delete.php b/delete.php
index df51bee..cde8539 100644
--- a/delete.php
+++ b/delete.php
@@ -60,4 +60,17 @@
die('?view&s='.$server['id'].'&d='.$server['db']);
}
+if (isset($_GET['batch_del'])) {
+ $keys = $_POST['selected_keys'];
+ $keys = trim($keys, ',');
+ if (empty($keys)) die('No keys to delete');
+
+ $keys = explode(',', $keys);
+ foreach ($keys as $key) {
+ $redis->del($key);
+ }
+
+ die('?view&s=' . $server['id'] . '&d=' . $server['db'] . '&key=' . urlencode($keys[0]));
+}
+
?>
diff --git a/index.php b/index.php
index 8e695e0..ae5ad90 100644
--- a/index.php
+++ b/index.php
@@ -102,6 +102,7 @@ function print_namespace($item, $name, $fullkey, $islast) {
?>
>
+
()
-
+Select all
+
+Delete selected
+
diff --git a/js/index.js b/js/index.js
index b440a77..de45790 100644
--- a/js/index.js
+++ b/js/index.js
@@ -1,6 +1,40 @@
$(function() {
+ $('#selected_all_keys').on('click', function () {
+ if ($(this).html()=='Select all'){
+ $('input[name=checked_keys]').each(function () {
+ $(this).attr('checked', 'checked');
+ });
+ $(this).html('Select none');
+ }else {
+ $('input[name=checked_keys]').each(function () {
+ $(this).removeAttr('checked');
+ });
+ $(this).html('Select all');
+ }
+ })
+
$('#sidebar').on('click', 'a', function(e) {
- if (e.currentTarget.className.indexOf('deltree') !== -1) {
+ if (e.currentTarget.className.indexOf('batch_del') !== -1){
+ e.preventDefault();
+ var selected_keys = '';
+ $('input[name=checked_keys]:checked').each(function () {
+ selected_keys += $(this).val() + ',';
+ });
+ if (!selected_keys) {
+ alert('Please select the keys you want to delete.');
+ return;
+ }
+ if (confirm('Are you sure you want to delete all selected keys?')) {
+ $.ajax({
+ type: "POST",
+ url: this.href,
+ data: 'post=1&selected_keys=' + selected_keys,
+ success: function(url) {
+ top.location.href = top.location.pathname+url;
+ }
+ });
+ }
+ }else if (e.currentTarget.className.indexOf('deltree') !== -1) {
e.preventDefault();
if (confirm('Are you sure you want to delete this whole tree and all it\'s keys?')) {
From a858f60baea28405b0373ddf42fc77a56bc10820 Mon Sep 17 00:00:00 2001
From: Atef Ben Ali
Date: Thu, 19 Sep 2019 12:04:45 +0100
Subject: [PATCH 039/107] style: remove `?>` php ending tag (#146)
The `?>` ending tag is optional in a pure `php` file.
---
includes/config.sample.inc.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index 558f231..10e043d 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -81,5 +81,3 @@
// How many entries to fetch using each SCAN command.
'scansize' => 1000
);
-
-?>
From 0e8e4724be4016f75608aafd1c260b6f3350c490 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 27 Sep 2019 20:10:43 +0000
Subject: [PATCH 040/107] Make all paths relative
---
edit.php | 2 +-
export.php | 2 +-
import.php | 2 +-
includes/functions.inc.php | 3 +++
logout.php | 4 +---
rename.php | 2 +-
ttl.php | 2 +-
7 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/edit.php b/edit.php
index 4842655..0940503 100644
--- a/edit.php
+++ b/edit.php
@@ -144,7 +144,7 @@
?>
-
+
+ scaned keys= $server['scanmax']) ? ', reached scanmax' : '' ?>
+
From 47f4c678f0cca20709a2587c2704c0ec612de189 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sat, 21 Sep 2024 16:10:00 +0200
Subject: [PATCH 097/107] v1.21.1
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 1052799..29d6261 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.21.0",
+ "version": "1.21.1",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From c8fc6a08e4f05c710daa9c8a695f54b7aba498f2 Mon Sep 17 00:00:00 2001
From: "Helmut K. C. Tessarek"
Date: Sun, 8 Dec 2024 10:35:59 +0100
Subject: [PATCH 098/107] fix: scanmax behavior (#212)
* fix: typo
* fix: scanmax behavior
---
includes/common.inc.php | 12 ++++++++++++
includes/config.sample.inc.php | 5 ++++-
index.php | 8 +++-----
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/includes/common.inc.php b/includes/common.inc.php
index 075ca16..c13424b 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -95,10 +95,22 @@
$server['keys'] = $config['keys'];
}
+if (!isset($config['scansize'])) {
+ $config['scansize'] = 1000;
+}
+
+if (!isset($config['scanmax'])) {
+ $config['scanmax'] = 0;
+}
+
if (!isset($server['scansize'])) {
$server['scansize'] = $config['scansize'];
}
+if (!isset($server['scanmax'])) {
+ $server['scanmax'] = $config['scanmax'];
+}
+
if (!isset($server['serialization'])) {
if (isset($config['serialization'])) {
$server['serialization'] = $config['serialization'];
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index 13f4a2c..2732d97 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -33,7 +33,7 @@
'charset' => 'cp1251', // Keys and values are stored in redis using this encoding (default utf-8).
'keys' => false, // Use the old KEYS command instead of SCAN to fetch all keys for this server (default uses config default).
'scansize' => 1000, // How many entries to fetch using each SCAN command for this server (default uses config default).
- 'scanmax' => 1000, // In each query, SCAN command may be executed several times. To shorten the duration, it is recommended to limit the total number of entries to fetch.
+ 'scanmax' => 1000, // In each query, SCAN command may be executed several times. To shorten the duration, it is recommended to limit the total number of entries to fetch (default uses config default).
),*/
),
@@ -85,4 +85,7 @@
// How many entries to fetch using each SCAN command.
'scansize' => 1000
+
+ // The total number of entries to fetch. Set to 0 or -1 for no limit.
+ 'scanmax' => 0
);
diff --git a/index.php b/index.php
index 056abeb..b513947 100644
--- a/index.php
+++ b/index.php
@@ -10,18 +10,16 @@
} else {
$next = 0;
$keys = array();
- $scansize = $server['scansize'];
while (true) {
- $r = $redis->scan($next, 'MATCH', $server['filter'], 'COUNT', $scansize);
+ $r = $redis->scan($next, 'MATCH', $server['filter'], 'COUNT', $server['scansize']);
$next = $r[0];
$keys = array_merge($keys, $r[1]);
if ($next == 0) {
break;
}
- if (count($keys) >= $server['scanmax']) {
+ if ($server['scanmax'] > 0 && count($keys) >= $server['scanmax']) {
break;
}
- $scansize = min($server['scanmax'] - count($keys), $server['scansize']);
}
}
@@ -255,7 +253,7 @@ function getDbInfo($d, $info, $padding = '') {
- scaned keys= $server['scanmax']) ? ', reached scanmax' : '' ?>
+ scanned keys 0 && count($keys) >= $server['scanmax']) ? ', reached scanmax' : '' ?>
From 644162e932230d8eef642ebce327260a4dd54b0a Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sun, 8 Dec 2024 10:41:43 +0100
Subject: [PATCH 099/107] v1.22.0
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 29d6261..475fd18 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.21.1",
+ "version": "1.22.0",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 5e8c6ecb19e68988994ac20a1dff30b3fa65cf3e Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Mon, 9 Dec 2024 13:04:25 +0100
Subject: [PATCH 100/107] Add missing ,
Fixes: https://github.com/erikdubbelboer/phpRedisAdmin/issues/202
---
includes/config.sample.inc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index 2732d97..cca5b81 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -84,7 +84,7 @@
'keys' => false,
// How many entries to fetch using each SCAN command.
- 'scansize' => 1000
+ 'scansize' => 1000,
// The total number of entries to fetch. Set to 0 or -1 for no limit.
'scanmax' => 0
From 3e60b217dae70e0be700202c2fb3d4cf46ac02fe Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Mon, 9 Dec 2024 13:05:05 +0100
Subject: [PATCH 101/107] v1.22.1
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 475fd18..a851fe6 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.22.0",
+ "version": "1.22.1",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 543cbc7997874fae7967aaaa85bf190a6b24d0b4 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 20 Dec 2024 07:28:42 +0000
Subject: [PATCH 102/107] Upgrade predis to v2.3.0
Fixes a bug with $server['scheme'] and simplifies some of the config
code.
Fixes https://github.com/erikdubbelboer/phpRedisAdmin/issues/214
---
composer.json | 2 +-
composer.lock | 42 ++++++++++++++++++++---------------------
includes/common.inc.php | 24 +++++++++++------------
3 files changed, 33 insertions(+), 35 deletions(-)
diff --git a/composer.json b/composer.json
index a851fe6..5c6d433 100644
--- a/composer.json
+++ b/composer.json
@@ -15,7 +15,7 @@
"require": {
"ext-mbstring": "*",
"ext-json": "*",
- "predis/predis": "v1.1.9",
+ "predis/predis": "v2.3.0",
"paragonie/random_compat": ">=2"
},
"minimum-stability": "stable",
diff --git a/composer.lock b/composer.lock
index 41f9438..f724f31 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "ad3fb9bfb043b086870b317dc9eff9b7",
+ "content-hash": "401ff61cebe5223d003a47192d7c3d6a",
"packages": [
{
"name": "paragonie/random_compat",
@@ -58,27 +58,28 @@
},
{
"name": "predis/predis",
- "version": "v1.1.9",
+ "version": "v2.3.0",
"source": {
"type": "git",
"url": "https://github.com/predis/predis.git",
- "reference": "c50c3393bb9f47fa012d0cdfb727a266b0818259"
+ "reference": "bac46bfdb78cd6e9c7926c697012aae740cb9ec9"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/predis/predis/zipball/c50c3393bb9f47fa012d0cdfb727a266b0818259",
- "reference": "c50c3393bb9f47fa012d0cdfb727a266b0818259",
+ "url": "https://api.github.com/repos/predis/predis/zipball/bac46bfdb78cd6e9c7926c697012aae740cb9ec9",
+ "reference": "bac46bfdb78cd6e9c7926c697012aae740cb9ec9",
"shasum": ""
},
"require": {
- "php": ">=5.3.9"
+ "php": "^7.2 || ^8.0"
},
"require-dev": {
- "phpunit/phpunit": "~4.8"
+ "friendsofphp/php-cs-fixer": "^3.3",
+ "phpstan/phpstan": "^1.9",
+ "phpunit/phpunit": "^8.0 || ^9.4"
},
"suggest": {
- "ext-curl": "Allows access to Webdis when paired with phpiredis",
- "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
+ "ext-relay": "Faster connection with in-memory caching (>=0.6.2)"
},
"type": "library",
"autoload": {
@@ -91,19 +92,13 @@
"MIT"
],
"authors": [
- {
- "name": "Daniele Alessandri",
- "email": "suppakilla@gmail.com",
- "homepage": "http://clorophilla.net/",
- "role": "Creator & Maintainer"
- },
{
"name": "Till Krüss",
"homepage": "https://till.im/",
"role": "Maintainer"
}
],
- "description": "Flexible and feature-complete Redis client for PHP and HHVM",
+ "description": "A flexible and feature-complete Redis client for PHP.",
"homepage": "http://github.com/predis/predis",
"keywords": [
"nosql",
@@ -112,7 +107,7 @@
],
"support": {
"issues": "https://github.com/predis/predis/issues",
- "source": "https://github.com/predis/predis/tree/v1.1.9"
+ "source": "https://github.com/predis/predis/tree/v2.3.0"
},
"funding": [
{
@@ -120,16 +115,19 @@
"type": "github"
}
],
- "time": "2021-10-05T19:02:38+00:00"
+ "time": "2024-11-21T20:00:02+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": [],
+ "stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
- "platform": [],
- "platform-dev": [],
- "plugin-api-version": "2.1.0"
+ "platform": {
+ "ext-mbstring": "*",
+ "ext-json": "*"
+ },
+ "platform-dev": {},
+ "plugin-api-version": "2.6.0"
}
diff --git a/includes/common.inc.php b/includes/common.inc.php
index c13424b..a92a3ed 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -95,20 +95,20 @@
$server['keys'] = $config['keys'];
}
-if (!isset($config['scansize'])) {
- $config['scansize'] = 1000;
-}
-
-if (!isset($config['scanmax'])) {
- $config['scanmax'] = 0;
-}
-
if (!isset($server['scansize'])) {
- $server['scansize'] = $config['scansize'];
+ if (isset($config['scansize'])) {
+ $server['scansize'] = $config['scansize'];
+ } else {
+ $server['scansize'] = 1000;
+ }
}
if (!isset($server['scanmax'])) {
- $server['scanmax'] = $config['scanmax'];
+ if (isset($config['scanmax'])) {
+ $server['scanmax'] = $config['scanmax'];
+ } else {
+ $server['scanmax'] = 0;
+ }
}
if (!isset($server['serialization'])) {
@@ -125,8 +125,8 @@
$config['showEmptyNamespaceAsKey'] = false;
}
-if (!isset($config['scheme']) || empty($config['scheme'])) {
- $config['scheme'] = 'tcp';
+if (!isset($server['scheme']) || empty($server['scheme'])) {
+ $server['scheme'] = 'tcp';
}
// Setup a connection to Redis.
From 6f9fae06b4edeaa758113407d90b4a3d2915ad76 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 20 Dec 2024 08:31:12 +0100
Subject: [PATCH 103/107] v1.23.0
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 5c6d433..fb69cc8 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.22.1",
+ "version": "1.23.0",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From dc8fce6df5385c7e3c12e8f10ed40a6d9bd5fb01 Mon Sep 17 00:00:00 2001
From: Wildan M
Date: Wed, 26 Mar 2025 11:03:53 +0700
Subject: [PATCH 104/107] Handle permission access errors (#216)
---
css/frame.css | 10 +++++
edit.php | 115 +++++++++++++++++++++++++++-----------------------
index.php | 8 +++-
view.php | 14 +++++-
4 files changed, 92 insertions(+), 55 deletions(-)
diff --git a/css/frame.css b/css/frame.css
index 8969e10..7cf935d 100644
--- a/css/frame.css
+++ b/css/frame.css
@@ -52,3 +52,13 @@ float: left;
margin: 1em;
}
+
+.exception {
+border: 1px solid #ff0000;
+background-color: rgba(255, 0, 0, 0.2);
+color: #880000;
+padding: 10px;
+border-radius: 5px;
+margin: 20px;
+}
+
diff --git a/edit.php b/edit.php
index 4424d24..998012c 100644
--- a/edit.php
+++ b/edit.php
@@ -34,72 +34,83 @@
die('ERROR: could not encode value');
}
- // String
- if ($_POST['type'] == 'string') {
- $redis->set($key, $value);
- }
-
- // Hash
- else if (($_POST['type'] == 'hash') && isset($_POST['hkey'])) {
- if (strlen($_POST['hkey']) > $config['maxkeylen']) {
- die('ERROR: Your hash key is to long (max length is '.$config['maxkeylen'].')');
+ try {
+ // String
+ if ($_POST['type'] == 'string') {
+ $redis->set($key, $value);
}
- if ($edit && !$redis->hExists($key, input_convert($_POST['hkey']))) {
- $redis->hDel($key, input_convert($_GET['hkey']));
+ // Hash
+ else if (($_POST['type'] == 'hash') && isset($_POST['hkey'])) {
+ if (strlen($_POST['hkey']) > $config['maxkeylen']) {
+ die('ERROR: Your hash key is to long (max length is '.$config['maxkeylen'].')');
+ }
+
+ if ($edit && !$redis->hExists($key, input_convert($_POST['hkey']))) {
+ $redis->hDel($key, input_convert($_GET['hkey']));
+ }
+
+ $redis->hSet($key, input_convert($_POST['hkey']), $value);
}
- $redis->hSet($key, input_convert($_POST['hkey']), $value);
- }
+ // List
+ else if (($_POST['type'] == 'list') && isset($_POST['index'])) {
+ $size = $redis->lLen($key);
+
+ if (($_POST['index'] == '') ||
+ ($_POST['index'] == $size)) {
+ // Push it at the end
+ $redis->rPush($key, $value);
+ } else if ($_POST['index'] == -1) {
+ // Push it at the start
+ $redis->lPush($key, $value);
+ } else if (($_POST['index'] >= 0) &&
+ ($_POST['index'] < $size)) {
+ // Overwrite an index
+ $redis->lSet($key, input_convert($_POST['index']), $value);
+ } else {
+ die('ERROR: Out of bounds index');
+ }
+ }
- // List
- else if (($_POST['type'] == 'list') && isset($_POST['index'])) {
- $size = $redis->lLen($key);
-
- if (($_POST['index'] == '') ||
- ($_POST['index'] == $size)) {
- // Push it at the end
- $redis->rPush($key, $value);
- } else if ($_POST['index'] == -1) {
- // Push it at the start
- $redis->lPush($key, $value);
- } else if (($_POST['index'] >= 0) &&
- ($_POST['index'] < $size)) {
- // Overwrite an index
- $redis->lSet($key, input_convert($_POST['index']), $value);
- } else {
- die('ERROR: Out of bounds index');
+ // Set
+ else if ($_POST['type'] == 'set') {
+ if ($_POST['value'] != $_POST['oldvalue']) {
+ // The only way to edit a Set value is to add it and remove the old value.
+ $redis->sRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue'])));
+ $redis->sAdd($key, $value);
+ }
}
- }
- // Set
- else if ($_POST['type'] == 'set') {
- if ($_POST['value'] != $_POST['oldvalue']) {
- // The only way to edit a Set value is to add it and remove the old value.
- $redis->sRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue'])));
- $redis->sAdd($key, $value);
+ // ZSet
+ else if (($_POST['type'] == 'zset') && isset($_POST['score']) && is_numeric($_POST['score'])) {
+ // The only way to edit a ZSet value is to add it and remove the old value.
+ $redis->zRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue'])));
+ $redis->zAdd($key, input_convert($_POST['score']), $value);
}
- }
- // ZSet
- else if (($_POST['type'] == 'zset') && isset($_POST['score']) && is_numeric($_POST['score'])) {
- // The only way to edit a ZSet value is to add it and remove the old value.
- $redis->zRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue'])));
- $redis->zAdd($key, input_convert($_POST['score']), $value);
- }
+ // Refresh the top so the key tree is updated.
+ require 'includes/header.inc.php';
- // Refresh the top so the key tree is updated.
- require 'includes/header.inc.php';
+ ?>
+
+
-
-
+
+
getMessage() ?>
+
+ type($fullkey)) {
+ $type = '';
+ try {
+ $type = $redis->type($fullkey);
+ } catch (\Predis\Response\ServerException $th) {
+ $class[] = 'empty';
+ }
+ switch ($type) {
case 'hash':
$len = $redis->hLen($fullkey);
break;
diff --git a/view.php b/view.php
index 1836979..0fdb1b5 100644
--- a/view.php
+++ b/view.php
@@ -17,8 +17,18 @@
die;
}
-$type = $redis->type($_GET['key']);
-$exists = $redis->exists($_GET['key']);
+$type = '';
+$exists = false;
+try {
+ $type = $redis->type($_GET['key']);
+ $exists = $redis->exists($_GET['key']);
+} catch (\Predis\Response\ServerException $th) {
+ ?>
+
+
getMessage() ?>
+
+
Date: Sat, 29 Mar 2025 12:04:03 +0700
Subject: [PATCH 105/107] Change TTL input type (#217)
---
ttl.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ttl.php b/ttl.php
index 92e6cca..c5d7a88 100644
--- a/ttl.php
+++ b/ttl.php
@@ -31,7 +31,7 @@
TTL :
- > (-1 to remove the TTL)
+ > (-1 to remove the TTL)
From 2d977bce2a3225bacf9ab04ba0ca27c5d58324ab Mon Sep 17 00:00:00 2001
From: Wildan M
Date: Mon, 31 Mar 2025 11:33:09 +0700
Subject: [PATCH 106/107] Implement ACL login (#218)
* Implement ACL login
* Make password form optional
---
includes/common.inc.php | 3 +
includes/config.sample.inc.php | 6 ++
includes/login_acl.inc.php | 100 +++++++++++++++++++++++++++++++++
login.php | 2 +-
logout.php | 4 ++
overview.php | 33 ++++++++---
6 files changed, 138 insertions(+), 10 deletions(-)
create mode 100644 includes/login_acl.inc.php
diff --git a/includes/common.inc.php b/includes/common.inc.php
index a92a3ed..78e791f 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -148,6 +148,9 @@
}
}
+if (!isset($config['login']) && !empty($config['login_as_acl_auth'])) {
+ require_once PHPREDIS_ADMIN_PATH . '/includes/login_acl.inc.php';
+}
if ($server['db'] != 0) {
if (!$redis->select($server['db'])) {
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index cca5b81..923a60c 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -61,6 +61,12 @@
)
),*/
+ // Uncomment to enable login as ACL authentication (won't work if 'login' or 'auth' is also used)
+ // Only support using one server at this moment.
+ // If you set the default user off, browsers will be redirected to login page.
+ // The user and password will be stored in browser as plaintext so using HTTPS is strongly recommended.
+ // 'login_as_acl_auth' => true,
+
// Use HTML form/cookie-based auth instead of HTTP Basic/Digest auth
'cookie_auth' => false,
diff --git a/includes/login_acl.inc.php b/includes/login_acl.inc.php
new file mode 100644
index 0000000..e8b7d72
--- /dev/null
+++ b/includes/login_acl.inc.php
@@ -0,0 +1,100 @@
+auth($login['username'], $login['password']);
+ } catch (Predis\Response\ServerException $exception) {
+ return false;
+ }
+ return true;
+}
+
+// This fill will perform HTTP basic authentication. The authentication data will be sent and stored as plaintext
+// Please make sure to use HTTPS proxy such as Apache or Nginx to prevent traffic eavesdropping.
+function authHttpBasic()
+{
+ $realm = 'phpRedisAdmin';
+
+ if (!isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
+ try {
+ global $redis;
+ $redis->ping();
+ } catch (Predis\Response\ServerException $exception) {
+ header('HTTP/1.1 401 Unauthorized');
+ header('WWW-Authenticate: Basic realm="' . $realm . '"');
+ die('NOAUTH -- Authentication required');
+ }
+ }
+
+ $login = [
+ 'username' => $_SERVER['PHP_AUTH_USER'],
+ 'password' => $_SERVER['PHP_AUTH_PW'],
+ ];
+
+ if (!authCheck($login)) {
+ header('HTTP/1.1 401 Unauthorized');
+ header('WWW-Authenticate: Basic realm="' . $realm . '"');
+ die('NOAUTH -- Authentication required');
+ }
+
+ return $login;
+}
+
+// Perform auth using a standard HTML submission and cookies to save login state
+function authCookie()
+{
+ if (!empty($_COOKIE['phpRedisAdminLogin'])) {
+ // We have a cookie; is it correct?
+ // Cookie value looks like "username:password-hash"
+ $login = explode(':', $_COOKIE['phpRedisAdminLogin'], 2);
+ if (count($login) === 2) {
+ $login = [
+ 'username' => $login[0],
+ 'password' => $login[1],
+ ];
+ if (authCheck($login)) {
+ return $login;
+ }
+ }
+ }
+
+ if (isset($_POST['username'], $_POST['password'])) {
+ // Login form submitted; correctly?
+ $login = [
+ 'username' => $_POST['username'],
+ 'password' => $_POST['password'],
+ ];
+
+ if (authCheck($login)) {
+ setcookie('phpRedisAdminLogin', $login['username'] . ':' . $login['password']);
+ // This should be an absolute URL, but that's a bit of a pain to generate; this will work
+ header("Location: index.php");
+ die();
+ }
+ }
+
+ try {
+ global $redis;
+ $redis->ping();
+ } catch (Predis\Response\ServerException $exception) {
+ // If we're here, we don't have a valid login cookie and we don't have a
+ // valid form submission, so redirect to the login page if we aren't
+ // already on that page
+ if (!defined('LOGIN_PAGE')) {
+ header("Location: login.php");
+ die();
+ }
+ }
+
+ // We must be on the login page without a valid cookie or submission
+ return null;
+}
+
+if (!empty($config['cookie_auth'])) {
+ $login = authCookie();
+} else {
+ $login = authHttpBasic();
+}
diff --git a/login.php b/login.php
index a80a24c..5c12301 100644
--- a/login.php
+++ b/login.php
@@ -33,7 +33,7 @@
Password
>
+ = isset($_POST['username']) ? 'autofocus' : '' ?>>
Log in
diff --git a/logout.php b/logout.php
index 12cc80b..07e10ae 100644
--- a/logout.php
+++ b/logout.php
@@ -8,6 +8,10 @@
setcookie('phpRedisAdminLogin', '', 1);
header("Location: login.php");
die();
+} else if (isset($config['login_as_acl_auth'])) {
+ // HTTP Basic auth
+ header('HTTP/1.1 401 Unauthorized');
+ die(' ');
} else {
// HTTP Digest auth
$needed_parts = array(
diff --git a/overview.php b/overview.php
index 3e426db..5c67370 100644
--- a/overview.php
+++ b/overview.php
@@ -10,16 +10,24 @@
$server['db'] = 0;
}
- // Setup a connection to Redis.
- if(isset($server['scheme']) && $server['scheme'] === 'unix' && $server['path']) {
- $redis = new Predis\Client(array('scheme' => 'unix', 'path' => $server['path']));
+
+ if (isset($config['login_as_acl_auth'])) {
+ // Currently only support one server at a time
+ if ($i > 0) {
+ break;
+ }
} else {
- $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']);
- }
- try {
- $redis->connect();
- } catch (Predis\CommunicationException $exception) {
- $redis = false;
+ // Setup a connection to Redis.
+ if(isset($server['scheme']) && $server['scheme'] === 'unix' && $server['path']) {
+ $redis = new Predis\Client(array('scheme' => 'unix', 'path' => $server['path']));
+ } else {
+ $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']);
+ }
+ try {
+ $redis->connect();
+ } catch (Predis\CommunicationException $exception) {
+ $redis = false;
+ }
}
if(!$redis) {
@@ -38,6 +46,9 @@
$info[$i] = $redis->info();
$info[$i]['size'] = $redis->dbSize();
+ if (isset($config['login_as_acl_auth'])) {
+ $info[$i]['username'] = $redis->acl->whoami();
+ }
if (!isset($info[$i]['Server'])) {
$info[$i]['Server'] = array(
@@ -83,6 +94,10 @@
Uptime:
+
+ Username:
+
+
Last save:
Date: Mon, 31 Mar 2025 06:36:23 +0200
Subject: [PATCH 107/107] v1.24.0
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index fb69cc8..3b3ab81 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "erik-dubbelboer/php-redis-admin",
"description": "Simple web interface to manage Redis databases.",
- "version": "1.23.0",
+ "version": "1.24.0",
"license": "CC-BY-3.0",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [