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