代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/phpredisadmin 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<?php
require_once 'includes/common.inc.php';
global $redis, $config, $csrfToken, $server;
// Are we editing or creating a new key?
$edit = false;
if (isset($_GET['key'], $_GET['type'])) {
if (($_GET['type'] == 'string') ||
(($_GET['type'] == 'hash') && isset($_GET['hkey'])) ||
(($_GET['type'] == 'list') && isset($_GET['index'])) ||
(($_GET['type'] == 'set' ) && isset($_GET['value'])) ||
(($_GET['type'] == 'zset') && isset($_GET['value']))) {
$edit = true;
}
}
if (isset($_POST['type'], $_POST['key'], $_POST['value'])) {
// Don't allow keys that are to long (Redis supports keys that can be way to long to put in an url).
if (strlen($_POST['key']) > $config['maxkeylen']) {
die('ERROR: Your key is to long (max length is '.$config['maxkeylen'].')');
}
$key = input_convert($_POST['key']);
$value = input_convert($_POST['value']);
$value = encodeOrDecode('save', $key, $value);
if ($value === false || is_null($value)) {
die('ERROR: could not encode value');
}
// String
if ($_POST['type'] == 'string') {
$redis->set($key, $value);
}
// Hash
else if (($_POST['type'] == 'hash') && isset($_POST['hkey'])) {
if (strlen($_POST['hkey']) > $config['maxkeylen']) {
die('ERROR: Your hash key is to long (max length is '.$config['maxkeylen'].')');
}
if ($edit && !$redis->hExists($key, input_convert($_POST['hkey']))) {
$redis->hDel($key, input_convert($_GET['hkey']));
}
$redis->hSet($key, input_convert($_POST['hkey']), $value);
}
// List
else if (($_POST['type'] == 'list') && isset($_POST['index'])) {
$size = $redis->lLen($key);
if (($_POST['index'] == '') ||
($_POST['index'] == $size)) {
// Push it at the end
$redis->rPush($key, $value);
} else if ($_POST['index'] == -1) {
// Push it at the start
$redis->lPush($key, $value);
} else if (($_POST['index'] >= 0) &&
($_POST['index'] < $size)) {
// Overwrite an index
$redis->lSet($key, input_convert($_POST['index']), $value);
} else {
die('ERROR: Out of bounds index');
}
}
// Set
else if ($_POST['type'] == 'set') {
if ($_POST['value'] != $_POST['oldvalue']) {
// The only way to edit a Set value is to add it and remove the old value.
$redis->sRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue'])));
$redis->sAdd($key, $value);
}
}
// ZSet
else if (($_POST['type'] == 'zset') && isset($_POST['score'])) {
// The only way to edit a ZSet value is to add it and remove the old value.
$redis->zRem($key, encodeOrDecode('save', $key, input_convert($_POST['oldvalue'])));
$redis->zAdd($key, input_convert($_POST['score']), $value);
}
// Refresh the top so the key tree is updated.
require 'includes/header.inc.php';
?>
<script>
top.location.href = top.location.pathname+'?view&s=<?php echo $server['id']?>&d=<?php echo $server['db']?>&key=<?php echo urlencode($_POST['key'])?>';
</script>
<?php
require 'includes/footer.inc.php';
die;
}
// Get the current value.
$value = '';
if ($edit) {
// String
if ($_GET['type'] == 'string') {
$value = $redis->get($_GET['key']);
}
// Hash
else if (($_GET['type'] == 'hash') && isset($_GET['hkey'])) {
$value = $redis->hGet($_GET['key'], $_GET['hkey']);
}
// List
else if (($_GET['type'] == 'list') && isset($_GET['index'])) {
$value = $redis->lIndex($_GET['key'], $_GET['index']);
}
// Set, ZSet
else if ((($_GET['type'] == 'set') || ($_GET['type'] == 'zset')) && isset($_GET['value'])) {
$value = $_GET['value'];
}
$value = encodeOrDecode('load', $_GET['key'], $value);
}
$page['css'][] = 'frame';
$page['js'][] = 'frame';
require 'includes/header.inc.php';
?>
<h2><?php echo $edit ? 'Edit' : 'Add'?></h2>
<form action="<?php echo format_html(getRelativePath('edit.php'))?>" method="post">
<input type="hidden" name="csrf" value="<?php echo $csrfToken; ?>" />
<p>
<label for="type">Type:</label>
<select name="type" id="type">
<option value="string" <?php echo (isset($_GET['type']) && ($_GET['type'] == 'string')) ? 'selected="selected"' : ''?>>String</option>
<option value="hash" <?php echo (isset($_GET['type']) && ($_GET['type'] == 'hash' )) ? 'selected="selected"' : ''?>>Hash</option>
<option value="list" <?php echo (isset($_GET['type']) && ($_GET['type'] == 'list' )) ? 'selected="selected"' : ''?>>List</option>
<option value="set" <?php echo (isset($_GET['type']) && ($_GET['type'] == 'set' )) ? 'selected="selected"' : ''?>>Set</option>
<option value="zset" <?php echo (isset($_GET['type']) && ($_GET['type'] == 'zset' )) ? 'selected="selected"' : ''?>>ZSet</option>
</select>
</p>
<p>
<label for="key">Key:</label>
<input type="text" name="key" id="key" size="30" <?php echo isset($_GET['key']) ? 'value="'.format_html($_GET['key']).'"' : ''?>>
</p>
<p id="hkeyp">
<label for="khey">Hash key:</label>
<input type="text" name="hkey" id="hkey" size="30" <?php echo isset($_GET['hkey']) ? 'value="'.format_html($_GET['hkey']).'"' : ''?>>
</p>
<p id="indexp">
<label for="index">Index:</label>
<input type="text" name="index" id="index" size="30" <?php echo isset($_GET['index']) ? 'value="'.format_html($_GET['index']).'"' : ''?>> <span class="info">empty to append, -1 to prepend</span>
</p>
<p id="scorep">
<label for="score">Score:</label>
<input type="text" name="score" id="score" size="30" <?php echo isset($_GET['score']) ? 'value="'.format_html($_GET['score']).'"' : ''?>>
</p>
<p>
<label for="value">Value:</label>
<textarea name="value" id="value" cols="80" rows="20"><?php echo format_html($value)?></textarea>
</p>
<input type="hidden" name="oldvalue" value="<?php echo format_html($value)?>">
<input type="submit" class="button" value="<?php echo $edit ? 'Edit' : 'Add'?>">
</form>
<?php
require 'includes/footer.inc.php';
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。