view index.php @ 78:d50b64fbbc70

Use silent auth check.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 17 Oct 2013 18:14:15 +0300
parents 4e09327ed4d0
children c6b9041078ec
line wrap: on
line source

<?php
require "mconfig.inc.php";
require "msite.inc.php";
require "mcommon.inc.php";
require "msession.inc.php";


// Switch to https first, if needed
if (!stCheckHTTPS() && isset($_SERVER["REQUEST_URI"]) &&
  array_key_exists($_SERVER["REQUEST_URI"], $securePages))
{
  header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
  exit;
}


// Check for cache-controlled pages
if (isset($_SERVER["REQUEST_URI"]) &&
  array_key_exists($_SERVER["REQUEST_URI"], $securePages))
  stSetupCacheControl();

// Start output
cmPrintPageHeader($pageTitle,
  " <meta http-equiv=\"Pragma\" content=\"no-cache\" />");

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

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

?>
<div id="header">
 <? echo stGetSetting("siteInfoText") ?>
</div>

<div id="menu">
  <? echo stGetSetting("siteMenuHeader") ?>
  <a href="news">News</a>
  <a href="compos">Compos</a>
  <a href="event">Event</a>
<?
$visibility = stAdmSessionAuth(TRUE);

if (stGetSetting("showAttendees"))
echo "  <a href=\"attendees\">Attendees</a>\n";

if (stGetSetting("allowVoting"))
echo "  <a href=\"vote\">Vote</a>\n";

if ($visibility || stGetSetting("showResults"))
echo "  <a href=\"results\">Results</a>\n";

if ($visibility || stGetSetting("showAdmin"))
echo "  <a href=\"admin\">Admin</a>\n";
?>
  <? echo stGetSetting("siteMenuFooter") ?>
</div>

<?
$pageName = isset($_GET["p"]) ? $_GET["p"] : "news";
$pageBasename = basename($pageName);
$pageFilename = $pageBasename.".inc.php";
if (file_exists($pageFilename))
  echo "<div id=\"infobox\">".strtoupper($pageBasename)."</div>\n";
?>
<div id="maincontent">
<div>
<?
if (file_exists($pageFilename))
  include($pageFilename);
?>
</div>
</div>
<?
cmPrintPageFooter();
?>