submissions_list.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. $conds = array();
  3. $q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null;
  4. $q_submitter = isset($_GET['submitter']) && validateUsername($_GET['submitter']) ? $_GET['submitter'] : null;
  5. $q_min_score = isset($_GET['min_score']) && validateUInt($_GET['min_score']) ? $_GET['min_score'] : null;
  6. $q_max_score = isset($_GET['max_score']) && validateUInt($_GET['max_score']) ? $_GET['max_score'] : null;
  7. $q_language = isset($_GET['language']) ? $_GET['language'] : null;
  8. if ($q_problem_id != null) {
  9. $conds[] = "problem_id = $q_problem_id";
  10. }
  11. if ($q_submitter != null) {
  12. $conds[] = "submitter = '$q_submitter'";
  13. }
  14. if ($q_min_score != null) {
  15. $conds[] = "score >= $q_min_score";
  16. }
  17. if ($q_max_score != null) {
  18. $conds[] = "score <= $q_max_score";
  19. }
  20. if ($q_language != null) {
  21. $conds[] = sprintf("language = '%s'", DB::escape($q_language));
  22. }
  23. $html_esc_q_language = htmlspecialchars($q_language);
  24. if ($conds) {
  25. $cond = join($conds, ' and ');
  26. } else {
  27. $cond = '1';
  28. }
  29. ?>
  30. <?php echoUOJPageHeader(UOJLocale::get('submissions')) ?>
  31. <div class="d-none d-sm-block">
  32. <?php if ($myUser != null): ?>
  33. <div class="float-right">
  34. <a href="/submissions?submitter=<?= $myUser['username'] ?>" class="btn btn-primary btn-sm"><?= UOJLocale::get('problems::my submissions') ?></a>
  35. </div>
  36. <?php endif ?>
  37. <form id="form-search" class="form-inline" method="get">
  38. <div id="form-group-problem_id" class="form-group">
  39. <label for="input-problem_id" class="control-label mx-2"><?= UOJLocale::get('problems::problem id')?>:</label>
  40. <input type="text" class="form-control input-sm" name="problem_id" id="input-problem_id" value="<?= $q_problem_id ?>" maxlength="4" style="width:4em" />
  41. </div>
  42. <div id="form-group-submitter" class="form-group">
  43. <label for="input-submitter" class="control-label mx-2"><?= UOJLocale::get('username')?>:</label>
  44. <input type="text" class="form-control input-sm" name="submitter" id="input-submitter" value="<?= $q_submitter ?>" maxlength="20" style="width:10em" />
  45. </div>
  46. <div id="form-group-score" class="form-group">
  47. <label for="input-min_score" class="control-label mx-2"><?= UOJLocale::get('score range')?>:</label>
  48. <input type="text" class="form-control input-sm" name="min_score" id="input-min_score" value="<?= $q_min_score ?>" maxlength="3" style="width:4em" placeholder="0" />
  49. <label for="input-max_score" class="control-label">~</label>
  50. <input type="text" class="form-control input-sm" name="max_score" id="input-max_score" value="<?= $q_max_score ?>" maxlength="3" style="width:4em" placeholder="100" />
  51. </div>
  52. <div id="form-group-language" class="form-group">
  53. <label for="input-language" class="control-label mx-2"><?= UOJLocale::get('problems::language')?>:</label>
  54. <input type="text" class="form-control input-sm" name="language" id="input-language" value="<?= $html_esc_q_language ?>" maxlength="10" style="width:8em" />
  55. </div>
  56. <button type="submit" id="submit-search" class="btn btn-secondary btn-sm ml-2"><?= UOJLocale::get('search')?></button>
  57. </form>
  58. <script type="text/javascript">
  59. $('#form-search').submit(function(e) {
  60. e.preventDefault();
  61. url = '/submissions';
  62. qs = [];
  63. $(['problem_id', 'submitter', 'min_score', 'max_score', 'language']).each(function () {
  64. if ($('#input-' + this).val()) {
  65. qs.push(this + '=' + encodeURIComponent($('#input-' + this).val()));
  66. }
  67. });
  68. if (qs.length > 0) {
  69. url += '?' + qs.join('&');
  70. }
  71. location.href = url;
  72. });
  73. </script>
  74. <div class="top-buffer-sm"></div>
  75. </div>
  76. <?php
  77. echoSubmissionsList($cond, 'order by id desc', array('judge_time_hidden' => ''), $myUser);
  78. ?>
  79. <?php echoUOJPageFooter() ?>