Skip to content

Commit

Permalink
Fixed possible direct calls
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Sep 27, 2017
1 parent 3c75f87 commit cce47f9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions phpmyfaq/admin/stat.ratings.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
<i aria-hidden="true" class="fa fa-tasks"></i> <?php echo $PMF_LANG['ad_rs'] ?>

<div class="pull-right">
<a class="btn btn-danger" href="?action=clear-statistics">
<a class="btn btn-danger"
href="?action=clear-statistics&csrf=<?php echo $user->getCsrfTokenFromSession() ?>">
<i aria-hidden="true" class="fa fa-trash"></i> <?php echo $PMF_LANG['ad_delete_all_votings'] ?>
</a>
</div>
Expand All @@ -50,7 +51,15 @@
</header>

<?php
if ('clear-statistics' === $action) {
$csrfToken = PMF_Filter::filterInput(INPUT_GET, 'csrf', FILTER_SANITIZE_STRING);

if (!isset($_SESSION['phpmyfaq_csrf_token']) || $_SESSION['phpmyfaq_csrf_token'] !== $csrfToken) {
$clearStatistics = false;
} else {
$clearStatistics = true;
}

if ('clear-statistics' === $action && $clearStatistics) {
if ($ratings->deleteAll()) {
echo '<p class="alert alert-success">Statistics successfully deleted.</p>';
} else {
Expand Down

0 comments on commit cce47f9

Please sign in to comment.