hack_list.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. $conds = array();
  3. $q_problem_id = isset($_GET['problem_id']) && validateUInt($_GET['problem_id']) ? $_GET['problem_id'] : null;
  4. $q_submission_id = isset($_GET['submission_id']) && validateUInt($_GET['submission_id']) ? $_GET['submission_id'] : null;
  5. $q_hacker = isset($_GET['hacker']) && validateUsername($_GET['hacker']) ? $_GET['hacker'] : null;
  6. $q_owner = isset($_GET['owner']) && validateUsername($_GET['owner']) ? $_GET['owner'] : null;
  7. if ($q_problem_id != null) {
  8. $conds[] = "problem_id = $q_problem_id";
  9. }
  10. if ($q_submission_id != null) {
  11. $conds[] = "submission_id = $q_submission_id";
  12. }
  13. if ($q_hacker != null) {
  14. $conds[] = "hacker = '$q_hacker'";
  15. }
  16. if ($q_owner != null) {
  17. $conds[] = "owner = '$q_owner'";
  18. }
  19. $selected_all = ' selected="selected"';
  20. $selected_succ ='';
  21. $selected_fail ='';
  22. if (isset($_GET['status']) && validateUInt($_GET['status'])) {
  23. if ($_GET['status'] == 1) {
  24. $selected_all = '';
  25. $selected_succ =' selected="selected"';
  26. $conds[] = 'success = 1';
  27. }
  28. if ($_GET['status'] == 2) {
  29. $selected_all = '';
  30. $selected_fail = ' selected="selected"';
  31. $conds[] = 'success = 0';
  32. }
  33. }
  34. if ($conds) {
  35. $cond = join($conds, ' and ');
  36. } else {
  37. $cond = '1';
  38. }
  39. ?>
  40. <?php echoUOJPageHeader(UOJLocale::get('hacks')) ?>
  41. <div class="d-none d-sm-block">
  42. <?php if ($myUser != null): ?>
  43. <div class="float-right">
  44. <a href="/hacks?hacker=<?= $myUser['username'] ?>" class="btn btn-success btn-sm"><?= UOJLocale::get('problems::hacks by me') ?></a>
  45. <a href="/hacks?owner=<?= $myUser['username'] ?>" class="btn btn-danger btn-sm"><?= UOJLocale::get('problems::hacks to me') ?></a>
  46. </div>
  47. <?php endif ?>
  48. <form id="form-search" class="form-inline" role="form">
  49. <div id="form-group-submission_id" class="form-group">
  50. <label for="input-submission_id" class="control-label mx-2"><?= UOJLocale::get('problems::submission id') ?>:</label>
  51. <input type="text" class="form-control input-sm" name="submission_id" id="input-submission_id" value="<?= $q_submission_id ?>" maxlength="6" style="width:5em" />
  52. </div>
  53. <div id="form-group-problem_id" class="form-group">
  54. <label for="input-problem_id" class="control-label mx-2"><?= UOJLocale::get('problems::problem id') ?>:</label>
  55. <input type="text" class="form-control input-sm" name="problem_id" id="input-problem_id" value="<?= $q_problem_id ?>" maxlength="4" style="width:4em" />
  56. </div>
  57. <div id="form-group-hacker" class="form-group">
  58. <label for="input-hacker" class="control-label mx-2"><?= UOJLocale::get('problems::hacker') ?>:</label>
  59. <input type="text" class="form-control input-sm" name="hacker" id="input-hacker" value="<?= $q_hacker ?>" maxlength="100" style="width:6em" />
  60. </div>
  61. <div id="form-group-owner" class="form-group">
  62. <label for="input-owner" class="control-label mx-2"><?= UOJLocale::get('problems::owner') ?>:</label>
  63. <input type="text" class="form-control input-sm" name="owner" id="input-owner" value="<?= $q_owner ?>" maxlength="100" style="width:6em" />
  64. </div>
  65. <div id="form-group-status" class="form-group">
  66. <label for="input-status" class="control-label mx-2"><?= UOJLocale::get('problems::result') ?>:</label>
  67. <select class="form-control input-sm" id="input-status" name="status" style="width:6em">
  68. <option value=""<?= $selected_all?>>All</option>
  69. <option value="1"<?= $selected_succ ?>>Success!</option>
  70. <option value="2"<?= $selected_fail ?>>Failed.</option>
  71. </select>
  72. </div>
  73. <button type="submit" id="submit-search" class="btn btn-secondary btn-sm ml-2"><?= UOJLocale::get('search') ?></button>
  74. </form>
  75. <script type="text/javascript">
  76. $('#form-search').submit(function(e) {
  77. e.preventDefault();
  78. url = '/hacks';
  79. qs = [];
  80. $(['submission_id', 'problem_id', 'hacker', 'owner', 'status']).each(function () {
  81. if ($('#input-' + this).val()) {
  82. qs.push(this + '=' + encodeURIComponent($('#input-' + this).val()));
  83. }
  84. });
  85. if (qs.length > 0) {
  86. url += '?' + qs.join('&');
  87. }
  88. location.href = url;
  89. });
  90. </script>
  91. <div class="top-buffer-sm"></div>
  92. </div>
  93. <?php
  94. echoHacksList($cond, 'order by id desc', array('judge_time_hidden' => ''), $myUser);
  95. ?>
  96. <?php echoUOJPageFooter() ?>