api scrape + medal wearing status

This commit is contained in:
xiaomlove
2022-03-19 14:55:43 +08:00
parent 8c32b45e64
commit 4857b799b8
24 changed files with 16536 additions and 69 deletions

29
public/ajax.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
require "../include/bittorrent.php";
dbconn();
loggedinorreturn();
$action = $_POST['action'] ?? 'noAction';
$params = $_POST['params'] ?? [];
function noAction()
{
throw new \RuntimeException("no Action");
}
try {
$result = call_user_func($action, $params);
exit(json_encode(success($result)));
} catch (\Throwable $exception) {
exit(json_encode(fail($exception->getMessage(), $_POST)));
}
function toggleUserMedalStatus($params)
{
global $CURUSER;
$rep = new \App\Repositories\MedalRepository();
return $rep->toggleUserMedalStatus($params['id'], $CURUSER['id']);
}