Commit 087020df authored by Ryan Wade's avatar Ryan Wade

Login component added into admin.php and viewpage.php

Both files have been mostly merged.
TODO: extract similar functionality into separate class.
parent 701e6b5f
<?php
$AuthRequired = true;
$AuthReturn = "./viewpage.php?id=-2";
$linking = "admin.php";
$Table = 2;
$title = "Admin Panel";
//Include all components
include "./Authentication.php";
include "./SQL.php";
include "./css.php";
......@@ -9,13 +15,20 @@
include "./breadcrumb.php";
include "./body.php";
include "./sitemap.php";
include "./login.php";
include "./footer.php";
//Initialize SQL database object
$SQL = new SQL();
$Auth = new Authentication($SQL->Get_TABLE(1));
if($AuthRequired&&(!$Auth->isAuthenticated()))
header("location: ".AuthReturn);
//Get Basic Site Info
$site_title = "Admin Panel";
if($title==null)
$site_title = $SQL->GET_SITE_TITLE();
else
$site_title = $title;
$site_logo = $SQL->GET_SITE_LOGO();
//Get ID from HTML GET REQUEST or set to 0
$page_id = 0;
......@@ -23,18 +36,39 @@
$page_id = $_GET["id"];
//Identify special pages and get page info;
$page_title = $SQL->GET_TABLE(2)->GET_ROW($page_id)->GET_ATTRIBUTE(2);
$page_desc = $SQL->GET_TABLE(2)->GET_ROW($page_id)->GET_ATTRIBUTE(3);
$page_img = $SQL->GET_TABLE(2)->GET_ROW($page_id)->GET_ATTRIBUTE(4);
$page_src = $SQL->GET_TABLE(2)->GET_ROW($page_id)->GET_ATTRIBUTE(5);
$page_title = null;
$page_desc = null;
$page_img = null;
$page_src = null;
switch ($page_id)
{
case -3:
$Auth->TerminateUser();
break;
case -2:
$page_title = "Login";
break;
case -1:
$page_title = "Sitemap";
break;
default:
$page_title = $SQL->GET_TABLE($Table)->GET_ROW($page_id)->GET_ATTRIBUTE(2);
$page_desc = $SQL->GET_TABLE($Table)->GET_ROW($page_id)->GET_ATTRIBUTE(3);
$page_img = $SQL->GET_TABLE($Table)->GET_ROW($page_id)->GET_ATTRIBUTE(4);
$page_src = $SQL->GET_TABLE($Table)->GET_ROW($page_id)->GET_ATTRIBUTE(5);
break;
}
//Initialize page component objects
$css = new CSS();
$header = new Header($site_title, $site_logo);
$nav = new NAV($SQL->GET_TABLE(2), "admin.php", $page_id);
$nav = new NAV($SQL->GET_TABLE($Table), $linking, $page_id);
$title = new Title($page_id, $page_title, $page_desc, $page_img);
$breadcrumb = new Breadcrumb($SQL->GET_TABLE(2), "admin.php", $page_id, $page_title);
$breadcrumb = new Breadcrumb($SQL->GET_TABLE($Table), $linking, $page_id, $page_title);
$body = new Body($page_src);
$sitemap = new Sitemap($SQL->GET_TABLE($Table), $linking);
$login = new Login($SQL->GET_TABLE(1), $Auth, "./".$linking);
$footer = new footer($linking);
//render HTML output
?>
......@@ -52,10 +86,21 @@
<?php
$title->render();
$breadcrumb->render();
$body->render();
switch ($page_id)
{
case -2:
$login->render();
break;
case -1:
$sitemap->render();
break;
default:
$body->render();
break;
}
?>
</div>
<?php $footer->render(); ?>
</div>
</body>
</html>
\ No newline at end of file
<?php
$AuthRequired = false;
$AuthReturn = "./viewpage.php?id=-2";
$linking = "viewpage.php";
$Table = 0;
$title = null;
//Include all components
include "./Authentication.php";
include "./SQL.php";
include "./css.php";
......@@ -9,13 +15,20 @@
include "./breadcrumb.php";
include "./body.php";
include "./sitemap.php";
include "./login.php";
include "./footer.php";
//Initialize SQL database object
$SQL = new SQL();
$Auth = new Authentication($SQL->Get_TABLE(1));
if($AuthRequired&&(!$Auth->isAuthenticated()))
header("location: ".AuthReturn);
//Get Basic Site Info
$site_title = $SQL->GET_SITE_TITLE();
if($title==null)
$site_title = $SQL->GET_SITE_TITLE();
else
$site_title = $title;
$site_logo = $SQL->GET_SITE_LOGO();
//Get ID from HTML GET REQUEST or set to 0
$page_id = 0;
......@@ -29,26 +42,33 @@
$page_src = null;
switch ($page_id)
{
case -3:
$Auth->TerminateUser();
break;
case -2:
$page_title = "Login";
break;
case -1:
$page_title = "Sitemap";
$page_title = "Sitemap";
break;
default:
$page_title = $SQL->GET_TABLE(0)->GET_ROW($page_id)->GET_ATTRIBUTE(2);
$page_desc = $SQL->GET_TABLE(0)->GET_ROW($page_id)->GET_ATTRIBUTE(3);
$page_img = $SQL->GET_TABLE(0)->GET_ROW($page_id)->GET_ATTRIBUTE(4);
$page_src = $SQL->GET_TABLE(0)->GET_ROW($page_id)->GET_ATTRIBUTE(5);
$page_title = $SQL->GET_TABLE($Table)->GET_ROW($page_id)->GET_ATTRIBUTE(2);
$page_desc = $SQL->GET_TABLE($Table)->GET_ROW($page_id)->GET_ATTRIBUTE(3);
$page_img = $SQL->GET_TABLE($Table)->GET_ROW($page_id)->GET_ATTRIBUTE(4);
$page_src = $SQL->GET_TABLE($Table)->GET_ROW($page_id)->GET_ATTRIBUTE(5);
break;
}
//Initialize page component objects
$css = new CSS();
$header = new Header($site_title, $site_logo);
$nav = new NAV($SQL->GET_TABLE(0), "viewpage.php", $page_id);
$nav = new NAV($SQL->GET_TABLE($Table), $linking, $page_id);
$title = new Title($page_id, $page_title, $page_desc, $page_img);
$breadcrumb = new Breadcrumb($SQL->GET_TABLE(0), "viewpage.php",$page_id, $page_title);
$breadcrumb = new Breadcrumb($SQL->GET_TABLE($Table), $linking, $page_id, $page_title);
$body = new Body($page_src);
$sitemap = new Sitemap($SQL->GET_TABLE(0), "viewpage.php");
$footer = new footer("viewpage.php");
$sitemap = new Sitemap($SQL->GET_TABLE($Table), $linking);
$login = new Login($SQL->GET_TABLE(1), $Auth, "./".$linking);
$footer = new footer($linking);
//render HTML output
?>
......@@ -68,6 +88,9 @@
$breadcrumb->render();
switch ($page_id)
{
case -2:
$login->render();
break;
case -1:
$sitemap->render();
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment