From 9dc3496c2796b05f263ce322a61f7fa7c9a36f8f Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sat, 30 Dec 2023 04:30:21 +0800 Subject: [PATCH] update --- plugins/phpredisadmin/conf/config.inc.php | 2 +- plugins/phpredisadmin/index.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/phpredisadmin/conf/config.inc.php b/plugins/phpredisadmin/conf/config.inc.php index ef9c0fea4..f92419324 100644 --- a/plugins/phpredisadmin/conf/config.inc.php +++ b/plugins/phpredisadmin/conf/config.inc.php @@ -6,7 +6,7 @@ $config = array( array( 'name' => 'local server', // Optional name. 'host' => '127.0.0.1', - 'port' => 6379, + 'port' => {$REDIS_PORT}, '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' diff --git a/plugins/phpredisadmin/index.py b/plugins/phpredisadmin/index.py index fec686545..e4a26b485 100755 --- a/plugins/phpredisadmin/index.py +++ b/plugins/phpredisadmin/index.py @@ -122,6 +122,18 @@ def getRedisPass(): return requirepass + +def getRedisPort(): + port = "6379" + conf = mw.getServerDir() + '/redis/redis.conf' + if os.path.exists(conf): + content = mw.readFile(conf) + rep = "^(" + 'port' + ')\s*([.0-9A-Za-z_& ~]+)' + tmp = re.search(rep, content, re.M) + if tmp: + port = tmp.groups()[1] + return port + def contentReplace(content): service_path = mw.getServerDir() php_ver = getCachePhpVer() @@ -138,7 +150,9 @@ def contentReplace(content): # REDIS_PASS rd_pass = getRedisPass() + rd_port = getRedisPort() content = content.replace('{$REDIS_PASS}', rd_pass) + content = content.replace('{$REDIS_PORT}', rd_port) cfg = getCfg()