Init
This commit is contained in:
33
rss/php/pageHandler.php
Normal file
33
rss/php/pageHandler.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/autoload.php');
|
||||
// require_once($_SERVER['DOCUMENT_ROOT'] . '/rss/php/conf.php');
|
||||
$page = isset($_GET['page']) && !empty($_GET['page']) ? str_replace('.php', '', $_GET['page']) : 'index';
|
||||
if($page == '404'){
|
||||
http_response_code(404);
|
||||
}
|
||||
|
||||
if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/rss/json/pages/' . $page . '.json')){
|
||||
// Load page configuration
|
||||
$jsonInfo = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/rss/json/pages/' . $page .'.json');
|
||||
$pageInfo = json_decode($jsonInfo, true);
|
||||
|
||||
}else{
|
||||
http_response_code(404);
|
||||
header('location:/404');
|
||||
die('Not found');
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
function loadContents(){
|
||||
global $pageInfo;
|
||||
if(file_exists($_SERVER['DOCUMENT_ROOT'] . '/rss/php/templates/'.$pageInfo['template'].'.php')){
|
||||
include($_SERVER['DOCUMENT_ROOT'] . '/rss/php/templates/'.$pageInfo['template'].'.php');
|
||||
}else{
|
||||
http_response_code(404);
|
||||
header('location:/404');
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user