diff --git a/README.markdown b/README.markdown index 0dd4ef1..daec73c 100644 --- a/README.markdown +++ b/README.markdown @@ -24,7 +24,6 @@ TODO ==== * Javascript sorting of tables -* Make delete a POST request * Better error handling * Move or Copy key to different server * Importing JSON diff --git a/delete.php b/delete.php index 931b023..eba4f66 100644 --- a/delete.php +++ b/delete.php @@ -1,7 +1,12 @@ - - diff --git a/header.inc.php b/header.inc.php index 2c69043..dcb43b2 100644 --- a/header.inc.php +++ b/header.inc.php @@ -4,7 +4,7 @@ header('Cache-Control: private'); ?> - + diff --git a/import.php b/import.php index 0121760..bcb675c 100644 --- a/import.php +++ b/import.php @@ -5,6 +5,7 @@ +// This mess could need some cleanup! if (isset($_POST['commands'])) { $commands = explode("\n", $_POST['commands']); @@ -22,6 +23,8 @@ // We can't just explode since we might have \" inside the key. So do a preg_split on " with a negative lookbehind assertions to make sure it isn't a \". $key = preg_split('/(?set($key[0], trim($key[1], '"')); + if ($key[1][0] == '"') { + $val = stripslashes(trim($key[1], '"')); + } else { + $val = $key[1]; + } + + $redis->set($key[0], $val); break; } @@ -39,6 +47,8 @@ if ($key[1][0] == '"') { // See preg_split above. $hkey = preg_split('/(?hSet($key[0], $hkey[0], trim($hkey[1], '"')); + if ($hkey[1][0] == '"') { + $val = stripslashes(trim($hkey[1], '"')); + } else { + $val = $hkey[1]; + } + + $redis->hSet($key[0], $hkey[0], $val); break; } case 'RPUSH': { - $redis->rPush($key[0], trim($key[1], '"')); + if ($key[1][0] == '"') { + $val = stripslashes(trim($key[1], '"')); + } else { + $val = $key[1]; + } + + $redis->rPush($key[0], $val); break; } case 'SADD': { - $redis->sAdd($key[0], trim($key[1], '"')); + if ($key[1][0] == '"') { + $val = stripslashes(trim($key[1], '"')); + } else { + $val = $key[1]; + } + + $redis->sAdd($key[0], $val); break; } @@ -64,6 +92,8 @@ if ($key[1][0] == '"') { // See preg_split ebove. $score = preg_split('/(?zAdd($key[0], $score[0], trim($score[1], '"')); + if ($score[1][0] == '"') { + $val = stripslashes(trim($score[1], '"')); + } else { + $val = $score[1]; + } + + $redis->zAdd($key[0], $score[0], $val); break; } @@ -80,7 +116,6 @@ } - // Refresh the top so the key tree is updated. require 'header.inc.php'; diff --git a/index.php b/index.php index b2d97b0..82e507f 100644 --- a/index.php +++ b/index.php @@ -34,7 +34,9 @@ $d = &$d[$key[$i]]; } - $d[$key[count($key) - 1]] = true; // true means this is an actual key. + // Containing an item named __phpredisadmin__ means it's also a key. + // 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); @@ -65,9 +67,11 @@ function print_namespace($item, $name, $fullkey, $islast) { global $config, $redistypes, $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__']); - // true means it's a key and not a namespace. - if ($item === true) { $type = $redis->type($fullkey); if (!isset($redistypes[$type])) { @@ -114,7 +118,10 @@ function print_namespace($item, $name, $fullkey, $islast) { () 0) { ?>
  • ()