Yeah, I'm just very wary of using too many AJAX requests as if there are a few logged in it may cause load issues. I could send the key perhaps every 2 mins with the time resync.
What are your thoughts on this code? Its my main script and it page has 3 functions called getPage.. and the template files has similar. The idea being that each page would have had a bulk of code (now in template) that was duplicated this way template script is only in one file.
I could probably do that check somewhere in here but this is only executed on page refresh. :S
- <?php
-
ob_start(); //Buffer all output.
-
session_start();//Start global session.
-
-
require("PHP/TemplatePHP.php"); //Website template
-
include("PHP/dbCon/config.php"); //Required for db connection
-
include("PHP/dbCon/opendb.php"); //Required for db connection
-
-
-
-
//Check if user is logged in.
-
-
-
if(isset($_GET["page"])){$inPage="PHP/". $_GET["page"] .".php";}
-
else{$inPage=null;}
-
-
if(!isset($_SESSION['username']))
-
{
-
if($inPage == "PHP/Register.php")
-
{
-
$outPage = $inPage;
-
}
-
else
-
{
-
$outPage = "PHP/Login.php";
-
}
-
}
-
else
-
{
-
if(file_exists($inPage))
-
{
-
$outPage = $inPage;
-
}
-
else
-
{
-
$outPage = "PHP/Error.php";
-
}
-
}
-
-
include($outPage);
-
-
tempPageP1(true);
-
-
//Header additions (JS)
-
getPageJS();
-
//Header additions (CSS)
-
getPageCSS();
-
-
tempPageP2(true);
-
-
//Page Title
-
getPageTitle();
-
-
tempPageP3(true);
-
-
//Message to user.
-
if(isset($_SESSION['message']))
-
{
-
echo "<p id=\"userMessage\">{$_SESSION['message']}</p>";
-
unset($_SESSION['message']);
-
}
-
//Page body
-
getPageContent();
-
-
tempPageP4(true);
-
-
include("PHP/dbCon/closedb.php");
-
?>