forked from erikdubbelboer/phpRedisAdmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
import.php
122 lines (92 loc) · 2.27 KB
/
import.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
require_once 'includes/common.inc.php';
// This mess could need some cleanup!
if (isset($_POST['commands'])) {
// Append some spaces at the end to make sure we always have enough arguments for the last function.
$commands = str_getcsv(str_replace(array("\r", "\n"), array('', ' '), $_POST['commands']).' ', ' ');
foreach ($commands as &$command) {
$command = stripslashes($command);
}
unset($command);
for ($i = 0; $i < count($commands); ++$i) {
if (empty($commands[$i])) {
continue;
}
$commands[$i] = strtoupper($commands[$i]);
switch ($commands[$i]) {
case 'SET': {
$redis->set($commands[$i+1], $commands[$i+2]);
$i += 2;
break;
}
case 'HSET': {
$redis->hSet($commands[$i+1], $commands[$i+2], $commands[$i+3]);
$i += 3;
break;
}
case 'LPUSH': {
$redis->lPush($commands[$i+1], $commands[$i+2]);
$i += 2;
break;
}
case 'RPUSH': {
$redis->rPush($commands[$i+1], $commands[$i+2]);
$i += 2;
break;
}
case 'LSET': {
$redis->lSet($commands[$i+1], $commands[$i+2], $commands[$i+3]);
$i += 3;
break;
}
case 'SADD': {
$redis->sAdd($commands[$i+1], $commands[$i+2]);
$i += 2;
break;
}
case 'ZADD': {
$redis->zAdd($commands[$i+1], $commands[$i+2], $commands[$i+3]);
$i += 3;
break;
}
}
}
// Refresh the top so the key tree is updated.
require 'includes/header.inc.php';
?>
<script>
top.location.href = top.location.pathname+'?overview&s=<?php echo $server['id']?>&d=<?php echo $server['db']?>';
</script>
<?php
require 'includes/footer.inc.php';
die;
}
$page['css'][] = 'frame';
$page['js'][] = 'frame';
require 'includes/header.inc.php';
?>
<h2>Import</h2>
<form action="<?php echo format_html($_SERVER['REQUEST_URI'])?>" method="post">
<p>
<label for="commands">Commands:<br>
<br>
<span class="info">
Valid are:<br>
SET<br>
HSET<br>
LPUSH<br>
RPUSH<br>
LSET<br>
SADD<br>
ZADD
</span>
</label>
<textarea name="commands" id="commands" cols="80" rows="20"></textarea>
</p>
<p>
<input type="submit" class="button" value="Import">
</p>
</form>
<?php
require 'includes/footer.inc.php';
?>