$invite_string .= "</tbody></table>"; $invites_adek = true; } } //get all request $request_displayed = "You currently have no pending request."; $all_requests = $connection1->query("SELECT election_id,request_date FROM request WHERE user_id='{$user_id}'"); $all_requests->setFetchMode(PDO::FETCH_ASSOC); $all_requests = $all_requests->fetchAll(); $has_request = array(); $requests_count = 0; $requests_adek = false; //for each request,check if the election is yet to start if (count($all_requests) > 0) { for ($i = 0; $i < count($all_requests); $i++) { $election = getElectionDetails($all_requests[$i]["election_id"])[0]; if (!concluded($election["election_start_date"], $election["election_time_from"], 0)) { //get useful details $has_request[$requests_count] = array("election_pin" => $election["election_pin"], "admin_email" => email($election["user_id"]), "request_date" => dateString(explode(" ", $all_requests[$i]["request_date"])[0]), "request_time" => timeString(explode(" ", $all_requests[$i]["request_date"])[1])); $requests_count++; } } //generate display if (count($has_request) > 0) { $request_displayed = "<table id='table_5' class='table table-striped table-bordered' cellspacing='0'>\n <thead class='default'>\n <tr>\n <th>Election Pin</th>\n <th>Admin Address</th>\n <th>Request Date</th>\n <th>Request Time</th>\n <th></th>\n </tr>\n </thead>\n <tbody>"; for ($i = 0; $i < count($has_request); $i++) { $request_displayed .= "<tr>"; $request_displayed .= "<td>" . $has_request[$i]["election_pin"] . "</td>\n <td>" . $has_request[$i]["admin_email"] . "</td>\n <td>" . $has_request[$i]["request_date"] . "</td>\n <td> " . $has_request[$i]["request_time"] . "</td>\n <td class='text-danger'>pending</td>"; $request_displayed .= "</tr>"; } $request_displayed .= "</tbody></table>";
$body = "Hello " . $username . ".<br>\n You are welcome to Obafemi Awolowo University online voting system.<br>\n This is to notify you that your email address has been used to create an\n account with us. Kindly ignore this mail if your account was used without your consent.\n If not, click on <a href='http://evoting.oauife.edu.ng/html?confirm_me=" . $coded . "'>Activate account.</a>\n to activate your account.Thank you."; // $mail->AltBody = ""; if (SendEmail($email, $recipient_name, $subject, $body)) { $sql = "INSERT INTO users(fname, lname, username, email, phone, password, gender)\n VALUES('" . ucwords($fname) . "', '" . ucwords($lname) . "', '" . $username . "', '" . $email . "', '" . $phone . "', '" . $hashedpassword . "','" . $sex . "')"; if ($connection1->query($sql)) { //Invite the signed up user for an election he has been invited $output = "<span style='color: #008000'>Account created successfully. Check Your email For verification.</span>"; $electionId = $election_start = $election_time = $invite_message = ""; $invite_query = $connection1->prepare("SELECT * FROM ignored WHERE email='{$email}'"); $invite_query->execute(); $invite_result = $invite_query->setFetchMode(PDO::FETCH_ASSOC); $invite_result = $invite_query->fetchAll(); if (!empty($invite_result)) { for ($i = 0; $i < count($invite_result); $i++) { $electionId = $invite_result[$i]['election_id']; $electionDetails = getElectionDetails($electionId); $election_start = $electionDetails[0]['election_start_date']; $election_time = $electionDetails[0]['election_time_from']; $invite_date = $invite_result[$i]["ignored_date"]; if (!concluded($election_start, $election_time, 7200)) { $insertQuery = "INSERT INTO invites (user_id, election_id, invite_date) VALUES ('{$last_id}', '{$electionId}', '{$invite_date}')"; if ($connection1->query($insertQuery)) { $deleteQuery = "DELETE FROM ignored WHERE email='{$email}' AND election_id='{$electionId}'"; $connection1->query($deleteQuery); } } } } // header("Location:../html/index.php?key=".$output); $fname = $lname = $email = $username = $phone = $password1 = $password2 = $sex = ""; } else {
<?php //get user_id and election_id require_once "function.php"; include_once 'connection.php'; include_once 'database.php'; $id = $_POST["id"]; $id = explode(" ", $id)[1]; $sender_id = explode("_", $id)[0]; $election_id = explode("_", $id)[1]; //check if voting has not started $election = getElectionDetails($election_id)[0]; $starting_date = $election["election_start_date"]; $starting_time = $election["election_time_from"]; if (!concluded($starting_date, $starting_time, 0) && isset($_POST)) { //get needed election details in case you need to send mail $admin_query = "SELECT\n election.election_name,users.fname AS admin_fname,users.lname AS admin_lname\n FROM\n election\n LEFT JOIN\n users\n ON\n election.user_id = users.user_id\n WHERE\n election_id = {$election_id}"; $admin = $connection1->prepare($admin_query); $admin->execute(); $admin->setFetchMode(PDO::FETCH_ASSOC); $admin = $admin->fetchAll()[0]; $election_name = $admin['election_name']; $sender_name = strtoupper($admin['admin_fname']) . " " . $admin['admin_lname']; //get recipient $recipient = getAllMembers('users', ['*'], ['user_id', '=', $sender_id])[0]; $recipient_address = $recipient['email']; $recipient_name = strtoupper($recipient['fname']) . " " . $recipient['lname']; $mail_subject = "Your request to join " . $election_name . " has been "; //delete request $delete_request_query = "DELETE FROM request WHERE user_id='{$sender_id}' AND election_id='{$election_id}'"; if ($connection1->query($delete_request_query)) {
<?php include 'connection.php'; include_once 'database.php'; include_once 'function.php'; //echo base64_decode("Ni"); //function subme($a, $b) //{ // return $a-$b; //} $election = getElectionDetails(1)[0]; if (concluded($election["election_end_date"], $election["election_time_to"], 0) && $election["result_mail_sent"] == 0) { //make all variable declaration $all_member = $members = $participants = []; //all member needs to be mailed $all_member = getAllMembers("joined", ["user_id"], ["election_id", "=", $election["election_id"]]); //add admin to member array_push($all_member, ["user_id" => $election["user_id"]]); //reduce the array to a one dimensional array for ($head = 0; $head < count($all_member); $head++) { array_push($members, $all_member[$head]["user_id"]); } //shuffle array for the case when the admin is also a voter $participants = array_unique($members); print_r($participants); // echo("concluded"); } else { echo "on point"; }
<?php include_once '../php/connection.php'; include_once '../php/session.php'; include_once '../php/database.php'; include_once '../php/function.php'; $election_id = $_SESSION['election_id_view']; //fetching the election details $election_name = $election_start_date = $election_end_date = $election_time_from = $election_time_to = $string_election = ""; $result_tag1 = $result_tag2 = $result_display = ""; $election_details1 = getElectionDetails($election_id); //for($j=0;$j<count($election_details1);$j++){ $election_name = $election_details1[0]['election_name']; $election_start_date = $election_details1[0]['election_start_date']; $election_end_date = $election_details1[0]['election_end_date']; $election_time_from = $election_details1[0]['election_time_from']; $election_time_to = $election_details1[0]['election_time_to']; $result_display = $election_details1[0]['result_display']; $election_date = strtotime($election_start_date . " " . $election_time_from); $parts = explode('-', $election_start_date); $start_year = $parts[0]; $start_month = $parts[1]; $start_day = $parts[2]; $part1 = explode(':', $election_time_from); $start_hour = $part1[0]; $start_minute = $part1[1]; $part2 = explode('-', $election_end_date); $end_year = $part2[0]; $end_month = $part2[1]; $end_day = $part2[2]; $part3 = explode(':', $election_time_to);