diff --git a/web/app/controllers/subdomain/api/remote_judge/custom_account_validator.php b/web/app/controllers/subdomain/api/remote_judge/custom_account_validator.php index f655b20..87a3aa5 100644 --- a/web/app/controllers/subdomain/api/remote_judge/custom_account_validator.php +++ b/web/app/controllers/subdomain/api/remote_judge/custom_account_validator.php @@ -77,6 +77,29 @@ if ($type == 'luogu') { return true; } + return false; + }, 3); +} else if ($type == 'uoj') { + $curl->setFollowLocation(); + $curl->setCookie('UOJSESSID', UOJRequest::post('UOJSESSID', 'is_string', '')); + + retry_loop(function () use (&$curl, &$res) { + $curl->get(UOJRemoteProblem::$providers['uoj']['url'] . '/login'); + + if ($curl->error) { + return false; + } + + if (str_starts_with($curl->responseHeaders['Content-Type'], 'text/html')) { + if (str_contains($curl->response, '登录')) { + return false; + } + + $res = true; + + return true; + } + return false; }, 3); } else { diff --git a/web/js/uoj.js b/web/js/uoj.js index e08d151..69063ce 100644 --- a/web/js/uoj.js +++ b/web/js/uoj.js @@ -1181,16 +1181,31 @@ $.fn.remote_submit_type_group = function(oj, pid, url, submit_type) { uoj_account_data.UOJSESSID = $(this).val(); input_my_account_data.val(JSON.stringify(uoj_account_data)); save_uoj_account_data(); + my_account_validation_status.html('<span class="text-secondary">待验证</span>'); + }); + + my_account_validation_btn.click(function() { + validate_my_account({ + type: 'uoj', + UOJSESSID: input_uoj_uojsessid.val(), + }); }); input_my_account_data.val(JSON.stringify(uoj_account_data)); input_uoj_uojsessid.val(uoj_account_data.UOJSESSID); + if (uoj_account_data.UOJSESSID) { + validate_my_account({ + type: 'uoj', + UOJSESSID: uoj_account_data.UOJSESSID, + }); + } + div_submit_type_my.append( - $('<div class="row mt-3" />') + $('<div class="row mt-3 align-items-center" />') .append($('<div class="col-sm-2" />').append('<label for="input-uoj_uojsessid" class="col-form-label">UOJSESSID</label>')) .append($('<div class="col-sm-4" />').append(input_uoj_uojsessid)) - .append($('<div class="col-sm-6" />').append($('<div class="form-text" />').append('请填入 Cookie 中的 <code>UOJSESSID</code>。'))) + .append($('<div class="col-sm-6" />').append($('<div class="form-text mt-0" />').append('请填入 Cookie 中的 <code>UOJSESSID</code>。'))) ).append(input_my_account_data); }