annotate index.php @ 820:e213dca6354d

Add filename as ref variable argument to stSetFileEntryFilename().
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 24 Nov 2014 22:31:47 +0200
parents 9a948144dcc9
children e6a1410ce71d
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
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
11 // Get the name of the page
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
12 if (!isset($pagePath)) $pagePath = "pages/";
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
13 if (!isset($pageExt)) $pageExt = ".inc.php";
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
14 $pageName = isset($_GET["page"]) ? basename($_GET["page"]) : stGetSetting("defaultPage");
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
15
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
16
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 // Switch to https first, if needed
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
18 $isSecurePage = isset($pageName) && array_key_exists($pageName, $securePages);
365
2e0a0d93b8c1 Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents: 303
diff changeset
19 if (!stCheckHTTPS() && $isSecurePage)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 exit;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
39
1844df51a55c Improve authentication.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
25
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
26 // Check for cache-controlled pages
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
27 $noCache = $isSecurePage && $securePages[$pageName];
365
2e0a0d93b8c1 Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents: 303
diff changeset
28 if ($noCache)
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
29 stSetupCacheControl();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
31 stDebug("PG: '".$pageName."' is secure=".intval($isSecurePage).", noCache=".intval($noCache));
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
32
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
33
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
34 // Start output
34
8ecf7c04a837 Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
35 cmPrintPageHeader($pageTitle,
365
2e0a0d93b8c1 Sanitize secure pages scheme.
Matti Hamalainen <ccr@tnsp.org>
parents: 303
diff changeset
36 ($noCache ? " <meta http-equiv=\"Pragma\" content=\"no-cache\" />\n" : "").
232
aad9ededea6c Reorder some meta tags.
Matti Hamalainen <ccr@tnsp.org>
parents: 231
diff changeset
37 " <meta name=\"viewport\" content=\"width=device-width\" />\n");
0
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 // Initiate SQL database connection
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 if (!stConnectSQLDB())
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 {
39
1844df51a55c Improve authentication.
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
42 // Error occured, bail out early
34
8ecf7c04a837 Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
43 cmPrintPageFooter();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 exit;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
47
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
48 // Default to set default page if selected page does not exist
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
49 if (!file_exists($pagePath.$pageName.$pageExt))
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
50 $pageName = stGetSetting("defaultPage");
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
51 $currPagename = $pageName;
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
52
106
324f3a415237 Add extra HTML + sponsors box to layout.
Matti Hamalainen <ccr@tnsp.org>
parents: 104
diff changeset
53
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
54 // Fetch non-"hardcoded" settings from SQL database
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
55 stReloadSettings();
149
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".
610
167ca3827c31 Add some new HTML elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 603
diff changeset
63 " <div id=\"menuInner\">\n".
585
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
64 stGetMainPageLink("about", "About").
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
65 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
66 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
67 stGetMainPageLink("schedule", "Schedule", stGetSetting("showSchedule"));
585
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
68
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
69 if (stGetSetting("showAttendees"))
587
135efe0c3b49 Add new options for hiding/showing compo and schedule pages.
Matti Hamalainen <ccr@tnsp.org>
parents: 585
diff changeset
70 echo stGetMainPageLink("visitors", "Visitors");
585
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
71 else
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
72 if (stChkSetting("allowRegister"))
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
73 echo stGetMainPageLink("register", "Register");
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
74
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
75 $visibility = stAdmSessionAuth(TRUE);
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
76 echo
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
77 stGetMainPageLink("vote", "Vote", stGetSetting("allowVoting")).
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
78 stGetMainPageLink("results", "Results", $visibility || stGetSetting("showResults")).
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
79 stGetMainPageLink("admin.php", "Admin", $visibility || stGetSetting("showAdmin")).
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
80 stGetSetting("siteMenuFooter").
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
81 " </div>\n".
610
167ca3827c31 Add some new HTML elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 603
diff changeset
82 " </div>\n".
585
cec36fd24d21 Clean up the menu and HTML somewhat.
Matti Hamalainen <ccr@tnsp.org>
parents: 571
diff changeset
83 "</div>\n".
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
84 "<div id=\"infobox\">".$pageName."</div>\n";
44
72dcc1d48809 More work on the design.
Matti Hamalainen <ccr@tnsp.org>
parents: 43
diff changeset
85 ?>
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
86 <div id="mainContent">
588
e533955fa055 Add some more DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 587
diff changeset
87 <div id="mainContentInner">
e533955fa055 Add some more DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 587
diff changeset
88 <div id="mainContentWrap">
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 <?
699
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
90 if (file_exists($pagePath.$pageName.$pageExt))
9a948144dcc9 Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
91 include($pagePath.$pageName.$pageExt);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 ?>
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 </div>
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 </div>
588
e533955fa055 Add some more DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents: 587
diff changeset
95 </div>
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 <?
603
e48d5fbb3803 Adjust layout a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 588
diff changeset
97 echo stGetSetting("siteExtraHTML");
34
8ecf7c04a837 Update to match with common web code API.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
98 cmPrintPageFooter();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 ?>