S2OJ/web/app/controllers/hack_list.php

142 lines
4.4 KiB
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
2022-11-06 02:26:21 +00:00
requireLib('bootstrap5');
2022-10-20 22:58:32 +00:00
2022-11-06 02:26:21 +00:00
Auth::check() || redirectToLogin();
2022-03-17 04:00:03 +00:00
2022-11-06 02:26:21 +00:00
$q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null;
$q_submission_id = isset($_GET['submission_id']) && validateUInt($_GET['submission_id']) ? $_GET['submission_id'] : null;
$q_hacker = isset($_GET['hacker']) && validateUsername($_GET['hacker']) ? $_GET['hacker'] : null;
$q_owner = isset($_GET['owner']) && validateUsername($_GET['owner']) ? $_GET['owner'] : null;
2022-04-03 10:18:17 +00:00
2022-11-06 02:26:21 +00:00
$conds = [];
if ($q_problem_id != null) {
$conds[] = ["problem_id" => $q_problem_id];
}
if ($q_submission_id != null) {
$conds[] = ["submission_id" => $q_submission_id];
}
if ($q_hacker != null) {
$conds[] = ["hacker" => $q_hacker];
}
if ($q_owner != null) {
$conds[] = ["owner" => $q_owner];
}
2016-07-18 16:39:37 +00:00
2022-11-06 02:26:21 +00:00
$selected_all = ' selected="selected"';
$selected_succ = '';
$selected_fail = '';
if (isset($_GET['status']) && validateUInt($_GET['status'])) {
if ($_GET['status'] == 1) {
$selected_all = '';
$selected_succ = ' selected="selected"';
$conds[] = 'success = 1';
2016-07-18 16:39:37 +00:00
}
2022-11-06 02:26:21 +00:00
if ($_GET['status'] == 2) {
$selected_all = '';
$selected_fail = ' selected="selected"';
$conds[] = 'success = 0';
2016-07-18 16:39:37 +00:00
}
2022-11-06 02:26:21 +00:00
}
if ($conds) {
$cond = $conds;
} else {
$cond = '1';
}
?>
2016-07-18 16:39:37 +00:00
<?php echoUOJPageHeader(UOJLocale::get('hacks')) ?>
2022-09-26 12:42:46 +00:00
2022-11-06 02:26:21 +00:00
<h1>
<?= UOJLocale::get('hacks') ?>
2022-09-26 12:42:46 +00:00
</h1>
2022-10-21 00:01:54 +00:00
<div class="d-none d-sm-block mb-3">
<form id="form-search" class="row gy-2 gx-3 align-items-end mb-3" target="_self" method="GET">
<div id="form-group-submission_id" class="col-auto">
<label for="input-submission_id" class="form-label">
<?= UOJLocale::get('problems::submission id') ?>:
</label>
<input type="text" class="form-control form-control-sm" name="submission_id" id="input-submission_id" value="<?= $q_submission_id ?>" style="width:6em" />
2016-07-18 16:39:37 +00:00
</div>
2022-10-21 00:01:54 +00:00
<div id="form-group-problem_id" class="col-auto">
<label for="input-problem_id" class="form-label">
<?= UOJLocale::get('problems::problem id') ?>:
</label>
<input type="text" class="form-control form-control-sm" name="problem_id" id="input-problem_id" value="<?= $q_problem_id ?>" style="width:6em" />
2016-07-18 16:39:37 +00:00
</div>
2022-10-21 00:01:54 +00:00
<div id="form-group-hacker" class="col-auto">
<label for="input-hacker" class="form-label">
<?= UOJLocale::get('problems::hacker') ?>:
</label>
<div class="input-group">
<input type="text" class="form-control form-control-sm" name="hacker" id="input-hacker" value="<?= $q_hacker ?>" maxlength="20" style="width:10em" />
2022-11-06 02:26:21 +00:00
<?php if (Auth::check()) : ?>
<a id="my-hacks" href="/hacks?hacker=<?= Auth::id() ?>" class="btn btn-outline-secondary btn-sm">
我的
</a>
2022-10-21 00:01:54 +00:00
<?php endif ?>
</div>
<script>
$('#my-hacks').click(function(event) {
event.preventDefault();
$('#input-hacker').val('<?= Auth::id() ?>');
$('#form-search').submit();
});
</script>
2016-07-18 16:39:37 +00:00
</div>
2022-10-21 00:01:54 +00:00
<div id="form-group-owner" class="col-auto">
<label for="input-owner" class="form-label">
<?= UOJLocale::get('problems::owner') ?>:
</label>
<div class="input-group">
<input type="text" class="form-control form-control-sm" name="owner" id="input-owner" value="<?= $q_owner ?>" maxlength="20" style="width:10em" />
2022-11-06 02:26:21 +00:00
<?php if (Auth::check()) : ?>
<a id="my-owners" href="/hacks?owner=<?= Auth::id() ?>" class="btn btn-outline-secondary btn-sm">
我的
</a>
2022-10-21 00:01:54 +00:00
<?php endif ?>
</div>
<script>
$('#my-owners').click(function(event) {
event.preventDefault();
$('#input-owner').val('<?= Auth::id() ?>');
$('#form-search').submit();
});
</script>
2016-07-18 16:39:37 +00:00
</div>
2022-10-21 00:01:54 +00:00
<div id="form-group-status" class="col-auto">
<label for="input-status" class="form-label">
<?= UOJLocale::get('problems::result') ?>:
</label>
<select class="form-select form-select-sm" id="input-status" name="status">
2022-11-06 02:26:21 +00:00
<option value="" <?= $selected_all ?>>All</option>
<option value="1" <?= $selected_succ ?>>Success!</option>
<option value="2" <?= $selected_fail ?>>Failed.</option>
2016-07-18 16:39:37 +00:00
</select>
</div>
2022-10-21 00:01:54 +00:00
<div class="col-auto">
<button type="submit" id="submit-search" class="btn btn-secondary btn-sm ml-2">
<?= UOJLocale::get('search') ?>
</button>
</div>
2016-07-18 16:39:37 +00:00
</form>
</div>
2022-09-26 12:42:46 +00:00
2022-11-06 02:26:21 +00:00
<?php
echoHacksList(
$cond,
2022-09-26 12:42:46 +00:00
'order by id desc',
2022-10-20 22:58:32 +00:00
[
2022-09-26 12:42:46 +00:00
'judge_time_hidden' => '',
2022-10-20 22:58:32 +00:00
'table_config' => [
'div_classes' => ['card', 'mb-3', 'table-responsive'],
'table_classes' => ['table', 'mb-0', 'uoj-table', 'text-center'],
],
],
2022-11-06 02:26:21 +00:00
Auth::user()
);
?>
2022-09-26 12:42:46 +00:00
2016-07-18 16:39:37 +00:00
<?php echoUOJPageFooter() ?>