include_once("_inc/config.inc.php");
include_once("_inc/init.inc.php");
// Variables Initialization
$content_template = TEMPLATE_PATH."content_".$page_section.".tpl.php";
$page_template = TEMPLATE_PATH."page_".$page_section.".tpl.php";
$terms_source = 'terms_registration.tpl.php';
$section = array();
$var = array();
// URL Validation
if(!file_exists($content_template)) {
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
include_once(TEMPLATE_PATH."404.php");
exit();
}
// Set Page Base Temaplate If Not Defined
if(!file_exists($page_template)) {
$page_template = TEMPLATE_PATH."page_index.tpl.php";
}
// Set OG Information If Not Defined
if(!$page_config['FB_OG'][$page_section]) {
$page_config['FB_OG'][$page_section] = $page_config['FB_OG']['index'];
}
// Set Section Template
$section[$page_section] = array(
'template' => $content_template,
);
// Set Section Variables
$section[$page_section]['var'] = array(
'owner' => $companyName,
);
if ($page_section == 'photosharing') {
$total_vote = getTotalVoteCount();
$current_page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$users = getUserData();
$no_of_user = sizeof($users);
$total_pages = ceil($no_of_user / $user_per_page);
if ($current_page != 1 && ($current_page > $total_pages || $current_page < 1)) {
header('Location: ../1/');
exit();
}
$section[$page_section]['var']['users'] = $users;
$section[$page_section]['var']['total_user'] = $no_of_user;
$section[$page_section]['var']['total_pages'] = $total_pages;
$section[$page_section]['var']['user_per_page'] = $user_per_page;
$section[$page_section]['var']['page_prev'] = ($current_page-1 > 0) ? $current_page-1 : 1;
$section[$page_section]['var']['next_prev'] = ($current_page+1 < $total_pages) ? $current_page+1 : $total_pages;
$section[$page_section]['var']['page'] = $current_page;
$section[$page_section]['var']['user_start'] = ($current_page-1)*$user_per_page;
$section[$page_section]['var']['user_end'] = ($current_page < $total_pages) ? $section[$page_section]['var']['user_start']+$user_per_page-1 : $no_of_user-1;
}
if ($page_section == 'result') {
$section[$page_section]['var']['FirstPrizeList'] = getUserPrize(1);
$section[$page_section]['var']['SecondPrizeList'] = getUserPrize(2);
}
// Set Page Variables
$var['terms']['enabled'] = true;
$var['meta']['viewport'] = '';
if ($page_section == 'photosharing') {
$terms_source = 'terms_listing.tpl.php';
} else if ($page_section == 'registration') {
$var['meta']['viewport'] = '';
} else if ($page_section == 'result') {
$terms_source = 'terms_listing.tpl.php';
}
$var['og'] = $page_config['FB_OG'][$page_section];
$var['info'] = array(
'company' => $companyName,
'campaign' => $campaignName,
);
$var['html'] = array(
'sections' => getSectionContent($section),
'terms' => getTemplateHTML(array('template' => TEMPLATE_PATH.$terms_source)),
);
$var['section'] = $page_section;
// Define Page Object
$page = new Template($page_template);
$page->var = $var;
// Display Page
ob_start();
$page->display();
ob_end_flush();
?>