S2OJ/web/app/controllers/click_zan.php
Baoshuo 62a63c4c6e
All checks were successful
continuous-integration/drone/push Build is passing
fix(web): ClickZans::click
2022-11-07 20:13:57 +08:00

25 lines
717 B
PHP

<?php
function validateZan() {
if (!validateUInt($_POST['id']))
return false;
if (!validateInt($_POST['delta']))
return false;
if ($_POST['delta'] != 1 && $_POST['delta'] != -1)
return false;
if (!ClickZans::getTable($_POST['type']))
return false;
return true;
}
if (!validateZan()) {
die('<div class="text-danger">failed</div>');
}
if (!Auth::check()) {
die('<div class="text-danger">please <a href="' . HTML::url('/login') . '">log in</a></div>');
}
if (!ClickZans::canClickZan($_POST['id'], $_POST['type'], Auth::user())) {
die('<div class="text-danger">no permission</div>');
}
die(ClickZans::click($_POST['id'], $_POST['type'], Auth::user(), $_POST['delta'], $_POST['show-text'] !== 'false'));