<?php

session_start();
include '../config/config.php';
$dbObj = new Database($cfg);
//Instantiate database
$thisPage = new WebPage($dbObj);
//Create new instance of webPage class
$entrantObj = new Entrant($dbObj);
// Create an object of Entrant class
$errorArr = array();
//Array of error
if (!isset($_SESSION['SWPLoggedInAdmin']) || !isset($_SESSION["SWPadminEmail"])) {
    $json = array("status" => 0, "msg" => "You are not logged in.");
    header('Content-type: application/json');
    echo json_encode($json);
} else {
    if (filter_input(INPUT_GET, "fetchEntrants") != NULL) {
        $requestData = $_REQUEST;
        $columns = array(0 => 'id', 1 => 'id', 2 => 'id', 3 => 'contest', 4 => 'email', 5 => 'friends', 6 => 'names', 7 => 'time_entered', 8 => 'point');
        // getting total number records without any search
        $query = $dbObj->query("SELECT * FROM " . $entrantObj::$tableName);
        $totalData = mysqli_num_rows($query);
        $totalFiltered = $totalData;
        // when there is no search parameter then total number rows = total number filtered rows.
        $sql = "SELECT * FROM " . $entrantObj::$tableName . " WHERE 1=1 ";
        if (!empty($requestData['search']['value'])) {
            // if there is a search parameter, $requestData['search']['value'] contains search parameter
            $sql .= " AND ( email LIKE '%" . $requestData['search']['value'] . "%' ";
            $sql .= " OR contest = '" . Contest::getSingle($dbObj, 'id', $requestData['search']['value']) . "' ) ";
        }
Example #2
0
<?php

session_start();
include 'config/config.php';
require 'swiftmailer/lib/swift_required.php';
$dbObj = new Database($cfg);
//Instantiate database
$thisPage = new WebPage($dbObj, 'webpage');
//Create new instance of webPage class
$contestObj = new Contest($dbObj);
$entrantObj = new Entrant($dbObj);
$errorArr = array();
//get the contest id; if failed redirect to contest-home page
$thisContestId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT) ? filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT) : $thisPage->redirectTo(SITE_URL);
if (count($contestObj->fetchRaw("*", " id = {$thisContestId} AND status = 1 ")) < 1) {
    $thisPage->redirectTo(SITE_URL);
}
foreach ($contestObj->fetchRaw("*", " id = {$thisContestId} ") as $contest) {
    $contestData = array('status' => 'status', 'id' => 'id', 'title' => 'title', 'intro' => 'intro', 'description' => 'description', 'header' => 'header', 'logo' => 'logo', 'startDate' => 'start_date', 'endDate' => 'end_date', 'announcementDate' => 'announcement_date', 'winners' => 'winners', 'question' => 'question', 'answer' => 'answer', 'point' => 'point', 'bonusPoint' => 'bonus_point', 'rules' => 'rules', 'prize' => 'prize', 'message' => 'message', 'css' => 'css', 'dateAdded' => 'date_added', 'announceWinner' => 'announce_winner', 'restart' => 'restart', 'restartInterval' => 'restart_interval', 'cutOffPoint' => 'cut_off_point', 'theme' => 'theme');
    foreach ($contestData as $key => $value) {
        switch ($key) {
            case 'header':
                $contestObj->{$key} = MEDIA_FILES_PATH1 . 'contest-header/' . $contest[$value];
                break;
            case 'logo':
                $contestObj->{$key} = MEDIA_FILES_PATH1 . 'contest-logo/' . $contest[$value];
                break;
            default:
                $contestObj->{$key} = $contest[$value];
                break;
        }
Example #3
0
 public function Entrant($dbObj = null, $tableName = 'entrant')
 {
     self::$dbObj = $dbObj;
     self::$tableName = $tableName;
 }
Example #4
0
 /**
  * getWinners gets all winners of the contest 
  * @return string List of winners or error message
  */
 public function getWinners()
 {
     $d1 = new DateTime(date('j F Y H:i'));
     $d2 = new DateTime(str_replace(" - ", " ", $this->endDate));
     if ($d1 >= $d2) {
         if ($this->announceWinner == "Yes") {
             return Entrant::getWinners($this->id, $this->cutOffPoint, $this->winners);
         } else {
             if ($this->announceWinner == "No") {
                 $dd1 = new DateTime(date('j F Y H:i'));
                 $dd2 = new DateTime(str_replace(" - ", " ", $this->announcementDate));
                 if ($dd1 >= $dd2) {
                     return Entrant::getWinners($this->id, $this->cutOffPoint, $this->winners);
                 } else {
                     return "<em style='color:red;font-weight:bold;'>Winners are yet to be announced!</em> <p>Please check back. Winner announcement date is {$this->announcementDate} </p>";
                 }
             }
         }
     } else {
         return "<p>The contest/sweepstakes is still ongoing please check back. This contest will end on <strong>" . str_replace("-", "at", $this->endDate) . "</strong></p>";
     }
 }