From 412ce52e5418b691ef65ff632315312b48700e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgaras=20Janu=C5=A1auskas?= Date: Fri, 7 Apr 2017 15:19:49 +0300 Subject: [PATCH 001/107] Format TTL to days, hours or minutes --- includes/functions.inc.php | 9 +++++++++ view.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/functions.inc.php b/includes/functions.inc.php index 89368e3..f884260 100644 --- a/includes/functions.inc.php +++ b/includes/functions.inc.php @@ -74,6 +74,15 @@ function format_size($size) { } +function format_ttl($seconds) { + if ($seconds > 60) { + return sprintf('%d (%s)', $seconds, format_ago($seconds)); + } else { + return $seconds; + } +} + + function str_rand($length) { $r = ''; diff --git a/view.php b/view.php index 5799a2e..1bfff92 100644 --- a/view.php +++ b/view.php @@ -107,7 +107,7 @@
Type:
-
TTL:
[E]
+
TTL:
[E]
Encoding:
From 5ed9bbe9584b503ea24994d9cfb7265943cbab4e Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Sat, 8 Apr 2017 03:09:55 +0000 Subject: [PATCH 002/107] 1.7.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 287c77e..d39bc0c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.6.0", + "version": "1.7.0", "license": "CC-BY-ND", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From ec42e396b6259880b92dbf41f1075239f47d2322 Mon Sep 17 00:00:00 2001 From: Ares Date: Sat, 27 May 2017 12:57:43 +0800 Subject: [PATCH 003/107] replaceState problem Route will be wrong if domain has substring 'php'. eg. 'local.redis.phptest.com'. So fix it. --- js/frame.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/frame.js b/js/frame.js index c2f1d95..b3b84b5 100644 --- a/js/frame.js +++ b/js/frame.js @@ -1,6 +1,6 @@ $(function() { if (history.replaceState) { - window.parent.history.replaceState({}, '', document.location.href.replace('?', '&').replace(/([a-z]*)\.php/, '?$1')); + window.parent.history.replaceState({}, '', document.location.href.replace('?', '&').replace(/\/([a-z]*)\.php/, '/?$1')); } From f5a445d07c87524e892c3d14fd1250bf1a8fee3d Mon Sep 17 00:00:00 2001 From: Igor Sheviakov Date: Sun, 11 Jun 2017 16:40:11 +0300 Subject: [PATCH 004/107] changing style for #keys block adding netbeans metadata folder to .gitignore --- .gitignore | 3 +++ css/index.css | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index daf3eea..4dc5d11 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ config.inc.php *.phar vendor + +# IDEs metadata +/nbproject/ diff --git a/css/index.css b/css/index.css index 2c8faf5..80ceade 100644 --- a/css/index.css +++ b/css/index.css @@ -23,10 +23,6 @@ text-decoration: underline; #keys { -position: absolute; -top: 18.5em; -left: 0; -bottom: 0; width: 290px; padding-left: 10px; overflow: auto; @@ -45,6 +41,7 @@ font-weight: normal; #keys li.folder { font-weight: bold; margin-top: .05em; +cursor: pointer; } #keys li.current a { From a5617b025c5a51872763d1cc60984bd9b72081b3 Mon Sep 17 00:00:00 2001 From: Andrew Gillard Date: Tue, 13 Jun 2017 17:14:27 +0100 Subject: [PATCH 005/107] Allow logging in via HTML
and cookies rather than HTTP Digest auth --- css/login.css | 116 +++++++++++++++++++++++ includes/config.sample.inc.php | 3 + includes/login.inc.php | 165 ++++++++++++++++++++++++--------- login.php | 43 +++++++++ logout.php | 59 +++++++----- 5 files changed, 319 insertions(+), 67 deletions(-) create mode 100644 css/login.css create mode 100644 login.php diff --git a/css/login.css b/css/login.css new file mode 100644 index 0000000..f439934 --- /dev/null +++ b/css/login.css @@ -0,0 +1,116 @@ +/* Styles borrowed from http://getbootstrap.com/examples/signin/ */ +h1.logo { + text-align: center; +} +h2 { + font-size: 30px; +} +h2 { + margin-top: 20px; + margin-bottom: 10px; +} +h2 { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight: 500; + line-height: 1.1; + color: inherit; +} +.form-signin { + max-width: 330px; + padding: 15px; + margin: 0 auto; +} +.form-signin .form-signin-heading, +.form-signin .form-control { + position: relative; + height: auto; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 10px; +} +.form-signin .form-control:focus { + z-index: 2; +} +.form-signin input[type="text"] { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +.form-signin input[type="password"] { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} +.sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0,0,0,0); + border: 0; +} +.form-control { + display: block; + width: 100%; + height: 34px; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857143; + color: #555; + background-color: #fff; + background-image: none; + border: 1px solid #ccc; + border-radius: 4px; + -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); + box-shadow: inset 0 1px 1px rgba(0,0,0,.075); + -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s; + -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; + transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; +} +.btn { + display: inline-block; + padding: 6px 12px; + margin-bottom: 0; + font-size: 14px; + font-weight: 400; + line-height: 1.42857143; + text-align: center; + white-space: nowrap; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + background-image: none; + border: 1px solid transparent; + border-radius: 4px; +} +.btn-block { + display: block; + width: 100%; +} +.btn-lg { + padding: 10px 16px; + font-size: 18px; + line-height: 1.3333333; + border-radius: 6px; +} +.btn-primary { + color: #fff; + background-color: #337ab7; + border-color: #2e6da4; +} +.invalid-credentials { + border: 1px solid #ff0000; + background-color: rgba(255, 0, 0, 0.2); + color: #880000; + padding: 10px; + border-radius: 5px; + margin: 20px; +} diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 321c8d6..c11b25b 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -56,6 +56,9 @@ ) ),*/ + // Use HTML form/cookie-based auth instead of HTTP Basic/Digest auth + 'cookie_auth' => false, + /*'serialization' => array( 'foo*' => array( // Match like KEYS diff --git a/includes/login.inc.php b/includes/login.inc.php index 633bd94..cda4bad 100644 --- a/includes/login.inc.php +++ b/includes/login.inc.php @@ -1,63 +1,144 @@ 1, + 'nc' => 1, + 'cnonce' => 1, + 'qop' => 1, + 'username' => 1, + 'uri' => 1, + 'response' => 1 + ); -$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 (!empty($needed_parts)) { + header('HTTP/1.1 401 Unauthorized'); + header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.$opaque.'"'); + die; + } -if (!empty($needed_parts)) { - header('HTTP/1.1 401 Unauthorized'); - header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.$opaque.'"'); - die; -} + if (!isset($config['login'][$data['username']])) { + header('HTTP/1.1 401 Unauthorized'); + header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.$opaque.'"'); + die('Invalid username and/or password combination.'); + } -if (!isset($config['login'][$data['username']])) { - header('HTTP/1.1 401 Unauthorized'); - header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.$opaque.'"'); - die('Invalid username and/or password combination.'); -} + $login = $config['login'][$data['username']]; + $login['name'] = $data['username']; -$login = $config['login'][$data['username']]; -$login['name'] = $data['username']; + $password = md5($login['name'].':'.$realm.':'.$login['password']); -$password = md5($login['name'].':'.$realm.':'.$login['password']); + $response = md5($password.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.md5($_SERVER['REQUEST_METHOD'].':'.$data['uri'])); -$response = md5($password.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.md5($_SERVER['REQUEST_METHOD'].':'.$data['uri'])); + if ($data['response'] != $response) { + header('HTTP/1.1 401 Unauthorized'); + header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.$opaque.'"'); + die('Invalid username and/or password combination.'); + } + + return $login; +} + +// Perform auth using a standard HTML submission and cookies to save login state +function authCookie() +{ + global $config; + + $generateCookieHash = function($username) use ($config) { + if (!isset($config['login'][$username])) { + throw new \RuntimeException("Invalid username"); + } + + // Storing this value client-side so we need to be careful that it + // doesn't reveal anything nor can be guessed. + // Using SHA512 because MD5, SHA1 are both now considered broken + return hash( + 'sha512', + implode(':', [ + $username, + $_SERVER['HTTP_USER_AGENT'], + $_SERVER['REMOTE_ADDR'], + $config['login'][$username]['password'], + ]) + ); + }; + + if (!empty($_COOKIE['phpRedisAdminLogin'])) { + // We have a cookie; is it correct? + // Cookie value looks like "username:password-hash" + $cookieVal = explode(':', $_COOKIE['phpRedisAdminLogin']); + if (count($cookieVal) === 2) { + list($username, $cookieHash) = $cookieVal; + if (isset($config['login'][$username])) { + $userData = $config['login'][$username]; + $expectedHash = $generateCookieHash($username); + + if ($cookieHash === $expectedHash) { + // Correct username & password + return $userData; + } + } + } + } + + if (isset($_POST['username'], $_POST['password'])) { + // Login form submitted; correctly? + if ($config['login'][$_POST['username']]) { + $userData = $config['login'][$_POST['username']]; + if ($_POST['password'] === $userData['password']) { + // Correct username & password. Set cookie and redirect to home page + $cookieValue = $_POST['username'] . ':' . $generateCookieHash($_POST['username']); + setcookie('phpRedisAdminLogin', $cookieValue); + + // This should be an absolute URL, but that's a bit of a pain to generate; this will work + header("Location: index.php"); + die(); + } + } + } + + // 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 ($data['response'] != $response) { - header('HTTP/1.1 401 Unauthorized'); - header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.uniqid().'",opaque="'.$opaque.'"'); - die('Invalid username and/or password combination.'); +if (!empty($config['cookie_auth'])) { + $login = authCookie(); +} else { + $login = authHttpDigest(); } ?> diff --git a/login.php b/login.php new file mode 100644 index 0000000..dc0a887 --- /dev/null +++ b/login.php @@ -0,0 +1,43 @@ + + +

phpRedisAdmin

+ + + + + +
+

Invalid username/password

+

Please try again.

+
+ + + + > + + + > + + +
+ + diff --git a/logout.php b/logout.php index 2d6aca8..b5c9324 100644 --- a/logout.php +++ b/logout.php @@ -1,40 +1,49 @@ 1, - 'nc' => 1, - 'cnonce' => 1, - 'qop' => 1, - 'username' => 1, - 'uri' => 1, - 'response' => 1 - ); +if (!empty($config['cookie_auth'])) { + // Cookie-based auth + setcookie('phpRedisAdminLogin', '', 1); + header("Location: login.php"); + die(); +} else { + // HTTP Digest auth + $needed_parts = array( + 'nonce' => 1, + 'nc' => 1, + 'cnonce' => 1, + 'qop' => 1, + 'username' => 1, + 'uri' => 1, + 'response' => 1 + ); -$data = array(); -$keys = implode('|', array_keys($needed_parts)); + $data = array(); + $keys = implode('|', array_keys($needed_parts)); -preg_match_all('/('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))/', $_SERVER['PHP_AUTH_DIGEST'], $matches, PREG_SET_ORDER); + preg_match_all('/('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))/', $_SERVER['PHP_AUTH_DIGEST'], $matches, PREG_SET_ORDER); -foreach ($matches as $m) { - $data[$m[1]] = $m[3] ? $m[3] : $m[4]; - unset($needed_parts[$m[1]]); -} + foreach ($matches as $m) { + $data[$m[1]] = $m[3] ? $m[3] : $m[4]; + unset($needed_parts[$m[1]]); + } -if (!isset($_GET['nonce'])) { - header('Location: logout.php?nonce='.$data['nonce']); - die; -} + if (!isset($_GET['nonce'])) { + header('Location: logout.php?nonce='.$data['nonce']); + die; + } -if ($data['nonce'] == $_GET['nonce']) { - unset($_SERVER['PHP_AUTH_DIGEST']); + if ($data['nonce'] == $_GET['nonce']) { + unset($_SERVER['PHP_AUTH_DIGEST']); - require 'includes/login.inc.php'; -} + require 'includes/login.inc.php'; + } -header('Location: '.substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'logout.php'))); + header('Location: '.substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'logout.php'))); +} ?> From 88e9e0b7c6a0f153030217cd40aa4b1468d9339b Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 14 Aug 2017 09:21:52 +0000 Subject: [PATCH 006/107] 1.8.0 --- README.markdown | 4 ++-- composer.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 115bcfc..aa24a86 100644 --- a/README.markdown +++ b/README.markdown @@ -1,5 +1,5 @@ -phpRedisAdmin 1.6.0 -=================== +phpRedisAdmin +============= phpRedisAdmin is a simple web interface to manage [Redis](http://redis.io/) databases. It is released under the diff --git a/composer.json b/composer.json index d39bc0c..a8d026d 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.7.0", + "version": "1.8.0", "license": "CC-BY-ND", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 51a2a08dd86ce69f62eb6d55cf4efe4a7b32ff4b Mon Sep 17 00:00:00 2001 From: aplexup <32103435+aplexup@users.noreply.github.com> Date: Tue, 19 Sep 2017 18:39:26 +0300 Subject: [PATCH 007/107] Update login.inc.php If using "cookie_auth" and enter not exists login, then PHP show "Notice: Undefined index: a in /usr/www/pra/includes/login.inc.php on line 112" --- includes/login.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/login.inc.php b/includes/login.inc.php index cda4bad..f1abce6 100644 --- a/includes/login.inc.php +++ b/includes/login.inc.php @@ -109,7 +109,7 @@ function authCookie() if (isset($_POST['username'], $_POST['password'])) { // Login form submitted; correctly? - if ($config['login'][$_POST['username']]) { + if (isset($config['login'][$_POST['username']])) { $userData = $config['login'][$_POST['username']]; if ($_POST['password'] === $userData['password']) { // Correct username & password. Set cookie and redirect to home page From b38b7d2fd63f5ccc0c80b0cca9c0e017b7423fcc Mon Sep 17 00:00:00 2001 From: fratuz610 Date: Wed, 8 Nov 2017 19:31:18 +1100 Subject: [PATCH 008/107] Improved export functionality (#120) Added support for filter and transform parameters while exporting bulk databases --- export.php | 61 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/export.php b/export.php index 69c15c4..ae1f0c3 100644 --- a/export.php +++ b/export.php @@ -3,18 +3,22 @@ require_once 'includes/common.inc.php'; - - // Export to redis-cli commands -function export_redis($key) { +function export_redis($key, $filter = false, $transform = false) { + global $redis; $type = $redis->type($key); - + // we rename the keys as necessary + if($filter !== false && $transform !== false) + $outputKey = str_replace($filter, $transform, $key); + else + $outputKey = $key; + // String if ($type == 'string') { - echo 'SET "',addslashes($key),'" "',addslashes($redis->get($key)),'"',PHP_EOL; + echo 'SET "',addslashes($outputKey),'" "',addslashes($redis->get($key)),'"',PHP_EOL; } // Hash @@ -22,7 +26,7 @@ function export_redis($key) { $values = $redis->hGetAll($key); foreach ($values as $k => $v) { - echo 'HSET "',addslashes($key),'" "',addslashes($k),'" "',addslashes($v),'"',PHP_EOL; + echo 'HSET "',addslashes($outputKey),'" "',addslashes($k),'" "',addslashes($v),'"',PHP_EOL; } } @@ -31,7 +35,7 @@ function export_redis($key) { $size = $redis->lLen($key); for ($i = 0; $i < $size; ++$i) { - echo 'RPUSH "',addslashes($key),'" "',addslashes($redis->lIndex($key, $i)),'"',PHP_EOL; + echo 'RPUSH "',addslashes($outputKey),'" "',addslashes($redis->lIndex($key, $i)),'"',PHP_EOL; } } @@ -40,7 +44,7 @@ function export_redis($key) { $values = $redis->sMembers($key); foreach ($values as $v) { - echo 'SADD "',addslashes($key),'" "',addslashes($v),'"',PHP_EOL; + echo 'SADD "',addslashes($outputKey),'" "',addslashes($v),'"',PHP_EOL; } } @@ -51,7 +55,7 @@ function export_redis($key) { foreach ($values as $v) { $s = $redis->zScore($key, $v); - echo 'ZADD "',addslashes($key),'" ',$s,' "',addslashes($v),'"',PHP_EOL; + echo 'ZADD "',addslashes($outputKey),'" ',$s,' "',addslashes($v),'"',PHP_EOL; } } } @@ -64,7 +68,6 @@ function export_json($key) { $type = $redis->type($key); - // String if ($type == 'string') { $value = $redis->get($key); @@ -116,9 +119,12 @@ function export_json($key) { header('Content-type: '.$ct.'; charset=utf-8'); header('Content-Disposition: inline; filename="export.'.$ext.'"'); + $filter = !empty($_POST['filter']) ? trim($_POST['filter']) : false; + $transform = !empty($_POST['transform']) ? trim($_POST['transform']) : false; // JSON if ($_POST['type'] == 'json') { + // Single key if (isset($_GET['key'])) { echo json_encode(export_json($_GET['key'])); @@ -127,7 +133,18 @@ function export_json($key) { $vals = array(); foreach ($keys as $key) { - $vals[$key] = export_json($key); + + // if we have a filter and no match, nothing to do + if($filter !== false && stripos($key, $filter) === false) + continue; + + // we rename the keys as necessary + if($filter !== false && $transform !== false) + $outputKey = str_replace($filter, $transform, $key); + else + $outputKey = $key; + + $vals[$outputKey] = export_json($key); } echo json_encode($vals); @@ -136,6 +153,7 @@ function export_json($key) { // Redis Commands else { + // Single key if (isset($_GET['key'])) { export_redis($_GET['key']); @@ -143,7 +161,12 @@ function export_json($key) { $keys = $redis->keys('*'); foreach ($keys as $key) { - export_redis($key); + + // if we have a filter and no match, we skip + if($filter !== false && stripos($key, $filter) === false) + continue; + + export_redis($key, $filter, $transform); } } } @@ -171,7 +194,19 @@ function export_json($key) { -

+

+ + +

+ + +

+ +

+ + +

+

From b8d054de1d661188379aa357e32f0c3d2be94b5c Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Wed, 8 Nov 2017 08:34:20 +0000 Subject: [PATCH 009/107] Fix #119 --- composer.lock | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.lock b/composer.lock index cd0cb49..b9c3078 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "e81aef935c2a6d36cf7690dbdb9d129a", - "content-hash": "3212fc4e8463f3bf5ff7db4655eecbf0", + "content-hash": "c4f147b8be07b8af9b1dfaffaa9a7616", "packages": [ { "name": "predis/predis", @@ -55,7 +54,7 @@ "predis", "redis" ], - "time": "2015-07-30 18:34:15" + "time": "2015-07-30T18:34:15+00:00" } ], "packages-dev": [], From f3000673c5c67811c3da8c12395d2cf6974d406a Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Wed, 8 Nov 2017 08:46:36 +0000 Subject: [PATCH 010/107] 1.9.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a8d026d..fa9bd8b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.8.0", + "version": "1.9.0", "license": "CC-BY-ND", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 46d0e40fdffe21cd86a6a310a5c380eb070765c8 Mon Sep 17 00:00:00 2001 From: pataquets Date: Wed, 10 Jan 2018 20:21:00 +0100 Subject: [PATCH 011/107] Add Docker usage docs and Docker Compose manifest for testing/development. --- README.markdown | 10 ++++++++++ docker-compose.yml | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 docker-compose.yml diff --git a/README.markdown b/README.markdown index aa24a86..19fd8d7 100644 --- a/README.markdown +++ b/README.markdown @@ -39,6 +39,16 @@ cd phpRedisAdmin git clone https://github.com/nrk/predis.git vendor ``` +Docker Image +============ +A public [phpRedisAdmin Docker image](https://hub.docker.com/r/erikdubbelboer/phpredisadmin/) is available on Docker Hub [automatically built](https://docs.docker.com/docker-hub/builds/) from latest source. +The file ```includes/config.environment.inc.php``` is used as the configuration file to allow environment variables to be used as configuration values. +Example: +``` +docker run --rm -it -e REDIS_1_HOST=myredis.host -e REDIS_1_NAME=MyRedis -p 80:80 erikdubbelboer/phpredisadmin +``` +Also, a Docker Compose manifest with a stack for testing and development is provided. Just issue ```docker-compose up --build``` to start it and browse to http://localhost. See ```docker-compose.yml``` file for configuration details. + TODO ==== diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..dab64b9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +phpredisadmin: + build: . + environment: + - ADMIN_USER=admin + - ADMIN_PASS=admin + - REDIS_1_HOST=redis + - REDIS_1_PORT=6379 + links: + - redis + ports: + - "80:80" + +redis: + image: redis + command: --loglevel verbose From e4731fea07e715ad7afe3948ca5c0cab349f4545 Mon Sep 17 00:00:00 2001 From: pataquets Date: Wed, 10 Jan 2018 20:21:41 +0100 Subject: [PATCH 012/107] Fix: delete inherited servers when loading configuration from environment variables. --- includes/config.environment.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index bb7c76c..7f32a20 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -14,6 +14,7 @@ } $i=1; +$config['servers'] = array(); while (TRUE) { From ca42173213dc62c541921ee31aa525097e81ba86 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Thu, 11 Jan 2018 06:20:19 +0000 Subject: [PATCH 013/107] v1.10.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fa9bd8b..7ac4a22 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.9.0", + "version": "1.10.0", "license": "CC-BY-ND", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 260ad43edbc2e390e03b6878c3d746ff2d86a6ca Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Tue, 16 Jan 2018 07:22:34 +0000 Subject: [PATCH 014/107] v1.10.1 To test the docker build system. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7ac4a22..96cb7eb 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.10.0", + "version": "1.10.1", "license": "CC-BY-ND", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From ed103da0ee08402bb12d09e12fc346db9b155ae5 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 23 Feb 2018 02:31:39 +0000 Subject: [PATCH 015/107] Fix license in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 96cb7eb..cb5da2e 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", "version": "1.10.1", - "license": "CC-BY-ND", + "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ { From 36e35016a41bb0b8545d028f7db90e2f62b0e9c4 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 23 Feb 2018 02:33:18 +0000 Subject: [PATCH 016/107] v1.10.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cb5da2e..ca3887f 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.10.1", + "version": "1.10.2", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 9668550081e56b6a5ed0da033d111ccfdef42084 Mon Sep 17 00:00:00 2001 From: ppeer Date: Thu, 22 Mar 2018 16:06:44 +0100 Subject: [PATCH 017/107] added ',' to line 12 as response to: "PHP message: PHP Parse error: syntax error, unexpected ''auth'' (T_CONSTANT_ENCAPSED_STRING)" --- includes/config.sample.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index c11b25b..558f231 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -9,7 +9,7 @@ 'port' => 6379, 'filter' => '*', 'scheme' => 'tcp', // Optional. Connection scheme. 'tcp' - for TCP connection, 'unix' - for connection by unix domain socket - 'path' => '' // Optional. Path to unix domain socket. Uses only if 'scheme' => 'unix'. Example: '/var/run/redis/redis.sock' + 'path' => '', // Optional. Path to unix domain socket. Uses only if 'scheme' => 'unix'. Example: '/var/run/redis/redis.sock' // Optional Redis authentication. //'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server. From 4e226fc08b1a98b17c29c7de9458d9ca196ca825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E6=9C=A8=E5=A4=A9=E7=90=AA?= Date: Thu, 24 May 2018 18:09:21 +0800 Subject: [PATCH 018/107] Update config.environment.inc.php add auth config to environment --- includes/config.environment.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index 7f32a20..cde45e0 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -23,7 +23,8 @@ $server_name = getenv($prefix . 'NAME'); $server_host = getenv($prefix . 'HOST'); $server_port = getenv($prefix . 'PORT'); - + $server_auth = getenv($prefix . 'AUTH'); + if (empty($server_host)) { break; } @@ -40,6 +41,7 @@ 'name' => $server_name, 'host' => $server_host, 'port' => $server_port, + 'auth' => $server_auth, 'filter' => '*', ); From 2cf0f7708db7fa2b008b08a441e5deb94d0388f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A4=E6=9C=A8=E5=A4=A9=E7=90=AA?= Date: Thu, 24 May 2018 18:21:24 +0800 Subject: [PATCH 019/107] Update config.environment.inc.php fix auth config env --- includes/config.environment.inc.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index cde45e0..d8c9ae8 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -24,7 +24,7 @@ $server_host = getenv($prefix . 'HOST'); $server_port = getenv($prefix . 'PORT'); $server_auth = getenv($prefix . 'AUTH'); - + if (empty($server_host)) { break; } @@ -32,6 +32,10 @@ if (empty($server_name)) { $server_name = $server_host; } + + if (empty($server_auth)) { + $server_auth = ""; + } if (empty($server_port)) { $server_port = 6379; @@ -41,9 +45,12 @@ 'name' => $server_name, 'host' => $server_host, 'port' => $server_port, - 'auth' => $server_auth, 'filter' => '*', ); + + if (!empty($server_auth)) { + $config['servers'][$i-1]['auth'] = $server_auth; + } $i++; } From c9e364be158b6b78ab96b5c7894e5c811fc704dd Mon Sep 17 00:00:00 2001 From: JACK Date: Sat, 4 Aug 2018 05:57:35 +0800 Subject: [PATCH 020/107] Correction time shows that time is more scientific (#130) Improve time formatting --- includes/functions.inc.php | 39 +++++++++++++++----------------------- overview.php | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/includes/functions.inc.php b/includes/functions.inc.php index f884260..10f8dcd 100644 --- a/includes/functions.inc.php +++ b/includes/functions.inc.php @@ -26,39 +26,30 @@ function input_convert($str) { } -function format_ago($time, $ago = false) { +function format_time($time) { $minute = 60; $hour = $minute * 60; $day = $hour * 24; $when = $time; - if ($when >= 0) - $suffix = 'ago'; - else { - $when = -$when; - $suffix = 'in the future'; - } - if ($when > $day) { - $when = round($when / $day); - $what = 'day'; + $tmpday = floor($when / $day); + $tmphour = floor(($when / $hour) - (24*$tmpday)); + $tmpminute = floor(($when / $minute) - (24*60*$tmpday) - ($tmphour * 60)); + $tmpsec = floor($when - (24*60*60*$tmpday) - ($tmphour * 60 * 60) - ($tmpminute * 60)); + return sprintf("%d day%s %d hour%s %d min%s %d sec%s",$tmpday,($tmpday != 1) ? 's' : '',$tmphour,($tmphour != 1) ? 's' : '',$tmpminute,($tmpminute != 1) ? 's' : '',$tmpsec,($tmpsec != 1) ? 's' : ''); } else if ($when > $hour) { - $when = round($when / $hour); - $what = 'hour'; + $tmphour = floor($when / $hour); + $tmpminute = floor(($when / $minute) - ($tmphour * 60)); + $tmpsec = floor($when - ($tmphour * 60 * 60) - ($tmpminute * 60)); + return sprintf("%d hour%s %d min%s %d sec%s",$tmphour,($tmphour != 1) ? 's' : '',$tmpminute,($tmpminute != 1) ? 's' : '',$tmpsec,($tmpsec != 1) ? 's' : ''); } else if ($when > $minute) { - $when = round($when / $minute); - $what = 'minute'; - } else { - $what = 'second'; - } - - if ($when != 1) $what .= 's'; - - if ($ago) { - return "$when $what $suffix"; + $tmpminute = floor($when / $minute); + $tmpsec = floor($when - ($tmpminute * 60)); + return sprintf("%d min%s %d sec%s",$tmpminute,($tmpminute != 1) ? 's' : '',$tmpsec,($tmpsec != 1) ? 's' : ''); } else { - return "$when $what"; + return sprintf("%d sec%s",$when,($when != 1) ? 's' : ''); } } @@ -76,7 +67,7 @@ function format_size($size) { function format_ttl($seconds) { if ($seconds > 60) { - return sprintf('%d (%s)', $seconds, format_ago($seconds)); + return sprintf('%d (%s)', $seconds, format_time($seconds)); } else { return $seconds; } diff --git a/overview.php b/overview.php index 8c0b073..007e2d6 100644 --- a/overview.php +++ b/overview.php @@ -83,9 +83,21 @@

Memory used:
-
Uptime:
- -
Last save:
[S]
+
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'; + } + ?> + [S]
From 451caf7b7c1869560619a8b18fc560fcc5d49fd2 Mon Sep 17 00:00:00 2001 From: toughIQ Date: Tue, 21 Aug 2018 16:45:53 +0200 Subject: [PATCH 021/107] changed FROM image (#132) changed base image from "composer/composer", which is deprecated, to current "composer" with tag "1.7" Also reduced image size from 650MB to 150MB. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ebca2d9..57830ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM composer/composer +FROM composer:1.7 ADD . /src/app/ WORKDIR /src/app From 687a7928a0509438d0eca5ebc8ad7d0d1966cd02 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Tue, 21 Aug 2018 14:45:28 +0000 Subject: [PATCH 022/107] v1.11.0 Using predis 1.1.1 and docker composer:1.7 image --- composer.json | 4 ++-- composer.lock | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index ca3887f..a28d814 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.10.2", + "version": "1.11.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ @@ -13,7 +13,7 @@ } ], "require": { - "predis/predis": "1.0.3" + "predis/predis": "1.1.1" }, "minimum-stability": "stable", "target-dir": "ErikDubbelboer/phpRedisAdmin" diff --git a/composer.lock b/composer.lock index b9c3078..c07bb64 100644 --- a/composer.lock +++ b/composer.lock @@ -1,30 +1,30 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c4f147b8be07b8af9b1dfaffaa9a7616", + "content-hash": "e2489e7a22a6412f072878dd7c867843", "packages": [ { "name": "predis/predis", - "version": "v1.0.3", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/nrk/predis.git", - "reference": "84060b9034d756b4d79641667d7f9efe1aeb8e04" + "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nrk/predis/zipball/84060b9034d756b4d79641667d7f9efe1aeb8e04", - "reference": "84060b9034d756b4d79641667d7f9efe1aeb8e04", + "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1", + "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": ">=5.3.9" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~4.8" }, "suggest": { "ext-curl": "Allows access to Webdis when paired with phpiredis", @@ -47,14 +47,14 @@ "homepage": "http://clorophilla.net/" } ], - "description": "Flexible and feature-complete PHP client library for Redis", + "description": "Flexible and feature-complete Redis client for PHP and HHVM", "homepage": "http://github.com/nrk/predis", "keywords": [ "nosql", "predis", "redis" ], - "time": "2015-07-30T18:34:15+00:00" + "time": "2016-06-16T16:22:20+00:00" } ], "packages-dev": [], From ed5966f637ceda71b63693bd3d8fd336a840d01a Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 3 Sep 2018 01:29:33 +0000 Subject: [PATCH 023/107] Fix redeclare authCookie error Fixes https://github.com/erikdubbelboer/phpRedisAdmin/issues/133 --- logout.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/logout.php b/logout.php index b5c9324..afede7e 100644 --- a/logout.php +++ b/logout.php @@ -39,7 +39,11 @@ if ($data['nonce'] == $_GET['nonce']) { unset($_SERVER['PHP_AUTH_DIGEST']); - require 'includes/login.inc.php'; + if (!empty($config['cookie_auth'])) { + $login = authCookie(); + } else { + $login = authHttpDigest(); + } } From da821c44e30a07922e29fe1fd81553069fafe3a7 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 24 Sep 2018 12:26:15 +0000 Subject: [PATCH 024/107] Fix -1 to push to the start of a list Fixes #135 --- edit.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/edit.php b/edit.php index e50da25..4842655 100644 --- a/edit.php +++ b/edit.php @@ -58,10 +58,12 @@ $size = $redis->lLen($key); if (($_POST['index'] == '') || - ($_POST['index'] == $size) || - ($_POST['index'] == -1)) { + ($_POST['index'] == $size)) { // Push it at the end $redis->rPush($key, $value); + } else if ($_POST['index'] == -1) { + // Push it at the start + $redis->lPush($key, $value); } else if (($_POST['index'] >= 0) && ($_POST['index'] < $size)) { // Overwrite an index From ea40bf4a9160990722ce705954b01a417da7ca7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=81=A5?= Date: Wed, 23 Jan 2019 09:34:33 +0800 Subject: [PATCH 025/107] fix a bug: remove tree action will do nothing when 'seperator' config is not ':' --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index f56c572..e575b2c 100644 --- a/index.php +++ b/index.php @@ -109,7 +109,7 @@ function print_namespace($item, $name, $fullkey, $islast) { ?>
  •  () - [X] + [X]
      Date: Thu, 24 Jan 2019 20:24:46 +0000 Subject: [PATCH 026/107] Fix PHP 5.3 compatibility Fixes #140 --- includes/login.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/login.inc.php b/includes/login.inc.php index f1abce6..75ed28d 100644 --- a/includes/login.inc.php +++ b/includes/login.inc.php @@ -80,12 +80,12 @@ function authCookie() // Using SHA512 because MD5, SHA1 are both now considered broken return hash( 'sha512', - implode(':', [ + implode(':', array( $username, $_SERVER['HTTP_USER_AGENT'], $_SERVER['REMOTE_ADDR'], $config['login'][$username]['password'], - ]) + )) ); }; From 6ced4d2aba817c6e8ae1665298e78c60a1f234a3 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Thu, 24 Jan 2019 20:26:52 +0000 Subject: [PATCH 027/107] v1.11.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a28d814..34b18cc 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.11.0", + "version": "1.11.1", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From f49526a61519ac48215b9f00aa2c441c30030e9d Mon Sep 17 00:00:00 2001 From: friendlydan <47954270+friendlydan@users.noreply.github.com> Date: Tue, 2 Apr 2019 21:39:32 +1300 Subject: [PATCH 028/107] Fix case of contants based on best practices from PSR2 (#141) Signed-off-by: CodeLingoBot --- includes/config.environment.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index d8c9ae8..0522421 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -16,7 +16,7 @@ $i=1; $config['servers'] = array(); -while (TRUE) { +while (true) { $prefix = 'REDIS_' . $i . '_'; From 249fd9edad4213a9742c1e46ef89b3bee65e010b Mon Sep 17 00:00:00 2001 From: Maciej Klak Date: Mon, 3 Jun 2019 08:21:37 +0200 Subject: [PATCH 029/107] Add tini (#142) --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 57830ce..0597c23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,10 +3,13 @@ FROM composer:1.7 ADD . /src/app/ WORKDIR /src/app +ENV TINI_VERSION 0.18.0-r0 + RUN \ + apk add --no-cache tini=$TINI_VERSION && \ composer install && \ cp includes/config.environment.inc.php includes/config.inc.php EXPOSE 80 -ENTRYPOINT [ "php", "-S", "0.0.0.0:80" ] +ENTRYPOINT [ "tini", "--", "php", "-S", "0.0.0.0:80" ] From c8cb378ba7c51559ef4955dfdca3b104ba817d1b Mon Sep 17 00:00:00 2001 From: Yige Date: Fri, 14 Jun 2019 14:00:39 +0800 Subject: [PATCH 030/107] Update README.markdown (#138) * Update README.markdown Add Environment variables summary * Update README.markdown --- README.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.markdown b/README.markdown index 19fd8d7..ddf39d3 100644 --- a/README.markdown +++ b/README.markdown @@ -49,6 +49,16 @@ docker run --rm -it -e REDIS_1_HOST=myredis.host -e REDIS_1_NAME=MyRedis -p 80:8 ``` Also, a Docker Compose manifest with a stack for testing and development is provided. Just issue ```docker-compose up --build``` to start it and browse to http://localhost. See ```docker-compose.yml``` file for configuration details. +Environment variables summary +==== + +* ``REDIS_1_HOST`` - define host of the Redis server +* ``REDIS_1_NAME`` - define name of the Redis server +* ``REDIS_1_PORT`` - define port of the Redis server +* ``REDIS_1_AUTH`` - define password of the Redis server +* ``ADMIN_USER`` - define username for user-facing Basic Auth +* ``ADMIN_PASS`` - define password for user-facing Basic Auth + TODO ==== From 7a8c84b4af5b07686f78e2b644c8157b879fc431 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 14 Jun 2019 05:45:25 +0000 Subject: [PATCH 031/107] Fix PHP 7.3 compatibility Fixes #143 --- composer.json | 2 +- composer.lock | 16 +++++++++------- includes/common.inc.php | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 34b18cc..c741447 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } ], "require": { - "predis/predis": "1.1.1" + "predis/predis": "1.1.x-dev" }, "minimum-stability": "stable", "target-dir": "ErikDubbelboer/phpRedisAdmin" diff --git a/composer.lock b/composer.lock index c07bb64..ac3a614 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e2489e7a22a6412f072878dd7c867843", + "content-hash": "0c346d5e2f2e0897260911e1b2966180", "packages": [ { "name": "predis/predis", - "version": "v1.1.1", + "version": "v1.1.x-dev", "source": { "type": "git", "url": "https://github.com/nrk/predis.git", - "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1" + "reference": "111d100ee389d624036b46b35ed0c9ac59c71313" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1", - "reference": "f0210e38881631afeafb56ab43405a92cafd9fd1", + "url": "https://api.github.com/repos/nrk/predis/zipball/111d100ee389d624036b46b35ed0c9ac59c71313", + "reference": "111d100ee389d624036b46b35ed0c9ac59c71313", "shasum": "" }, "require": { @@ -54,13 +54,15 @@ "predis", "redis" ], - "time": "2016-06-16T16:22:20+00:00" + "time": "2017-07-12T14:39:17+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "predis/predis": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": [], diff --git a/includes/common.inc.php b/includes/common.inc.php index e8f1cd1..367c539 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -7,7 +7,7 @@ if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { $process = array(&$_GET, &$_POST); - while (list($key, $val) = each($process)) { + foreach ($process as $key => $val) { foreach ($val as $k => $v) { unset($process[$key][$k]); From de084f5b1581ac4e23f8dc507308f6e5a4d61590 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 14 Jun 2019 05:45:42 +0000 Subject: [PATCH 032/107] Improve Dockerfile Change order so layers can be cached more properly. --- Dockerfile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0597c23..bdd0a48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,14 @@ FROM composer:1.7 -ADD . /src/app/ -WORKDIR /src/app - ENV TINI_VERSION 0.18.0-r0 -RUN \ - apk add --no-cache tini=$TINI_VERSION && \ - composer install && \ - cp includes/config.environment.inc.php includes/config.inc.php +RUN apk add --no-cache tini=$TINI_VERSION +RUN composer install -EXPOSE 80 +ADD . /src/app/ + +RUN cp includes/config.environment.inc.php includes/config.inc.php +WORKDIR /src/app +EXPOSE 80 ENTRYPOINT [ "tini", "--", "php", "-S", "0.0.0.0:80" ] From 83ca06f519dd69422b7b7c4d49e4bdd10b86b395 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 14 Jun 2019 05:46:41 +0000 Subject: [PATCH 033/107] v1.11.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c741447..188d1aa 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.11.1", + "version": "1.11.2", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 534bfe411e59dc2733387fc11ad109f770c1f8b6 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 14 Jun 2019 06:05:19 +0000 Subject: [PATCH 034/107] Fix Dockerfile --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index bdd0a48..fd40ac1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,14 @@ FROM composer:1.7 ENV TINI_VERSION 0.18.0-r0 RUN apk add --no-cache tini=$TINI_VERSION -RUN composer install ADD . /src/app/ +WORKDIR /src/app + +RUN composer install + RUN cp includes/config.environment.inc.php includes/config.inc.php -WORKDIR /src/app EXPOSE 80 ENTRYPOINT [ "tini", "--", "php", "-S", "0.0.0.0:80" ] From 9d37b0957f8cd90fa4e13ceddb956d85989224d8 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 14 Jun 2019 06:31:32 +0000 Subject: [PATCH 035/107] v1.11.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 188d1aa..f837aef 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.11.2", + "version": "1.11.3", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From df4f1e8dd7e773eebe88218510d90ef1161b1a39 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Tue, 2 Jul 2019 13:40:23 +0000 Subject: [PATCH 036/107] Show for empty key names --- index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.php b/index.php index e575b2c..8e695e0 100644 --- a/index.php +++ b/index.php @@ -96,6 +96,9 @@ function print_namespace($item, $name, $fullkey, $islast) { } } + if (empty($name)) { + $name = ''; + } ?> > From 4c0c99cd8d1289b389d9b9a4cc3dbdba2d75acc7 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Tue, 2 Jul 2019 13:43:58 +0000 Subject: [PATCH 037/107] v1.11.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f837aef..5199506 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.11.3", + "version": "1.11.4", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 913fac2159b922f0a9e335916fc6fa57606acd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E9=A2=97=E7=BA=A2=E5=BF=83?= Date: Mon, 19 Aug 2019 16:41:27 +0800 Subject: [PATCH 038/107] Add features: batch delete (#145) * Add features: batch delete --- delete.php | 13 +++++++++++++ index.php | 6 +++++- js/index.js | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/delete.php b/delete.php index df51bee..cde8539 100644 --- a/delete.php +++ b/delete.php @@ -60,4 +60,17 @@ die('?view&s='.$server['id'].'&d='.$server['db']); } +if (isset($_GET['batch_del'])) { + $keys = $_POST['selected_keys']; + $keys = trim($keys, ','); + if (empty($keys)) die('No keys to delete'); + + $keys = explode(',', $keys); + foreach ($keys as $key) { + $redis->del($key); + } + + die('?view&s=' . $server['id'] . '&d=' . $server['db'] . '&key=' . urlencode($keys[0])); +} + ?> diff --git a/index.php b/index.php index 8e695e0..ae5ad90 100644 --- a/index.php +++ b/index.php @@ -102,6 +102,7 @@ function print_namespace($item, $name, $fullkey, $islast) { ?> > + ()

      - + +
        diff --git a/js/index.js b/js/index.js index b440a77..de45790 100644 --- a/js/index.js +++ b/js/index.js @@ -1,6 +1,40 @@ $(function() { + $('#selected_all_keys').on('click', function () { + if ($(this).html()=='Select all'){ + $('input[name=checked_keys]').each(function () { + $(this).attr('checked', 'checked'); + }); + $(this).html('Select none'); + }else { + $('input[name=checked_keys]').each(function () { + $(this).removeAttr('checked'); + }); + $(this).html('Select all'); + } + }) + $('#sidebar').on('click', 'a', function(e) { - if (e.currentTarget.className.indexOf('deltree') !== -1) { + if (e.currentTarget.className.indexOf('batch_del') !== -1){ + e.preventDefault(); + var selected_keys = ''; + $('input[name=checked_keys]:checked').each(function () { + selected_keys += $(this).val() + ','; + }); + if (!selected_keys) { + alert('Please select the keys you want to delete.'); + return; + } + if (confirm('Are you sure you want to delete all selected keys?')) { + $.ajax({ + type: "POST", + url: this.href, + data: 'post=1&selected_keys=' + selected_keys, + success: function(url) { + top.location.href = top.location.pathname+url; + } + }); + } + }else if (e.currentTarget.className.indexOf('deltree') !== -1) { e.preventDefault(); if (confirm('Are you sure you want to delete this whole tree and all it\'s keys?')) { From a858f60baea28405b0373ddf42fc77a56bc10820 Mon Sep 17 00:00:00 2001 From: Atef Ben Ali Date: Thu, 19 Sep 2019 12:04:45 +0100 Subject: [PATCH 039/107] style: remove `?>` php ending tag (#146) The `?>` ending tag is optional in a pure `php` file. --- includes/config.sample.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 558f231..10e043d 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -81,5 +81,3 @@ // How many entries to fetch using each SCAN command. 'scansize' => 1000 ); - -?> From 0e8e4724be4016f75608aafd1c260b6f3350c490 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 27 Sep 2019 20:10:43 +0000 Subject: [PATCH 040/107] Make all paths relative --- edit.php | 2 +- export.php | 2 +- import.php | 2 +- includes/functions.inc.php | 3 +++ logout.php | 4 +--- rename.php | 2 +- ttl.php | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/edit.php b/edit.php index 4842655..0940503 100644 --- a/edit.php +++ b/edit.php @@ -144,7 +144,7 @@ ?>

        -
        +

        diff --git a/export.php b/export.php index ae1f0c3..c886e46 100644 --- a/export.php +++ b/export.php @@ -186,7 +186,7 @@ function export_json($key) { ?>

        Export

        - +

        diff --git a/import.php b/import.php index 9dbca76..1786164 100644 --- a/import.php +++ b/import.php @@ -91,7 +91,7 @@ ?>

        Import

        - +

        Edit Name of

        - + diff --git a/ttl.php b/ttl.php index b326823..6db0cb2 100644 --- a/ttl.php +++ b/ttl.php @@ -26,7 +26,7 @@ ?>

        Edit TTL

        - +

        From f20eda4baf6838a1b79379ee92e2669a5de197e2 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 27 Sep 2019 20:11:52 +0000 Subject: [PATCH 041/107] v1.11.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5199506..7d6cb26 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.4", + "version": "1.11.5", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 4a23c51c8b30409c57aa191cf74e29bae2b9c431 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Tue, 22 Oct 2019 06:56:15 +0200 Subject: [PATCH 042/107] Trying out github sponsorship --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..a5fe8e7 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [erikdubbelboer] From 5e870a22a8dda82cc148656a6462305576b807d6 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Sat, 16 Nov 2019 12:11:51 -0500 Subject: [PATCH 043/107] fix keys ending in :0 shown as (#148) --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index ae5ad90..cd96cd3 100644 --- a/index.php +++ b/index.php @@ -96,7 +96,7 @@ function print_namespace($item, $name, $fullkey, $islast) { } } - if (empty($name)) { + if (empty($name) && $name != '0') { $name = ''; } From 484714a25771e41b451bd2aaee068e5e0c07a0b5 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Sun, 17 Nov 2019 15:27:11 -0500 Subject: [PATCH 044/107] show number of keys in database drop-down list (#150) also added an option to hide empty database the option can be set for all databases or on a database level the default is that empty database are shown closes #149 --- includes/common.inc.php | 4 ++++ includes/config.sample.inc.php | 3 +++ index.php | 26 ++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/includes/common.inc.php b/includes/common.inc.php index 367c539..c50a2f3 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -111,6 +111,10 @@ } } +if (!isset($config['hideEmptyDBs'])) { + $config['hideEmptyDBs'] = 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'])); diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 10e043d..e24aa52 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -10,6 +10,7 @@ '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' + 'hide' => false, // Optional. Override global setting. Hide empty databases in the database list. // Optional Redis authentication. //'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server. @@ -38,6 +39,8 @@ 'seperator' => ':', + // Hide empty databases in the database list (global, valid for all servers unless set at server level) + 'hideEmptyDBs' => false, // Uncomment to show less information and make phpRedisAdmin fire less commands to the Redis server. Recommended for a really busy Redis server. //'faster' => true, diff --git a/index.php b/index.php index cd96cd3..fc271b6 100644 --- a/index.php +++ b/index.php @@ -137,9 +137,30 @@ function print_namespace($item, $name, $fullkey, $islast) { } } + function getDbInfo($d, $info, $padding = '') { + global $config, $server; + $prefix = "database "; + $db = "db$d"; + + $dbHasData = array_key_exists("db$d", $info['Keyspace']); + + if (!$dbHasData && ((isset($server['hide']) && $server['hide']) || (!isset($server['hide']) && $config['hideEmptyDBs']))) { + return false; // we don't show empty dbs, so return false to tell the caller to continue the loop + } + + $dbinfo = sprintf("$prefix%'.-${padding}d", $d); + if ($dbHasData) { + $dbinfo = sprintf("%s (%d)", $dbinfo, $info['Keyspace'][$db]['keys']); + } + $dbinfo = str_replace('.', '  ', $dbinfo); // 2 spaces per character are needed to get the alignment right + + return $dbinfo; + } + } // if redis + // This is basically the same as the click code in index.js. // Just build the url for the frame based on our own url. if (count($_GET) == 0) { @@ -183,10 +204,11 @@ function print_namespace($item, $name, $fullkey, $islast) { $databases = $redis->config('GET', 'databases'); $databases = $databases['databases']; } +$info = $redis->info(); $len = strlen((string)($databases-1)); if ($databases > 1) { ?> From 65880d35bb745870f27a390e30ff98424cee16af Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Wed, 20 Nov 2019 16:20:57 -0500 Subject: [PATCH 045/107] fix reset stat code (#152) as mentioned earlier the method 'resetstat' does not exist and therefore the test will always be false. config resetstat is part of redis forever, so there's no reason for testing for this functionality. --- info.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/info.php b/info.php index 4d1f821..d657533 100644 --- a/info.php +++ b/info.php @@ -5,8 +5,8 @@ -if (isset($_GET['reset']) && method_exists($redis, 'resetStat')) { - $redis->resetStat(); +if (isset($_GET['reset'])) { + $redis->config('resetstat'); header('Location: info.php'); die; @@ -29,11 +29,9 @@ ?>

        Info

        -

        -Reset usage statistics +Reset usage statistics

        - From feed670bbdcb81b673de85f3327e0c232c915fd9 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Wed, 20 Nov 2019 16:22:52 -0500 Subject: [PATCH 046/107] fix switching server and database (#153) always show overview when switching - server, only keep var s (old database index might not exist on new server) - db, only keep vars s and d (whatever we are doing (show/edit key) won't be valid on new db) fixes #89, fixes #151 --- js/index.js | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/js/index.js b/js/index.js index de45790..3557014 100644 --- a/js/index.js +++ b/js/index.js @@ -12,7 +12,7 @@ $(function() { $(this).html('Select all'); } }) - + $('#sidebar').on('click', 'a', function(e) { if (e.currentTarget.className.indexOf('batch_del') !== -1){ e.preventDefault(); @@ -51,24 +51,24 @@ $(function() { 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({ @@ -90,24 +90,17 @@ $(function() { }); $('#server').change(function(e) { - if (location.href.indexOf('?') == -1) { - location.href = location.href+'?s='+e.target.value; - } else if (location.href.indexOf('&s=') == -1) { - location.href = location.href+'&s='+e.target.value; - } else { - location.href = location.href.replace(/s=[0-9]*/, 's='+e.target.value); - } + // always show overview when switching server, only keep var s (old database index might not exist on new server) + const base = location.href.split('?', 1)[0]; + location.href = base + '?overview&s=' + e.target.value; }); $('#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); - } + // always show overview when switching db, only keep vars s and d (whatever we are doing (show/edit key) won't be valid on new db) + const base = location.href.split('?', 1)[0]; + const s = location.href.match(/s=[0-9]*/); + location.href = base + '?overview&' + s + '&d=' + e.target.value; }); From c291de34a179faefa84ea53bee89176a5d380817 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Sun, 24 Nov 2019 16:43:06 +0000 Subject: [PATCH 047/107] Add showEmptyNamespaceAsKey and make grey --- css/index.css | 4 ++++ includes/config.sample.inc.php | 1 + index.php | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/css/index.css b/css/index.css index 80ceade..7b898e5 100644 --- a/css/index.css +++ b/css/index.css @@ -44,6 +44,10 @@ margin-top: .05em; cursor: pointer; } +#keys li.empty a { +color: #888; +} + #keys li.current a { background-color: #eee; } diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index e24aa52..10ed201 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -38,6 +38,7 @@ 'seperator' => ':', + 'showEmptyNamespaceAsKey' => false, // Hide empty databases in the database list (global, valid for all servers unless set at server level) 'hideEmptyDBs' => false, diff --git a/index.php b/index.php index fc271b6..fa0c51e 100644 --- a/index.php +++ b/index.php @@ -34,6 +34,10 @@ } $key = explode($server['seperator'], $key); + if ($key[count($key) - 1] == '' && $config['showEmptyNamespaceAsKey']) { + array_pop($key); + $key[count($key) - 1] .= ':'; + } // $d will be a reference to the current namespace. $d = &$namespaces; @@ -98,6 +102,7 @@ function print_namespace($item, $name, $fullkey, $islast) { if (empty($name) && $name != '0') { $name = ''; + $class[] = 'empty'; } ?> From 8c7bfcfe7a7bee5e2a0ede68eb95d29450682d93 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Mon, 25 Nov 2019 14:46:35 -0500 Subject: [PATCH 048/107] minor changes (#156) * change order of evaluation PHP evaluates conditions from left to right count needs more instructions thus should be on the right side (probably not necessary, but I'm a perf guy...) * set a default in case it is not set in confg (to avoid PHP warnings) --- includes/common.inc.php | 4 ++++ index.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/common.inc.php b/includes/common.inc.php index c50a2f3..ca63814 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -115,6 +115,10 @@ $config['hideEmptyDBs'] = false; } +if (!isset($config['showEmptyNamespaceAsKey'])) { + $config['showEmptyNamespaceAsKey'] = 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'])); diff --git a/index.php b/index.php index fa0c51e..5ea3b25 100644 --- a/index.php +++ b/index.php @@ -34,7 +34,7 @@ } $key = explode($server['seperator'], $key); - if ($key[count($key) - 1] == '' && $config['showEmptyNamespaceAsKey']) { + if ($config['showEmptyNamespaceAsKey'] && $key[count($key) - 1] == '') { array_pop($key); $key[count($key) - 1] .= ':'; } From 756c4016130bb63a88e2eed07740d98fa5538a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 10 Jan 2020 09:39:02 +0100 Subject: [PATCH 049/107] Remove usage of get_magic_quotes_gpc method (#158) --- includes/common.inc.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/includes/common.inc.php b/includes/common.inc.php index ca63814..85dfe76 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -3,26 +3,6 @@ define('PHPREDIS_ADMIN_PATH', dirname(__DIR__)); -// Undo magic quotes (both in keys and values) -if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { - $process = array(&$_GET, &$_POST); - - foreach ($process as $key => $val) { - foreach ($val as $k => $v) { - unset($process[$key][$k]); - - if (is_array($v)) { - $process[$key][stripslashes($k)] = $v; - $process[] = &$process[$key][stripslashes($k)]; - } else { - $process[$key][stripslashes($k)] = stripslashes($v); - } - } - } - - unset($process); -} - From 7e4bc6cfedc02e045ef43936d615e07444c0de07 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 10 Jan 2020 08:48:08 +0000 Subject: [PATCH 050/107] v1.12.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7d6cb26..7198e92 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.5", + "version": "1.12.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 5752c5087023464e8f41161e77a87c3a8263ac95 Mon Sep 17 00:00:00 2001 From: Alex Stansfield Date: Sat, 1 Feb 2020 04:19:00 +0700 Subject: [PATCH 051/107] Allow 'databases' server config option to be set by ENV (#159) This is quite specific to my needs, but possibly useful for others. My setup is PhpRedisAdmin running in Docker on ECS Fargate connnecting to Redis Elasticache. AWS Elasticache has a restricted CONFIG command so you can't get the databases. This change allows me to set the databases in the Task Definition in ECS. --- includes/config.environment.inc.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index 0522421..587899c 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -24,6 +24,7 @@ $server_host = getenv($prefix . 'HOST'); $server_port = getenv($prefix . 'PORT'); $server_auth = getenv($prefix . 'AUTH'); + $server_databases = getenv($prefix . 'DATABASES'); if (empty($server_host)) { break; @@ -51,6 +52,10 @@ if (!empty($server_auth)) { $config['servers'][$i-1]['auth'] = $server_auth; } + + if (!empty($server_databases)) { + $config['servers'][$i-1]['databases'] = $server_databases; + } $i++; } From 9eb60157dc13e660d6707af40835b8227b2ae3e9 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 31 Jan 2020 20:53:00 +0000 Subject: [PATCH 052/107] v1.13.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7198e92..0cfdc77 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.12.0", + "version": "1.13.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 4501c5d6500a926784fa32e7607065526f85e556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abra=C3=A3o=20Zaidan?= Date: Fri, 28 Feb 2020 10:24:17 -0300 Subject: [PATCH 053/107] Avoid unnecessary horizontal scrollbars (#160) * Avoid unnecessary horizontal scrollbars Fix long key values rendering with horizontal scrollbar; Fix keys folder with checkbox in one line and key name in another line. * Ellipsis replaced by horizontal scrollbar while keeping elements aligned https://github.com/erikdubbelboer/phpRedisAdmin/pull/160#issuecomment-589968360 * Fix missing padding on the right frame in Firefox for Mac https://github.com/erikdubbelboer/phpRedisAdmin/pull/160#issuecomment-590048242 --- css/common.css | 2 +- css/index.css | 15 ++++++++++++--- index.php | 5 +++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/css/common.css b/css/common.css index b2a8431..9dc6276 100644 --- a/css/common.css +++ b/css/common.css @@ -52,6 +52,6 @@ background: url(http://github.com/images/add.png) left center no-repeat; .data { -white-space: pre; +white-space: pre-wrap; } diff --git a/css/index.css b/css/index.css index 7b898e5..4a56aa9 100644 --- a/css/index.css +++ b/css/index.css @@ -3,10 +3,14 @@ position: absolute; top: 0; bottom: 0; left: 0; +display: flex; +flex-direction: column; width: 290px; height: 100%; +} + +#header { padding-left: 10px; -border-right: 1px solid #000; } #sidebar a, #sidebar a:visited { @@ -23,7 +27,9 @@ text-decoration: underline; #keys { +flex-grow: 1; width: 290px; +margin-top: 10px; padding-left: 10px; overflow: auto; } @@ -36,6 +42,7 @@ padding: 0; #keys li { font-weight: normal; +white-space: nowrap; } #keys li.folder { @@ -115,6 +122,7 @@ background-color: #aaa; cursor: col-resize; padding: 0; margin: 0; +border-left: 1px solid #000; } #resize-layover { @@ -133,11 +141,12 @@ top: 0; left: 305px; right: 0; bottom: 0; -padding-left: 2em; } #frame iframe { -width: 100%; +width: calc(100% - 3em); height: 100%; +margin-left: 1.5em; +margin-right: 1.5em; } diff --git a/index.php b/index.php index 5ea3b25..933796a 100644 --- a/index.php +++ b/index.php @@ -108,7 +108,7 @@ function print_namespace($item, $name, $fullkey, $islast) { ?> > - () + () - +
        Key
        Value
        Encoding:
        Size:
        Size:
        + +
        From 175faa7f8f39e189eaeccb9cd556d7d3397fe696 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 11 Apr 2022 16:22:58 +0000 Subject: [PATCH 074/107] v1.17.1 * 0866ff2 Update view.php (#180) (diplopito) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3cc3fdd..69cf7ab 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.17.0", + "version": "1.17.1", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 7be7f0a27c0c732d4c1dad5f194c07c7e09dda50 Mon Sep 17 00:00:00 2001 From: suyar <296399959@qq.com> Date: Mon, 4 Jul 2022 03:03:29 +0800 Subject: [PATCH 075/107] Bring in tzdata so users could set the timezones through the environment (#182) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 16f313d..6a82667 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM composer:2.2 ENV TINI_VERSION 0.19.0-r0 -RUN apk add --no-cache tini=$TINI_VERSION +RUN apk add --no-cache tini=$TINI_VERSION tzdata ADD . /src/app/ From d8b24525562d8f6f2392a212242e094cdd9d8697 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Sun, 3 Jul 2022 21:09:48 +0200 Subject: [PATCH 076/107] v1.17.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 69cf7ab..75b1587 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.17.1", + "version": "1.17.2", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From e1f15392891d3648fafb3d2ec074db041a164faf Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Thu, 25 Aug 2022 08:15:13 +0200 Subject: [PATCH 077/107] Add support for REDIS_N_AUTH_FILE --- README.markdown | 1 + includes/config.environment.inc.php | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 15de6f7..6c90f58 100644 --- a/README.markdown +++ b/README.markdown @@ -56,6 +56,7 @@ Environment variables summary * ``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 +* ``REDIS_1_AUTH_FILE`` - define file containing the password of the Redis server * ``REDIS_1_DATABASES`` - You can modify you config to prevent phpRedisAdmin from using CONFIG command * ``ADMIN_USER`` - define username for user-facing Basic Auth * ``ADMIN_PASS`` - define password for user-facing Basic Auth diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index 587899c..798281f 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -23,7 +23,11 @@ $server_name = getenv($prefix . 'NAME'); $server_host = getenv($prefix . 'HOST'); $server_port = getenv($prefix . 'PORT'); - $server_auth = getenv($prefix . 'AUTH'); + if (getenv($prefix . 'AUTH_FILE') !== false) { + $server_auth = file_get_contents(getenv($prefix . 'AUTH_FILE')); + } else { + $server_auth = getenv($prefix . 'AUTH'); + } $server_databases = getenv($prefix . 'DATABASES'); if (empty($server_host)) { From d6786dc91bf77bf66e4ac5a2c8bc968ee55a5468 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Thu, 25 Aug 2022 08:15:49 +0200 Subject: [PATCH 078/107] v1.17.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 75b1587..50c18ee 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.17.2", + "version": "1.17.3", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From bccabce045071fbc2962496ec4f02ec3b30b45a6 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Wed, 28 Sep 2022 14:17:11 +0200 Subject: [PATCH 079/107] Update readme --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 6c90f58..6b525a4 100644 --- a/README.markdown +++ b/README.markdown @@ -41,7 +41,7 @@ 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. +A public [phpRedisAdmin Docker image](https://hub.docker.com/r/erikdubbelboer/phpredisadmin/) is available on Docker Hub built from the latest tag. The file ```includes/config.environment.inc.php``` is used as the configuration file to allow environment variables to be used as configuration values. Example: ``` From e2348fdba7c124b5128684989ddb788ae388db52 Mon Sep 17 00:00:00 2001 From: Karel Wintersky Date: Sat, 29 Oct 2022 20:24:31 +0300 Subject: [PATCH 080/107] Fix #187 issue (comma in keys) (#188) * * [*] make all AJAX requrests recieve data as object * [*] JSON.Stringify() selected keys (fix issue #187) * * [*] add `ext-mbstring` and `ext-json` to composer.json * * [*] replaced `dirname(__FILE__)` to `__DIR__` (faster) * * [-] removed obsolete empty lines * [+] export `$redis, $config, $csrfToken, $server` to local env of any PHP file * [*] a little fixes --- composer.json | 2 ++ delete.php | 13 ++++++------- edit.php | 5 ++--- export.php | 1 + flush.php | 4 +--- import.php | 4 +--- includes/common.inc.php | 8 +------- includes/page.inc.php | 4 ---- index.php | 3 ++- info.php | 9 +-------- js/frame.js | 2 -- js/index.js | 26 ++++++++++++++++++-------- login.php | 1 + logout.php | 1 + overview.php | 6 ++---- rename.php | 4 +--- save.php | 4 +--- ttl.php | 7 +------ view.php | 10 +--------- 19 files changed, 43 insertions(+), 71 deletions(-) diff --git a/composer.json b/composer.json index 50c18ee..3136710 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,8 @@ } ], "require": { + "ext-mbstring": "*", + "ext-json": "*", "predis/predis": "v1.1.9", "paragonie/random_compat": ">=2" }, diff --git a/delete.php b/delete.php index cde8539..c329919 100644 --- a/delete.php +++ b/delete.php @@ -1,13 +1,13 @@ del($key); } @@ -73,4 +73,3 @@ die('?view&s=' . $server['id'] . '&d=' . $server['db'] . '&key=' . urlencode($keys[0])); } -?> diff --git a/edit.php b/edit.php index 0e0b360..6f3fd20 100644 --- a/edit.php +++ b/edit.php @@ -2,8 +2,7 @@ require_once 'includes/common.inc.php'; - - +global $redis, $config, $csrfToken, $server; // Are we editing or creating a new key? $edit = false; @@ -192,4 +191,4 @@ require 'includes/footer.inc.php'; -?> +?> \ No newline at end of file diff --git a/export.php b/export.php index 2812705..d17839e 100644 --- a/export.php +++ b/export.php @@ -2,6 +2,7 @@ require_once 'includes/common.inc.php'; +global $redis, $config, $csrfToken, $server; // Export to redis-cli commands function export_redis($key, $filter = false, $transform = false) { diff --git a/flush.php b/flush.php index 4e74489..c8fc1f5 100644 --- a/flush.php +++ b/flush.php @@ -1,13 +1,11 @@ flushdb(); diff --git a/import.php b/import.php index e9176dc..5e5a89e 100644 --- a/import.php +++ b/import.php @@ -1,9 +1,7 @@ diff --git a/includes/page.inc.php b/includes/page.inc.php index 2f1a0e9..2941e68 100644 --- a/includes/page.inc.php +++ b/includes/page.inc.php @@ -1,6 +1,5 @@ array('common'), 'js' => array('jquery') diff --git a/index.php b/index.php index be7c9d8..94dd90a 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,7 @@ config('resetstat'); @@ -12,15 +10,10 @@ die; } - - // Fetch the info $info = $redis->info(); $alt = false; - - - $page['css'][] = 'frame'; $page['js'][] = 'frame'; diff --git a/js/frame.js b/js/frame.js index 1a77e34..0196452 100644 --- a/js/frame.js +++ b/js/frame.js @@ -3,14 +3,12 @@ $(function() { window.parent.history.replaceState({}, '', document.location.href.replace('?', '&').replace(/\/([a-z]*)\.php/, '/?$1')); } - $('#type').change(function(e) { $('#hkeyp' ).css('display', e.target.value == 'hash' ? 'block' : 'none'); $('#indexp').css('display', e.target.value == 'list' ? 'block' : 'none'); $('#scorep').css('display', e.target.value == 'zset' ? 'block' : 'none'); }).change(); - $('.delkey, .delval').click(function(e) { e.preventDefault(); diff --git a/js/index.js b/js/index.js index a3ba627..a3f3414 100644 --- a/js/index.js +++ b/js/index.js @@ -14,13 +14,13 @@ $(function() { }) $('#sidebar').on('click', 'a', function(e) { - if (e.currentTarget.className.indexOf('batch_del') !== -1){ + if (e.currentTarget.className.indexOf('batch_del') !== -1) { e.preventDefault(); - var selected_keys = ''; + var selected_keys = []; $('input[name=checked_keys]:checked').each(function () { - selected_keys += $(this).val() + ','; + selected_keys.push($(this).val()); }); - if (!selected_keys) { + if (selected_keys.length == 0) { alert('Please select the keys you want to delete.'); return; } @@ -28,20 +28,27 @@ $(function() { $.ajax({ type: "POST", url: this.href, - data: 'post=1&selected_keys=' + selected_keys + '&csrf=' + phpRedisAdmin_csrfToken, + data: { + post: 1, + selected_keys: JSON.stringify(selected_keys), + csrf: phpRedisAdmin_csrfToken + }, success: function(url) { top.location.href = top.location.pathname+url; } }); } - }else if (e.currentTarget.className.indexOf('deltree') !== -1) { + } 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?')) { $.ajax({ type: "POST", url: this.href, - data: 'post=1&csrf=' + phpRedisAdmin_csrfToken, + data: { + post: 1, + csrf: phpRedisAdmin_csrfToken + }, success: function(url) { top.location.href = top.location.pathname+url; } @@ -74,7 +81,10 @@ $(function() { $.ajax({ type: "POST", url: href, - data: 'post=1&csrf=' + phpRedisAdmin_csrfToken, + data: { + post: 1, + csrf: phpRedisAdmin_csrfToken + }, success: function() { window.location.reload(); } diff --git a/login.php b/login.php index 298b32f..a80a24c 100644 --- a/login.php +++ b/login.php @@ -2,6 +2,7 @@ define('LOGIN_PAGE', true); require_once 'includes/common.inc.php'; +global $redis, $config, $csrfToken, $server; $page['css'][] = 'login'; diff --git a/logout.php b/logout.php index 44b1785..12cc80b 100644 --- a/logout.php +++ b/logout.php @@ -1,6 +1,7 @@

        -Redis Documentation +Redis Documentation

        $config['maxkeylen']) { diff --git a/save.php b/save.php index 3154e8c..ef8b1d8 100644 --- a/save.php +++ b/save.php @@ -1,9 +1,7 @@ Invalid key @@ -18,8 +17,6 @@ die; } - - $type = $redis->type($_GET['key']); $exists = $redis->exists($_GET['key']); @@ -27,8 +24,6 @@ $page_num_request = isset($_GET['page']) ? (int)$_GET['page'] : 1; $page_num_request = $page_num_request === 0 ? 1 : $page_num_request; - - ?>

        @@ -48,8 +43,6 @@ die; } - - $alt = false; $ttl = $redis->ttl($_GET['key']); @@ -59,7 +52,6 @@ $encoding = null; } - switch ($type) { case 'string': $value = $redis->get($_GET['key']); From 88b5d92c3d015d58be3aa346a23bbb457de6e64b Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Sun, 30 Oct 2022 09:55:07 +0100 Subject: [PATCH 081/107] v1.18.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3136710..e0251f6 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.17.3", + "version": "1.18.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 46be650827d65b51fc117b559dea6e059aa41547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=9B=E5=85=B5?= Date: Mon, 9 Jan 2023 11:49:47 +0800 Subject: [PATCH 082/107] Update Dockerfile to enable change listen port (#191) Docker can not change the exported port when in host mode, and port 80 open used by http server. So i made this to enable change the listening port by environment variables. --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6a82667..73ea46e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,5 +12,6 @@ RUN composer install RUN cp includes/config.environment.inc.php includes/config.inc.php +ENV PORT 80 EXPOSE 80 -ENTRYPOINT [ "tini", "--", "php", "-S", "0.0.0.0:80" ] +ENTRYPOINT [ "sh", "-c", "tini -- php -S 0.0.0.0:$PORT" ] From aeab4b0322eda72965ddbbc606fffef1163f89f0 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 9 Jan 2023 04:50:32 +0100 Subject: [PATCH 083/107] v1.19.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e0251f6..16a914d 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.18.0", + "version": "1.19.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From bdc2e88160928fbd2e5fe49ddb6cf90cbd44be6e Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 9 Jan 2023 10:24:58 +0100 Subject: [PATCH 084/107] Use the latest version of tini --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 73ea46e..c9ff06c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,6 @@ FROM composer:2.2 -ENV TINI_VERSION 0.19.0-r0 - -RUN apk add --no-cache tini=$TINI_VERSION tzdata +RUN apk add --no-cache tini tzdata ADD . /src/app/ From 9221bfeb1cd01b7710ae84effc23194b382d85ff Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 9 Jan 2023 10:25:43 +0100 Subject: [PATCH 085/107] v1.19.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 16a914d..a7b3881 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.19.0", + "version": "1.19.1", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From bf71b74103b4aa506606f63344835f13ac42294d Mon Sep 17 00:00:00 2001 From: Sam Benskin <1180089+sambenskin@users.noreply.github.com> Date: Fri, 27 Jan 2023 05:36:20 +0000 Subject: [PATCH 086/107] Fix #194 Changed variable to {$var} syntax (#195) --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index 94dd90a..44f7c85 100644 --- a/index.php +++ b/index.php @@ -154,7 +154,7 @@ function getDbInfo($d, $info, $padding = '') { return false; // we don't show empty dbs, so return false to tell the caller to continue the loop } - $dbinfo = sprintf("$prefix%'.-${padding}d", $d); + $dbinfo = sprintf("$prefix%'.-{$padding}d", $d); if ($dbHasData) { $dbinfo = sprintf("%s (%d)", $dbinfo, $info['Keyspace'][$db]['keys']); } From cb2d6a3e772948e6fec148a2ed0c76c8568ee386 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 3 Mar 2023 21:39:48 +0100 Subject: [PATCH 087/107] v1.19.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a7b3881..e1043de 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.19.1", + "version": "1.19.2", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From c7229f0ec3825b726f8074a3fbc4b2ea10301722 Mon Sep 17 00:00:00 2001 From: xiagw Date: Mon, 7 Aug 2023 23:44:14 +0800 Subject: [PATCH 088/107] fix Dockerfile (#201) --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index c9ff06c..610dbda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,13 @@ FROM composer:2.2 RUN apk add --no-cache tini tzdata -ADD . /src/app/ - WORKDIR /src/app -RUN composer install +COPY . . -RUN cp includes/config.environment.inc.php includes/config.inc.php +RUN set -xe; \ + composer install; \ + cp includes/config.environment.inc.php includes/config.inc.php ENV PORT 80 EXPOSE 80 From 0303c81abd6a73a37399229bbb6a9eb7b9dfbe10 Mon Sep 17 00:00:00 2001 From: Sachin Bahukhandi Date: Thu, 11 Apr 2024 00:09:16 +0530 Subject: [PATCH 089/107] Added a check for ZSET values (#204) --- edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edit.php b/edit.php index 6f3fd20..4424d24 100644 --- a/edit.php +++ b/edit.php @@ -82,7 +82,7 @@ } // ZSet - else if (($_POST['type'] == 'zset') && isset($_POST['score'])) { + 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); From acc524865bb8e3c98bef2b0dec451f4c25712008 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Wed, 10 Apr 2024 20:40:01 +0200 Subject: [PATCH 090/107] 1.19.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e1043de..acb2515 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.19.2", + "version": "1.19.3", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 7bf33653b74e5419e9acef00b63c9c54e304765a Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Sun, 23 Jun 2024 21:24:14 +0800 Subject: [PATCH 091/107] Get more configs params from environment variables (#207) --- includes/config.environment.inc.php | 33 ++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index 798281f..a35bf07 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -2,6 +2,18 @@ include 'config.sample.inc.php'; +// get configs from environment variables +$config['cookie_auth'] = getenv('COOKIE_AUTH') ?: false; +$config['count_elements_page'] = getenv('COUNT_ELEMENTS_PAGE') ?: 100; +$config['faster'] = getenv('FASTER') ?: true; +$config['filter'] = getenv('FILTER') ?: '*'; +$config['hideEmptyDBs'] = getenv('HIDE_EMPTY_DBS') ?: false; +$config['keys'] = getenv('KEYS') ?: false; +$config['maxkeylen'] = getenv('MAX_KEY_LEN') ?: 100; +$config['scansize'] = getenv('SCAN_SIZE') ?: 1000; +$config['seperator'] = getenv('SEPERATOR') ?: ':'; +$config['showEmptyNamespaceAsKey'] = getenv('SHOW_EMPTY_NAMESPACE_AS_KEY') ?: false; + $admin_user = getenv('ADMIN_USER'); $admin_pass = getenv('ADMIN_PASS'); @@ -37,29 +49,30 @@ if (empty($server_name)) { $server_name = $server_host; } - + if (empty($server_auth)) { $server_auth = ""; - } + } if (empty($server_port)) { $server_port = 6379; } $config['servers'][] = array( - 'name' => $server_name, - 'host' => $server_host, - 'port' => $server_port, - 'filter' => '*', + 'name' => $server_name, + 'host' => $server_host, + 'port' => $server_port, + 'filter' => $config['filter'], + 'scansize' => $config['scansize'], ); - + if (!empty($server_auth)) { $config['servers'][$i-1]['auth'] = $server_auth; - } - + } + if (!empty($server_databases)) { $config['servers'][$i-1]['databases'] = $server_databases; - } + } $i++; } From 092f83ff156b8f6b9355ca3ce5733172e7127297 Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Tue, 25 Jun 2024 01:14:38 +0800 Subject: [PATCH 092/107] Limit the max number of keys when scanning (#206) * Add parameter scan_max * Limit the max number of keys when scanning * Rename parameter scan_max to scanmax --- includes/config.environment.inc.php | 2 ++ includes/config.sample.inc.php | 3 ++- index.php | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index a35bf07..b987194 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -11,6 +11,7 @@ $config['keys'] = getenv('KEYS') ?: false; $config['maxkeylen'] = getenv('MAX_KEY_LEN') ?: 100; $config['scansize'] = getenv('SCAN_SIZE') ?: 1000; +$config['scanmax'] = getenv('SCAN_MAX') ?: 1000; $config['seperator'] = getenv('SEPERATOR') ?: ':'; $config['showEmptyNamespaceAsKey'] = getenv('SHOW_EMPTY_NAMESPACE_AS_KEY') ?: false; @@ -64,6 +65,7 @@ 'port' => $server_port, 'filter' => $config['filter'], 'scansize' => $config['scansize'], + 'scanmax' => $config['scanmax'], ); if (!empty($server_auth)) { diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 10ed201..13f4a2c 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -32,7 +32,8 @@ '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). + '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. ),*/ ), diff --git a/index.php b/index.php index 44f7c85..8f99dd8 100644 --- a/index.php +++ b/index.php @@ -17,6 +17,10 @@ $next = $r[0]; $keys = array_merge($keys, $r[1]); + if (count($keys) >= $server['scanmax']) { + break; + } + if ($next == 0) { break; } From 3dcd016ae259dbe0836a04d7907905cb078640db Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 24 Jun 2024 19:16:11 +0200 Subject: [PATCH 093/107] 1.20.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index acb2515..5c707cf 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.19.3", + "version": "1.20.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 4f1544459395892741ebcabec498680e544742f2 Mon Sep 17 00:00:00 2001 From: arielectron Date: Sun, 18 Aug 2024 14:28:06 -0300 Subject: [PATCH 094/107] Allow scheme config from env vars (#209) * Allow scheme config from env vars * Fix condition * Add new config to readme file * Update includes/common.inc.php --------- Co-authored-by: Erik Dubbelboer --- README.markdown | 1 + includes/common.inc.php | 8 ++++++-- includes/config.environment.inc.php | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 6b525a4..0938c08 100644 --- a/README.markdown +++ b/README.markdown @@ -55,6 +55,7 @@ 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_SCHEME`` - define scheme of the Redis server (tcp or tls) * ``REDIS_1_AUTH`` - define password of the Redis server * ``REDIS_1_AUTH_FILE`` - define file containing the password of the Redis server * ``REDIS_1_DATABASES`` - You can modify you config to prevent phpRedisAdmin from using CONFIG command diff --git a/includes/common.inc.php b/includes/common.inc.php index ae0bd52..075ca16 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -113,11 +113,15 @@ $config['showEmptyNamespaceAsKey'] = false; } +if (!isset($config['scheme']) || empty($config['scheme'])) { + $config['scheme'] = 'tcp'; +} + // Setup a connection to Redis. -if(isset($server['scheme']) && $server['scheme'] === 'unix' && $server['path']) { +if ($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']); + $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client($server['scheme'].'://'.$server['host'].':'.$server['port']); } try { diff --git a/includes/config.environment.inc.php b/includes/config.environment.inc.php index b987194..06a06fe 100644 --- a/includes/config.environment.inc.php +++ b/includes/config.environment.inc.php @@ -36,6 +36,7 @@ $server_name = getenv($prefix . 'NAME'); $server_host = getenv($prefix . 'HOST'); $server_port = getenv($prefix . 'PORT'); + $server_scheme = getenv($prefix . 'SCHEME'); if (getenv($prefix . 'AUTH_FILE') !== false) { $server_auth = file_get_contents(getenv($prefix . 'AUTH_FILE')); } else { @@ -55,10 +56,14 @@ $server_auth = ""; } - if (empty($server_port)) { + if (empty($server_port) && strpos($server_host, ':') === false) { $server_port = 6379; } + if (empty($server_scheme)) { + $server_scheme = 'tcp'; + } + $config['servers'][] = array( 'name' => $server_name, 'host' => $server_host, @@ -66,6 +71,7 @@ 'filter' => $config['filter'], 'scansize' => $config['scansize'], 'scanmax' => $config['scanmax'], + 'scheme' => $server_scheme, ); if (!empty($server_auth)) { From 5d8756c0863cfbf7f95206520be6d101f4f67079 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Sun, 18 Aug 2024 19:29:01 +0200 Subject: [PATCH 095/107] 1.21.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5c707cf..1052799 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.20.0", + "version": "1.21.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From fed29bf9dac74ce0eb37a89ebeae014c290bd3de Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Sat, 21 Sep 2024 22:09:23 +0800 Subject: [PATCH 096/107] Display the number of keys scanned (#210) * Display the number of keys scanned and the limit * Reduce scansize according to scanmax * Simplify info about scanmax --- index.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index 8f99dd8..056abeb 100644 --- a/index.php +++ b/index.php @@ -10,20 +10,18 @@ } else { $next = 0; $keys = array(); - + $scansize = $server['scansize']; while (true) { - $r = $redis->scan($next, 'MATCH', $server['filter'], 'COUNT', $server['scansize']); - + $r = $redis->scan($next, 'MATCH', $server['filter'], 'COUNT', $scansize); $next = $r[0]; $keys = array_merge($keys, $r[1]); - - if (count($keys) >= $server['scanmax']) { + if ($next == 0) { break; } - - if ($next == 0) { + if (count($keys) >= $server['scanmax']) { break; } + $scansize = min($server['scanmax'] - count($keys), $server['scansize']); } } @@ -256,6 +254,9 @@ function getDbInfo($d, $info, $padding = '') {

      +
      + scaned keys= $server['scanmax']) ? ', reached scanmax' : '' ?> +
      From 47f4c678f0cca20709a2587c2704c0ec612de189 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Sat, 21 Sep 2024 16:10:00 +0200 Subject: [PATCH 097/107] v1.21.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1052799..29d6261 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.21.0", + "version": "1.21.1", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From c8fc6a08e4f05c710daa9c8a695f54b7aba498f2 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Sun, 8 Dec 2024 10:35:59 +0100 Subject: [PATCH 098/107] fix: scanmax behavior (#212) * fix: typo * fix: scanmax behavior --- includes/common.inc.php | 12 ++++++++++++ includes/config.sample.inc.php | 5 ++++- index.php | 8 +++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/includes/common.inc.php b/includes/common.inc.php index 075ca16..c13424b 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -95,10 +95,22 @@ $server['keys'] = $config['keys']; } +if (!isset($config['scansize'])) { + $config['scansize'] = 1000; +} + +if (!isset($config['scanmax'])) { + $config['scanmax'] = 0; +} + if (!isset($server['scansize'])) { $server['scansize'] = $config['scansize']; } +if (!isset($server['scanmax'])) { + $server['scanmax'] = $config['scanmax']; +} + if (!isset($server['serialization'])) { if (isset($config['serialization'])) { $server['serialization'] = $config['serialization']; diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 13f4a2c..2732d97 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -33,7 +33,7 @@ 'charset' => 'cp1251', // Keys and values are stored in redis using this encoding (default utf-8). 'keys' => false, // Use the old KEYS command instead of SCAN to fetch all keys for this server (default uses config default). 'scansize' => 1000, // How many entries to fetch using each SCAN command for this server (default uses config default). - 'scanmax' => 1000, // In each query, SCAN command may be executed several times. To shorten the duration, it is recommended to limit the total number of entries to fetch. + 'scanmax' => 1000, // In each query, SCAN command may be executed several times. To shorten the duration, it is recommended to limit the total number of entries to fetch (default uses config default). ),*/ ), @@ -85,4 +85,7 @@ // How many entries to fetch using each SCAN command. 'scansize' => 1000 + + // The total number of entries to fetch. Set to 0 or -1 for no limit. + 'scanmax' => 0 ); diff --git a/index.php b/index.php index 056abeb..b513947 100644 --- a/index.php +++ b/index.php @@ -10,18 +10,16 @@ } else { $next = 0; $keys = array(); - $scansize = $server['scansize']; while (true) { - $r = $redis->scan($next, 'MATCH', $server['filter'], 'COUNT', $scansize); + $r = $redis->scan($next, 'MATCH', $server['filter'], 'COUNT', $server['scansize']); $next = $r[0]; $keys = array_merge($keys, $r[1]); if ($next == 0) { break; } - if (count($keys) >= $server['scanmax']) { + if ($server['scanmax'] > 0 && count($keys) >= $server['scanmax']) { break; } - $scansize = min($server['scanmax'] - count($keys), $server['scansize']); } } @@ -255,7 +253,7 @@ function getDbInfo($d, $info, $padding = '') {
      - scaned keys= $server['scanmax']) ? ', reached scanmax' : '' ?> + scanned keys 0 && count($keys) >= $server['scanmax']) ? ', reached scanmax' : '' ?>
        From 644162e932230d8eef642ebce327260a4dd54b0a Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Sun, 8 Dec 2024 10:41:43 +0100 Subject: [PATCH 099/107] v1.22.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 29d6261..475fd18 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.21.1", + "version": "1.22.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 5e8c6ecb19e68988994ac20a1dff30b3fa65cf3e Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 9 Dec 2024 13:04:25 +0100 Subject: [PATCH 100/107] Add missing , Fixes: https://github.com/erikdubbelboer/phpRedisAdmin/issues/202 --- includes/config.sample.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index 2732d97..cca5b81 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -84,7 +84,7 @@ 'keys' => false, // How many entries to fetch using each SCAN command. - 'scansize' => 1000 + 'scansize' => 1000, // The total number of entries to fetch. Set to 0 or -1 for no limit. 'scanmax' => 0 From 3e60b217dae70e0be700202c2fb3d4cf46ac02fe Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Mon, 9 Dec 2024 13:05:05 +0100 Subject: [PATCH 101/107] v1.22.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 475fd18..a851fe6 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.22.0", + "version": "1.22.1", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 543cbc7997874fae7967aaaa85bf190a6b24d0b4 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 20 Dec 2024 07:28:42 +0000 Subject: [PATCH 102/107] Upgrade predis to v2.3.0 Fixes a bug with $server['scheme'] and simplifies some of the config code. Fixes https://github.com/erikdubbelboer/phpRedisAdmin/issues/214 --- composer.json | 2 +- composer.lock | 42 ++++++++++++++++++++--------------------- includes/common.inc.php | 24 +++++++++++------------ 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index a851fe6..5c6d433 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "require": { "ext-mbstring": "*", "ext-json": "*", - "predis/predis": "v1.1.9", + "predis/predis": "v2.3.0", "paragonie/random_compat": ">=2" }, "minimum-stability": "stable", diff --git a/composer.lock b/composer.lock index 41f9438..f724f31 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ad3fb9bfb043b086870b317dc9eff9b7", + "content-hash": "401ff61cebe5223d003a47192d7c3d6a", "packages": [ { "name": "paragonie/random_compat", @@ -58,27 +58,28 @@ }, { "name": "predis/predis", - "version": "v1.1.9", + "version": "v2.3.0", "source": { "type": "git", "url": "https://github.com/predis/predis.git", - "reference": "c50c3393bb9f47fa012d0cdfb727a266b0818259" + "reference": "bac46bfdb78cd6e9c7926c697012aae740cb9ec9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/predis/predis/zipball/c50c3393bb9f47fa012d0cdfb727a266b0818259", - "reference": "c50c3393bb9f47fa012d0cdfb727a266b0818259", + "url": "https://api.github.com/repos/predis/predis/zipball/bac46bfdb78cd6e9c7926c697012aae740cb9ec9", + "reference": "bac46bfdb78cd6e9c7926c697012aae740cb9ec9", "shasum": "" }, "require": { - "php": ">=5.3.9" + "php": "^7.2 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "~4.8" + "friendsofphp/php-cs-fixer": "^3.3", + "phpstan/phpstan": "^1.9", + "phpunit/phpunit": "^8.0 || ^9.4" }, "suggest": { - "ext-curl": "Allows access to Webdis when paired with phpiredis", - "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" + "ext-relay": "Faster connection with in-memory caching (>=0.6.2)" }, "type": "library", "autoload": { @@ -91,19 +92,13 @@ "MIT" ], "authors": [ - { - "name": "Daniele Alessandri", - "email": "suppakilla@gmail.com", - "homepage": "http://clorophilla.net/", - "role": "Creator & Maintainer" - }, { "name": "Till Krüss", "homepage": "https://till.im/", "role": "Maintainer" } ], - "description": "Flexible and feature-complete Redis client for PHP and HHVM", + "description": "A flexible and feature-complete Redis client for PHP.", "homepage": "http://github.com/predis/predis", "keywords": [ "nosql", @@ -112,7 +107,7 @@ ], "support": { "issues": "https://github.com/predis/predis/issues", - "source": "https://github.com/predis/predis/tree/v1.1.9" + "source": "https://github.com/predis/predis/tree/v2.3.0" }, "funding": [ { @@ -120,16 +115,19 @@ "type": "github" } ], - "time": "2021-10-05T19:02:38+00:00" + "time": "2024-11-21T20:00:02+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.1.0" + "platform": { + "ext-mbstring": "*", + "ext-json": "*" + }, + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/includes/common.inc.php b/includes/common.inc.php index c13424b..a92a3ed 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -95,20 +95,20 @@ $server['keys'] = $config['keys']; } -if (!isset($config['scansize'])) { - $config['scansize'] = 1000; -} - -if (!isset($config['scanmax'])) { - $config['scanmax'] = 0; -} - if (!isset($server['scansize'])) { - $server['scansize'] = $config['scansize']; + if (isset($config['scansize'])) { + $server['scansize'] = $config['scansize']; + } else { + $server['scansize'] = 1000; + } } if (!isset($server['scanmax'])) { - $server['scanmax'] = $config['scanmax']; + if (isset($config['scanmax'])) { + $server['scanmax'] = $config['scanmax']; + } else { + $server['scanmax'] = 0; + } } if (!isset($server['serialization'])) { @@ -125,8 +125,8 @@ $config['showEmptyNamespaceAsKey'] = false; } -if (!isset($config['scheme']) || empty($config['scheme'])) { - $config['scheme'] = 'tcp'; +if (!isset($server['scheme']) || empty($server['scheme'])) { + $server['scheme'] = 'tcp'; } // Setup a connection to Redis. From 6f9fae06b4edeaa758113407d90b4a3d2915ad76 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Fri, 20 Dec 2024 08:31:12 +0100 Subject: [PATCH 103/107] v1.23.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5c6d433..fb69cc8 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.22.1", + "version": "1.23.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From dc8fce6df5385c7e3c12e8f10ed40a6d9bd5fb01 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Wed, 26 Mar 2025 11:03:53 +0700 Subject: [PATCH 104/107] Handle permission access errors (#216) --- css/frame.css | 10 +++++ edit.php | 115 +++++++++++++++++++++++++++----------------------- index.php | 8 +++- view.php | 14 +++++- 4 files changed, 92 insertions(+), 55 deletions(-) diff --git a/css/frame.css b/css/frame.css index 8969e10..7cf935d 100644 --- a/css/frame.css +++ b/css/frame.css @@ -52,3 +52,13 @@ float: left; margin: 1em; } + +.exception { +border: 1px solid #ff0000; +background-color: rgba(255, 0, 0, 0.2); +color: #880000; +padding: 10px; +border-radius: 5px; +margin: 20px; +} + diff --git a/edit.php b/edit.php index 4424d24..998012c 100644 --- a/edit.php +++ b/edit.php @@ -34,72 +34,83 @@ die('ERROR: could not encode value'); } - // String - if ($_POST['type'] == 'string') { - $redis->set($key, $value); - } - - // Hash - else if (($_POST['type'] == 'hash') && isset($_POST['hkey'])) { - if (strlen($_POST['hkey']) > $config['maxkeylen']) { - die('ERROR: Your hash key is to long (max length is '.$config['maxkeylen'].')'); + try { + // String + if ($_POST['type'] == 'string') { + $redis->set($key, $value); } - if ($edit && !$redis->hExists($key, input_convert($_POST['hkey']))) { - $redis->hDel($key, input_convert($_GET['hkey'])); + // Hash + else if (($_POST['type'] == 'hash') && isset($_POST['hkey'])) { + if (strlen($_POST['hkey']) > $config['maxkeylen']) { + die('ERROR: Your hash key is to long (max length is '.$config['maxkeylen'].')'); + } + + if ($edit && !$redis->hExists($key, input_convert($_POST['hkey']))) { + $redis->hDel($key, input_convert($_GET['hkey'])); + } + + $redis->hSet($key, input_convert($_POST['hkey']), $value); } - $redis->hSet($key, input_convert($_POST['hkey']), $value); - } + // List + else if (($_POST['type'] == 'list') && isset($_POST['index'])) { + $size = $redis->lLen($key); + + if (($_POST['index'] == '') || + ($_POST['index'] == $size)) { + // Push it at the end + $redis->rPush($key, $value); + } else if ($_POST['index'] == -1) { + // Push it at the start + $redis->lPush($key, $value); + } else if (($_POST['index'] >= 0) && + ($_POST['index'] < $size)) { + // Overwrite an index + $redis->lSet($key, input_convert($_POST['index']), $value); + } else { + die('ERROR: Out of bounds index'); + } + } - // List - else if (($_POST['type'] == 'list') && isset($_POST['index'])) { - $size = $redis->lLen($key); - - if (($_POST['index'] == '') || - ($_POST['index'] == $size)) { - // Push it at the end - $redis->rPush($key, $value); - } else if ($_POST['index'] == -1) { - // Push it at the start - $redis->lPush($key, $value); - } else if (($_POST['index'] >= 0) && - ($_POST['index'] < $size)) { - // Overwrite an index - $redis->lSet($key, input_convert($_POST['index']), $value); - } else { - die('ERROR: Out of bounds index'); + // Set + else if ($_POST['type'] == 'set') { + if ($_POST['value'] != $_POST['oldvalue']) { + // The only way to edit a Set value is to add it and remove the old value. + $redis->sRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue']))); + $redis->sAdd($key, $value); + } } - } - // Set - else if ($_POST['type'] == 'set') { - if ($_POST['value'] != $_POST['oldvalue']) { - // The only way to edit a Set value is to add it and remove the old value. - $redis->sRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue']))); - $redis->sAdd($key, $value); + // ZSet + else if (($_POST['type'] == 'zset') && isset($_POST['score']) && is_numeric($_POST['score'])) { + // The only way to edit a ZSet value is to add it and remove the old value. + $redis->zRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue']))); + $redis->zAdd($key, input_convert($_POST['score']), $value); } - } - // ZSet - else if (($_POST['type'] == 'zset') && isset($_POST['score']) && is_numeric($_POST['score'])) { - // The only way to edit a ZSet value is to add it and remove the old value. - $redis->zRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue']))); - $redis->zAdd($key, input_convert($_POST['score']), $value); - } + // Refresh the top so the key tree is updated. + require 'includes/header.inc.php'; - // Refresh the top so the key tree is updated. - require 'includes/header.inc.php'; + ?> + + - - +
        +

        getMessage() ?>

        +
        + type($fullkey)) { + $type = ''; + try { + $type = $redis->type($fullkey); + } catch (\Predis\Response\ServerException $th) { + $class[] = 'empty'; + } + switch ($type) { case 'hash': $len = $redis->hLen($fullkey); break; diff --git a/view.php b/view.php index 1836979..0fdb1b5 100644 --- a/view.php +++ b/view.php @@ -17,8 +17,18 @@ die; } -$type = $redis->type($_GET['key']); -$exists = $redis->exists($_GET['key']); +$type = ''; +$exists = false; +try { + $type = $redis->type($_GET['key']); + $exists = $redis->exists($_GET['key']); +} catch (\Predis\Response\ServerException $th) { + ?> +
        +

        getMessage() ?>

        +
        + Date: Sat, 29 Mar 2025 12:04:03 +0700 Subject: [PATCH 105/107] Change TTL input type (#217) --- ttl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ttl.php b/ttl.php index 92e6cca..c5d7a88 100644 --- a/ttl.php +++ b/ttl.php @@ -31,7 +31,7 @@

        -> (-1 to remove the TTL) +> (-1 to remove the TTL)

        From 2d977bce2a3225bacf9ab04ba0ca27c5d58324ab Mon Sep 17 00:00:00 2001 From: Wildan M Date: Mon, 31 Mar 2025 11:33:09 +0700 Subject: [PATCH 106/107] Implement ACL login (#218) * Implement ACL login * Make password form optional --- includes/common.inc.php | 3 + includes/config.sample.inc.php | 6 ++ includes/login_acl.inc.php | 100 +++++++++++++++++++++++++++++++++ login.php | 2 +- logout.php | 4 ++ overview.php | 33 ++++++++--- 6 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 includes/login_acl.inc.php diff --git a/includes/common.inc.php b/includes/common.inc.php index a92a3ed..78e791f 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -148,6 +148,9 @@ } } +if (!isset($config['login']) && !empty($config['login_as_acl_auth'])) { + require_once PHPREDIS_ADMIN_PATH . '/includes/login_acl.inc.php'; +} if ($server['db'] != 0) { if (!$redis->select($server['db'])) { diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php index cca5b81..923a60c 100644 --- a/includes/config.sample.inc.php +++ b/includes/config.sample.inc.php @@ -61,6 +61,12 @@ ) ),*/ + // Uncomment to enable login as ACL authentication (won't work if 'login' or 'auth' is also used) + // Only support using one server at this moment. + // If you set the default user off, browsers will be redirected to login page. + // The user and password will be stored in browser as plaintext so using HTTPS is strongly recommended. + // 'login_as_acl_auth' => true, + // Use HTML form/cookie-based auth instead of HTTP Basic/Digest auth 'cookie_auth' => false, diff --git a/includes/login_acl.inc.php b/includes/login_acl.inc.php new file mode 100644 index 0000000..e8b7d72 --- /dev/null +++ b/includes/login_acl.inc.php @@ -0,0 +1,100 @@ +auth($login['username'], $login['password']); + } catch (Predis\Response\ServerException $exception) { + return false; + } + return true; +} + +// This fill will perform HTTP basic authentication. The authentication data will be sent and stored as plaintext +// Please make sure to use HTTPS proxy such as Apache or Nginx to prevent traffic eavesdropping. +function authHttpBasic() +{ + $realm = 'phpRedisAdmin'; + + if (!isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) { + try { + global $redis; + $redis->ping(); + } catch (Predis\Response\ServerException $exception) { + header('HTTP/1.1 401 Unauthorized'); + header('WWW-Authenticate: Basic realm="' . $realm . '"'); + die('NOAUTH -- Authentication required'); + } + } + + $login = [ + 'username' => $_SERVER['PHP_AUTH_USER'], + 'password' => $_SERVER['PHP_AUTH_PW'], + ]; + + if (!authCheck($login)) { + header('HTTP/1.1 401 Unauthorized'); + header('WWW-Authenticate: Basic realm="' . $realm . '"'); + die('NOAUTH -- Authentication required'); + } + + return $login; +} + +// Perform auth using a standard HTML
        submission and cookies to save login state +function authCookie() +{ + if (!empty($_COOKIE['phpRedisAdminLogin'])) { + // We have a cookie; is it correct? + // Cookie value looks like "username:password-hash" + $login = explode(':', $_COOKIE['phpRedisAdminLogin'], 2); + if (count($login) === 2) { + $login = [ + 'username' => $login[0], + 'password' => $login[1], + ]; + if (authCheck($login)) { + return $login; + } + } + } + + if (isset($_POST['username'], $_POST['password'])) { + // Login form submitted; correctly? + $login = [ + 'username' => $_POST['username'], + 'password' => $_POST['password'], + ]; + + if (authCheck($login)) { + setcookie('phpRedisAdminLogin', $login['username'] . ':' . $login['password']); + // This should be an absolute URL, but that's a bit of a pain to generate; this will work + header("Location: index.php"); + die(); + } + } + + try { + global $redis; + $redis->ping(); + } catch (Predis\Response\ServerException $exception) { + // If we're here, we don't have a valid login cookie and we don't have a + // valid form submission, so redirect to the login page if we aren't + // already on that page + if (!defined('LOGIN_PAGE')) { + header("Location: login.php"); + die(); + } + } + + // We must be on the login page without a valid cookie or submission + return null; +} + +if (!empty($config['cookie_auth'])) { + $login = authCookie(); +} else { + $login = authHttpBasic(); +} diff --git a/login.php b/login.php index a80a24c..5c12301 100644 --- a/login.php +++ b/login.php @@ -33,7 +33,7 @@ > + >
        diff --git a/logout.php b/logout.php index 12cc80b..07e10ae 100644 --- a/logout.php +++ b/logout.php @@ -8,6 +8,10 @@ setcookie('phpRedisAdminLogin', '', 1); header("Location: login.php"); die(); +} else if (isset($config['login_as_acl_auth'])) { + // HTTP Basic auth + header('HTTP/1.1 401 Unauthorized'); + die(''); } else { // HTTP Digest auth $needed_parts = array( diff --git a/overview.php b/overview.php index 3e426db..5c67370 100644 --- a/overview.php +++ b/overview.php @@ -10,16 +10,24 @@ $server['db'] = 0; } - // Setup a connection to Redis. - if(isset($server['scheme']) && $server['scheme'] === 'unix' && $server['path']) { - $redis = new Predis\Client(array('scheme' => 'unix', 'path' => $server['path'])); + + if (isset($config['login_as_acl_auth'])) { + // Currently only support one server at a time + if ($i > 0) { + break; + } } else { - $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']); - } - try { - $redis->connect(); - } catch (Predis\CommunicationException $exception) { - $redis = false; + // Setup a connection to Redis. + if(isset($server['scheme']) && $server['scheme'] === 'unix' && $server['path']) { + $redis = new Predis\Client(array('scheme' => 'unix', 'path' => $server['path'])); + } else { + $redis = !$server['port'] ? new Predis\Client($server['host']) : new Predis\Client('tcp://'.$server['host'].':'.$server['port']); + } + try { + $redis->connect(); + } catch (Predis\CommunicationException $exception) { + $redis = false; + } } if(!$redis) { @@ -38,6 +46,9 @@ $info[$i] = $redis->info(); $info[$i]['size'] = $redis->dbSize(); + if (isset($config['login_as_acl_auth'])) { + $info[$i]['username'] = $redis->acl->whoami(); + } if (!isset($info[$i]['Server'])) { $info[$i]['Server'] = array( @@ -83,6 +94,10 @@
        Uptime:
        + +
        Username:
        + +
        Last save:
        Date: Mon, 31 Mar 2025 06:36:23 +0200 Subject: [PATCH 107/107] v1.24.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fb69cc8..3b3ab81 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "erik-dubbelboer/php-redis-admin", "description": "Simple web interface to manage Redis databases.", - "version": "1.23.0", + "version": "1.24.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [