<?php require 'requests/mods.php'; require 'requests/chat.php'; $mods = new Mods(); if (!(isset($_SESSION['user_id']) && isset($_SESSION['user_type']))) { $mods->sendStatus($mods->getError(1), 'admin.php'); } else { if ($_SESSION['user_type'] == 'Voter') { $mods->sendStatus($mods->getError(7), 'index.php'); } } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>UE College of Law Election System</title> <link rel="stylesheet" href="assets/css/font-awesome.min.css"> <link rel="stylesheet" href="assets/css/stylesheet.css"> <script src="assets/js/jquery.min.js"></script> <script src="assets/js/dashboard.js"></script> </head> <body id="main-body"> <div id="main-block" class="shadow"> <div id="header">UE College of Law Election <?php echo date('Y'); ?> </div> <div id="content">
</form> </div> <div id="container"> </div> </div> <div id="footer">© Copyright <?php echo date('Y'); ?> UE-CCSS Research & Development Unit 2013</div> </div> <div class="special"> <?php if (isset($_POST['status'])) { $status = $_POST['status']; switch ($status) { case $mods->getError(0): $mods->showDialog('prompt', 'Login Status', 'You may now start voting.', 'precinct.php'); break; case $mods->getError(1): $mods->showDialog('prompt', 'Login Status', 'You\'re not logged in or session has expired. Please login to continue.'); break; case $mods->getError(2): $mods->showDialog('prompt', 'Login Status', 'Voter not found.'); break; case $mods->getError(3): $mods->showDialog('prompt', 'Login Status', 'Voter not registered.'); break; case $mods->getError(4): $mods->showDialog('prompt', 'System Error', 'Voter has already voted.'); break; case $mods->getError(5):
echo 'Voter not registered.'; } else { if ($row['Status'] == 1) { $ctr = 0; foreach ($_POST['votes'] as $vote) { if ($vote != '') { $mods->setQuery("INSERT INTO votes (Voter_ID, Candidate_ID) VALUES ('{$sessionID}', '{$vote}')"); if ($mods->getCount() > 0) { $ctr++; } } } if ($ctr > 0) { $mods->setQuery("UPDATE voters SET Status=2 WHERE Voter_ID='{$sessionID}'"); if ($mods->getCount() == 1) { $mods->sendStatus('20c1e9da750353cf0cba49283c17f8a7', '../index.php', 'output'); } } else { $mods->sendStatus($mods->getError(5), '../index.php'); } } else { if ($row['Status'] == 2) { echo 'Voter already voted.'; } else { echo 'Oops! There\'s something wrong with the voter\'s information.'; } } } } } $mods->stopConnection();
<?php require 'mods.php'; require 'election.php'; $mods = new Mods(); $mods->startConnection(); $action = $mods->escapeString($_POST['action']); if ($action == $mods->getAction(1)) { $studentNumber = $mods->escapeString($_POST['studentNumber']); $mods->setQuery("SELECT * FROM voters WHERE Voter_ID='{$studentNumber}'"); if ($mods->getCount() == 1) { $row = $mods->getResults('array'); if ($row['Status'] == 1) { $mods->login($studentNumber, 'Voter'); $mods->sendStatus($mods->getError(0), '../index.php'); } else { if ($row['Status'] == 0) { $mods->sendStatus($mods->getError(3), '../index.php'); } else { if ($row['Status'] == 2) { $mods->sendStatus($mods->getError(4), '../index.php'); } } } } else { $mods->sendStatus($mods->getError(2), '../index.php'); } } else { if ($action == $mods->getAction(2)) { $username = $mods->escapeString($_POST['username']); $password = $mods->escapeString($_POST['password']);
</form> </div> <div id="container"> </div> </div> <div id="footer">© Copyright <?php echo date('Y'); ?> UE-CCSS Research & Development Unit 2013</div> </div> <div class="special"> <?php if (isset($_POST['status'])) { $status = $_POST['status']; switch ($status) { case $mods->getError(0): $mods->showDialog('prompt', 'Login Status', 'You will now be redirected to the Dashboard.', 'dashboard.php'); break; case $mods->getError(1): $mods->showDialog('prompt', 'Login Status', 'You\'re not logged in or session has expired. Please login to continue.'); break; case $mods->getError(6): $mods->showDialog('prompt', 'Login Status', 'Account doesn\'t exist.'); break; default: break; } } else { $mods->logout(); } ?>