+
@@ -155,7 +155,7 @@
Key
Value
$value) { ?>
-
>
+
>
@@ -183,7 +183,7 @@
for ($i = $start; $i < $end; ++$i) {
$value = $redis->lIndex($_GET['key'], $i);
?>
-
>
+
>
@@ -202,7 +202,7 @@
Value
exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
+ $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value, $server['charset'])).' ' : nl2br(format_html($value, $server['charset']));
?>
>
@@ -223,7 +223,7 @@
zScore($_GET['key'], $value);
- $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
+ $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value, $server['charset'])).' ' : nl2br(format_html($value, $server['charset']));
?>
>
From d08677a05936965b7f9e8acaa83d6bd093505951 Mon Sep 17 00:00:00 2001
From: wason
Date: Thu, 17 Apr 2014 16:20:38 +0800
Subject: [PATCH 009/147] Added server key filter input and buttom on sidebar
---
css/index.css | 2 +-
includes/common.inc.php | 8 ++++++++
index.php | 5 +++++
js/index.js | 12 +++++++++++-
4 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/css/index.css b/css/index.css
index 228e00b..6fa6dda 100644
--- a/css/index.css
+++ b/css/index.css
@@ -25,7 +25,7 @@ text-decoration: underline;
#keys {
position: fixed;
-top: 15.5em;
+top: 18.5em;
bottom: 0;
width: 24em;
padding-bottom: 1em;
diff --git a/includes/common.inc.php b/includes/common.inc.php
index 04d7c01..7eb260c 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -78,6 +78,14 @@
$server['filter'] = '*';
}
+// filter from GET param
+if (isset($_GET['filter']) && $_GET['filter'] != '') {
+ $server['filter'] = $_GET['filter'];
+ if (strpos($server['filter'], '*') === false) {
+ $server['filter'].= '*';
+ }
+}
+
if (!isset($server['seperator'])) {
$server['seperator'] = $config['seperator'];
}
diff --git a/index.php b/index.php
index 5bf3c53..5f1be31 100644
--- a/index.php
+++ b/index.php
@@ -175,6 +175,11 @@ function print_namespace($item, $name, $fullkey, $islast) {
Add another key
+
+
+Filter!
+
+
diff --git a/js/index.js b/js/index.js
index 9886aa6..545add0 100644
--- a/js/index.js
+++ b/js/index.js
@@ -20,7 +20,7 @@ $(function() {
href += '.php';
}
}
-
+
if (href.indexOf('flush.php') == 0) {
if (confirm('Are you sure you want to delete this key and all it\'s values?')) {
$.ajax({
@@ -69,6 +69,16 @@ $(function() {
$(this).parent().addClass('current');
});
+ $('#btn_server_filter').click(function() {
+ var filter = $('#server_filter').val();
+ location.href = top.location.pathname + '?overview&s=' + $('#server').val() + '&filter=' + filter;
+ });
+
+ $('#server_filter').keydown(function(e){
+ if (e.keyCode == 13) {
+ $('#btn_server_filter').click();
+ }
+ });
$('#filter').focus(function() {
if ($(this).hasClass('info')) {
From b4446e2877b31a575e5160fd754f0495b587b585 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Thu, 24 Apr 2014 08:53:37 +0000
Subject: [PATCH 010/147] Fixed #46
---
includes/functions.inc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/functions.inc.php b/includes/functions.inc.php
index 0a4eb7d..3f49f4b 100644
--- a/includes/functions.inc.php
+++ b/includes/functions.inc.php
@@ -2,7 +2,7 @@
function format_html($str, $from_encoding = FALSE) {
$res = $from_encoding ? mb_convert_encoding($str, 'utf-8', $from_encoding) : $str;
- $res = htmlentities($res, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8');
+ $res = htmlentities($res, defined('ENT_SUBSTITUTE') ? (ENT_QUOTES | ENT_SUBSTITUTE) : ENT_QUOTES, 'utf-8');
return ($res || !$str) ? $res : '(' . strlen($str) . ' bytes)';
}
From c7d22a1ecd638b80e26e66978410f5943877e958 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Thu, 26 Jun 2014 18:07:04 +0000
Subject: [PATCH 011/147] Fixed the idea of #49
---
composer.json | 2 +-
includes/header.inc.php | 6 ++++--
index.php | 3 +--
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/composer.json b/composer.json
index 24fb027..fd6edaf 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.1.0",
+ "version": "1.1.1",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
diff --git a/includes/header.inc.php b/includes/header.inc.php
index 368da14..aa618f1 100644
--- a/includes/header.inc.php
+++ b/includes/header.inc.php
@@ -1,5 +1,7 @@
- phpRedisAdmin
-
+
-
+
diff --git a/index.php b/index.php
index 5f1be31..d142f99 100644
--- a/index.php
+++ b/index.php
@@ -49,7 +49,6 @@ function print_namespace($item, $name, $fullkey, $islast) {
// Unset it so we won't loop over it when printing this namespace.
unset($item['__phpredisadmin__']);
- $type = $redis->type($fullkey);
$class = array();
$len = false;
@@ -62,7 +61,7 @@ function print_namespace($item, $name, $fullkey, $islast) {
// Get the number of items in the key.
if (!isset($config['faster']) || !$config['faster']) {
- switch ($type) {
+ switch ($redis->type($fullkey)) {
case 'hash':
$len = $redis->hLen($fullkey);
break;
From 6c1e10212596b576f142414cf7667616727961ac Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Thu, 7 Aug 2014 01:25:34 +0000
Subject: [PATCH 012/147] Fix issue #55
---
index.php | 6 ++----
view.php | 4 ++--
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/index.php b/index.php
index d142f99..61323f4 100644
--- a/index.php
+++ b/index.php
@@ -71,13 +71,11 @@ function print_namespace($item, $name, $fullkey, $islast) {
break;
case 'set':
- // This is currently the only way to do this, this can be slow since we need to retrieve all keys
- $len = count($redis->sMembers($fullkey));
+ $len = count($redis->sCard($fullkey));
break;
case 'zset':
- // This is currently the only way to do this, this can be slow since we need to retrieve all keys
- $len = count($redis->zRange($fullkey, 0, -1));
+ $len = count($redis->zCard($fullkey));
break;
}
}
diff --git a/view.php b/view.php
index 8d86371..1fba1a2 100644
--- a/view.php
+++ b/view.php
@@ -76,12 +76,12 @@
break;
case 'set':
- $values = $redis->sMembers($_GET['key']);
+ $values = $redis->sCard($_GET['key']);
$size = count($values);
break;
case 'zset':
- $values = $redis->zRange($_GET['key'], 0, -1);
+ $values = $redis->zCard($_GET['key']);
$size = count($values);
break;
}
From 94fb92e8befb35e43bd91fefa4633545f4017878 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Thu, 14 Aug 2014 18:36:09 +0000
Subject: [PATCH 013/147] Fixed bugs in previous commit
---
index.php | 4 ++--
view.php | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/index.php b/index.php
index 61323f4..b768ecb 100644
--- a/index.php
+++ b/index.php
@@ -71,11 +71,11 @@ function print_namespace($item, $name, $fullkey, $islast) {
break;
case 'set':
- $len = count($redis->sCard($fullkey));
+ $len = $redis->sCard($fullkey);
break;
case 'zset':
- $len = count($redis->zCard($fullkey));
+ $len = $redis->zCard($fullkey);
break;
}
}
diff --git a/view.php b/view.php
index 1fba1a2..8d86371 100644
--- a/view.php
+++ b/view.php
@@ -76,12 +76,12 @@
break;
case 'set':
- $values = $redis->sCard($_GET['key']);
+ $values = $redis->sMembers($_GET['key']);
$size = count($values);
break;
case 'zset':
- $values = $redis->zCard($_GET['key']);
+ $values = $redis->zRange($_GET['key'], 0, -1);
$size = count($values);
break;
}
From 82e354e30979614c7803056b593c8634fd61496f Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Tue, 9 Sep 2014 10:56:00 +0000
Subject: [PATCH 014/147] Fix readme bug
---
README.markdown | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.markdown b/README.markdown
index 1a744ac..d126910 100644
--- a/README.markdown
+++ b/README.markdown
@@ -28,7 +28,7 @@ curl -s http://getcomposer.org/installer | php
php composer.phar create-project -s dev erik-dubbelboer/php-redis-admin path/to/install
```
-You may also want to copy include/config.simple.inc.php to include/config.inc.php
+You may also want to copy includes/config.simple.inc.php to includes/config.inc.php
and edit it with your specific redis configuration.
Instead of using composer, you can also do a manual install using:
From 1f571355bf5bc6127b3a9d6630b10e31d574b40a Mon Sep 17 00:00:00 2001
From: Mtillmann
Date: Sat, 11 Oct 2014 18:55:56 +0200
Subject: [PATCH 015/147] added missing commas to additional config example
to avoid fatal error on uncommenting
---
includes/config.sample.inc.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index 4fc63d7..0111902 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -22,12 +22,12 @@
'name' => 'local db 2',
'host' => 'localhost',
'port' => 6379,
- 'db' => 1 // Optional database number, see http://redis.io/commands/select
- 'filter' => 'something:*' // Show only parts of database for speed or security reasons
+ 'db' => 1, // Optional database number, see http://redis.io/commands/select
+ 'filter' => 'something:*', // Show only parts of database for speed or security reasons
'seperator' => '/', // Use a different seperator on this database
'flush' => false, // Set to true to enable the flushdb button for this instance.
'encoding' => 'cp1251', // Set for view values in other encoding
- )*/
+ ),*/
),
From d9791285ea64c42e5181b98df85704cddefb0fec Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Mon, 13 Oct 2014 08:05:19 +0000
Subject: [PATCH 016/147] Fix issue #59
---
edit.php | 22 +++++++++++-----------
includes/common.inc.php | 5 ++++-
includes/config.sample.inc.php | 22 +++++++++++-----------
includes/functions.inc.php | 22 ++++++++++++++++++++--
view.php | 10 +++++-----
5 files changed, 51 insertions(+), 30 deletions(-)
diff --git a/edit.php b/edit.php
index 357a368..a2e8164 100644
--- a/edit.php
+++ b/edit.php
@@ -29,7 +29,7 @@
// String
if ($_POST['type'] == 'string') {
- $redis->set($_POST['key'], $_POST['value']);
+ $redis->set(input_convert($_POST['key']), input_convert($_POST['value']));
}
// Hash
@@ -38,26 +38,26 @@
die('ERROR: Your hash key is to long (max length is '.$config['maxkeylen'].')');
}
- if ($edit && !$redis->hExists($_POST['key'], $_POST['hkey'])) {
- $redis->hDel($_POST['key'], $_GET['hkey']);
+ if ($edit && !$redis->hExists(input_convert($_POST['key']), input_convert($_POST['hkey']))) {
+ $redis->hDel(input_convert($_POST['key']), input_convert($_GET['hkey']));
}
- $redis->hSet($_POST['key'], $_POST['hkey'], $_POST['value']);
+ $redis->hSet(input_convert($_POST['key']), input_convert($_POST['hkey']), input_convert($_POST['value']));
}
// List
else if (($_POST['type'] == 'list') && isset($_POST['index'])) {
- $size = $redis->lLen($_POST['key']);
+ $size = $redis->lLen(input_convert($_POST['key']));
if (($_POST['index'] == '') ||
($_POST['index'] == $size) ||
($_POST['index'] == -1)) {
// Push it at the end
- $redis->rPush($_POST['key'], $_POST['value']);
+ $redis->rPush(input_convert($_POST['key']), input_convert($_POST['value']));
} else if (($_POST['index'] >= 0) &&
($_POST['index'] < $size)) {
// Overwrite an index
- $redis->lSet($_POST['key'], $_POST['index'], $_POST['value']);
+ $redis->lSet(input_convert($_POST['key']), input_convert($_POST['index']), input_convert($_POST['value']));
} else {
die('ERROR: Out of bounds index');
}
@@ -67,8 +67,8 @@
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($_POST['key'], $_POST['oldvalue']);
- $redis->sAdd($_POST['key'], $_POST['value']);
+ $redis->sRem(input_convert($_POST['key']), input_convert($_POST['oldvalue']));
+ $redis->sAdd(input_convert($_POST['key']), input_convert($_POST['value']));
}
}
@@ -76,8 +76,8 @@
else if (($_POST['type'] == 'zset') && isset($_POST['score'])) {
if ($_POST['value'] != $_POST['oldvalue']) {
// The only way to edit a ZSet value is to add it and remove the old value.
- $redis->zRem($_POST['key'], $_POST['oldvalue']);
- $redis->zAdd($_POST['key'], $_POST['score'], $_POST['value']);
+ $redis->zRem(input_convert($_POST['key']), input_convert($_POST['oldvalue']));
+ $redis->zAdd(input_convert($_POST['key']), input_convert($_POST['score']), input_convert($_POST['value']));
}
}
diff --git a/includes/common.inc.php b/includes/common.inc.php
index 3e960c0..d5f2305 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -55,7 +55,10 @@
$server = $config['servers'][$i];
$server['id'] = $i;
-$server['charset'] = isset($server['charset']) && $server['charset'] ? $server['charset'] : mb_internal_encoding();
+$server['charset'] = isset($server['charset']) && $server['charset'] ? $server['charset'] : false;
+
+
+mb_internal_encoding('utf-8');
if (isset($login, $login['servers'])) {
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index 0111902..b132bed 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -4,9 +4,9 @@
$config = array(
'servers' => array(
array(
- 'name' => 'local server', // Optional name.
- 'host' => '127.0.0.1',
- 'port' => 6379,
+ 'name' => 'local server', // Optional name.
+ 'host' => '127.0.0.1',
+ 'port' => 6379,
'filter' => '*',
// Optional Redis authentication.
@@ -19,14 +19,14 @@
),*/
/*array(
- 'name' => 'local db 2',
- 'host' => 'localhost',
- 'port' => 6379,
- 'db' => 1, // Optional database number, see http://redis.io/commands/select
- 'filter' => 'something:*', // Show only parts of database for speed or security reasons
- 'seperator' => '/', // Use a different seperator on this database
- 'flush' => false, // Set to true to enable the flushdb button for this instance.
- 'encoding' => 'cp1251', // Set for view values in other encoding
+ 'name' => 'local db 2',
+ 'host' => 'localhost',
+ 'port' => 6379,
+ 'db' => 1, // Optional database number, see http://redis.io/commands/select
+ 'filter' => 'something:*', // Show only parts of database for speed or security reasons.
+ 'seperator' => '/', // Use a different seperator on this database.
+ 'flush' => false, // Set to true to enable the flushdb button for this instance.
+ 'charset' => 'cp1251', // Keys and values are stored in redis using this encoding (default utf-8).
),*/
),
diff --git a/includes/functions.inc.php b/includes/functions.inc.php
index 3f49f4b..22e9253 100644
--- a/includes/functions.inc.php
+++ b/includes/functions.inc.php
@@ -1,11 +1,29 @@
-
+
@@ -155,7 +155,7 @@
Key
Value
$value) { ?>
-
>
+
>
@@ -183,7 +183,7 @@
for ($i = $start; $i < $end; ++$i) {
$value = $redis->lIndex($_GET['key'], $i);
?>
-
>
+
>
@@ -202,7 +202,7 @@
Value
exists($value) ? '
'.nl2br(format_html($value, $server['charset'])).' ' : nl2br(format_html($value, $server['charset']));
+ $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
?>
>
@@ -223,7 +223,7 @@
zScore($_GET['key'], $value);
- $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value, $server['charset'])).' ' : nl2br(format_html($value, $server['charset']));
+ $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
?>
>
From fad07ad5cef367d69219ffbf6f7c9b02b0cec739 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Thu, 23 Oct 2014 07:54:54 +0000
Subject: [PATCH 017/147] Fixed zset score edit bug
---
composer.json | 2 +-
edit.php | 8 +++-----
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/composer.json b/composer.json
index fd6edaf..dd19d92 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.1.1",
+ "version": "1.1.2",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
diff --git a/edit.php b/edit.php
index a2e8164..fade77c 100644
--- a/edit.php
+++ b/edit.php
@@ -74,11 +74,9 @@
// ZSet
else if (($_POST['type'] == 'zset') && isset($_POST['score'])) {
- if ($_POST['value'] != $_POST['oldvalue']) {
- // The only way to edit a ZSet value is to add it and remove the old value.
- $redis->zRem(input_convert($_POST['key']), input_convert($_POST['oldvalue']));
- $redis->zAdd(input_convert($_POST['key']), input_convert($_POST['score']), input_convert($_POST['value']));
- }
+ // The only way to edit a ZSet value is to add it and remove the old value.
+ $redis->zRem(input_convert($_POST['key']), input_convert($_POST['oldvalue']));
+ $redis->zAdd(input_convert($_POST['key']), input_convert($_POST['score']), input_convert($_POST['value']));
}
From 37d0b67d3a34e99de77f811e481e07e6abebbce7 Mon Sep 17 00:00:00 2001
From: primeinc
Date: Sat, 25 Oct 2014 11:41:13 -0400
Subject: [PATCH 018/147] resolved issue with displaying thousands of pages
---
view.php | 65 +++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 50 insertions(+), 15 deletions(-)
diff --git a/view.php b/view.php
index 3dd2ea0..4c48cb6 100644
--- a/view.php
+++ b/view.php
@@ -111,25 +111,60 @@
// Build pagination div.
if (($count_elements_page !== false) && in_array($type, array('hash', 'list', 'set', 'zset')) && ($size > $count_elements_page)) {
- $pagination = '';
- $url = preg_replace('/&page=(\d+)/i', '', $_SERVER['REQUEST_URI']);
-
- for ($i = 0; $i < ceil($size / $count_elements_page); ++$i) {
- $page_num = $i + 1;
-
- if ($page_num === $page_num_request) {
- $pagination .= $page_num . ' ';
- } else {
- $pagination .= '
' . $page_num . " ";
+ $prev = $page_num_request - 1;
+ $next = $page_num_request + 1;
+ $lastpage = ceil($size / $count_elements_page);
+ $lpm1 = $lastpage - 1;
+ $adjacents = 3;
+ $pagination = '
';
+ $url = preg_replace('/&page=(\d+)/i', '', $_SERVER['REQUEST_URI']);
+
+ if ($page_num_request > 1) $pagination .= "
← "; else
+ $pagination .= "← ";
+
+ if ($lastpage < 7 + ($adjacents * 2)) { //not enough pages to bother breaking it up
+ for ($counter = 1; $counter <= $lastpage; $counter++) {
+ if ($counter == $page_num_request) $pagination .= $page_num_request . ' '; else
+ $pagination .= "
$counter ";
+ }
+ } elseif ($lastpage > 5 + ($adjacents * 2)) { //enough pages to hide some
+
+ if ($page_num_request < 1 + ($adjacents * 2)) { //close to beginning; only hide later pages
+ for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) {
+ if ($counter == $page_num_request) $pagination .= $page_num_request . ' '; else
+ $pagination .= "
$counter ";
+ }
+ $pagination .= "... ";
+ $pagination .= "
$lpm1 ";
+ $pagination .= "
$lastpage ";
+ } elseif ($lastpage - ($adjacents * 2) > $page_num_request && $page_num_request > ($adjacents * 2)) { //in middle; hide some front and some back
+ $pagination .= "
1 ";
+ $pagination .= "
2 ";
+ $pagination .= "... ";
+ for ($counter = $page_num_request - $adjacents; $counter <= $page_num_request + $adjacents; $counter++) {
+ if ($counter == $page_num_request) $pagination .= $page_num_request . ' '; else
+ $pagination .= "
$counter ";
+ }
+ $pagination .= "... ";
+ $pagination .= "
$lpm1 ";
+ $pagination .= "
$lastpage ";
+ } else { //close to end; only hide early pages
+ $pagination .= "
1 ";
+ $pagination .= "
2 ";
+ $pagination .= "... ";
+ for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) {
+ if ($counter == $page_num_request) $pagination .= $page_num_request . ' '; else
+ $pagination .= "
$counter ";
+ }
+ }
}
- }
-
- $pagination .= '
';
+ if ($page_num_request < $counter - 1) $pagination .= "
→ "; else
+ $pagination .= "→ ";
+ $pagination .= "
";
}
-
if (isset($pagination)) {
- echo $pagination;
+ echo $pagination;
}
From 38cd02432955bcc97af389c2d500999f95001748 Mon Sep 17 00:00:00 2001
From: Bas van Dorst
Date: Mon, 26 Jan 2015 11:07:25 +0000
Subject: [PATCH 019/147] Use the pre-tag for better showing multidimensional
arrays
---
info.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/info.php b/info.php
index 1c20961..ae37a86 100644
--- a/info.php
+++ b/info.php
@@ -45,7 +45,7 @@
}
?>
- >
+ >
Date: Tue, 27 Jan 2015 13:19:36 +0800
Subject: [PATCH 020/147] fix infinite redirect bug when delete a key
fix infinite redirect bug when delete a key
---
delete.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/delete.php b/delete.php
index ec7e20e..8e4fdeb 100644
--- a/delete.php
+++ b/delete.php
@@ -57,7 +57,7 @@
$redis->del($key);
}
- die('?&s='.$server['id']);
+ die('?view&s='.$server['id']);
}
?>
From f419e7fb95652b0c429e01d50c32586733face1b Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sun, 22 Mar 2015 17:25:53 +0000
Subject: [PATCH 021/147] Fix #35 and possibly #52
---
composer.json | 4 +--
composer.lock | 44 +++++++++++++--------------
delete.php | 4 +--
edit.php | 2 +-
import.php | 2 +-
includes/common.inc.php | 21 +++++++++----
includes/config.sample.inc.php | 13 ++++++--
index.php | 54 ++++++++++++++++++++++++++--------
info.php | 2 +-
js/index.js | 13 +++++++-
rename.php | 2 +-
view.php | 34 ++++++++++-----------
12 files changed, 125 insertions(+), 70 deletions(-)
diff --git a/composer.json b/composer.json
index dd19d92..d51d3cc 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.1.2",
+ "version": "1.2.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
@@ -13,7 +13,7 @@
}
],
"require": {
- "predis/predis": "0.8.*"
+ "predis/predis": "1.0.1"
},
"minimum-stability": "stable",
"target-dir": "ErikDubbelboer/phpRedisAdmin"
diff --git a/composer.lock b/composer.lock
index 55ba3ee..99da8b2 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1,35 +1,39 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
- "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
+ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "This file is @generated automatically"
],
- "hash": "81de6835a02ee54ae5d87ce2b395ba6e",
+ "hash": "e0695856c109266b2eabff6d53d879c0",
"packages": [
{
"name": "predis/predis",
- "version": "v0.8.3",
+ "version": "v1.0.1",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
- "reference": "v0.8.3"
+ "reference": "7a170b3d8123c556597b4fbdb88631f99de180c2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nrk/predis/zipball/v0.8.3",
- "reference": "v0.8.3",
+ "url": "https://api.github.com/repos/nrk/predis/zipball/7a170b3d8123c556597b4fbdb88631f99de180c2",
+ "reference": "7a170b3d8123c556597b4fbdb88631f99de180c2",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
+ "require-dev": {
+ "phpunit/phpunit": "~4.0"
+ },
"suggest": {
"ext-curl": "Allows access to Webdis when paired with phpiredis",
"ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
},
"type": "library",
"autoload": {
- "psr-0": {
- "Predis": "lib/"
+ "psr-4": {
+ "Predis\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -50,23 +54,15 @@
"predis",
"redis"
],
- "time": "2013-02-18 14:03:45"
+ "time": "2015-01-02 12:51:34"
}
],
- "packages-dev": [
-
- ],
- "aliases": [
-
- ],
+ "packages-dev": [],
+ "aliases": [],
"minimum-stability": "stable",
- "stability-flags": [
-
- ],
- "platform": [
-
- ],
- "platform-dev": [
-
- ]
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": [],
+ "platform-dev": []
}
diff --git a/delete.php b/delete.php
index 8e4fdeb..df51bee 100644
--- a/delete.php
+++ b/delete.php
@@ -46,7 +46,7 @@
}
- die('?view&s='.$server['id'].'&key='.urlencode($_GET['key']));
+ die('?view&s='.$server['id'].'&d='.$server['db'].'&key='.urlencode($_GET['key']));
}
@@ -57,7 +57,7 @@
$redis->del($key);
}
- die('?view&s='.$server['id']);
+ die('?view&s='.$server['id'].'&d='.$server['db']);
}
?>
diff --git a/edit.php b/edit.php
index fade77c..09ad55e 100644
--- a/edit.php
+++ b/edit.php
@@ -86,7 +86,7 @@
?>
6379,
'db' => 1, // Optional database number, see http://redis.io/commands/select
'filter' => 'something:*', // Show only parts of database for speed or security reasons.
- 'seperator' => '/', // Use a different seperator on this database.
+ 'seperator' => '/', // Use a different seperator on this database (default uses config default).
'flush' => false, // Set to true to enable the flushdb button for this instance.
'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).
),*/
),
@@ -55,7 +57,14 @@
// You can ignore settings below this point.
'maxkeylen' => 100,
- 'count_elements_page' => 100
+ 'count_elements_page' => 100,
+
+
+ // Use the old KEYS command instead of SCAN to fetch all keys.
+ 'keys' => false,
+
+ // How many entries to fetch using each SCAN command.
+ 'scansize' => 1000
);
?>
diff --git a/index.php b/index.php
index b768ecb..851c9f4 100644
--- a/index.php
+++ b/index.php
@@ -4,7 +4,23 @@
if($redis) {
- $keys = $redis->keys($server['filter']);
+ if (!empty($server['keys'])) {
+ $keys = $redis->keys($server['filter']);
+ } else {
+ $next = 0;
+ $keys = array();
+
+ while (true) {
+ $r = $redis->scan($next, 'MATCH', $server['filter'], 'COUNT', $server['scansize']);
+
+ $next = $r[0];
+ $keys = array_merge($keys, $r[1]);
+
+ if ($next == 0) {
+ break;
+ }
+ }
+ }
sort($keys);
@@ -83,7 +99,7 @@ function print_namespace($item, $name, $fullkey, $islast) {
?>
>
- ()
+ ()
()
-
+
-
+
+
Can't connect to this server
-
+
diff --git a/info.php b/info.php
index ae37a86..4d1f821 100644
--- a/info.php
+++ b/info.php
@@ -31,7 +31,7 @@
-Reset usage statistics
+Reset usage statistics
diff --git a/js/index.js b/js/index.js
index 545add0..1fbb755 100644
--- a/js/index.js
+++ b/js/index.js
@@ -49,6 +49,17 @@ $(function() {
});
+ $('#database').change(function(e) {
+ if (location.href.indexOf('?') == -1) {
+ location.href = location.href+'?d='+e.target.value;
+ } else if (location.href.indexOf('&d=') == -1) {
+ location.href = location.href+'&d='+e.target.value;
+ } else {
+ location.href = location.href.replace(/d=[0-9]*/, 'd='+e.target.value);
+ }
+ });
+
+
$('li.current').parents('li.folder').removeClass('collapsed');
$('li.folder').click(function(e) {
@@ -71,7 +82,7 @@ $(function() {
$('#btn_server_filter').click(function() {
var filter = $('#server_filter').val();
- location.href = top.location.pathname + '?overview&s=' + $('#server').val() + '&filter=' + filter;
+ location.href = top.location.pathname + '?overview&s=' + $('#server').val() + '&d=' + ($('#database').val() || '') + '&filter=' + filter;
});
$('#server_filter').keydown(function(e){
diff --git a/rename.php b/rename.php
index a542576..6c192b1 100644
--- a/rename.php
+++ b/rename.php
@@ -18,7 +18,7 @@
?>
-
-
-
+
+
+
Type:
-
+
Encoding:
@@ -173,9 +173,9 @@
@@ -191,9 +191,9 @@
$value) { ?>
>
-
+
-
+
@@ -219,9 +219,9 @@
$value = $redis->lIndex($_GET['key'], $i);
?>
>
-
+
-
+
@@ -237,12 +237,12 @@
Value
exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
+ $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
?>
>
-
+
-
+
@@ -258,11 +258,11 @@
zScore($_GET['key'], $value);
- $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
+ $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
?>
>
@@ -272,7 +272,7 @@
- Add another value
+ Add another value
Date: Fri, 27 Mar 2015 09:10:33 +0800
Subject: [PATCH 022/147] Remove maxlength limit from edit control.
Update view.php
---
edit.php | 4 ++--
view.php | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/edit.php b/edit.php
index 09ad55e..4f2ed80 100644
--- a/edit.php
+++ b/edit.php
@@ -147,12 +147,12 @@
Key:
- >
+ >
Hash key:
- >
+ >
diff --git a/view.php b/view.php
index 533ad9e..c0b39c4 100644
--- a/view.php
+++ b/view.php
@@ -69,6 +69,7 @@
case 'hash':
$values = $redis->hGetAll($_GET['key']);
$size = count($values);
+ ksort($values);
break;
case 'list':
@@ -78,6 +79,7 @@
case 'set':
$values = $redis->sMembers($_GET['key']);
$size = count($values);
+ sort($values);
break;
case 'zset':
From 067db7ee9993bf7b0c109cfe29fc192673d66cd8 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sat, 11 Apr 2015 07:15:32 +0000
Subject: [PATCH 023/147] Fix rename, 1.2.1
---
composer.json | 2 +-
rename.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index d51d3cc..27b6a9e 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.2.0",
+ "version": "1.2.1",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
diff --git a/rename.php b/rename.php
index 6c192b1..1dd50d9 100644
--- a/rename.php
+++ b/rename.php
@@ -18,7 +18,7 @@
?>
Date: Sat, 25 Apr 2015 04:50:03 +0000
Subject: [PATCH 024/147] Add custom per key encoding (fix #69)
---
css/common.css | 5 +++++
edit.php | 32 +++++++++++++++++++++-----------
includes/common.inc.php | 6 ++++++
includes/config.sample.inc.php | 11 ++++++++++-
includes/functions.inc.php | 19 +++++++++++++++++++
view.php | 31 +++++++++++++++++++++----------
6 files changed, 82 insertions(+), 22 deletions(-)
diff --git a/css/common.css b/css/common.css
index 005a792..b2a8431 100644
--- a/css/common.css
+++ b/css/common.css
@@ -50,3 +50,8 @@ padding: 3px 0 1px 20px;
background: url(http://github.com/images/add.png) left center no-repeat;
}
+
+.data {
+white-space: pre;
+}
+
diff --git a/edit.php b/edit.php
index 4f2ed80..e50da25 100644
--- a/edit.php
+++ b/edit.php
@@ -27,9 +27,17 @@
die('ERROR: Your key is to long (max length is '.$config['maxkeylen'].')');
}
+ $key = input_convert($_POST['key']);
+ $value = input_convert($_POST['value']);
+ $value = encodeOrDecode('save', $key, $value);
+
+ if ($value === false || is_null($value)) {
+ die('ERROR: could not encode value');
+ }
+
// String
if ($_POST['type'] == 'string') {
- $redis->set(input_convert($_POST['key']), input_convert($_POST['value']));
+ $redis->set($key, $value);
}
// Hash
@@ -38,26 +46,26 @@
die('ERROR: Your hash key is to long (max length is '.$config['maxkeylen'].')');
}
- if ($edit && !$redis->hExists(input_convert($_POST['key']), input_convert($_POST['hkey']))) {
- $redis->hDel(input_convert($_POST['key']), input_convert($_GET['hkey']));
+ if ($edit && !$redis->hExists($key, input_convert($_POST['hkey']))) {
+ $redis->hDel($key, input_convert($_GET['hkey']));
}
- $redis->hSet(input_convert($_POST['key']), input_convert($_POST['hkey']), input_convert($_POST['value']));
+ $redis->hSet($key, input_convert($_POST['hkey']), $value);
}
// List
else if (($_POST['type'] == 'list') && isset($_POST['index'])) {
- $size = $redis->lLen(input_convert($_POST['key']));
+ $size = $redis->lLen($key);
if (($_POST['index'] == '') ||
($_POST['index'] == $size) ||
($_POST['index'] == -1)) {
// Push it at the end
- $redis->rPush(input_convert($_POST['key']), input_convert($_POST['value']));
+ $redis->rPush($key, $value);
} else if (($_POST['index'] >= 0) &&
($_POST['index'] < $size)) {
// Overwrite an index
- $redis->lSet(input_convert($_POST['key']), input_convert($_POST['index']), input_convert($_POST['value']));
+ $redis->lSet($key, input_convert($_POST['index']), $value);
} else {
die('ERROR: Out of bounds index');
}
@@ -67,16 +75,16 @@
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(input_convert($_POST['key']), input_convert($_POST['oldvalue']));
- $redis->sAdd(input_convert($_POST['key']), input_convert($_POST['value']));
+ $redis->sRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue'])));
+ $redis->sAdd($key, $value);
}
}
// ZSet
else if (($_POST['type'] == 'zset') && isset($_POST['score'])) {
// The only way to edit a ZSet value is to add it and remove the old value.
- $redis->zRem(input_convert($_POST['key']), input_convert($_POST['oldvalue']));
- $redis->zAdd(input_convert($_POST['key']), input_convert($_POST['score']), input_convert($_POST['value']));
+ $redis->zRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue'])));
+ $redis->zAdd($key, input_convert($_POST['score']), $value);
}
@@ -120,6 +128,8 @@
else if ((($_GET['type'] == 'set') || ($_GET['type'] == 'zset')) && isset($_GET['value'])) {
$value = $_GET['value'];
}
+
+ $value = encodeOrDecode('load', $_GET['key'], $value);
}
diff --git a/includes/common.inc.php b/includes/common.inc.php
index 0d45753..3e02caa 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -105,6 +105,12 @@
$server['scansize'] = $config['scansize'];
}
+if (!isset($server['serialization'])) {
+ if (isset($config['serialization'])) {
+ $server['serialization'] = $config['serialization'];
+ }
+}
+
// Setup a connection to Redis.
$redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']);
try {
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index 9455e67..fc21162 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -54,12 +54,21 @@
),*/
+ /*'serialization' => array(
+ 'foo*' => array( // Match like KEYS
+ // Function called when saving to redis.
+ 'save' => function($data) { return json_encode(json_decode($data)); },
+ // Function called when loading from redis.
+ 'load' => function($data) { return json_encode(json_decode($data), JSON_PRETTY_PRINT); },
+ ),
+ ),*/
+
+
// You can ignore settings below this point.
'maxkeylen' => 100,
'count_elements_page' => 100,
-
// Use the old KEYS command instead of SCAN to fetch all keys.
'keys' => false,
diff --git a/includes/functions.inc.php b/includes/functions.inc.php
index 22e9253..89368e3 100644
--- a/includes/functions.inc.php
+++ b/includes/functions.inc.php
@@ -16,6 +16,8 @@ function format_html($str) {
function input_convert($str) {
+ global $server;
+
if (isset($server['charset']) && $server['charset']) {
return mb_convert_encoding($str, $server['charset'], 'utf-8');
} else {
@@ -82,3 +84,20 @@ function str_rand($length) {
return $r;
}
+
+function encodeOrDecode($action, $key, $data) {
+ global $server;
+
+ if (isset($_GET['raw']) || !isset($server['serialization'])) {
+ return $data;
+ }
+
+ foreach ($server['serialization'] as $pattern => $closures) {
+ if (fnmatch($pattern, $key)) {
+ return $closures[$action]($data);
+ }
+ }
+
+ return $data;
+}
+
diff --git a/view.php b/view.php
index c0b39c4..5799a2e 100644
--- a/view.php
+++ b/view.php
@@ -63,12 +63,16 @@
switch ($type) {
case 'string':
$value = $redis->get($_GET['key']);
+ $value = encodeOrDecode('load', $_GET['key'], $value);
$size = strlen($value);
break;
case 'hash':
$values = $redis->hGetAll($_GET['key']);
- $size = count($values);
+ foreach ($values as $k => $value) {
+ $values[$k] = encodeOrDecode('load', $_GET['key'], $value);
+ }
+ $size = count($values);
ksort($values);
break;
@@ -78,13 +82,19 @@
case 'set':
$values = $redis->sMembers($_GET['key']);
- $size = count($values);
+ foreach ($values as $k => $value) {
+ $values[$k] = encodeOrDecode('load', $_GET['key'], $value);
+ }
+ $size = count($values);
sort($values);
break;
case 'zset':
$values = $redis->zRange($_GET['key'], 0, -1);
- $size = count($values);
+ foreach ($values as $k => $value) {
+ $values[$k] = encodeOrDecode('load', $_GET['key'], $value);
+ }
+ $size = count($values);
break;
}
@@ -174,7 +184,7 @@
if ($type == 'string') { ?>
-
+
@@ -192,7 +202,7 @@
Key
Value
$value) { ?>
-
>
+
>
@@ -219,8 +229,9 @@
for ($i = $start; $i < $end; ++$i) {
$value = $redis->lIndex($_GET['key'], $i);
+ $value = encodeOrDecode('load', $_GET['key'], $value);
?>
-
>
+
>
@@ -239,9 +250,9 @@
Value
exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
+ $display_value = $redis->exists($value) ? '
'.format_html($value).' ' : format_html($value);
?>
-
>
+
>
@@ -260,9 +271,9 @@
zScore($_GET['key'], $value);
- $display_value = $redis->exists($value) ? '
'.nl2br(format_html($value)).' ' : nl2br(format_html($value));
+ $display_value = $redis->exists($value) ? '
'.format_html($value).' ' : format_html($value);
?>
-
>
+
>
From 219002ba5ef4445d1a07a5a232727f9a71dca7f0 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sat, 20 Jun 2015 04:25:23 +0000
Subject: [PATCH 025/147] v1.3.0
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 27b6a9e..b497172 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.2.1",
+ "version": "1.3.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 673cbe19a47b0887e59fcd6a5318041d36346b51 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sun, 28 Jun 2015 10:44:06 +0000
Subject: [PATCH 026/147] Fix issue #47 Resize key frame
---
css/index.css | 37 ++++++++++----
index.php | 7 ++-
js/index.js | 42 ++++++++++++++++
js/jquery-cookie.js | 114 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 191 insertions(+), 9 deletions(-)
create mode 100644 js/jquery-cookie.js
diff --git a/css/index.css b/css/index.css
index 6fa6dda..2c8faf5 100644
--- a/css/index.css
+++ b/css/index.css
@@ -3,11 +3,10 @@ position: absolute;
top: 0;
bottom: 0;
left: 0;
-width: 24em;
+width: 290px;
height: 100%;
-padding-left: 1em;
+padding-left: 10px;
border-right: 1px solid #000;
-overflow: hidden;
}
#sidebar a, #sidebar a:visited {
@@ -24,11 +23,12 @@ text-decoration: underline;
#keys {
-position: fixed;
+position: absolute;
top: 18.5em;
+left: 0;
bottom: 0;
-width: 24em;
-padding-bottom: 1em;
+width: 290px;
+padding-left: 10px;
overflow: auto;
}
@@ -104,14 +104,35 @@ display: none;
display: inline;
}
+#resize {
+position: fixed;
+top: 0;
+left: 300px;
+bottom: 0;
+width: 5px;
+background-color: #aaa;
+cursor: col-resize;
+padding: 0;
+margin: 0;
+}
+
+#resize-layover {
+position: fixed;
+top: 0;
+left: 305px;
+right: 0;
+bottom: 0;
+width: 100%;
+z-index: 1000;
+}
#frame {
position: fixed;
top: 0;
-left: 25em;
+left: 305px;
right: 0;
bottom: 0;
-padding-left: 1em;
+padding-left: 2em;
}
#frame iframe {
diff --git a/index.php b/index.php
index 851c9f4..499f1e1 100644
--- a/index.php
+++ b/index.php
@@ -154,6 +154,7 @@ function print_namespace($item, $name, $fullkey, $islast) {
$page['css'][] = 'index';
$page['js'][] = 'index';
+$page['js'][] = 'jquery-cookie';
require 'includes/header.inc.php';
@@ -219,11 +220,15 @@ function print_namespace($item, $name, $fullkey, $islast) {
Can't connect to this server
+
+
+
+
+
-
0) {
+ resizeSidebar(parseInt($.cookie('sidebar')));
+ }
+
+ $('#resize').on('mousedown', function (e) {
+ isResizing = true;
+ lastDownX = e.clientX;
+ lastWidth = $('#sidebar').width();
+ $('#resize-layover').css('z-index', 1000);
+ e.preventDefault();
+ });
+ $(document).on('mousemove', function (e) {
+ if (!isResizing) {
+ return;
+ }
+
+ var w = lastWidth - (lastDownX - e.clientX);
+ if (w < 250 ) {
+ w = 250;
+ } else if (w > 1000) {
+ w = 1000;
+ }
+
+ resizeSidebar(w);
+ $.cookie('sidebar', w);
+ }).on('mouseup', function (e) {
+ isResizing = false;
+ $('#resize-layover').css('z-index', 0);
+ });
});
diff --git a/js/jquery-cookie.js b/js/jquery-cookie.js
new file mode 100644
index 0000000..29769eb
--- /dev/null
+++ b/js/jquery-cookie.js
@@ -0,0 +1,114 @@
+/*!
+ * jQuery Cookie Plugin v1.4.1
+ * https://github.com/carhartl/jquery-cookie
+ *
+ * Copyright 2006, 2014 Klaus Hartl
+ * Released under the MIT license
+ */
+(function (factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD (Register as an anonymous module)
+ define(['jquery'], factory);
+ } else if (typeof exports === 'object') {
+ // Node/CommonJS
+ module.exports = factory(require('jquery'));
+ } else {
+ // Browser globals
+ factory(jQuery);
+ }
+}(function ($) {
+
+ var pluses = /\+/g;
+
+ function encode(s) {
+ return config.raw ? s : encodeURIComponent(s);
+ }
+
+ function decode(s) {
+ return config.raw ? s : decodeURIComponent(s);
+ }
+
+ function stringifyCookieValue(value) {
+ return encode(config.json ? JSON.stringify(value) : String(value));
+ }
+
+ function parseCookieValue(s) {
+ if (s.indexOf('"') === 0) {
+ // This is a quoted cookie as according to RFC2068, unescape...
+ s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
+ }
+
+ try {
+ // Replace server-side written pluses with spaces.
+ // If we can't decode the cookie, ignore it, it's unusable.
+ // If we can't parse the cookie, ignore it, it's unusable.
+ s = decodeURIComponent(s.replace(pluses, ' '));
+ return config.json ? JSON.parse(s) : s;
+ } catch(e) {}
+ }
+
+ function read(s, converter) {
+ var value = config.raw ? s : parseCookieValue(s);
+ return $.isFunction(converter) ? converter(value) : value;
+ }
+
+ var config = $.cookie = function (key, value, options) {
+
+ // Write
+
+ if (arguments.length > 1 && !$.isFunction(value)) {
+ options = $.extend({}, config.defaults, options);
+
+ if (typeof options.expires === 'number') {
+ var days = options.expires, t = options.expires = new Date();
+ t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
+ }
+
+ return (document.cookie = [
+ encode(key), '=', stringifyCookieValue(value),
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
+ options.path ? '; path=' + options.path : '',
+ options.domain ? '; domain=' + options.domain : '',
+ options.secure ? '; secure' : ''
+ ].join(''));
+ }
+
+ // Read
+
+ var result = key ? undefined : {},
+ // To prevent the for loop in the first place assign an empty array
+ // in case there are no cookies at all. Also prevents odd result when
+ // calling $.cookie().
+ cookies = document.cookie ? document.cookie.split('; ') : [],
+ i = 0,
+ l = cookies.length;
+
+ for (; i < l; i++) {
+ var parts = cookies[i].split('='),
+ name = decode(parts.shift()),
+ cookie = parts.join('=');
+
+ if (key === name) {
+ // If second argument (value) is a function it's a converter...
+ result = read(cookie, value);
+ break;
+ }
+
+ // Prevent storing a cookie that we couldn't decode.
+ if (!key && (cookie = read(cookie)) !== undefined) {
+ result[name] = cookie;
+ }
+ }
+
+ return result;
+ };
+
+ config.defaults = {};
+
+ $.removeCookie = function (key, options) {
+ // Must not alter options, thus extending a fresh object...
+ $.cookie(key, '', $.extend({}, options, { expires: -1 }));
+ return !$.cookie(key);
+ };
+
+}));
From e2c827d962d210ed48a8171aa7d62c7c3f0a0b94 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sun, 28 Jun 2015 10:44:53 +0000
Subject: [PATCH 027/147] v1.4.0
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index b497172..dabe9cf 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.3.0",
+ "version": "1.4.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From aaac0f447ac54c8d54ead9f21d452de33c0c3644 Mon Sep 17 00:00:00 2001
From: pataquets
Date: Sat, 18 Jul 2015 16:10:34 +0200
Subject: [PATCH 028/147] Add Docker support: Dockerfile initial version and
environment-sourcing config file.
---
Dockerfile | 12 ++++++++
includes/config.environment.inc.php | 46 +++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
create mode 100644 Dockerfile
create mode 100644 includes/config.environment.inc.php
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..ebca2d9
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,12 @@
+FROM composer/composer
+
+ADD . /src/app/
+WORKDIR /src/app
+
+RUN \
+ composer install && \
+ cp includes/config.environment.inc.php includes/config.inc.php
+
+EXPOSE 80
+
+ENTRYPOINT [ "php", "-S", "0.0.0.0:80" ]
diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php
new file mode 100644
index 0000000..bb7c76c
--- /dev/null
+++ b/includes/config.environment.inc.php
@@ -0,0 +1,46 @@
+ array(
+ 'password' => $admin_pass,
+ ),
+ );
+}
+
+$i=1;
+
+while (TRUE) {
+
+ $prefix = 'REDIS_' . $i . '_';
+
+ $server_name = getenv($prefix . 'NAME');
+ $server_host = getenv($prefix . 'HOST');
+ $server_port = getenv($prefix . 'PORT');
+
+ if (empty($server_host)) {
+ break;
+ }
+
+ if (empty($server_name)) {
+ $server_name = $server_host;
+ }
+
+ if (empty($server_port)) {
+ $server_port = 6379;
+ }
+
+ $config['servers'][] = array(
+ 'name' => $server_name,
+ 'host' => $server_host,
+ 'port' => $server_port,
+ 'filter' => '*',
+ );
+
+ $i++;
+}
From d344599f6c3e4bd080fe3d0f243a561c55b1a7f9 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Wed, 19 Aug 2015 07:27:29 +0000
Subject: [PATCH 029/147] Added databases config option
See: #76
---
composer.json | 2 +-
includes/config.sample.inc.php | 1 +
index.php | 8 ++++++--
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/composer.json b/composer.json
index dabe9cf..6d46ce0 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.4.0",
+ "version": "1.4.1",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index fc21162..219bbcc 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -23,6 +23,7 @@
'host' => 'localhost',
'port' => 6379,
'db' => 1, // Optional database number, see http://redis.io/commands/select
+ 'databases' => 1, // Optional number of databases (prevents use of CONFIG command).
'filter' => 'something:*', // Show only parts of database for speed or security reasons.
'seperator' => '/', // Use a different seperator on this database (default uses config default).
'flush' => false, // Set to true to enable the flushdb button for this instance.
diff --git a/index.php b/index.php
index 499f1e1..a1a952f 100644
--- a/index.php
+++ b/index.php
@@ -173,8 +173,12 @@ function print_namespace($item, $name, $fullkey, $islast) {
config('GET', 'databases');
-$databases = $databases['databases'];
+if (isset($server['database'])) {
+ $databases = $server['database'];
+} else {
+ $databases = $redis->config('GET', 'databases');
+ $databases = $databases['databases'];
+}
if ($databases > 1) { ?>
From 3fa986f7f782babd758b504852a4aeffb89363bd Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Mon, 5 Oct 2015 04:23:17 +0000
Subject: [PATCH 030/147] database, fixes #79
---
index.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/index.php b/index.php
index a1a952f..f56c572 100644
--- a/index.php
+++ b/index.php
@@ -173,8 +173,8 @@ function print_namespace($item, $name, $fullkey, $islast) {
config('GET', 'databases');
$databases = $databases['databases'];
From 8ff8a7effad636b63c5f83bd505eba8a3d6bbe1c Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Fri, 20 Nov 2015 21:38:55 +0800
Subject: [PATCH 031/147] Update README.markdown
---
README.markdown | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.markdown b/README.markdown
index d126910..fb17061 100644
--- a/README.markdown
+++ b/README.markdown
@@ -21,7 +21,7 @@ You can find an example database at
Installing/Configuring
======================
-To install phpRedisAdmin through [composer](http://getcomposer.org/) you need to execute the following commands:
+To install [phpRedisAdmin](https://packagist.org/packages/erik-dubbelboer/php-redis-admin) through [composer](http://getcomposer.org/) you need to execute the following commands:
```
curl -s http://getcomposer.org/installer | php
From 57fe486ae74b15d7a45e0381909b77d8c8798053 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Wed, 20 Jan 2016 09:05:08 +0000
Subject: [PATCH 032/147] Update predis, fix #87
---
composer.json | 2 +-
composer.lock | 15 ++++++++-------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/composer.json b/composer.json
index 6d46ce0..4116672 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
}
],
"require": {
- "predis/predis": "1.0.1"
+ "predis/predis": "1.0.3"
},
"minimum-stability": "stable",
"target-dir": "ErikDubbelboer/phpRedisAdmin"
diff --git a/composer.lock b/composer.lock
index 99da8b2..cd0cb49 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1,23 +1,24 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
- "Read more about it at http://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#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "e0695856c109266b2eabff6d53d879c0",
+ "hash": "e81aef935c2a6d36cf7690dbdb9d129a",
+ "content-hash": "3212fc4e8463f3bf5ff7db4655eecbf0",
"packages": [
{
"name": "predis/predis",
- "version": "v1.0.1",
+ "version": "v1.0.3",
"source": {
"type": "git",
"url": "https://github.com/nrk/predis.git",
- "reference": "7a170b3d8123c556597b4fbdb88631f99de180c2"
+ "reference": "84060b9034d756b4d79641667d7f9efe1aeb8e04"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nrk/predis/zipball/7a170b3d8123c556597b4fbdb88631f99de180c2",
- "reference": "7a170b3d8123c556597b4fbdb88631f99de180c2",
+ "url": "https://api.github.com/repos/nrk/predis/zipball/84060b9034d756b4d79641667d7f9efe1aeb8e04",
+ "reference": "84060b9034d756b4d79641667d7f9efe1aeb8e04",
"shasum": ""
},
"require": {
@@ -54,7 +55,7 @@
"predis",
"redis"
],
- "time": "2015-01-02 12:51:34"
+ "time": "2015-07-30 18:34:15"
}
],
"packages-dev": [],
From f88cfaf4124677e8e1e8cc1c1853c51a2c49ba39 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Wed, 20 Jan 2016 09:06:50 +0000
Subject: [PATCH 033/147] v1.4.2
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 4116672..2db83f8 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.4.1",
+ "version": "1.4.2",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 94150ccd534c91b53220006fe36b79621920d19f Mon Sep 17 00:00:00 2001
From: gulch
Date: Thu, 31 Mar 2016 17:55:47 +0300
Subject: [PATCH 034/147] Added possibility of connection via UNIX domain
socket.
---
includes/common.inc.php | 7 ++++++-
includes/config.sample.inc.php | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/includes/common.inc.php b/includes/common.inc.php
index 3e02caa..66c8769 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -112,7 +112,12 @@
}
// Setup a connection to Redis.
-$redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']);
+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) {
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index 219bbcc..321c8d6 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -8,6 +8,8 @@
'host' => '127.0.0.1',
'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'
// Optional Redis authentication.
//'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server.
From d2207d359527a053bedba27c3878cdabaea072b1 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Tue, 12 Apr 2016 04:46:15 +0000
Subject: [PATCH 035/147] 1.5.0, fix #91
---
composer.json | 2 +-
overview.php | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index 2db83f8..832bf35 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.4.2",
+ "version": "1.5.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
diff --git a/overview.php b/overview.php
index caeb2bb..8c0b073 100644
--- a/overview.php
+++ b/overview.php
@@ -13,7 +13,11 @@
}
// Setup a connection to Redis.
- $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']);
+ 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) {
From c7d38e1b234ccd1f6a1b8aee01649c74eaf8fd25 Mon Sep 17 00:00:00 2001
From: Greg ORIOL
Date: Fri, 22 Apr 2016 15:29:48 +0200
Subject: [PATCH 036/147] Fixed "click" binding on redis databases with a lot
of keys (#93)
---
js/index.js | 96 ++++++++++++++++++++++++-----------------------------
1 file changed, 43 insertions(+), 53 deletions(-)
diff --git a/js/index.js b/js/index.js
index 0b4d924..4a4ed6a 100644
--- a/js/index.js
+++ b/js/index.js
@@ -1,43 +1,57 @@
$(function() {
- $('#sidebar a').click(function(e) {
- if (e.currentTarget.href.indexOf('/?') == -1) {
- return;
- }
-
- e.preventDefault();
+ $('#sidebar').on('click', 'a', function(e) {
+ if (e.currentTarget.className.indexOf('deltree') !== -1) {
+ e.preventDefault();
- var href;
-
- if ((e.currentTarget.href.indexOf('?') == -1) ||
- (e.currentTarget.href.indexOf('?') == (e.currentTarget.href.length - 1))) {
- href = 'overview.php';
- } else {
- href = e.currentTarget.href.substr(e.currentTarget.href.indexOf('?') + 1);
-
- if (href.indexOf('&') != -1) {
- href = href.replace('&', '.php?');
- } else {
- href += '.php';
- }
- }
-
- if (href.indexOf('flush.php') == 0) {
- if (confirm('Are you sure you want to delete this key and all it\'s values?')) {
+ if (confirm('Are you sure you want to delete this whole tree and all it\'s keys?')) {
$.ajax({
type: "POST",
- url: href,
+ url: this.href,
data: 'post=1',
- success: function() {
- window.location.reload();
+ success: function(url) {
+ top.location.href = top.location.pathname+url;
}
});
}
} else {
- $('#iframe').attr('src', href);
+ if (e.currentTarget.href.indexOf('/?') == -1) {
+ return;
+ }
+
+ e.preventDefault();
+
+ var href;
+
+ if ((e.currentTarget.href.indexOf('?') == -1) ||
+ (e.currentTarget.href.indexOf('?') == (e.currentTarget.href.length - 1))) {
+ href = 'overview.php';
+ } else {
+ href = e.currentTarget.href.substr(e.currentTarget.href.indexOf('?') + 1);
+
+ if (href.indexOf('&') != -1) {
+ href = href.replace('&', '.php?');
+ } else {
+ href += '.php';
+ }
+ }
+
+ if (href.indexOf('flush.php') == 0) {
+ if (confirm('Are you sure you want to delete this key and all it\'s values?')) {
+ $.ajax({
+ type: "POST",
+ url: href,
+ data: 'post=1',
+ success: function() {
+ window.location.reload();
+ }
+ });
+ }
+ } else {
+ $('#iframe').attr('src', href);
+ }
}
});
-
$('#server').change(function(e) {
if (location.href.indexOf('?') == -1) {
location.href = location.href+'?s='+e.target.value;
@@ -62,7 +76,7 @@ $(function() {
$('li.current').parents('li.folder').removeClass('collapsed');
- $('li.folder').click(function(e) {
+ $('#sidebar').on('click', 'li.folder', function(e) {
var t = $(this);
if ((e.pageY >= t.offset().top) &&
@@ -72,14 +86,6 @@ $(function() {
}
});
- $('a').click(function() {
- $('li.current').removeClass('current');
- });
-
- $('li a').click(function() {
- $(this).parent().addClass('current');
- });
-
$('#btn_server_filter').click(function() {
var filter = $('#server_filter').val();
location.href = top.location.pathname + '?overview&s=' + $('#server').val() + '&d=' + ($('#database').val() || '') + '&filter=' + filter;
@@ -118,22 +124,6 @@ $(function() {
});
});
- $('.deltree').click(function(e) {
- e.preventDefault();
-
- if (confirm('Are you sure you want to delete this whole tree and all it\'s keys?')) {
- $.ajax({
- type: "POST",
- url: this.href,
- data: 'post=1',
- success: function(url) {
- top.location.href = top.location.pathname+url;
- }
- });
- }
- });
-
-
var isResizing = false;
var lastDownX = 0;
var lastWidth = 0;
From 8cf5e8e4aa544d86f6fc21466503849ef2e0fe48 Mon Sep 17 00:00:00 2001
From: Greg ORIOL
Date: Sat, 23 Apr 2016 12:05:13 +0200
Subject: [PATCH 037/147] Fixed missing current class toggle
---
js/index.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/js/index.js b/js/index.js
index 4a4ed6a..b440a77 100644
--- a/js/index.js
+++ b/js/index.js
@@ -49,6 +49,9 @@ $(function() {
} else {
$('#iframe').attr('src', href);
}
+
+ $('li.current').removeClass('current');
+ $(this).parent().addClass('current');
}
});
From 3a2655dde6bcc58d72770256bdbf0ec66e54f8d8 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sun, 24 Apr 2016 10:28:45 +0000
Subject: [PATCH 038/147] 1.6.0, fixes #95
---
README.markdown | 4 ++--
composer.json | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.markdown b/README.markdown
index fb17061..29a93cd 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,5 +1,5 @@
-phpRedisAdmin
-=============
+phpRedisAdmin 1.6.0
+===================
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 832bf35..287c77e 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.5.0",
+ "version": "1.6.0",
"license": "CC-BY-ND",
"homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin",
"authors": [
From 961e1d5ae94152b7494048b2df5e5f1a6e01b574 Mon Sep 17 00:00:00 2001
From: Erik Dubbelboer
Date: Sat, 21 May 2016 06:55:20 +0000
Subject: [PATCH 039/147] Fix #96
---
README.markdown | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.markdown b/README.markdown
index 29a93cd..115bcfc 100644
--- a/README.markdown
+++ b/README.markdown
@@ -28,7 +28,7 @@ curl -s http://getcomposer.org/installer | php
php composer.phar create-project -s dev erik-dubbelboer/php-redis-admin path/to/install
```
-You may also want to copy includes/config.simple.inc.php to includes/config.inc.php
+You may also want to copy includes/config.sample.inc.php to includes/config.inc.php
and edit it with your specific redis configuration.
Instead of using composer, you can also do a manual install using:
From f4640adf01b5e8428612bb2da49030497103b6f9 Mon Sep 17 00:00:00 2001
From: Devon Liu
Date: Thu, 22 Sep 2016 16:45:10 +0800
Subject: [PATCH 040/147] die on an exception occurred.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
otherwise it will get a inaccurate ERROR MSG when connect refused (e.g. a wrong server address) 。
---
includes/common.inc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/common.inc.php b/includes/common.inc.php
index 66c8769..e8f1cd1 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -121,7 +121,7 @@
try {
$redis->connect();
} catch (Predis\CommunicationException $exception) {
- $redis = false;
+ die('ERROR: ' . $exception->getMessage());
}
if (isset($server['auth'])) {
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 041/147] 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 042/147] 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 043/147] 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 044/147] 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 045/147] 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 046/147] 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 047/147] 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 048/147] 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 049/147] 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 050/147] 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 051/147] 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 052/147] 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 053/147] 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 054/147] 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 055/147] 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 056/147] 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 057/147] 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 058/147] 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 059/147] 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 060/147] 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 061/147] 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 062/147] 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 063/147] 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 064/147] 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 065/147] 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 066/147] 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 067/147] 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 068/147] 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 069/147] 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 070/147] 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 071/147] 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 072/147] 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 073/147] 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 074/147] 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 075/147] 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 076/147] 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 077/147] 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 078/147] 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 079/147] 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 080/147] 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 137/147] 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 138/147] 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 139/147] 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 140/147] 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 141/147] 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 142/147] 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 143/147] 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 144/147] 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 145/147] 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 146/147] 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 147/147] 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": [