view index.php @ 1120:b2bca5f6d0ff default tip

Cosmetic cleanup: remove trailing whitespace.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 13 Dec 2020 13:47:13 +0200
parents e1cfbfb0b64a
children
line wrap: on
line source

<?php
//
// FAPWeb - Simple Web-based Demoparty Management System
// Main HTML page wrapper
// (C) Copyright 2012-2017 Tecnic Software productions (TNSP)
//
if (!file_exists("mconfig.inc.php"))
  die("Missing site configuration file.\n");

require_once "mconfig.inc.php";
require_once "msite.inc.php";
require_once "msession.inc.php";


function stGetMainPageLink($id, $name, $show = TRUE)
{
  global $pageName;
  if ($show)
    return "    <a class=\"".($id == $pageName ? "active" : "inactive")."\" href=\"".$id."\">".$name."</a>\n";
  else
    return "";
}


// 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".
  "  <script type=\"text/javascript\" src=\"genajax.js\"></script>\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
  "<!-- header -->\n".
  "<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".
  "<!-- main -->\n".
  "<div id=\"infobox\">".$pageName."</div>\n".
  "<div id=\"mainContent\">\n".
  "<div id=\"mainContentInner\">\n".
  "<div id=\"mainContentWrap\">\n";

if (file_exists($pagePath.$pageName.$pageExt))
  include($pagePath.$pageName.$pageExt);

echo
  "</div>\n".
  "</div>\n".
  "</div>\n".
  "<!-- extra -->\n".
  stGetSetting("siteExtraHTML").
  "\n".
  "<!-- end -->\n";

cmPrintPageFooter();
?>