setProblem() || UOJResponse::page404(); UOJHack::cur()->userCanView(Auth::user(), ['ensure' => true]); if (UOJHack::cur()->setSubmission()) { UOJHack::cur()->submission->setAsCur(); UOJSubmission::cur()->setProblem(['problem' => UOJHack::cur()->problem]) || UOJResponse::page404(); UOJSubmission::cur()->userCanView(Auth::user(), ['ensure' => true]); } if (UOJHack::cur()->userCanDelete(Auth::user())) { $delete_form = new UOJForm('delete'); $delete_form->handle = function () { DB::delete([ "delete from hacks", "where", ["id" => UOJHack::info('id')] ]); }; $delete_form->config['submit_container']['class'] = 'text-end'; $delete_form->config['submit_button']['class'] = 'btn btn-sm btn-danger'; $delete_form->config['submit_button']['text'] = '删除此 Hack'; $delete_form->config['confirm']['smart'] = true; $delete_form->succ_href = "/hacks"; $delete_form->runAtServer(); } if (UOJHack::cur()->userCanReview(Auth::user())) { $addex_form = new UOJForm('addex'); $addex_form->handle = function () { $input = UOJContext::storagePath() . UOJHack::info('input'); $new_in = "{$input}_in"; $new_out = "{$input}_out"; $reason = null; $err = dataAddHackPoint(UOJHack::cur()->problem->info, $new_in, $new_out, $reason, Auth::user()); $err === '' || UOJResponse::message($err); unlink($new_in); unlink($new_out); DB::update([ "update hacks", "set", [ 'status' => 'Judged', ], "where", ['id' => UOJHack::info('id')] ]); }; $addex_form->config['submit_button']['class'] = 'btn btn-sm btn-danger'; $addex_form->config['submit_button']['text'] = '确认无误,添加到测试数据'; $addex_form->config['submit_container']['class'] = 'mt-3 text-end'; $addex_form->config['confirm']['text'] = '将这个 Hack 数据添加到测试数据中'; $addex_form->succ_href = "/hacks"; $addex_form->runAtServer(); } $perm = UOJHack::cur()->viewerCanSeeComponents(Auth::user()); ?>