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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
ed2247111fdd Bump copyright years.
Matti Hamalainen <ccr@tnsp.org>
parents: 564
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
11
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 exit;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
39
1844df51a55c Improve authentication.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
aad9ededea6c Reorder some meta tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 231
diff changeset
29 " <meta name=\"viewport\" content=\"width=device-width\" />\n");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 if (!stConnectSQLDB())
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 {
39
1844df51a55c Improve authentication.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 exit;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
7e20560ac479 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
734781881e47 Change page parameter.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
46 $pageName = isset($_GET["page"]) ? $_GET["page"] : stGetSetting("defaultPage");
44
72dcc1d48809 More work on the design.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
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
7e20560ac479 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
49
7e20560ac479 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
92de3e1393ba Use default basename.
Matti Hamalainen <ccr@tnsp.org>
parents: 560
diff changeset
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
7e20560ac479 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
55
7e20560ac479 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
72dcc1d48809 More work on the design.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
84 ?>
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
85 <div id="mainContent">
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 <div>
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 ?>
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 </div>
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 </div>
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 <?
34
8ecf7c04a837 Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
94 cmPrintPageFooter();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 ?>