Skip to content

Commit

Permalink
Flush button that can be enabled per server (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdubbelboer committed Nov 20, 2013
1 parent 8459eb1 commit 0b8d3b7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
13 changes: 13 additions & 0 deletions flush.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php


if (!isset($_POST['post'])) {
die('Javascript needs to be enabled for you to flush a database.');
}


require_once 'includes/common.inc.php';


$redis->flushdb();

Binary file added images/flush.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions includes/config.sample.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'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.
)*/
),

Expand All @@ -50,8 +51,6 @@
),*/




// You can ignore settings below this point.

'maxkeylen' => 100,
Expand Down
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ function print_namespace($item, $name, $fullkey, $islast) {
<a href="?info&amp;s=<?php echo $server['id']?>"><img src="images/info.png" width="16" height="16" title="Info" alt="[I]"></a>
<a href="?export&amp;s=<?php echo $server['id']?>"><img src="images/export.png" width="16" height="16" title="Export" alt="[E]"></a>
<a href="?import&amp;s=<?php echo $server['id']?>"><img src="images/import.png" width="16" height="16" title="Import" alt="[I]"></a>
<?php if (isset($server['flush']) && $server['flush']) { ?>
<a href="?flush&amp;s=<?php echo $server['id']?>" id="flush"><img src="images/flush.png" width="16" height="16" title="Flush" alt="[F]"></a>
<?php } ?>
</p>

<p>
Expand Down
18 changes: 16 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@ $(function() {
href += '.php';
}
}

$('#iframe').attr('src', href);

if (href.indexOf('flush.php') == 0) {
if (confirm('Are you sure you want to delete this key and all it\'s values?')) {
$.ajax({
type: "POST",
url: href,
data: 'post=1',
success: function() {
window.location.reload();
}
});
}
} else {
$('#iframe').attr('src', href);
}
});


Expand Down Expand Up @@ -98,5 +111,6 @@ $(function() {
});
}
});

});

0 comments on commit 0b8d3b7

Please sign in to comment.