Mercurial > hg > fapweb
annotate index.php @ 1071:76e11ae923a7
Use long tags.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Jan 2017 17:44:50 +0200 |
parents | 22b6442d5cb3 |
children | 7da8bde9b7be |
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 |
1001 | 5 // (C) Copyright 2012-2015 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" : ""). |
232 | 51 " <meta name=\"viewport\" content=\"width=device-width\" />\n"); |
0 | 52 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
53 // Initiate SQL database connection |
0 | 54 if (!stConnectSQLDB()) |
55 { | |
39 | 56 // Error occured, bail out early |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
57 cmPrintPageFooter(); |
0 | 58 exit; |
59 } | |
60 | |
699 | 61 |
62 // Default to set default page if selected page does not exist | |
63 if (!file_exists($pagePath.$pageName.$pageExt)) | |
64 $pageName = stGetSetting("defaultPage"); | |
65 $currPagename = $pageName; | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
66 |
106
324f3a415237
Add extra HTML + sponsors box to layout.
Matti Hamalainen <ccr@tnsp.org>
parents:
104
diff
changeset
|
67 |
699 | 68 // Fetch non-"hardcoded" settings from SQL database |
69 stReloadSettings(); | |
149 | 70 |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
71 // Output the page menu etc. |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
72 echo |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
73 "<div id=\"header\">\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
74 stGetSetting("siteInfoText"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
75 " <div id=\"menu\">\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
76 " ".stGetSetting("siteMenuHeader")."\n". |
610
167ca3827c31
Add some new HTML elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
603
diff
changeset
|
77 " <div id=\"menuInner\">\n". |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
78 stGetMainPageLink("about", "About"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
79 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
|
80 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
|
81 stGetMainPageLink("schedule", "Schedule", stGetSetting("showSchedule")); |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
82 |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
83 if (stGetSetting("showAttendees")) |
587
135efe0c3b49
Add new options for hiding/showing compo and schedule pages.
Matti Hamalainen <ccr@tnsp.org>
parents:
585
diff
changeset
|
84 echo stGetMainPageLink("visitors", "Visitors"); |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
85 else |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
86 if (stChkSetting("allowRegister")) |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
87 echo stGetMainPageLink("register", "Register"); |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
88 |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
89 $visibility = stAdmSessionAuth(TRUE); |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
90 echo |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
91 stGetMainPageLink("vote", "Vote", stGetSetting("allowVoting")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
92 stGetMainPageLink("results", "Results", $visibility || stGetSetting("showResults")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
93 stGetMainPageLink("admin.php", "Admin", $visibility || stGetSetting("showAdmin")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
94 stGetSetting("siteMenuFooter"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
95 " </div>\n". |
610
167ca3827c31
Add some new HTML elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
603
diff
changeset
|
96 " </div>\n". |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
97 "</div>\n". |
699 | 98 "<div id=\"infobox\">".$pageName."</div>\n"; |
1071 | 99 "<div id=\"mainContent\">\n". |
100 "<div id=\"mainContentInner\">\n". | |
101 "<div id=\"mainContentWrap\">\n"; | |
102 | |
699 | 103 if (file_exists($pagePath.$pageName.$pageExt)) |
104 include($pagePath.$pageName.$pageExt); | |
1071 | 105 |
106 echo | |
107 "</div>\n". | |
108 "</div>\n". | |
109 "</div>\n". | |
110 stGetSetting("siteExtraHTML"); | |
111 | |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
112 cmPrintPageFooter(); |
0 | 113 ?> |