S2OJ/web/app/controllers/click_zan.php

25 lines
684 B
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
2022-11-06 02:26:21 +00:00
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']));