Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/erikdubbelboer/phpRedisAdmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.markdown1
-rw-r--r--includes/common.inc.php1
-rw-r--r--includes/config.sample.inc.php3
-rw-r--r--includes/functions.inc.php8
-rw-r--r--overview.php2
-rw-r--r--view.php10
6 files changed, 14 insertions, 11 deletions
diff --git a/README.markdown b/README.markdown
index 0564eae..1a744ac 100644
--- a/README.markdown
+++ b/README.markdown
@@ -42,6 +42,7 @@ git clone https://github.com/nrk/predis.git vendor
TODO
====
+* Encoding support for editing
* Javascript sorting of tables
* Better error handling
* Move or Copy key to different server
diff --git a/includes/common.inc.php b/includes/common.inc.php
index 04d7c01..d15270e 100644
--- a/includes/common.inc.php
+++ b/includes/common.inc.php
@@ -55,6 +55,7 @@ if (isset($_GET['s']) && is_numeric($_GET['s']) && ($_GET['s'] < count($config['
$server = $config['servers'][$i];
$server['id'] = $i;
+$server['charset'] = isset($server['charset']) && $server['charset'] ? $server['charset'] : mb_internal_encoding();
if (isset($login, $login['servers'])) {
diff --git a/includes/config.sample.inc.php b/includes/config.sample.inc.php
index 1227fce..4fc63d7 100644
--- a/includes/config.sample.inc.php
+++ b/includes/config.sample.inc.php
@@ -25,7 +25,8 @@ $config = array(
'db' => 1 // Optional database number, see http://redis.io/commands/select
'filter' => 'something:*' // Show only parts of database for speed or security reasons
'seperator' => '/', // Use a different seperator on this database
- 'flush' => false // Set to true to enable the flushdb button for this instance.
+ 'flush' => false, // Set to true to enable the flushdb button for this instance.
+ 'encoding' => 'cp1251', // Set for view values in other encoding
)*/
),
diff --git a/includes/functions.inc.php b/includes/functions.inc.php
index 1f370df..0a4eb7d 100644
--- a/includes/functions.inc.php
+++ b/includes/functions.inc.php
@@ -1,11 +1,11 @@
<?php
-
-function format_html($str) {
- return htmlentities($str, ENT_COMPAT, 'UTF-8');
+function format_html($str, $from_encoding = FALSE) {
+ $res = $from_encoding ? mb_convert_encoding($str, 'utf-8', $from_encoding) : $str;
+ $res = htmlentities($res, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8');
+ return ($res || !$str) ? $res : '(' . strlen($str) . ' bytes)';
}
-
function format_ago($time, $ago = false) {
$minute = 60;
$hour = $minute * 60;
diff --git a/overview.php b/overview.php
index bf65d57..caeb2bb 100644
--- a/overview.php
+++ b/overview.php
@@ -65,7 +65,7 @@ require 'includes/header.inc.php';
<?php foreach ($config['servers'] as $i => $server) { ?>
<div class="server">
- <h2><?php echo isset($server['name']) ? $server['name'] : format_html($server['host'])?></h2>
+ <h2><?php echo isset($server['name']) ? format_html($server['name']) : format_html($server['host'])?></h2>
<?php if(!$info[$i]): ?>
<div style="text-align:center;color:red">Server Down</div>
diff --git a/view.php b/view.php
index 3dd2ea0..8d86371 100644
--- a/view.php
+++ b/view.php
@@ -137,7 +137,7 @@ if (isset($pagination)) {
if ($type == 'string') { ?>
<table>
-<tr><td><div><?php echo nl2br(format_html($value))?></div></td><td><div>
+<tr><td><div><?php echo nl2br(format_html($value, $server['charset']))?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&amp;type=string&amp;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']?>&amp;type=string&amp;key=<?php echo urlencode($_GET['key'])?>" class="delval"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
@@ -155,7 +155,7 @@ else if ($type == 'hash') { ?>
<tr><th><div>Key</div></th><th><div>Value</div></th><th><div>&nbsp;</div></th><th><div>&nbsp;</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><?php echo nl2br(format_html($value))?></div></td><td><div>
+ <tr <?php echo $alt ? 'class="alt"' : ''?>><td><div><?php echo format_html($hkey, $server['charset'])?></div></td><td><div><?php echo nl2br(format_html($value, $server['charset']))?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&amp;type=hash&amp;key=<?php echo urlencode($_GET['key'])?>&amp;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']?>&amp;type=hash&amp;key=<?php echo urlencode($_GET['key'])?>&amp;hkey=<?php echo urlencode($hkey)?>" class="delval"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
@@ -183,7 +183,7 @@ else if ($type == 'list') { ?>
for ($i = $start; $i < $end; ++$i) {
$value = $redis->lIndex($_GET['key'], $i);
?>
- <tr <?php echo $alt ? 'class="alt"' : ''?>><td><div><?php echo $i?></div></td><td><div><?php echo nl2br(format_html($value))?></div></td><td><div>
+ <tr <?php echo $alt ? 'class="alt"' : ''?>><td><div><?php echo $i?></div></td><td><div><?php echo nl2br(format_html($value, $server['charset']))?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&amp;type=list&amp;key=<?php echo urlencode($_GET['key'])?>&amp;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']?>&amp;type=list&amp;key=<?php echo urlencode($_GET['key'])?>&amp;index=<?php echo $i?>" class="delval"><img src="images/delete.png" width="16" height="16" title="Delete" alt="[X]"></a>
@@ -202,7 +202,7 @@ else if ($type == 'set') {
<tr><th><div>Value</div></th><th><div>&nbsp;</div></th><th><div>&nbsp;</div></th></tr>
<?php foreach ($values as $value) {
- $display_value = $redis->exists($value) ? '<a href="view.php?s='.$server['id'].'&key='.urlencode($value).'">'.nl2br(format_html($value)).'</a>' : nl2br(format_html($value));
+ $display_value = $redis->exists($value) ? '<a href="view.php?s='.$server['id'].'&key='.urlencode($value).'">'.nl2br(format_html($value, $server['charset'])).'</a>' : nl2br(format_html($value, $server['charset']));
?>
<tr <?php echo $alt ? 'class="alt"' : ''?>><td><div><?php echo $display_value ?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&amp;type=set&amp;key=<?php echo urlencode($_GET['key'])?>&amp;value=<?php echo urlencode($value)?>"><img src="images/edit.png" width="16" height="16" title="Edit" alt="[E]"></a>
@@ -223,7 +223,7 @@ else if ($type == 'zset') { ?>
<?php foreach ($values as $value) {
$score = $redis->zScore($_GET['key'], $value);
- $display_value = $redis->exists($value) ? '<a href="view.php?s='.$server['id'].'&key='.urlencode($value).'">'.nl2br(format_html($value)).'</a>' : nl2br(format_html($value));
+ $display_value = $redis->exists($value) ? '<a href="view.php?s='.$server['id'].'&key='.urlencode($value).'">'.nl2br(format_html($value, $server['charset'])).'</a>' : nl2br(format_html($value, $server['charset']));
?>
<tr <?php echo $alt ? 'class="alt"' : ''?>><td><div><?php echo $score?></div></td><td><div><?php echo $display_value ?></div></td><td><div>
<a href="edit.php?s=<?php echo $server['id']?>&amp;type=zset&amp;key=<?php echo urlencode($_GET['key'])?>&amp;score=<?php echo $score?>&amp;value=<?php echo urlencode($value)?>"><img src="images/edit.png" width="16" height="16" title="Edit" alt="[E]"></a>