Mercurial > hg > fapweb
annotate admajax.php @ 208:8985d2bdb29b
More work on error handling etc.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 17 Nov 2013 20:04:50 +0200 |
parents | e31c42a9b574 |
children | 3870601c17c3 |
rev | line source |
---|---|
0 | 1 <? |
56 | 2 // |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
3 // FAPWeb Simple Demoparty System |
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
4 // Party administration page AJAX backend module |
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP) |
56 | 6 // |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
7 $sessionType = "admin"; |
175
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
8 require_once "mconfig.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
9 require_once "msite.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
169
diff
changeset
|
10 require_once "msession.inc.php"; |
0 | 11 |
12 // Check if we are allowed to execute | |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
3
diff
changeset
|
13 if (!stCheckHTTPS() || !stAdmSessionAuth()) |
0 | 14 { |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
15 stSetupCacheControl(); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
16 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
17 stSessionEnd(SESS_ADMIN); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
18 |
123
5837b9333964
Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents:
116
diff
changeset
|
19 header("Location: ".stGetSetting("defaultPage")); |
0 | 20 exit; |
21 } | |
22 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
23 stSetupCacheControl(); |
0 | 24 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
25 // Initiate SQL database connection |
0 | 26 if (!stConnectSQLDB()) |
27 die("Could not connect to SQL database."); | |
28 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
29 // 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
|
30 stReloadSettings(); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
31 |
0 | 32 |
16 | 33 function saveButton() |
34 { | |
35 return "<input type=\"submit\" value=\" Save \" />\n"; | |
36 } | |
37 | |
38 | |
0 | 39 // XMLHttp responses |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
40 $type = stGetRequestItem("type", ""); |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
41 switch (stGetRequestItem("action", "")) |
0 | 42 { |
43 case "dump": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
44 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
45 // Perform generic data dump |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
46 // |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
47 if (($res = stExecSQLCond( |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
48 "SELECT * FROM attendees WHERE email NOT NULL AND email != '' ORDER BY regtime DESC")) !== FALSE) |
0 | 49 { |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
50 stSetStatus(200, "Dump OK."); |
0 | 51 $out1 = array(); |
52 $out2 = array(); | |
53 | |
54 foreach ($res as $item) | |
55 { | |
133 | 56 $out1[] = chentities($item["name"])." <".chentities($item["email"]).">"; |
57 $out2[] = chentities($item["email"]); | |
0 | 58 } |
59 | |
60 echo "<br /><hr />". | |
61 implode(", ", $out1)."<br /><hr /><br />". | |
62 implode("<br />", $out1)."<br /><hr /><br />". | |
63 implode(", ", $out2)."<br /><hr /><br />". | |
64 implode("<br />", $out2)."<br /><hr />"; | |
65 | |
66 } | |
67 break; | |
68 | |
69 case "get": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
70 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
71 // Get specific data |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
72 // |
0 | 73 switch ($type) |
74 { | |
75 case "news": | |
76 $sql = "SELECT * FROM news ORDER BY utime DESC"; | |
77 break; | |
78 | |
79 case "attendees": | |
80 $sql = "SELECT * FROM attendees ORDER BY regtime DESC"; | |
81 break; | |
82 | |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
83 case "attendee": |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
84 $res = stFetchSQL(stPrepareSQL("SELECT * FROM attendees WHERE id=%D", "id")); |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
85 if ($res !== FALSE) |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
86 stPrintAttendee($res, -1, FALSE, TRUE, stGetRequestItem("edit", FALSE)); |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
87 break; |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
88 |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
89 case "voters": |
116
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
90 $sqlJoins = ""; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
91 switch (stGetSetting("voteKeyMode")) |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
92 { |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
93 case VOTE_FREELY: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
94 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
95 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
96 case VOTE_ACTIVATE: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
97 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
98 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
99 case VOTE_ASSIGN: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
100 $sqlJoins = "LEFT JOIN attendees ON votekeys.voter_id=attendees.id "; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
101 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
102 } |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
103 $sql = "SELECT * FROM votekeys ".$sqlJoins."ORDER BY votekeys.id ASC"; |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
104 break; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
105 |
0 | 106 case "compos": |
107 $sql = "SELECT * FROM compos ORDER BY id DESC"; | |
108 break; | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
109 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
110 case "settings": |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
111 $prefix = "st"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
112 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
113 echo |
16 | 114 "<h1>Site settings</h1>\n". |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
115 "<form method=\"post\" action=\"\" onsubmit=\"return updateSettings()\">\n". |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
116 "<table>\n"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
117 foreach (stExecSQL("SELECT * FROM settings WHERE vtype<>".VT_TEXT) as $item) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
118 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
119 echo |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
120 " <tr>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
121 " <td>"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
122 $id = $item["key"]; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
123 switch ($item["vtype"]) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
124 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
125 case VT_INT: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
126 echo stGetFormTextInput(10, 10, "", $id, $prefix, $item["vint"]); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
127 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
128 case VT_STR: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
129 echo stGetFormTextInput(40, 128, "", $id, $prefix, $item["vstr"]); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
130 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
131 case VT_BOOL: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
132 echo stGetFormCheckBoxInput("", $id, $prefix, $item["vint"], ""); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
133 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
134 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
135 echo "</td>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
136 " <td>".$item["desc"]."</td>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
137 " </tr>\n"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
138 } |
16 | 139 echo "</table>\n".saveButton(); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
140 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
141 foreach (stExecSQL("SELECT * FROM settings WHERE vtype=".VT_TEXT) as $item) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
142 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
143 echo "<h2>".chentities($item["desc"])."</h2>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
144 stGetFormTextArea(10, 60, "", $item["key"], $prefix, $item["vtext"]). |
16 | 145 "\n<br />\n".saveButton(); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
146 } |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
147 echo "</form>\n"; |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
148 break; |
0 | 149 |
150 case "entries": | |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
151 stGetCompoList(FALSE, FALSE); |
0 | 152 |
153 foreach ($compos as $id => $compo) | |
154 { | |
155 echo | |
156 "<form>\n". | |
157 " <table class=\"misc\">\n". | |
158 " <tr>\n". | |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
159 " <th colspan=\"5\">#".$id." - ".chentities($compo["name"])."</th>\n". |
0 | 160 " </tr>\n". |
161 " <tr>\n". | |
113
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
162 " <th style=\"width:4%;\">ID#</th>\n". |
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
163 " <th style=\"width:4%;\">S#</th>\n". |
0 | 164 " <th>Title</th>\n". |
29 | 165 " <th>Author(s)</th>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
166 " <th>Filename</th>\n". |
0 | 167 " <th>Actions</th>\n". |
168 " </tr>\n"; | |
169 | |
170 $prefix = "en"; | |
171 foreach ($compo["entries"] as $eid => $entry) | |
172 { | |
173 echo | |
174 " <tr id=\"entry".$eid."\">\n". | |
113
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
175 " <td>".$eid."</td>\n". |
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
176 " <td>".($entry["show_id"] > 0 ? $entry["show_id"] : "-")."</td>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
177 " <td>".stGetFormTextInput(30, 64, "name", $eid, "en", $entry["name"])."</td>\n". |
29 | 178 " <td>".stGetFormTextInput(30, 64, "author", $eid, "en", $entry["author"])."</td>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
179 " <td>".stGetFormTextInput(20, 64, "filename", $eid, "en", $entry["filename"])."</td>\n". |
0 | 180 " <td>". |
113
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
181 stGetFormButtonInput("delete", $eid, $prefix, " Del ", "deleteEntry(".$eid.")"). |
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
182 stGetFormTextInput(3, 3, "compo_id", $eid, "en", $id). |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
183 stGetFormButtonInput("update", $eid, $prefix, " Upd ", "updateEntry(".$eid.")"). |
0 | 184 "</td>\n". |
185 " </tr>\n"; | |
186 } | |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
187 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
188 $prefix = "ne"; |
0 | 189 echo |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
190 " <tr>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
191 " <td></td>\n". |
113
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
192 " <td></td>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
193 " <td>".stGetFormTextInput(30, 64, "name", $id, "ne", "")."</td>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
194 " <td>".stGetFormTextInput(30, 64, "author", $id, "ne", "")."</td>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
195 " <td>".stGetFormTextInput(20, 64, "filename", $id, "ne", "")."</td>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
196 " <td>".stGetFormButtonInput("add", $id, $prefix, " Add new ", "addEntry(".$id.")")."</td>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
197 " </tr>\n". |
0 | 198 " </table>\n". |
199 "</form>\n"; | |
200 } | |
201 break; | |
202 } | |
203 | |
56 | 204 // |
205 // Perform query if we need to, output results | |
206 // | |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
207 if (isset($sql) && ($res = stExecSQLCond($sql)) !== FALSE) |
0 | 208 { |
209 if ($type == "news") | |
210 { | |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
211 echo |
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
212 "<form method=\"post\" action=\"\" onsubmit=\"return addNews()\">\n". |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
213 " ".stGetFormTextInput(40, SET_LEN_NEWS_TITLE, "", "nntitle", "", "")."<br />\n". |
204 | 214 " ".stGetFormTextArea(5, 60, "", "nntext", "", "")."<br />\n". |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
215 " ".stGetFormTextInput(20, SET_LEN_NEWS_AUTHOR, "", "nnauthor", "", "orgaz")."\n". |
204 | 216 " ".stGetFormSubmitInput("nnadd", "Add post")."\n". |
217 " ".stGetFormButtonInput("", "", "", "Clear", "this.form.reset()")."\n". | |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
218 "</form>\n". |
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
219 "<hr />\n"; |
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
220 |
0 | 221 foreach ($res as $item) |
222 { | |
223 $id = $item["id"]; | |
224 stPrintNewsItem($item, | |
225 "<br />". | |
226 " <button class=\"button\" id=\"ndel".$id. | |
227 "\" type=\"button\" onclick=\"deleteNews(".$id. | |
228 ")\">Delete</button>\n" | |
229 ); | |
230 } | |
231 } | |
232 else | |
233 if ($type == "attendees") | |
234 { | |
90 | 235 // For adding a new one |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
236 $prefix = "ne"; |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
237 echo |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
238 "<table>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
239 " <tr>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
240 " <th>Name</th>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
241 " <th>Groups</th>\n". |
82
a071dacdcfc5
Change order of table fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
242 " <th>Oneliner</th>\n". |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
243 " <th>E-mail</th>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
244 " <th>Actions</th>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
245 " </tr>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
246 " <tr>\n". |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
247 " <td>".stGetFormTextInput(20, SET_LEN_USERNAME, "name", "x", $prefix, "")."</td>\n". |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
248 " <td>".stGetFormTextInput(20, SET_LEN_GROUPS, "groups", "x", $prefix, "")."</td>\n". |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
249 " <td>".stGetFormTextInput(30, SET_LEN_ONELINER, "oneliner", "x", $prefix, "")."</td>\n". |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
250 " <td>".stGetFormTextInput(20, SET_LEN_EMAIL, "email", "x", $prefix, "")."</td>\n". |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
251 " <td>".stGetFormButtonInput("add", "", $prefix, " Add new ", "addAttendee()")."</td>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
252 " </tr>\n". |
169
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
253 "</table>\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
254 "<hr />\n"; |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
255 |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
256 // List of attendees |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
257 echo |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
258 "<table class=\"attendees\">\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
259 " <tr>\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
260 " <th class=\"name\">Name</th>\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
261 " <th class=\"groups\">Groups</th>\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
262 " <th class=\"regtime\">Registered</th>\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
263 " <th class=\"oneliner\">Oneliner</th>\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
264 " <th class=\"email\">E-mail</th>\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
265 " <th>Actions</th>\n". |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
266 " </tr>\n"; |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
267 |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
268 $row = 0; |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
269 foreach ($res as $item) |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
270 { |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
271 stPrintAttendee($item, $row++, TRUE, TRUE, FALSE); |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
272 } |
169
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
273 |
8db98399bb38
Put the "new attendee" form above the current attendees in admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
136
diff
changeset
|
274 echo |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
275 "</table>\n"; |
0 | 276 } |
277 else | |
116
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
278 if ($type == "voters") |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
279 { |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
280 switch (stGetSetting("voteKeyMode")) |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
281 { |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
282 case VOTE_FREELY: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
283 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
284 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
285 case VOTE_ACTIVATE: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
286 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
287 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
288 case VOTE_ASSIGN: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
289 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
290 } |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
291 // List of votekeys |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
292 echo |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
293 "<table class=\"attendees\">\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
294 " <tr>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
295 " <th class=\"name\">Name</th>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
296 " <th class=\"groups\">Groups</th>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
297 " <th class=\"email\">E-mail</th>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
298 " <th class=\"\">Key</th>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
299 " </tr>\n"; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
300 $row = 0; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
301 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
302 echo |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
303 "</table>\n"; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
304 } |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
305 else |
0 | 306 if ($type == "compos") |
307 { | |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
308 echo |
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
309 "<form method=\"post\" action=\"\" onsubmit=\"return addCompo()\">\n". |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
310 " ".stGetFormTextInput(64, SET_LEN_COMPO_NAME, "", "ncname", "", "")."<br />\n". |
203 | 311 " ".stGetFormTextArea(5, 60, "", "ncdescription", "", "")."<br />\n". |
312 " ".stGetFormSubmitInput("nccompo", "Add compo")."\n". | |
313 " ".stGetFormButtonInput("", "", "", "Clear", "this.form.reset()")."\n". | |
201
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
314 "</form>\n". |
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
315 "<hr />\n"; |
a4be19c4d99d
Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents:
198
diff
changeset
|
316 |
0 | 317 foreach ($res as $item) |
318 { | |
319 $id = $item["id"]; | |
320 $prefix = "co"; | |
321 echo | |
203 | 322 "<div id=\"compo".$id."\">\n". |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
323 " <h2>#".$id." - ".chentities($item["name"])."</h2>\n". |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
324 " ".stGetFormTextInput(40, SET_LEN_COMPO_NAME, "name", $id, $prefix, $item["name"])."\n". |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
325 " ".stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible")."\n". |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
326 " ".stGetFormCheckBoxInput("showAuthors", $id, $prefix, $item["showAuthors"], "Show authors")."\n". |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
327 " ".stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting")."<br />\n". |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
328 " ".stGetFormTextArea(5, 60, "description", $id, $prefix, $item["description"])."\n<br />\n". |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
329 " ".stGetFormButtonInput("update", $id, $prefix, "Update", "updateCompo(".$id.")")."\n". |
203 | 330 "</div>\n". |
331 "<hr />\n"; | |
0 | 332 } |
333 } | |
334 } | |
335 break; | |
336 | |
337 case "delete": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
338 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
339 // Delete entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
340 // |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
341 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
0 | 342 { |
343 if ($type == "news") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
344 { |
0 | 345 $sql = stPrepareSQL("DELETE FROM news WHERE id=%d AND persist=0", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
346 stExecSQLCond($sql, "OK, news item ".$id." deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
347 } |
0 | 348 else |
349 if ($type == "attendees") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
350 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
351 // Attendees require some more work |
0 | 352 $sql = stPrepareSQL("DELETE FROM attendees WHERE id=%d", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
353 stExecSQLCond($sql, "OK, attendee ".$id." deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
354 |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
355 $sql = stPrepareSQL("DELETE FROM votes WHERE voter_id=%d", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
356 stExecSQLCond($sql, "OK, attendee ".$id." votes deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
357 } |
0 | 358 else |
359 if ($type == "entries") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
360 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
361 // .. as do compo entries |
0 | 362 $sql = stPrepareSQL("DELETE FROM entries WHERE id=%d", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
363 stExecSQLCond($sql, "OK, entry ".$id." deleted."); |
0 | 364 |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
365 $sql = stPrepareSQL("DELETE FROM votes WHERE entry_id=%d", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
366 stExecSQLCond($sql, "OK, entry ".$id." votes deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
367 } |
0 | 368 } |
369 break; | |
370 | |
371 case "add": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
372 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
373 // Add new entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
374 // |
26
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
375 if ($type == "news" && stChkRequestItem("text") && |
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
376 stChkRequestItem("author") && stChkRequestItem("title")) |
0 | 377 { |
378 $sql = stPrepareSQL( | |
379 "INSERT INTO news (utime,title,text,author) VALUES (%d,%S,%Q,%S)", | |
380 time(), "title", "text", "author"); | |
381 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
382 stExecSQLCond($sql, "OK, news item added."); |
0 | 383 } |
384 else | |
26
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
385 if ($type == "compo" && stChkRequestItem("name") && |
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
386 stChkRequestItem("description")) |
0 | 387 { |
388 $sql = stPrepareSQL( | |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
389 "INSERT INTO compos (name,description,visible,voting,showAuthors) VALUES (%S,%Q,0,0,0)", |
26
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
390 "name", "description"); |
0 | 391 |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
392 stExecSQLCond($sql, "OK, compo added."); |
0 | 393 } |
394 else | |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
395 if ($type == "attendees" && stCheckRequestUserData(TRUE)) |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
396 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
397 $sql = stPrepareSQL( |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
398 "INSERT INTO attendees (regtime,name,groups,oneliner,email) VALUES (%d,%S,%S,%S,%S)", |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
399 time(), "name", "groups", "oneliner", "email"); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
400 |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
401 stExecSQLCond($sql, "OK, attendee added."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
402 } |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
403 else |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
404 if ($type == "entry" && stChkRequestItem("name") && |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
405 stChkRequestItem("author") && stChkRequestItem("compo_id")) |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
406 { |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
407 $sql = stPrepareSQL( |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
408 "INSERT INTO entries (name,author,compo_id,filename) VALUES (%S,%S,%D,%S)", |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
409 "name", "author", "compo_id", "filename"); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
410 |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
411 stExecSQLCond($sql, "OK, entry added."); |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
412 } |
0 | 413 break; |
414 | |
415 case "update": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
416 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
417 // Update existing entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
418 // |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
419 if ($type == "attendees" && stCheckRequestUserData(TRUE)) |
0 | 420 { |
421 $sql = stPrepareSQLUpdate("attendees", | |
422 "WHERE id=".intval(stGetRequestItem("id")), | |
423 array( | |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
424 "name" => "S", |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
425 "groups" => "S", |
0 | 426 "email" => "S", |
427 "oneliner" => "S", | |
428 )); | |
429 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
430 stExecSQLCond($sql, "OK, attendee updated."); |
0 | 431 } |
432 else | |
433 if ($type == "news" && stChkRequestItem("id") && | |
434 stChkRequestItem("text") && stChkRequestItem("author") && | |
435 stChkRequestItem("title")) | |
436 { | |
437 $sql = stPrepareSQLUpdate("news", | |
438 "WHERE id=".intval(stGetRequestItem("id")), | |
439 array( | |
440 "title" => "S", | |
441 "text" => "Q", | |
442 "author" => "S" | |
443 )); | |
444 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
445 stExecSQLCond($sql, "OK, news item updated."); |
0 | 446 } |
447 else | |
448 if ($type == "compo" && stChkRequestItem("id") && | |
449 stChkRequestItem("name") && stChkRequestItem("description") && | |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
450 stChkRequestItem("visible") && stChkRequestItem("voting") && |
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
451 stChkRequestItem("showAuthors")) |
0 | 452 { |
453 $sql = stPrepareSQLUpdate("compos", | |
454 "WHERE id=".intval(stGetRequestItem("id")), | |
455 array( | |
456 "name" => "S", | |
457 "description" => "Q", | |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
458 "visible" => "B", |
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
459 "voting" => "B", |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
460 "showAuthors" => "B", |
0 | 461 )); |
462 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
463 stExecSQLCond($sql, "OK, compo updated."); |
0 | 464 } |
465 else | |
466 if ($type == "entry" && stChkRequestItem("id") && | |
30
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
467 stChkRequestItem("name") && stChkRequestItem("author") && |
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
468 stChkRequestItem("compo_id")) |
0 | 469 { |
112
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
470 $cid = stGetRequestItem("compo_id"); |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
471 if (stFetchSQLColumn("SELECT id FROM compos WHERE id=".$cid) === FALSE) |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
472 { |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
473 stError("No such compo id."); |
112
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
474 } |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
475 else |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
476 { |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
477 $sql = stPrepareSQLUpdate("entries", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
478 "WHERE id=".intval(stGetRequestItem("id")), |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
479 array( |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
480 "name" => "S", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
481 "author" => "S", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
482 "filename" => "S", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
483 "compo_id" => "D", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
484 )); |
0 | 485 |
112
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
486 stExecSQLCond($sql, "OK, entry updated."); |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
487 } |
0 | 488 } |
489 else | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
490 if ($type == "settings") |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
491 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
492 foreach (stExecSQL("SELECT * FROM settings") as $item) |
198
96ab189e5c03
Add some new helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
493 if (($val = stGetRequestItem($item["key"], FALSE)) !== FALSE) |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
494 { |
198
96ab189e5c03
Add some new helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
495 $sql = "UPDATE settings SET ".stGetSettingSQL($item, $val)." WHERE key=".$db->quote($item["key"]); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
496 stExecSQLCond($sql, "OK, setting updated."); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
497 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
498 } |
0 | 499 break; |
500 | |
501 default: | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
502 stSetStatus(404, "Not Found"); |
0 | 503 break; |
504 } | |
505 | |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
506 |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
507 if ($statusSet) |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
508 |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
509 |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
510 if ($errorSet) |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
511 echo $errorMsg; |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
512 |
0 | 513 ?> |