Added page function + needed files & debug
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// CHECKING ERROR ENV AND PRINT RESULT
|
||||||
function error_env($option){
|
function error_env($option){
|
||||||
global $env;
|
global $env;
|
||||||
if (empty($env)){
|
if (empty($env)){
|
||||||
@@ -17,6 +19,105 @@
|
|||||||
echo "ERROR: Wrong attribute in declared in the function!";
|
echo "ERROR: Wrong attribute in declared in the function!";
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function php_pages($option=null, $domain_shows=null){
|
||||||
|
// Required files or shows error if debug has been set to on.
|
||||||
|
if ($option == "error"){
|
||||||
|
$required_pages=[
|
||||||
|
PAGES_FOLD . "404.php",
|
||||||
|
PAGES_FOLD . "home.php"
|
||||||
|
];
|
||||||
|
|
||||||
|
$missing_pages=[];
|
||||||
|
|
||||||
|
foreach($required_pages as $required){
|
||||||
|
if (! file_exists($required)){
|
||||||
|
array_push($missing_pages, $required);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($missing_pages)){
|
||||||
|
if (DEBUG){
|
||||||
|
echo "<h1>ERROR: Missing Required Pages:</h1>";
|
||||||
|
echo "<ul>";
|
||||||
|
foreach ($missing_pages as $pagepath){
|
||||||
|
echo "<li>Required file '" . $pagepath . "' is missing!</li>";
|
||||||
|
}
|
||||||
|
echo "</ul>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
die("Required pages are missing!.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["page"])){
|
||||||
|
// ---- OPTIONS IF PAGE HAS BEEN DECLARED ----
|
||||||
|
$pagecheck=$_GET["page"];
|
||||||
|
if (empty($pagecheck)){
|
||||||
|
$page="home";
|
||||||
|
}elseif(file_exists(PAGES_FOLD . $pagecheck . ".php")){
|
||||||
|
$page=$pagecheck;
|
||||||
|
}else{
|
||||||
|
$page="404";
|
||||||
|
}
|
||||||
|
|
||||||
|
// title for pages
|
||||||
|
if ( $domain_shows == "show" ){
|
||||||
|
$page_title=DOMAIN . " | " . ucfirst($page);
|
||||||
|
}else{
|
||||||
|
$page_title= ucfirst($page);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return call
|
||||||
|
switch($option){
|
||||||
|
case "return_page":
|
||||||
|
return $page;
|
||||||
|
break;
|
||||||
|
case "return_title":
|
||||||
|
return $page_title;
|
||||||
|
break;
|
||||||
|
case "page":
|
||||||
|
echo $page;
|
||||||
|
break;
|
||||||
|
case "title":
|
||||||
|
echo $page_title;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
// ---- OPTIONS IF PAGE HAS NOT BEEN DECLARED ----
|
||||||
|
$page = "home";
|
||||||
|
|
||||||
|
// title for pages
|
||||||
|
if ( $domain_shows == "show" ){
|
||||||
|
$page_title=DOMAIN . " | " . ucfirst($page);
|
||||||
|
}else{
|
||||||
|
$page_title= ucfirst($page);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return call
|
||||||
|
switch($option){
|
||||||
|
case "return_page":
|
||||||
|
return $page;
|
||||||
|
break;
|
||||||
|
case "return_title":
|
||||||
|
return $page_title;
|
||||||
|
break;
|
||||||
|
case "page":
|
||||||
|
echo $page;
|
||||||
|
break;
|
||||||
|
case "title":
|
||||||
|
echo $page_title;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo $page;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
$env="";
|
include("config/functions_init.php");
|
||||||
|
$env="generic";
|
||||||
|
|
||||||
switch($env){
|
switch($env){
|
||||||
/*------ DON'T TOUCH THIS PART ------ */
|
/*------ DON'T TOUCH THIS PART ------ */
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
break;
|
break;
|
||||||
/* ----------------------------------- */
|
/* ----------------------------------- */
|
||||||
default:
|
default:
|
||||||
include("config/functions_init.php");
|
// Showing error page by default.
|
||||||
include("pages/env-error.php");
|
include("pages/env-error.php");
|
||||||
die;
|
die;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// -- GENERAL SETTING --
|
||||||
|
$debug="on";
|
||||||
|
|
||||||
// --- DB SETTINGS ---
|
// --- DB SETTINGS ---
|
||||||
$db_needed="no";
|
$db_needed="no";
|
||||||
$db_debug="yes";
|
$db_debug="yes";
|
||||||
@@ -7,9 +10,14 @@ $db_name="database-name";
|
|||||||
$db_user="database-user";
|
$db_user="database-user";
|
||||||
$db_pass="database-user-password";
|
$db_pass="database-user-password";
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
// --- DON'T CHANGE ALL THE CODE BELOW!!! ---
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// --- GENERAL SECTION CONFIGURATION
|
||||||
|
if ($debug == "on"){ define("DEBUG",true);} else { define("DEBUG", false); }
|
||||||
|
|
||||||
// --- DON'T CHANGE ALL THE CODE BELOW ---
|
// --- DB SECTION CONFIGURATION
|
||||||
if ($db_needed == "yes"){
|
if ($db_needed == "yes"){
|
||||||
define("DB_HOST", $db_host);
|
define("DB_HOST", $db_host);
|
||||||
define("DB_USER", $db_user);
|
define("DB_USER", $db_user);
|
||||||
@@ -17,6 +25,5 @@ if ($db_needed == "yes"){
|
|||||||
define("DB_NAME", $db_name);
|
define("DB_NAME", $db_name);
|
||||||
define("DB_DEBUG", $db_debug);
|
define("DB_DEBUG", $db_debug);
|
||||||
require_once(CONFIG_FOLD . "db.php");
|
require_once(CONFIG_FOLD . "db.php");
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
include("./config/init.php");
|
include("./config/init.php");
|
||||||
|
php_pages("error");
|
||||||
include(ROOT_DIR . "/templates/header.php");
|
include(ROOT_DIR . "/templates/header.php");
|
||||||
include("./pages/home.php");
|
include("./pages/home.php");
|
||||||
include("./templates/footer.php");
|
include("./templates/footer.php");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<?php include(INCLUDES_FOLD . "head_links.php"); ?>
|
<?php include(INCLUDES_FOLD . "head_links.php"); ?>
|
||||||
<title>Document</title>
|
<title><?php php_pages("title", "show"); ?></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
|
|||||||
Reference in New Issue
Block a user