keys($server['filter']); } else { $next = 0; $keys = array(); while (true) { $r = $redis->scan($next, 'MATCH', $server['filter'], 'COUNT', $server['scansize']); $next = $r[0]; $keys = array_merge($keys, $r[1]); if ($next == 0) { break; } } } sort($keys); $namespaces = array(); // Array to hold our top namespaces. // Build an array of nested arrays containing all our namespaces and containing keys. foreach ($keys as $key) { // Ignore keys that are to long (Redis supports keys that can be way to long to put in an url). if (strlen($key) > $config['maxkeylen']) { continue; } $key = explode($server['seperator'], $key); //@todo: may be separator ? if ($config['showEmptyNamespaceAsKey'] && $key[count($key) - 1] == '') { array_pop($key); $key[count($key) - 1] .= ':'; } // $d will be a reference to the current namespace. $d = &$namespaces; // We loop though all the namespaces for this key creating the array for each. // Each time updating $d to be a reference to the last namespace so we can create the next one in it. for ($i = 0; $i < (count($key) - 1); ++$i) { if (!isset($d[$key[$i]])) { $d[$key[$i]] = array(); } $d = &$d[$key[$i]]; } // Nodes containing an item named __phpredisadmin__ are also a key, not just a directory. // This means that creating an actual key named __phpredisadmin__ will make this bug. $d[$key[count($key) - 1]] = array('__phpredisadmin__' => true); // Unset $d so we don't accidentally overwrite it somewhere else. unset($d); } // Recursive function used to print the namespaces. function print_namespace($item, $name, $fullkey, $islast) { global $config, $server, $redis; // Is this also a key and not just a namespace? if (isset($item['__phpredisadmin__'])) { // Unset it so we won't loop over it when printing this namespace. unset($item['__phpredisadmin__']); $class = array(); $len = false; if (isset($_GET['key']) && ($fullkey == $_GET['key'])) { $class[] = 'current'; } if ($islast) { $class[] = 'last'; } // Get the number of items in the key. if (!isset($config['faster']) || !$config['faster']) { switch ($redis->type($fullkey)) { case 'hash': $len = $redis->hLen($fullkey); break; case 'list': $len = $redis->lLen($fullkey); break; case 'set': $len = $redis->sCard($fullkey); break; case 'zset': $len = $redis->zCard($fullkey); break; } } if (empty($name) && $name != '0') { $name = ''; $class[] = 'empty'; } ?> > () 0) { ?>
  •  () [X]
      $childitem) { // $fullkey will be empty on the first call. if ($fullkey === '') { $childfullkey = $childname; } else { $childfullkey = $fullkey.$server['seperator'].$childname; } print_namespace($childitem, $childname, $childfullkey, (--$l == 0)); } ?>