From 31aa7661e6db6f4dffbf9a635817832a0a11c7d9 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Tue, 5 Oct 2021 18:45:52 +0000 Subject: [PATCH 01/40] Fix magic hash attack --- 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 75ed28d..8cfb26d 100644 --- a/includes/login.inc.php +++ b/includes/login.inc.php @@ -56,7 +56,7 @@ function authHttpDigest() $response = md5($password.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.md5($_SERVER['REQUEST_METHOD'].':'.$data['uri'])); - if ($data['response'] != $response) { + 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.'); From 33d3d99ccbb553bb12d2b10c4e45abafd55bcd3c Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Tue, 5 Oct 2021 18:46:18 +0000 Subject: [PATCH 02/40] v1.16.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8a896b6..823fd5f 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.16.1", + "version": "1.16.2", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From cc9f24c9c7dca6182b2f3a6d02e6b12b6af4b0aa Mon Sep 17 00:00:00 2001 From: kerolos william Date: Thu, 14 Oct 2021 21:31:47 +0200 Subject: [PATCH 03/40] ADD DATABASES env var in the readme file #102 (#173) --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index ddf39d3..15de6f7 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_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 From 57268d96b00d16c1b5177df9bd0ac74338433ea1 Mon Sep 17 00:00:00 2001 From: Charlie Hayes Date: Mon, 13 Dec 2021 02:51:45 -0600 Subject: [PATCH 04/40] Fix #157 by upgrading predis; Upgraded docker compose; Fixed submit button being cut off (#174) --- Dockerfile | 4 ++-- composer.json | 4 ++-- composer.lock | 44 ++++++++++++++++++++++++++++++++------------ css/frame.css | 1 - docker-compose.yml | 29 +++++++++++++++-------------- edit.php | 2 -- export.php | 14 ++++++-------- import.php | 2 -- rename.php | 2 -- ttl.php | 2 -- 10 files changed, 57 insertions(+), 47 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd40ac1..16f313d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM composer:1.7 +FROM composer:2.2 -ENV TINI_VERSION 0.18.0-r0 +ENV TINI_VERSION 0.19.0-r0 RUN apk add --no-cache tini=$TINI_VERSION diff --git a/composer.json b/composer.json index 823fd5f..544a765 100644 --- a/composer.json +++ b/composer.json @@ -13,9 +13,9 @@ } ], "require": { - "predis/predis": "1.1.x-dev", + "predis/predis": "v1.1.9", "paragonie/random_compat": ">=2" }, "minimum-stability": "stable", - "target-dir": "ErikDubbelboer/phpRedisAdmin" + "target-dir": "ErikDubbelboer/phpRedisAdmin" } diff --git a/composer.lock b/composer.lock index 43a24c3..41f9438 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": "719c08328f6db3021508e7ef84d95588", + "content-hash": "ad3fb9bfb043b086870b317dc9eff9b7", "packages": [ { "name": "paragonie/random_compat", @@ -49,20 +49,25 @@ "pseudorandom", "random" ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, "time": "2020-10-15T08:29:30+00:00" }, { "name": "predis/predis", - "version": "v1.1.x-dev", + "version": "v1.1.9", "source": { "type": "git", "url": "https://github.com/predis/predis.git", - "reference": "111d100ee389d624036b46b35ed0c9ac59c71313" + "reference": "c50c3393bb9f47fa012d0cdfb727a266b0818259" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/predis/predis/zipball/111d100ee389d624036b46b35ed0c9ac59c71313", - "reference": "111d100ee389d624036b46b35ed0c9ac59c71313", + "url": "https://api.github.com/repos/predis/predis/zipball/c50c3393bb9f47fa012d0cdfb727a266b0818259", + "reference": "c50c3393bb9f47fa012d0cdfb727a266b0818259", "shasum": "" }, "require": { @@ -89,27 +94,42 @@ { "name": "Daniele Alessandri", "email": "suppakilla@gmail.com", - "homepage": "http://clorophilla.net/" + "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", - "homepage": "http://github.com/nrk/predis", + "homepage": "http://github.com/predis/predis", "keywords": [ "nosql", "predis", "redis" ], - "time": "2017-07-12T14:39:17+00:00" + "support": { + "issues": "https://github.com/predis/predis/issues", + "source": "https://github.com/predis/predis/tree/v1.1.9" + }, + "funding": [ + { + "url": "https://github.com/sponsors/tillkruss", + "type": "github" + } + ], + "time": "2021-10-05T19:02:38+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "predis/predis": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "2.1.0" } diff --git a/css/frame.css b/css/frame.css index e54ca9e..8969e10 100644 --- a/css/frame.css +++ b/css/frame.css @@ -14,7 +14,6 @@ margin-left: -8em; } form .button { -margin-left: -7em; } diff --git a/docker-compose.yml b/docker-compose.yml index dab64b9..5ef83df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,16 @@ -phpredisadmin: - build: . - environment: - - ADMIN_USER=admin - - ADMIN_PASS=admin - - REDIS_1_HOST=redis - - REDIS_1_PORT=6379 - links: - - redis - ports: - - "80:80" +services: + 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 + redis: + image: redis + command: --loglevel verbose diff --git a/edit.php b/edit.php index 9642171..0e0b360 100644 --- a/edit.php +++ b/edit.php @@ -185,9 +185,7 @@ -

-

get($key)),'"',PHP_EOL; @@ -124,7 +124,7 @@ function export_json($key) { // JSON if ($_POST['type'] == 'json') { - + // Single key if (isset($_GET['key'])) { echo json_encode(export_json($_GET['key'])); @@ -137,13 +137,13 @@ function 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); } @@ -165,7 +165,7 @@ function export_json($key) { // if we have a filter and no match, we skip if($filter !== false && stripos($key, $filter) === false) continue; - + export_redis($key, $filter, $transform); } } @@ -195,7 +195,7 @@ function export_json($key) { -

+

@@ -209,9 +209,7 @@ function export_json($key) {

-

-

-

-

>

-

-

> (-1 to remove the TTL)

-

-

Date: Mon, 13 Dec 2021 08:52:26 +0000 Subject: [PATCH 05/40] v1.17.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 544a765..3cc3fdd 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.16.2", + "version": "1.17.0", "license": "CC-BY-3.0", "homepage": "https://github.com/ErikDubbelboer/phpRedisAdmin", "authors": [ From 0866ff2d438dfe11c306f60fa88e21c0f0866ed5 Mon Sep 17 00:00:00 2001 From: diplopito <26707508+diplopito@users.noreply.github.com> Date: Mon, 11 Apr 2022 19:21:27 +0300 Subject: [PATCH 06/40] Update view.php (#180) * Update view.php When `$type = 'ReJSON-RL'`, a warning is displayed: "Notice: Undefined variable: size in view.php on line 116." This is a small patch while reJson is added to library. * Update view.php * Update view.php Extended `if` code (didn't want to nest ternary operators). * Update view.php Default statement updated. --- view.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/view.php b/view.php index 1bfff92..e33bcae 100644 --- a/view.php +++ b/view.php @@ -96,6 +96,9 @@ } $size = count($values); break; + + default: + $size = -1; } if (isset($values) && ($count_elements_page !== false)) { @@ -113,7 +116,19 @@
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 07/40] 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 08/40] 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 09/40] 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 10/40] 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 11/40] 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 12/40] 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 13/40] 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 14/40] 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 15/40] 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 16/40] 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 17/40] 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 18/40] 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 19/40] 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 20/40] 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 21/40] 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 22/40] 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 23/40] 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 24/40] 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 25/40] 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 26/40] 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 27/40] 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 28/40] 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 29/40] 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 30/40] 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 31/40] 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 32/40] 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 33/40] 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 34/40] 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 35/40] 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 36/40] 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 37/40] 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 38/40] 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 39/40] 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 40/40] 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": [