comparison index.php @ 699:9a948144dcc9

Various cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 10 Nov 2014 19:44:53 +0200
parents 167ca3827c31
children e6a1410ce71d
comparison
equal deleted inserted replaced
698:3f322be347d6 699:9a948144dcc9
6 // 6 //
7 require_once "mconfig.inc.php"; 7 require_once "mconfig.inc.php";
8 require_once "msite.inc.php"; 8 require_once "msite.inc.php";
9 require_once "msession.inc.php"; 9 require_once "msession.inc.php";
10 10
11 // Get the name of the page
12 if (!isset($pagePath)) $pagePath = "pages/";
13 if (!isset($pageExt)) $pageExt = ".inc.php";
14 $pageName = isset($_GET["page"]) ? basename($_GET["page"]) : stGetSetting("defaultPage");
15
11 16
12 // Switch to https first, if needed 17 // Switch to https first, if needed
13 $isSecurePage = isset($_GET["page"]) && array_key_exists($_GET["page"], $securePages); 18 $isSecurePage = isset($pageName) && array_key_exists($pageName, $securePages);
14 if (!stCheckHTTPS() && $isSecurePage) 19 if (!stCheckHTTPS() && $isSecurePage)
15 { 20 {
16 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); 21 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
17 exit; 22 exit;
18 } 23 }
19 24
20 25
21 // Check for cache-controlled pages 26 // Check for cache-controlled pages
22 $noCache = $isSecurePage && $securePages[$_GET["page"]]; 27 $noCache = $isSecurePage && $securePages[$pageName];
23 if ($noCache) 28 if ($noCache)
24 stSetupCacheControl(); 29 stSetupCacheControl();
30
31 stDebug("PG: '".$pageName."' is secure=".intval($isSecurePage).", noCache=".intval($noCache));
32
25 33
26 // Start output 34 // Start output
27 cmPrintPageHeader($pageTitle, 35 cmPrintPageHeader($pageTitle,
28 ($noCache ? " <meta http-equiv=\"Pragma\" content=\"no-cache\" />\n" : ""). 36 ($noCache ? " <meta http-equiv=\"Pragma\" content=\"no-cache\" />\n" : "").
29 " <meta name=\"viewport\" content=\"width=device-width\" />\n"); 37 " <meta name=\"viewport\" content=\"width=device-width\" />\n");
34 // Error occured, bail out early 42 // Error occured, bail out early
35 cmPrintPageFooter(); 43 cmPrintPageFooter();
36 exit; 44 exit;
37 } 45 }
38 46
47
48 // Default to set default page if selected page does not exist
49 if (!file_exists($pagePath.$pageName.$pageExt))
50 $pageName = stGetSetting("defaultPage");
51 $currPagename = $pageName;
52
53
39 // Fetch non-"hardcoded" settings from SQL database 54 // Fetch non-"hardcoded" settings from SQL database
40 stReloadSettings(); 55 stReloadSettings();
41
42
43 // Get the name of the page
44 $pagePath = "pages/";
45 $pageExt = ".inc.php";
46 $pageName = isset($_GET["page"]) ? $_GET["page"] : stGetSetting("defaultPage");
47 $pageBasename = basename($pageName);
48 $currPagename = "";
49
50 // Default to set default page if selected page does not exist
51 if (!file_exists($pagePath.$pageBasename.$pageExt))
52 $pageBasename = stGetSetting("defaultPage");
53 else
54 $currPagename = $pageBasename;
55
56 56
57 // Output the page menu etc. 57 // Output the page menu etc.
58 echo 58 echo
59 "<div id=\"header\">\n". 59 "<div id=\"header\">\n".
60 stGetSetting("siteInfoText"). 60 stGetSetting("siteInfoText").
79 stGetMainPageLink("admin.php", "Admin", $visibility || stGetSetting("showAdmin")). 79 stGetMainPageLink("admin.php", "Admin", $visibility || stGetSetting("showAdmin")).
80 stGetSetting("siteMenuFooter"). 80 stGetSetting("siteMenuFooter").
81 " </div>\n". 81 " </div>\n".
82 " </div>\n". 82 " </div>\n".
83 "</div>\n". 83 "</div>\n".
84 "<div id=\"infobox\">".$pageBasename."</div>\n"; 84 "<div id=\"infobox\">".$pageName."</div>\n";
85 ?> 85 ?>
86 <div id="mainContent"> 86 <div id="mainContent">
87 <div id="mainContentInner"> 87 <div id="mainContentInner">
88 <div id="mainContentWrap"> 88 <div id="mainContentWrap">
89 <? 89 <?
90 if (file_exists($pagePath.$pageBasename.$pageExt)) 90 if (file_exists($pagePath.$pageName.$pageExt))
91 include($pagePath.$pageBasename.$pageExt); 91 include($pagePath.$pageName.$pageExt);
92 ?> 92 ?>
93 </div> 93 </div>
94 </div> 94 </div>
95 </div> 95 </div>
96 <? 96 <?