Ejemplo n.º 1
0
                             } else {
                                 $uploadErr = "File is not an image";
                             }
                         }
                     }
                 }
             }
         } else {
             trigger_error("Sorry cannot currently write to folder images");
             $success = "false";
         }
     }
 }
 //verifying the old password with the password saved in the database
 if (!$error && empty($uploadErr)) {
     $result2 = getAllMembers("users", ["email", "password"], ["email", "=", $myemail], 0, "AND", ["password", "=", $hashed_old_password]);
     if (count($result2) != 0) {
         if (!$error3) {
             $query_pass = "******";
             $result_pass = $connection1->query($query_pass);
         }
         if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
             //
             $picture_name = $name . $imageFileType;
             $success = "The file was successfully uploaded";
             $uploadOK = 1;
         } else {
             $success = "The file was not successfully uploaded.";
             $uploadOK = 0;
         }
         if ($picture_name != "") {
Ejemplo n.º 2
0
/**
 * Created by PhpStorm.
 * User: gabriel
 * Date: 1/26/16
 * Time: 11:00 AM
 */
include_once "session.php";
include_once 'connection.php';
require_once "function.php";
require_once "database.php";
if (isset($_POST["pin"]) && !empty($_POST["pin"])) {
    //collect pin
    $election_pin = $_POST['pin'];
    //get the election corresponding to the pin
    $election = getAllMembers("election", ["*"], ["election_pin", "=", $election_pin]);
    if (count($election) != 0) {
        $election = $election[0];
        //get openness
        $openness = substr($election["privacy"], 1, 1);
        //get user_id
        $user_id = user_id($myemail);
        //check if user is in anyway attached to the election
        if (concluded($election["election_end_date"], $election["election_time_to"], 0)) {
            echo 'This election has been concluded.';
        } elseif ($openness == 1 && concluded($election["election_start_date"], $election["election_time_from"], 0)) {
            echo 'Voting for this election has commenced.';
        } elseif ($openness == 1 && concluded($election["election_start_date"], $election["election_time_from"], 3600)) {
            echo 'Voting for this election will commence in less an hour.Therefore your request cannot be processed.';
        } elseif (attached("request", $user_id, $election["election_id"]) === "request") {
            echo 'You have already sent a request to the admin of this election.Just hold on till your request is granted.Thank you.';
Ejemplo n.º 3
0
//extract those that will start in at least an hour time and yet to start (2 step authentication which may not be necessary)
for ($i = 0; $i < $to_remind_num; $i++) {
    $start_date = $to_remind[$i]["election_start_date"];
    $start_time = $to_remind[$i]["election_time_from"];
    if (concluded($start_date, $start_time, 3600) && !concluded($start_date, $start_time, 0)) {
        //send reminder to the admin
        $admin_id = $to_remind[$i]["user_id"];
        $subject = "Remember to cast your vote in " . $to_remind[$i]["election_name"] . ".";
        $admin_details = getAllMembers("users", ["*"], ["user_id", "=", $admin_id])[0];
        $recipient_name = strtoupper($admin_details["fname"]) . " " . $admin_details["lname"];
        $body = "Hello " . $admin_details["username"] . ".<br>\n                This is to bring to your notice that the aforementioned election will commence in less than an hour from\n                the time this remainder was received by you. You are being reminded of this as regards to the fact that\n                you are the administrator of this election.<br><br>" . $main_body;
        $recipient_address = $admin_details["email"];
        sendEmail($recipient_address, $recipient_name, $subject, $body);
        //check if there is at least a voter in the election
        $id = $to_remind[$i]["election_id"];
        $has_voter = getAllMembers("joined", ["*"], ["election_id", "=", $id]);
        if (count($has_voter) > 0) {
            //get all the ready election into an array
            $remind_ready[$remind_ready_num] = $to_remind[$i];
            $remind_ready_num++;
        } else {
            //just set the reminder_sent to 1 and forget about the election
            $election_update_query = "UPDATE\n                                        election\n                                      SET\n                                        reminder_sent = 1\n                                      WHERE\n                                         election_id = :election_id";
            $update = $connection1->prepare($election_update_query);
            $update->bindParam(':election_id', $id);
            $update->execute();
        }
    }
}
//send reminder to those joined to each of $remind_ready
for ($j = 0; $j < count($remind_ready); $j++) {
Ejemplo n.º 4
0
     $user_id = $user_members[0]['user_id'];
     if ($request_members && in_array($user_id, $request_members)) {
         $request_count++;
     } elseif ($invite_members && in_array($user_id, $invite_members)) {
         $invite_count++;
     } elseif ($joined_members && in_array($user_id, $joined_members)) {
         $joined_count++;
     } else {
         $insert_query = "INSERT INTO invites (user_id, election_id) VALUES (:user_id, :election_id)";
         $smh = $connection1->prepare($insert_query);
         $smh->bindValue('user_id', $user_id);
         $smh->bindValue('election_id', $election_id);
         //execute the query and send notification
         if ($smh->execute()) {
             //get recipient
             $recipient = getAllMembers('users', ['*'], ['user_id', '=', $user_id])[0];
             $recipient_address = $recipient['email'];
             $recipient_name = strtoupper($recipient['fname']) . " " . $recipient['lname'];
             //generate mail body
             $mail_body = "Hello " . $recipient['username'] . ".<br>\r\n                                                This is to notify you that " . $sender_name . " has invited you to be a voter\r\n                                                in the election named " . $election_name . ". The acceptance of this invitation\r\n                                                makes you a valid voter in the election but if rejected, this invitation will\r\n                                                be removed from the list of your current invitations. Also note that this invitation\r\n                                                will be available for a specified period of time depending on the type of election\r\n                                                which " . $election_name . " is. To see more details about this invitation or respond to it,\r\n                                                <a href='http://evoting.oauife.edu.ng'>Login into your account</a> now.";
             sendEmail($recipient_address, $recipient_name, $mail_subject, $mail_body);
         }
     }
 } else {
     if (!in_array($email, $ignored_members)) {
         $insert_query = "INSERT INTO ignored (email, election_id) VALUES (:email, :election_id)";
         $smh = $connection1->prepare($insert_query);
         $smh->bindValue(':email', $email);
         $smh->bindValue('election_id', $election_id);
         //execute the query and send notification
         if ($smh->execute()) {
Ejemplo n.º 5
0
<?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";
}
Ejemplo n.º 6
0
 $lpassword = stripcslashes($_POST["lpassword"]);
 $lerror = false;
 if (empty($lemail) || empty($lpassword)) {
     $lmainError = "Invalid email or password. ";
     $lerror = true;
 } else {
     $mistake = ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'];
     if (in_array(ucwords($lemail), $mistake)) {
         $lhashedpassword = md5(ucwords($lpassword));
         $lemail = ucwords($lemail);
     } else {
         $lhashedpassword = md5($lpassword);
     }
 }
 if (!$lerror) {
     $result2 = getAllMembers("users", ["email", "status"], ["email", "=", $lemail], 0, "AND", ["password", "=", $lhashedpassword]);
     if (count($result2) > 0) {
         //check status
         $status = $result2[0]["status"];
         if ($status == 0) {
             $lmainError = "Sorry, you are yet to confirm your email. A confirmation<br> mail has already\n                                been sent to your mailbox.";
         } else {
             session_start();
             $_SESSION['login_user'] = $result2[0]["email"];
             $_SESSION['adek_link'] = '';
             $_SESSION['adek_status'] = '';
             header('Location:maindashboard.php');
         }
     } else {
         $lmainError = "Invalid email or password.";
     }
<?php

include_once "../php/connection.php";
include_once '../php/photo.php';
include_once '../php/post_news.php';
include_once '../php/view_contestant.php';
include_once "../php/vote.php";
include_once "../php/database.php";
//check if election exists
$election_id = $_SESSION["election_id"];
$user_id = user_id($myemail);
$election = getElectionDetails($election_id);
$joined = getAllMembers("joined", ["*"], ["user_id", "=", $user_id], 0, "AND", ["election_id", "=", $election_id]);
if (count($election) == 0 | count($joined) == 0) {
    //that means the election does not exist or the user is not joined to the election
    header("Location:maindashboard.php");
}
// check if contestant or voter
$adekagun = "Voter";
if (attached("contestants", user_id($myemail), $_SESSION["election_id"]) === "contestants") {
    $adekagun = 'Contestant';
}
$_SESSION['adek_link'] = 'election_detailsNews.php?key=' . $_SESSION['election_key'];
$_SESSION['adek_status'] = $adekagun;
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">

<head>
    <style type="text/css">
Ejemplo n.º 8
0
 * Date: 2/17/16
 * Time: 3:01 PM
 */
//include('session.php');
include '../php/connection.php';
include_once '../php/session.php';
include_once '../php/function.php';
include_once '../php/database.php';
$name_of_electionErr = $start_date_of_electionErr = $new_post_Err = $end_date_of_electionErr = $time_of_election_fromErr = $time_of_election_toErr = $messaging = $message2 = $post1 = $pin1 = $status_string = "";
$name_of_election = $name_of_election_temp = $start_date_of_election = $start_date_of_election1 = $end_date_of_election = $end_date_of_election1 = $time_of_election_from = $time_of_election_to = $election_pin = $result_display = "";
$dummy1 = $dummy2 = $dummy3 = $dummy4 = "";
$election_id = unwrap($_SESSION['election_id']);
$this_election = getAllMembers("election", ["*"], ["election_id", "=", $election_id])[0];
//get all post and there corresponding pin
$old_posts = array();
$post_pin = getAllMembers("posts", ["post_id,post_key,post"], ["election_id", "=", $election_id]);
$post_string = '<div class="" style="text-align:left"><b>Post(s)</b><br>';
$pin_string = '<div class="" style="text-align:left"><b>Pin(s)</b><br>';
for ($i = 0; $i < count($post_pin); $i++) {
    array_push($old_posts, ucwords($post_pin[$i]["post"]));
    $post_id = $post_pin[$i]["post_id"];
    $post_string .= $post_pin[$i]["post"] . '<br>';
    $pin_string .= $post_pin[$i]["post_key"] . '<br>';
}
$post_string .= '</div>';
$pin_string .= '</div>';
//get current date and current time
$now_date = convert_date(date("Y-m-d"));
$now_time = convert_date(date("H:i:s"));
//check if election has not started
if (concluded($this_election["election_end_date"], $this_election["election_time_to"], 0)) {
Ejemplo n.º 9
0
    $date1 = getDateInterval($date_time1[0]);
    $time1 = timeString($date_time1[1]);
    $view_posted_news .= "<div class='me' style='margin-bottom:10px; ' >" . "<br>\n                <label style='overflow:hidden;text-overflow:ellipsis;'>" . $row[$i]['news'] . "</label>\n                <br>" . $date1 . "&nbsp" . $time1 . "<br></div>";
}
//querying for election name
$election_name = $election_details_test = "";
$row = getElectionDetails($election_id)[0];
$election_name .= $row['election_name'];
$_SESSION['election_name'] = $election_name;
$election_details_test .= "<label>Start Date:</label> " . dateString($row['election_start_date']) . "<br>\n        <label>Start Time:</label> " . timeString($row['election_time_from']) . "<br><label>End Date:</label> &nbsp" . dateString($row['election_end_date']) . "<br><label>End Time:</label> " . timeString($row['election_time_to']) . "<br>\n        <label>Number of Voters: </label> " . count(getAllMembers("joined", ['election_id'], ['election_id', '=', $election_id])) . "<br><label>Number of Contestants: </label> " . count(getAllMembers("contestants", ['contestant_id'], ['election_id', '=', $election_id]));
//getting the user_id for a particular election
$election_admin_details = $election_admin_detail = "";
$images_dir = "../images/users/";
$user_id_result = $row["user_id"];
//querying to get the admin email
$row = getAllMembers("users", ["*"], ["user_id", "=", $user_id_result])[0];
$election_admin_details .= "<div class='col-md-6'><label>Name:</label> " . $row['lname'] . "&nbsp" . $row['fname'] . "\n        <br><label>Username:</label> " . $row['username'] . "<br><label>Email:</label> " . $row['email'] . "<br>\n        <label>Telephone:</label> " . $row['phone'] . "</div>";
$election_admin_detail .= "<div class='col-md-4'><img src=" . $images_dir . $row['picture_name'] . " width='120px'\n        height='auto' style='border-radius:100%;max-height:200px;' class='preview' id='displayedPhoto'></div>";
//checking for the link vote
$hasvoted = hasvoted(user_id($myemail), $election_id);
//determining when to make the view profile link visible or not'
$checkContestant1 = checkContestant(user_id($myemail), $election_id);
if (!empty($checkContestant1)) {
    $profile1 = "<a href='viewprofile.php' class='active'>View Profile</a>";
} else {
    $profile1 = "";
}
//get post table
$all_posts = getAllPosts($election_id);
$total_contestants = 0;
$posts_table = '<div class="table-responsive contestants_table" style="max-height: 220px">
Ejemplo n.º 10
0
function printAllMembersDatalist()
{
    $allMembers = getAllMembers();
    printMemberDatalist($allMembers);
}
Ejemplo n.º 11
0
$end_year = $part2[0];
$end_month = $part2[1];
$end_day = $part2[2];
$part3 = explode(':', $election_time_to);
$end_hour = $part3[0];
$end_minute = $part3[1];
//getting the election duration
$election_end1 = $election_end_date . " " . $election_time_to;
$election_end = strtotime($election_end1);
$electionStartDateTemp = $election_start_date . " " . $election_time_from;
$electionStartDate = convert_date($electionStartDateTemp);
//}
$string_election = "";
//get number of registered and voted voters
$number_registered = count(getAllMembers('joined', ['joined_id'], ['election_id', '=', $election_id]));
$number_voted = count(getAllMembers('joined', ['joined_id'], ['election_id', '=', $election_id], 0, 'AND', ['has_voted', '=', 1]));
//$string_election.="<div class='col-md-6'><label>Election Start Date:</label> ".dateString($election_start_date)."</div> <div class='col-md-6'><label>Start time: </label> ".timeString($election_time_from)."</div><div class='col-md-6'> <label>Election End Date: </label>".
//dateString($election_end_date)."</div> <div class='col-md-6'><label>End time: </label> ".timeString($election_time_to).'</div>';
$string_election .= "<div class='col-md-6'><label>Number of registered voter(s):</label> " . $number_registered . "</div> <div class='col-md-6'><label>Election End Date: </label> " . dateString($election_end_date) . "</div><div class='col-md-6'> <label>Those that have voted: </label>" . $number_voted . "</div> <div class='col-md-6'><label>End time: </label> " . timeString($election_time_to) . '</div>';
$string = "";
//get all posts for this election
$allPosts = getAllPosts($election_id);
//for each post,get all contestants
$postCon = $display = $string_array = $string_result_array = [];
//let superIndex retain 1D array of all post
$superIndex = [];
$image_dir = "../images/contestants/";
for ($i = 0; $i < count($allPosts); $i++) {
    //let the post by the key to all contestant array in postCon array
    $postCon[$allPosts[$i]['post']] = getAllContestants($allPosts[$i]['post_id']);
    //push each post to the superIndex
Ejemplo n.º 12
0
<?php

require_once "includes/head.php";
$rows1 = getAllMembers(1);
$rows2 = getAllMembers(2);
$rows3 = getAllMembers(3);
$rows4 = getAllMembers(1, 0);
?>

<!-- member list page -->
<div id="member_list" data-role='page' data-title='member_list'>
	
	<div data-role='header' data-position='fixed' data-tap-toggle="false">
			<h2>成员列表</h2>
		<a href="doAction.php?act=logout"
			rel='external'
			data-icon='power'
			data-iconpos='notext'
			data-direction='reverse'
			class='ui-btn-left'
			data-transition="none" >
		退出</a>
		<a href="do_member_info.php"
			rel='external'
			data-icon='plus'
			data-iconpos='notext'
			data-direction='reverse'
			class='ui-btn-right'
			data-transition="none" >
		添加新成员</a>
	</div>
<?php

include "Crest.php";
$auth_code = $_GET["access_token"];
$name = $_GET["name"];
$id = 92439100;
$name2 = str_replace(" ", "+", $name);
$name2 = getID($name2);
//print_r(getAllAllianceMembers((INT) $name2["ownerID"]));
addMembers($auth_code, $id, getAllMembers((int) $name2["ownerID"], (int) $name2["ownerGroupID"], $name));
//echo "FINISHED!";
function getAllMembers($corpID, $isCorp, $name)
{
    if ($isCorp == 2) {
        return getAllCorpMembers($corpID);
    } else {
        if ($isCorp == 32) {
            return getAllAllianceMembers($corpID);
        } else {
            if ($isCorp == 1) {
                $pilot[0] = new stdClass();
                $pilot[0]->name = $name;
                $pilot[0]->character_id = $corpID;
                return $pilot;
            } else {
                echo "No Char or Corp or Alliance with this name exists, please check spelling.";
            }
        }
    }
}
function addMembers($auth_code, $id, $pilots)
Ejemplo n.º 14
0
                 }
                 $user_id = user_id($myemail);
                 //get admin details for mail sending
                 $administrator = getAllMembers('users', ['*'], ['user_id', '=', $user_id])[0];
                 $sender_name = strtoupper($administrator['fname']) . " " . $administrator['lname'];
                 //keep the sender_name and election_name for the ignored guys
                 $_SESSION['sender_name'] = $sender_name;
                 $_SESSION['election_name'] = $election_name;
                 foreach ($valid_voters_id as $voter) {
                     if ($voter['user_id'] != $user_id) {
                         $insertQuery = "INSERT INTO invites (user_id, election_id) VALUES (:user_id, :election_id)";
                         $smh = $connection1->prepare($insertQuery);
                         //lets forward the invite to the invitee and also send notification to the invitee
                         if ($smh->execute($voter)) {
                             //forward the mail. start by getting sender and receiver first
                             $recipient = getAllMembers('users', ['*'], ['user_id', '=', $voter['user_id']])[0];
                             $recipient_name = strtoupper($recipient['fname']) . " " . $recipient['lname'];
                             $mail_subject = "Invitation to join an election - " . $election_name;
                             $mail_body = "Hello " . $recipient['username'] . ".<br>\n                                                This is to notify you that " . $sender_name . " has invited you to be a voter\n                                                in the election named <bold>" . $election_name . "</bold>. The acceptance of this invitation\n                                                makes you a valid voter in the election but if rejected, this invitation will\n                                                be removed from the list of your current invitations. Also note that this invitation\n                                                will be available for a specified period of time depending on the type of election\n                                                which " . $election_name . " is. To see more details about this invitation or respond to it,\n                                                <a href='evoting.oauife.edu.ng'>Login into your account</a> now.";
                             sendEmail($recipient['email'], $recipient_name, $mail_subject, $mail_body);
                         }
                     }
                 }
             }
         } else {
             @unlink($target);
         }
     }
 } else {
     $message = "Election name already exists.";
 }
if (count($election_details) === 0) {
    header("Location:maindashboard.php");
} else {
    //check if the user truly received an invite from the election
    $query = "SELECT\n            users.user_id, invites.invite_id\n          FROM\n            users\n          LEFT JOIN\n            invites\n          ON\n            users.user_id = invites.user_id\n          WHERE\n            users.email = '{$myemail}'\n          AND\n            invites.election_id = '{$election_id}'\n          ";
    $check_invite = $connection1->prepare($query);
    $check_invite->execute();
    $check_invite->setFetchMode(PDO::FETCH_ASSOC);
    $is_invite = $check_invite->fetchAll();
    if (count($is_invite) == 0) {
        header("Location:maindashboard.php");
    } else {
        //get all admin details
        $_SESSION["election_index"] = $election_details["election_id"];
        $admin_id = $election_details["user_id"];
        $admin_details = getAllMembers("users", ["*"], ["user_id", "=", $admin_id])[0];
        $images_dir = "../images/users/";
        $election_admin_detail = "";
        $election_admin_detail .= "<div class='dem1'><img src=" . $images_dir . $admin_details["picture_name"] . " id='displayedPhoto'></div>";
    }
}
//check if either accept or decline button has been clicked
if (isset($_POST["accept"]) || isset($_POST["decline"])) {
    $election_id = $_SESSION["election_index"];
    //get user_id
    $user_id = user_id($myemail);
    //delete from invite table
    $delete_query = "DELETE FROM invites WHERE user_id='{$user_id}' AND election_id='{$election_id}'";
    $connection1->query($delete_query);
    if (isset($_POST["accept"])) {
        //add user to the election