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