Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

index.php 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. include('inc/inc.php');
  3. if (!$user->loggedin()) {
  4. header('Location: /login.php');
  5. die();
  6. }
  7. if (!$user->voterId()) {
  8. header('Location: /login.php?denied');
  9. die();
  10. }
  11. $header = new Header("2022 Michigan Flyers Election");
  12. $header->addStyle("/styles/style.css");
  13. $header->addScript("/js/jquery-1.11.3.min.js");
  14. $header->addScript("/js/search.js");
  15. $header->setAttribute('title', 'Michigan Flyers');
  16. $header->setAttribute('tagline', '2022 Online Ballot');
  17. $header->output();
  18. $candidates = $db->fetchAssoc('select skymanager_id, name, username, md5(coalesce(email, "")) as `gravatar_hash` from members where voting_id is not null');
  19. $votes = $db->fetchAssoc("select position from votes where member_id={$user->voterId()}");
  20. foreach ($votes as &$vote) {
  21. $vote = $vote['position'];
  22. }
  23. unset($vote);
  24. $vicepresident_voted = in_array("VICEPRESIDENT", $votes);
  25. $secretary_voted = in_array("SECRETARY", $votes);
  26. $director_voted = in_array("DIRECTOR", $votes);
  27. $vicepresident_disabled = $vicepresident_voted;
  28. $secretary_disabled = $secretary_voted || !$vicepresident_voted;
  29. $director_disabled = $director_voted || !$secretary_voted || !$vicepresident_voted;
  30. $vicepresident_disabled_reason = $vicepresident_voted ? "You have already voted for Vice President." : "";
  31. $secretary_disabled_reason = $secretary_disabled ? ($secretary_voted ? "You have already voted for Secretary." : "You must vote for Vice President first.") : "";
  32. $director_disabled_reason = $director_disabled ? ($director_voted ? "You have already voted for Director." : "You must vote for Vice President and Secretary first.") : "";
  33. ?>
  34. <script type="text/javascript">
  35. var candidates = <?= json_encode($candidates); ?>;
  36. </script>
  37. <form action="vote.php" method="POST">
  38. <div class="form-row">
  39. <div class="selector">
  40. <label class="radio">
  41. <input type="radio" id="vote-vicepresident" name="ballot"
  42. value="VICEPRESIDENT" <?= $vicepresident_disabled ? "disabled" : "checked"; ?> />
  43. <span class="radio-button-label">Vice President</span>
  44. <?php if ($vicepresident_disabled_reason): ?>
  45. <div class="hover-tooltip"><?= $vicepresident_disabled_reason; ?></div>
  46. <?php endif; ?>
  47. </label>
  48. <label class="radio">
  49. <input type="radio" id="vote-director" name="ballot"
  50. value="SECRETARY" <?= $secretary_disabled ? "disabled" : ($vicepresident_disabled ? "checked" : ""); ?> />
  51. <span class="radio-button-label">Secretary</span>
  52. <?php if ($secretary_disabled_reason): ?>
  53. <div class="hover-tooltip"><?= $secretary_disabled_reason; ?></div>
  54. <?php endif; ?>
  55. </label>
  56. <label class="radio">
  57. <input type="radio" id="vote-director" name="ballot"
  58. value="DIRECTOR" <?= $director_disabled ? "disabled" : ($vicepresident_disabled && $secretary_disabled ? "checked" : ""); ?> />
  59. <span class="radio-button-label">Director-At-Large</span>
  60. <?php if ($director_disabled_reason): ?>
  61. <div class="hover-tooltip"><?= $director_disabled_reason; ?></div>
  62. <?php endif; ?>
  63. </label>
  64. </div>
  65. </div>
  66. <div class="form-row">
  67. <input type="text" placeholder="Candidate Search" id="searchbox" name="searchbox" value="" />
  68. <div id="results"></div>
  69. <input type="hidden" name="candidate" id="candidate-input" value="0" />
  70. <div id="selectedCandidate" class="selected candidate">
  71. <span class="placeholder">No Candidate Selected</span>
  72. </div>
  73. </div>
  74. <div class="form-row">
  75. <input class="submit" type="submit" name="submit" value="Submit Ballot" />
  76. </div>
  77. </form>
  78. <?php
  79. $footer = new Footer();
  80. $footer->output();