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