--- UOJ-System/web/app/controllers/problem_set.php 2023-03-19 21:20:30.679254485 +0800 +++ UOJ-Luogu-RemoteJudge/web/app/controllers/problem_set.php 2023-03-20 14:43:44.884987235 +0800 @@ -2,6 +2,7 @@ requirePHPLib('form'); requirePHPLib('judger'); requirePHPLib('data'); + requirePHPLib('luogu'); if (isSuperUser($myUser)) { $new_problem_form = new UOJForm('new_problem'); @@ -15,8 +16,28 @@ $new_problem_form->submit_button_config['class_str'] = 'btn btn-primary'; $new_problem_form->submit_button_config['text'] = UOJLocale::get('problems::add new'); $new_problem_form->submit_button_config['smart_confirm'] = ''; - $new_problem_form->runAtServer(); + + $new_luogu_problem_form = new UOJForm('new_luogu_problem'); + $new_luogu_problem_form->addVInput('luogu_pid', 'text', '洛谷题号', '', function($id) { + if (!validateLuoguProblemId($id)) { + return '题目 ID 不合法'; + } + + return ''; + }, null); + $new_luogu_problem_form->handle = function() { + try { + newLuoguRemoteProblem($_POST['luogu_pid']); + } catch (Exception $e) { + becomeMsgPage('

添加失败

' . $e->getMessage() . '
'); + } + }; + // $new_luogu_problem_form->submit_button_config['align'] = 'right'; + $new_luogu_problem_form->submit_button_config['class_str'] = 'btn btn-primary'; + $new_luogu_problem_form->submit_button_config['text'] = UOJLocale::get('problems::add new'); + $new_luogu_problem_form->submit_button_config['confirm'] = '新增来自洛谷的题目'; + $new_luogu_problem_form->runAtServer(); } function echoProblem($problem) { @@ -186,7 +207,16 @@ echo ''; if (isSuperUser($myUser)) { + echo '
'; $new_problem_form->printHTML(); + + echo '
'; + echo '
'; + echo '
'; + $new_luogu_problem_form->printHTML(); + echo '
'; + echo '
'; + echo ''; } echo $pag->pagination();