Mercurial > hg > fapweb
annotate 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 |
rev | line source |
---|---|
1071 | 1 <?php |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
2 // |
571
ce11ea112a65
Change the header blurb a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
565
diff
changeset
|
3 // FAPWeb - Simple Web-based Demoparty Management System |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
4 // Main HTML page wrapper |
1072 | 5 // (C) Copyright 2012-2017 Tecnic Software productions (TNSP) |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
6 // |
1019
22b6442d5cb3
Add error messages for missing mconfig.inc.php.
Matti Hamalainen <ccr@tnsp.org>
parents:
1001
diff
changeset
|
7 if (!file_exists("mconfig.inc.php")) |
22b6442d5cb3
Add error messages for missing mconfig.inc.php.
Matti Hamalainen <ccr@tnsp.org>
parents:
1001
diff
changeset
|
8 die("Missing site configuration file.\n"); |
22b6442d5cb3
Add error messages for missing mconfig.inc.php.
Matti Hamalainen <ccr@tnsp.org>
parents:
1001
diff
changeset
|
9 |
175
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
10 require_once "mconfig.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
11 require_once "msite.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
12 require_once "msession.inc.php"; |
0 | 13 |
887 | 14 |
15 function stGetMainPageLink($id, $name, $show = TRUE) | |
16 { | |
17 global $pageName; | |
18 if ($show) | |
19 return " <a class=\"".($id == $pageName ? "active" : "inactive")."\" href=\"".$id."\">".$name."</a>\n"; | |
20 else | |
21 return ""; | |
22 } | |
23 | |
24 | |
699 | 25 // Get the name of the page |
26 if (!isset($pagePath)) $pagePath = "pages/"; | |
27 if (!isset($pageExt)) $pageExt = ".inc.php"; | |
28 $pageName = isset($_GET["page"]) ? basename($_GET["page"]) : stGetSetting("defaultPage"); | |
29 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
30 |
0 | 31 // Switch to https first, if needed |
699 | 32 $isSecurePage = isset($pageName) && array_key_exists($pageName, $securePages); |
365
2e0a0d93b8c1
Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents:
303
diff
changeset
|
33 if (!stCheckHTTPS() && $isSecurePage) |
0 | 34 { |
35 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); | |
36 exit; | |
37 } | |
38 | |
39 | 39 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
40 // Check for cache-controlled pages |
699 | 41 $noCache = $isSecurePage && $securePages[$pageName]; |
365
2e0a0d93b8c1
Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents:
303
diff
changeset
|
42 if ($noCache) |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
43 stSetupCacheControl(); |
0 | 44 |
699 | 45 stDebug("PG: '".$pageName."' is secure=".intval($isSecurePage).", noCache=".intval($noCache)); |
46 | |
47 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
48 // Start output |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
49 cmPrintPageHeader($pageTitle, |
365
2e0a0d93b8c1
Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents:
303
diff
changeset
|
50 ($noCache ? " <meta http-equiv=\"Pragma\" content=\"no-cache\" />\n" : ""). |
1084 | 51 " <meta name=\"viewport\" content=\"width=device-width\" />\n". |
52 " <script type=\"text/javascript\" src=\"genajax.js\"></script>\n"); | |
0 | 53 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
54 // Initiate SQL database connection |
0 | 55 if (!stConnectSQLDB()) |
56 { | |
39 | 57 // Error occured, bail out early |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
58 cmPrintPageFooter(); |
0 | 59 exit; |
60 } | |
61 | |
699 | 62 |
63 // Default to set default page if selected page does not exist | |
64 if (!file_exists($pagePath.$pageName.$pageExt)) | |
65 $pageName = stGetSetting("defaultPage"); | |
66 $currPagename = $pageName; | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
67 |
106
324f3a415237
Add extra HTML + sponsors box to layout.
Matti Hamalainen <ccr@tnsp.org>
parents:
104
diff
changeset
|
68 |
699 | 69 // Fetch non-"hardcoded" settings from SQL database |
70 stReloadSettings(); | |
149 | 71 |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
72 // Output the page menu etc. |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
73 echo |
1073 | 74 "<!-- header -->\n". |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
75 "<div id=\"header\">\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
76 stGetSetting("siteInfoText"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
77 " <div id=\"menu\">\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
78 " ".stGetSetting("siteMenuHeader")."\n". |
610
167ca3827c31
Add some new HTML elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
603
diff
changeset
|
79 " <div id=\"menuInner\">\n". |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
80 stGetMainPageLink("about", "About"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
81 stGetMainPageLink("news", "News", stGetSetting("showNews")). |
587
135efe0c3b49
Add new options for hiding/showing compo and schedule pages.
Matti Hamalainen <ccr@tnsp.org>
parents:
585
diff
changeset
|
82 stGetMainPageLink("compos", "Compos", stGetSetting("showCompos")). |
135efe0c3b49
Add new options for hiding/showing compo and schedule pages.
Matti Hamalainen <ccr@tnsp.org>
parents:
585
diff
changeset
|
83 stGetMainPageLink("schedule", "Schedule", stGetSetting("showSchedule")); |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
84 |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
85 if (stGetSetting("showAttendees")) |
587
135efe0c3b49
Add new options for hiding/showing compo and schedule pages.
Matti Hamalainen <ccr@tnsp.org>
parents:
585
diff
changeset
|
86 echo stGetMainPageLink("visitors", "Visitors"); |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
87 else |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
88 if (stChkSetting("allowRegister")) |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
89 echo stGetMainPageLink("register", "Register"); |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
90 |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
91 $visibility = stAdmSessionAuth(TRUE); |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
92 echo |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
93 stGetMainPageLink("vote", "Vote", stGetSetting("allowVoting")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
94 stGetMainPageLink("results", "Results", $visibility || stGetSetting("showResults")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
95 stGetMainPageLink("admin.php", "Admin", $visibility || stGetSetting("showAdmin")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
96 stGetSetting("siteMenuFooter"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
97 " </div>\n". |
610
167ca3827c31
Add some new HTML elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
603
diff
changeset
|
98 " </div>\n". |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
99 "</div>\n". |
1073 | 100 "<!-- main -->\n". |
101 "<div id=\"infobox\">".$pageName."</div>\n". | |
1071 | 102 "<div id=\"mainContent\">\n". |
103 "<div id=\"mainContentInner\">\n". | |
104 "<div id=\"mainContentWrap\">\n"; | |
105 | |
699 | 106 if (file_exists($pagePath.$pageName.$pageExt)) |
107 include($pagePath.$pageName.$pageExt); | |
1071 | 108 |
109 echo | |
110 "</div>\n". | |
111 "</div>\n". | |
112 "</div>\n". | |
1073 | 113 "<!-- extra -->\n". |
114 stGetSetting("siteExtraHTML"). | |
115 "\n". | |
116 "<!-- end -->\n"; | |
1071 | 117 |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
118 cmPrintPageFooter(); |
0 | 119 ?> |