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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1071
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
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
7da8bde9b7be Bump copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 1071
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
887
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
14
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
15 function stGetMainPageLink($id, $name, $show = TRUE)
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
16 {
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
17 global $pageName;
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
18 if ($show)
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
19 return " <a class=\"".($id == $pageName ? "active" : "inactive")."\" href=\"".$id."\">".$name."</a>\n";
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
20 else
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
21 return "";
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
22 }
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
23
e6a1410ce71d Move function to index.php
Matti Hamalainen <ccr@tnsp.org>
parents: 699
diff changeset
24
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
25 // Get the name of the page
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
26 if (!isset($pagePath)) $pagePath = "pages/";
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
27 if (!isset($pageExt)) $pageExt = ".inc.php";
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
28 $pageName = isset($_GET["page"]) ? basename($_GET["page"]) : stGetSetting("defaultPage");
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
29
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
30
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 // Switch to https first, if needed
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
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
39
1844df51a55c Improve authentication.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
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
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
45 stDebug("PG: '".$pageName."' is secure=".intval($isSecurePage).", noCache=".intval($noCache));
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
46
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
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
e1cfbfb0b64a Add genajax.js to pages.
Matti Hamalainen <ccr@tnsp.org>
parents: 1073
diff changeset
51 " <meta name=\"viewport\" content=\"width=device-width\" />\n".
e1cfbfb0b64a Add genajax.js to pages.
Matti Hamalainen <ccr@tnsp.org>
parents: 1073
diff changeset
52 " <script type=\"text/javascript\" src=\"genajax.js\"></script>\n");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 if (!stConnectSQLDB())
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 {
39
1844df51a55c Improve authentication.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 exit;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
62
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
63 // Default to set default page if selected page does not exist
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
64 if (!file_exists($pagePath.$pageName.$pageExt))
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
65 $pageName = stGetSetting("defaultPage");
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
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
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
69 // Fetch non-"hardcoded" settings from SQL database
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
70 stReloadSettings();
149
7e20560ac479 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
Matti Hamalainen <ccr@tnsp.org>
parents: 1072
diff changeset
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
Matti Hamalainen <ccr@tnsp.org>
parents: 1072
diff changeset
100 "<!-- main -->\n".
Matti Hamalainen <ccr@tnsp.org>
parents: 1072
diff changeset
101 "<div id=\"infobox\">".$pageName."</div>\n".
1071
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
102 "<div id=\"mainContent\">\n".
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
103 "<div id=\"mainContentInner\">\n".
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
104 "<div id=\"mainContentWrap\">\n";
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
105
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
106 if (file_exists($pagePath.$pageName.$pageExt))
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
107 include($pagePath.$pageName.$pageExt);
1071
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
108
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
109 echo
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
110 "</div>\n".
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
111 "</div>\n".
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
112 "</div>\n".
1073
Matti Hamalainen <ccr@tnsp.org>
parents: 1072
diff changeset
113 "<!-- extra -->\n".
Matti Hamalainen <ccr@tnsp.org>
parents: 1072
diff changeset
114 stGetSetting("siteExtraHTML").
Matti Hamalainen <ccr@tnsp.org>
parents: 1072
diff changeset
115 "\n".
Matti Hamalainen <ccr@tnsp.org>
parents: 1072
diff changeset
116 "<!-- end -->\n";
1071
76e11ae923a7 Use long tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 1019
diff changeset
117
34
8ecf7c04a837 Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
118 cmPrintPageFooter();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 ?>