view index.php @ 820:e213dca6354d

Add filename as ref variable argument to stSetFileEntryFilename().
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 24 Nov 2014 22:31:47 +0200
parents 9a948144dcc9
children e6a1410ce71d
line wrap: on
line source

<?
//
// FAPWeb - Simple Web-based Demoparty Management System
// Main HTML page wrapper
// (C) Copyright 2012-2014 Tecnic Software productions (TNSP)
//
require_once "mconfig.inc.php";
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($pageName) && array_key_exists($pageName, $securePages);
if (!stCheckHTTPS() && $isSecurePage)
{
  header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
  exit;
}


// Check for cache-controlled pages
$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" : "").
  "  <meta name=\"viewport\" content=\"width=device-width\" />\n");

// Initiate SQL database connection
if (!stConnectSQLDB())
{
  // Error occured, bail out early
  cmPrintPageFooter();
  exit;
}


// Default to set default page if selected page does not exist
if (!file_exists($pagePath.$pageName.$pageExt))
  $pageName = stGetSetting("defaultPage");
$currPagename = $pageName;


// Fetch non-"hardcoded" settings from SQL database
stReloadSettings();

// Output the page menu etc.
echo
  "<div id=\"header\">\n".
  stGetSetting("siteInfoText").
  "  <div id=\"menu\">\n".
  "    ".stGetSetting("siteMenuHeader")."\n".
  "   <div id=\"menuInner\">\n".
  stGetMainPageLink("about", "About").
  stGetMainPageLink("news", "News", stGetSetting("showNews")).
  stGetMainPageLink("compos", "Compos", stGetSetting("showCompos")).
  stGetMainPageLink("schedule", "Schedule", stGetSetting("showSchedule"));

if (stGetSetting("showAttendees"))
  echo stGetMainPageLink("visitors", "Visitors");
else
if (stChkSetting("allowRegister"))
  echo stGetMainPageLink("register", "Register");

$visibility = stAdmSessionAuth(TRUE);
echo
  stGetMainPageLink("vote", "Vote", stGetSetting("allowVoting")).
  stGetMainPageLink("results", "Results", $visibility || stGetSetting("showResults")).
  stGetMainPageLink("admin.php", "Admin", $visibility || stGetSetting("showAdmin")).
  stGetSetting("siteMenuFooter").
  "  </div>\n".
  " </div>\n".
  "</div>\n".
  "<div id=\"infobox\">".$pageName."</div>\n";
?>
<div id="mainContent">
<div id="mainContentInner">
<div id="mainContentWrap">
<?
if (file_exists($pagePath.$pageName.$pageExt))
  include($pagePath.$pageName.$pageExt);
?>
</div>
</div>
</div>
<?
echo stGetSetting("siteExtraHTML");
cmPrintPageFooter();
?>