Mercurial > hg > fapweb
annotate index.php @ 585:cec36fd24d21
Clean up the menu and HTML somewhat.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 17 Oct 2014 00:49:13 +0300 |
parents | ce11ea112a65 |
children | 135efe0c3b49 |
rev | line source |
---|---|
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
1 <? |
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 |
565 | 5 // (C) Copyright 2012-2014 Tecnic Software productions (TNSP) |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
6 // |
175
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
7 require_once "mconfig.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
8 require_once "msite.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
9 require_once "msession.inc.php"; |
0 | 10 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
11 |
0 | 12 // Switch to https first, if needed |
365
2e0a0d93b8c1
Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents:
303
diff
changeset
|
13 $isSecurePage = isset($_GET["page"]) && array_key_exists($_GET["page"], $securePages); |
2e0a0d93b8c1
Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents:
303
diff
changeset
|
14 if (!stCheckHTTPS() && $isSecurePage) |
0 | 15 { |
16 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); | |
17 exit; | |
18 } | |
19 | |
39 | 20 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
21 // Check for cache-controlled pages |
365
2e0a0d93b8c1
Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents:
303
diff
changeset
|
22 $noCache = $isSecurePage && $securePages[$_GET["page"]]; |
2e0a0d93b8c1
Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents:
303
diff
changeset
|
23 if ($noCache) |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
24 stSetupCacheControl(); |
0 | 25 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
26 // Start output |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
27 cmPrintPageHeader($pageTitle, |
365
2e0a0d93b8c1
Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents:
303
diff
changeset
|
28 ($noCache ? " <meta http-equiv=\"Pragma\" content=\"no-cache\" />\n" : ""). |
232 | 29 " <meta name=\"viewport\" content=\"width=device-width\" />\n"); |
0 | 30 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
31 // Initiate SQL database connection |
0 | 32 if (!stConnectSQLDB()) |
33 { | |
39 | 34 // Error occured, bail out early |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
35 cmPrintPageFooter(); |
0 | 36 exit; |
37 } | |
38 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
39 // Fetch non-"hardcoded" settings from SQL database |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
40 stReloadSettings(); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
41 |
106
324f3a415237
Add extra HTML + sponsors box to layout.
Matti Hamalainen <ccr@tnsp.org>
parents:
104
diff
changeset
|
42 |
149 | 43 // Get the name of the page |
514
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
44 $pagePath = "pages/"; |
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
45 $pageExt = ".inc.php"; |
303 | 46 $pageName = isset($_GET["page"]) ? $_GET["page"] : stGetSetting("defaultPage"); |
44 | 47 $pageBasename = basename($pageName); |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
48 $currPagename = ""; |
149 | 49 |
50 // Default to set default page if selected page does not exist | |
514
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
51 if (!file_exists($pagePath.$pageBasename.$pageExt)) |
564 | 52 $pageBasename = stGetSetting("defaultPage"); |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
53 else |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
54 $currPagename = $pageBasename; |
149 | 55 |
56 | |
585
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
57 // Output the page menu etc. |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
58 echo |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
59 "<div id=\"header\">\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
60 stGetSetting("siteInfoText"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
61 " <div id=\"menu\">\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
62 " ".stGetSetting("siteMenuHeader")."\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
63 stGetMainPageLink("about", "About"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
64 stGetMainPageLink("news", "News", stGetSetting("showNews")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
65 stGetMainPageLink("compos", "Compos"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
66 stGetMainPageLink("schedule", "Schedule"); |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
67 |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
68 if (stGetSetting("showAttendees")) |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
69 echo stGetMainPageLink("attendees", "Attendees"); |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
70 else |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
71 if (stChkSetting("allowRegister")) |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
72 echo stGetMainPageLink("register", "Register"); |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
73 |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
74 $visibility = stAdmSessionAuth(TRUE); |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
75 echo |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
76 stGetMainPageLink("vote", "Vote", stGetSetting("allowVoting")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
77 stGetMainPageLink("results", "Results", $visibility || stGetSetting("showResults")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
78 stGetMainPageLink("admin.php", "Admin", $visibility || stGetSetting("showAdmin")). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
79 stGetSetting("siteMenuFooter"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
80 " </div>\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
81 "</div>\n". |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
82 stGetSetting("siteExtraHTML"). |
cec36fd24d21
Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
83 "<div id=\"infobox\">".$pageBasename."</div>\n"; |
44 | 84 ?> |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
85 <div id="mainContent"> |
0 | 86 <div> |
87 <? | |
514
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
88 if (file_exists($pagePath.$pageBasename.$pageExt)) |
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
89 include($pagePath.$pageBasename.$pageExt); |
0 | 90 ?> |
91 </div> | |
92 </div> | |
93 <? | |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
94 cmPrintPageFooter(); |
0 | 95 ?> |