Mercurial > hg > fapweb
changeset 699:9a948144dcc9
Various cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 10 Nov 2014 19:44:53 +0200 |
parents | 3f322be347d6 |
children | d0418af28559 |
files | index.php msite.inc.php |
diffstat | 2 files changed, 22 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/index.php Mon Nov 10 17:46:42 2014 +0200 +++ b/index.php Mon Nov 10 19:44:53 2014 +0200 @@ -8,9 +8,14 @@ require_once "msite.inc.php"; require_once "msession.inc.php"; +// Get the name of the page +if (!isset($pagePath)) $pagePath = "pages/"; +if (!isset($pageExt)) $pageExt = ".inc.php"; +$pageName = isset($_GET["page"]) ? basename($_GET["page"]) : stGetSetting("defaultPage"); + // Switch to https first, if needed -$isSecurePage = isset($_GET["page"]) && array_key_exists($_GET["page"], $securePages); +$isSecurePage = isset($pageName) && array_key_exists($pageName, $securePages); if (!stCheckHTTPS() && $isSecurePage) { header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); @@ -19,10 +24,13 @@ // Check for cache-controlled pages -$noCache = $isSecurePage && $securePages[$_GET["page"]]; +$noCache = $isSecurePage && $securePages[$pageName]; if ($noCache) stSetupCacheControl(); +stDebug("PG: '".$pageName."' is secure=".intval($isSecurePage).", noCache=".intval($noCache)); + + // Start output cmPrintPageHeader($pageTitle, ($noCache ? " <meta http-equiv=\"Pragma\" content=\"no-cache\" />\n" : ""). @@ -36,23 +44,15 @@ exit; } -// Fetch non-"hardcoded" settings from SQL database -stReloadSettings(); + +// Default to set default page if selected page does not exist +if (!file_exists($pagePath.$pageName.$pageExt)) + $pageName = stGetSetting("defaultPage"); +$currPagename = $pageName; -// Get the name of the page -$pagePath = "pages/"; -$pageExt = ".inc.php"; -$pageName = isset($_GET["page"]) ? $_GET["page"] : stGetSetting("defaultPage"); -$pageBasename = basename($pageName); -$currPagename = ""; - -// Default to set default page if selected page does not exist -if (!file_exists($pagePath.$pageBasename.$pageExt)) - $pageBasename = stGetSetting("defaultPage"); -else - $currPagename = $pageBasename; - +// Fetch non-"hardcoded" settings from SQL database +stReloadSettings(); // Output the page menu etc. echo @@ -81,14 +81,14 @@ " </div>\n". " </div>\n". "</div>\n". - "<div id=\"infobox\">".$pageBasename."</div>\n"; + "<div id=\"infobox\">".$pageName."</div>\n"; ?> <div id="mainContent"> <div id="mainContentInner"> <div id="mainContentWrap"> <? -if (file_exists($pagePath.$pageBasename.$pageExt)) - include($pagePath.$pageBasename.$pageExt); +if (file_exists($pagePath.$pageName.$pageExt)) + include($pagePath.$pageName.$pageExt); ?> </div> </div>
--- a/msite.inc.php Mon Nov 10 17:46:42 2014 +0200 +++ b/msite.inc.php Mon Nov 10 19:44:53 2014 +0200 @@ -622,9 +622,9 @@ // Get link helper function function stGetMainPageLink($id, $name, $show = TRUE) { - global $currPagename; + global $pageName; if ($show) - return " <a class=\"".($id == $currPagename ? "active" : "inactive")."\" href=\"".$id."\">".$name."</a>\n"; + return " <a class=\"".($id == $pageName ? "active" : "inactive")."\" href=\"".$id."\">".$name."</a>\n"; else return ""; }