<?php

session_start();
include '../config/config.php';
$dbObj = new Database($cfg);
//Instantiate database
$thisPage = new WebPage($dbObj);
//Create new instance of webPage class
$contestObj = new Contest($dbObj);
// Create an object of Contest class
$errorArr = array();
//Array of errors
//get the contest id; if failed redirect to contest-categories page
$thisContestId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT) ? filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT) : $thisPage->redirectTo('manage-contests');
//Check if the contest exists if not redirect it to manage-contests page
if (count($contestObj->fetchRaw("*", " id = {$thisContestId} ")) < 1) {
    $thisPage->redirectTo('manage-contests');
}
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) {
            default:
                $contestObj->{$key} = $contest[$value];
                break;
        }
    }
}
$cfg->templateName = $contestObj->theme ? $contestObj->theme : 'default';
?>
<!DOCTYPE html>
Example #2
0
    <!-- Page Content -->
    <div class="container">

        <!-- Jumbotron Header -->
        <header class="jumbotron hero-spacer panel panel-default">
            <h1>A Warm Welcome!</h1>
            <p>Below is/are the available sweepstakes or contest(s) </p>
        </header>

        <hr>

        <!-- Page Features -->
        <div class="row text-center">
            <?php 
foreach ($contestObj->fetchRaw("*", " status= 1 ", " id DESC") 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;
        }
    }
    ?>