diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0d6a4b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/local.php +/phpRedisAdmin.sublime-project +/phpRedisAdmin.sublime-workspace diff --git a/delete.php b/delete.php index ec7e20e..afe0322 100644 --- a/delete.php +++ b/delete.php @@ -59,5 +59,3 @@ die('?&s='.$server['id']); } - -?> diff --git a/edit.php b/edit.php index 357a368..4666862 100644 --- a/edit.php +++ b/edit.php @@ -182,5 +182,3 @@ diff --git a/includes/common.inc.php b/includes/common.inc.php index b1c38de..1725d4b 100644 --- a/includes/common.inc.php +++ b/includes/common.inc.php @@ -25,17 +25,16 @@ // These includes are needed by each script. -require_once PHPREDIS_ADMIN_PATH . '/includes/config.inc.php'; +$config = require(PHPREDIS_ADMIN_PATH . '/includes/config.inc.php'); + require_once PHPREDIS_ADMIN_PATH . '/includes/functions.inc.php'; require_once PHPREDIS_ADMIN_PATH . '/includes/page.inc.php'; -require_once PHPREDIS_ADMIN_PATH . '/predis/autoload.php'; - if (isset($config['login'])) { require_once PHPREDIS_ADMIN_PATH . '/includes/login.inc.php'; } - +require_once PHPREDIS_ADMIN_PATH . '/predis/autoload.php'; if (isset($login['servers'])) { @@ -88,6 +87,4 @@ if (!$redis->select($server['db'])) { die('ERROR: Selecting database failed ('.$server['host'].':'.$server['port'].','.$server['db'].')'); } -} - -?> +} \ No newline at end of file diff --git a/includes/config.inc.php b/includes/config.inc.php index 3664c8b..62ba5bd 100644 --- a/includes/config.inc.php +++ b/includes/config.inc.php @@ -1,58 +1,73 @@ array( - 0 => array( - 'name' => 'local server', // Optional name. - 'host' => '127.0.0.1', - 'port' => 6379, - 'filter' => '*' +return call_user_func(function () { - // Optional Redis authentication. - //'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server. - ), + defined('PHPREDIS_CONFIG_PATH') || define('PHPREDIS_CONFIG_PATH', (getenv('PHPREDIS_CONFIG_PATH') + ? getenv('PHPREDIS_CONFIG_PATH') + : null) + ); - /*1 => array( - 'host' => 'localhost', - 'port' => 6380 - ),*/ + if (!is_null(PHPREDIS_CONFIG_PATH) && file_exists(PHPREDIS_CONFIG_PATH)) { + $config = require(PHPREDIS_CONFIG_PATH); + } + else { - /*2 => array( - 'name' => 'local db 2', - 'host' => 'localhost', - 'port' => 6379, - 'db' => 1 // Optional database number, see http://redis.io/commands/select - 'filter' => 'something:*' // Show only parts of database for speed or security reasons - )*/ - ), + $config = array( + 'servers' => array( + 0 => array( + 'name' => 'local server', // Optional name. + 'host' => '127.0.0.1', + 'port' => 6379, + 'filter' => '*' + // Optional Redis authentication. + //'auth' => 'redispasswordhere' // Warning: The password is sent in plain-text to the Redis server. + ), - 'seperator' => ':', + /*1 => array( + 'host' => 'localhost', + 'port' => 6380 + ),*/ + /*2 => array( + 'name' => 'local db 2', + 'host' => 'localhost', + 'port' => 6379, + 'db' => 1 // Optional database number, see http://redis.io/commands/select + 'filter' => 'something:*' // Show only parts of database for speed or security reasons + )*/ + ), - // Uncomment to show less information and make phpRedisAdmin fire less commands to the Redis server. Recommended for a really busy Redis server. - //'faster' => true, + 'seperator' => ':', - // Uncomment to enable HTTP authentication - /*'login' => array( - // Username => Password - // Multiple combinations can be used - 'admin' => array( - 'password' => 'adminpassword', - ), - 'guest' => array( - 'password' => '', - 'servers' => array(1) // Optional list of servers this user can access. - ) - ),*/ + // Uncomment to show less information and make phpRedisAdmin fire less commands to the Redis server. Recommended for a really busy Redis server. + //'faster' => true, + // Uncomment to enable HTTP authentication + /*'login' => array( + // Username => Password + // Multiple combinations can be used + 'admin' => array( + 'password' => 'adminpassword', + ), + 'guest' => array( + 'password' => '', + 'servers' => array(1) // Optional list of servers this user can access. + ) + ),*/ - // You can ignore settings below this point. - 'maxkeylen' => 100 -); -?> + + // You can ignore settings below this point. + + 'maxkeylen' => 100 + ); + + } + + return $config; +}); \ No newline at end of file diff --git a/includes/functions.inc.php b/includes/functions.inc.php index 388f535..ebd2e27 100644 --- a/includes/functions.inc.php +++ b/includes/functions.inc.php @@ -64,3 +64,22 @@ function str_rand($length) { return $r; } +function merge_arrays($a,$b) +{ + $args=func_get_args(); + $res=array_shift($args); + while(!empty($args)) + { + $next=array_shift($args); + foreach($next as $k => $v) + { + if(is_integer($k)) + isset($res[$k]) ? $res[]=$v : $res[$k]=$v; + else if(is_array($v) && isset($res[$k]) && is_array($res[$k])) + $res[$k]=merge_arrays($res[$k],$v); + else + $res[$k]=$v; + } + } + return $res; +} \ No newline at end of file diff --git a/includes/header.inc.php b/includes/header.inc.php index 368da14..acf84e3 100644 --- a/includes/header.inc.php +++ b/includes/header.inc.php @@ -35,3 +35,4 @@ + \ No newline at end of file diff --git a/includes/login.inc.php b/includes/login.inc.php index 633bd94..30b632d 100644 --- a/includes/login.inc.php +++ b/includes/login.inc.php @@ -58,6 +58,4 @@ 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.'); -} - -?> +} \ No newline at end of file diff --git a/includes/page.inc.php b/includes/page.inc.php index 2f1a0e9..0a0c381 100644 --- a/includes/page.inc.php +++ b/includes/page.inc.php @@ -18,5 +18,3 @@ function is_ie() { 'css' => array('common'), 'js' => array('jquery') ); - -?> \ No newline at end of file diff --git a/index.php b/index.php index e0d5068..482283b 100644 --- a/index.php +++ b/index.php @@ -195,5 +195,3 @@ function print_namespace($item, $name, $fullkey, $islast) { diff --git a/info.php b/info.php index 1c20961..6fd624f 100644 --- a/info.php +++ b/info.php @@ -56,5 +56,3 @@ diff --git a/logout.php b/logout.php index 2d6aca8..3d29598 100644 --- a/logout.php +++ b/logout.php @@ -36,5 +36,3 @@ header('Location: '.substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'logout.php'))); - -?> diff --git a/overview.php b/overview.php index 111f919..3eee9b4 100644 --- a/overview.php +++ b/overview.php @@ -78,5 +78,3 @@ diff --git a/rename.php b/rename.php index a542576..15071cb 100644 --- a/rename.php +++ b/rename.php @@ -52,5 +52,3 @@ diff --git a/ttl.php b/ttl.php index 7e09efc..153321a 100644 --- a/ttl.php +++ b/ttl.php @@ -46,5 +46,3 @@ diff --git a/view.php b/view.php index c023fc9..8337c1d 100644 --- a/view.php +++ b/view.php @@ -210,4 +210,3 @@ require 'includes/footer.inc.php'; -