Skip to content

Commit b57e3b0

Browse files
Fix CSRF bugs
1 parent f62fd14 commit b57e3b0

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

includes/header.inc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,9 @@
3535
<script src="js/<?php echo $js; ?>.js?v<?=$version?>"></script>
3636
<?php } ?>
3737

38+
<script>
39+
phpRedisAdmin_csrfToken = '<?php echo $csrfToken; ?>';
40+
</script>
41+
3842
</head>
3943
<body>

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function getDbInfo($d, $info, $padding = '') {
245245
</p>
246246
<button id="selected_all_keys">Select all</button>
247247
<button id="operations">
248-
<a href="delete.php?s=<?php echo $server['id']?>&amp;d=<?php echo $server['db']?>&batch_del=1" class="batch_del">Delete selected<img src="images/delete.png" style="width: 1em;height: 1em;vertical-align: middle;" title="Delete selected" alt="[X]"></a>
248+
<a href="delete.php?s=<?php echo $server['id']?>&amp;d=<?php echo $server['db']?>&batch_del=1&csrf=<?php echo $csrfToken; ?>" class="batch_del">Delete selected<img src="images/delete.png" style="width: 1em;height: 1em;vertical-align: middle;" title="Delete selected" alt="[X]"></a>
249249
</button>
250250
</div>
251251
<div id="keys">

js/frame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $(function() {
1818
$.ajax({
1919
type: "POST",
2020
url: this.href,
21-
data: 'post=1',
21+
data: 'post=1&csrf=' + phpRedisAdmin_csrfToken,
2222
success: function(url) {
2323
top.location.href = top.location.pathname+url;
2424
}

js/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ $(function() {
2828
$.ajax({
2929
type: "POST",
3030
url: this.href,
31-
data: 'post=1&selected_keys=' + selected_keys,
31+
data: 'post=1&selected_keys=' + selected_keys + '&csrf=' + phpRedisAdmin_csrfToken,
3232
success: function(url) {
3333
top.location.href = top.location.pathname+url;
3434
}
@@ -41,7 +41,7 @@ $(function() {
4141
$.ajax({
4242
type: "POST",
4343
url: this.href,
44-
data: 'post=1',
44+
data: 'post=1&csrf=' + phpRedisAdmin_csrfToken,
4545
success: function(url) {
4646
top.location.href = top.location.pathname+url;
4747
}
@@ -74,7 +74,7 @@ $(function() {
7474
$.ajax({
7575
type: "POST",
7676
url: href,
77-
data: 'post=1',
77+
data: 'post=1&csrf=' + phpRedisAdmin_csrfToken,
7878
success: function() {
7979
window.location.reload();
8080
}

0 commit comments

Comments
 (0)