Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 64 lines (45 sloc) 1.73 kb
159fae3 noferi mickaël complete check to remove php short tag
r043v authored
1 <?php
05f5795 Erik Dubbelboer first commit
authored
2
3
f53b55a Erik Dubbelboer made delete a POST
authored
4 if (!isset($_POST['post'])) {
5 die('Javascript needs to be enabled for you to delete keys.');
6 }
7
8
bfc7d91 Dirk Brünsicke move all include files to subfolder /includes
d1rk authored
9 require_once 'includes/common.inc.php';
05f5795 Erik Dubbelboer first commit
authored
10
11
12 if (isset($_GET['key'])) {
b6617ab Erik Dubbelboer - multi server support
authored
13 // String
05f5795 Erik Dubbelboer first commit
authored
14 if (!isset($_GET['type']) || ($_GET['type'] == 'string')) {
b6617ab Erik Dubbelboer - multi server support
authored
15 // Delete the whole key.
306b73d Erik Dubbelboer Now usable without php module.
authored
16 $redis->del($_GET['key']);
b6617ab Erik Dubbelboer - multi server support
authored
17 }
18
19 // Hash
20 else if (($_GET['type'] == 'hash') && isset($_GET['hkey'])) {
21 // Delete only the field in the hash.
05f5795 Erik Dubbelboer first commit
authored
22 $redis->hDel($_GET['key'], $_GET['hkey']);
b6617ab Erik Dubbelboer - multi server support
authored
23 }
05f5795 Erik Dubbelboer first commit
authored
24
b6617ab Erik Dubbelboer - multi server support
authored
25 // List
26 else if (($_GET['type'] == 'list') && isset($_GET['index'])) {
27 // Lists don't have simple delete operations.
28 // You can only remove something based on a value so we set the value at the index to some random value we hope doesn't occur elsewhere in the list.
29 $value = str_rand(69);
30
31 // This code assumes $value is not present in the list. To make sure of this we would need to check the whole list and place a Watch on it to make sure the list isn't modified in between.
05f5795 Erik Dubbelboer first commit
authored
32 $redis->lSet($_GET['key'], $_GET['index'], $value);
306b73d Erik Dubbelboer Now usable without php module.
authored
33 $redis->lRem($_GET['key'], 1, $value);
b6617ab Erik Dubbelboer - multi server support
authored
34 }
35
36 // Set
37 else if (($_GET['type'] == 'set') && isset($_GET['value'])) {
38 // Removing members from a set can only be done by supplying the member.
05f5795 Erik Dubbelboer first commit
authored
39 $redis->sRem($_GET['key'], $_GET['value']);
b6617ab Erik Dubbelboer - multi server support
authored
40 }
41
42 // ZSet
43 else if (($_GET['type'] == 'zset') && isset($_GET['value'])) {
44 // Removing members from a zset can only be done by supplying the value.
306b73d Erik Dubbelboer Now usable without php module.
authored
45 $redis->zRem($_GET['key'], $_GET['value']);
05f5795 Erik Dubbelboer first commit
authored
46 }
47
b6617ab Erik Dubbelboer - multi server support
authored
48
f53b55a Erik Dubbelboer made delete a POST
authored
49 die('?view&s='.$server['id'].'&key='.urlencode($_GET['key']));
05f5795 Erik Dubbelboer first commit
authored
50 }
51
a0e47b7 Erik Dubbelboer It is possible to delete whole trees now. Made the keys column a bit wid...
authored
52
53 if (isset($_GET['tree'])) {
54 $keys = $redis->keys($_GET['tree'].'*');
55
56 foreach ($keys as $key) {
306b73d Erik Dubbelboer Now usable without php module.
authored
57 $redis->del($key);
a0e47b7 Erik Dubbelboer It is possible to delete whole trees now. Made the keys column a bit wid...
authored
58 }
bfc7d91 Dirk Brünsicke move all include files to subfolder /includes
d1rk authored
59
4c56f58 ZJH fix infinite redirect bug when delete a key
zhengjinhua authored
60 die('?view&s='.$server['id']);
a0e47b7 Erik Dubbelboer It is possible to delete whole trees now. Made the keys column a bit wid...
authored
61 }
62
f705e67 Erik Dubbelboer replace print with echo (small bit faster)
authored
63 ?>
Something went wrong with that request. Please try again.