Mercurial > hg > fapweb
annotate index.php @ 564:92de3e1393ba
Use default basename.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 10 Mar 2014 17:02:00 +0200 |
parents | 279a98abe3d3 |
children | ed2247111fdd |
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 // |
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
3 // FAPWeb Simple Demoparty System |
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
4 // Main HTML page wrapper |
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP) |
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 |
0 | 42 ?> |
40 | 43 <div id="header"> |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
44 <? echo stGetSetting("siteInfoText") ?> |
40 | 45 </div> |
46 | |
47 <div id="menu"> | |
43 | 48 <? echo stGetSetting("siteMenuHeader") ?> |
104 | 49 |
123
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
50 <a href="about">About</a> |
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
51 <? |
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
52 if (stGetSetting("showNews")) |
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
53 echo "<a href=\"news\">News</a>\n"; |
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
54 ?> |
0 | 55 <a href="compos">Compos</a> |
131
ed05cc69e1c2
The event page was renamed to schedule.
Matti Hamalainen <ccr@tnsp.org>
parents:
123
diff
changeset
|
56 <a href="schedule">Schedule</a> |
0 | 57 <? |
78 | 58 $visibility = stAdmSessionAuth(TRUE); |
60
4e09327ed4d0
Show certain menu options always if we are inside an admin session.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
59 |
17 | 60 if (stGetSetting("showAttendees")) |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
61 echo " <a href=\"attendees\">Attendees</a>\n"; |
103
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
62 else |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
63 if (stChkSetting("allowRegister")) |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
64 echo " <a href=\"register\">Register</a>\n"; |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
65 |
17 | 66 if (stGetSetting("allowVoting")) |
0 | 67 echo " <a href=\"vote\">Vote</a>\n"; |
3
916623924bd5
More work on the party management and voting system.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
68 |
60
4e09327ed4d0
Show certain menu options always if we are inside an admin session.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
69 if ($visibility || stGetSetting("showResults")) |
3
916623924bd5
More work on the party management and voting system.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
70 echo " <a href=\"results\">Results</a>\n"; |
4 | 71 |
60
4e09327ed4d0
Show certain menu options always if we are inside an admin session.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
72 if ($visibility || stGetSetting("showAdmin")) |
171
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
157
diff
changeset
|
73 echo " <a href=\"admin.php\">Admin</a>\n"; |
0 | 74 ?> |
47 | 75 <? echo stGetSetting("siteMenuFooter") ?> |
0 | 76 </div> |
77 | |
149 | 78 <? |
79 echo stGetSetting("siteExtraHTML"); | |
106
324f3a415237
Add extra HTML + sponsors box to layout.
Matti Hamalainen <ccr@tnsp.org>
parents:
104
diff
changeset
|
80 |
149 | 81 // Get the name of the page |
514
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
82 $pagePath = "pages/"; |
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
83 $pageExt = ".inc.php"; |
303 | 84 $pageName = isset($_GET["page"]) ? $_GET["page"] : stGetSetting("defaultPage"); |
44 | 85 $pageBasename = basename($pageName); |
149 | 86 |
87 // 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
|
88 if (!file_exists($pagePath.$pageBasename.$pageExt)) |
564 | 89 $pageBasename = stGetSetting("defaultPage"); |
149 | 90 |
91 | |
92 echo "<div id=\"infobox\">".strtoupper($pageBasename)."</div>\n"; | |
44 | 93 ?> |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
94 <div id="mainContent"> |
0 | 95 <div> |
96 <? | |
514
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
97 if (file_exists($pagePath.$pageBasename.$pageExt)) |
8693052c66a9
Move normal pages under a sub-directory.
Matti Hamalainen <ccr@tnsp.org>
parents:
365
diff
changeset
|
98 include($pagePath.$pageBasename.$pageExt); |
0 | 99 ?> |
100 </div> | |
101 </div> | |
102 <? | |
34
8ecf7c04a837
Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
103 cmPrintPageFooter(); |
0 | 104 ?> |