annotate index.php @ 887:e6a1410ce71d

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