代码拉取完成,页面将自动刷新
<?php
require_once 'includes/common.inc.php';
global $redis, $config, $csrfToken, $server;
$page['css'][] = 'frame';
$page['js'][] = 'frame';
require 'includes/header.inc.php';
if (!isset($_GET['key'])) {
?>
Invalid key
<?php
require 'includes/footer.inc.php';
die;
}
$type = $redis->type($_GET['key']);
$exists = $redis->exists($_GET['key']);
$count_elements_page = isset($config['count_elements_page']) ? $config['count_elements_page'] : false;
$page_num_request = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$page_num_request = $page_num_request === 0 ? 1 : $page_num_request;
?>
<h2><?php echo format_html($_GET['key'])?>
<?php if ($exists) { ?>
<a href="rename.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&key=<?php echo urlencode($_GET['key'])?>"><img src="images/edit.png" width="16" height="16" title="Rename" alt="[R]"></a>
<a href="delete.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&key=<?php echo urlencode($_GET['key'])?>" class="delkey"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
<a href="export.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&key=<?php echo urlencode($_GET['key'])?>"><img src="images/export.png" width="16" height="16" title="Export" alt="[E]"></a>
<?php } ?>
</h2>
<?php
if (!$exists) {
?>
This key does not exist.
<?php
require 'includes/footer.inc.php';
die;
}
$alt = false;
$ttl = $redis->ttl($_GET['key']);
try {
$encoding = $redis->object('encoding', $_GET['key']);
} catch (Exception $e) {
$encoding = null;
}
switch ($type) {
case 'string':
$value = $redis->get($_GET['key']);
$value = encodeOrDecode('load', $_GET['key'], $value);
$size = strlen($value);
break;
case 'hash':
$values = $redis->hGetAll($_GET['key']);
foreach ($values as $k => $value) {
$values[$k] = encodeOrDecode('load', $_GET['key'], $value);
}
$size = count($values);
ksort($values);
break;
case 'list':
$size = $redis->lLen($_GET['key']);
break;
case 'set':
$values = $redis->sMembers($_GET['key']);
foreach ($values as $k => $value) {
$values[$k] = encodeOrDecode('load', $_GET['key'], $value);
}
$size = count($values);
sort($values);
break;
case 'zset':
$values = $redis->zRange($_GET['key'], 0, -1);
foreach ($values as $k => $value) {
$values[$k] = encodeOrDecode('load', $_GET['key'], $value);
}
$size = count($values);
break;
default:
$size = -1;
}
if (isset($values) && ($count_elements_page !== false)) {
$values = array_slice($values, $count_elements_page * ($page_num_request - 1), $count_elements_page,true);
}
?>
<table>
<tr><td><div>Type:</div></td><td><div><?php echo format_html($type)?></div></td></tr>
<tr><td><div><abbr title="Time To Live">TTL</abbr>:</div></td><td><div><?php echo ($ttl == -1) ? 'does not expire' : format_ttl($ttl) ?> <a href="ttl.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&key=<?php echo urlencode($_GET['key'])?>&ttl=<?php echo $ttl?>"><img src="images/edit.png" width="16" height="16" title="Edit TTL" alt="[E]" class="imgbut"></a></div></td></tr>
<?php if (!is_null($encoding)) { ?>
<tr><td><div>Encoding:</div></td><td><div><?php echo format_html($encoding)?></div></td></tr>
<?php } ?>
<tr><td><div>Size:</div></td><td><div>
<?php
echo $size;
if ($type === 'string') {
echo " characters";
} else if ($size < 0) {
echo " (Type Unsupported)";
} else {
echo " items";
}
?>
</div></td></tr>
</table>
<p>
<?php
// Build pagination div.
if (($count_elements_page !== false) && in_array($type, array('hash', 'list', 'set', 'zset')) && ($size > $count_elements_page)) {
$prev = $page_num_request - 1;
$next = $page_num_request + 1;
$lastpage = ceil($size / $count_elements_page);
$lpm1 = $lastpage - 1;
$adjacents = 3;
$pagination = '<div style="width: inherit; word-wrap: break-word;">';
$url = preg_replace('/&page=(\d+)/i', '', $_SERVER['REQUEST_URI']);
if ($page_num_request > 1) $pagination .= "<a href=\"$url&page=$prev\">←</a> "; else
$pagination .= "← ";
if ($lastpage < 7 + ($adjacents * 2)) { //not enough pages to bother breaking it up
for ($counter = 1; $counter <= $lastpage; $counter++) {
if ($counter == $page_num_request) $pagination .= $page_num_request . ' '; else
$pagination .= "<a href=\"$url&page=$counter\">$counter</a> ";
}
} elseif ($lastpage > 5 + ($adjacents * 2)) { //enough pages to hide some
if ($page_num_request < 1 + ($adjacents * 2)) { //close to beginning; only hide later pages
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) {
if ($counter == $page_num_request) $pagination .= $page_num_request . ' '; else
$pagination .= "<a href=\"$url&page=$counter\">$counter</a> ";
}
$pagination .= "... ";
$pagination .= "<a href=\"$url&page=$lpm1\">$lpm1</a> ";
$pagination .= "<a href=\"$url&page=$lastpage\">$lastpage</a> ";
} elseif ($lastpage - ($adjacents * 2) > $page_num_request && $page_num_request > ($adjacents * 2)) { //in middle; hide some front and some back
$pagination .= "<a href=\"$url&page=1\">1</a> ";
$pagination .= "<a href=\"$url&page=2\">2</a> ";
$pagination .= "... ";
for ($counter = $page_num_request - $adjacents; $counter <= $page_num_request + $adjacents; $counter++) {
if ($counter == $page_num_request) $pagination .= $page_num_request . ' '; else
$pagination .= "<a href=\"$url&page=$counter\">$counter</a> ";
}
$pagination .= "... ";
$pagination .= "<a href=\"$url&page=$lpm1\">$lpm1</a> ";
$pagination .= "<a href=\"$url&page=$lastpage\">$lastpage</a> ";
} else { //close to end; only hide early pages
$pagination .= "<a href=\"$url&page=1\">1</a> ";
$pagination .= "<a href=\"$url&page=2\">2</a> ";
$pagination .= "... ";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) {
if ($counter == $page_num_request) $pagination .= $page_num_request . ' '; else
$pagination .= "<a href=\"$url&page=$counter\">$counter</a> ";
}
}
}
if ($page_num_request < $counter - 1) $pagination .= "<a href=\"$url&page=$next\">→</a> "; else
$pagination .= "→ ";
$pagination .= "</div>";
}
if (isset($pagination)) {
echo $pagination;
}
// String
if ($type == 'string') { ?>
<table>
<tr><td><div class=data><?php echo format_html($value)?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=string&key=<?php echo urlencode($_GET['key'])?>"><img src="images/edit.png" width="16" height="16" title="Edit" alt="[E]"></a>
</div></td><td><div>
<a href="delete.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=string&key=<?php echo urlencode($_GET['key'])?>" class="delval"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
</div></td></tr>
</table>
<?php }
// Hash
else if ($type == 'hash') { ?>
<table>
<tr><th><div>Key</div></th><th><div>Value</div></th><th><div> </div></th><th><div> </div></th></tr>
<?php foreach ($values as $hkey => $value) { ?>
<tr <?php echo $alt ? 'class="alt"' : ''?>><td><div><?php echo format_html($hkey)?></div></td><td><div class=data><?php echo format_html($value)?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=hash&key=<?php echo urlencode($_GET['key'])?>&hkey=<?php echo urlencode($hkey)?>"><img src="images/edit.png" width="16" height="16" title="Edit" alt="[E]"></a>
</div></td><td><div>
<a href="delete.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=hash&key=<?php echo urlencode($_GET['key'])?>&hkey=<?php echo urlencode($hkey)?>" class="delval"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
</div></td></tr>
<?php $alt = !$alt; } ?>
<?php }
// List
else if ($type == 'list') { ?>
<table>
<tr><th><div>Index</div></th><th><div>Value</div></th><th><div> </div></th><th><div> </div></th></tr>
<?php
if (($count_elements_page === false) && ($size > $count_elements_page)) {
$start = 0;
$end = $size;
} else {
$start = $count_elements_page * ($page_num_request - 1);
$end = min($start + $count_elements_page, $size);
}
for ($i = $start; $i < $end; ++$i) {
$value = $redis->lIndex($_GET['key'], $i);
$value = encodeOrDecode('load', $_GET['key'], $value);
?>
<tr <?php echo $alt ? 'class="alt"' : ''?>><td><div><?php echo $i?></div></td><td><div class=data><?php echo format_html($value)?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=list&key=<?php echo urlencode($_GET['key'])?>&index=<?php echo $i?>"><img src="images/edit.png" width="16" height="16" title="Edit" alt="[E]"></a>
</div></td><td><div>
<a href="delete.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=list&key=<?php echo urlencode($_GET['key'])?>&index=<?php echo $i?>" class="delval"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
</div></td></tr>
<?php $alt = !$alt; } ?>
<?php }
// Set
else if ($type == 'set') {
?>
<table>
<tr><th><div>Value</div></th><th><div> </div></th><th><div> </div></th></tr>
<?php foreach ($values as $value) {
$display_value = $redis->exists($value) ? '<a href="view.php?s='.$server['id'].'&d='.$server['db'].'&key='.urlencode($value).'">'.format_html($value).'</a>' : format_html($value);
?>
<tr <?php echo $alt ? 'class="alt"' : ''?>><td><div class=data><?php echo $display_value ?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=set&key=<?php echo urlencode($_GET['key'])?>&value=<?php echo urlencode($value)?>"><img src="images/edit.png" width="16" height="16" title="Edit" alt="[E]"></a>
</div></td><td><div>
<a href="delete.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=set&key=<?php echo urlencode($_GET['key'])?>&value=<?php echo urlencode($value)?>" class="delval"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
</div></td></tr>
<?php $alt = !$alt; } ?>
<?php }
// ZSet
else if ($type == 'zset') { ?>
<table>
<tr><th><div>Score</div></th><th><div>Value</div></th><th><div> </div></th><th><div> </div></th></tr>
<?php foreach ($values as $value) {
$score = $redis->zScore($_GET['key'], $value);
$display_value = $redis->exists($value) ? '<a href="view.php?s='.$server['id'].'&d='.$server['db'].'&key='.urlencode($value).'">'.format_html($value).'</a>' : format_html($value);
?>
<tr <?php echo $alt ? 'class="alt"' : ''?>><td><div><?php echo $score?></div></td><td><div class=data><?php echo $display_value ?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=zset&key=<?php echo urlencode($_GET['key'])?>&score=<?php echo $score?>&value=<?php echo urlencode($value)?>"><img src="images/edit.png" width="16" height="16" title="Edit" alt="[E]"></a>
<a href="delete.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=zset&key=<?php echo urlencode($_GET['key'])?>&value=<?php echo urlencode($value)?>" class="delval"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
</div></td></tr>
<?php $alt = !$alt; } ?>
<?php }
if ($type != 'string') { ?>
</table>
<p>
<a href="edit.php?s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&type=<?php echo $type?>&key=<?php echo urlencode($_GET['key'])?>" class="add">Add another value</a>
</p>
<?php }
if (isset($pagination)) {
echo $pagination;
}
require 'includes/footer.inc.php';
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。