Mercurial > hg > fapweb
annotate admin.php @ 614:7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 01 Nov 2014 02:49:03 +0200 |
parents | a42efdc2cca7 |
children | aad32d21091f |
rev | line source |
---|---|
0 | 1 <? |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
126
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:
126
diff
changeset
|
4 // Party administration page frontend module |
565 | 5 // (C) Copyright 2012-2014 Tecnic Software productions (TNSP) |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
126
diff
changeset
|
6 // |
32 | 7 $sessionType = "admin"; |
175
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
8 require_once "mconfig.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
9 require_once "msite.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
10 require_once "msession.inc.php"; |
384
357b81e39ab3
Rename majax.php -> majax.inc.php.
Matti Hamalainen <ccr@tnsp.org>
parents:
378
diff
changeset
|
11 require_once "majax.inc.php"; |
32 | 12 |
614
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
13 |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
14 function stCreateSettingsData() |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
15 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
16 $args = array(); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
17 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
18 if (($res = stExecSQL("SELECT * FROM settings")) !== FALSE) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
19 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
20 foreach ($res as $item) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
21 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
22 switch ($item["vtype"]) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
23 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
24 case VT_STR: |
298
2f35c4b90ee7
Fix site settings javascript generator.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
25 case VT_TEXT: $type = 1; break; |
2f35c4b90ee7
Fix site settings javascript generator.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
26 case VT_INT: $type = 2; break; |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
27 case VT_BOOL: $type = 3; break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
28 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
29 $args[] = "\"".$item["key"]."\":".$type; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
30 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
31 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
32 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
33 echo |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
34 "\n". |
601 | 35 "function jsUpdateSettings()\n". |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
36 "{\n". |
346
c922e5200c55
Rename makePostArgs() to jsMakePostArgs().
Matti Hamalainen <ccr@tnsp.org>
parents:
345
diff
changeset
|
37 " var args = jsMakePostArgs({".implode(",", $args)."}, \"st\", \"\");\n". |
342
3175ec252c73
Rename sendPOSTRequest() to jsSendPOSTRequest().
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
38 " jsSendPOSTRequest(\"action=update&type=settings&\"+args);\n". |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
39 " return false;\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
40 "}\n"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
41 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
42 |
614
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
43 |
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
44 function stLoginContent() |
347 | 45 { |
614
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
46 echo "<div id=\"adminContent\">\n<div id=\"adminLogin\">"; |
347 | 47 } |
48 | |
614
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
49 function stLoginFooter() |
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
50 { |
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
51 echo "</div>\n"; |
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
52 cmPrintPageFooter(); |
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
53 } |
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
54 |
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
55 |
347 | 56 // Switch to https first, if needed |
57 if (!stCheckHTTPS()) | |
58 { | |
59 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); | |
60 exit; | |
61 } | |
62 | |
63 // Start output | |
591
f7078755dff5
Fix CSS paths for admin and print pages.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
64 $pageCSS = "css/admin.css"; |
347 | 65 cmPrintPageHeader("FAPWeb Administration", |
364 | 66 " <meta http-equiv=\"Pragma\" content=\"no-cache\" />\n", |
347 | 67 FALSE); |
68 | |
69 | |
70 // Initiate SQL database connection | |
71 if (!stConnectSQLDB()) | |
72 { | |
73 // Error occured, bail out early | |
74 cmPrintPageFooter(); | |
75 exit; | |
76 } | |
77 | |
78 // Fetch non-"hardcoded" settings from SQL database | |
79 stReloadSettings(); | |
80 | |
0 | 81 // Check if sessions are enabled |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
82 if (!stChkSetting("admPassword")) |
0 | 83 { |
614
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
84 stLoginContent(); |
171
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
85 echo |
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
86 "<h1>Oh noes, admin configuration not done!</h1>\n". |
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
87 "<p>Better go and prod that, so you get to use the fine admin interface.</p>\n"; |
614
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
88 stLoginFooter(); |
347 | 89 exit; |
0 | 90 } |
91 else | |
107 | 92 if (!stAdmSessionAuth(FALSE)) |
0 | 93 { |
94 // Perform authentication if we are not in session already | |
614
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
95 stLoginContent(); |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
96 echo |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
97 "<h1>Party admin login</h1>\n". |
596
b09fdf99b54b
Add return to main pages link to admin login.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
98 "<p>Please use illegal telepathy over HTTP to provide a ". |
b09fdf99b54b
Add return to main pages link to admin login.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
99 "password to enter the party administration systembolaget.</p>\n". |
b09fdf99b54b
Add return to main pages link to admin login.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
100 "\n". |
347 | 101 " ".stGetFormStart("admlogin", "admlogin.php"). |
102 " ".stGetFormHiddenInput("mode", "check")."\n". | |
103 " ".stGetFormPasswordInput("admpass", "", "", "autofocus=\"autofocus\"")."\n". | |
104 " ".stGetFormSubmitInput("submit", "Login")."\n". | |
596
b09fdf99b54b
Add return to main pages link to admin login.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
105 " </form>\n". |
b09fdf99b54b
Add return to main pages link to admin login.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
106 "\n". |
b09fdf99b54b
Add return to main pages link to admin login.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
107 "<p>[<a href=\"".stGetSetting("defaultPage")."\">Return to the main page</a>].</p>\n"; |
614
7987aa59c2a0
Clean up admin login a bit, and add some DOM elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
108 stLoginFooter(); |
347 | 109 exit; |
0 | 110 } |
107 | 111 else |
0 | 112 { |
113 ?> | |
114 <script type="text/javascript"> | |
445
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
115 // <? stCreateSettingsData(); stCommonAJAX("admajax.php", "admlogout.php", FALSE, TRUE); ?> |
0 | 116 </script> |
599
eebbc96d7fe5
Move javascript code from admin.php to a separate file.
Matti Hamalainen <ccr@tnsp.org>
parents:
596
diff
changeset
|
117 <script type="text/javascript" src="admin.js"></script> |
0 | 118 |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
119 <!-- ========================== --> |
0 | 120 |
427 | 121 <div id="adminPopup"></div> |
345 | 122 <div id="adminContent"> |
123 | |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 <div id="nstatus">-</div> |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
189
diff
changeset
|
125 <div id="tabHeadersCC" class="tabHeaders"></div> |
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
189
diff
changeset
|
126 <div id="tabContentsCC" class="tabContents"></div> |
171
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
127 |
0 | 128 <script type="text/javascript"> |
445
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
129 jsRegisterTab("CC", "Settings", "Settings"); |
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
130 jsRegisterTab("CC", "News", "News"); |
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
131 jsRegisterTab("CC", "Attendees", "Attendees"); |
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
132 jsRegisterTab("CC", "Voting", "Voting"); |
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
133 jsRegisterTab("CC", "Compos", "Compos"); |
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
134 jsRegisterTab("CC", "Entries", "Entries"); |
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
135 jsRegisterTab("CC", "InfoSys", "Infosystem"); |
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
136 jsUpdateTabList("CC", |
263 | 137 "<a class=\"admin\" href=\"admlogout.php\">Logout</a> " + |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
189
diff
changeset
|
138 "<a class=\"admin\" href=\"about\">Mainpage</a>"); |
445
cf7053f04e88
Move tab handling code to majax module.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
139 jsSwitchActiveTab("CC", "Settings"); |
0 | 140 </script> |
171
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
141 <? |
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
142 } |
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
143 |
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
144 cmPrintPageFooter(); |
705dabdc37d4
Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
145 ?> |