Mercurial > hg > fapweb
annotate msite.inc.php @ 1118:29206517d32e
Cosmetic.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 14 Oct 2019 10:49:10 +0300 |
parents | 24e6915fc0fb |
children | b2bca5f6d0ff |
rev | line source |
---|---|
1071 | 1 <?php |
0 | 2 // |
571
ce11ea112a65
Change the header blurb a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
570
diff
changeset
|
3 // FAPWeb - Simple Web-based Demoparty Management System |
33 | 4 // Generic and miscellaneous site support code |
1072 | 5 // (C) Copyright 2012-2017 Tecnic Software productions (TNSP) |
0 | 6 // |
175
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
7 require_once "msitegen.inc.php"; |
1115
24e6915fc0fb
Move database field length definitions from msite.inc.php to dbdefs.inc.php
Matti Hamalainen <ccr@tnsp.org>
parents:
1114
diff
changeset
|
8 require_once "dbdefs.inc.php"; |
51 | 9 |
184
1b30c2107e5b
Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
10 // Define modes of party information display system |
410
298822ed0420
Change display mode constant values.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
11 define("SMODE_DISABLED", 0); |
298822ed0420
Change display mode constant values.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
12 define("SMODE_ROTATE", 1); |
298822ed0420
Change display mode constant values.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
13 define("SMODE_COMPO", 2); |
139
75cf14ee99a7
More work on party information system.
Matti Hamalainen <ccr@tnsp.org>
parents:
135
diff
changeset
|
14 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
15 |
508
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
16 // |
815 | 17 // File format classes |
18 // | |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
19 define("EFILE_NONE", 0); |
815 | 20 define("EFILE_IMAGE", 1); |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
21 define("EFILE_AUDIO", 2); // Also preview types |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
22 |
824 | 23 define("EFILE_VIDEO", 3); |
839
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
24 define("EFILE_TEXT", 4); |
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
25 define("EFILE_BINARY", 5); |
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
26 define("EFILE_ARCHIVE", 6); |
703
242cb053fbb2
Add array/list of preview types and descriptions for them.
Matti Hamalainen <ccr@tnsp.org>
parents:
702
diff
changeset
|
27 |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
28 |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
29 // |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
30 // Entry preview type (value) |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
31 // |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
32 $previewTypeList = array( |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
33 EFILE_NONE => array("No previews" , "Default"), |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
34 EFILE_IMAGE => array("Image file" , "Image"), |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
35 EFILE_AUDIO => array("Audio file" , "Audio"), |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
36 ); |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
37 |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
38 |
702 | 39 // |
40 // Entry flags (bitfield) | |
41 // | |
998
b0ef1c1b0eeb
Add a new entry flag, update comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
42 define("EFLAG_DISQUALIFIED" , 1); // Entry is disqualified |
b0ef1c1b0eeb
Add a new entry flag, update comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
43 define("EFLAG_PROBLEMS" , 2); // Has some problems |
b0ef1c1b0eeb
Add a new entry flag, update comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
44 define("EFLAG_LOCKED" , 4); // Can't be edited by non-admins |
508
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
45 |
690
bad79296eb34
Cleanups, rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
680
diff
changeset
|
46 $entryFlagsList = array( |
bad79296eb34
Cleanups, rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
680
diff
changeset
|
47 EFLAG_DISQUALIFIED => array("Disqualified", "img/disqualified.png"), |
bad79296eb34
Cleanups, rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
680
diff
changeset
|
48 EFLAG_PROBLEMS => array("Has problems", "img/problems.png"), |
998
b0ef1c1b0eeb
Add a new entry flag, update comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
980
diff
changeset
|
49 EFLAG_LOCKED => array("LOCKED", "img/locked.png"), |
690
bad79296eb34
Cleanups, rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
680
diff
changeset
|
50 ); |
bad79296eb34
Cleanups, rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents:
680
diff
changeset
|
51 |
508
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
52 |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
53 // |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
54 // Results output flags |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
55 // |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
56 define("RFLAG_NORMAL", 0); |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
57 define("RFLAG_DISQUALIFIED", 1); |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
58 define("RFLAG_HIDDEN_COMPOS", 2); |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
59 |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
60 // |
508
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
61 // Competition types |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
62 // |
606 | 63 define("COMPO_NORMAL", 0); // Normal voting compo, points determine placement |
64 define("COMPO_POINTS", 1); // Assigned points, points determines placement (no voting) | |
508
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
65 define("COMPO_ASSIGN", 2); // Assigned places (no voting) |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
66 |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
67 |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
68 $compoModeData = array( |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
69 COMPO_NORMAL => array("Normal", |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
70 "Normal voting compo.", |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
71 ), |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
72 COMPO_POINTS => array("Points", |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
73 "Assigned points (no voting).", |
745
7ac6d1fdc078
Add two new fields to compoModeData.
Matti Hamalainen <ccr@tnsp.org>
parents:
742
diff
changeset
|
74 "Points", |
508
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
75 ), |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
76 COMPO_ASSIGN => array("Assigned", |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
77 "Assigned places (no points, no voting).", |
745
7ac6d1fdc078
Add two new fields to compoModeData.
Matti Hamalainen <ccr@tnsp.org>
parents:
742
diff
changeset
|
78 "Place", |
508
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
79 ), |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
80 ); |
b6fe46c86ff3
Add definitions for entry flags and compo types. Not used yet (though the
Matti Hamalainen <ccr@tnsp.org>
parents:
506
diff
changeset
|
81 |
641 | 82 |
94
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
83 // |
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
84 // Different voting modes |
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
85 // |
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
86 define("VOTE_FREELY", 0); |
274
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
87 define("VOTE_ACTIVATE", 1); |
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
88 define("VOTE_ASSIGN", 2); |
94
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
89 |
274
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
90 $voteModeData = array( |
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
91 VOTE_FREELY => array("Freeform voting", |
1092
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
92 "User keys are not tied to attendees, and do not need to be activated. ". |
274
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
93 "Take one printed key slip, give it to attendee." |
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
94 ), |
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
95 VOTE_ACTIVATE => array("Key activation", |
1092
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
96 "User keys are not tied to attendees, but require manual activation. ". |
274
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
97 "Take one printed key slip, find it by the index number in the list below, set to activated. ". |
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
98 "Give key slip to attendee." |
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
99 ), |
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
100 VOTE_ASSIGN => array("Assigned keys", |
1092
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
101 "User keys are tied to attendees, activated by assigning the key to attendee. ". |
307
c0d573a5de5b
Add procedure description to assigned keys mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
282
diff
changeset
|
102 "Take one printed key slip, find attendee in the list below, enter key ID number, assign, check. ". |
c0d573a5de5b
Add procedure description to assigned keys mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
282
diff
changeset
|
103 "Give key slip to attendee." |
274
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
104 ), |
81507072f25d
Add explanations of the different voting modes.
Matti Hamalainen <ccr@tnsp.org>
parents:
261
diff
changeset
|
105 ); |
94
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
106 |
6edd7d623eab
Start adding votekey modes code.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
107 |
535 | 108 // |
807 | 109 // Data about the file types we use |
110 // | |
809 | 111 $fileTypeData = array( |
807 | 112 "PNG" => array( |
815 | 113 "class" => EFILE_IMAGE, |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
114 "type" => EFILE_IMAGE, |
807 | 115 "mime" => "image/png", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
116 "fext" => "png", |
807 | 117 ), |
118 "JPEG" => array( | |
815 | 119 "class" => EFILE_IMAGE, |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
120 "type" => EFILE_IMAGE, |
807 | 121 "mime" => "image/jpeg", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
122 "fext" => "jpg", |
807 | 123 ), |
124 "GIF" => array( | |
815 | 125 "class" => EFILE_IMAGE, |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
126 "type" => EFILE_IMAGE, |
807 | 127 "mime" => "image/gif", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
128 "fext" => "gif", |
807 | 129 ), |
130 | |
131 "MP3" => array( | |
815 | 132 "class" => EFILE_AUDIO, |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
133 "type" => EFILE_AUDIO, |
807 | 134 "mime" => "audio/mpeg", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
135 "fext" => "mp3", |
808 | 136 "test" => "MPEG ADTS, layer III", |
807 | 137 ), |
138 "OggVorbis" => array( | |
815 | 139 "class" => EFILE_AUDIO, |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
140 "type" => EFILE_AUDIO, |
807 | 141 "mime" => "audio/ogg; codecs=vorbis", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
142 "fext" => "ogg", |
808 | 143 "test" => "Ogg data, Vorbis audio", |
144 ), | |
815 | 145 "FLAC" => array( |
146 "class" => EFILE_AUDIO, | |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
147 "type" => EFILE_AUDIO, |
815 | 148 "mime" => "audio/x-flac", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
149 "fext" => "flac", |
815 | 150 ), |
151 "WAV" => array( | |
152 "class" => EFILE_AUDIO, | |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
153 "type" => EFILE_AUDIO, |
815 | 154 "mime" => "audio/x-wav", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
155 "fext" => "wav", |
815 | 156 ), |
808 | 157 |
158 // Special cases | |
159 "ILBM" => array( | |
815 | 160 "class" => EFILE_IMAGE, |
808 | 161 "mime" => "gfx", // Special cases to be converted through gfxconv .. |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
162 "fext" => "lbm", |
936 | 163 "test" => "^IFF data, ILBM", |
164 ), | |
165 "ANIM" => array( | |
166 "class" => EFILE_IMAGE, | |
167 "mime" => "image/x-anim", // Special cases to be converted through gfxconv .. | |
168 "fext" => "anim", | |
169 "test" => "^IFF data, ILBM", | |
808 | 170 ), |
171 "PCX" => array( | |
815 | 172 "class" => EFILE_IMAGE, |
808 | 173 "mime" => "image/x-pcx", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
174 "fext" => "pcx", |
808 | 175 "test" => "^PCX ver\. 3\.0", |
176 ), | |
177 | |
178 "PTMOD" => array( | |
815 | 179 "class" => EFILE_AUDIO, |
808 | 180 "mime" => "audio/x-mod", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
181 "fext" => "mod", |
808 | 182 "test" => "^\d+-channel Protracker module", |
183 ), | |
937 | 184 "FTMOD" => array( |
815 | 185 "class" => EFILE_AUDIO, |
808 | 186 "mime" => "audio/x-mod", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
187 "fext" => "mod", |
808 | 188 "test" => "^\d+-channel Fasttracker module", |
189 ), | |
190 "S3M" => array( | |
815 | 191 "class" => EFILE_AUDIO, |
808 | 192 "mime" => "audio/x-mod", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
193 "fext" => "s3m", |
808 | 194 "test" => "^ScreamTracker III Module", |
195 ), | |
196 "XM" => array( | |
815 | 197 "class" => EFILE_AUDIO, |
808 | 198 "mime" => "audio/x-mod", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
199 "fext" => "xm", |
808 | 200 "test" => "^Fasttracker II module", |
201 ), | |
202 "IT" => array( | |
815 | 203 "class" => EFILE_AUDIO, |
808 | 204 "mime" => "audio/x-mod", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
205 "fext" => "it", |
808 | 206 "test" => "^Impulse Tracker module", |
207 ), | |
208 "PTM" => array( | |
815 | 209 "class" => EFILE_AUDIO, |
808 | 210 "mime" => "audio/x-mod", |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
211 "fext" => "ptm", |
808 | 212 "test" => "^Poly Tracker PTM Module", |
807 | 213 ), |
815 | 214 |
215 "AVI" => array( | |
216 "class" => EFILE_VIDEO, | |
217 "mime" => "video/x-msvideo", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
218 "fext" => "avi", |
815 | 219 ), |
220 "WMV" => array( | |
221 "class" => EFILE_VIDEO, | |
222 "mime" => "video/x-ms-asf", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
223 "fext" => "wmv", |
815 | 224 ), |
225 "MP4" => array( | |
226 "class" => EFILE_VIDEO, | |
227 "mime" => "video/mp4", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
228 "fext" => "mp4", |
815 | 229 ), |
230 "MOV" => array( | |
231 "class" => EFILE_VIDEO, | |
232 "mime" => "video/quicktime", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
233 "fext" => "mov", |
815 | 234 ), |
235 "MKV" => array( | |
236 "class" => EFILE_VIDEO, | |
237 "mime" => "video/x-matroska", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
238 "fext" => "mkv", |
815 | 239 ), |
240 | |
241 // Archives | |
242 "LHA" => array( | |
243 "class" => EFILE_ARCHIVE, | |
244 "mime" => "application/x-lha", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
245 "fext" => "lha", |
1049 | 246 "test" => "^LHarc 1\.x", |
815 | 247 ), |
248 "ZIP" => array( | |
249 "class" => EFILE_ARCHIVE, | |
250 "mime" => "application/zip", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
251 "fext" => "zip", |
815 | 252 ), |
253 "7ZIP" => array( | |
254 "class" => EFILE_ARCHIVE, | |
255 "mime" => "application/x-7z-compressed", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
256 "fext" => "7z", |
815 | 257 ), |
258 "RAR" => array( | |
259 "class" => EFILE_ARCHIVE, | |
260 "mime" => "application/x-rar", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
261 "fext" => "rar", |
815 | 262 ), |
263 "ARJ" => array( | |
264 "class" => EFILE_ARCHIVE, | |
265 "mime" => "application/x-arj", | |
844
fcaafeda4faa
Remove "." from file extensions in filetype table.
Matti Hamalainen <ccr@tnsp.org>
parents:
841
diff
changeset
|
266 "fext" => "arj", |
815 | 267 ), |
268 | |
269 // Final fallback | |
270 "MISC" => array( | |
839
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
271 "class" => EFILE_BINARY, |
815 | 272 "mime" => "application/octet-stream", |
273 "fext" => FALSE, | |
274 ), | |
839
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
275 |
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
276 "TEXT" => array( |
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
277 "class" => EFILE_TEXT, |
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
278 "mime" => "text/plain", |
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
279 "fext" => FALSE, |
43e4a73deaf3
Add some missing file classes.
Matti Hamalainen <ccr@tnsp.org>
parents:
837
diff
changeset
|
280 ), |
807 | 281 ); |
282 | |
283 | |
888 | 284 function stFileError($userID, $adminMsg, $userMsg) |
285 { | |
286 stLogError($adminMsg); | |
287 stError(($userID === 0) ? $adminMsg : $userMsg); | |
288 return FALSE; | |
289 } | |
290 | |
291 | |
807 | 292 // |
535 | 293 // Party infromation system data/variables handling |
294 // | |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
295 function stReloadDisplayVars() |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
296 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
297 global $displayVars, $displayVarsChanged; |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
298 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
299 $displayVars = array(); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
300 $displayVarsChanged = array(); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
301 |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
302 if (($res = stExecSQL("SELECT * FROM display_vars")) !== FALSE) |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
303 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
304 foreach ($res as $row) |
354
1dd598221874
Simplify code by reusing functions from site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
307
diff
changeset
|
305 $displayVars[$row["key"]] = stGetSQLSettingData($row); |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
306 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
307 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
308 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
309 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
310 function stSaveDisplayVars() |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
311 { |
144
c030c3cf0d80
More work on display system.
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
312 global $db, $displayVars, $displayVarsChanged; |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
313 |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
314 foreach (stExecSQL("SELECT * FROM display_vars") as $item) |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
315 if (isset($displayVarsChanged[$item["key"]])) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
316 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
317 $val = $displayVars[$item["key"]]; |
354
1dd598221874
Simplify code by reusing functions from site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
307
diff
changeset
|
318 stExecSQL( |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
535
diff
changeset
|
319 "UPDATE display_vars SET ".stGetSettingSQL($item, $val). |
354
1dd598221874
Simplify code by reusing functions from site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
307
diff
changeset
|
320 " WHERE key=".$db->quote($item["key"])); |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
321 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
322 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
323 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
324 |
407 | 325 function stDisplayUpdated() |
326 { | |
327 stSetDisplayVar("lastUpdate", time()); | |
328 } | |
329 | |
330 | |
454 | 331 function stSetDisplayVarUpd($name, $value) |
332 { | |
333 if (stGetDisplayVar($name) != $value) | |
334 { | |
335 stSetDisplayVar($name, $value); | |
336 stDisplayUpdated(); | |
337 return TRUE; | |
338 } | |
339 else | |
340 return FALSE; | |
341 } | |
342 | |
343 | |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
344 function stGetDisplayVar($name) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
345 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
346 global $displayVars; |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
347 if (isset($displayVars[$name])) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
348 return $displayVars[$name]; |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
349 else |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
350 die("No display var for '".$name."'.\n"); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
351 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
352 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
353 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
354 function stSetDisplayVar($name, $value) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
355 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
356 global $displayVars, $displayVarsChanged; |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
357 if (isset($displayVars[$name])) |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
358 { |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
359 $displayVars[$name] = $value; |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
360 $displayVarsChanged[$name] = TRUE; |
143
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
361 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
362 else |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
363 die("No display var for '".$name."'.\n"); |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
364 } |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
365 |
20893a5442b7
Move some functions to site module, and use them.
Matti Hamalainen <ccr@tnsp.org>
parents:
139
diff
changeset
|
366 |
806 | 367 // |
368 // Like stExecSQL(), but throws error messages to "userspace". | |
369 // | |
484
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
370 function stExecSQLCond($sql, $msg = FALSE) |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
371 { |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
372 global $db; |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
373 if (($res = stDBExecSQL($db, $sql)) !== FALSE) |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
374 { |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
375 if ($msg !== FALSE) |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
376 stSetStatus(200, $msg); |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
377 return $res; |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
378 } |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
379 else |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
380 { |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
381 stSetStatus(902, "Error in SQL execution."); |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
382 return FALSE; |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
383 } |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
384 } |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
385 |
c8591a8fadbc
Move stExecSQLCond() to site module.
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
386 |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
387 function stPrintAttendee($item, $row, $tr, $full, $edit, $eclass = "") |
37 | 388 { |
389 $id = $item["id"]; | |
390 $prefix = "at"; | |
677 | 391 |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
392 if ($tr) |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
393 { |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
394 echo |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
395 " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven").$eclass. |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
396 "\" id=\"attendee".$id."\" ".($full ? "onClick=\"activateAttendee(".$id.")\"" : "").">"; |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
397 } |
677 | 398 |
71
d74fb8cf0062
Adjust attendee output again, we're separating vote keys from there once more. Durr.
Matti Hamalainen <ccr@tnsp.org>
parents:
70
diff
changeset
|
399 echo |
1114 | 400 stGetTDFormTextInput($edit, 20, SQL_LEN_USERNAME, "name", $id, $prefix, $item["name"]). |
401 stGetTDFormTextInput($edit, 20, SQL_LEN_GROUPS, "groups", $id, $prefix, $item["groups"]). | |
71
d74fb8cf0062
Adjust attendee output again, we're separating vote keys from there once more. Durr.
Matti Hamalainen <ccr@tnsp.org>
parents:
70
diff
changeset
|
402 "<td class=\"regtime\">".date("d.m. H:i", $item["regtime"])."</td>". |
1114 | 403 stGetTDFormTextInput($edit, 30, SQL_LEN_ONELINER, "oneliner", $id, $prefix, $item["oneliner"], "autocomplete=\"off\""); |
37 | 404 |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
405 if ($full) |
37 | 406 { |
407 echo | |
1114 | 408 stGetTDFormTextInput($edit, 15, SQL_LEN_EMAIL, "email", $id, $prefix, $item["email"], "autocomplete=\"off\""). |
409 stGetTDFormTextInput($edit, 15, SQL_LEN_REGHOST, "reghost", $id, $prefix, $item["reghost"], "autocomplete=\"off\""); | |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
410 |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
411 if ($edit) |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
412 { |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
413 echo |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
414 "<td>". |
680
c9b96a7b9dc4
Add new helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
679
diff
changeset
|
415 stGetFormButtonElement($prefix."upd".$id, "","", "Upd", "updateAttendee(".$id.")"). |
c9b96a7b9dc4
Add new helper function and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
679
diff
changeset
|
416 stGetFormButtonElement($prefix."del".$id, "","", "Del", "deleteAttendee(".$id.")"). |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
417 "</td>"; |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
418 } |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
419 else |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
420 echo "<td></td>"; |
37 | 421 } |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
422 |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
423 if ($tr) |
674 | 424 echo "</tr>\n"; |
37 | 425 } |
426 | |
427 | |
222 | 428 function stPrintNewsItem($item) |
37 | 429 { |
430 echo | |
592 | 431 "<div class=\"newsItem\" id=\"news".$item["id"]."\">\n". |
37 | 432 " <h2>".chentities($item["title"])."</h2>\n". |
592 | 433 " <div class=\"newsText\">".dhentities($item["text"])."</div>\n". |
593 | 434 " <div class=\"newsAuthor\"><span class=\"newsSig\">-- ".chentities($item["author"])."</span>". |
435 "<span class=\"newsDate\">".date("d M Y / H:i", $item["utime"])."</span></div>\n". | |
37 | 436 "</div>\n"; |
437 } | |
438 | |
439 | |
806 | 440 function stGetTDFormTextInput($edit, $size, $len, $name, $id, $prefix, $value, $extra = "") |
441 { | |
442 return | |
443 "<td class=\"".$name."\">". | |
444 ($edit ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). | |
445 "</td>"; | |
446 } | |
447 | |
448 | |
449 function stGetEditFormTextInput($mode, $title, $size, $len, $name, $id, $prefix, $value, $extra = "") | |
450 { | |
451 return | |
452 "<div class=\"editControl\"><span class=\"editControlTitle\">".chentities($title)."</span>". | |
453 ($mode ? stGetFormTextInput($size, $len, $name, $id, $prefix, $value, $extra) : chentities($value)). | |
454 "</div>"; | |
455 } | |
456 | |
457 | |
458 function stGetEditFormTextArea($mode, $title, $rows, $cols, $name, $id, $prefix, $value, $extra = "") | |
459 { | |
460 return | |
461 "<div class=\"editControl\"><span class=\"editControlTitle\">".chentities($title)."</span>". | |
462 stGetFormTextArea($rows, $cols, $name, $id, $prefix, $value, ($mode ? "" : " disabled=\"disabled\" ").$extra). | |
463 "</div>"; | |
464 } | |
465 | |
466 | |
467 function stConvSwitchMode(&$str, &$mode, $newMode) | |
468 { | |
469 if ($newMode != $mode) | |
470 { | |
471 if ($mode != "") | |
472 $str .= "\n</".$mode.">\n"; | |
473 | |
474 $mode = $newMode; | |
475 | |
476 if ($mode != "") | |
477 $str .= "<".$mode.">\n"; | |
478 } | |
479 } | |
480 | |
481 | |
482 function stConvertCommonDesc($desc, $chent) | |
483 { | |
484 $str = ""; | |
485 $mode = ""; | |
486 | |
487 foreach (explode("\n", $desc) as $line) | |
488 { | |
489 if (preg_match("/^\s*\s*\*(.+)$/", $line, $m)) | |
490 { | |
491 stConvSwitchMode($str, $mode, "ol"); | |
492 $str .= "<li>".($chent ? chentities($m[1]) : $m[1])."</li>\n"; | |
493 } | |
494 else | |
495 if (preg_match("/^\s*-\s*(.+)$/", $line, $m)) | |
496 { | |
497 stConvSwitchMode($str, $mode, "ul"); | |
498 $str .= "<li>".($chent ? chentities($m[1]) : $m[1])."</li>\n"; | |
499 } | |
500 else | |
501 { | |
502 stConvSwitchMode($str, $mode, "p"); | |
503 $str .= ($chent ? chentities($line) : $line); | |
504 } | |
505 } | |
506 | |
507 stConvSwitchMode($str, $mode, ""); | |
508 | |
509 return $str; | |
510 } | |
511 | |
512 | |
513 function stGetNumberSuffix($val) | |
514 { | |
515 switch ($val) | |
516 { | |
517 case 1: return "st"; | |
518 case 2: return "nd"; | |
519 case 3: return "rd"; | |
520 case 4: case 5: case 6: | |
521 case 7: case 8: case 9: return "th"; | |
522 default: return "th"; | |
523 } | |
524 } | |
525 | |
526 | |
69
30a4420e85ab
stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
527 function stGenerateUserKey() |
65
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
528 { |
69
30a4420e85ab
stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
529 global $db; |
1089
00632d30bafe
Implement new settings for making user/votekeys case-insensitive and
Matti Hamalainen <ccr@tnsp.org>
parents:
1072
diff
changeset
|
530 |
00632d30bafe
Implement new settings for making user/votekeys case-insensitive and
Matti Hamalainen <ccr@tnsp.org>
parents:
1072
diff
changeset
|
531 // Default keychars |
99
2169c3177f47
Limit the vote key character space even more.
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
532 $keyChars = "abdefghjkmnpqrstwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
1089
00632d30bafe
Implement new settings for making user/votekeys case-insensitive and
Matti Hamalainen <ccr@tnsp.org>
parents:
1072
diff
changeset
|
533 |
00632d30bafe
Implement new settings for making user/votekeys case-insensitive and
Matti Hamalainen <ccr@tnsp.org>
parents:
1072
diff
changeset
|
534 if (($tmp = stGetSetting("userKeyChars", NULL)) !== NULL) |
00632d30bafe
Implement new settings for making user/votekeys case-insensitive and
Matti Hamalainen <ccr@tnsp.org>
parents:
1072
diff
changeset
|
535 $keyChars = $tmp; |
00632d30bafe
Implement new settings for making user/votekeys case-insensitive and
Matti Hamalainen <ccr@tnsp.org>
parents:
1072
diff
changeset
|
536 |
00632d30bafe
Implement new settings for making user/votekeys case-insensitive and
Matti Hamalainen <ccr@tnsp.org>
parents:
1072
diff
changeset
|
537 if (($tmp = stGetSetting("userKeyCase", NULL)) !== NULL) |
00632d30bafe
Implement new settings for making user/votekeys case-insensitive and
Matti Hamalainen <ccr@tnsp.org>
parents:
1072
diff
changeset
|
538 $keyChars = strtoupper($keyChars); |
65
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
539 |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
540 while (TRUE) |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
541 { |
69
30a4420e85ab
stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
542 // Generate one randomized keycode |
65
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
543 $key = ""; |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
544 for ($n = 0; $n < stGetSetting("userKeyLength"); $n++) |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
545 $key .= $keyChars[rand() % strlen($keyChars)]; |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
546 |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
547 // Check if it already exists, to avoid duplicates |
69
30a4420e85ab
stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
548 // We need custom query code here, because stFetchSQLColumn() |
30a4420e85ab
stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
549 // won't work due to it returning FALSE in error cases. |
1092
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
550 $sql = stPrepareSQL("SELECT * FROM userkeys WHERE key=%s", $key); |
65
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
551 if (($res = @$db->query($sql)) !== FALSE) |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
552 { |
69
30a4420e85ab
stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
553 // Did we get results? |
65
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
554 if ($res->fetchColumn() === FALSE) |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
555 { |
69
30a4420e85ab
stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
556 // Nope, return key |
30a4420e85ab
stGenerateUserKey() simply returns a generated key now (string) or FALSE if
Matti Hamalainen <ccr@tnsp.org>
parents:
66
diff
changeset
|
557 return $key; |
65
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
558 } |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
559 } |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
560 else |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
561 { |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
562 stLogSQLError($sql); |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
563 return FALSE; |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
564 } |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
565 } |
72b22729ae7e
Add function for generating vote keys into site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
566 } |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
567 |
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
568 |
103
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
569 function stCheckRegistrationAvailable() |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
570 { |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
571 global $maxAttendeesHard, $maxAttendeesSoft, $numAttendees; |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
572 |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
573 $maxAttendeesHard = stGetSetting("maxAttendeesHard"); |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
574 $maxAttendeesSoft = stGetSetting("maxAttendeesSoft"); |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
575 if (($numAttendees = stFetchSQLColumn("SELECT COUNT(*) FROM attendees")) === FALSE) |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
576 $numAttendees = 0; |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
577 |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
578 return stChkSetting("allowRegister") && ($maxAttendeesHard <= 0 || $numAttendees < $maxAttendeesHard); |
c6b9041078ec
Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
579 } |
135
eecac02579c4
Move stChop() to site module and rename it to stStrChop().
Matti Hamalainen <ccr@tnsp.org>
parents:
121
diff
changeset
|
580 |
eecac02579c4
Move stChop() to site module and rename it to stStrChop().
Matti Hamalainen <ccr@tnsp.org>
parents:
121
diff
changeset
|
581 |
1014
87eda2e9023f
Back out the stValidateRequestUserData() parameter change, use separate
Matti Hamalainen <ccr@tnsp.org>
parents:
1012
diff
changeset
|
582 function stCheckRequireEmail() |
87eda2e9023f
Back out the stValidateRequestUserData() parameter change, use separate
Matti Hamalainen <ccr@tnsp.org>
parents:
1012
diff
changeset
|
583 { |
87eda2e9023f
Back out the stValidateRequestUserData() parameter change, use separate
Matti Hamalainen <ccr@tnsp.org>
parents:
1012
diff
changeset
|
584 return stGetSetting("requireEMail"); |
87eda2e9023f
Back out the stValidateRequestUserData() parameter change, use separate
Matti Hamalainen <ccr@tnsp.org>
parents:
1012
diff
changeset
|
585 } |
87eda2e9023f
Back out the stValidateRequestUserData() parameter change, use separate
Matti Hamalainen <ccr@tnsp.org>
parents:
1012
diff
changeset
|
586 |
87eda2e9023f
Back out the stValidateRequestUserData() parameter change, use separate
Matti Hamalainen <ccr@tnsp.org>
parents:
1012
diff
changeset
|
587 |
87eda2e9023f
Back out the stValidateRequestUserData() parameter change, use separate
Matti Hamalainen <ccr@tnsp.org>
parents:
1012
diff
changeset
|
588 function stValidateRequestUserData($admin, $id = FALSE) |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
589 { |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
590 $res = TRUE; |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
591 $chk = 0; |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
592 |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
593 if (stChkRequestItem("name", $name, |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
594 array(CHK_ISGT, VT_STR, 0, "Handle / name not given."), |
1114 | 595 array(CHK_LTEQ, VT_STR, SQL_LEN_USERNAME, "Handle / name is too long, should be less than ".SQL_LEN_USERNAME." characters."))) |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
596 $chk++; |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
597 else |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
598 $res = FALSE; |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
599 |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
600 if (stChkRequestItem("groups", $groups, |
1114 | 601 array(CHK_LTEQ, VT_STR, SQL_LEN_GROUPS, "Groups are too long, should be less than ".SQL_LEN_GROUPS." characters."))) |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
602 $chk++; |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
603 else |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
604 $res = FALSE; |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
605 |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
606 if (!stChkRequestItem("oneliner", $oneliner, |
1114 | 607 array(CHK_LTEQ, VT_STR, SQL_LEN_ONELINER, "Oneliner is too long, should be less than ".SQL_LEN_ONELINER." characters."))) |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
608 $res = FALSE; |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
609 |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
610 $email = stGetRequestItem("email"); |
1014
87eda2e9023f
Back out the stValidateRequestUserData() parameter change, use separate
Matti Hamalainen <ccr@tnsp.org>
parents:
1012
diff
changeset
|
611 if (!$admin && stCheckRequireEmail() && strlen($email) < 4) |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
612 { |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
613 stError("E-mail address not given, or it is too short."); |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
614 $res = FALSE; |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
615 } |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
616 |
605
f928b0a6e1af
Better validation for e-mail addresses.
Matti Hamalainen <ccr@tnsp.org>
parents:
598
diff
changeset
|
617 if (strlen($email) > 0 && preg_match("/^[a-z0-9][a-z0-9\+\-\.\%_]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", $email) != 1) |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
618 { |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
619 stError("E-mail address not in proper format."); |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
620 $res = FALSE; |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
621 } |
1015
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
622 else |
1114 | 623 if (strlen($email) > SQL_LEN_EMAIL) |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
624 { |
1114 | 625 stError("E-mail address too long, max ".SQL_LEN_EMAIL." characters."); |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
626 $res = FALSE; |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
627 } |
1015
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
628 else |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
629 if (strlen($email) > 0) |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
630 { |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
631 if ($id !== FALSE) |
1015
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
632 // By another ID, if we are updating an entry |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
633 $sql = stPrepareSQL("SELECT * FROM attendees WHERE id<>%d AND email=%s", $id, $email); |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
634 else |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
635 // Or just exists, if adding |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
636 $sql = stPrepareSQL("SELECT * FROM attendees WHERE email=%s", $email); |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
637 |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
638 if (($data = stFetchSQL($sql)) !== FALSE) |
1015
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
639 { |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
640 stError("Someone with the same e-mail address is already registered."); |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
641 $res = FALSE; |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
642 } |
6e8ae77e1a25
Add better checks for e-mails.
Matti Hamalainen <ccr@tnsp.org>
parents:
1014
diff
changeset
|
643 } |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
644 |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
645 // Check if another user already exists |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
646 if ($chk >= 2) |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
647 { |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
648 if ($id !== FALSE) |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
649 // By another ID, if we are updating an entry |
647
60b51ab059da
Oops, forgot an AND from one SQL clause.
Matti Hamalainen <ccr@tnsp.org>
parents:
646
diff
changeset
|
650 $sql = stPrepareSQL("SELECT * FROM attendees WHERE id<>%d AND name=%s AND groups=%s", $id, $name, $groups); |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
651 else |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
652 // Or just exists, if adding |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
653 $sql = stPrepareSQL("SELECT * FROM attendees WHERE name=%s AND groups=%s", $name, $groups); |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
654 |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
655 if (($data = stFetchSQL($sql)) !== FALSE) |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
656 { |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
657 stError("Someone with the same name and groups is already registered."); |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
658 $res = FALSE; |
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
659 } |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
660 } |
646
2eeca16e9c96
Improve attendee adding/updating data validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
641
diff
changeset
|
661 return $res; |
648 | 662 |
207
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
663 } |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
664 |
e31c42a9b574
Slowly work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
205
diff
changeset
|
665 |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
666 function stGetCompoResultsSQL($mode, $compo, $flags) |
531 | 667 { |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
668 // |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
669 // Act based on competition type |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
670 // |
640
c78e11aa3162
Rename a database field, so that it does not conflict with AJAX request item
Matti Hamalainen <ccr@tnsp.org>
parents:
637
diff
changeset
|
671 switch ($compo["ctype"]) |
531 | 672 { |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
673 case COMPO_NORMAL: |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
674 // |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
675 // "Normal" competition, where results are somehow |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
676 // based on points / voting. |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
677 // |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
678 switch ($mode) |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
679 { |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
680 case VOTE_FREELY: |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
681 $sql = |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
682 "SELECT entries.*,SUM(votes.value) AS votesum ". |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
683 "FROM entries ". |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
684 "LEFT JOIN votes ON votes.entry_id=entries.id"; |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
685 break; |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
686 |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
687 case VOTE_ACTIVATE: |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
688 $sql = |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
689 "SELECT entries.*, ". |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
690 "(SELECT SUM(votes.value) FROM votes ". |
1092
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
691 "LEFT JOIN userkeys ON votes.key_id=userkeys.id ". |
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
692 "WHERE votes.entry_id=entries.id AND userkeys.active<>0) ". |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
693 "AS votesum ". |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
694 "FROM entries"; |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
695 break; |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
696 |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
697 case VOTE_ASSIGN: |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
698 $sql = |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
699 "SELECT entries.*, ". |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
700 "(SELECT SUM(votes.value) FROM votes ". |
1092
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
701 "LEFT JOIN userkeys ON votes.key_id=userkeys.id ". |
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
702 "LEFT JOIN attendees ON userkeys.id=attendees.key_id ". |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
703 "WHERE votes.entry_id=entries.id AND attendees.key_id<>0) ". |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
704 "AS votesum ". |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
705 "FROM entries"; |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
706 break; |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
707 } |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
708 |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
709 $extra = |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
710 "GROUP BY entries.id ". |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
711 "ORDER BY votesum DESC"; |
531 | 712 break; |
713 | |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
714 case COMPO_POINTS: |
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
715 // |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
716 // Points .. |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
717 // |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
718 $sql = "SELECT entries.*,entries.evalue AS votesum FROM entries"; |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
719 $extra = "ORDER BY entries.evalue DESC"; |
531 | 720 break; |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
721 |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
722 case COMPO_ASSIGN: |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
723 // |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
724 // Ascending |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
725 // |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
726 $sql = "SELECT entries.*,entries.evalue AS votesum FROM entries"; |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
727 $extra = "ORDER BY entries.evalue ASC"; |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
728 break; |
531 | 729 } |
730 | |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
731 return $sql." ". |
606 | 732 "WHERE entries.compo_id=".$compo["id"]." ". |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
733 (($flags & RFLAG_DISQUALIFIED) ? "" : "AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0 "). |
623
8e6331d7870d
Some work on compo type handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
734 $extra; |
531 | 735 } |
736 | |
737 | |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
738 function stGetCompoResults($flags) |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
739 { |
1092
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
740 $userKeyMode = stGetSetting("userKeyMode"); |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
741 $out = array(); |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
742 $sql = "SELECT * FROM compos ".(($flags & RFLAG_HIDDEN_COMPOS) ? "" : "WHERE visible<>0 ")."ORDER BY name DESC"; |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
743 if (($res = stExecSQL($sql)) === FALSE) |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
744 return $out; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
745 |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
746 // For each compo that has been set visible |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
747 foreach ($res as $compo) |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
748 { |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
749 // Check if there are any entries for it |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
750 $sql = |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
751 "SELECT COUNT(*) FROM entries ". |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
752 "WHERE compo_id=".$compo["id"]. |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
753 (($flags & RFLAG_DISQUALIFIED) ? "" : " AND (entries.flags & ".EFLAG_DISQUALIFIED.")=0"); |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
754 |
798
b97d4b754bc0
Show also empty compos with RFLAG_HIDDEN_COMPOS.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
755 if (($nentries = stFetchSQLColumn($sql)) !== FALSE && |
b97d4b754bc0
Show also empty compos with RFLAG_HIDDEN_COMPOS.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
756 ($nentries > 0 || ($flags & RFLAG_HIDDEN_COMPOS))) |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
757 { |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
758 // Get voting results by mode |
1092
95b74632cfe2
Rename votekeys table to userkeys, and all related variables and settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
1089
diff
changeset
|
759 $sql = stGetCompoResultsSQL($userKeyMode, $compo, $flags); |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
760 |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
761 $out[$compo["id"]] = $compo; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
762 $out[$compo["id"]]["results"] = array(); |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
763 $prev = FALSE; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
764 $index = 0; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
765 |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
766 foreach (stExecSQL($sql) as $entry) |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
767 { |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
768 if ($entry["votesum"] !== $prev) |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
769 $index++; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
770 |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
771 $entry["position"] = $index; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
772 $out[$compo["id"]]["results"][] = $entry; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
773 |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
774 $prev = $entry["votesum"]; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
775 } |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
776 } |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
777 } |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
778 |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
779 return $out; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
780 } |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
781 |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
782 |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
783 function stGetCompoResultLine($html, $entry, $points, $showAuthor) |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
784 { |
965 | 785 $name = stStrChopPad($entry["name"], 40); |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
786 $author = stStrChopPad($entry["author"], 30); |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
787 |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
788 $out = sprintf(" %s", $html ? chentities($name) : $name); |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
789 |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
790 // Author? |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
791 if ($showAuthor) |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
792 $out .= sprintf(" by %s", $html ? chentities($author) : $author); |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
793 |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
794 // Points? |
698 | 795 if ($points !== FALSE) |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
796 $out .= sprintf(" (%d pts)", $points); |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
797 |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
798 // Add disqualified flag etc. |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
799 if ($entry["flags"] & EFLAG_DISQUALIFIED) |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
800 $out .= " [DISQ]"; |
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
801 |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
802 return $out."\n"; |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
803 } |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
804 |
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
805 |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
806 function stGetCompoResultsASCIIStr($html, $flags) |
511
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
807 { |
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
808 $out = ""; |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
785
diff
changeset
|
809 foreach (stGetCompoResults($flags) as $compo) |
511
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
810 { |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
811 // Output compo title / header |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
812 if ($html) |
511
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
813 { |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
814 $out .= |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
815 "<pre>\n". |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
816 "<b> ".chentities($compo["name"])." </b>\n". |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
817 str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n"; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
818 } |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
819 else |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
820 { |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
821 $out .= |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
822 " ".$compo["name"]."\n". |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
823 str_repeat("=", strlen($compo["name"]) + 2)."-- - .\n\n"; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
824 } |
511
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
825 |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
826 // List results for this compo |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
827 $prev = FALSE; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
828 foreach ($compo["results"] as $entry) |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
829 { |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
830 if ($entry["position"] !== $prev) |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
831 $out .= sprintf("%3d%s.", $entry["position"], stGetNumberSuffix($entry["position"])); |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
832 else |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
833 $out .= " -''-"; |
511
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
834 |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
835 $out .= stGetCompoResultLine($html, $entry, |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
836 ($compo["ctype"] != COMPO_ASSIGN) ? $entry["votesum"] : FALSE, |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
837 ($compo["ctype"] != COMPO_NORMAL) ? $compo["show_authors"] : TRUE); |
511
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
838 |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
839 $prev = $entry["position"]; |
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
840 } |
979 | 841 $out .= |
842 "\n".($compo["notes"] != "" ? "NOTES: ".chentities($compo["notes"])."\n" : ""). | |
843 "\n".($html ? "</pre>\n" : ""); | |
724
fd84eb4d8b74
Refactor compo results code for modularity.
Matti Hamalainen <ccr@tnsp.org>
parents:
721
diff
changeset
|
844 } |
695
dff9b125f774
Work on results printing and remove "show authors" option as it is rather
Matti Hamalainen <ccr@tnsp.org>
parents:
690
diff
changeset
|
845 |
511
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
846 return $out; |
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
847 } |
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
848 |
6fe66ea0e954
Move most of the results code to site module, remove the support for HTML
Matti Hamalainen <ccr@tnsp.org>
parents:
508
diff
changeset
|
849 |
716 | 850 function stGetAttendeeRegistrationSQL() |
851 { | |
852 return stPrepareSQL( | |
853 "INSERT INTO attendees (regtime,name,groups,oneliner,email,reghost) VALUES (%d,%S,%S,%S,%S,%s)", | |
854 time(), "name", "groups", "oneliner", "email", $_SERVER["REMOTE_ADDR"]); | |
855 } | |
856 | |
857 | |
819 | 858 // |
886 | 859 // Filter a path or filename component string |
819 | 860 // |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
861 function stFilterPathComponent($str) |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
862 { |
918 | 863 $tmp = str_replace(array(" / ", "/", "\$", ), array(" of ", " of ", "S", ), $str); |
915
a6b4b7401508
Improve path component filtering.
Matti Hamalainen <ccr@tnsp.org>
parents:
914
diff
changeset
|
864 return preg_replace("/[^a-zA-Z0-9\(\)\,\._-]/", "_", $tmp); |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
865 } |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
866 |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
867 |
886 | 868 // |
869 // Replace or add filename extension | |
870 // | |
885
2ca7f609e480
Allow fext to be FALSE stReplaceFileExt().
Matti Hamalainen <ccr@tnsp.org>
parents:
880
diff
changeset
|
871 function stReplaceFileExt($filename, $fext = FALSE) |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
872 { |
885
2ca7f609e480
Allow fext to be FALSE stReplaceFileExt().
Matti Hamalainen <ccr@tnsp.org>
parents:
880
diff
changeset
|
873 if ($fext === FALSE) |
2ca7f609e480
Allow fext to be FALSE stReplaceFileExt().
Matti Hamalainen <ccr@tnsp.org>
parents:
880
diff
changeset
|
874 return $filename; |
2ca7f609e480
Allow fext to be FALSE stReplaceFileExt().
Matti Hamalainen <ccr@tnsp.org>
parents:
880
diff
changeset
|
875 |
961
d0c49745f27f
Possible fix for certain things!
Matti Hamalainen <ccr@tnsp.org>
parents:
960
diff
changeset
|
876 $dpos = strrpos($filename, "/"); |
d0c49745f27f
Possible fix for certain things!
Matti Hamalainen <ccr@tnsp.org>
parents:
960
diff
changeset
|
877 if (($spos = strrpos($filename, ".")) !== FALSE && |
962 | 878 ($dpos === FALSE || $dpos < $spos)) |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
879 return substr($filename, 0, $spos).$fext; |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
880 else |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
881 return $filename.$fext; |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
882 } |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
883 |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
884 |
886 | 885 // |
886 // Create a path, or URL from specified components | |
887 // | |
880 | 888 function stMakePath($isURL, $hasFilename, $components) |
721
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
889 { |
780
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
890 $res = array(); |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
891 |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
892 // If this is URL, the first component is passed as is |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
893 if ($isURL) |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
894 { |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
895 $res[] = array_shift($components); |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
896 $first = FALSE; |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
897 } |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
898 else |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
899 $first = TRUE; |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
900 |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
901 // Handle each path component |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
902 if (count($components) > 0) |
780
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
903 { |
880 | 904 for ($i = 0; $i < count($components); $i++) |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
905 foreach (explode("/", $components[$i]) as $item) |
780
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
906 { |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
907 if ($item == "..") |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
908 array_pop($res); |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
909 else |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
910 if ($item != "." && ($item != "" || $first)) |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
911 $res[] = stFilterPathComponent($item); |
780
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
912 $first = FALSE; |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
913 } |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
914 } |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
915 |
f8d09e0de027
Properly implement stMakePath() replacing the stub function.
Matti Hamalainen <ccr@tnsp.org>
parents:
774
diff
changeset
|
916 return implode("/", $res); |
721
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
917 } |
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
918 |
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
919 |
891 | 920 function stGetEntryPreviewFile($entry, $compo, $previewPath, $previewURL, $type, $addPath) |
721
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
921 { |
889 | 922 global $fileTypeData; |
923 if (!isset($fileTypeData[$type])) | |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
924 die("Invalid file type: ".$type); |
721
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
925 |
889 | 926 $fileBase = sprintf("%03d.%s", $entry["id"], $fileTypeData[$type]["fext"]); |
891 | 927 $fileName = stMakePath(FALSE, TRUE, array($previewPath, $compo["cpath"], $addPath, $fileBase)); |
721
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
928 |
889 | 929 return array( |
930 "type" => $type, | |
931 "mime" => $fileTypeData[$type]["mime"], | |
932 "file" => $fileName, | |
933 "exists" => @file_exists($fileName), | |
934 "mtime" => @filemtime($fileName), | |
891 | 935 "url" => stMakePath(TRUE, TRUE, array($previewURL, $compo["cpath"], $addPath, $fileBase)), |
889 | 936 ); |
721
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
937 } |
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
938 |
69a829f687a9
Preliminary work for entry previews.
Matti Hamalainen <ccr@tnsp.org>
parents:
716
diff
changeset
|
939 |
891 | 940 function stGetPreviewFileData($compo, $entry, &$pdata) |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
941 { |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
942 global $fileTypeData; |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
943 |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
944 if ($compo === FALSE || $entry === FALSE) |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
945 return FALSE; |
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
946 |
889 | 947 $previewPath = stGetSetting("previewPath"); |
948 $previewURL = stGetSetting("previewURL"); | |
891 | 949 $pdata = array( |
950 "type" => $compo["preview_type"], | |
951 "valid" => TRUE, | |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
952 "exists" => 0, |
891 | 953 "files" => array(), |
954 ); | |
889 | 955 |
897 | 956 if ($entry["preview_id"] != 0 && |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
957 ($efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry["preview_id"])) !== FALSE) |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
958 { |
897 | 959 $pdata["file"] = $efile; |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
960 if (isset($fileTypeData[$efile["filetype"]]["type"])) |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
961 $pdata["type"] = $fileTypeData[$efile["filetype"]]["type"]; |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
962 } |
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
963 else |
969 | 964 if ($entry["file_id"] == 0) |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
965 $pdata["valid"] = $efile = FALSE; |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
966 |
891 | 967 switch ($pdata["type"]) |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
968 { |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
969 case EFILE_IMAGE: |
891 | 970 $pdata["files"]["image"] = stGetEntryPreviewFile( |
971 $entry, $compo, $previewPath, $previewURL, | |
889 | 972 stGetSetting("previewImageType"), ""); |
973 | |
891 | 974 $pdata["files"]["thumb"] = stGetEntryPreviewFile( |
975 $entry, $compo, $previewPath, $previewURL, | |
889 | 976 stGetSetting("previewThumbType"), |
977 stGetSetting("thumbnailSubDir")); | |
978 break; | |
979 | |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
980 case EFILE_AUDIO: |
895 | 981 foreach (stGetSetting("sampleTypes") as $type => $fdata) |
889 | 982 { |
891 | 983 $pdata["files"][$type] = stGetEntryPreviewFile( |
984 $entry, $compo, $previewPath, $previewURL, | |
889 | 985 $type, ""); |
986 } | |
987 break; | |
988 | |
989 default: | |
990 return FALSE; | |
991 } | |
992 | |
969 | 993 foreach ($pdata["files"] as $pkey => $pfile) |
891 | 994 { |
969 | 995 if ($pfile["exists"]) |
996 $pdata["exists"]++; | |
894 | 997 |
969 | 998 if (!$pfile["exists"])// |
999 $pdata["valid"] = FALSE; | |
891 | 1000 } |
1001 | |
1002 return TRUE; | |
1003 } | |
1004 | |
1005 | |
1006 function stPrintPreviewElements($compo, $entry) | |
1007 { | |
1008 if (!stGetPreviewFileData($compo, $entry, $pdata)) | |
1009 return FALSE; | |
1010 | |
1011 switch ($pdata["type"]) | |
889 | 1012 { |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
1013 case EFILE_IMAGE: |
911 | 1014 if ($pdata["exists"] >= 2) |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1015 { |
911 | 1016 if ($pdata["valid"]) |
1017 { | |
1018 echo | |
1019 "<a href=\"".ihentities($pdata["files"]["image"]["url"]). | |
1020 "\" onClick=\"return jsShowPreviewImage('".ihentities($pdata["files"]["image"]["url"])."');\">". | |
1021 "<img class=\"imagePreview\" src=\"".ihentities($pdata["files"]["thumb"]["url"]). | |
1022 "\" alt=\"Preview\" /></a>"; | |
1023 } | |
1024 else | |
1025 { | |
1026 echo | |
1027 "<img class=\"imagePreview\" src=\"".stGetSetting("previewNoImage")."\" alt=\"Preview\" />"; | |
1028 } | |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1029 } |
894 | 1030 else |
1031 { | |
911 | 1032 echo "<div class=\"noPreview\">No preview</div>"; |
894 | 1033 } |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1034 break; |
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1035 |
896
52737f6192bb
More work on preview handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
895
diff
changeset
|
1036 case EFILE_AUDIO: |
932
0c1ab858a3c5
Adjust preview file validity logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
924
diff
changeset
|
1037 if ($pdata["valid"]) |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1038 { |
889 | 1039 echo "<audio controls preload=\"none\" class=\"audioPreview\">"; |
891 | 1040 foreach ($pdata["files"] as $pkey => $pfile) |
889 | 1041 { |
1042 echo "<source src=\"".ihentities($pfile["url"])."\" type=\"".$pfile["mime"]."\">"; | |
1043 } | |
1044 echo "</audio>"; | |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1045 } |
894 | 1046 else |
1047 { | |
911 | 1048 echo "<div class=\"noPreview\">No preview</div>"; |
894 | 1049 } |
774
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1050 break; |
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1051 } |
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1052 } |
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1053 |
d6668b73bb01
Modularize preview HTML stuff into a function stPrintPreviewElements().
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
1054 |
816
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1055 // |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1056 // Probe file type information |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1057 // |
952
ef0d8615ec06
Add silent option to stProbeFileInfo()
Matti Hamalainen <ccr@tnsp.org>
parents:
937
diff
changeset
|
1058 function stProbeFileInfo($filename, $silent = FALSE) |
816
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1059 { |
840 | 1060 global $fileTypeData; |
816
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1061 |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1062 // Get file magic info |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1063 if (($finfo = finfo_open()) === FALSE) |
818 | 1064 { |
874 | 1065 stLogError("Internal error. Failed to initialize finfo()."); |
818 | 1066 return stError("Internal error, failed to probe file."); |
824 | 1067 } |
816
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1068 |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1069 $sdata = @finfo_file($finfo, $filename, FILEINFO_NONE); |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1070 $smime = @finfo_file($finfo, $filename, FILEINFO_MIME_TYPE); |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1071 finfo_close($finfo); |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1072 |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1073 // Did we get anything? |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1074 if ($sdata === FALSE || $smime === FALSE) |
818 | 1075 { |
874 | 1076 stLogError("Failed to probe file '".$filename."'."); |
952
ef0d8615ec06
Add silent option to stProbeFileInfo()
Matti Hamalainen <ccr@tnsp.org>
parents:
937
diff
changeset
|
1077 return stError("Failed to probe file."); |
818 | 1078 } |
816
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1079 |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1080 // Match through our supported types .. |
840 | 1081 foreach ($fileTypeData as $fid => $fdata) |
816
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1082 { |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1083 $fdata["id"] = $fid; |
914 | 1084 if (isset($fdata["test"]) && preg_match("/".$fdata["test"]."/", $sdata)) |
1085 return $fdata; | |
924 | 1086 } |
1087 | |
1088 // Fall back to mime types | |
1089 foreach ($fileTypeData as $fid => $fdata) | |
1090 { | |
957 | 1091 $fdata["id"] = $fid; |
816
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1092 if ($fdata["mime"] == $smime) |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1093 return $fdata; |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1094 } |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1095 |
952
ef0d8615ec06
Add silent option to stProbeFileInfo()
Matti Hamalainen <ccr@tnsp.org>
parents:
937
diff
changeset
|
1096 if ($silent) |
ef0d8615ec06
Add silent option to stProbeFileInfo()
Matti Hamalainen <ccr@tnsp.org>
parents:
937
diff
changeset
|
1097 return FALSE; |
ef0d8615ec06
Add silent option to stProbeFileInfo()
Matti Hamalainen <ccr@tnsp.org>
parents:
937
diff
changeset
|
1098 |
914 | 1099 stLogError("File '".$filename."' (".$smime.") did not match any defined file types [".$sdata."]."); |
1100 return stError("No matching defined file type found for '".$smime."'."); | |
816
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1101 } |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1102 |
95c3e0a1058e
Add new helper function stProbeFileInfo().
Matti Hamalainen <ccr@tnsp.org>
parents:
815
diff
changeset
|
1103 |
869 | 1104 // |
1105 // File table entry adding | |
1106 // | |
1107 function stAddFileEntry($entry, $type, $origName, $fileSize, $fileExt, $fileType, $uploaderID) | |
1108 { | |
1109 $field = (($type == "preview") ? "preview" : "file")."_id"; | |
1110 | |
1111 // Create new file entry | |
1112 $sql = stPrepareSQL( | |
872 | 1113 "INSERT INTO files (origname,filetype,filesize,entry_id,uploader_id,uploadtype,utime) ". |
892
c036db2c64a7
Add missing SQL insert parameter. 10L.
Matti Hamalainen <ccr@tnsp.org>
parents:
891
diff
changeset
|
1114 "VALUES (%s,%s,%d,%d,%d,%s,%d)", |
872 | 1115 $origName, $fileType, $fileSize, $entry["id"], $uploaderID, $type, time()); |
869 | 1116 |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1117 if (($fileID = stExecSQLInsert($sql)) === FALSE) |
869 | 1118 return stFileError($uploaderID, |
1119 "Failed to add new ".$type." file for entry #".$entry["id"]." '".$origName."'.", | |
1120 "Internal error. Failed to add new file."); | |
1121 | |
1122 // Compute storage filename | |
1123 $fileName = sprintf("%03d-%s--%s%s_(%d).%s", | |
1124 $entry["id"], | |
1125 stFilterPathComponent($entry["author"]), | |
1126 stFilterPathComponent($entry["name"]), | |
1127 ($type == "preview" ? "_preview" : ""), | |
1128 $fileID, | |
1129 $fileExt); | |
1130 | |
1131 // Update entry with generated filename | |
1132 $sql = stPrepareSQL("UPDATE files SET filename=%s WHERE id=%d", $fileName, $fileID); | |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1133 if (stExecSQL($sql) === FALSE) |
869 | 1134 return stFileError($uploaderID, |
1135 "Failed to update newly created files entry #".$fileID." with generated filename '".$fileName."'!", | |
1136 "Internal error. Failed to add new file."); | |
1137 | |
1138 // Update entry's reference | |
1139 $sql = stPrepareSQL("UPDATE entries SET ".$field."=%d WHERE id=%d", $fileID, $entry["id"]); | |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1140 if (stExecSQL($sql) === FALSE) |
869 | 1141 return stFileError($uploaderID, |
1142 "Failed to update entry #".$entry["id"]." ".$type." ID!", | |
1143 "Internal error. Failed to add new file."); | |
1144 | |
1145 // Return file entry | |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1146 if (($res = stFetchSQL("SELECT * FROM files WHERE id=".$fileID)) === FALSE) |
869 | 1147 return stFileError($uploaderID, |
1148 "Failed to fetch newly generated files entry #".$fileID, | |
1149 "Internal error. Failed to add new file."); | |
1150 | |
1151 return $res; | |
1152 } | |
1153 | |
1154 | |
1155 // | |
1156 // File upload handling | |
1157 // | |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1158 function stHandleGenericFileUpload($userID) |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1159 { |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1160 global $errorSet; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1161 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1162 // Check basics |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1163 if (!stChkRequestItem("type", $uploadType, |
824 | 1164 array(CHK_TYPE, VT_STR, "Invalid upload type."), |
910 | 1165 array(CHK_ARRAY_VAL, array("entry", "preview"), "Invalid upload type class '%1'.")) |
824 | 1166 || |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1167 !stChkRequestItem("entry_id", $entryID, |
824 | 1168 array(CHK_TYPE, VT_INT, "Invalid entry ID."))) |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1169 return FALSE; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1170 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1171 // Check entry existence |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1172 if (($entry = stFetchSQL("SELECT * FROM entries WHERE id=".$entryID)) === FALSE) |
864
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1173 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1174 "Entry ID #".$entryID." does not exist in the entries table?", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1175 "Entry does not exist??"); |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1176 |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1177 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$entry["compo_id"])) === FALSE) |
864
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1178 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1179 "Compo ID #".$entry["compo_id"]." in entry ID #".$entryID." does not exist!", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1180 "Compo does not exist??"); |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1181 |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1182 // Check target path existence / writability |
880 | 1183 $dstPath = stMakePath(FALSE, FALSE, array(stGetSetting("entryPath"), $compo["cpath"])); |
864
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1184 if (!file_exists($dstPath)) |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1185 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1186 "Path '".$dstPath."' for compo ID #".$entry["compo_id"]." does not exist.", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1187 "The directory for entry's compo does not exist!"); |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1188 |
866 | 1189 $dstPerms = fileperms($dstPath); |
864
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1190 if (($dstPerms & 0x4000) === 0) |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1191 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1192 "Path for entry's compo '".$dstPath."' is not a directory.", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1193 "Path for entry's compo is not a directory?"); |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1194 |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1195 $needPerms = 0x0100 | 0x0080 | 0x0040; |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1196 if (($dstPerms & $needPerms) !== $needPerms) |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1197 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1198 "Path for entry's compo '".$dstPath."' does not have sufficient permissions.", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1199 "Path for entry's compo has no sufficient permissions."); |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1200 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1201 // Check permissions for non-admins |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1202 if ($userID != 0) |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1203 { |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1204 // Check if the user even exists, just in case |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1205 if (($user = stFetchSQL("SELECT * FROM attendees WHERE id=".$userID)) === FALSE) |
864
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1206 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1207 "User ID #".$userID." does not exist??", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1208 "You do not exist. Go away."); |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1209 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1210 if ($entry["owner_id"] != $userID) |
864
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1211 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1212 "User ID #".$userID." attempted to upload file to an entry that is not owned by him (@ ".$_SERVER["REMOTE_ADDR"].")", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1213 "Attempted to upload file to entry not owned by user."); |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1214 } |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1215 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1216 // Check file status data |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1217 $maxFileSize = stGetSetting($uploadType."MaxSize"); |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
1218 |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
1219 $index = $uploadType."ToUpload".$entryID; |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
1220 $fileSize = $_FILES[$index]["size"]; |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
1221 $tmpFilename = $_FILES[$index]["tmp_name"]; |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
1222 $orgFilename = $_FILES[$index]["name"]; |
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
1223 |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1224 if ($fileSize > $maxFileSize) |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1225 stError("File size ".$fileSize." exceeds FAPWeb's size of ".$maxFileSize." bytes for ".$uploadType." uploads."); |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1226 |
959
1b95dcd0b566
Be more lenient about minimum size of uploaded files.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
1227 if ($fileSize < 16) |
1b95dcd0b566
Be more lenient about minimum size of uploaded files.
Matti Hamalainen <ccr@tnsp.org>
parents:
957
diff
changeset
|
1228 stError("File size ".$fileSize." is less than 16 bytes. This can't be right."); |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1229 |
845
123cd6868b1b
Rework file upload backend code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
844
diff
changeset
|
1230 switch ($_FILES[$index]["error"]) |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1231 { |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1232 case UPLOAD_ERR_INI_SIZE: |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1233 stError("File size exceeds PHP's max upload size."); |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1234 break; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1235 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1236 case UPLOAD_ERR_PARTIAL: |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1237 stError("File only partially uploaded."); |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1238 break; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1239 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1240 case UPLOAD_ERR_NO_FILE: |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1241 stError("No file data received!"); |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1242 break; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1243 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1244 case UPLOAD_ERR_NO_TMP_DIR: |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1245 stError("Internal error: Temporary file directory not available!"); |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1246 break; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1247 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1248 case UPLOAD_ERR_CANT_WRITE: |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1249 stError("Internal error: PHP could not write the file to disk."); |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1250 break; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1251 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1252 case UPLOAD_ERR_OK: |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1253 break; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1254 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1255 default: |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1256 stError("Unknown PHP file error occured."); |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1257 break; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1258 } |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1259 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1260 if ($errorSet) |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1261 return FALSE; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1262 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1263 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1264 // Check file properties .. |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1265 if (($fileInfo = stProbeFileInfo($tmpFilename)) === FALSE) |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1266 return FALSE; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1267 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1268 if ($uploadType == "preview" && !isset($fileInfo["type"])) |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1269 return stError("Preview file upload is not one of the supported preview file types."); |
841
f007e63f82d6
Use original filename extension if we can't determine a solid file type.
Matti Hamalainen <ccr@tnsp.org>
parents:
840
diff
changeset
|
1270 |
f007e63f82d6
Use original filename extension if we can't determine a solid file type.
Matti Hamalainen <ccr@tnsp.org>
parents:
840
diff
changeset
|
1271 // Get original extension |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1272 if (($fileExt = $fileInfo["fext"]) === FALSE) |
841
f007e63f82d6
Use original filename extension if we can't determine a solid file type.
Matti Hamalainen <ccr@tnsp.org>
parents:
840
diff
changeset
|
1273 { |
960 | 1274 $fileExt = "bin"; |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1275 if (($epos = strrpos($orgFilename, ".")) !== FALSE) |
960 | 1276 $fileExt = substr($orgFilename, $epos + 1); |
841
f007e63f82d6
Use original filename extension if we can't determine a solid file type.
Matti Hamalainen <ccr@tnsp.org>
parents:
840
diff
changeset
|
1277 } |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1278 |
852 | 1279 // Update current or add new file entry |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1280 if (($fentry = stAddFileEntry($entry, $uploadType, $orgFilename, $fileSize, $fileExt, $fileInfo["id"], $userID)) === FALSE) |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1281 return FALSE; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1282 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1283 // Set permissions before moving the file |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1284 if (chmod($tmpFilename, stGetSetting($uploadType."PathPerms")) === FALSE) |
864
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1285 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1286 "Could not set permissions for uploaded file '".$tmpFilename."'.", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1287 "Internal error. Could not set permissions for uploaded file. Contact site admins."); |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1288 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1289 // Move file to its destination |
880 | 1290 $dstFilename = stMakePath(FALSE, TRUE, array(stGetSetting("entryPath"), $compo["cpath"], $fentry["filename"])); |
1104
0a2117349f46
s/true/TRUE/g; s/false/FALSE/g;
Matti Hamalainen <ccr@tnsp.org>
parents:
1092
diff
changeset
|
1291 if (@move_uploaded_file($tmpFilename, $dstFilename) === FALSE) |
864
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1292 return stFileError($userID, |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1293 "Could not move uploaded file '".$tmpFilename."' to '".$dstFilename."'.", |
16bc6c1029ee
Handle file upload errors more nicely.
Matti Hamalainen <ccr@tnsp.org>
parents:
861
diff
changeset
|
1294 "Internal error. Deploying uploaded file failed! Contact site admins."); |
823
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1295 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1296 return TRUE; |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1297 } |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1298 |
debad9461b00
Add stHandleGenericFileUpload().
Matti Hamalainen <ccr@tnsp.org>
parents:
820
diff
changeset
|
1299 |
797 | 1300 function stNormalizeListSlideOrder($list_id) |
1301 { | |
1302 } | |
1303 | |
1304 | |
1029
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1305 function stAddCompoEntry($compo, $uid) |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1306 { |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1307 switch ($compo["ctype"]) |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1308 { |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1309 case COMPO_NORMAL: |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1310 $sql = stPrepareSQL( |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1311 "INSERT INTO entries (name,author,compo_id,info,notes,preview_type,utime,owner_id) VALUES (%S,%S,%d,%Q,%Q,%D,%d,%d)", |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1312 "name", "author", $compo["id"], "info", "notes", "preview_type", time(), $uid); |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1313 break; |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1314 |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1315 case COMPO_POINTS: |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1316 case COMPO_ASSIGN: |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1317 $sql = stPrepareSQL( |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1318 "INSERT INTO entries (name,compo_id,notes,evalue,utime,owner_id) VALUES (%S,%d,%Q,%D,%d,%d)", |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1319 "name", $compo["id"], "notes", "evalue", time(), $uid); |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1320 break; |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1321 } |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1322 |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1323 return stExecSQLCond($sql, "OK, entry added."); |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1324 } |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1325 |
35a00a986f79
Factorize compo entry adding into stAddCompoEntry().
Matti Hamalainen <ccr@tnsp.org>
parents:
1015
diff
changeset
|
1326 |
1032
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1327 function stDeleteCompoEntry($id) |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1328 { |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1329 // Delete entry itself |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1330 $sql = stPrepareSQL("DELETE FROM entries WHERE id=%d", $id); |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1331 stExecSQLCond($sql, "OK, entry ".$id." deleted."); |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1332 |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1333 // Delete votes for the entry |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1334 $sql = stPrepareSQL("DELETE FROM votes WHERE entry_id=%d", $id); |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1335 stExecSQLCond($sql, "OK, entry ".$id." votes deleted."); |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1336 |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1337 // Mark related files to be deleted |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1338 $sql = stPrepareSQL("UPDATE files SET deleted=%d WHERE entry_id=%d", 1, $id); |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1339 stExecSQLCond($sql, "OK, entry ".$id." files marked."); |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1340 } |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1341 |
9fffc9e7e1b6
Add stDeleteCompoEntry() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1029
diff
changeset
|
1342 |
0 | 1343 ?> |